private void FileWatcherOnFileCreated(object sender, FileSystemEventArgs e) { if (e.FullPath.Contains(".temp")) return; string temp = e.FullPath + ".temp"; try { if(File.Exists(temp)) File.Delete(temp); File.Copy(e.FullPath, temp); }catch{} try { FileDbEngine<ExchangeDataContainer> exContainerEngine = new FileDbEngine<ExchangeDataContainer>(temp); this.container = exContainerEngine.LoadFileDB(); } catch { MessageBox.Show("load failed."); } this.Invoke((MethodInvoker)(() => { if (this.cbIgnoreRefresh.Checked) return; try { this.dataGridView1.DataSource = container.FisrtList; this.dataGridView2.DataSource = container.SecondList; this.tbProductId.Text = container.FisrtList.First().ProductionID; this.webBrowser1.Navigate("https://zhaocaibao.alipay.com/pf/purchase.htm?productId=" + this.tbProductId.Text); File.Delete(e.FullPath); File.Delete(temp); } catch { } })); }
private void DoAnalysis() { var HittedRecord = RecordList.Where(x => x.MinMount >= this.zcbFileDb.MinMountLowerLimit && x.DayLeft <= this.zcbFileDb.DayLeftUpperLimit && x.DealCount <= this.zcbFileDb.DealCountUpperLimit) .OrderByDescending(x=>x.BuyIndex) .Take(this.zcbFileDb.DisplayTopCount) .ToList(); var SecondHittedRecord = RecordList.Where(x => x.DayLeft <= this.zcbFileDb.DayLeftUpperLimit) .OrderByDescending(x => x.BuyIndex) .Take(this.zcbFileDb.DisplayTopCount) .ToList(); Console.ForegroundColor = ConsoleColor.Green; foreach (var item in HittedRecord) { Console.WriteLine("Page={0:D2} Rate={1} R:{5:F2} DayLeft={2} MinMount={3} BuyIndex={4:F2}", item.PageIndex, item.YearRate, item.DayLeft, item.MinMount, item.BuyIndex, item.RawProfit); } Console.ResetColor(); double average = RecordList.Average(x => x.BuyIndex); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Average={0:F3}",average); Console.ResetColor(); var first = HittedRecord.FirstOrDefault(); if (first != null) { SaveHistory(first); this.speaker.Say("%" + first.BuyIndex.Round(2).ToString() ); if ( this.zcbFileDb.BuyIndexSendEmailEnabled && first.BuyIndex > this.zcbFileDb.BuyIndexSendEmailLimit ) { string msg = "{0}页{1}项-{2}天-{3}%--统合利率{4:F2}".FormatAs( first.PageIndex, first.ItemIndex, first.DayLeft, first.YearRate, first.BuyIndex); if (LastSentMsg != msg) { SendMessage(msg); LastSentMsg = msg; } } } ExchangeDataContainer exContainer = new ExchangeDataContainer(); exContainer.FisrtList = HittedRecord; exContainer.SecondList = SecondHittedRecord; ExportListToBuyUi(exContainer); }
private void ExportListToBuyUi(ExchangeDataContainer exContaienr) { string dirExchange = DirectoryHelper.CombineWithCurrentExeDir("ZcbListExchange"); if (!Directory.Exists(dirExchange)) Directory.CreateDirectory(dirExchange); string filePath = Path.Combine(dirExchange, "list.xml"); FileInfo file = new FileInfo(filePath); if (file.Exists) file.Delete(); var dbEngine = new FileDbEngine<ExchangeDataContainer>(filePath); dbEngine.SetDB(exContaienr); dbEngine.Save(false); }
private void btnLoad_Click(object sender, EventArgs e) { try { string filePath = DirectoryHelper.CombineWithCurrentExeDir("ZcbListExchange\\list.xml"); FileDbEngine<ExchangeDataContainer> exContainerEngine = new FileDbEngine<ExchangeDataContainer>(filePath); this.container = exContainerEngine.LoadFileDB(); this.dataGridView1.DataSource = container.FisrtList; this.dataGridView2.DataSource = container.SecondList; var first = container.FisrtList.FirstOrDefault(); if (first != null) { this.tbProductId.Text = container.FisrtList.First().ProductionID; this.webBrowser1.Navigate("https://zhaocaibao.alipay.com/pf/purchase.htm?productId=" + this.tbProductId.Text); } } catch { } }