private void btnSearch_Click(object sender, EventArgs e) { Global.HasNothingToConvert = false; SetStatus(ProcessStatus.Searching); FileService.CleanRootFolder(); var imageFiles = FileService.FindImages(); //get last count int iniRecord = bindingSource1.Count; bindingSource1.DataSource = imageFiles.ToList(); dgFiles.DataSource = bindingSource1; if (iniRecord <= 0) { var stat = BaiRocService.GetEngineStat(); if (imageFiles.Count > 0) { stat.Status = "Scanning"; if (stat.MaxValue > 0) { stat.LastBatchCount = stat.MaxValue; } stat.MaxValue = imageFiles.Count; stat.Value = 1; stat.LastStart = DateTime.Now; var imageFolder = Path.GetFileNameWithoutExtension(Global.CurrentImageFolder); stat.CurrentFolder = Global.CurrentUser + "/" + imageFolder; BaiRocService.UpdateEngine(stat); } if (stat.Value >= stat.MaxValue) { stat.Status = "Idle"; //stat.LastBatchCount = stat.MaxValue; //stat.TotalConvert += stat.MaxValue; //stat.MaxValue = 0; //stat.Value = 0; BaiRocService.UpdateEngine(stat); } } else { var stat = BaiRocService.GetEngineStat(); stat.Value += 1; BaiRocService.UpdateEngine(stat); } SetStatus(ProcessStatus.Ready); }
private void btnExcel_Click(object sender, EventArgs e) { string csvName = "receipt"; using (MyReceiptOnlyContext db = new MyReceiptOnlyContext()) { var q = db.TableReceipts.Where(r => r.UserFolder == Global.CurrentUser); var list = q.OrderBy(r => r.Created).ToList(); if (list.Count > 0) { var cnt = list.Count; csvName += cnt.ToString(); } this.bindingSourceCSV.DataSource = list; dgCSV.DataSource = bindingSourceCSV; this.bindingNavigatorCSV.BindingSource = bindingSourceCSV; } //export to csv var folder = Global.Config.GetValue("FrontFolder") + "\\" + Global.CurrentUser; //Global.CurrentUserFolder; var file = csvName + ".csv"; var path = Path.Combine(folder, file); SaveDataGridViewToCSV(path); var stat = BaiRocService.GetEngineStat(); if (stat.Value >= stat.MaxValue) { stat.Status = "Idle"; stat.LastBatchCount = stat.MaxValue; stat.TotalConvert += stat.MaxValue; stat.MaxValue = 0; stat.Value = 0; BaiRocService.UpdateEngine(stat); } }
private void btnAutoRun_Click(object sender, EventArgs e) { chkIsScanBusy.Checked = false; Global.MakeScanIdle = chkIsScanBusy.Checked; while (Global.MakeScanIdle == false) { //try //{ btnSearch_Click(sender, e); btnChekFile_Click(sender, e); if (Global.HasNothingToConvert == true) { Application.DoEvents(); var limit = DateTime.Now.AddSeconds(10); shutdown -= 1; Console.WriteLine("Shutsdown in ..." + shutdown.ToString()); if (shutdown < 1) { Global.IsShuttingDown = true; //this.Close(); // System.Windows.Forms.Application.Exit(); System.Environment.Exit(0); } while (DateTime.Now < limit) { ConsoleSpinner.Instance.Update(); //AsciiArt.Draw(); Task.Delay(100); Application.DoEvents(); } //Task.Delay(5000); break; } if (bindingSource1.Current == null) { break; } btnScan_Click(sender, e); if (Global.ProcessStatus == ProcessStatus.Error.ToString()) { Global.ProcessStatus = ProcessStatus.Ready.ToString(); break; } if (Global.HasNothingToConvert) { var stat = BaiRocService.GetEngineStat(); stat.Status = "Idle"; stat.MaxValue = 0; stat.Value = 0; BaiRocService.UpdateEngine(stat); break; } if (Global.OcrLines == null) { break; } //keep running.. shutdown = 4; try { btnWeight_Click(sender, e); btnSigma_Click(sender, e); btnElect1_Click(sender, e); btn2ndElection_Click(sender, e); btn3rdElection_Click(sender, e); btnCreateReceipt_Click(sender, e); btnDetails_Click(sender, e); } catch (Exception) { RecoverFromError1(sender, e); } try { btnAuthenticatedSet_Click(sender, e); btnUserSet_Click(sender, e); btnSave_Click(sender, e); btnExcel_Click(sender, e); } catch (Exception) { RecoverFromError3(sender, e); } Application.DoEvents(); } if (Global.MakeScanIdle == false) { btnAutoRun_Click(sender, e); } }