Posts

Agile in a Nutshell

Image
Agile software development describes a set of principles for software development under which requirements and solutions evolve through the collaborative effort of self-organizing cross-functional teams.It advocates adaptive planning, evolutionary development, early delivery, and continuous improvement, and it encourages rapid and flexible response to change.These principles support the definition and continuing evolution of many software development methods.

How to resolve file corruption after upload through WCF Service.

Recently I Implemented a WCF  Service to upload files. Implementation was fine and even file save to given location successfully, but  when I try to open these files I got error messages saying that the file is not encoded properly or file is too large to open. After searching I got a sample code to overcome that issue. You can check original Implementation in here  http://multipartparser.codeplex.com/ . Thanks Anthony for awesome code implementation.  

Upload Files using WCF Rest Service

1. Interface Class [ServiceContract] public interface IUpload { /// <summary> /// Upload, runs synchronously service side . /// </ summary > /// < param name="token">An application arbitrary piece of data. Can be used for request obfuscation.</ param > /// < param name="data">The data being uploaded.</param> [OperationContract] [WebInvoke(UriTemplate = "upload/{token}", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] void Upload(string token, Stream data); } 2. Service Implementation Class public class UploadDataService : IUpload { public void Upload(string token, Stream data) { StreamToFile(data); } private void StreamToFile(Stream data) { // get full path to and create the directory to save file in ...

Using Sharepoint objects (SPSite| SPWeb) in Sharepoint Hosted WCF service

Recently I Implemented and hosted WCF service inside Sharepoint (_vti_bin folder). so when I try to consume list and other sharepoint related object I got some SPSecurity errors. so normally what we do is something like below  using  ( SPSite  site =  new   SPSite (ProjectInfo.SiteUrl)) { // Your code here } but this approche will give you an error (SPSecurity is unhandled by user code). so to overcome that issue you can use  SPUserToken. SystemAccount when you try to creae a SPSite object or SPWeb object.   using ( SPSite site = new SPSite (ProjectInfo.SiteUrl, SPUserToken .SystemAccount )) { // Your code here } Note : And also use SPSecurity.RunwithElevatedPrivileges  to execute specified method with full control rights even if the current user doesn't have full control.

Deploy and Consume Sharepoint 2010 hosted WCF Service - Part 2

Image
Welcome back, I talked about how to create a HTTPS enable Sharepoint site in the 1st Part of this post series. You can find it here . 1. Create SharePoint WCF in Visual Studio 2010 1.1 Go to Visual studio Go to new project and Select empty Sharepoint 2010 Project. 1.2  Then it will ask you to select a Sharepoint site which you wanna host this Sharepoint Project. so give your Sharepoint site and Check on Deploy as Farm Solution 1.3 Now it's time to add your WCF  component  to your project. by default you cannot directly add a WCF component to your project. so Here I'm going to use CKS Dev component to do that.  1.4 Go to menu bar and select tool. then select on Extenstion manager to Add CKS Dev tool. Search for CKS Dev on online Gallery and Install CKS Dev server component. 1.5 Once you install CKS dev re-start your Visual studio and now you can add WCF components to your solution easily. Select your Project and select on add new Item and select WCF serv...

Deploy and Consume Sharepoint 2010 hosted WCF Service - Part 1

Image
Hosting a WCF service inside Sharepoint is now pretty easy and consume those services are also pretty easy compare with sharepoint. Today I'm going to create a simple SOAP WCF service and I'm going to host it inside Sharepoint Site. ( Note - HTTPS is enable in this Sharepoint site and It uses Claim base authentication) 1. Create HTTPS Sharepoint Web Application and Site Collection. 1.1 Go to Share Point  Central Administration  site and select Application Management  1.2  Select Manage Web application, It will redirect you to Web Application page. From thre select New button to create a new Site. Then Sharepoint will popup a window to create a new Web Application. Here I'm going to keep the most of the settings as it is but i'm going to change following settings Note - Change Authenitication to "Claims Based Authentication" In Authentication section and Select "Yes" for Use Secure Socket Layer in Security Section. Then Press OK to continue...

Recursive Folder Creation method for SharePoint

Image
public static class SPFolderExtensions { /// <summary> /// Ensure SPFolder /// </summary> /// <param name="web"></param> /// <param name="listTitle"></param> /// <param name="folderUrl"></param> /// <returns></returns> public static SPFolder CreateFolder(this SPWeb web, string listTitle, string folderUrl) { if (string.IsNullOrEmpty(folderUrl)) { throw new ArgumentNullException("folderUrl"); } var list = web.Lists.TryGetList(listTitle); return CreateFolderInternal(list, list.RootFolder, folderUrl); } /// <summary> /// Creates the folder internal. /// </summary> /// <param name="list">The list.</param> /// <param name="parentFolder">The parent folder.</param> ...