Building a Silverlight application upload utility? - c#

This post is really more of a discussion if this is even possible.
There are numerous examples all over the web, but all of those are using asp.net applications and unfortunately I can't go that route. So my goal is to build an upload utility in Silverlight that can be deployed as a CRM 2011 web resource, without using anything Asp.Net related.
I have looked at the Telerik SL upload control, but it appears to require a ServiceURL handler and I'm not sure I can embed something like that within Silverlight and make it work?
I guess I'm looking for some direction here on what my options would be. I don't want to start down one path and run into a brick wall.
Thanks for reading!

Your SL control can upload the bytes of the file as an attachment (in the Notes area) to the entity record. Here is a project on CodePlex that uses SL to upload an image as an attachment:
http://crmattachmentimage.codeplex.com/
Hopefully that will get you pointed in the right direction!

I haven't really looked into the creation of web-resources from silverlight, but considering the web-resource utility would be using the CRM SOAP end-point, I imagine you could do the same from Silverlight.
From Silverlight, you would either need to make a reference to SOAP End-Point url which can be found in the CRM client in Settings -> Customization -> Developer Resources.
Otherwise, you could use the open-source project CrmSilverSoap library which already has all the generated proxy classes as well as a few helper methods for connecting to the various CRM services.
In trying to work with and create the web resources, I'd have a look at the this SDK article which shows to how to use some messages for Creating Web Resources. You will need to make the required modifications to code to enable these messages to be sent via the reference soap end-point in silverlight.

Related

licenses.licx in Class Library vs Web Application

I am not quite sure how to ask this questions, so please forgive me for my ignorance.
I have a ASP.NET Web Application and I have as part of this solution a Project that contains all my library of functions and such. So, for simple explanation, I have two projects in one solution. One is a WEB Application and the other is a Project that gets compiled as a DLL and used within the WEB Application.
Inside my Library, I use GrapeCity Active Reports and a few other libraries that I have purchased and licensed. I have created references in my Library and I call those functions to generate reports and stream them. The WEB Application knows nothing about these controls, how they work or anything. So, lets say I call a function GetReport() that will generate the report and stream out to the client as a PDF.
My Library has the LICENSES.LICX with all the necessary license information in it.
The question is this. Do I have to include the license information in the ASP.NET Application, or will it become part of the DLL and I don't have to worry about the ASP.NET Application?
Thanks
as far as i know the caller assembly/exe of the component should have license embed to it you can refer to this link or this link that show and tell you more about it.

What design pattern should I follow for my web app?

I have an ASP.NET application that provides both front-end services (visualizations) and back-end services (data transformations and outputting some data from back-end SQL databases). I would like the following:
Extensible Back-end
Enable someone else to upload a "plugin" to enable additional REST API to be added
Extensible Front-end: I have the front-end currently with a top URL bar like this:
Category-1 Category-2 Category-3
--App11 ---App21 ---App31
--App12
I am looking for something like this: Assuming that my app has a simple admin panel, when someone uploads a compatible "module" with a manifest file, the app should add that into the main application and add a link to one of the categories based on what the plugin manifest says. Optionally, add a description of this plugin to the main application web page.
Specifically, I am looking for suggestions on the following:
How should the main application be structured?
What should the architecture of the plugin be like?
How do I enable a dashboard like design and let the plugin support it?
I have seen this in Joomla, a content management system but am not sure what is the design paradigm to be followed to enable this. I did a dumb thing and designed my currently (huge) application as separate aspx files linked from a main app. I don't mind rewriting parts of it but without a major rewrite, is it possible to achieve what I desire? Any suggestions on how to achieve this?
A basic solution:
Pretty close to bare-metal, but for back-end, you can create a dll, that contains the logic, and an HttpModule that registers new GenericHandlers to handle requests. Either use web.config to register plugin modules, or use Microsoft.Web.Infrastructure.DynamicModuleHelper to register your http modules at runtime just by copying into your bin without modifying web.config.
PortableAreas:
MVCContrib has a feature called "PortableAreas" that can be used to package UI and backend code into a dll like a plugin. MVC controllers can easily return HTML content for UI, and JSON or XML, to act like a REST web service. Also MVCContrib defines a "Bus" that can be used by plugins to communicate with the host app. Like "Hey, add a new link to categoryXY that points to me!".
Take a look at these blog posts about portable areas: asp net mvc portable areas via mvccontrib (talks about MVC2, but works in MVC3 as well). The latest version can be downloaded via nuget: MvcContrib.Mvc3-ci.
ASP.NET MVC is just "ASP.NET"
Therefore webforms and MVC can live in the same application.
Take a look at this article about "consuming a portable area with a web forms application". Basically it's just adding MVC related dlls and configuration to your existing application, and setting up communication.
Or really take a look at a real CMS,
maybe using one that has a working, documented plugin system is the real solution. Depends on what percent of the features would be part of the "core app", and what percent would be developed as plugins and your needs.

Editing Documents (.doc) in Browsers

