Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Local Storage and Stored Procedures
Message
 
 
À
26/11/2014 11:00:47
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01611428
Message ID:
01611463
Vues:
25
>>>>>>>>I am working on a web page that will be used to update on-hand quantity of parts in a stock room. The page is very simple: it has a text box Part No and a text box Quantity. The user will scan or type in the Part No text box and then enter the current on-hand quantity in the Quantity box. Then user clicks on Submit button. Submit button will call a stored procedure that will update the database table(s).
>>>>>>>>
>>>>>>>>The program will work in a company Wi-Fi. But it is possible that for a short period (or maybe longer) the Wi-Fi signal will be dropped. So, if the connection is dropped, - ideally - (I would need to check it before calling the stored procedure) I would store the values in the Local Storage. Then, when connection is restored the data from the Local Storage should be processed (transparent to the user).
>>>>>>>>
>>>>>>>>How could this be done, conceptually? That is, how would a program/page call a stored procedure for every pair of values in the Local Storage?
>>>>>>>>TIA
>>>>>>>
>>>>>>>Something like:
saveEntry(partno, quan) {
>>>>>>>            var entry = { PartNo: partno, Quan: quan };
>>>>>>>            if (localStorage['entries'] === undefined) {
>>>>>>>                var entries = new Array;
>>>>>>>            } else {
>>>>>>>                entries = JSON.parse(localStorage['entries']);
>>>>>>>            }
>>>>>>>            entries.push(entry);
>>>>>>>            localStorage['entries'] = JSON.stringify(entries);
>>>>>>>            if (window.navigator.onLine) {
>>>>>>>                //Send entries array to server
>>>>>>>                //On success:
>>>>>>>                localStorage['entries'] = JSON.stringify(new Array);
>>>>>>>            }
>>>>>>>        }
This would send when a new entry was added. If you wanted to send when a connection became available you could add a watch on window.navigator.online and send from there....
>>>>>>
>>>>>>Thank you, Viv. I will try your code. Do I understand that, since you can write this code off the top of your head, you have used Local Storage and it is more or less reliable?
>>>>>
>>>>>I've been working on an app that's used mainly offline. I'm storing half a dozen object collections in localStorage (sometimes up to 300-400 items in total) and it's been fine. Only risk is that the user clears the browser history whilst there's still stuff waiting to be uploaded.
>>>>>
>>>>>Since I'm mainly offline I have a 'Upload' button (which is only enabled when there's a connection) and the user pushes data up when they want. Bear in mind that when you do have a 'online' status it doesn't necessarily mean you can connect to the server - only clear localStorage after a successful upload.
>>>>
>>>>Thank you very much. I am taking notes of all your suggestions. Of course I know you are working with MVC and I am still in the 19th century technology of ASP.NET Web Forms :)
>>>
>>>Hardly using MVC at all - most of my pages are static HTML with data over WebApi......
>>
>>I will need to Google for "data over WebApi"; never done or heard about this technology.
>
>http://msdn.microsoft.com/en-us/library/hh833994(v=vs.108).aspx :-}

I see that Pluralsight has a course on Web Api; should be helpful.

If you don't mind my question (feel free to ignore since you must be busy getting ready for Thanksgiving holiday :), in one or two sentences. Why certain projects are more suitable for static HTML with data over WebApi vs MVC?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform