Silverlight application global data - silverlight

I am re-making a Console game, that my boss made a considerably long time ago, in Silverlight. It's totally text based. In the Console version, each computer that had it installed had its own map, which was divided into a grid of rooms.
What I want to do is make the map global; when anybody runs the Silverlight version, they will all see the same map. There is no changing that goes on in the map, only new rooms being added to the map.
So, currently I'm storing all the data in IsolatedStorage, which is obviously not global. How should I store the data and retrieve it so that everybody playing can see the same map?
If it helps any, the server that it will be hosted on is a linux server, and has MySQL.

See this answer to a person who was trying to do something very similar (he wanted high score data, you want map data): High Scores self contained in .xap
The fact that you are running a linux server complicates things a little - instead of running a WCF or asmx service, you could consider a java based web service, or just make a normal HTTP page that queries the MySQL database and returns data which your Silverlight app can request and consume (this is still a "web service", albeit a very primitive one).

Related

CakePHP Beginner: Advice needed, Everything on a single view or multi part forms

Thanks in advance for any help offered and patience for my current web-coding experience.
Background:
I'm currently attempting to develop an web based application for my family's business. There is a current version of this system I have developed in C#, however I want to get the system web-based and in the process learn cakephp and the MVC pattern.
Current problem:
I'm currently stuck in a controller that's supposed to take care of a PurchaseTicket. This ticket will have an associated customer, line items, totals etc. I've been trying to develop a basic 'add()' function to the controller however I'm having trouble with the following:
I'm creating a view with everything on it: a button for searching customer, a button to add line items, and a save button. Since I'm used to developing desktop applications, I'm thinking that I might be trying to transfer the same logic to web-based. Is this something that would be recommended or do'able?
I'm running into basic problems like 'searching customer'. From the New Ticket page I'm redirecting to the customer controller, searching and then putting result in session variable or posting it back, but as I continue my process with the rest of the required information, I'm ending up with a bit of "spaghetti" code. Should I do a multi part form? If I do I break the visual design of the application.
Right now I ended up instantiating my PurchaseTicket model and putting it in a session variable. I did this to save intermediate data however I'm not sure if instantiating a Model is conforming to cakephp standards or MVC pattern.
I apologize for the length, this is my first post as a member.
Thanks!
Welcome to Stack Overflow!
So it sounds like there's a few questions, all with pretty open-ended answers. I don't know if this will end up an answer as such, but it's more information than I could put in a comment, so here I go:
First and foremost, if you haven't already, I'd recommend doing the CakePHP Blog Tutorial to get familiar with Cake, before diving straight into a conversion of your existing desktop app.
Second, get familiar with CakePHP's bake console. It will save you a LOT of time if you use it to get started on the web version of your app.
I can't stress how important it is to get a decent grasp of MVC and CakePHP on a small project before trying to tackle something substantial.
Third, the UI for web apps is definitely different to desktop apps. In the case of CakePHP, nothing is 'running' permanently on the server. The entire CakePHP framework gets instantiated, and dies, with every single page request to the server. That can be a tricky concept when transitioning from desktop apps, where everything is stored in memory, and instances of objects can exist for as long as you want them to. With desktop apps, it's easier to have a user go and do another task (like searching for a customer), and then send the result back to the calling object, the instance of which will still exist. As you've found out, if you try and mimic this functionality in a web app by storing too much information in sessions, you'll quickly end up with spaghetti code.
You can use AJAX (google it if you don't already know about it) to update parts of a page only, and get a more streamlined UI, which it sounds like something you'll be needing to do. To get a general idea of the possibilities, you might want to take a look at Bamboo Invoice. It's not built with CakePHP, but it's built with CodeIgniter, which is another open source PHP MVC framework. It sounds like Bamboo Invoice has quite a few similar functionalities to what you're describing (an Invoice has line items, totals, a customer, etc), so it might help you to get an idea of how you should structure your interface - and if you want to dig into the source code, how you can achieve some of the things you want to do.
Bamboo Invoice uses Ajax to give the app a feel of 'one view with everything on it', which it sounds like you want.
Fourth, regarding the specific case of your Customer Search situation, storing stuff in a session variable probably isn't the way to go. You may well want to use an autocomplete field, which sends an Ajax request to server after each time a character is entered in the field, and displays the list list of suggestions / matching customers that the server sends back. See an example here: http://jqueryui.com/autocomplete/. Implementing an autocomplete isn't totally straight forward, but there should be plenty of examples and tutorials all over the web.
Lastly, I obviously don't know what your business does, but have you looked into existing software that might work for you, before building your own? There's a lot of great, flexible web-based solutions, at very reasonable prices, for a LOT of the common tasks that businesses have. There might be something that gives you great results for much less time and money than it costs to build your own solution.
Either way, good luck, and enjoy CakePHP!

silverlight sometimes work on a mac, sometimes not

I have an issue that is quite confusing for me and was hoping somebody might have some helpful information.
I have a Silverlight 4 app running on Azure (latest SDK). The Silverlight is a typical application using WCF Data Service calls to get and write data to a database. This all works fine on a PC. However, when running on a Mac, any browser, it works for 95% of the application. However, there is one piece that does not work.
My Silverlight application takes information entered into a form, formats a WCF Data Service call to get a record count from a Lucene Index file. The service gets the index count, packages it into one of my defined entities (using the Visual Studio Entity Data Model) and sends the object back from the service to the Silverlight application. The problem though is that it is not returning the correct number. My debugging seems to indicate a 0 is being returned. Again, it only does this for a Mac. The correct number is returned for any browser on any PC. Again, on top of that every other web service call I make from my Silverlight application is returning correctly on the Mac.
Does anybody have any ideas as to what might be happening? Please ask if I have left out any detail.
Thanks
Wanted to update with my solution in case anybody else ever runs into a similar issue.
Data from two of the fields on the form are dates (start and end dates to be specific). I was reading these values, extracting the year and then creating my own DateTime object. This is where the problem occurred. It appears Mac Silverlight formats the DateTime object differently than the PC Silverlight. The PC Silverlight was formatted correctly (1/1/2011 0:00:00) whereas the Mac Silverlight formatted incorrectly (1/1/11 12:00:00 AM -5:00) based on my time zone.
My solution was to format the date myself into a string as it needed to eventually be in string format for passing to the Web Service that queried my Lucene indexn anyway.

Making offline database application on WP7 - find the right way

I need to build an offline database application on WP7.
App is simple - it's about making orders from our clients, then translate it to main server (MS SQL).
Spend a days read about existing techologies - but I'am still confused. Which is right for that project?
Sync Framework.
Looking good, but as I understand - it provides single tables - no reference beetwen them. All the references I have to build on client side. Sad.
Entity FrameWork on server side.
And I have no clue - what can I use on client side. Is there a way to serialize entity object to Isolate Store, then restore it, and continue work with it? May be I can use Sync FrameWork, but scheme will become strange then - kinda one way.)))
Working with WCF & XML - most simple for me. A lot of code and conversion, but in this case I understand the data flow. In other view - I already have app with pure SQL-queries. I wanna be advanced. ))))
Using ext. databases (siaqodb for example).
Which one? siaqodb suppots "Sync provider", but it doesn't support references beetwen objects - so I have to build them by myself? Any gain? I don't know.
Is there another way to build such apps? Point it please.
If this has to be done offline, then I would generally use something like:
storing the minimal amount of the required data within isolated using a WP7 specific database like Sterling
using either a new REST or a new RIA/WCF service with objects/functions you define in order to provide the required data synchronisation
I think this is your option 3?
I've never really liked automatic data synchronisation. I just find it easier to code the sync and deal with the error cases myself - this is especially the case if your wp7 client app uses quite a small footprint of data in relation to the larger main server db.

