1

I am at the earliest stage of writing a desktop application for use by multiple users. I am looking for advice on what is the best way to approach this.

The Spec

I will persist my Model in a file which would often be used on a mapped network drive. (It is for the design of roadways and other linear features like railways and streams.)

The various end users need to be able to connect to and edit the file simultaneously. For example, Billy Bob is working on the road named US321 while Rupert is working on I40. The models for each road live in the same file. End users can "claim" any road name, in which only the claimant can edit the given road. Rupert can't edit US321 while Billy Bob has it claimed, but Rupert can read US321 for reference. Once a user is finished editing the road data, he can release the claim and someone else could edit it.

Limitations on Serialization?

My understanding of Serialization is quite limited (see my profile). But it looks to me like there is a one-to-one correlation between objects and serialization files. So if I use serialization to implement this, it would not be possible to claim just a part of it nor would it be possible to update only a part of it. (Is this correct? If not, then I can use Serialization, right?)

The Solution I am Considering

I am considering using SQL Server Express, and I am interested in the community's warnings, corrections, or affirmations on this.

The end users would not have to know that I am using SQL Server Express in the background. (I would even change the file extension to something suitable to my app.) I would load roads into a list, and each road would be "claimable". Claiming a road would mark it in the database for the other instances of the app to react to accordingly, kind of like it is a shared MS Excel file that multiple people can edit simultaneously, but (in the analogy to Excel) being able to lock individual worksheets.

[Edit] See Micah Armantrout's very informative response, below. So now I am wondering about using Microsoft Access as the intermediating db app.

[Edit]

Conclusion

Thanks to everyone for their helpful answers and comments. Micah's answer was very helpful since I did not realize I would be limited to the file being controled by only one server. Although it makes perfect sense now, I had not anticipated it, and if I had gone that route, I would have run aground on it after many hours of working in that direction.

When I first read urbadave's idea, I dismissed it as something I had already considered and not liked. But after thinking it over, it is clearly the simplest approach. I just use a directory like it is a file, but with user-transparency to my my top level sub-objects. But there clearly is an appeal to having my whole model be encapsualted into a single file.

So this is what I have decided to do: Start with just writing to a directory, just as urbadave suggests. Then later test out putting it in a zip directory and using the ZipPackage class to pluck out and insert the individual serialized files (or XML files -- another decision I have to make some day).

  • Paul
philologon
  • 2,093
  • 4
  • 19
  • 35
  • SQL server or any database engine would do the trick, you have row level locking and stuff that would make this possible in much easier way.. –  Apr 18 '12 at 00:59
  • Are all people going to be connected to the same network at the office, or is this case somthing to allow users to go out to the "field" and then return back to the office? The new "off line" abilites of Access 2010 thus might be of great use here. – Albert D. Kallal Apr 19 '12 at 01:34
  • @AlbertD.Kallal Everyone is connected simultaneously. I am not presently contemplating check-out then return. – philologon Apr 20 '12 at 22:25

2 Answers2

4

SQL server will work for what you are looking for but if your going to have multiple users you need to have a machine setup to be a server. It will not do you any good to have sql server express installed on each machine It might be one of the users machines or an actual server with SQL server express you are going to need to set it up to be accessible outside of a current machine to do this follow this tutorial.

If you are using anything past windows XP SP2 you will need to open up the ports of the firewall follow these instructions this is also talked about in the link below.

http://blogs.msdn.com/b/sqlexpress/archive/2005/05/05/415084.aspx

As far as sharing data I mean seeing other peoples work. If you are not wanting to install sql server on a server you can use MS Access I would refer you to a article on which one to use when

http://www.techrepublic.com/article/should-you-use-sql-server-express-edition-or-microsoft-access-for-your-small-business-applications/6140859

Micah Armantrout
  • 6,781
  • 4
  • 40
  • 66
  • Okay. Glad I asked. MS Access does not have this limitation/topology model. Would my plan work if I switch to using Access? – philologon Apr 18 '12 at 01:21
  • You mean as far as using a server ? I should have asked do you want the users to share data ? – Micah Armantrout Apr 18 '12 at 01:23
  • Micah, no, I mean going serverless. I would like for users to be able to read all of the data in the file at any time. We do this in Access all the time, and many, many people have it as part of their standard install. So by "share data?", do you mean have other people's work be visible to everyone? The answer to that is yes. If you meant something else by that, please clarify. – philologon Apr 18 '12 at 01:27
  • Edited to answer your question – Micah Armantrout Apr 18 '12 at 01:37
  • I read the article. This helps. If I am lucky I might have 10 users hitting the file at any one time. Still waiting for others to weigh in (hopefully), but based on your information, it looks like I will go with Access. – philologon Apr 18 '12 at 01:43
  • 1
    Access is *not* reliable in a multi-user scenario. See http://stackoverflow.com/questions/763888/is-ms-access-jet-suitable-for-multiuser-access for some reasons why you should avoid it. – Daniel Mann Apr 18 '12 at 02:32
  • 2
    Access is perfectly reliable in a multi-user scenario as long as you adhere to simple rules. Access is ideal for a very small office. – Fionnuala Apr 19 '12 at 10:19
1

While I have access to a nice database at work, most of my personal programming does not use a database. One of the tricks I've used in the past is that file extensions are meant to carry meaning. In your case, you can exploit file extensions to indicate claims and control writing to the master file.

You're right, you would want to serialize each road object to its own file. The Master File would be the serialization of a collection object that holds all of these individual road objects.

The users select and open these road files. Before opening the file, the user's app re-names the file, adding an extension (perhaps the user's id). This way, you can use directory scans to find claimed and unclaimed files.

The master file is only written to when the user releases their claim on the road they are working on. The user's app opens all the road files, assembles a master object using the road objects and then serializes this object into the master file. When finished, the users app releases the user's claim on the road file by renaming it.

Before writing to the master file, the user's app renames the file, indicating it is about to be written to. If an users app needs to write, it can check to see if the file is renamed, and wait for the file name to be restored to a writable name.

This is a sketch of how I would attack this spec. Good luck.

urbadave
  • 231
  • 1
  • 3
  • 9
  • Thanks urbadave. But what about using ZipPackage instead of a directory as a way to group files? I could twiddle with file attributes as a way to mark when something has been claimed for edit. TIA for opinions on this approach. – philologon Apr 18 '12 at 15:12
  • I wasn't that aware of the OPC, so I looked into it. Thanks for turning me onto it. I think this is an excellent solution! You use the file system to provide write locking. Use OPC to maintain the relationship between document parts and master document. Best of all, it's already built into .NET. – urbadave Apr 19 '12 at 03:48