public void ExportData(User user) { service = new ServicePersonalAssistant(); Note[] notes = service.RefreshNotes(user.Id); string notesSTR = "\tNOTES\n" + string.Join("\n", Array.ConvertAll <object, string>(notes, Convert.ToString)); Meetup[] meetups = service.RefreshMeetups(user.Id); string meetupsSTR = "\tMEETUPS\n" + string.Join("\n", Array.ConvertAll <object, string>(meetups, Convert.ToString)); Contact[] contacts = service.RefreshContacts(user.Id); string contactsSTR = "\tCONTACTS\n" + string.Join("\n", Array.ConvertAll <object, string>(contacts, Convert.ToString)); string[] res = { notesSTR, meetupsSTR, contactsSTR }; string docPath = @"D:\Обучение\3 курс\3 курс 1 сем\Тряпко\TRPZ\trpzlab\PersonalAssistant\PersonalAssistantData.txt"; using (StreamWriter file = new StreamWriter(docPath)) { foreach (string line in res) { Console.WriteLine(line); file.WriteLine(line); } } }
public void printAll(User user) { service = new ServicePersonalAssistant(); Contact[] contacts = service.RefreshContacts(user.Id); Console.WriteLine("\t CONTACTS \n"); foreach (Contact contact in contacts) { Console.WriteLine(contact.ToString()); } }
public void ExportData(User user) { service = new ServicePersonalAssistant(); Note[] notes = service.RefreshNotes(user.Id); string notesSTR = "\tNOTES\n" + string.Join("\n", Array.ConvertAll <object, string>(notes, Convert.ToString)); Meetup[] meetups = service.RefreshMeetups(user.Id); string meetupsSTR = "\tMEETUPS\n" + string.Join("\n", Array.ConvertAll <object, string>(meetups, Convert.ToString)); Contact[] contacts = service.RefreshContacts(user.Id); string contactsSTR = "\tCONTACTS\n" + string.Join("\n", Array.ConvertAll <object, string>(contacts, Convert.ToString)); string res = notesSTR + "\n" + meetupsSTR + "\n" + contactsSTR; const string bodyRES = ""; var fromAddress = new MailAddress("*****@*****.**", "Personal Assistant"); var toAddress = new MailAddress(user.Mail, user.Login); const string fromPassword = ""; const string subject = "Personal Assistant data export"; string body = res; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { smtp.Send(message); } }