Example #1
0
		internal bool CreateListOfAttachmentsToSendLink(MailItem mailItem, PolicyContent.Attachment[] builtup, RequestManager requestManager, ref List<PolicyContent.Attachment> listAttachments)
		{
			Logger.LogInfo("Matching the original attachments with the rebuilt collection and returning a list of items to SendLink");

			// ensure we have Recordkey of each non-signature attachment
			MessageBodyFormat bodyFormat;
		
            if (UseOutlookDOMForProcessing)
            {
                using (OutlookMailProxy outlookMailProxy = new OutlookMailProxy(mailItem))
                {
                    bodyFormat = OutlookBodyFormat.GetMessageBodyFormat(outlookMailProxy.FormattedBodyText);
                    Logger.LogInfo("Email body format: " + bodyFormat.ToString());
                }
            }
            else
            {
                using (RedemptionMailProxy redemptionMailProxy = new RedemptionMailProxy(mailItem, true, DisableAccessToDOMAttachments))
                {
                    bodyFormat = OutlookBodyFormat.GetMessageBodyFormat(redemptionMailProxy.FormattedBodyText);
                    Logger.LogInfo("Email body format: " + bodyFormat.ToString());
                }
            }


			List<string> recordKeys = new List<string>(GetListofRecordKeys(mailItem, bodyFormat));
			if (recordKeys.Count <= 0)
			{
				Logger.LogDebug("The list of record keys for the email is empty. Assuming the email only contains a signature image so there's nothing to SendLink.");
				return true;
			}

			foreach (PolicyContent.Attachment attachment in builtup)
			{
				// .msg files are flattened before normal Protect processing, so they need to be treated as
				// a special case as their IDs won't match against the processed file list.
				// i.e. att.Id == attachment.Id will not work (see below).
				if (!String.IsNullOrEmpty(attachment.FileName) && attachment.FileName.EndsWith(".msg", StringComparison.InvariantCultureIgnoreCase))
				{
					CustomProperty[] properties = attachment.Properties;
					bool hasRecordKey = false;

					// .msg files should always have a RecordKey, but check anyway for error cases     
					foreach (CustomProperty cp in properties)
					{
						hasRecordKey = (cp.Name == "RecordKey") && (recordKeys.Contains(cp.Value));

						if (hasRecordKey)
						{
							listAttachments.Add(attachment);
							Logger.LogInfo(".msg file added to SendLink attachments list.  Backing file: " + attachment.FileName);
							break;
						}
					}

					if (!hasRecordKey)
					{
						Logger.LogError("RecordKey was not found in the attachment's custom properties when processing .msg: " + attachment.FileName);
						return false;
					}
				}
				else
				{
					foreach (PolicyContent.Attachment att in requestManager.Request.Attachments)
					{
						// Match attachment on mailItem with processed equivalent in builtup collection
						// and add to SendLink list
						if (att.Id == attachment.Id)
						{
							CustomProperty[] properties = att.Properties;
							bool hasRecordKey = false;

							foreach (CustomProperty cp in properties)
							{
								hasRecordKey = (cp.Name == "RecordKey") && (recordKeys.Contains(cp.Value));

								// we don't want signature images
								if (hasRecordKey)
								{
									if ((attachment.Properties == null) || (attachment.Properties.Length == 0))
									{
										attachment.Properties = new[] { cp };
									}

									listAttachments.Add(attachment);
									break;
								}
							}

							if (!hasRecordKey)
							{
								Logger.LogDebug("Unable to find a RecordKey for attachment.  Assuming this is a signature image: " + attachment.Name);
							}
							break;
						}
					}
				}
			}

			return true;
		}
Example #2
0
		private void UpdateHeaderInfo(IProxy mailItem, PolicyContent.Request request)
		{
			Mime.Conversions.Priority priority = XHeaderParser.FromXHeader(PolicyManagerUtils.GetPropertyValue(request.Properties, MailMessagePropertyKeys.xPriority));
			NotesMailPriority notesPriority = (priority == Mime.Conversions.Priority.High ? NotesMailPriority.High : NotesMailPriority.Normal);
			mailItem.SetPriority(notesPriority);
		}
