locked
ServerApplicationContext? RRS feed

  • Question

  • Hello,

    Is it possible to use the new ServerApplicationContext which comes with HTML Preview 2 also in Silverlight projects?

    If yes how to use it there?

    robert

    Thursday, December 13, 2012 3:13 PM

Answers

  • Hi Robert,

    Let me to try to clarify the concept.  As Justin points out, the ServerApplicationContext is a server-side API that is only available on the LightSwitch middle-tier.  It can, however, be used in conjunction with another technology such as WebAPI, MVC, ASPX, etc to interact with it from *any* client.  In the blog I've shown using WebAPI, and you could extend the workflow I describe to talk to the WebAPI endpoint from a Silverlight client pretty easily.

    There is one small hitch to all of this, in that the ServerApplicationContext was introduced in the HTML client preview 2.  If you'd like to use it with your SL client, you'll first need to install the HTML client preview 2, and gesture to "Add Client..." to your existing SL project.  Adding  a client will upgrade your project and allow you to use the ServerApplicationContext.  (We're introducing other, more straightforward ways of upgrading the project soon.)

    I hope this helps.

    Joe

    Friday, December 14, 2012 3:46 PM

All replies

  • As explained in the blog post announcing it, "The ServerApplicationContext API allows server-side code to access the LightSwitch middle-tier’s data workspace and metadata." with the emphasis being added by me. It's a sever side concept. There is no access to it from either client type.

    Justin Anderson, LightSwitch Development Team

    Thursday, December 13, 2012 3:19 PM
    Moderator
  • If I read this:

    To date, the solutions we’ve offered to these scenarios involved custom RIA services or using “dummy” entities to pass messages between the client and middle-tier. It was cumbersome and complex. We’ve added a simple but powerful API to the LightSwitch middle-tier to address some these scenarios in the near-term—the ServerApplicationContext.

    I thought that it means that I need to the workaround with the dummy” entities to pass messages between the client and middle-tier but can use the ServerApplicationContext to communicate from the client with the middle tier?

    robert

    Thursday, December 13, 2012 3:31 PM
  • Hi Robert,

    Let me to try to clarify the concept.  As Justin points out, the ServerApplicationContext is a server-side API that is only available on the LightSwitch middle-tier.  It can, however, be used in conjunction with another technology such as WebAPI, MVC, ASPX, etc to interact with it from *any* client.  In the blog I've shown using WebAPI, and you could extend the workflow I describe to talk to the WebAPI endpoint from a Silverlight client pretty easily.

    There is one small hitch to all of this, in that the ServerApplicationContext was introduced in the HTML client preview 2.  If you'd like to use it with your SL client, you'll first need to install the HTML client preview 2, and gesture to "Add Client..." to your existing SL project.  Adding  a client will upgrade your project and allow you to use the ServerApplicationContext.  (We're introducing other, more straightforward ways of upgrading the project soon.)

    I hope this helps.

    Joe

    Friday, December 14, 2012 3:46 PM
  • Hi Joe,

    thanks for clarifying - it would be usefull to have some samples - that are situations where I need this:

    • load stream from server to display it in a webpage or silverlight control
    • call Stored Procesdures and get return value

    robert

    Friday, December 14, 2012 3:53 PM
  • Hey guys,

    Can't we establish a 2-way communication between the Client View and the Server using SignalR?


    Garth Henderson - Vanguard Business Technology

    Friday, December 14, 2012 5:44 PM
  • Hi Garth,

    Absolutely, SignalR would be a good option for the streaming scenario.  It handles cases where web sockets aren't available--which was going to be my other suggestion.  Robert, there is a walkthrough describing how to use SignalR and Silverlight here. It's not LightSwitch-specific, but everything in the walkthrough can be used as-is in the LS Silverlight client. 

    For the SPROC case, you might try taking the code from the blog entry and replacing the LINQ code with your call to the SPROC.

    I hope this helps.

    Joe


    Friday, December 14, 2012 6:18 PM
  • Friday, December 14, 2012 6:52 PM
  • Hi Paul,

    might this the right approach to solve my problem to convert a word document (BOLB column in the database) at the server to a PDF/XPS and send the stream to the client for displaying in a PDF viewer (Document Toolkit)

    I need this because in a 3 Tier browser LS app I cannot use the object model of word...

    robert

    Friday, December 14, 2012 7:02 PM
  • Hi Robert,

    I have never used the document toolkit, but i would definitely give it a try to use the SignalR-based command table approach.

    Simply foresee a binary array for transporting your pdf in the response class

    partial void MyFirstCommand_Execute()
            {
                Application.HubProxy.Invoke<ResponseParams>("MyCommand",
                    new RequestParams { RequestParam1 = "request 1", RequestParam2 = "request 2" }).ContinueWith((task) =>
                        {
                            var responseparam2 = task.Result.ResponseParam2;
                            this.Details.Dispatcher.BeginInvoke(() =>
                            {
                                this.ShowMessageBox("Thanks for " + responseparam2);
                            });
     
                        });


    paul van bladel

    Friday, December 14, 2012 7:23 PM
  • Hey Paul,

    Thank you for your posts on SignalR.  I'll be digging into SignalR soon.   I need to kick off server side updates and have the Screen wait until the Server Side updates have completed.  

    I also need to figure out a way to have the Task Scheduler kick off server side batch updates and SSRS reports (using SQL Web and Express versions).  All the code is in LS common classes. 

    I recommend First Floor Software ( http://firstfloorsoftware.com/ ).

    We use Doc Toolkit with a generic notes/document storage functionality that is used through all of our screens.   Very lightweight and responsive.   Users love it.

    Also, Koen Zwikstra is a great guy.   He helped me with our VS 2012 migration problems - even though it didn't have anything to do with the Document Toolkit.   He saw that I was distressed from my forum posts and gave me a hand.  With his help I was able to complete our migration and work around the couple of bugs.


    Garth Henderson - Vanguard Business Technology

    Friday, December 14, 2012 8:13 PM
  • Hi Garth,

    Integrating with doc toolkit should be a piece of cake.

    I think that signalR is not just another library. Take a look at the latest post of Scott Gutthri about Asp.net + signalR: 

    http://weblogs.asp.net/scottgu/archive/2012/12/14/announcing-the-asp-net-and-web-tools-2012-2-release-candidate.aspx


    paul van bladel

    Saturday, December 15, 2012 6:59 AM