コード例 #1
0
ファイル: UroTestHelper.cs プロジェクト: killbug2004/WSProf
        public static UniversalRequestObject GetUroFromMailMessage(System.Net.Mail.MailMessage message)
        {
            UniversalRequestObject uro = new UniversalRequestObject();

            uro.Properties.Add(MailMessagePropertyKeys.FileHeader, message.Headers.ToString());
            uro.Properties.Add(MailMessagePropertyKeys.Body, message.Body);
            uro.Properties.Add(MailMessagePropertyKeys.Subject, message.Subject);

            string sFilenames = "";
            foreach (System.Net.Mail.Attachment attachment in message.Attachments)
            {
                sFilenames += attachment.Name + ' ';

                RequestAttachment ra = new RequestAttachment();
                ra.Name = attachment.Name;
                ra.ContentType = attachment.ContentType.ToString();
	            ra.File = new Workshare.Policy.Engine.File(attachment.ContentStream, ra.Name);
				uro.Attachments.Add(ra);
            }
            uro.Properties.Add(MailMessagePropertyKeys.Attachments, sFilenames);

            uro.PolicyType = PolicyType.ClientEmail;
            uro.DataTimeStamp = System.DateTime.Now;

            if (message.From.Address.Length > 0)
            {
                PopulateSourceFromMailMessage(uro, message);
            }

            PopulateDestinationFromMailMessage(uro, message);

            return uro;
        }
コード例 #2
0
 RequestAttachment GetRequestAttachment(UniversalRequestObject uro, string stype, string filename, string displayname)
 {
     RequestAttachment ra = new RequestAttachment();
     ra.Name = displayname;
     ra.ContentType = stype;
     ra.Data = new BinaryData(filename);
     return ra;
 }
コード例 #3
0
ファイル: Email2Uro.cs プロジェクト: killbug2004/WSProf
		private RequestAttachment GetMime()
		{
			RequestAttachment requestAttachmentMime = new RequestAttachment();
			requestAttachmentMime.Name = "MIME";
			requestAttachmentMime.ContentType = "MIME";

			using (MemoryStream mimeStream = new MemoryStream(Encoding.Unicode.GetBytes(m_emailProxy.MimeContent)))
			{
				requestAttachmentMime.Data = new BinaryData(mimeStream);

				return requestAttachmentMime;
			}
		}
コード例 #4
0
        /// <summary>
        /// This method will create the attachment for the URO
        /// </summary>
        /// <returns>The requested attachment</returns>
        private RequestAttachment CreateAttachment(FileInfo file)
        {
            RequestAttachment ra = new RequestAttachment();
            using (FileStream fs = file.OpenRead())
            {
                ra.Data = new OptimizedBinaryData(fs);
                ra.ContentType = file.Extension.Substring(1);
                ra.Name = file.Name;
				ra.FileName = file.FullName;
				ra.File = new Workshare.FCS.Lite.Interface.File(file.FullName, Path.GetFileNameWithoutExtension(file.FullName));
			}
            return ra;
        }
コード例 #5
0
ファイル: RequestAdaptor.cs プロジェクト: killbug2004/WSProf
        private static void HandleOrigContentBytes(string mimeString, UniversalRequestObject uro)
        {
            RequestAttachment ra = new RequestAttachment();

            ra.Name = "MIME";
            ra.ContentType = "MIME";

            using (MemoryStream mimeStream = new MemoryStream(Encoding.Unicode.GetBytes(mimeString)))
            {
                ra.Data = new OptimizedBinaryData(mimeStream);
            }

            uro.OriginalContentBytes = ra;
        }
コード例 #6
0
ファイル: UroHelpers.cs プロジェクト: killbug2004/WSProf
		public static UniversalRequestObject GetUroFromMailMessage(System.Net.Mail.MailMessage message, string sPath)
        {
            UniversalRequestObject uro = new UniversalRequestObject();

            uro.Properties.Add(MailMessagePropertyKeys.FileHeader, message.Headers.ToString());
            uro.Properties.Add(MailMessagePropertyKeys.Body, message.Body);
            uro.Properties.Add(MailMessagePropertyKeys.Subject, message.Subject);

            string sFilenames = "";
            string name;
            System.Net.Mime.ContentType contentType;
            foreach (System.Net.Mail.Attachment attachment in message.Attachments)
            {
                using (attachment)
                {
                    name = attachment.Name;
                    contentType = attachment.ContentType;
                }

                sFilenames += name + ' ';

                RequestAttachment ra = new RequestAttachment();
                ra.ContentType = contentType.ToString();
                //ra.Data = new OptimizedBinaryData(attachment.ContentStream);
				ra.FileName = System.IO.Path.Combine(sPath, name);
				ra.Name = System.IO.Path.GetFileName(name);
				ra.File = new Workshare.FCS.Lite.Interface.File(ra.FileName, System.IO.Path.GetFileNameWithoutExtension(ra.FileName));
				ra.ContentId = Guid.NewGuid().ToString();	

                uro.Attachments.Add(ra);
            }
            uro.Properties.Add(MailMessagePropertyKeys.Attachments, sFilenames);


            uro.PolicyType = PolicyType.ClientEmail;
            uro.DataTimeStamp = System.DateTime.Now;

            if (message.From.Address.Length > 0)
            {
                PopulateSourceFromMailMessage(uro, message);
            }

            PopulateDestinationFromMailMessage(uro, message);

            return uro;
        }
