private void updateFileStatusInDocumentLibrary(int rowId, Utils.FileStatus fileStatus, Lists listService, int fileFormatId, int siteId) { // Get the information about the given list ID/Version //XmlNode listResponse = listService.GetList("PipelineLoader"); XmlNode listResponse = null; bool success = false; while (!success) { // web exception issue try { listResponse = listService.GetList("PipelineLoader"); success = true; } catch { success = false; Thread.Sleep(1000); } } string listID = listResponse.Attributes["ID"].Value; // Provides the GUID id for the actual list string listVersion = listResponse.Attributes["Version"].Value; // Provides the version number for the actual ist // Build the CAML statement string updateCAML = String.Format("<Method ID='1' Cmd='Update'><Field Name='ID'>{0}</Field><Field Name='FileStatus'>{1}</Field><Field Name='FileFormatId'>{2}</Field><Field Name='SiteId'>{3}</Field></Method>", rowId.ToString(), fileStatus, fileFormatId, siteId); // Build the XMLdocument object that contains the update request XmlDocument xmlDoc = new XmlDocument(); XmlElement elBatch = xmlDoc.CreateElement("Batch"); elBatch.SetAttribute("OnError", "Continue"); elBatch.SetAttribute("ListVersion", listVersion); elBatch.InnerXml = updateCAML; //XmlNode ndReturn = listService.UpdateListItems(listID, elBatch); XmlNode ndReturn = null; success = false; while (!success) { // web exception issue try { ndReturn = listService.UpdateListItems(listID, elBatch); success = true; } catch { success = false; Thread.Sleep(1000); } } }
public static void CopyFilesToDocumentLibrary(clsFileList cfl, Utils.FileStatus status, string logProcessName) { Dictionary <string, clsFileList> importFiles = new Dictionary <string, clsFileList>(); importFiles.Add(cfl.FullFilePath, cfl); CopyFilesToDocumentLibrary(importFiles, status, logProcessName); }
public void UpdateFileStatus(int processFileId, Utils.FileStatus fileStatus, int fileFormatId, int siteId) { if (ConfigurationSettings.AppSettings["SkipSharePoint"] != "True") { Lists listService = connectToListsWebService(); int rowId = getRowIdForProcessFileId(processFileId, listService); updateFileStatusInDocumentLibrary(rowId, fileStatus, listService, fileFormatId, siteId); } }
public static void CopyFilesToDocumentLibrary(Dictionary <string, clsFileList> importFiles, Utils.FileStatus status, string logProcessName) { uint count = 0; //Utils.FileStatus status; if (ConfigurationSettings.AppSettings["SkipSharePoint"] != "True") { foreach (clsFileList copyFile in importFiles.Values) { string copyFrom = copyFile.FullFilePath; string copyTo = ConfigurationSettings.AppSettings["SharePointDocumentLibrary"] + copyFile.Filename; // Override ready for import status if we are going for ReadForImport // We might not agree if (status == Utils.FileStatus.ReadyForImport) { //status = GetNextFileStatus(copyFile.Filename); status = GetNextFileStatus(copyFile); } Utils.UploadFile(copyFrom, copyTo, status, copyFile.FileLocationId, copyFile.ProcessFileId, logProcessName); count++; } } Utils.WriteToLog(Utils.LogSeverity.Info, logProcessName, count.ToString() + " file(s) uploaded to SharePoint Document Library"); }
public static void ReadProcessFileList(Dictionary <string, clsFileList> verifyFiles, Utils.FileStatus fileStatus) { WindART_SMIDataContext windARTDataContext = new WindART_SMIDataContext(); var processFilesCollection = from processFiles in windARTDataContext.ProcessFiles where processFiles.FileStatus == (int)fileStatus select processFiles; //Console.WriteLine("just before iterating results from processfile"); //Console.ReadLine(); foreach (var pf in processFilesCollection) { clsFileList fl = new clsFileList(); fl.FullFilePath = pf.Name; //****comment out for production // fl.FullFilePath = pf.Name.Replace(@"D:\", @"\\10.254.13.3\"); //*************************** fl.FileLocationId = (int)pf.FileLocationId; if (pf.FileFormatId != null) { fl.FileFormatId = (int)pf.FileFormatId; } //fl.Encrypted = pf.Encrypted.Equals('Y'); // should be a bool fl.ProcessFileId = pf.ProcessFileId; if (pf.SiteId != null) { fl.SiteId = (int)pf.SiteId; } // never add the same file twice if (!verifyFiles.Keys.Contains(fl.FullFilePath)) { verifyFiles.Add(fl.FullFilePath, fl); } fl.FullFilePath = pf.Name.Replace(@"\\10.254.13.3\", @"D:\"); } // Console.WriteLine("built list of files successfully"); //Console.ReadLine(); }
public static void ReadProcessFileList(Dictionary <string, clsFileList> verifyFiles, Utils.FileStatus fileStatus) { WindART_SMIDataContext windARTDataContext = new WindART_SMIDataContext(); var processFilesCollection = from processFiles in windARTDataContext.ProcessFiles where processFiles.FileStatus == (int)fileStatus select processFiles; foreach (var pf in processFilesCollection) { clsFileList fl = new clsFileList(); fl.FullFilePath = pf.Name; fl.FileLocationId = (int)pf.FileLocationId; if (pf.FileFormatId != null) { fl.FileFormatId = (int)pf.FileFormatId; } //fl.Encrypted = pf.Encrypted.Equals('Y'); // should be a bool fl.ProcessFileId = pf.ProcessFileId; if (pf.SiteId != null) { fl.SiteId = (int)pf.SiteId; } // never add the same file twice if (!verifyFiles.Keys.Contains(fl.FullFilePath)) { verifyFiles.Add(fl.FullFilePath, fl); } } }