private static void LoadPaymentsFromFile(PayReester payReester, System.IO.FileInfo sourceFile, string encoding) { payReester.ReeTypeId = FasetItem.FindByName(FasetsEnum.PaymentsReestrType, "Наличные платежи").Id; using (System.IO.StreamReader reader = new System.IO.StreamReader(sourceFile.get_FullName(), System.Text.Encoding.GetEncoding(string.IsNullOrEmpty(encoding) ? ((string) "CP866") : encoding))) { string str; while ((str = reader.ReadLine()) != null) { str = str.Trim(); new PayReesterRecord { ReesterId = payReester.Id, StatusId = payReester.StatusId, Apx = str }.SaveChanges(); } payReester.Prepare(); } }
private static void LoadCashlessPaymentsFromSalary(PayReester payReester, System.IO.FileInfo sourceFile) { System.Globalization.CultureInfo info = new System.Globalization.CultureInfo("en-US", true); info.DateTimeFormat.set_ShortDatePattern("dd'.'MM'.'yyyy HH':'mm':'ss"); info.NumberFormat.set_NumberDecimalSeparator("."); info.NumberFormat.set_NumberDecimalDigits(2); payReester.ReeTypeId = FasetItem.FindByName(FasetsEnum.PaymentsReestrType, "Безналичные платежи").Id; using (System.IO.StreamReader reader = new System.IO.StreamReader(sourceFile.get_FullName(), System.Text.Encoding.GetEncoding(0x362))) { string str; while ((str = reader.ReadLine()) != null) { int num; decimal num2; System.DateTime time; string str2; string str3; PayReesterRecord record; str = str.Trim(); if (!str.StartsWith("#")) { goto Label_01BA; } try { str2 = str.Substring(1, (int) (str.IndexOfAny((char[]) new char[] { ' ', '\t' }) - 1)).Trim().ToUpper(); str3 = str.Substring((int) (str.IndexOfAny((char[]) new char[] { ' ', '\t' }) + 1)).Trim(); } catch { continue; } string str4 = str2; if (str4 != null) { if (str4 != "ORGCODE") { if (str4 == "FILESUM") { goto Label_0147; } if (str4 == "COUNT") { goto Label_0168; } if (str4 == "PERIODB") { goto Label_0182; } if (str4 == "PERIODE") { goto Label_019E; } } else { payReester.Organization = str3; } } continue; Label_0147: if (decimal.TryParse(str3, System.Globalization.NumberStyles.Currency, info, ref num2)) { payReester.Summ = num2; } continue; Label_0168: if (int.TryParse(str3, System.Globalization.NumberStyles.Currency, info, ref num)) { payReester.Records = num; } continue; Label_0182: if (System.DateTime.TryParseExact(str3, "dd'.'MM'.'yyyy", info, System.Globalization.DateTimeStyles.AllowWhiteSpaces, ref time)) { payReester.FromDate = time; } continue; Label_019E: if (System.DateTime.TryParseExact(str3, "dd'.'MM'.'yyyy", info, System.Globalization.DateTimeStyles.AllowWhiteSpaces, ref time)) { payReester.ToDate = time; } continue; Label_01BA: record = new PayReesterRecord(); record.ReesterId = payReester.Id; record.StatusId = payReester.StatusId; record.Apx = str; record.SaveChanges(); } } }