コード例 #7
0
		private UniversalRequestObject GetUro3(bool bAddAttachments)
		{
			UniversalRequestObject uro = new UniversalRequestObject();

			uro.Properties.Add(MailMessagePropertyKeys.FileHeader, "Stuff");
			uro.Properties.Add(MailMessagePropertyKeys.Body, "4408 0412 3456 7890 piss");
			uro.Properties.Add(MailMessagePropertyKeys.Subject, "Random Subject line");
			if (bAddAttachments)
				uro.Properties.Add(MailMessagePropertyKeys.Attachments, "attachment1.txt; f**k.txt; c**t.txt");
			else
				uro.Properties.Add(MailMessagePropertyKeys.Attachments, "");

			uro.PolicyType = PolicyType.ClientEmail;
			uro.DataTimeStamp = System.DateTime.Now;

			uro.Source.RoutingType = RoutingTypes.Source;
			uro.Source.PolicyType = uro.PolicyType;
			IRoutingItem sourceRoutingItem = new RoutingItem("*****@*****.**");
			sourceRoutingItem.Properties.Add(SMTPItemPropertyKeys.AddressType, AddressType.From);
			uro.Source.Items.Add(sourceRoutingItem);

			uro.Destination.RoutingType = RoutingTypes.Destination;
			uro.Destination.PolicyType = uro.PolicyType;
			IRoutingItem toRoutingItem1 = new RoutingItem("*****@*****.**");
			toRoutingItem1.Properties.Add(SMTPItemPropertyKeys.AddressType, AddressType.To);
			uro.Destination.Items.Add(toRoutingItem1);
			IRoutingItem toRoutingItem2 = new RoutingItem("*****@*****.**");
			toRoutingItem2.Properties.Add(SMTPItemPropertyKeys.AddressType, AddressType.To);
			uro.Destination.Items.Add(toRoutingItem2);

			IRoutingItem ccRoutingItem1 = new RoutingItem("*****@*****.**");
			ccRoutingItem1.Properties.Add(SMTPItemPropertyKeys.AddressType, AddressType.CC);
			uro.Destination.Items.Add(ccRoutingItem1);
			IRoutingItem ccRoutingItem2 = new RoutingItem("*****@*****.**");
			ccRoutingItem2.Properties.Add(SMTPItemPropertyKeys.AddressType, AddressType.CC);
			uro.Destination.Items.Add(ccRoutingItem2);

			IRoutingItem bccRoutingItem1 = new RoutingItem("*****@*****.**");
			bccRoutingItem1.Properties.Add(SMTPItemPropertyKeys.AddressType, AddressType.CC);
			uro.Destination.Items.Add(bccRoutingItem1);

			if (bAddAttachments)
			{
				RequestAttachment ra = new RequestAttachment((new ASCIIEncoding()).GetBytes("tuff"));
				ra.Name = "attachment1.txt";
				ra.ContentType = "text";
				uro.Attachments.Add(ra);

				RequestAttachment ra2 = new RequestAttachment((new ASCIIEncoding()).GetBytes("is a big fishy, yes?"));
				ra2.Name = "f**k.txt";
				ra2.ContentType = "fish";
				uro.Attachments.Add(ra2);

				RequestAttachment ra3 = new RequestAttachment((new ASCIIEncoding()).GetBytes("tuff"));
				ra3.Name = "c**t.txt";
				ra3.ContentType = "TEXT";
				uro.Attachments.Add(ra3);
			}

			return uro;
		}
コード例 #8
0
ファイル: Email2Uro.cs プロジェクト: killbug2004/WSProf
		private string AddAttachment(IUniversalRequestObject uro, IEmailAttachment attachment)
		{
			RequestAttachment requestAttachment = new RequestAttachment();

			string attachmentName = attachment.DisplayName;
			requestAttachment.ContentType = MimeAttachmentsProxy.GetContentType(attachment);
			requestAttachment.ContentId = attachment.ContentId;
			requestAttachment.ContentItemIndex = attachment.ContentItemIndex;
			requestAttachment.Name = attachmentName;
			requestAttachment.FileName = attachment.FileName;
			requestAttachment.File = new Workshare.FCS.Lite.Interface.File(attachment.FileName, attachment.DisplayName);
			requestAttachment.IsSignature = attachment.IsSignature;

			uro.Attachments.Add(requestAttachment);

			return attachmentName;
		}
