Hi
Need help in transforming SP object model to client object model:
I am trying to submit infopath form data to the form library programatically which works in my dev server. The same code I would like to have in client object model so that I can submit the infopathform data to my test server from DEV's VS 2010 console application.
Here is the code which I am using to submit infopath data to form library programatically.
infoPathFormData = ms.GetBuffer();
ms.Close();
string rFormSite = @"http://MyCompany.com/MySite/InfopathLibrary";//TEST
using (SPSite site = new SPSite(rFormSite))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPList SpList = web.Lists["InfopathLibrary"];
SPFile file;
SPFolder mylibrary = web.Folders[SpList.Title];
file = mylibrary.Files.Add(String.Concat(ds.Tables[0].Rows[i]["Name"].ToString(), ".xml"), infoPathFormData);
file.Properties["Project Name"] = ds.Tables[0].Rows[i]["Name"].ToString();
file.Properties["UID"] = ds.Tables[0].Rows[i]["UID"].ToString();
file.Properties["Status"] = ds.Tables[0].Rows[i]["Status"].ToString();
file.Properties["Investment"] = ds.Tables[0].Rows[i]["Investment"].ToString();
file.Update();
}
}
ms.Close();
string rFormSite = @"http://MyCompany.com/MySite/InfopathLibrary";//TEST
using (SPSite site = new SPSite(rFormSite))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPList SpList = web.Lists["InfopathLibrary"];
SPFile file;
SPFolder mylibrary = web.Folders[SpList.Title];
file = mylibrary.Files.Add(String.Concat(ds.Tables[0].Rows[i]["Name"].ToString(), ".xml"), infoPathFormData);
file.Properties["Project Name"] = ds.Tables[0].Rows[i]["Name"].ToString();
file.Properties["UID"] = ds.Tables[0].Rows[i]["UID"].ToString();
file.Properties["Status"] = ds.Tables[0].Rows[i]["Status"].ToString();
file.Properties["Investment"] = ds.Tables[0].Rows[i]["Investment"].ToString();
file.Update();
}
}
Please suggest.