How do I load a module catalog from a database in Prism? - wpf

I'm using Prism in my WPF application and up to now, I've been loading the modules via var moduleCatalog = new ConfigurationModuleCatalog();. I'd like to get the module catalog from a database. The Prism documentation indicates that this is possible, but it doesn't go into any details.
Has anyone done this and can provide some guidance?

This is a theoretical possibility, but it's not in any samples I've seen.
Basically what you'd do is either base64 encode the DLLs / Files into the database or zip them up and store them in one blob. You'd download them in your bootstrapper and copy them locally (in a temp directory) and then allows them to load normally from the filesystem using the DirectoryModuleCatalog. If you wanted it to be a bit more elegant, you could write your own ModuleCatalog that encapsulates this logic.
This is very similar to what I do... I actually download a zip file of all of the modules from a website at launch time and unzip them and load them with the DirectoryModuleCatalog.

You can write your own ModuleCatalog implementation by implementing IModuleCatalog. Your implementation can then populate the catalog by any means you define.
You could also use the CreateFromXAML overload that accepts a Stream and implement a webservice that delivers the ModuleCatalog in XAML over HTTP.

Related

Streaming Binary Over a WCF DataService

The idea is pretty simple, I have a project hosting a WCF DataService, and another WPF Project, I'm referring the service in WPF and It's working great, I want to find out if there's a way to stream binary with the service, and get that binary with the WPF and save it on local disk!
Note: The binaries might be bigger than 200MBs
Everything you send by WCF has to be serializable in some way. So, yes, it's possible to find a format in which to serialize your binary file. However, I'm not sure this is the best approach. If your data service is being served over HTTP, and you're able to use ASP.NET, you may want to consider just using a generic handler (.ashx) to send your binary file provided that you do not just have a static link to the file.

DB objects relations visualization

I'm not guru in DBA, so I'll try explain what I want in terms I imagine it.
I have Oracle DB with network devices. each device has ports which has parent device/port
I want some tool which will automaticaly create visual map of this device relations.
Will create "Network Map" based on this relations.
It's would be better if this tool will have some output ready for web publishing, or web based tool from the begging. Also if it will automatically update "picture" as soon as I add new relation/object
From far it looks something like Gource http://youtu.be/E5xPMW5fg48
But not exactly what i need
Hope to get some suggestion.
Thanks in advance!
UPD: found another tool: Gephi
You could try graphviz. It was created specifically for visualising large graphs of network nodes.
It's not out of the box; you'll have to write some code that:
Reads data on the devices & their relationships
Creates the graphviz input file
generates the diagram by calling the graphviz binary.
There are many ways to do that. One of the easiest is to use python with the pydot library.
Note that graphviz generates static images (jpeg / tiff etc.) so you'd have to regenerate on demand.
There are more interactive toolkits available, e.g. protovis / infovis. Both are javascript based and render directly in the browser.
hth.

Scala/Lift Database Connections

I am working on a new web application using Scala with Lift. I want to make it reusable so others might install it on their own servers for their own needs. I come out of a PHP background where it is common practice to create an install form asking for database connection details. This information is stored in a configuration file and used by the rest of the PHP application for connecting to the database. It is extremely convenient for the user because everything is contained within the directory storing the PHP files. They are free to define everything else. My Java/Scala background has all been enterprise work where an application was only intended to run on the database we setup for it. It was not meant to be installed on others' web servers or with different databases.
So my question is how is this typically done for the Java/Scala world? If there are open source applications implementing the mainstream solution, feel free to point me to those too.
I use this to set up the database:
val vendor =
new StandardDBVendor(
Props.get("db.driver") openOr "org.h2.Driver",
Props.get("db.url") openOr "jdbc:h2:mem:db;AUTO_SERVER=TRUE",
Props.get("db.user"),
Props.get("db.password"))
LiftRules.unloadHooks.append(vendor.closeAllConnections_! _)
DB.defineConnectionManager(DefaultConnectionIdentifier, vendor)
The 'Props' referred to will then be (by default) in the file default.props in the props directory in resources.
Updated: This is what I do on servers in production. With 'Props.whereToLook' you provide a function that retrieves an input stream of the configuration. This can be a file as in the example below or you could for example fetch it over network socket.
You will probably let the application to fail with an error dialog.
val localFile = () => {
val file = new File("/opt/jb/myapp/etc/myapp.props")
if (file.exists) Full(new FileInputStream(file)) else Empty
}
Props.whereToLook = () => (("local", localFile) :: Nil)
I am not sure if I am missing your points.
By default, Lift use Scala source file(Boot.scala) to configure all the settings, because Lift doesn't wanna introduce other language into the framework, however you can override some of the configurations using a .properties file.
In Java/Scala world, we use .properties file. It's just a plain text file used for configuration or localization etc,just like text configuration files in PHP.
Lift Framework has it's default support for the external database configuration files, you check out the code in Boot.scala, that's if a .properties file existed, the database will initialized using the connection configuration, if it doesn't, it will use the source file configuration.

How do I put and replace a file using in a client machine in a Silverlight app?

I'm trying to make a Silverlight app which has a local sqlite file to search some data when the app gets offline. I found the following library, http://code.google.com/p/csharp-sqlite/ and it seems pretty nice.
So, what I want to know is, what is a good approach to have and place a file which might be replaced by automatically when the data in a server gets updated at some points?
I've tried to put a file into a folder under the app, but I couldn't access to the file by using csSQLite.sqlite3_open (This method is from the library above). Sorry, I'm pretty new to Silverlight, so my question might be very odd.
Thanks in advance,
yokyo
It doesn't look like this library has been specifially coded for Silverlight. Despite being a pure C# implementation its still likely to assume the full .NET API is available. This is not true in Silverlight.
Specifically Silverlight cannot ordinarily access the local file system. The SQLLite code would need to be modified to understand Silverlight's IsolatedStorage. It would also have to limit its file operations to those that are supported by the streams available Isolated Storage.
The creation of a DB-esq. data source in Silverlight is typically done by create Classes the represent records and collections of records, using LINQ to query them and Xml serialisation into Isolated storage to persist them.
Here is a hacked version of the SQLite code to work with Silverlight, you can use it for some ideas on what to do: http://www.itwriting.com/blog/1695-proof-of-concept-c-sqlite-running-in-silverlight.html

how to include XSD schema files in Silverlight library?

Within a Silverlight library, I need to validate incoming XML against a schema. The schema is composed of 5 interdependent .xsd files; the main file uses "xs:import" to reference all of the others, and there are other references among them.
Assuming that the .xsd files need to be distributed with the library (i.e. not hosted on some well-known external URL), how should I structure my project to include them?
I have found that I can embed them in the library project with build type "Resource" and then load them (individually) using Application.GetResourceStream() and a relative URI with the ";content" flag in it. But if I take this approach, can I validate against the interdependent set of 5 files? What happens when the schema parser tries to resolve the interdependencies?
Or should I embed them with build type "Content" and access the main one with some other sort of URL?
Or???
To summarize: how should I use these 5 .xsd files in my project so that I will be able to validate XML against them?
EDIT: It's not clear whether it's even possible to validate in Silverlight. I spun off a related question.
I cannot say much about Silverlight limitations with respect to validation, but the question itself is more generic - one might want to store .xsd files as resources in a desktop .NET application, for example - so I will answer that part.
You can have full control over resolution of URIs in xs:import by means of XmlSchemaSet.XmlResolver property. Just create your own subclass of XmlResolver, override GetEntity() method, and implement it using GetResourceStream(), or GetManifestResourceStream(), or whichever other way you prefer.

Resources