/// <summary> /// The Execute /// </summary> /// <param name="context">Code Activity Context</param> protected override void Execute(CodeActivityContext context) { var userName = UserName.Get(context); var listName = ListName.Get(context); var filePath = FilePath.Get(context); var isMultiFileUpload = IsMultiFileUpload.Get(context); if (isMultiFileUpload ? System.IO.Directory.Exists(filePath) :System.IO.File.Exists(filePath)) { var securePassword = new SecureString(); foreach (char c in Password.Get(context)) { securePassword.AppendChar(c); } using (var clientContext = new ClientContext(SharePointSiteUri.Get(context))) { clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword); var listItemOperations = new ListItemOperations(clientContext, listName); // Validate whether given List Context Type is Document Library or not // If not Don't upload documents if (listItemOperations.IsDocumentLibrary) { if (isMultiFileUpload) { ProcessDirectory(listItemOperations, filePath); } else { UploadFile(listItemOperations, filePath); } ResponseMessage.Set(context, $"Document Uploaded to {listName} Document Lirary"); } else { ResponseMessage.Set(context, $"Given List {listName} is Not a Document Lirary"); } } } else { ResponseMessage.Set(context, $"File / File Path Not found"); } }
/// <summary> /// The Execute /// </summary> /// <param name="context">Code Activity Context</param> protected override void Execute(CodeActivityContext context) { var userName = UserName.Get(context); var listName = ListName.Get(context); var securePassword = new SecureString(); foreach (char c in Password.Get(context)) { securePassword.AppendChar(c); } using (var clientContext = new ClientContext(SharePointSiteUri.Get(context))) { clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword); var listItemOperations = new ListItemOperations(clientContext, listName); ListItems.Set(context, DataHelperUtility.GetDataTableFromListItemCollection(listItemOperations.GetListItems())); } }
/// <summary> /// The Execute /// </summary> /// <param name="context">Code Activity Context</param> protected override void Execute(CodeActivityContext context) { var userName = UserName.Get(context); var listName = ListName.Get(context); var inputData = InputData.Get(context); if (inputData.Rows.Count > 0) { var securePassword = new SecureString(); foreach (char c in Password.Get(context)) { securePassword.AppendChar(c); } using (var clientContext = new ClientContext(SharePointSiteUri.Get(context))) { clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword); var listItemOperations = new ListItemOperations(clientContext, listName); var columnList = inputData.Columns; foreach (DataRow dataRow in inputData.Rows) { Dictionary <string, string> newItemRecord = new Dictionary <string, string>(); foreach (var column in columnList) { newItemRecord.Add(column.ToString(), dataRow[column.ToString()].ToString()); } if (newItemRecord.Count > 0) { listItemOperations.CreateListItem(newItemRecord); } } ResultMessage.Set(context, $"Records Inserted to SharePoint List, Inserted Items : {inputData.Rows.Count}"); } } else { ResultMessage.Set(context, "DataTable table is empty. Nothing to insert."); } }
protected override void Execute(CodeActivityContext context) { var userName = UserName.Get(context); var password = Password.Get(context); var listName = ListName.Get(context); var camlQueryXml = CamlQueryXml.Get(context); var column = ColumnName.Get(context); var value = updateVaule.Get(context); var securePassword = new SecureString(); foreach (char c in Password.Get(context)) { securePassword.AppendChar(c); } using (var clientContext = new ClientContext(SharePointSiteUri.Get(context))) { clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword); var listItemOperations = new ListItemOperations(clientContext, listName, camlQueryXml); isUpdated.Set(context, listItemOperations.updateListItemColumn(column, value)); } }