コード例 #9
0
ファイル: TestHelpers.cs プロジェクト: killbug2004/WSProf
        public static UniversalRequestObject GetUro(bool bAddAttachments)
        {
            UniversalRequestObject uro = new UniversalRequestObject();

            uro.Properties.Add(MailMessagePropertyKeys.FileHeader, "Stuff");
            uro.Properties.Add(MailMessagePropertyKeys.Body, "4408 0412 3456 7890");
            uro.Properties.Add(MailMessagePropertyKeys.Subject, "Subject line");
            uro.Properties.Add(MailMessagePropertyKeys.Attachments, "");

            uro.PolicyType = PolicyType.ClientEmail;
            uro.DataTimeStamp = System.DateTime.Now;

            uro.Source.RoutingType = RoutingTypes.Source;
            uro.Source.PolicyType = uro.PolicyType;
            IRoutingItem sourceRoutingItem = new RoutingItem("*****@*****.**");
            sourceRoutingItem.Properties.Add(SMTPItemPropertyKeys.AddressType, AddressType.From);
            uro.Source.Items.Add(sourceRoutingItem);

            uro.Destination.RoutingType = RoutingTypes.Destination;
            uro.Destination.PolicyType = uro.PolicyType;
            IRoutingItem toRoutingItem = new RoutingItem("sam test");
            toRoutingItem.Properties.Add(SMTPItemPropertyKeys.AddressType, AddressType.To);
            uro.Destination.Items.Add(toRoutingItem);

            IRoutingItem ccRoutingItem1 = new RoutingItem("*****@*****.**");
            ccRoutingItem1.Properties.Add(SMTPItemPropertyKeys.AddressType, AddressType.CC);
            uro.Destination.Items.Add(ccRoutingItem1);
            IRoutingItem ccRoutingItem2 = new RoutingItem("*****@*****.**");
            ccRoutingItem2.Properties.Add(SMTPItemPropertyKeys.AddressType, AddressType.CC);
            uro.Destination.Items.Add(ccRoutingItem2);

            IRoutingItem bccRoutingItem = new RoutingItem("*****@*****.**");
            bccRoutingItem.Properties.Add(SMTPItemPropertyKeys.AddressType, AddressType.BCC);
            uro.Destination.Items.Add(bccRoutingItem);

            if (bAddAttachments)
            {

				string attachment1 = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\TestURO_Attachments\attachment1.txt");
				string attachment2 = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\TestURO_Attachments\attachment2.txt");
				string attachment3 = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\TestURO_Attachments\attachment3.txt");

                RequestAttachment ra = new RequestAttachment();
				ra.FileName = attachment1;
				ra.Name = Path.GetFileName(attachment1);
				ra.File = new Workshare.FCS.Lite.Interface.File(attachment1, Path.GetFileNameWithoutExtension(attachment1));
                ra.ContentType = "text";
                uro.Attachments.Add(ra);

                RequestAttachment ra2 = new RequestAttachment();
				ra2.FileName = attachment2;
				ra2.Name = Path.GetFileName(attachment2);
				ra2.File = new Workshare.FCS.Lite.Interface.File(attachment2, Path.GetFileNameWithoutExtension(attachment2));
                ra2.ContentType = "fish";
                uro.Attachments.Add(ra2);

                RequestAttachment ra3 = new RequestAttachment();
				ra3.FileName = attachment3;
				ra3.Name = Path.GetFileName(attachment3);
				ra3.File = new Workshare.FCS.Lite.Interface.File(attachment3, Path.GetFileNameWithoutExtension(attachment3));
                ra3.ContentType = "TEXT";
                uro.Attachments.Add(ra3);
            }

            return uro;
        }
