public void AddNewClients(string[] filenames, string XMLfilename = "BazaKlientow.xml") { List <string> stringList1 = new List <string>(); List <string> stringList2 = new List <string>(); List <DocFV> docFvList = ReaderDocFV.Make(filenames); this.version = DateTime.Now.ToFileTime().ToString(); foreach (DocFV docFv in docFvList) { try { Klient nowy = ClientFromDocFV.KlientParserFromString(docFv.nabywca, docFv.termin_zaplaty, docFv.sposob_zaplaty, docFv.filename); if (this.Baza.Where <Klient>((Func <Klient, bool>)(n => n.NIP == nowy.NIP)).Count <Klient>() == 0) { this.Baza.Add(nowy); stringList2.Add("Dodano do bazy firmę o skrócie " + nowy.skrot + " z pliku " + docFv.filename); } else { stringList2.Add("Pominięto firmę o skrócie " + nowy.skrot + ", ponieważ jest w bazie. Badany plik to " + docFv.filename); } } catch { stringList1.Add("Błąd parsowania danych do klasy Klient (BazaKlientow.CreateBazaFromDocFiles) z pliku " + docFv.filename); } } StreamWriter streamWriter1 = new StreamWriter("errors\\WordErrors" + this.version + ".txt"); foreach (string str in stringList1) { streamWriter1.WriteLine(str); } streamWriter1.Close(); StreamWriter streamWriter2 = new StreamWriter("errors\\WordRaport" + this.version + ".txt"); foreach (string str in stringList2) { streamWriter2.WriteLine(str); } streamWriter2.Close(); this.SaveXML(XMLfilename); }
public static Klient KlientParserFromString(string nabywca, string termin, string sposob, string filename) { Klient klient1 = new Klient(); string[] nabywca1 = nabywca.Split(new char[2] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); klient1.NIP = ClientFromDocFV.GetNIP(nabywca1); klient1.nr_telefonu = ClientFromDocFV.GetPhoneNumber(nabywca1); klient1.skrot = ClientFromDocFV.GetShortName(filename); klient1.dane_do_fv = ""; foreach (string str in nabywca1) { Klient klient2 = klient1; klient2.dane_do_fv = klient2.dane_do_fv + str + "\r"; } klient1.nazwa_firmy = nabywca1[0]; return(klient1); }