Example #3
0
		internal bool ExecuteSendLinkAction(MailItem mailItem, PolicyContent.Attachment[] builtup, RequestManager requestManager)
		{
			Logger.LogInfo("Executing Secure File Transfer Process");

            Workshare.Analytics.WsAnalyticsListener analyticsListener = new Workshare.Analytics.WsAnalyticsListener();
            analyticsListener.SendSendLinkStatistic();

			if (!requestManager.SendAndProtect && !ShowBccWarning(mailItem, requestManager))
            {
                return false;
            }

            try
            {
                List<PolicyContent.Attachment> listAttachments = new List<PolicyContent.Attachment>();

                if (!CreateListOfAttachmentsToSendLink(mailItem, builtup, requestManager, ref listAttachments))
                {
                    return false;
                }

        
                if (listAttachments.Count <= 0)
                {
                    Logger.LogInfo("List of attachments to SendLink is empty");
                    return true;
                }
                string id = Guid.NewGuid().ToString();
                List<SendLinkInfo> links = GetLinks(requestManager.Response, mailItem, listAttachments, id);
             


                if (links != null && links.Count > 0)
                {
					Logger.LogInfo("Secure File Transfer: removing old attachments");

                    //SetMessageWindowVisible(mailItem, false);

                    //This call will change the mailItem
                    AdjustAttachments(mailItem, links, id);


                    if (!string.IsNullOrEmpty(GetPropertyValue(requestManager.EnforceResponse.ModifiedRequest.Properties,
                                                               MailMessagePropertyKeys.MimeContent)) ||
                        !string.IsNullOrEmpty(GetPropertyValue(requestManager.EnforceResponse.ModifiedRequest.Properties,
                                                               MailMessagePropertyKeys.LargeMimeContent)))
                    {
                        string body;
                        // Need to create a new proxy object because mailItem was changed in AdjustAttachments()
                        if (UseOutlookDOMForProcessing)
                        {
                            using (OutlookMailProxy outlookMailProxy = new OutlookMailProxy(mailItem))
                            {
                                body = outlookMailProxy.FormattedBodyText;
                                body = OutlookFormattedTextProcessor.NewFormattedBodyText(body, links, mailItem);
                            }
                        }
                        else
                        {
                            using (RedemptionMailProxy redemptionMailProxy = new RedemptionMailProxy(mailItem, true, DisableAccessToDOMAttachments))
                            {
                                body = redemptionMailProxy.FormattedBodyText;
                                body = OutlookFormattedTextProcessor.NewFormattedBodyText(body, links, mailItem, false);

                                //private static void InsertHtmlIntoBodyText(ref string body, MessageBodyFormat bodyformat, IEnumerable<SendLinkInfo> links, MailItem mailItem)
                                //sets body as null.
                                if (body != null)
                                {
                                    redemptionMailProxy.FormattedBodyText = body;
                                }
                            }
                        }

                        if (body != null)
                        {
                            SetPropertyValue(requestManager.EnforceResponse.ModifiedRequest.Properties, MailMessagePropertyKeys.FormattedBody, body);
                        }
                    }

					Logger.LogInfo("End Secure File Transfer Process");

                    // Allow the inspector window to redraw now, so that the attachments
                    // and altered body text are immediately updated.
                    System.Windows.Forms.Application.DoEvents();
                }
                else
                {
                    Logger.LogInfo("No Links to process");
                }

                StartSendLinkClient();

                mailItem.UserProperties.Add("SendLink", OlUserPropertyType.olText);
            }
            catch (Exception e)
            {
                //SetMessageWindowVisible(mailItem, true);
                Logger.LogError(e);
                throw;
            }

            return true;
		}
Example #4
0
		private void UpdateEmailContent(IProxy mailItem, PolicyContent.Request request)
		{
			if (string.IsNullOrEmpty(PolicyManagerUtils.GetPropertyValue(request.Properties, MailMessagePropertyKeys.MimeContent)))
			{
				return;
			}
			mailItem.SetSubject(PolicyManagerUtils.GetPropertyValue(request.Properties, MailMessagePropertyKeys.Subject));
			mailItem.SetBody(PolicyManagerUtils.GetPropertyValue(request.Properties, MailMessagePropertyKeys.FormattedBody));
			UpdateHeaderInfo(mailItem, request);
		}
