views:

91

answers:

3

Hi all,

I need to implement a poll mechanism (simple questions with yes/no options) in Silverlight, but I can't use any database. The client says the only available storage is xml files.

Do you think this is a viable option? I'm thinking about dealing with file integrity and any concurrency issues that may arise from this. It would require locking the entire file when a user submitted a response, and the file may get big.

Any suggestions? Thanks.

PS: Lost my previous account on stackoverflow (can't understand why).

A: 

I had looked into this for a previous project, and I believe the only option for server-side data storage in Silverlight is a backend web service. You would have to create something in Asp.net to handle requests from Silverlight for voting, retrieving options, and retrieving votes. Although I believe the best option for this backend would be a database, I suppose you could store this data in XML and retrieve using LINQ-to-XML.

kersny
+1  A: 

Have you considered using separate XML files per user? You could serialize every poll that the user took into a separate object inside the XML. You remove the need for locking, as users aren't sharing a single file, though on the other hand you'd have many small XML files littering the place, and it may be difficult to aggregate them, though it shouldn't be too much of a hassle.

As an example, you could name all the files with some hash of the user's username or something, so you'd have a file like a09r0awegamogm.xml, laid out like so:

<?xml version="1.0" encoding='UTF-8'?>
<poll>
  <title>My First Poll</title>
  <answers>
    <answer>D</answer>
    <answer>C</answer>
    <answer>A</answer>
    <answer>E</answer>
  </answers>
</poll>
B.R.
A: 

Possibilities I see: - go for one file per user/poll and use a background service to agregate the results. - Fire the user's answer into a queue that is read by a background service that produces the agregated xml file with the results. But if you do not have a database you probably also don't have a queuing system...