Archive | November, 2011

C# – EpochTime

Snipplet code to convert current date time to epoch time
you may go to http://www.epochconverter.com/ to check the result.

public long GetEpochTime()
        {
            DateTime dtCurTime = DateTime.Now;
            DateTime dtEpochStartTime = Convert.ToDateTime("1/1/1970 00:00:00 AM");
            TimeSpan ts = dtCurTime.Subtract(dtEpochStartTime);

            long epochtime;
            epochtime = ((((((ts.Days * 24) + ts.Hours) * 60) + ts.Minutes) * 60) + ts.Seconds);
            return epochtime;
        }

SharePoint 2010 – return XmlDocument with WCF Rest WebService

Objective: to return XmlDocument from WCF REST WebService via URL.

Creating a WCF WebService is straight forward, but to create a WCF WebService to host under SharePoint 2010 you need extra steps to accomplish.
This is my first time to develop WCF RestFul WebService. Many of you may familiar with REST if you are the SharePoint Developer.

I will attach a zip file of a working solution at the end of this post.

To Create WCF Service

  • New Project -> WCF -> WCF Service Library
  • it will create 2 class files for you. (we need these 2 files)

To Create SharePoint WCF Service

  • New Project -> SharePoint -> Empty SharePoint Project
  • Map ISAPI SharePoint Folder
  • Create a text file and rename it to “BuckOfficesService.svc”
  • Create another text file and rename it to “web.config”
  • Copy 2 cs files from WCF Service Project (Rename them as BuckOfficeService.cs and IBuckOfficesService.cs)
  • Make sure those references added in the project as well
  • Microsoft.SharePoint
  • Microsoft.SharePoint.Client.Runtime
  • Microsoft.SharePoint.Security
  • System.ServiceModel
  • System.ServiceModel.Web


Click it for clear view

 

So I wanted to return a XmlDocument from Rest WCF WebService.
You need to make sure you add [XmlSerializerFormat] in your Interface class (it will return error when you try to run the service) before or after [ServiceContract]

Deploy the solution to your SharePoint Server.
Launch IE with http://localhost/_vti_bin/buckofficesservice.svc/getbuckoffices


You may download the full working source code for HTTP only [here]

To cater for HTTPS, you need to add extra line in web.config (those red highlighted)
Click the image for better view

Incoming search terms:

Ivory Romance @ Malaysia Wedding Fair

Thanks to the Project Car, I have missed out a lot of photo shooting opportunities.
Anyhow, I managed to attend this wedding fair.

Overall, I quite like the lighting setup there, but not the background poster.
As usual, Click the image for 960 x 640 pixel.

Not able to scan through all the photos, only selected photos uploaded because I like the dress.

Related Posts with Thumbnails

Incoming search terms:

Get Adobe Flash player