using System; |
using System.AddIn; |
using System.Data; |
using System.Data.SqlClient; |
using System.Windows.Forms; |
using System.Xml; |
using SharePointServices; |
using SharePointServices.NorthwindSync; |
using System.IO; |
using System.Net; |
using System.Web; |
|
namespace SharePoint_LIst_Retrieval |
{ |
[System.AddIn.AddIn("Program", Version = "1.0", Publisher = "me", Description = "A simple script to export multiple SharePoint Lists to an XML file.")] |
|
class Program |
{ |
static void Main() |
{ |
String conxString = "Data Source=MyServer; Integrated Security=True;", DocLoc, |
listName, xmlFile; |
SqlDataAdapter oleda = new SqlDataAdapter(); |
DataTable tblItems = new DataTable(); |
Lists listService = new Lists(); |
XmlNode node; |
TextWriter TextDoc; |
|
listService.Credentials = CredentialCache.DefaultNetworkCredentials; |
|
using (SqlConnection sqlConx = new SqlConnection(conxString)) |
{ |
SqlCommand txtCommand = new SqlCommand("SELECT * FROM MyDB.dbo.SharePointLists", sqlConx); |
|
sqlConx.Open(); |
oleda.SelectCommand = txtCommand; |
oleda.Fill(tblItems); |
sqlConx.Close(); |
} |
|
foreach (DataRow row in tblItems.Rows) |
{ |
listService.Url = row["SharePoint_Url"].ToString(); |
listName = row["List_Name"].ToString(); |
DocLoc = row["File_Path"].ToString() + row["File_Name"].ToString() + ".xml"; |
|
node = ListHelper.GetAllListItems(listService, listName); |
|
xmlFile = node.OuterXml; |
|
TextDoc = File.CreateText(DocLoc); |
TextDoc.WriteLine(xmlFile); |
TextDoc.Flush(); |
TextDoc.Close(); |
|
MessageBox.Show("File created: " + DocLoc, "List File Created", MessageBoxButtons.OK); |
|
DocLoc = row["File_Path"].ToString() + row["File_Name"].ToString() + ".xsd"; |
|
xmlFile = node.; <---problem line |
|
TextDoc = File.CreateText(DocLoc); |
TextDoc.WriteLine(xmlFile); |
TextDoc.Flush(); |
TextDoc.Close(); |
|
MessageBox.Show("File created: " + DocLoc, "XSD File Created", MessageBoxButtons.OK); |
} |
} |
} |
} |