コード例 #10
0
ファイル: TestHelpers.cs プロジェクト: killbug2004/WSProf
        public static void AddFilesToRemovableDeviceRoot(IUniversalRequestObject uro, string[] files)
        {
            foreach (string file in files)
            {
                RequestAttachment ra = new RequestAttachment();
                ra.Name = System.IO.Path.Combine(System.IO.Path.GetPathRoot(file), System.IO.Path.GetFileName(file));
				ra.File = new File(Path.Combine(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments"), System.IO.Path.GetFileName(file)), System.IO.Path.GetFileName(file));

                uro.Attachments.Add(ra);
            }
        }
コード例 #11
0
ファイル: TestHelpers.cs プロジェクト: killbug2004/WSProf
        public static RequestAttachment AddAttachment(UniversalRequestObject uro, string sType, string sFilename, string sDisplayName)
        {
            RequestAttachment ra = new RequestAttachment();
            ra.Name = ((uro.PolicyType == PolicyType.ClientEmail) ? sDisplayName : sFilename);
            ra.ContentType = sType;
			ra.ContentId = Guid.NewGuid().ToString();
			ra.FileName = sFilename;
			ra.File = new Workshare.Policy.Engine.File (new Workshare.FCS.Lite.Interface.File(sFilename, sDisplayName));
			
            uro.Attachments.Add(ra);

            return ra;
        }
コード例 #12
0
        public static RequestAttachment CreateBinaryRequestAttachment(string path)
        {
            RequestAttachment ra = new RequestAttachment();

            ra.Name = Path.GetFileNameWithoutExtension(path);
            ra.ContentType = ExtensionToContentLookup.GetContent(Path.GetExtension(path).Substring(1));
            ra.Data = new BinaryData(path);

            return ra;
        }
コード例 #13
0
		private static RequestAttachment getRequestAttachment(UniversalRequestObject uro, string stype,
			string filename, string displayname)
		{
			RequestAttachment ra = new RequestAttachment();

			ra.Name = displayname;
		    ra.FileName = filename;
		    ra.File = new Workshare.FCS.Lite.Interface.File(filename, displayname);
			ra.ContentType = stype;

			return ra;
		}
コード例 #14
0
        private UniversalRequestObject CreateSMTPUro(string contentType, string attachmentPath)
        {
            UniversalRequestObject uro = new UniversalRequestObject();
            uro.Properties.Add(MailMessagePropertyKeys.FileHeader, "Harmless");
            uro.Properties.Add(MailMessagePropertyKeys.Body, "Mostly harmless");
            uro.Properties.Add(MailMessagePropertyKeys.Subject, "EAT test subject");
            uro.Properties.Add(MailMessagePropertyKeys.Attachments, "");
            uro.Properties.Add("RequestChannel", RequestChannel.Outlook.ToString());
            uro.PolicyType = PolicyType.ClientEmail;
            uro.DataTimeStamp = System.DateTime.Now;

            uro.Source.PolicyType = uro.PolicyType;
            uro.Source.RoutingType = RoutingTypes.Source;
            IRoutingItem fromRoutingItem = new RoutingItem("*****@*****.**");
            fromRoutingItem.Properties.Add(SMTPItemPropertyKeys.DisplayName, "pair");
            fromRoutingItem.Properties.Add(SMTPItemPropertyKeys.AddressType, AddressType.From);
            uro.Source.Items.Add(fromRoutingItem);

            uro.Destination.PolicyType = uro.PolicyType;
            uro.Destination.RoutingType = RoutingTypes.Destination;
            IRoutingItem toRoutingItem = new RoutingItem("*****@*****.**");
            toRoutingItem.Properties.Add(SMTPItemPropertyKeys.DisplayName, "Henry.McAlpine");
            toRoutingItem.Properties.Add(SMTPItemPropertyKeys.AddressType, AddressType.To);
            uro.Destination.Items.Add(toRoutingItem); 

            RequestAttachment ra = new RequestAttachment();
            ra.Name = "Do Not Panic";
            ra.ContentType = contentType;
            ra.Data = new BinaryData(attachmentPath);
            uro.Attachments.Add(ra);
            return uro;
        }
コード例 #15
0
		private static void HandleAttachments(SafeMailItemClass mailItem, UniversalRequestObject uro)
		{
			System.Text.StringBuilder sb = new System.Text.StringBuilder();

			Attachments mailAttachments = mailItem.Attachments;
			using (new ComObjectGovernor(mailAttachments))
			{
				string filenames = "";
				for (int i = 1; i <= mailAttachments.Count; i++)
				{
					Attachment attachmentToCopy = mailAttachments.Item(i);
					using (new ComObjectGovernor(attachmentToCopy))
					{
						sb.AppendFormat("{0} ", attachmentToCopy.DisplayName);

						object objAttach = attachmentToCopy.AsArray;
						byte[] bytes = objAttach as byte[];

						if (bytes != null)
						{
							System.IO.MemoryStream memStream = new System.IO.MemoryStream(bytes);
							bytes = null;

							using (System.Net.Mail.Attachment tempAttach = new System.Net.Mail.Attachment(memStream, attachmentToCopy.FileName))
							{
								filenames += tempAttach.Name;
								RequestAttachment ra = new RequestAttachment
									{
										Name = tempAttach.Name,
										ContentType = tempAttach.ContentType.ToString(),
										Data = new OptimizedBinaryData(tempAttach.ContentStream)
									};
								uro.Attachments.Add(ra);
							}
						}
					}
				}
			}

			uro.Properties.Add(MailMessagePropertyKeys.Attachments, sb.ToString());
		}