次の方法で共有


Contoso Construction - LightSwitch Advanced Development Sample

UPDATE: If you are looking for the Visual Studio 2012 version see: Contoso Construction - LightSwitch Advanced Sample (Visual Studio 2012)

Last week I demonstrated a more advanced sample at TechEd and showed different levels of customization that you can do to your LightSwitch applications as a professional developer by putting your own code into the client and server tiers. You can watch the session where I went through it here: Extending Microsoft Visual Studio LightSwitch Applications(also check out additional resources from my trip report I posted yesterday).

Download SampleDownload the Contoso Construction Sample

This sample demonstrates some of the more advanced code, screen, and data customizations you can do with Visual Studio LightSwitch Beta 2 as a professional developer (you get paid to write code). If you are not a professional developer or do not have any experience with LightSwitch, please see the Getting Started section of the LightSwitch Developer Center for step-by-step walkthroughs and How-to videos. Also please make sure you read the setup instructions below.

Features of this sample include:

  • A “Home screen” with static images and text similar to the Course Manager sample
  • Personalization with My Appointments displayed on log in
  • “Show Map..” links under the addresses in data grids
  • Picture editors
  • Reporting via COM interop to Word
  • Import data from Excel using the Excel Importer Extension
  • Composite LINQ queries to retrieve/aggregate data
  • Custom report filter using the Advanced Filter Control
  • Emailing appointments via SMTP using iCal format in response to events on the save pipeline

 

Building the Sample

You will need Visual Studio LightSwitch Beta 2 installed to run this sample. Before building the sample you will need to set up a few things so that all the pieces work. Once you complete the following steps, press F5 to run the application in debug mode.

1. Install Extensions

You will need the following extensions installed to load this application:
https://code.msdn.microsoft.com/Filter-Control-for-Visual-90fb8e93
https://code.msdn.microsoft.com/Excel-Importer-for-Visual-61dd4a90
And the Bing Map control from the Training Kit:
https://go.microsoft.com/?linkid=9741442

These are .VSIX packages and are also located in the root folder of this sample. Close Visual Studio and then double-click them to install.

2. Set Up Bing Map Control

In order to use the Bing Maps Control and the Bing Maps Web Services, you need a Bing Maps Key. Getting the key is a free and straightforward process you can complete by following these steps:

  • Go to the Bing Maps Account Center at https://www.bingmapsportal.com.
  • Click Sign In, to sign in using your Windows Live ID credentials.
  • If you haven’t got an account, you will be prompted to create one. 
  • Enter the requested information and then click Save.
  • Click the "Create or View Keys" link on the left navigation bar. 
  • Fill in the requested information and click "Create Key" to generate a Bing Maps Key.
  • In the ContosoConstruction application open the MapScreen screen. 
  • Select the Bing Map control and enter the key in the Properties window.

3. Set Up Email Server Settings

When you create, update or cancel an appointment in the system between a customer and an employee emails can be sent. In order for the emailing of appointments to work you must add the correct settings for your SMTP server in the ServerGenerated project's Web.config:

  • Open the ContosoConstruction project and in the solution explorer select "File View".
  • Expand the ServerGenerated project and open the Web.config file.
  • You will see the following settings that you must change to valid values:

    <add key="SMTPServer" value="smtp.mydomain.com" />
    <add key="SMTPPort" value="25" />
    <add key="SMTPUserId" value="admin" />
    <add key="SMTPPassword" value="password" />

  • Run the application and open the employees screen, select Test User and specify a
    valid email address. When you select this user on appointments, emails will be sent here.

Additional Setup Notes:

Personalization:

The system is set to Forms Authentication but if you change it to Windows Authenticaion then in order for the "My Appointments" feature to work you will need to add yourself into the Employees table and specify your domain name as the user name. Make sure to specify a valid email address if you want to email appointments.

Excel Import:

In order to import data on the Materials Catalog screen, copy the StructuralMaterials.xls located in the root of this sample to your My Documents folder first. Then click the Import from Excel button on the screen and select the spreadsheet. You can them map the columns in the spreadsheet to the entity properties and the data from the spreadsheet will appear as new rows on the Materials Catalog. Click Save to send the data to the database.

Additional Resources

You can get a good understanding of more advanced LightSwitch features by working through the LightSwitch Training Kit. If you look under the “LightSwitch Advanced features” section on the right-hand sidebar on the opening page of the kit you will see the demos and labs.

Here are some more resources of Visual Studio LightSwitch to explore:

For questions related to this sample please contact me here. For other LightSwitch questions and troubleshooting please visit the LightSwitch Forums.

Enjoy!

Comments

  • Anonymous
    May 25, 2011
    Thanks for another great sample! Just one note about Filter Control - it's a fantastic control and I hope the handling of the exception I mentioned here: social.msdn.microsoft.com/.../29d6cf79-7935-4b1f-abff-05b18e8a2643 will be fixed soon.

  • Anonymous
    May 25, 2011
    Excellent video, Beth.  Videos like this showing useful examples are terrific--good info, nice presentation.  Keep up the great work.  

  • Anonymous
    May 27, 2011
    Like many people, i have this message when your Contoso application start : "...The database '2F2EAC41F87EB280337C4343CFF80203_L STUDIO 2010PROJECTSCONTOSOCONSTRUCTIONCONTOSOCONSTRUCTIONBINDATAAPPLICATIONDATABASE.MDF' cannot be opened because it is version 661. This server supports version 612 and earlier. A downgrade path is not supported. Cannot open user default database. Login failed. Login failed for user 'HALStealthWise'." I have read your blog "Attaching a Local SQL Server Database Using sqlcmd". But, that don't work. I have also change the database tools option from sqlexpress to HALSQLSERVERR2. Can you help me ?

  • Anonymous
    May 29, 2011
    Hi Beth, thanks for the article. I do have a question about Lightswitch and maybe it's the same for Silverlight.  How come I need to do so many refreshes after I've modified data on a screen.  For example if you add a detail item and go back to the master item the detail don't show unless you do a refresh. Thanks, Dave

  • Anonymous
    June 06, 2011
    Hi Christian, When you install LightSwitch Beta 2 it will install SQL Express edition. You will need that to run the sample. It sounds like you don't have it installed.

  • Anonymous
    June 06, 2011
    Do we have chart controls added for this application to show data?

  • Anonymous
    June 08, 2011
    Make the images in this post clickable. They are unreadable in Firefox or IE9.

  • Anonymous
    August 11, 2011
    This is great. Is there a way to send Task requests to Outlook using a similar function to the way you're sending the appointment requests?

  • Anonymous
    February 07, 2012
    Hi, Beth! Nice post! Is it possible to uso Geo Tags with bing control? Best regards, Ciro.

  • Anonymous
    August 07, 2012
    Have you used the xCode logo from Mac in this? The icon for "Search Projects"

  • Anonymous
    December 10, 2013
    The comment has been removed

  • Anonymous
    December 10, 2013
    @JoeJ - You should be able to just set the smtpclient.EnableSSL = True in the mail helper class. See msdn.microsoft.com/.../system.net.mail.smtpclient.enablessl.aspx

  • Anonymous
    December 10, 2013
    Thanks, that did it. I have something im going to try later when I'm home, but worth asking anyways. Do you think its possible instead of using an address, that using a Lat and Long can be used for map location? I deal with sites in which some are off road, so it'd be helpful to use coordinates.

  • Anonymous
    February 23, 2016
    I'd like to know when this application will be available for Visual Studio 2015 and Lightswitch 2015.Thank you for your kind reply!David.