Silverlight 4, Out of browser, Printing, Automatic updates

I have a very critial business application presently running using Winforms.
The application is a very core UI shell. It accepts input data, calls a webservice on my server to do the computation, displays the results on the winforms app and finally send a print stream to the printer.
Presently the application is deployed using Click-once.
Moving forward, I am trying to contemplate wheather I should move the application into a Silverlight application. Couple of reasons I am thinking silverlight.
Gives clients the feel that it is a cloud based solution.
Can be accessed from any PC. While the clickonce app is able to do this as well, they have to install an app, and when updates are available they have to click "Yes" to update.
The application presently has a drop down list of customers, this list has expanded to over 3000 records. Scrolling through the list is very painful. With Silverlight I am thinking of the auto complete ability.
Out of the browser - this will be handy for those users who use the app daily.
I haven't used Silverlight previous hence looking for some expert advice on a few things:
Printing - does silverlight allow sending raw print data to the printer. The application prints to a Zebra Thermal label printer. I have to send raw bytes to the printer with the commands. Can this be done with SL, or will it always prompt the "Print" dialog?
Out of browser - when SL apps are installed as out of browser, how to updates come through, does the app update automatically or is the user prompted to opt for update?
Printing -- using the PrintDocument API your user will be prompted for a print dialog. Currently using that API there is no way to suppress this. It isn't ideal for high-volume thermal situations (like pharmacies, shipping warehouses, etc.). You could use the trusted application mode and peek out into COM and do whatever you want with the printer.
The update happens when the application asks for it. There is an API to use and, once called, if an update exists it is downloaded -- no prompt to the user as an option. If an update is found you can alert the user to restart or that on the next restart they will have the updated application.
Autocomplete is not something that can only be done in Silverlight. Your ClickOnce app is already out-of-browser. And printing via raw bytes to a thermal printer is something that would not be easily engineered in Silverlight.
Not trying to sound negative, but in sum it sounds like you're better off simply working on enhancing the app that you already have.

How do I create a database on the computer in flash?

I want to create a a application in actionscipt 3.0 that allows the user to listen to music and read descriptions of the music. For this to happen i suppose there should be a database where the textbits and music is located and then flash fetch the info when the correct buttons are pushed. The database will contain up to 100 tracks and textbits.
The application will function on a stand that won't have a connection to the internet.
What is the easiest way to do this in actionscript 3.0?
If any of you are familiar with UML and thinks this might help in understanding the problem, then here is use-case and flow-chart:
alt text http://img135.imageshack.us/img135/1498/flowchart2.jpg
alt text http://img27.imageshack.us/img27/1000/usercase.jpg
Thanks in advance.
The easiest way to do what you're asking is probably to store the files in a directory on the machine the application is going to be running on, and then design an XML structure for storing your data. The XML is easily loaded in to Flash at runtime and is easily edittable.
Your other option would be running a database server on the machine, creating web services that run locally and push/pull the data from the database, and then call those services from your Flash application.
The first option is most definitely the easiest and should be able to provide exactly what you need. The second would be more geared towards a distributed Flash application where you needed a central data repository for the clients.
If you're building an AIR application, you can use the integrated SQLITE database. But, i agree with Justin, the easiest way is to use a XML file.
You can probably consider using "Local Shared Objects" which is a kind of cookie, with bigger capacity (100Kb by default, but you can change it). Compared to other solutions already proposed, it has then advantage of not requiring any web server.

Resources