public static PayReester SaveCityReesterToDatabase(Reester248 fileRee, PayPaymentSystem paymentSystem, AIS.SN.Model.DomainObjects.Organization agent) { PayReester reester = new PayReester { PaymentSystem = "Система \"Город\"", PaymentSystemId = paymentSystem.Id, Number = ((int) fileRee.Number).ToString() }; FasetItem item = FasetItem.FindByName(FasetsEnum.PaymentsReestrType, Reester.GetTypeDescription(fileRee.ReeType)); reester.ReeTypeId = item.Id; FasetItem item2 = FasetItem.FindByName(FasetsEnum.PaymentReestrStatus, "Загружен"); reester.StatusId = item2.Id; reester.Created = fileRee.Created; reester.FromDate = fileRee.FromDate; reester.ToDate = fileRee.ToDate; reester.Organization = ((int) fileRee.AgentId).ToString(); reester.OrganizationId = agent.Id; reester.Summ = fileRee.ReeSumm; reester.Records = fileRee.RecCount; reester.PaymentService = ((int) fileRee.Service).ToString(); reester.SaveChanges(); foreach (Record record in fileRee.Records) { PayReesterRecord record2; new PayReesterRecord { ReesterId = reester.Id, StatusId = reester.StatusId, AccountNumber = record.acc_pu, AbonentName = record.fio, Address = record.address, SubService = record.sub_srv_pu, PaymentSumm = record.summ, Period = record.dateb.get_HasValue() ? record.dateb.Value : record2.Period, Apx = record.apx, PaymentDate = record.created.get_HasValue() ? record.created.Value : record2.PaymentDate, ExternalTransactionId = record.uno.ToString() }.SaveChanges(); } reester.Prepare(); return reester; }
public static PayReester LoadReesterFromFile(string sourceFileName, PayPaymentSystem paymentSystem, AIS.SN.Model.DomainObjects.Organization agent, FasetItem reesterType, System.DateTime paymentOrderDate, System.DateTime paymentOrderPeriod) { PayReester reester2; try { System.IO.FileInfo sourceFile = new System.IO.FileInfo(sourceFileName); if (!System.IO.File.Exists(sourceFile.get_FullName())) { throw new System.ApplicationException(string.Format("Файл {0} не существует", sourceFile)); } PayReester payReester = new PayReester { PaymentSystemId = paymentSystem.Id, Organization = agent.ShortName, OrganizationId = agent.Id, Created = DALSql.GetDatabaseTime(), Number = sourceFile.get_Name().Substring(0, (int) (sourceFile.get_Name().get_Length() - sourceFile.get_Extension().get_Length())), StatusId = FasetItem.FindByName(FasetsEnum.PaymentReestrStatus, "Загружен").Id, PaymentOrderDate = paymentOrderDate, PaymentOrderPeriod = paymentOrderPeriod }; if (reesterType != FasetItem.Null) { payReester.ReeTypeId = reesterType.Id; } payReester.SaveChanges(); if (sourceFile.get_Extension().ToUpper() == ".DBF") { LoadPaymentsFromDbf(payReester, sourceFile); } else if ((sourceFile.get_Extension().ToUpper() == ".TXT") && (paymentSystem.Name == "Безналичные платежи с зарплаты")) { LoadCashlessPaymentsFromSalary(payReester, sourceFile); } else { try { LoadPaymentsFromFile(payReester, sourceFile, paymentSystem.Encoding); return payReester; } catch (System.Exception exception) { payReester.Delete(); throw new System.ApplicationException("Не удалось прочитать данные из файла " + sourceFile.get_Name() + " или выполнить обработку реестра. Содержание ошибки: " + exception.get_Message()); } } payReester.SaveChanges(); reester2 = payReester; } catch (System.Exception exception2) { throw new System.ApplicationException("Ошибка при загрузке файла реестра " + sourceFileName + ", возможно данный реестр уже был загружен", exception2); } return reester2; }