private void ExportBody(ExportFileParameters parameters, QueryPageCountResult result,ExportIndex index) { object[] data = GetData(parameters.IsPL,index); string continuousFileName = GetFileName(parameters.QueryInfo.FilePath, index, result.PageCount); using (FileStream fs = new FileStream(continuousFileName, FileMode.Create, FileAccess.Write)) { int startFileIndex = index.RecordIndex * 150 + 1; if (parameters.IsPL) { PLExportCenter.Default.Process((PLData[])data, startFileIndex,fs); } else { FlexInterface.Helper.FlexPersistence.PersiteDesposit((DepositData[])data, fs,startFileIndex , parameters.QueryInfo.Type); } this._ErrorHandler.WhenExportPerPageSendMsgToUI(parameters.IsPL, index, result.PageCount); index.FileIndex++; index.PageIndex++; index.RecordIndex++; } }
public bool IsDataNormal(QueryPageCountResult result) { ReturnType type = result.Type; if (type == ReturnType.Normal && result.PageCount > 0) return true; string errorMsg = string.Empty; if (type == ReturnType.NoData) { errorMsg = "No Data"; } else if (type == ReturnType.DataNotComplete) { errorMsg = "Some record's data is not complete "; } else if (type == ReturnType.Error) { errorMsg = "Server error"; } else { errorMsg = "No Data"; } DebugHelper.Log("export " + errorMsg); Common.SynchronizationContext.Send(m => { Messenger.Default.Send(new ShowProgressMsg(false)); MessageBox.Show(errorMsg); }, null); return false; }
public QueryPageCountResult GetPLDataPageCount(string sessionID, QueryObject parameter) { PLPrameter plParameter = new PLPrameter() { FromTradeDay = parameter.BeginDatetime, ToTradeDay = parameter.EndDatetime, AccountCodeString = parameter.AccountStr, Type = parameter.Type, IsGetRecordCount = false }; string sql = ProcedureStrFactory.CreateQueryPlSql(plParameter); QueryPageCountResult result = new QueryPageCountResult(); List<PLData> plList = new List<PLData>(); _Log.WarnFormat(" GET PL DATA, sql: {0} ", sql); DataSet ds = DataAccess.GetData(sql, ConfigHelper.ConnectionString, TimeSpan.FromMinutes(10)); _Log.Warn(string.Format("GET PL DATA End. Result Count:{0}", ds.Tables[0].Rows.Count)); foreach (DataRow dr in ds.Tables[0].Rows) { try { PLData plData = Fill(dr, parameter.Type); if (plData == null) { result.Type = ReturnType.DataNotComplete; return result; } plData.FromTradeDay = parameter.BeginDatetime; plData.ToTradeDay = parameter.EndDatetime; if (plData is FloatingPLData) { FloatingPLData data = (FloatingPLData)plData; DateTime targetDate = data.FromTradeDay.AddDays(-1); data.LastFloatingPLData.FromTradeDay = targetDate; data.LastFloatingPLData.ToTradeDay =data.ToTradeDay; } if (plData.OriginAmount == 0) continue; plList.Add(plData); } catch (ArgumentNullException ane) { _Log.Error(ane); result.Type = ReturnType.DataNotComplete; return result; } catch (Exception ex) { _Log.Error(ex); result.Type = ReturnType.Error; return result; } } int count = plList.Count; _Log.InfoFormat("Final Data quantity: {0}", count); if (count == 0) { result.Type = ReturnType.NoData; } else { result.Type = ReturnType.Normal; } result.PageCount = count / ConfigHelper.PageSize + (count % ConfigHelper.PageSize == 0 ? 0 : 1); lock (this._SycBlock) { this._Dict[sessionID] = plList; } return result; }
public QueryPageCountResult GetDepositPageCount(string sessionID, QueryObject parameter) { QueryPageCountResult result = new QueryPageCountResult(); QueryDepositRecordParameter depositParameter = new QueryDepositRecordParameter { FromTradeDay= parameter.BeginDatetime, ToTradeDay=parameter.EndDatetime, AccountCodeStr=parameter.AccountStr, DepositCodeStr=parameter.DepositQueryStr, PaymentType=parameter.Type, IsGetRecordCount=false }; string sql = ProcedureStrFactory.CreateQueryDepositRecordSql(depositParameter); _Log.Warn(string.Format("GetDepositData {0}", sql)); DataSet ds = DataAccess.GetData(sql, ConfigHelper.ConnectionString, TimeSpan.FromMinutes(10)); _Log.Warn(string.Format("GetDepositData End Count: {0}", ds.Tables[0].Rows.Count)); Guid? accountingBaseCurrencyId = CurrencyRepository.GetAccountingBaseCurrency(); if (accountingBaseCurrencyId == null) { result.Type = ReturnType.DataNotComplete; return result; } string baseCurrencyName = CurrencyRepository.GetCurrencyName(accountingBaseCurrencyId.Value); List<DepositData> list = new List<DepositData>(); foreach (DataRow dr in ds.Tables[0].Rows) { try { var data = Fill(dr, baseCurrencyName, parameter.Type); if (data == null) { result.Type = ReturnType.DataNotComplete; return result; } if (parameter.Type != BusinessTypeEnum.Transfer) FlexInterface.Helper.DepositInnerService.AddDesc(parameter.Type, data); list.Add(data); } catch (Exception ex) { _Log.ErrorFormat("GetDepositData {0}", ex); result.Type = ReturnType.Error; return result; } } int count = list.Count; if (parameter.Type == BusinessTypeEnum.Transfer) { count = count / 2; List<DepositData> transferList = new List<DepositData>(); foreach (var item in list.GroupBy(m => m.MarginReference).ToDictionary(m => m.Key, m => m.OrderBy(x => x.SourceAmount).ToList())) { if (item.Value.Count != 2) { result.Type = ReturnType.Error; return result; } var target = item.Value[1]; target.Transfer = item.Value[0]; FlexInterface.Helper.DepositInnerService.AddDesc(BusinessTypeEnum.Transfer, target); transferList.Add(target); } lock (this._SycBlock) { this._Dict[sessionID] = transferList; } } else { lock (this._SycBlock) { this._Dict[sessionID] = list; } } _Log.Warn(string.Format("GetDepositData Complete Count: {0}", count)); result.Type = ReturnType.Normal; result.PageCount = this._CommonService.GetPageCount(count); return result; }