Example #5
0
        // Add msg files back to the collection of attachments that was processed
        internal PolicyContent.Attachment[] AppendMissingAttachments(PolicyContent.Attachment[] missingAttachments, PolicyContent.Attachment[] modifiedRequestAttachments)
        {
            // No *.msg files so return the modified request attachments
            if (missingAttachments.Length == 0)
            {
                return modifiedRequestAttachments;
            }

            // Array to list
            List<Workshare.PolicyContent.Attachment> resultAttachments = new List<Workshare.PolicyContent.Attachment>(modifiedRequestAttachments.Length);
            resultAttachments.AddRange(modifiedRequestAttachments);

            // Add any missing files to the modified collection
            foreach (var attachment in missingAttachments)
            {
                if (!resultAttachments.Exists(x => x.Id == attachment.Id))
                {
                    resultAttachments.Add(attachment);
                    Logger.LogInfo(string.Format("Add missing unprocessed attachment to the collection of processed attachments. Id = {0} DisplayName = {1} Source = {2}.", attachment.Id, attachment.Name, attachment.File.FileName));
                }
				else
				{
					Logger.LogError(string.Format("a file previously removed was found in the modified collection. Id = {0} DisplayName = {1} Source = {2}.", attachment.Id, attachment.Name, attachment.File.FileName));
				}
            }

            return resultAttachments.ToArray();
        }
Example #6
0
        public PolicyContent.Attachment[] GetIgnoreForWorkshareActionAttachments(PolicyContent.Request request)
        {
            List<PolicyContent.Attachment> result = new List<PolicyContent.Attachment>();

            foreach (var attachment in request.Attachments)
            {
                if (attachment.IgnoreForWorkshareActions)
                {
                    result.Add(attachment);
                    Logger.LogInfo(string.Format("Add IgnoreForWorkshareActions attachment to missing attachment collection. Id = {0} DisplayName = {1} Source = {2}.", attachment.Id, attachment.Name, attachment.File.FileName));
                }
            }

            return result.ToArray();        
        }
Example #7
0
        // Remove any .msg files from the Request object and return a collection of the msg files that was removed
        internal Workshare.PolicyContent.Attachment[] ExtractAttachmentsOfTypeEmail(PolicyContent.Request request)
        {
			// Add msg attachements
            List<Workshare.PolicyContent.Attachment> attachmentsTypeMail = new List<Workshare.PolicyContent.Attachment>();
			// Add !msg attachements
            List<Workshare.PolicyContent.Attachment> attachments = new List<Workshare.PolicyContent.Attachment>();

			// Find attachmend of type Mail (msg) in the Request attachments
            foreach (var item in request.Attachments)
            {
                if (item.File.FileType == Policy.FileType.Email)
                {
					// return result
                    attachmentsTypeMail.Add(item);
                    Logger.LogInfo(string.Format("Remove msg file from collection to be processed. Id = {0} DisplayName = {1} Source = {2}.", item.Id, item.Name, item.File.FileName));
                }
                else
                {
					// update Request
                    attachments.Add(item);
                }
            }
            
            if (attachmentsTypeMail.Count != 0)
            {
                // Replace the Request object attachmentd with the collection without the msg files
                request.Attachments = attachments.ToArray();
            }
			
            return attachmentsTypeMail.ToArray();
        }
Example #8
0
		/// <summary>|
		/// We need this to handle the recursive parenting.
		/// </summary>
		/// <param name="response">The <see cref="Workshare.PolicyContent.Response"/></param>
		/// <param name="uiAction">The <see cref="UIAction"/> object for the content item</param>
		/// <param name="action">The <see cref="Workshare.PolicyContent.Action"/> object for the content item</param>
		/// <param name="contentItem"></param>
		/// <returns></returns>
		private static UIContentItem HandleParentContentItems(Response response, UIAction uiAction, PolicyContent.Action action, ContentItem contentItem)
		{
			UIContentItem parent = uiAction.GetContentItemById(contentItem.ParentId);
			if (parent == null)
			{
				CustomProperty parentIndex = Array.Find(contentItem.Properties, p => p.Name == "ParentIndex");
				int index = (parentIndex == null ? -1 : Int32.Parse(parentIndex.Value));
				if (index > -1)
				{
					parent = new UIContentItem(response.Contents[index], action, true);
				}
				if (parent != null)
				{
					if (parent.ParentId == null)
					{
						uiAction.ContentItems[parent.Id] = parent;
					}
					else
					{
						UIContentItem grandparent = HandleParentContentItems(response, uiAction, action, parent.ContentItem);
						grandparent.ChildContentItems[parent.Id] = parent;
					}
				}
			}
			return parent;
		}