/// <summary> /// <c>UploadItemUsingCopyService</c> member function /// this uploads the file to sharepoint document library /// </summary> /// <param name="uploadData"></param> /// <param name="property"></param> /// <returns></returns> public static bool UploadItemUsingCopyService(UploadItemsData uploadData, CommonProperties property) { bool result = false; try { SPCopyService.Copy copyws = new Copy(); byte[] fileBytes = null; string[] destinationUrls = null; //Replace "" with empty uploadData.UploadFileName = uploadData.UploadFileName.Replace("\"", " "); if (uploadData.UploadType == TypeOfUploading.Mail) { //Get mail item string tempFilePath = UserLogManagerUtility.RootDirectory + @"\\temp.msg"; if (Directory.Exists(UserLogManagerUtility.RootDirectory) == false) { Directory.CreateDirectory(UserLogManagerUtility.RootDirectory); } Outlook.MailItem omail = uploadData.UploadingMailItem; omail.SaveAs(tempFilePath, Outlook.OlSaveAsType.olMSG); //// load the file into a file stream //Read data to byte fileBytes = File.ReadAllBytes(tempFilePath); uploadData.UploadFileName = uploadData.UploadFileName.Trim() + uploadData.UploadFileExtension; } else { //Set fullname to filename fileBytes = uploadData.AttachmentData; uploadData.UploadFileName = uploadData.UploadFileName.Trim() + uploadData.UploadFileExtension; } // format the destination URL destinationUrls = new string[] { property.LibSite + property.UploadDocLibraryName + "/" + uploadData.UploadFileName }; // to specify the content type FieldInformation ctInformation = new FieldInformation(); ctInformation.DisplayName = "Content Type"; ctInformation.InternalName = "ContentType"; ctInformation.Type = FieldType.Choice; ctInformation.Value = "Your content type"; //FieldInformation[] metadata = { titleInformation }; FieldInformation[] metadata = { }; // execute the CopyIntoItems method copyws.CopyIntoItemsAsync("OutLook", destinationUrls, metadata, fileBytes, uploadData); } catch (Exception) { result = false; } return result; }
public uint GetItem(string Url, out FieldInformation[] Fields, [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")] out byte[] Stream) { object[] results = this.Invoke("GetItem", new object[] { Url}); Fields = ((FieldInformation[])(results[1])); Stream = ((byte[])(results[2])); return ((uint)(results[0])); }
/// <remarks/> public void CopyIntoItemsAsync(string SourceUrl, string[] DestinationUrls, FieldInformation[] Fields, byte[] Stream) { this.CopyIntoItemsAsync(SourceUrl, DestinationUrls, Fields, Stream, null); }
/// <remarks/> public void CopyIntoItemsAsync(string SourceUrl, string[] DestinationUrls, FieldInformation[] Fields, byte[] Stream, object userState) { if ((this.CopyIntoItemsOperationCompleted == null)) { this.CopyIntoItemsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCopyIntoItemsOperationCompleted); } this.InvokeAsync("CopyIntoItems", new object[] { SourceUrl, DestinationUrls, Fields, Stream}, this.CopyIntoItemsOperationCompleted, userState); }
public uint CopyIntoItems(string SourceUrl, string[] DestinationUrls, FieldInformation[] Fields, [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")] byte[] Stream, out CopyResult[] Results) { object[] results1 = this.Invoke("CopyIntoItems", new object[] { SourceUrl, DestinationUrls, Fields, Stream}); Results = ((CopyResult[])(results1[1])); return ((uint)(results1[0])); }