public void TestSaveAttachmentsToEmptyFolder() { var directory = new System.IO.DirectoryInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)); var store = new RfiCoder.Entity.Store(); store.ProjectNumber = 1305015; store.Program = RfiCoder.Enum.ProgramTypes.NewStores; store.City = "Oconomowoc"; var fileHandler = new RfiCoder.Utilities.FileHandler(store); var email = new Microsoft.Exchange.WebServices.Data.EmailMessage( RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService); email.Subject = @"WM Store #9999 Sink Drain Dimensions RFI"; var files = directory.GetFiles(); var randGen = new System.Random(); var pt = randGen.Next(1, files.Length); var file = files[pt]; email.Attachments.AddFileAttachment(file.Name, file.OpenRead()); email.Save(Microsoft.Exchange.WebServices.Data.WellKnownFolderName.Drafts); var result = fileHandler.SaveAttachmentsToFolder(email.Attachments); email.Delete(Microsoft.Exchange.WebServices.Data.DeleteMode.HardDelete); }
public void TestSaveAttachmentsAndEmail() { int i = 0; var directory = new System.IO.DirectoryInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)); var store = new RfiCoder.Entity.Store(); store.ProjectNumber = 1305015; store.Program = RfiCoder.Enum.ProgramTypes.NewStores; store.City = "Oconomowoc"; do { var email = new Microsoft.Exchange.WebServices.Data.EmailMessage( RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService); email.Subject = @"FW: RFI:Request for Information Answered: TEST"; email.Categories.Add("TEST"); var files = directory.GetFiles(); var randGen = new System.Random(); var pt = randGen.Next(1, files.Length); var file = files[pt]; email.Attachments.AddFileAttachment(file.Name, file.OpenRead()); email.Save(RfiCoder.Utilities.EmailHelper.InstanceOf.NewStoresFolder); i++; } while (i < 5); var itemView = new Microsoft.Exchange.WebServices.Data.ItemView(int.MaxValue); itemView.PropertySet = new Microsoft.Exchange.WebServices.Data.PropertySet(Microsoft.Exchange.WebServices.Data.BasePropertySet.IdOnly, Microsoft.Exchange.WebServices.Data.ItemSchema.Categories); var filter = new Microsoft.Exchange.WebServices.Data.SearchFilter.IsEqualTo(Microsoft.Exchange.WebServices.Data.EmailMessageSchema.Categories, "TEST"); var results = RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService.FindItems(RfiCoder.Utilities.EmailHelper.InstanceOf.NewStoresFolder, filter, itemView); var message = Microsoft.Exchange.WebServices.Data.Item.Bind(RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService, results.Items[0].Id, RfiCoder.Utilities.EmailHelper.EmailProperties ); var result = RfiCoder.Utilities.EmailHelper.InstanceOf.ArchiveAnsweredRfi(message, store); Assert.That(result, Is.True); }
public void TestGetProjectFolder2() { var store = new RfiCoder.Entity.Store(); store.Program = RfiCoder.Enum.ProgramTypes.Expansions; store.ProjectNumber = 1201001; var result = RfiCoder.Utilities.EmailHelper.InstanceOf.GetOutlookProjectPath(store); var name = Microsoft.Exchange.WebServices.Data.Folder.Bind(RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService, result).DisplayName; Assert.That(name, Is.EqualTo("Paramount, CA #2110 (1201001)")); }
public void TestGetProjectFolder() { var store = new RfiCoder.Entity.Store(); store.Program = RfiCoder.Enum.ProgramTypes.NewStores; store.ProjectNumber = 1404016; var result = RfiCoder.Utilities.EmailHelper.InstanceOf.GetOutlookProjectPath(store); var name = Microsoft.Exchange.WebServices.Data.Folder.Bind(RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService, result).DisplayName; Assert.That(name, Is.EqualTo("Broomfield, CO #85527 (1404016)")); }
public void TestGetProjectRfiFolder2() { var store = new RfiCoder.Entity.Store(); store.Program = RfiCoder.Enum.ProgramTypes.NewStores; store.ProjectNumber = 1305015; var folderId = RfiCoder.Utilities.EmailHelper.InstanceOf.GetOutlookProjectPath(store); var result = RfiCoder.Utilities.EmailHelper.InstanceOf.GetProjectRfiFolder(folderId); var name = Microsoft.Exchange.WebServices.Data.Folder.Bind(RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService, result).DisplayName; Assert.That(name, Is.EqualTo("RFI")); }
public void TestHashStorage() { var directory = new System.IO.DirectoryInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)); var fileHandler = new RfiCoder.Utilities.FileHandler(); var hasher = new RfiCoder.Data.HashStorage(@"..\XmlStorage\test.xml"); hasher.Read(); var result = fileHandler.DirectoryFileHash(directory); var store = new RfiCoder.Entity.Store(); store.ProjectNumber = 1420563; store.City = "South Boston"; hasher.Write(directory, result.Result, store); }
public void TestTryGetAndAttachDocumentsMultiStore() { var email = new Microsoft.Exchange.WebServices.Data.EmailMessage( RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService); var store = new RfiCoder.Entity.Store(); store.Number = 6589; store.Sequence = 0; var category = "RFI: 1"; var result = RfiCoder.Utilities.EmailHelper.InstanceOf.TryGetAndAttachDocuments(email, store, category); Assert.That(result, Is.False); var attachments = email.Attachments; Assert.That(attachments.Count, Is.EqualTo(0)); }
public void TestTryGetAndAttachDocuments2() { var email = new Microsoft.Exchange.WebServices.Data.EmailMessage( RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService); var store = new RfiCoder.Entity.Store(); store.Number = 6406; store.Sequence = 3; var category = "RFI: 072"; var result = RfiCoder.Utilities.EmailHelper.InstanceOf.TryGetAndAttachDocuments(email, store, category); Assert.That(result, Is.True); var attachments = email.Attachments; Assert.That(attachments.Count, Is.InRange(1, 6)); int count = 1; var parser = new RfiCoder.Utilities.Parser(); foreach (var attachment in attachments) { var name = attachment.Name; var extension = parser.GetAttachmentExtension(name); var rfiNumber = parser.GetRfiNumberWithPadding(category); var rename = String.Format("{0}_RFI {1}_Attachment {2}{3}", store.Number.ToString(), rfiNumber, count.ToString("D2"), extension); Assert.That(name, Is.EqualTo(rename)); count++; } }
public void TestGetPathToAProject() { var store = new RfiCoder.Entity.Store(); store.Program = RfiCoder.Enum.ProgramTypes.NewStores; store.ProjectNumber = 1105039; store.Type = RfiCoder.Enum.ProjectTypes.GroundUp; store.Number = 4165; store.City = "Fort Worth (Jackson & River Oaks), TX #4165 (1105039)"; var filehandler = new RfiCoder.Utilities.FileHandler(); var result = filehandler.GetFileServerProjectPath(store); Assert.That(result, Is.Not.Empty); Assert.That(result, Is.EqualTo(@"R:\05 New Supercenters\Fort Worth (Jackson & River Oaks), TX #4165 (1105039)\14-RFI Attachments")); }
public void TestGetPathToProject() { var store = new RfiCoder.Entity.Store(); store.Program = RfiCoder.Enum.ProgramTypes.NewStores; store.ProjectNumber = 1404016; store.Type = RfiCoder.Enum.ProjectTypes.GroundUp; store.Number = 85527; store.City = "Broomfield"; var filehandler = new RfiCoder.Utilities.FileHandler(); var result = filehandler.GetFileServerProjectPath(store); Assert.That(result, Is.Not.Empty); Assert.That(result, Is.EqualTo(@"R:\04 New Sams\Broomfield, CO #85527 (1404016)\14-RFI Attachments")); }
public void TestSaveAttachmentsToFolderWithDuplicateFile() { var store = new RfiCoder.Entity.Store(); store.ProjectNumber = 1304007; store.Program = RfiCoder.Enum.ProgramTypes.NewStores; store.City = "Austin (lakeline)"; var fileHandler = new RfiCoder.Utilities.FileHandler(store); var email = new Microsoft.Exchange.WebServices.Data.EmailMessage( RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService); email.Subject = @"WM Store #9999 Sink Drain Dimensions RFI"; var directory = new System.IO.DirectoryInfo(fileHandler.Path); var files = directory.GetFiles(); var randGen = new System.Random(); var pt = randGen.Next(1, files.Length); var file = files[pt]; email.Attachments.AddFileAttachment(file.Name, file.OpenRead()); email.Save(Microsoft.Exchange.WebServices.Data.WellKnownFolderName.Drafts); var result = fileHandler.SaveAttachmentsToFolder(email.Attachments); email.Delete(Microsoft.Exchange.WebServices.Data.DeleteMode.HardDelete); Assert.That(result, Is.False); }