private async Task <object> DohRecord(s_lev lev, dynamic objSE, dynamic obj, ImportParam importParam) { bool ok = false; DateTime?date = null; decimal summa = 0.0M; if (obj.TYPE_KBK == "20" && lev != null) { var oktmopp = lev?.Oktmo ?? ""; var oktmo = GetOktmo(oktmopp.Substr(0, 8), importParam); // Для SE не фильтруем по m.o.idOkato = 0 он уже из lev //if (oktmo != null) //{ ok = true; date = objSE.DATE_SP; if (obj.Marker == "SPOST") { summa = (decimal)obj.SUM_POST; } else if (obj.Marker == "SVIP") { summa = (decimal)obj.SUM_VIP; } //} } return(ok, date, summa); }
private async Task <object> DohRecord(dynamic objNP, dynamic objNPST, ImportParam importParam) { bool ok = false; DateTime?date = null; decimal summa = 0.0M; var dateOtch = (DateTime)objNP.DATE_OTCH; var dateEnd = (DateTime)objNP.DATE_END_PER; if (dateOtch != dateEnd) { dateOtch = objNPST.DATE_DOC_VB; } if (dateOtch != null && objNPST.TYPE_KBK == "20") { // пропускаем, могли писать бы на какую то дату MIN(MAX(m.dDateBeg, m.o.dDatePP + 2), m.dDateEnd) например string oktmopp = objNPST.OKATO; // Область обязательно, даже если не прописана в ca_okato(из за акцизов) var isOblast = oktmopp.StartsWith("45000000") || oktmopp.StartsWith("46000000"); var oktmo = GetOktmo(oktmopp.Substr(0, 8), importParam); if (oktmo != null || isOblast) { // Пишем ok = true; date = dateOtch; summa = (decimal)objNPST.SUM; } } return(ok, date, summa); }
public override async Task <bool> AfterDataWrited(List <t_dohod> dohods, ImportParam importParam) //, bool isUvDocMarking = true) { // пытаемся определить плательщика, через уведомление foreach (var dohod in dohods)//.Where(x=>x.IsNp ?? false)) { var uvdet = await _dohodDbContext.IdentUved(dohod, importParam, true); if (uvdet != null) { // Также для парной записи var dohpair = await _dohodDbContext.t_dohod.FirstOrDefaultAsync(x => x.Guid == dohod.Guid && x.Sysid != dohod.Sysid && Math.Abs(x.SumItg) == Math.Abs(dohod.SumItg)); if (dohpair != null) { dohpair.PlatId = dohod.PlatId; dohpair.Orig.Inn = dohod.Orig.Inn; // ?? Може достаточно PlatId dohpair.Orig.Kpp = dohod.Orig.Kpp; _dohodDbContext.t_dohod.Update(dohpair); await _dohodDbContext.SaveChangesAsync(); } } } return(true); }
protected override async Task <t_dohod> ChechRecord(t_dohod dohod, ImportParam importParam) { if (dohod == null) { return(null); } var record = await GetExistingRecord(dohod); if (record != null) { // VT или NP if (record.VidDoc == VidDoc.NP) { // Записи из NP не заменяем данными VT, Переиндетификацию уведомлений непроизводим _previewdata.recsSkip++; return(null); } if (record.VidDoc == VidDoc.VT) { _previewdata.recsUpd++; dohod.Sysid = record.Sysid; dohod.Orig.Sysid = record.Orig.Sysid; dohod.Orig.DohodId = record.Sysid; return(dohod); } } _previewdata.recsAdd++; return(dohod); }
public async Task <object> ParserFormat(object doc, ImportParam importParam) { await DeleteTheFileData(importParam); var dohods = new List <t_dohod>(); dynamic objVT = null; foreach (dynamic obj in (List <ExpandoObject>)doc) { switch (obj.Marker) { case "VT": objVT = obj; break; case "VTOPER": var dohod = await DohRecord(objVT, obj, importParam); dohod = await ChechRecord(dohod, importParam); if (dohod == null) { continue; } dohods.Add(dohod); break; default: break; } } return(dohods); }
public void Import(ImportParam importParam) { var validate = new ImportParamValidator().Validate(importParam); if (!validate.IsValid) { throw new ApplicationException($"Falha nos parâmetros de entrada ({string.Join(",", validate.Errors)})"); } var repository = new BovespaRepository(); var stockNegotiationList = repository.ImportFileHistory(importParam.BasePath, importParam.FileName); var stockRepository = new StockRepository(); var stockDic = new Dictionary <string, Stock>(); foreach (var stockNegotiation in stockNegotiationList) { if (!stockDic.ContainsKey(stockNegotiation.Stock.Code)) { stockDic.Add(stockNegotiation.Stock.Code, stockNegotiation.Stock); } } var stockList = stockDic.Select(a => a.Value).ToList(); stockRepository.BulkMerge(stockList); stockRepository.BulkMerge(stockNegotiationList); }
public async Task <object> PreviewFormat(object doc, ImportParam importParam) { decimal summa = 0.0M; var reccount = 0; var writecount = 0; DateTime datemin = default(DateTime); DateTime datemax = default(DateTime); foreach (dynamic obj in (List <ExpandoObject>)doc) { if (obj.Marker == "ZF") { reccount++; (bool ok, DateTime? date, decimal summa)rec = DohRecord(obj, importParam); if (!rec.ok) { continue; } writecount++; (datemin, datemax) = rec.date.GetMinMax(datemin, datemax); summa += rec.summa; } } return(InfoPreviewData(doc, reccount == 0, reccount, writecount, summa, datemin, datemax, importParam)); }
/// <summary> /// 新增数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { string desStr1 = this.textBox1.Text.Trim(); if (string.IsNullOrEmpty(desStr1)) { MessageBox.Show("插入失败,textBox1为空!"); return; } string desStr2 = this.textBox2.Text.Trim(); if (string.IsNullOrEmpty(desStr1)) { MessageBox.Show("插入失败,textBox2为空!"); return; } ImportParam importZ = new ImportParam() { MDirection = this.comboBox1.SelectedItem.ToString(), WDirection = this.comboBox2.SelectedItem.ToString(), DescribeZ = desStr1, CDirection = this.comboBox3.SelectedItem.ToString(), DescribeF = desStr2 }; bool flag = YzsyManament.GetInstance().ImportYzsy(importZ); MessageBox.Show($"插入结果:{flag}!"); RefreshYzsyList(Convert.ToInt32(this.comboBox4.SelectedItem.ToString()), currentIndex); }
protected virtual async Task <t_dohod> ChechRecord(t_dohod dohod, ImportParam importParam) { if (dohod == null) { return(null); } // Стандартно: добавить или обновить, ничего не пропуская var record = await GetExistingRecord(dohod); if (record != null) { // var yy = _dohodDbContext.Entry(dohod); // var xx = _dohodDbContext.Entry(record); // _dohodDbContext.Entry(record).State = EntityState.Detached; // _previewdata.recsUpd++; dohod.Sysid = record.Sysid; dohod.Orig.Sysid = record.Orig.Sysid; dohod.Orig.DohodId = record.Sysid; //yy.State = EntityState.Modified; } else { _previewdata.recsAdd++; } //importParam.recsSkip = 0; return(dohod); }
private void setBusinessVolumeParams(ImportParam importParam, ImportType importType) { string fileName; switch (importType) { case ImportType.ActualBusinessVolume: fileName = ImportManager.BusinessVolumeActualFileSearchPattern; break; case ImportType.TargetBusinessVolume: fileName = ImportManager.BusinessVolumeTargetFileSearchPattern; break; case ImportType.CashRegisterReceipt: fileName = ImportManager.CashRegisterReceiptFileSearchPattern; break; default: goto case ImportType.ActualBusinessVolume; } ServerImportFoldersInfo serverImportFoldersInfo = importParam.StoreService.GetServerImportFoldersInfo(); addTextToMemo(string.Format(GetLocalized("BVInformation"), serverImportFoldersInfo.SourceFolder, fileName, serverImportFoldersInfo.ImportedFolder)); _ImportFormType = importType; }
public async Task <IActionResult> ImportUserJson(ImportParam param) { List <UserEntity> list = new ExcelHelper <UserEntity>().ImportFromExcel(param.FilePath); TData obj = await userBLL.ImportUser(param, list); return(Json(obj)); }
protected override async Task <t_dohod> ChechRecord(t_dohod dohod, ImportParam importParam) { if (dohod == null) { return(null); } var record = await GetExistingRecord(dohod); if (record != null) { // if (record.VidDoc == VidDoc.BD) { // Пропускаем BD _previewdata.recsSkip++; return(null); } else { // Запись из XL, VT, NP, SF -Обновляем _previewdata.recsUpd++; dohod.Sysid = record.Sysid; dohod.Orig.Sysid = record.Orig.Sysid; dohod.Orig.DohodId = record.Sysid; return(dohod); } } _previewdata.recsAdd++; return(dohod); }
public void GetImportInfoEntity(int communityID, int t19LeafID, int treeID, int txLeafID, long sysLogID, out ImportParam param, out List <ImportMetaData> metaDatas, out int errCode, out string errText) { string strProcedureName = string.Format("{0}.{1}", className, MethodBase.GetCurrentMethod().Name); GetImportInfoEntity(communityID, t19LeafID, txLeafID, sysLogID, out param, out metaDatas, out errCode, out errText); if (!ImportParaValidate(param, out errText)) { errCode = 9999; WriteLog.Instance.Write(errText, strProcedureName); return; } if (Convert.ToInt32(param.DstTableExist) == 0) { CreateTable(communityID, t19LeafID, treeID, txLeafID, sysLogID, param.ProcToCreateTBL, out errCode, out errText); if (errCode != 0) { WriteLog.Instance.Write(errText, strProcedureName); return; } GetImportInfoEntity(communityID, t19LeafID, treeID, txLeafID, sysLogID, out param, out metaDatas, out errCode, out errText); } if (!ImportMetaDataValidate(metaDatas, out errText)) { errCode = 9999; WriteLog.Instance.Write(errText, strProcedureName); return; } errText = "成功获取导入的xml信息!"; WriteLog.Instance.Write(errText, strProcedureName); return; }
/// <summary> /// 插入单个数据 /// </summary> /// <param name="importStr"></param> /// <returns></returns> public bool ImportYzsy(ImportParam import) { using (CompassDbContext dbContext = new CompassDbContext()) { try { var obj = dbContext.Yzsys.Where(r => r.MDirection.Equals(import.MDirection) && r.WDirection.Equals(import.WDirection) && r.CDirection.Equals(import.CDirection)).FirstOrDefault(); if (obj != null) { return(false); } dbContext.Yzsys.Add(new Tb_YZSY() { MDirection = import.MDirection, WDirection = import.WDirection, DescribeZ = import.DescribeZ, CDirection = import.CDirection, DescribeF = import.DescribeF }); var n = dbContext.SaveChanges(); if (n > 0) { return(true); } } catch (Exception ex) { //MessageBox.Show($"数据库单个插入YZSY失败,{ex.ToString()}"); } } return(false); }
private fk_code FkCodeRecord(fk_doc fkDoc, dynamic objTb, ImportParam importParam) { if (fkDoc == null) { return(null); } //if (string.IsNullOrWhiteSpace(objTb.NumOrder)) // филтр // return null; fk_code fkCode = new fk_code() { DocId = fkDoc.Sysid, Marker = objTb.Marker, NumPos = objTb.NumPos, NumOrder = objTb.NumOrder, Code = objTb.Code, FldType = objTb.FldType, FldLen = objTb.FldLen, IsFilled = ((string)objTb.IsFilled) == "Да", Descript = objTb.Descript, Comments = objTb.Comments }; // fkCode.FkDoc = fkDoc; return(fkCode); }
public async Task <TData> ImportUser(ImportParam param, List <UserEntity> list) { TData obj = new TData(); if (list.Any()) { foreach (UserEntity entity in list) { UserEntity dbEntity = await userService.GetEntity(entity.UserName); if (dbEntity != null) { entity.Id = dbEntity.Id; if (param.IsOverride == 1) { await userService.SaveForm(entity); await RemoveCacheById(entity.Id.Value); } } else { await userService.SaveForm(entity); await RemoveCacheById(entity.Id.Value); } } obj.Tag = 1; } else { obj.Message = " 未找到导入的数据"; } return(obj); }
protected override async Task <t_dohod> ChechRecord(t_dohod dohod, ImportParam importParam) { if (dohod == null) { return(null); } var record = await GetExistingRecord(dohod); if (record != null) { // здесь только записи NP, VT, SF if (record.VidDoc == VidDoc.NP) { // Записи из NP не заменяем данными SF _previewdata.recsSkip++; return(null); } else { _previewdata.recsUpd++; dohod.Sysid = record.Sysid; dohod.Orig.Sysid = record.Orig.Sysid; dohod.Orig.DohodId = record.Sysid; return(dohod); } } _previewdata.recsAdd++; return(dohod); }
public async Task <ResultCrmDb> PreviewFile(byte[] fileData, ImportParam importParam) { var result = new ResultCrmDb(); importParam.TypeImp = ImportType.Preview; try { // TheOktmo потом перенести в Settings _dohodDbContext.SetTheOktmo(importParam, result); if (!result.Succeeded) { return(result); } var parserFile = AutoFac.ResolveNamed <IParseFile>(importParam.FormatGroup); parserFile.FileData = fileData; parserFile.ImportParam = importParam; var parserResult = await parserFile.ParseFile(); if (!parserResult.Succeeded) { return(parserResult); } var previewFormat = AutoFac.ResolveNamed <IPreviewFormat>(importParam.FormatGroup + importParam.Format); result.Result = (ImpPreviewData)await previewFormat.PreviewFormat(parserResult.Result, importParam); } catch (Exception ex) { result.AddError(Constant.ErrCodeImport, ex.Message); result.AddError(Constant.ErrCodeStackTrace, ex.StackTrace); } return(result); }
// ======================================== fk_doc === fk_code ========================== public async Task <ResultCrmDb> LoadFkDocxFormat(byte[] fileData, ImportParam importParam) { var result = new ResultCrmDb(); importParam.TypeImp = ImportType.None; try { var parserFile = AutoFac.ResolveNamed <IParseFile>("FKDOCX"); parserFile.FileData = fileData; parserFile.ImportParam = importParam; var parserResult = await parserFile.ParseFile(); if (!parserResult.Succeeded) { return(parserResult); } var parserFormat = AutoFac.ResolveNamed <IParserFormat>("FKDOCX00"); var fkCodes = (List <fk_code>) await parserFormat.ParserFormat(parserResult.Result, importParam); await WriteFkCode(fkCodes); } catch (Exception ex) { result.AddError(Constant.ErrCodeImport, ex.Message); result.AddError(Constant.ErrCodeStackTrace, ex.StackTrace); } return(result); }
private (DateTime, DateTime) CorrectFileName(object doc, ImportParam importParam) { // Исходные наименования файлов не уникальны. // Формируется специальные уникальные наименования по содержимому файла. var teritory = ""; DateTime dtheader = default(DateTime); DateTime dtmin = default(DateTime); DateTime dtmax = default(DateTime); foreach (dynamic obj in (List <ExpandoObject>)doc) { if (obj.Marker == Constant.MarkerXlHeader) { dtheader = obj.DATEVYB; teritory = obj.TERRITORY; continue; } // TB (dtmin, dtmax) = ((DateTime?)obj.DATE_IN_TOFK).GetMinMax(dtmin, dtmax); if (dtmin == default(DateTime)) { (dtmin, dtmax) = (dtheader, dtheader); } } importParam.FileName = $"{teritory}-{dtmin:MMdd}-{dtmax:dd}{Path.GetExtension(importParam.FileName)}"; return(dtmin, dtmax); }
public async Task <object> ParserFormat(object doc, ImportParam importParam) { (DateTime dtMin, DateTime dtmax) = CorrectFileName(doc, importParam); await DeleteTheFileData(importParam); // var dohods = new List <t_dohod>(); dynamic objHeader = null; foreach (dynamic obj in (List <ExpandoObject>)doc) { if (obj.Marker == Constant.MarkerXlHeader) { objHeader = obj; continue; } // TB var org = await _dohodDbContext.IdentPlat((string)obj.INN_PAY, (string)obj.KPP_PAY, (string)obj.CNAME_PAY, ""); var dohod = await DohRecord(org, objHeader, obj, importParam, dtMin, dtmax); dohod = await ChechRecord(dohod, importParam); if (dohod != null) { dohods.Add(dohod); } } return(dohods); }
public async Task <object> PreviewFormat(object doc, ImportParam importParam) { dynamic objVT = null; decimal summa = 0.0M; var reccount = 0; var writecount = 0; DateTime datemin = default(DateTime); DateTime datemax = default(DateTime); foreach (dynamic obj in (List <ExpandoObject>)doc) { if (obj.Marker == "VT") { objVT = obj; datemin = obj.DATE_OTCH; datemax = obj.DATE_OTCH; } else if (obj.Marker == "VTOPER") { reccount++; (bool ok, decimal summa)rec = await DohRecord(obj, importParam); if (!rec.ok) { continue; } writecount++; summa += rec.summa; } } return(InfoPreviewData(doc, (bool)(objVT == null), reccount, writecount, summa, datemin, datemax, importParam)); }
public async Task <object> ParserFormat(object doc, ImportParam importParam) { await DeleteTheFileData(importParam); var dohods = new List <t_dohod>(); dynamic objBD = null; dynamic objBDPD = null; s_org org = null; foreach (dynamic obj in (List <ExpandoObject>)doc) { switch (obj.Marker) { case "BD": if (!FilterBD(obj)) { continue; } objBD = obj; break; case "BDPD": if (objBD == null) { continue; } org = await _dohodDbContext.IdentPlat((string)obj.INN_PAY, (string)obj.KPP_PAY, (string)obj.CNAME_PAY, (string)obj.BS_PAY); if (org == null) { continue; } objBDPD = obj; break; case "BDPDST": if (objBDPD == null) { continue; } var dohod = await DohRecord(org, objBD, objBDPD, obj, importParam); dohod = await ChechRecord(dohod, importParam); if (dohod == null) { continue; } dohods.Add(dohod); break; default: objBDPD = null; break; } } return(dohods); }
private async Task <object> DohRecord(s_lev lev, dynamic objIP, dynamic obj, ImportParam importParam) { bool ok = false; DateTime?date = null; decimal summa = 0.0M; if (obj.TYPE_KBK == "20") { if (obj.Marker == "IPSTBK_E") { lev = await _dohodDbContext.IdentLevelOnNameBudget((string)obj.NAME_BUD); } if (lev != null) { var oktmopp = lev?.Oktmo ?? ""; var oktmo = GetOktmo(oktmopp.Substr(0, 8), importParam); // Для IP пока не фильтруем по m.o.idOkato = 0 //if (oktmo != null) //{ ok = true; date = objIP.DATE_OTCH; summa = (decimal)obj.SUM_POST_DATE; //} } } return(ok, date, summa); }
protected string CheckFormatInFile(dynamic header, ImportParam importParam) { string formatstr = (string)header.VERSIONSTR; if (formatstr == null) { return(null); } var formatinfile = formatstr.To("|") + formatstr.Between("|", "|"); if (formatinfile.Length != 12) { return(null); } var formatinfilename = Path.GetFileNameWithoutExtension(importParam.FileName); if (!formatinfilename.StartsWith("FK")) { formatinfilename = "FK" + formatinfilename; } if (formatinfilename.Length != 12) { return(null); } if (formatinfile != formatinfilename) { return(null); } return(formatinfilename.Substring(6)); }
public async Task <object> PreviewFormat(object doc, ImportParam importParam) { dynamic objIP = null; decimal summa = 0.0M; s_lev lev = null; var reccount = 0; var writecount = 0; DateTime datemin = default(DateTime); DateTime datemax = default(DateTime); foreach (dynamic obj in (List <ExpandoObject>)doc) { if (obj.Marker == "IP") { objIP = obj; lev = await _dohodDbContext.IdentLevelOnSchet((string)objIP.BS); } else if (obj.Marker == "IPSTBK_E_KBK" && objIP != null) { reccount++; if (!OkSchet()) { continue; } (bool ok, DateTime? date, decimal summa)rec = await DohRecord(lev, objIP, obj, importParam); if (!rec.ok) { continue; } writecount++; (datemin, datemax) = rec.date.GetMinMax(datemin, datemax); summa += rec.summa; } else if (obj.Marker == "IPSTBK_E" && objIP != null) { reccount++; if (OkSchet()) { continue; } (bool ok, DateTime? date, decimal summa)rec = await DohRecord(lev, objIP, obj, importParam); if (!rec.ok) { continue; } writecount++; (datemin, datemax) = rec.date.GetMinMax(datemin, datemax); summa += rec.summa; } } return(InfoPreviewData(doc, (bool)(objIP == null), reccount, writecount, summa, datemin, datemax, importParam)); bool OkSchet() => lev != null && !string.IsNullOrWhiteSpace(lev.Inn) && !string.IsNullOrWhiteSpace(lev.Kpp); }
public override async Task <bool> AfterDataWrited(List <t_dohod> dohods, ImportParam importParam) //, bool isUvDocMarking = true) { // пытаемся определить плательщика, через уведомление foreach (var dohod in dohods) { var uvdet = await _dohodDbContext.IdentUved(dohod, importParam, true); } return(true); }
public static void SetTheOktmo(this DohodDbContext dbContext, ImportParam importParam, ResultCrmDb result) { //dbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; importParam.TheOktmo = dbContext.s_oktmo.AsNoTracking().Where(x => x.CodeAte == importParam.CodeAte && x.CodePos == importParam.CodePos).FirstOrDefault(); if (importParam.TheOktmo == null) { result.AddError(Constant.ErrCodeSetting, "Не найден ОКТМО. Возможно, не правильные параметры настройки"); } }
public static void ValidateParameters(ImportParam param) { if (param.ObjectTypeInfo == null) { throw new ArgumentException( string.Format("ObjectTypeInfo cannot be null. " + "This may also be because ObjectTypeName '{0}' does not match any business objects", param.ObjectTypeName), "ObjectTypeInfo"); } }
public async Task <ResultWebApi <List <ODTOTestDemo> > > ImportExport(IFormFile input) { ImportParam inputParam = new ImportParam() { FileBase64 = input.OpenReadStream().Convert2Base64(true) }; var result = _displayer.ImportExcel(inputParam); return(result.ToResultWebApi()); }