public Wz(string fileNameTXT, string fileLogName) { conf Config = new conf(); FileStream fs = new FileStream(fileNameTXT, FileMode.Open, FileAccess.ReadWrite); DataTable docNames = new DataTable(); docNames.Columns.Add("WZ", typeof(string)); StreamReader sr = new StreamReader(fs); while (!sr.EndOfStream) { string text1 = sr.ReadLine().Replace(" ", ""); compilerDocName.All allCompiler = new ocr_wz.compilerDocName.All(text1); string text = allCompiler.resultText; if ( text.Contains("mówienie") || (text.Contains("am") && text.Contains("wi") && text.Contains("nie") && text.Contains("AS")) || text.Contains("ZAS") || (text.Contains("ze") && text.Contains("wn") && text.Contains("me")) || (text.Contains("trz") && text.Contains("num")) || text.Contains("ydanie") || text.Contains("numer:") || text.Contains("WZ/") ) { if (text.Contains("WZ")) { compilerDocName.Wz WzName = new ocr_wz.compilerDocName.Wz(text); counter.Wz licznikWz = new ocr_wz.counter.Wz(WzName.resultWZ); if (licznikWz.result0 != null) { docNames.Rows.Add(licznikWz.result0); } } else if (text.Contains("ZAS")) { compilerDocName.Zas ZasName = new ocr_wz.compilerDocName.Zas(text); counter.Zas licznikZas = new ocr_wz.counter.Zas(ZasName.resultZas); if (licznikZas.result0 != null) { docNames.Rows.Add(licznikZas.result0); } } } } if (docNames.Rows.Count == 0) { string docName = pdfName.Replace(Config.inPath + "\\!ocr\\po_ocr\\", ""); Copy CopyNewName = new Copy(pdfName, "0", docName, fileLogName); CopyNewName.CopyOther(); } else { var UniqueRows = docNames.AsEnumerable().Distinct(DataRowComparer.Default); DataTable uniqDocNames = UniqueRows.CopyToDataTable(); StreamWriter SW; SW = File.AppendText(fileLogName); SW.WriteLine("Tablica dokumentów:"); SW.Close(); int ileWZ = 0; int ileZAS = 0; foreach (DataRow row in uniqDocNames.Rows) { StreamWriter SW1; SW1 = File.AppendText(fileLogName); SW1.WriteLine(row.Field <string>(0)); SW1.Close(); if (row.Field <string>(0).Contains("WZ_")) { ileWZ++; } else if (row.Field <string>(0).Contains("ZAS_")) { ileZAS++; } } pdfName = fileNameTXT.Replace(".txt", ".pdf"); if (ileWZ == ileZAS || ileWZ > ileZAS) { foreach (DataRow row in uniqDocNames.Rows) { if (row.Field <string>(0).Contains("WZ_")) { yearDocs WZ = new yearDocs(row.Field <string>(0)); WZ.yearWZ(); Copy CopyNewName = new Copy(pdfName, WZ.year, row.Field <string>(0), fileLogName); CopyNewName.CopyWZ(); } } } else { int tableElements = uniqDocNames.Rows.Count; for (int i = 0; i < tableElements; i++) { string docName = Convert.ToString(uniqDocNames.Rows[i]["WZ"]); if (i == 0 && docName.Contains("WZ_")) { yearDocs readYear = new yearDocs(docName); readYear.yearWZ(); Copy CopyNewName = new Copy(pdfName, readYear.year, docName, fileLogName); CopyNewName.CopyWZ(); } else if (i == 0 && docName.Contains("ZAS_") && tableElements < 2) { yearDocs readYear = new yearDocs(docName); readYear.yearZas(); Copy CopyNewName = new Copy(pdfName, readYear.year, docName, fileLogName); CopyNewName.CopyZAS(); } else if (i > 0 && docName.Contains("ZAS_") && (Convert.ToString(uniqDocNames.Rows[i - 1]["WZ"])).Contains("ZAS_")) { yearDocs readYear = new yearDocs(docName); readYear.yearZas(); Copy CopyNewName = new Copy(pdfName, readYear.year, docName, fileLogName); CopyNewName.CopyZAS(); } else if (i > 0 && docName.Contains("WZ")) { yearDocs readYear = new yearDocs(docName); readYear.yearWZ(); Copy CopyNewName = new Copy(pdfName, readYear.year, docName, fileLogName); CopyNewName.CopyWZ(); } } } } fs.Close(); }
public Schenker(string fileNameTXT, string fileLogName) { conf Config = new conf(); FileStream fs = new FileStream(fileNameTXT, FileMode.Open, FileAccess.ReadWrite); DataTable docNames = new DataTable(); docNames.Columns.Add("WZ", typeof(string)); string pdfName = fileNameTXT.Replace(".txt", ".pdf"); StreamReader sr = new StreamReader(fs); DateTime thisTime = DateTime.Now; string year = (thisTime.ToString().Replace(" ", "_").Replace("-", "").Replace(":", "")).Remove(4).Replace("20", ""); string yearBack = Convert.ToString((Convert.ToInt32(year) - 1)); string yearNext = Convert.ToString((Convert.ToInt32(year) + 1)); String[] documents; while (!sr.EndOfStream) { string text1 = sr.ReadLine().Replace(" ", ""); compilerDocName.All allCompiler = new ocr_wz.compilerDocName.All(text1); string text = allCompiler.resultText; if ( text.Contains("WZ/" + yearBack + "/") || text.Contains("WZ/" + year + "/") || text.Contains("WZ/" + yearNext + "/") || text.Contains("WW" + yearBack + "/") || text.Contains("WW" + year + "/") || text.Contains("WW" + yearNext + "/") ) { compilerDocName.Schenker SchenkerName = new ocr_wz.compilerDocName.Schenker(text); documents = SchenkerName.resultSchenker.Split(','); documents = SchenkerName.resultSchenker.Split(';'); foreach (string row in documents) { if (row.Contains("WZ/")) { compilerDocName.Wz WzName = new ocr_wz.compilerDocName.Wz(row); counter.Wz licznikWz = new ocr_wz.counter.Wz(WzName.resultWZ); if (licznikWz.result0 != null) { docNames.Rows.Add(licznikWz.result0); } } else if (row.Contains("WW")) { compilerDocName.Ww WwName = new ocr_wz.compilerDocName.Ww(row); counter.Ww licznikWw = new ocr_wz.counter.Ww(WwName.resultWW); if (licznikWw.result0 != null) { docNames.Rows.Add(licznikWw.result0); } } } } } if (docNames.Rows.Count == 0) { string docName = pdfName.Replace(Config.inPath + "\\!ocr\\po_ocr\\", ""); Copy CopyNewName = new Copy(pdfName, "0", docName, fileLogName); CopyNewName.CopyOther(); } else { var UniqueRows = docNames.AsEnumerable().Distinct(DataRowComparer.Default); DataTable uniqDocNames = UniqueRows.CopyToDataTable(); StreamWriter SW; SW = File.AppendText(fileLogName); SW.WriteLine("Tablica dokumentów:"); SW.Close(); foreach (DataRow row in uniqDocNames.Rows) { StreamWriter SW1; SW1 = File.AppendText(fileLogName); SW1.WriteLine(row.Field<string>(0)); SW1.Close(); if (row.Field<string>(0).Contains("WZ_")) { yearDocs WZ = new yearDocs(row.Field<string>(0)); WZ.yearWZ(); Copy CopyNewName = new Copy(pdfName, WZ.year, row.Field<string>(0), fileLogName); CopyNewName.CopyWZdeliveryDoc(); } else if (row.Field<string>(0).Contains("WW")) { yearDocs WW = new yearDocs(row.Field<string>(0)); WW.yearWW(); Copy CopyNewName = new Copy(pdfName, WW.year, row.Field<string>(0), fileLogName); CopyNewName.CopyWWdeliveryDoc(); } } fs.Close(); } }
public Fv(string fileNameTXT, string fileLogName) { string pdfName = fileNameTXT.Replace(".txt", ".pdf"); conf Config = new conf(); FileStream fs = new FileStream(fileNameTXT, FileMode.Open, FileAccess.ReadWrite); DataTable docNames = new DataTable(); docNames.Columns.Add("WZ", typeof(string)); StreamReader sr = new StreamReader(fs); while (!sr.EndOfStream) { string text1 = sr.ReadLine().Replace(" ", ""); compilerDocName.All allCompiler = new ocr_wz.compilerDocName.All(text1); string text = allCompiler.resultText; if ( text.Contains("F/") || (text.Contains("Nu") && text.Contains("dow") && text.Contains("du")) ) { if (text.Contains("F/")) { compilerDocName.Fv FvName = new ocr_wz.compilerDocName.Fv(text); counter.Fv licznikFv = new ocr_wz.counter.Fv(FvName.resultFV); if (licznikFv.result0 != null) { docNames.Rows.Add(licznikFv.result0); } } else if (text.Contains("Nu") && text.Contains("dow") && text.Contains("du")) { compilerDocName.Wz WzName = new ocr_wz.compilerDocName.Wz(text); counter.Wz licznikWz = new ocr_wz.counter.Wz(WzName.resultWZ); if (licznikWz.result0 != null) { docNames.Rows.Add(licznikWz.result0); } } } } if (docNames.Rows.Count == 0) { string docName = pdfName.Replace(Config.inPath + "\\!ocr\\po_ocr\\", ""); Copy CopyNewName = new Copy(pdfName, "0", docName, fileLogName); CopyNewName.CopyOther(); } else { var UniqueRows = docNames.AsEnumerable().Distinct(DataRowComparer.Default); DataTable uniqDocNames = UniqueRows.CopyToDataTable(); StreamWriter SW; SW = File.AppendText(fileLogName); SW.WriteLine("Tablica dokumentów:"); SW.Close(); int ileFV = 0; int ileWZ = 0; foreach (DataRow row in uniqDocNames.Rows) { StreamWriter SW2; SW2 = File.AppendText(fileLogName); SW2.WriteLine(row.Field <string>(0)); SW2.Close(); string docName = row.Field <string>(0); if (docName.Contains("F_")) { ileFV++; } else if (docName.Contains("WZ_")) { ileWZ++; } } if (ileFV == ileWZ || ileWZ > ileFV) { foreach (DataRow row in uniqDocNames.Rows) { if (row.Field <string>(0).Contains("WZ_")) { yearDocs WZ = new yearDocs(row.Field <string>(0)); WZ.yearWZ(); Copy CopyNewName = new Copy(pdfName, WZ.year, row.Field <string>(0), fileLogName); CopyNewName.CopyWZFV(); } } } else { foreach (DataRow row in uniqDocNames.Rows) { string docName = row.Field <string>(0); if (docName.Contains("F_")) { yearDocs readYear = new yearDocs(docName); readYear.yearFV(); Copy CopyNewName = new Copy(pdfName, readYear.year, docName, fileLogName); CopyNewName.CopyFV(); } } } fs.Close(); } }