I've been developing a web application with asp.net webforms and in this app I have some documents (.doc, .docx, .rtf files), and my client want to edit these files on browser, they want to open a document in an editor, edit, save it on server (without downloading) and close it. I know it's difficult but I would like to know if it's possible or if is there any easy way to do it. We find something like SkyDrive of Microsoft.
PS: We can pay for components if you can suggest something that really works.
Thank you!
IF the clients have Office installed:
I would recommend http://www.webdavsystem.com/server - this allows you to build a "virtual filesystem" (WebDAV which is based on HTTP) which Office can access thus allowing the client to open/edit/save a document (DOCX etc.) via HTTP(S)... it is pure .NET, integrates nicely with ASP.NET and has even a JavaScript accessible API... esp. the upcoming V 3 comes with a wizard which allows you easily to add that funcionality to your ASP.NET application... (just a happy customer, not affilliated).
IF the clients don't have Office installed then it gets tricky:
To really fully support you would need some sort of Silverlight/Flash/ActiveX/JavaApplet which runs in the clients browser and supports the needed editing features...
I am not aware of such production-quality components except the ones from Microsoft - see http://www.microsoft.com/en-us/office365/online-software.aspx
You could integrate them into your web application although they won't offer the full Office feature set in the browser...

Track embedded charts via Google Analytics

I've got a site which produces charts such as the one below
I'd like to encourage visitors to embed the generated graphic on their own sites and blogs. Is it possible to include views for that chart in google Analytics? I want to be able to see when a site embeds the image so that it's tracked in the analytics reports.
I'd envision some API that I can call from the server-side method which generates the PNG, but haven't been able to find anything specific.
Thanks!
This is indeed possible, have a look at the Google Analytics for Mobile Websites documentation. This details how to build a request to google analytics on the server, with quite a few different code samples (C# included).
While this documentation revolves around tracking page views, this concept could be extended to other types of activity you can record in google analytics, such as Events. In your specific situation I think I would want to setup the view of the chart as an Event, as this will not 'mess up' your true traffic (though you could use an advanced segment to exclude the chart traffic if you chose to register them as page views).
The documentation for event tracking is available here. Looking through it should give you a good idea of how you could express viewing your charts. Once you got an idea of how you wanted to track the event in GA, write the javascript and then view the URL (beacon) it generates to send the information to google. You'll be able to use that as a template to send event information from the server.
In regards to actually serving the image, you have a lot of options. If you app is written in MVC, look at the FileResult class (and the asssociated File() method available on the Controller class). If you working in a Webforms app, you will be using a Response.WriteFile() or something to that affect. This wrox article has an example of the idea behind this. The example is for creating a no leaching / hotlinking image handler, but the concept of writing an image to the HttpReponse is the same.

C# plugin for Google Chrome

Can I communicate to Google Chrome in C#?
For writing a chrome plugin for example.
<Spoilers>
Quick short answer: No, because Extensions require JSON, JavaScript, and HTML.
</Spoilers>
Hi Tony,
There are multiple templates on the internet that you can download to build a chrome extension project using Visual Studio.
Downloading one of these templates just gives you the files and folders that you need which I call "the setup".
That won't let you build a Google extension using C#.
Andrey mentioned that there are libraries like Bridge.NET that will compile your code into HTML/JavaScript. That will help you write HTML and JavaScript using C#. You still need a manifest.json file.
I don't recommend that. That library is not designed for Chrome Extensions. Also, you will have to compile the code into JavaScript and store that JavaScript code in a JavaScript file. I recommend using HTML/JavaScript with no compilers when building your Chrome Extension.
You need to keep in mind that there are 3 main parts in a chrome extension. These are:
manifest.json
A JavaScript file
HTML file
There are multiple steps and it's not hard to build a google chrome extension. This link will give you the complete tutorial on developing a chrome extension with detailed explanation. This tutorial installs a template so that you can develop it in Visual Studio just like I mentioned before.
What I have done to address is use Simple Message Host, it will trigger an executable on the local machine that you code in c#, sending stdin messages and listening to stdout messages so you can build this host to use as a bridge, but like I said, it needs to be on your local network at least, and you have to do some editing in the windows registry, so it has its limitations.
But for the system I am working with, this solution worked perfectly because I have a controlled environment that I can set up all these prerequisites.
So, just to clarify, what I did here is:
Create a chrome extension with background.js opening up the listener to the website's javascript.
Add a registry in windows registry pointing to the path of the executable.
Create the executable in C# doing all your logic.
Send a response from the executable to the extension and then back to the website.
There are several guides on how to do this, so I won't detail these steps here so I don't replicate it.
But for the moment, it is the best way to do what you want, if you have control of your environment that is.
So, if your plugin (extension or chrome app) will work on a controlled environment, this is the way to go, otherwise, I would consider something related to ClickOnce perhaps or WebAssembly but that's not fully released yet.
Chrome own extension manager supports extensions written in js and html.
that said, to execute c# code within the extension you have two options:
Compile c# code to javascript code which then can be added as a normal javascript extension to chrome (take a look at scriptsharp)
Use c# as a back-end system. just like most of download managers:
for case 2 you need a c# application installed in client device(or in the cloud) listing to a specific port (using httplistener or self hosted webapi (you can use netcore) which do these steps
Listing to incoming requests
parse request data eg. json and do something with it
return the result to javascript extension which can display it to user or do other things with it.
The topic is quite old, but I'd like to share that sample:
https://github.com/Retyped/Demos/tree/master/ChromeDemo
In a few words, the sample is implemented in C#. The Retyped.chrome NuGet package provides bindings (Chrome API) for Bridge.NET projects. So yes, now you can implement your logic in C#, then C# code will be transparently compiled into JavaScript by Bridge.NET compiler.
With that approach you can build your Chrome extension on top of .NET Framework as well as utilize thousands of JavaScript libraries.

Categories