Exemple #1
0
		private void UpdateProxyForSendLink(IProxy mailItem, string message, List<SendLinkInfo> uploadedFiles, string id)
		{
			mailItem.SetLinkMessage(message);

			foreach (SendLinkInfo sli in uploadedFiles)
			{
				if (0 != mailItem.ContainsAttachment(sli.ContentId))
				{
					//Update existing
					global::Interop.Workshare.Client.NotesProxy.Attachment proxyAttachment = mailItem.GetAttachmentById(sli.ContentId);
					proxyAttachment.SetLink(string.IsNullOrEmpty(sli.Link) ? "" : sli.Link);
					proxyAttachment.SetProcessStatus(AttachmentProcessStatus.ProcessStatus_ReplaceWithLink);
					
					// The displayname of the first item can change if there is a single link for the collection
					proxyAttachment.SetDisplayName(string.IsNullOrEmpty(sli.DisplayName) ? "" : sli.DisplayName);
				}
			}

			if (ShouldAttachSendLinkContentFile())
			{
				SendLinkInfo sli = CreateSendLinkContentFile(uploadedFiles, id);
				global::Interop.Workshare.Client.NotesProxy.Attachment proxyAttachment = new global::Interop.Workshare.Client.NotesProxy.Attachment();
				proxyAttachment.SetFileName(sli.FilePath);
				proxyAttachment.SetDisplayName(sli.DisplayName);
				proxyAttachment.SetProcessStatus(AttachmentProcessStatus.ProcessStatus_New);
				proxyAttachment.SetContentId(Guid.NewGuid().ToString("B")); //B = 32 digits separated by hyphens, enclosed in brace
				proxyAttachment.SetContentItemIndex(-1); // -1 = At end of message
				mailItem.AddAttachment(proxyAttachment);
			}
		}
        internal void UpdateProxyAttachments(IProxy mailItem, Workshare.PolicyContent.Attachment[] processedAttachments)
		{
			using (LocalCopyOfFileManager lcofm = new LocalCopyOfFileManager())
			{
				for (int i = 0; i < processedAttachments.Length; ++i)
				{
					//Write processed file to disk
					Workshare.PolicyContent.Attachment serviceAttachment = processedAttachments[i];
				    string tempFileName = lcofm.GetLocalCopyOfFileTarget(serviceAttachment.Name);
                    File.Copy(serviceAttachment.FileName, tempFileName);

					//Find the matching proxy attachment
					if (0 != mailItem.ContainsAttachment(serviceAttachment.Id))
					{
						//Update existing attachment
						NotesProxy.Attachment proxyAttachment = mailItem.GetAttachmentById(serviceAttachment.Id) as NotesProxy.Attachment;
						FileInfo oldFile = new FileInfo(proxyAttachment.GetFileName());
						File.Delete(oldFile.FullName);

						//Copy processed file to original location
						string oldPath = oldFile.DirectoryName;
                        string newFile = Path.Combine(oldFile.DirectoryName, Path.GetFileName(tempFileName));
						File.Copy(tempFileName, newFile, true);

						//Update proxy attachment info
						proxyAttachment.SetFileName(newFile);
						proxyAttachment.SetDisplayName(serviceAttachment.Name);
						proxyAttachment.SetProcessStatus(AttachmentProcessStatus.ProcessStatus_Update);

                        File.Delete(tempFileName);
					}
					else
					{
						//Create a new copy before LCFM deletes the file
						string newFile = Path.Combine(GetWorkshareWorkingDirectory(), serviceAttachment.Name);
                        File.Copy(tempFileName, newFile, true);

						//Add attachment to proxy
						NotesProxy.Attachment proxyAttachment = new NotesProxy.Attachment();
						proxyAttachment.SetFileName(newFile);
						proxyAttachment.SetDisplayName(serviceAttachment.Name);
						proxyAttachment.SetProcessStatus(AttachmentProcessStatus.ProcessStatus_New);
						proxyAttachment.SetContentId(serviceAttachment.Id);
						proxyAttachment.SetContentItemIndex(-1);
						mailItem.AddAttachment(proxyAttachment);

                        File.Delete(tempFileName);
					}
				}
			}
		}