locked
LightSwitch integration with existing systems RRS feed

  • Question

  • Scenario:  LS web application with external SQL Server db.  In general, users enter data into the web client and LS performs its operations.  By operations I mean that many service operations are fired using the “command table pattern”, such as sending the user an email from the server, creating records in other tables based on parameters contained in the data entered by the user, etc.  We are working to implement a service that will regularly update an orders table within the db with orders and financial information from the accounting system.  Because the service will deposit the data directly into the db (back door), LS will not be aware of the new records and will therefore not perform its operations.  My question is how, at the concept level, would you go about informing LS of these new records so it can do its work?  One idea is to have a boolean field on the orders table that will default to False on the new records and run queries that are triggered by various user interactions (could be a screen loading, a button click, or anything) to find the new records, perform the operations, and toggle the boolean field to True.  I am very interested to hear any better ideas for how to go about this type of integration.  As always, thanks!


    • Edited by Hessc Thursday, February 28, 2013 5:03 AM correct a typo
    Thursday, February 28, 2013 5:03 AM

Answers

  • So I ended up using the screen_Created method to query for new records from the external system.  If new records are detected a message box is displayed informing the user that new records from the accounting system are available.  The code then performs the operations and sets the "InsertedByExternalSystem" property to true.  Seems to work well so far in dev.

    • Marked as answer by Angie Xu Monday, March 11, 2013 12:31 AM
    Friday, March 1, 2013 3:08 AM

All replies

  •  My question is how, at the concept level, would you go about informing LS of these new records so it can do its work?  


    It depends on what you mean with "do its work". When records are inserted directly in the db, indeed, the save pipeline (the _inserting method)will not be triggered. Nonetheless, they are directly visible to the user (after a screen refresh).  

    I think that the boolean "InsertedByExternalSystem", is the only way to make distinction between system-own records and external system records. That field is, as such, part of your extended domain logic.


    paul van bladel

    Thursday, February 28, 2013 5:58 AM
  • Paul,

    Thanks for your reply.  By "do its work" I mean the operations normally triggered within the save pipeline that are processed on the server.  So the second part of the question is how/when would you query for the "InsertedByExternalSystem" in order to run code on the server via "command-table pattern"?  I am thinking of a screen loaded event (or something like that) as I do not want the user to have to initiate this psuedo-sync-up process.  Thanks again.

    Thursday, February 28, 2013 4:42 PM
  • Sorry, you lost me.

    The save pipeline (e.g. on customers) can do all kind of pure data processing on customers and do what I tend to call "side-effect processing". (e.g. sending an email).

    When a specific use case of you app is only interested in "side-effect processing", the command table pattern comes into play: you inform the server to do "side-effect processing" only.

    But, still the command is triggered by the user. 

    Now, please explain what you mean with pseudo-sync-up process?


    paul van bladel

    Thursday, February 28, 2013 8:07 PM
  • Forget what I said about the sync up, I can see why that is confusing.  You have it exactly right.  I want the side-effect processing via the command table.  The command will be triggered by the user, but I am hoping to have the user trigger it unconsciously, rather than by intentionally clicking a button.  I am wondering if I can do this by using a screen's loaded event or something similar?  Thanks for your help.

    Friday, March 1, 2013 2:09 AM
  • So I ended up using the screen_Created method to query for new records from the external system.  If new records are detected a message box is displayed informing the user that new records from the accounting system are available.  The code then performs the operations and sets the "InsertedByExternalSystem" property to true.  Seems to work well so far in dev.

    • Marked as answer by Angie Xu Monday, March 11, 2013 12:31 AM
    Friday, March 1, 2013 3:08 AM