extjs grid update on database change - extjs

I need info about updating grid when database is changed.
What I have:
A client application in php which uses Extjs to provide interface to db.
What seems to be a problem:
A problem occurs when for example there are two users are using the app. The 1st user changes and commits data to db, the 2nd user isn't able to see the changed data.
Other example is when admin changes data directly in db.
What I'm trying to do:
I need to be able to load changed data to the grid in timely maner. Reloading store is an issue because the data returned is huge (takes few seconds to load) and while the app would be used by hundreds of users at one time it would create quite an overhead.
Can I load only changed rows (can be checked by timestamp)?

There are 2 parts I see in this question:
Q) Can you update only the changed rows?
A) Sure. Find the record (using the store's "find" function), change the appropriate values (using record.set(key, value)) and commit the changes.
Q) Can you synchronize multiple users?
A) You have 2 options. Option #1, you can lock the object so only one user can edit at a time. This is the simplest solution. Option #2, you can add a synchronizing option (via comet would probably be the best option) and synchronize the changes as they occur.

Related

SQL Server: Copy Live Data from View to Table

right now I have a challenge what I'm not sure about how to solve in the best manner. I searched the internet but did not find a suitable solution ...
I want to copy data from a view on a linked server (read only; view has severals sub views and tables) to a table which is located on my database. This View contains live data, basically showing the last 100 occuring events. However, what I need is the whole history of the data shown by the view. As I have just reading permission on that specific view and the admin of the linked server is not able (or willing) to give further rights or change the view, I was wondering what the best way is to copy the view data and basically building up the whole history on my database.
I was thinking about a stored procedure and run it on a schedule, but as the last 100 events can change very quickly, this does not seem like an appropriate approach. Another option would be to build a trigger, which takes new rows an copies them to my table. However, I'm not sure if this would be possible.
I appreciate any hints, tips or impulses.

Cancelling and discard changes in Entity Framework and WPF

I am developing a system where the user have forms to fill and this info is stored in a database. In one of the screens I have the following flow:
Inside a project he can add multiple orders.
Each added order opens a configuration screen which internal information of the order can be set. Also it is possible to add items to the order.
Each added item opens a configuration screen that allows user to set internal informations.
To sum up, the flow is Project -> Order -> Item, where "A -> B" means A contains 0, 1 or more Bs.
This project is being developed using WPF with Entity Framework to manage the database access. I am binding entities from Entity database mapping directly into the screens. This way we have some "advantages" with WPF, as not null fields are painted red, for example. Moreover, the code is much simpler. The entities are only updated (or added) to the database when the project is saved. Therefore, items can be edited, then orders can be edited and they are only saved when the project is saved, since they are dependent of the project ID to be saved.
However, using mapped entities directly has a huge problem: let's say the user edits an Item inside an Order. Then, he edits it again, but this time, instead of pressing "OK", the user presses "Cancel". The changes must be reverted. However, the previous state was lost, since it was not updated in the database and were changed because of WPF binding.
What is the best approach to prevent this problem? I don't know if creating clones work well in Entity Framework. And creating variables that only transfer their values to the object when the confirm command is clicked would be against the MVVM pattern, and would make me lose the "advantages" I have already talked about.
Please help me!
Thanks!

Merging ACCESS projects (transferring a switchboard)

I am enhancing and fixing the forms/queries/VBcode etc. for an access 2007 database. The current version is being actively used and when I am done with my changes I need to transfer in my changes without disrupting the data stored in the tables already in the running mdb.
I'm not entirely sure how to handle the "merge" when the time comes. As an experiment I have a local backup copy of the version I started working on and used the import external Access data option. This imported the new forms, queries, vb, etc. But the only hang up is that the switchboard form isn't the new. Switchboard forms of course are guided by the switchboard manager but I was hoping that all that logic is held inside the form itself somehow. It seems this is not the case. After the import there is a new form of the same name with a number after it as expected, and the correct create/modify date. But when open it looks exactly the same as the old switchboard.
Any ideas?
It sounds to me as if you have both the data and the forms etc in the one database. This is not a good idea at all and if you are updating, it is the ideal time to correct the problem. If you split the database, any updates to forms and code can be simply copied to the user without worrying about the data. You will find some notes here: http://office.microsoft.com/en-us/access-help/split-an-access-database-HA010342026.aspx
The Access switchboard manager uses a table named Switchboard Items to dynamically populate switchboard form pages. You will need to transfer the updated version of that table to make your revised switchboard pages available in the other project.

Real time database query

We have a windows program written in vbasic(i think) and we are re-writing the same program in c#. In the old program there is a grid. When we click any cell and as soon as edit the cell content the data in database is changing. In our new program we couldn't find the way of doing that. So we added some buttons for database actions like update selected cell.
What is the best way to do that?
You can do this in c# too.Use a datagridview and to bind with the database so that change in the grid effect database see here
Out of seeing dozens of legacy ODBC frontends put together in Access I would strongly advice not to commit changes in the database at real time. Instead try to create a lightweight process that helps the users to keep their data's quality high.
If you want this kind of functionality you could have the real time changes saved in a different schema, a set of different tables or with a flag that tells that these rows are unverified edits by the user X.
Rasel already gave you a pointer how to do the functionality in C#.

WPF live Update from database

I am building a multiuser WPF application (requirement is a desktop app), database SQL Server 2008.
There are two types of users.
The first type user will enter a record which would be stored in a table.
The second type user initially will be presented with a listbox with the records from the table. The requirement is that the listbox must be updated live (i.e. if a new record is entered by the first user the listbox must be updated).
Currently I have not yet implemented the Database functionality.
I am currently working with ObservableCollection and simulating this scenario.
I would like to know the best approach for achieving this.
Should i use a timer and keep querying the table? Is there a more efficient way?
Is this even possible (should I switch to ASP.NET?) ?
I would appreciate any suggestions and tips that you may have.
Try using SqlDependency, since it can raise an event (OnChange) in your code when the results of a query would change on the server (as the result of an INSERT or UPDATE from another user or process, for example)
An example of its use on CodeProject for a simple live chat application:
http://www.codeproject.com/KB/database/chatter.aspx

Resources