private void dataImptBtnStkHeadImport_Click(object sender, EventArgs e) { BLLDataImport bllDaImpt = new BLLDataImport(CommProp.ConnectionString); UIInProcess(true); try { bllDaImpt.OpenConnection(); bllDaImpt.ImportStockHead(); Console.WriteLine("执行完成!"); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { bllDaImpt.CloseConnection(); } UIInProcess(false); }
private string LoadFileList_TDXDayFile(bool isComposite) { StringBuilder sb = new StringBuilder(); BLLDataImport bllDaImpt = new BLLDataImport(CommProp.ConnectionString); try { bllDaImpt.OpenConnection(); AllFile.Clear(); List <string> lstFullName = bllDaImpt.GetMatchedTDXDayFileFullNameList(isComposite); foreach (string fullName in lstFullName) { AllFile.Add(new FileInfo(fullName)); sb.AppendLine(fullName); } } finally { bllDaImpt.CloseConnection(); } //一行一行显示文件名 return(sb.ToString().TrimEnd(Environment.NewLine.ToCharArray()));; }
private void bkgDataImport_DoWork(object sender, DoWorkEventArgs e) { // < 覆盖,指数,TDX文件,K线级别 > TupleValue <bool, bool, bool, KLineType> arg = (TupleValue <bool, bool, bool, KLineType>)e.Argument; BLLDataImport bllDaImpt = new BLLDataImport(CommProp.ConnectionString); bool isConvert = arg.Value1; bool isComposite = arg.Value2; bool useTDXFile = arg.Value3; KLineType kLineType = arg.Value4; UIInProcess(true); _processCancel = false; if (useTDXFile) { this.LoadFileList_TDXDayFile(isComposite); } else { this.LoadFileList_exportFile(); } // List<TupleValue<完整文件名, StockHead>> List <TupleValue <string, StockHead> > lstStockData = bllDaImpt.LoadMrkTypeAndCodeFromDataFile(AllFile, isComposite, useTDXFile); if (lstStockData.Count > 0) { Stopwatch stopWatch = Stopwatch.StartNew(); try { bllDaImpt.OpenConnection(); int count = lstStockData.Count; int insLineCount = 0; string msgString = string.Empty; // 显示百分比提示信息 Action <int, int, int> showMsg = ((per, all, lineCnt) => { SysFunction.BackspaceInConsole(msgString, txtConsole); msgString = string.Format("{0} / {1},已导入:{2} 行)", per, all, lineCnt.ToString("N0")); Console.Write(msgString); }); Console.Write("正在导入...("); // 是否需要删表动作,如果表中无记录,则省去 Delete 动作 bool haveRecord = bllDaImpt.GetTableRecordCount(BLL.GetKLineDBTableName(kLineType, isComposite)) > 0; for (int i = 0; i < count; i++) { showMsg(i + 1, count, insLineCount); // TupleValue<完整文件名, StockHead> TupleValue <string, StockHead> stkData = lstStockData[i]; insLineCount += bllDaImpt.InsertStkKLine(stkData, isConvert, isComposite, useTDXFile, kLineType, haveRecord); // 最后一批完成后,再刷一下 if (i == count - 1) { showMsg(i + 1, count, insLineCount); } if (_processCancel) { break; } } if (_processCancel) { Console.WriteLine(" 导入终止!"); } else { Console.WriteLine(" 导入完成!"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { bllDaImpt.CloseConnection(); _processCancel = false; Console.WriteLine("总耗时:{0}", stopWatch.Elapsed); } } UIInProcess(false); }