public int CompareTo(object obj) { if (obj == null) { return(1); } Message otherMessage = obj as Message; if (otherMessage != null) { return(MessageDate.CompareTo(otherMessage.MessageDate)); } throw new ArgumentException("Object is not a Temperature"); }
public override string ToString() { return($"Address : {DeviceAddress}/Adapter : {DeviceAdapter}/Value : {Value}/message date : {MessageDate.ToString()}"); }
} // текст сообщения public override string ToString() { return(String.Format("ID: {0}\tДАТА: {1}\tПОЛЬЗОВАТЕЛЬ: {2}\t ТИП: {3}\tСООБЩЕНИЕ: {4}\n", Id, MessageDate.ToString("dd.MM.yy HH:mm:ss"), UserName, MessageType, MessageText)); }
/// <summary> /// Сохранение вложений в выбранных папках, полученные текущей датой /// </summary> public int SaveAttachments() { MessageDate messageDate = new MessageDate(); messageDate.ShowDialog(); if (messageDate.DialogResult != DialogResult.OK) { return(0); } //messageDate.date int count = 0; OutlookApp.Session.Logon(); foreach (string folderName in FolderNames) { Outlook.Folder folder = GetFolder(folderName); if (folder == null) { continue; } ProcessBar pb = Forms.ProcessBar.Init("Сканирование папки " + folder.Name, folder.Items.Count, 1, folder.Name); pb.Show(); foreach (object item in folder.Items) { if (pb.Cancel) { break; } if (!(item is Outlook.MailItem mail)) { pb.Action(); continue; } pb.Action(mail.ReceivedTime.Date.ToString()); if (mail.Attachments.Count == 0) { continue; } if (mail.ReceivedTime.Date < messageDate.DateStart || mail.ReceivedTime.Date > messageDate.DateEnd) { continue; } string path = Globals.ThisWorkbook.Path + "\\MailFromProviders\\" + DateTime.Today.ToString("dd.MM.yyyy") + '\\'; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } foreach (Outlook.Attachment attach in mail.Attachments) { if (!attach.FileName.Contains("xls")) { continue; } attach.SaveAsFile(path + attach.FileName); count++; } } pb.Close(); } return(count); }
public override string ToString() { return(string.Format("From {0} to {1} on {2:dd/MM HH:mm} about {3}", From, MailBoxName, MessageDate.AddHours(1), Subject)); }