private bool IsCheckValidate() { int totalReport = ReportList.Count(o => o.IsPrintReport || IsHasExportExcel(o.IsExportExcel)); if (totalReport <= 0) { MessageBoxHelper.ShowErrorMessage("Vui lòng chọn báo cáo để in."); return(false); } return(true); }
private void CheckNewReports(object sender, DoWorkEventArgs e) { int prevCount = -1; while (true) { if (ReportList != null && prevCount == -1) // only once { prevCount = ReportList.Count(); } GetReports(); if (ReportList.Count() != prevCount) // for loading the new data { prevCount = ReportList.Count(); kmeansLocationList = null; OnPropertyChanged(nameof(LocationList)); } Thread.Sleep(5000); } }
//private List<ReportInfo> GetReportInfos(DateTime fromDate, DateTime toDate) //{ // List<ReportInfo> result = new List<ReportInfo>(); // int pageEnd = 0; // int page = 0; // int totalReport = ReportItem_CheckedListBox.CheckedItemsCount; // for (int i = 0; i < ReportItem_CheckedListBox.ItemCount; i++) // { // ReportInfo item = ReportItem_CheckedListBox.GetItem(i).CastTo<ReportInfo>(); // if (item.IsPrintReport) // { // page++; // if (!IsPrintIn1File_CheckEdit.Checked) // { // pageEnd = 0; // } // ReportInfo report; // if (item.ReportID == ReportTemplate.RPT010) // { // report = GetSoQuyReportInfo(fromDate, toDate, item.ReportID, item.ReportName, ref pageEnd); // } // else // { // report = GetReportInfo(fromDate, toDate, item.ReportID, item.ReportName, ref pageEnd); // } // if (report != null) // { // result.Add(report); // } // int value = page * 100 / totalReport; // SetProcessing(value); // } // } // return result; //} private void SetReportInfos(DateTime fromDate, DateTime toDate) { ReportInfos = new List <ReportInfo>(); ExcelReportInfos = new List <ReportInfo>(); int pageEnd = 0; int reportNum = 0; int totalReport = ReportList.Count(o => o.IsPrintReport || IsHasExportExcel(o.IsExportExcel)); SetMaxProcessing(totalReport); ReportInfo report; List <ReportInfo> reportExcel; //ReportInfo reportExcel; foreach (ReportInfo item in ReportList) { report = null; reportExcel = null; //ReportInfo item = ReportItem_CheckedListBox.GetItem(i).CastTo<ReportInfo>(); if (item.IsPrintReport || IsHasExportExcel(item.IsExportExcel)) { reportNum++; //object reportSource = GetReportSource(item.ReportID, fromDate, toDate); if (item.IsPrintReport) { // xuất report if (!IsPrintIn1File_CheckEdit.Checked) { pageEnd = 0; } // report //if (item.ReportID == ReportTemplate.RPT010) //{ // report = GetSoQuyReportInfo(fromDate, toDate, item.ReportID, item.ReportName, ref pageEnd); //} //else //{ report = GetReportInfo(item, fromDate, toDate, ref pageEnd); //} // xuất excel if (IsHasExportExcel(item.IsExportExcel)) { if (string.IsNullOrEmpty(item.ReportExcelID)) { reportExcel = new List <ReportInfo> { report }; } else { reportExcel = GetReportInfoExcelList(item, fromDate, toDate); } } } else { // Chỉ chọn xuất excel reportExcel = GetReportInfoExcelList(item, fromDate, toDate); } if (item.IsPrintReport && report != null) { ReportInfos.Add(report); } if (IsHasExportExcel(item.IsExportExcel) && reportExcel != null) { ExcelReportInfos.AddRange(reportExcel); } //int value = reportNum * 100 / totalReport; SetProcessing(reportNum); } } }
private void ReportImport() { System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog(); openFileDialog.Filter = "标签模板|*.lbpt"; if (openFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } Encoding gbk = Encoding.GetEncoding("gbk"); ZipStrings.CodePage = gbk.CodePage; ZipFile zipFile = new ZipFile(openFileDialog.FileName); var json = zipFile.ZipFileComment; Report report = JsonConvert.DeserializeObject <Report>(json); if (ReportList.Count(r => r.Id == report.Id) > 0) { if (System.Windows.Forms.MessageBox.Show("已包含该模板,确定覆盖吗", "询问", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel) { return; } } for (int i = 0; i < zipFile.Count; i++) { var zipEntry = zipFile[i]; if (zipEntry.IsDirectory) { var folderPath = $"{Funs.ReportsFolder}/{zipEntry.Name}"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } continue; } var filePath = $"{Funs.ReportsFolder}/{zipEntry.Name}"; using (FileStream fs = new FileStream(filePath, FileMode.Create)) { using (Stream input = zipFile.GetInputStream(zipEntry)) { byte[] buffer = new byte[10 * 1024]; int length = 0; while ((length = input.Read(buffer, 0, 10 * 1024)) > 0) { fs.Write(buffer, 0, length); } } } } if (ReportList.Count(r => r.Id == report.Id) <= 0) { ReportAdd(report.Id, report.ReportName); } SelectedReport = ReportList.First(r => r.Id == report.Id); System.Windows.Forms.MessageBox.Show("导入完成", "提示"); }