May
19
Written by:
Michael Washington
5/19/2011 5:34 AM
The Document Toolkit for LightSwitch is a commercial LightSwitch control extension. It is one of the first to become available, and is a great example of an extension that allows you to do amazing things easily with LightSwitch.
Click here for directions to install the control extension.
The Resume Application
To run the Document Toolkit for LightSwitch through it’s paces, let’s build a LightSwitch application that will allow us to organize resumes. This application will allow us to enter information from job candidates, and upload and store their Microsoft Word resume in the application. The Document Toolkit for LightSwitch will allow us to see the resumes.
First we create a new LightSwitch Desktop application.
We use the schema above for the table. Notice that WordDocument has a type of Binary.
When we create a List and Details screen, we then have the opportunity to change it to use the Document Toolkit for LightSwitch extension.
Next, we add a button.
Enter the following code for the button:
using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
using Microsoft.LightSwitch.Threading;
using System.Windows.Controls;
namespace LightSwitchApplication
{
public partial class ResumeDatasListDetail
{
partial void UploadDocument_Execute()
{
// Write your code here.
Dispatchers.Main.Invoke(() =>
{
var dlg = new OpenFileDialog();
if (dlg.ShowDialog() == true)
{
// load document into byte[] (== binary)
var data = new byte[dlg.File.Length];
using (var stream = dlg.File.OpenRead())
{
stream.Read(data, 0, data.Length);
}
// assign loaded document to Document property
this.ResumeDatas.SelectedItem.WordDocument = data;
}
});
}
}
}
When we run the application, we can add a new person…
We can then click the Upload Document button…
The document shows up in the Document Viewer (note, it will have a watermark, to remove the watermark, you will need to purchase the product at: http://firstfloorsoftware.com/documenttoolkit).
Click Save to save the record and the document.
16 comment(s) so far...
This is great!
LightSwitch is not even out of beta and there is already a commercial extension available. This is just the beginning and I truely believe that the market for LightSwitch extensions will explode soon.
I can't wait to see what other creative solutions are on their way.
Paul
By Paul Patterson on
5/19/2011 7:17 AM
|
Michael, Thanks. Do you know if it works both in and out of browser? paul.
By paul on
5/20/2011 9:19 AM
|
I was only able to get it to work out of browser, but ask on http://firstfloorsoftware.com
By Michael Washington on
5/20/2011 9:20 AM
|
Fantastic. My boss has been bugging me to find something like this.
By Garth Henderson on
5/21/2011 8:04 AM
|
Thank you for his intellectual contribution
By Luis Mariano Russo on
5/22/2011 2:11 PM
|
Thanks Michael. This is great
By Bhuven on
7/3/2011 9:19 PM
|
great tutorial and love the extension
By Dave on
7/24/2011 4:52 PM
|
Hi Michael
there is problem with Right to left .
In Arabic Lang mode the Word file also RTL that mean Data appear in reverse
how can fix this please ?
By nasser on
8/22/2011 12:04 PM
|
@nasser - You want to contact http://firstfloorsoftware.com
By Michael Washington on
8/22/2011 12:22 PM
|
What is the VB code to do this??
By Kevin Delaney on
9/21/2011 4:20 AM
|
Hi Michael,
I am getting following errors while trying to upload any document.
for PDF : Failed to railed to load package part "1.fpage"(PDF support is experimental. Document may not be rendered correctly)
for Excel : Document conversion failed - Exception from HRESULT : 0x800A03EC
for Word : Document conversion failed - Exception from HRESULT : 0x800A1066
How to solve it?
Please help...
Thanks,
Vivek
By Vivek Vishwakarma on
11/29/2011 5:43 AM
|
@Vivek Vishwakarma - You will want to report any errors at: http://firstfloorsoftware.com/documenttoolkit
By Michael Washington on
11/29/2011 5:44 AM
|
very great! Thaks you so much. it's very helpful for me^^
By nguyen cong vinh on
11/8/2012 9:40 AM
|
Thanks for this however when I try to upload the document it says object reference not set to an instance of an object
By Jason Assaf on
12/3/2014 5:06 PM
|
@Jason Assaf - Please contact the vendor for support. Thank You
By Michael Washington on
12/3/2014 5:06 PM
|
I found the reason why it was saying that I needed to fill out the rest of the data first. Thanks for the tutorial really helped I just wish it would support pdf
By Jason Assaf on
12/8/2014 9:15 PM
|