private static List <FundResponse.CreateData> GetResponsesFromArchive(FundResponseCreateDataBuilder builder, string zipDirectoryName) { List <FundResponse.CreateData> responsesToCreate = new List <FundResponse.CreateData>(); foreach (var directory in Directory.GetDirectories(zipDirectoryName)) { DirectoryInfo dInfo = new DirectoryInfo(directory); string directoryName = dInfo.Name; IEnumerable <string> dataFiles = Directory.GetFiles(directory).Where(f => Path.GetFileName(f).StartsWith("d")); foreach (var dataFile in dataFiles) { string fname = dataFile; if (!fname.EndsWith("dbf")) { File.Copy(fname, fname = dataFile.Split('.')[0] + ".dbf"); } if (!string.IsNullOrEmpty(fname)) { DataTable dataTable = DBFProcessor.GetDataTable(fname, string.Format("select * from \"{0}\";", fname)); IEnumerable <FundResponse.CreateData> list = builder.BuildList(directoryName, dataTable); responsesToCreate.AddRange(list); } } } return(responsesToCreate); }
public List <STOP> GetDataFromSTOPDbf(string filename) { DBFProcessor pr = new DBFProcessor(); List <STOP> result = new List <STOP>(); try { DataTable table = DBFProcessor.GetDataTable(filename, string.Format("select * from \"{0}\" where Q=3386;", filename)); foreach (DataRow row in table.Rows) { STOP data = new STOP(); data.SCENARIO = (string)(row["SCENARIO"]); data.S_CARD = (string)(row["S_CARD"]); data.N_CARD = ((decimal)row["N_CARD"]).ToString(); data.ENP = (string)row["ENP"]; data.VSN = ((string)row["VSN"]).Trim(); data.QZ = (long?)((decimal)row["QZ"]); data.DATE_END = (DateTime?)row["DATE_END"]; data.DATE_ARC = (DateTime?)row["DATE_ARC"]; data.IST = (string)row["IST"]; result.Add(data); } } finally { File.Delete(filename); } return(result); }
public List <NOMP> GetDataFromNOMPDbf(string filename) { DBFProcessor pr = new DBFProcessor(); List <NOMP> result = new List <NOMP>(); try { DataTable table = DBFProcessor.GetDataTable(filename, string.Format("select * from \"{0}\" where Q='P2';", filename)); foreach (DataRow row in table.Rows) { NOMP data = new NOMP(); data.S_CARD = (string)(row["S_CARD"]); data.N_CARD = ((decimal)row["N_CARD"]).ToString(); data.ENP = (string)row["ENP"]; data.VSN = (string)row["VSN"]; data.LPU_ID = (long?)((decimal)row["LPU_ID"]); data.DATE_IN = (DateTime?)row["DATE_IN"]; data.SPOS = (int?)((decimal)row["SPOS"]); result.Add(data); } } finally { File.Delete(filename); } return(result); }
public long?GetOurRowCount(string filename, string param) { try { DataTable table = DBFProcessor.GetDataTable(filename, string.Format("select count(1) from \"{0}\" where Q={1};", filename, param)); return((long)((decimal)((table.Rows[0])[0]))); } catch { return(null); } }
public List <FundResponse.UploadReportData> UploadSubmitFundResponse(User user, string zipPath) { List <FundResponse.UploadReportData> report = new List <FundResponse.UploadReportData>(); string zipDirectoryName = Path.Combine(ConfiguraionProvider.FileStorageFolder, Path.GetFileNameWithoutExtension(zipPath)); ZipHelper.UnZipFiles(zipPath, zipDirectoryName); var responsesToCreate = new List <FundResponse.CreateData>(); FundResponseCreateDataBuilder builder = new FundResponseCreateDataBuilder(); foreach (var file in Directory.GetFiles(zipDirectoryName)) { System.IO.FileInfo fInfo = new System.IO.FileInfo(file); DataTable dataTable = DBFProcessor.GetDataTable(fInfo.FullName, string.Format("select * from \"{0}\";", fInfo.FullName)); if (fInfo.Name.StartsWith("errp2", StringComparison.InvariantCultureIgnoreCase)) { dataTable.TableName = Path.GetFileNameWithoutExtension(fInfo.Name); IEnumerable <FundResponse.CreateData> list = builder.BuildList(FundErrorResponse.Name, dataTable); responsesToCreate.AddRange(list); } if (fInfo.Name.StartsWith("zP2", StringComparison.InvariantCultureIgnoreCase)) { IEnumerable <FundResponse.CreateData> list = builder.BuildList(GoznakResponse.Name, dataTable); responsesToCreate.AddRange(list); } } DateTime date = DateTime.Now; var responsesByclientVisitId = new Dictionary <long, List <FundResponse.CreateData> >(); List <FundRequestRecid> recids = FundProcessingDao.Instance.ClientVisitId_GetByFundRequesetRecid(responsesToCreate.Where(item => item.Recid.HasValue).Select(item => item.Recid.Value)); Dictionary <long, FundRequestRecid> recidsByRecid = recids.ToDictionary(item => item.Recid); foreach (FundResponse.CreateData response in responsesToCreate) { FundRequestRecid recid; if (response.Recid.HasValue && recidsByRecid.TryGetValue(response.Recid.Value, out recid)) { response.ClientVisitId = recid.ClientVisitId; } if (response.ClientVisitId != 0) { if (!responsesByclientVisitId.ContainsKey(response.ClientVisitId)) { responsesByclientVisitId.Add(response.ClientVisitId, new List <FundResponse.CreateData>()); } responsesByclientVisitId[response.ClientVisitId].Add(response); } else { report.Add(new FundResponse.UploadReportData() { Recid = response.Recid, Fullname = response.GetFullname(), ResponseTypeName = response.GetResponseTypeName(), UploadResult = "Не найдена соответствующая заявка" }); } } foreach (var pack in responsesByclientVisitId) { long clientVisitId = pack.Key; ClientVisit clientVisit = clientBusinessLogic.ClientVisit_Get(clientVisitId); if (clientVisit == null) { foreach (var response in pack.Value) { report.Add(new FundResponse.UploadReportData() { Recid = response.Recid, ClientVisitId = clientVisitId, ResponseTypeName = response.GetResponseTypeName(), UploadResult = "Не найдена соответствующая заявка" }); } continue; } ClientVisit lastClientVisit = clientBusinessLogic.ClientVisit_GetLastClientVisitInGroup(clientVisit.VisitGroupId); foreach (var response in pack.Value) { FundProcessingDao.Instance.FundResponse_Create(response, date); } foreach (FundErrorResponse.CreateData response in pack.Value.OfType <FundErrorResponse.CreateData>().Cast <FundErrorResponse.CreateData>()) { if (string.IsNullOrEmpty(response.ErrorCode) && string.IsNullOrEmpty(response.ErrorText)) { if (lastClientVisit.Status.Id == ClientVisitStatuses.AnswerPending.Id) { if (lastClientVisit.Scenario.Id == ClientVisitScenaries.PolicyExtradition.Id) { ClientDao.Instance.ClientVisit_SetStatus(user.Id, lastClientVisit.Id, ClientVisitStatuses.PolicyIssuedAndSentToTheFond.Id, true, date); report.Add(AddReportItem(clientVisit, response, lastClientVisit.Id, ClientVisitStatuses.PolicyIssuedAndSentToTheFond, date, "Загружен ответ фонда")); } else { ClientDao.Instance.ClientVisit_SetStatus(user.Id, lastClientVisit.Id, ClientVisitStatuses.Processed.Id, true, date); report.Add(AddReportItem(clientVisit, response, lastClientVisit.Id, ClientVisitStatuses.Processed, date, "Загружен ответ фонда")); } } else if (lastClientVisit.Status.Id == ClientVisitStatuses.FundError.Id) { ClientVisit.SaveData newClientVisitData = new ClientVisit.SaveData(clientVisit); newClientVisitData.Status = ClientVisitStatuses.Processed.Id; newClientVisitData.StatusDate = date; newClientVisitData.IsActual = true; var saveResult = clientBusinessLogic.ClientVisit_Save(user, newClientVisitData, date); report.Add(AddReportItem(clientVisit, response, saveResult.ClientVisitID, ClientVisitStatuses.Processed, date, "Загружен ответ фонда")); } } else { if (lastClientVisit.Status.Id == ClientVisitStatuses.Reconciliation.Id || lastClientVisit.Status.Id == ClientVisitStatuses.AnswerPending.Id) { ClientDao.Instance.ClientVisit_SetStatus(user.Id, lastClientVisit.Id, ClientVisitStatuses.FundError.Id, true, date); ClientVisit.SaveData newClientVisitData = new ClientVisit.SaveData(clientVisit); newClientVisitData.Status = ClientVisitStatuses.FundError.Id; newClientVisitData.StatusDate = date; newClientVisitData.IsActual = true; var saveResult = clientBusinessLogic.ClientVisit_Save(user, newClientVisitData, date); report.Add(AddReportItem(clientVisit, response, saveResult.ClientVisitID, ClientVisitStatuses.FundError, date, "Загружен ответ фонда")); } else { report.Add(AddReportItem(clientVisit, response, lastClientVisit.Id, lastClientVisit.Status, date, "Статус не изменен")); } } } foreach (GoznakResponse.CreateData response in pack.Value.OfType <GoznakResponse.CreateData>().Cast <GoznakResponse.CreateData>()) { if (lastClientVisit.Status.Id == ClientVisitStatuses.AnswerPending.Id || lastClientVisit.Status.Id == ClientVisitStatuses.Processed.Id || lastClientVisit.Status.Id == ClientVisitStatuses.FundError.Id) { ClientDao.Instance.ClientVisit_SetStatus(user.Id, lastClientVisit.Id, ClientVisitStatuses.SentToGoznak.Id, true, date); report.Add(AddReportItem(clientVisit, response, lastClientVisit.Id, ClientVisitStatuses.SentToGoznak, date)); } else { report.Add(AddReportItem(clientVisit, response, lastClientVisit.Id, lastClientVisit.Status, date, "Статус не изменен")); } } } return(report); }
public List <ClientVisit.UpdateResultData> UploadMFCClientVisitsExtradition(User user, string zipFilepath) { List <ClientVisit.UpdateResultData> report = new List <ClientVisit.UpdateResultData>(); string zipDirectoryName = Path.Combine(ConfiguraionProvider.FileStorageFolder, Path.GetFileNameWithoutExtension(zipFilepath)); ZipHelper.UnZipFiles(zipFilepath, zipDirectoryName); string[] filenames = Directory.GetFiles(zipDirectoryName); string file = filenames.FirstOrDefault(); System.IO.FileInfo fileInfo = new System.IO.FileInfo(file); DataTable table = DBFProcessor.GetDataTable(file, string.Format("select * from \"{0}\";", fileInfo.FullName)); foreach (DataRow row in table.Rows) { string unifiedPolicyNumber = (string)row["ENP"]; string temporaryPolicyNumber = (string)row["VSN"]; DateTime issueDate = (DateTime)row["DATE_V"]; ClientVisitInfo clientVisitInfo = clientBusinessLogic.ClientVisit_Find( new ClientVisitSearchCriteria() { TemporaryPolicyNumber = temporaryPolicyNumber }, new List <SortCriteria <ClientVisitSortField> >(), new PageRequest()).Data.FirstOrDefault(); if (clientVisitInfo != null) { ClientVisit visit = clientBusinessLogic.ClientVisit_GetLastClientVisitInGroup(clientVisitInfo.VisitGroupId); ClientVisit.SaveData data = ClientVisit.SaveData.BuildSaveData(visit); data.ScenarioId = ClientVisitScenaries.PolicyExtradition.Id; data.Status = ClientVisitStatuses.PolicyIssuedAndSentToTheFond.Id; data.StatusDate = issueDate; data.IssueDate = issueDate; data.NewPolicy.UnifiedPolicyNumber = unifiedPolicyNumber; clientBusinessLogic.ClientVisit_Save(user, data, data.IssueDate); report.Add(new ClientVisit.UpdateResultData() { Birthday = visit.NewClientInfo.Birthday, ClientId = visit.ClientId, ClientVisitGroupId = visit.VisitGroupId, Firstname = visit.NewClientInfo.Firstname, Id = visit.Id, IsSuccess = true, Lastname = visit.NewClientInfo.Lastname, Secondname = visit.NewClientInfo.Secondname, Sex = int.Parse(visit.NewClientInfo.Sex), Status = ClientVisitStatuses.PolicyIssuedAndSentToTheFond, UnifiedPolicyNumber = unifiedPolicyNumber, Message = "Успешно" }); } else { report.Add(new ClientVisit.UpdateResultData() { IsSuccess = false, UnifiedPolicyNumber = unifiedPolicyNumber, Message = "Не найден" }); } } return(report); }