protected void Page_Load(object sender, EventArgs e) { PublishJobTable.GetPublishedJobTable_All(); this.DgvGdh.DataSource = MySqlDbHelper.ExecuteDataTable( sqlSelect + " ORDER BY `Excel时间` DESC LIMIT 300"); this.DgvGdh.DataBind(); }
protected void ButtonSearch_Click(object sender, EventArgs e) { PublishJobTable.GetPublishedJobTable_All(); string searchTxt = this.TextBoxSearch.Text.Trim(); if (!string.IsNullOrWhiteSpace(searchTxt)) { // StringBuilder sb = new StringBuilder(); // DataTable tempDt = SQLiteDbHelper.ExecuteDataTable("SELECT `ID],`稿袋号],`客户简称],`产品名称]FROM`Job]"); // foreach (DataRow row in tempDt.Select(string.Format("`客户简称] LIKE '%{0}%' OR`产品名称] LIKE '%{0}%'OR`稿袋号] LIKE '%{0}%'", searchTxt.Trim()))) // { // sb.Append(row`"ID"].ToString() + ","); // } // sb.Append(0); // this.DgvGdh.DataSource = SQLiteDbHelper.ExecuteDataTable( // sqlSelect + "WHERE`ID] IN (" + sb.ToString() + ")"); this.DgvGdh.DataSource = MySqlDbHelper.ExecuteDataTable( string.Format(sqlSelect + " WHERE`客户简称` LIKE '%{0}%' OR`产品名称` LIKE '%{0}%' " + "OR`稿袋号` LIKE '%{0}%' ORDER BY `Excel时间` DESC LIMIT 300", searchTxt.Trim())); this.DgvGdh.DataBind(); } }
public static void GetPublishedJobTable_All() { DateTime excelLastTime = DateTime.MinValue; object obj = MySqlDbHelper.ExecuteScalar("select max(`Excel时间`) from job"); DataTable excelTable = MySqlDbHelper.ExecuteDataTable("select Excel文件 from job group by excel文件"); if (obj != null) { DateTime.TryParse(obj.ToString(), out excelLastTime); } //检索Excel文件 FileInfo[] files = new DirectoryInfo(@"\\128.1.30.112\Downloads").GetFiles("*.xls"); foreach (FileInfo file in files) { //删除超过日期的信息 if (file.LastWriteTime < excelLastTime) { continue; } //判断Excel文件名是否存在 string excelFileName = Path.GetFileNameWithoutExtension(file.FullName); DataRow[] rows = excelTable.Select("`Excel文件`='" + excelFileName + "'"); //如果不存在,则添加 if (rows == null || rows.Length == 0) { //读取Excel里面的作业信息,并返回一个DataTable DataTable dt_excel = GetPublishDataTableFromExcelFile(file.FullName); if (dt_excel != null) { //添加 JobService.Add(dt_excel); } } } }
private void ShowProcess(bool isShowGdh) { // //出版的Excel文件 DataTable dt_gdh_cpmc = new DataTable(); if (isShowGdh) { CheckBoxGdh.Checked = true; } if (CheckBoxGdh.Checked) { // PublishJobTable.GetAllPublishedJobTableByHour(); PublishJobTable.GetPublishedJobTable_All(); //***读取稿袋号和产品名称 dt_gdh_cpmc = MySqlDbHelper.ExecuteDataTable( "SELECT * FROM `Job` order by `Excel时间`desc limit 1000"); } //****历史记录**** //加载指定小时以内的完成出版的记录 int hour = 2; List <EvoProcessInfo> hisProcessList = new List <EvoProcessInfo>(); foreach (String fileFullName in EvoProcess.Get_historical_data_Files_hours(hour)) { EvoProcessInfo process = new EvoProcessInfo(fileFullName); if (process != null) { //判断GUID是否已经存在,并确定整个的完成时间 bool cunzai = false; int index = -1; for (int i = 0; i < hisProcessList.Count; i++) { if (process.Guid == hisProcessList[i].Guid) { cunzai = true; index = i; break; } } if (cunzai) { if (hisProcessList[index].CompletionTime.CompareTo(process.CompletionTime) < 0) { hisProcessList[index].CompletionTime = process.CompletionTime; } } else { hisProcessList.Add(process); } } } //************ if (hisProcessList != null && hisProcessList.Count > 0) { //需要绑定到GridView中的DataTable DataTable gridVies_dt = new DataTable(); gridVies_dt.Columns.Add("文件名"); gridVies_dt.Columns.Add("板材咬口"); gridVies_dt.Columns.Add("颜色"); gridVies_dt.Columns.Add("加网信息"); //按照完成时间排序(晚的时间靠前) hisProcessList.Sort(CompareProcessByCompletionTime); //遍历整个整理好的列表,并且将数据添加到表格中 foreach (EvoProcessInfo proInfo in hisProcessList) { DataRow dr = gridVies_dt.NewRow(); StringBuilder sb = new StringBuilder(); foreach (String fileName in proInfo.FileList) { //稿袋号 int num = 0; string gaodaihao = ""; if (isShowGdh) { foreach (DataRow row in dt_gdh_cpmc.Rows) { if (IsEachContain(Path.GetFileNameWithoutExtension(fileName), row["产品名称"].ToString()) && DateTime.Parse(row["Excel时间"].ToString()).AddDays(3) > DateTime.Now) { if (!gaodaihao.Equals(row["稿袋号"].ToString(), StringComparison.OrdinalIgnoreCase)) { num++; gaodaihao = row["稿袋号"].ToString(); } if (num >= 2) { break; } } } } sb.AppendLine(Path.GetFileNameWithoutExtension(fileName) + "</br>"); if (num == 1 && !string.IsNullOrWhiteSpace(gaodaihao)) { sb.AppendLine("(" + gaodaihao + ")</br>"); } } dr["文件名"] = sb.ToString(); dr["板材咬口"] = "板材:" + proInfo.Plant + "<br/>咬口:" + proInfo.OffsetY + "<br/>"; sb.Clear(); foreach (String color in proInfo.ColorList) { sb.AppendLine(color + "</br>"); } dr["颜色"] = sb.ToString(); dr["加网信息"] = "线数:" + proInfo.RulingOrFeatureSize + "</br>网点:" + proInfo.DotShape + "</br>曲线:" + proInfo.CalibrationTarget; gridVies_dt.Rows.Add(dr); } this.GridViewHistorical.Visible = true; this.GridViewHistorical.DataSource = gridVies_dt; this.GridViewHistorical.DataBind(); } else { this.GridViewHistorical.Visible = false; } //*****当前出版记录 //加载所有的完成出版的记录 List <EvoProcessInfo> dynProcessList = new List <EvoProcessInfo>(); foreach (String fileFullName in EvoProcess.Get_dynamic_data_Files_All()) { EvoProcessInfo process = new EvoProcessInfo(fileFullName); if (process.FileList.Count > 0) { //判断GUID是否已经存在,并确定整个的完成时间 bool cunzai = false; int index = -1; for (int i = 0; i < dynProcessList.Count; i++) { if (process.Guid == dynProcessList[i].Guid) { cunzai = true; index = i; break; } } if (cunzai) { if (dynProcessList[index].CompletionTime.CompareTo(process.CompletionTime) < 0) { dynProcessList[index].CompletionTime = process.CompletionTime; } } else { dynProcessList.Add(process); } } } //************ if (dynProcessList != null && dynProcessList.Count > 0) { //需要绑定到GridView中的DataTable DataTable gridVies_dt = new DataTable(); gridVies_dt.Columns.Add("文件名"); gridVies_dt.Columns.Add("板材咬口"); gridVies_dt.Columns.Add("颜色"); gridVies_dt.Columns.Add("加网信息"); //按照完成时间排序(晚的时间靠前) dynProcessList.Sort(CompareProcessByCompletionTime); //遍历整个整理好的列表,并且将数据添加到表格中 foreach (EvoProcessInfo proInfo in dynProcessList) { DataRow dr = gridVies_dt.NewRow(); StringBuilder sb = new StringBuilder(); foreach (String fileName in proInfo.FileList) { //稿袋号 int num = 0; string gaodaihao = ""; if (isShowGdh) { foreach (DataRow row in dt_gdh_cpmc.Rows) { if (IsEachContain(Path.GetFileNameWithoutExtension(fileName), row["产品名称"].ToString()) && DateTime.Parse(row["Excel时间"].ToString()).AddDays(3) > DateTime.Now) { if (!gaodaihao.Equals(row["稿袋号"].ToString(), StringComparison.OrdinalIgnoreCase)) { num++; gaodaihao = row["稿袋号"].ToString(); } if (num >= 2) { break; } } } } sb.Append(Path.GetFileNameWithoutExtension(fileName) + "</br>"); if (num == 1 && !string.IsNullOrWhiteSpace(gaodaihao)) { sb.AppendLine("(" + gaodaihao + ")</br>"); } } dr["文件名"] = sb.ToString(); dr["板材咬口"] = "板材:" + proInfo.Plant + "</br>咬口:" + proInfo.OffsetY; sb.Clear(); foreach (String color in proInfo.ColorList) { sb.AppendLine(color + "</br>"); } dr["颜色"] = sb.ToString(); dr["加网信息"] = "线数:" + proInfo.RulingOrFeatureSize + "</br>网点:" + proInfo.DotShape + "</br>曲线:" + proInfo.CalibrationTarget; gridVies_dt.Rows.Add(dr); } this.GridViewDynamic.Visible = true; this.GridViewDynamic.DataSource = gridVies_dt; this.GridViewDynamic.DataBind(); } else { this.GridViewDynamic.Visible = false; } try { //***错误信息 if (true) { DataTable dt_error = new DataTable(); dt_error.Columns.Add("文件名"); dt_error.Columns.Add("错误"); //[ID],[Name],[PlantSize],[Bite],[MaxPaper],[MaxPrinting],[MinPaper] List <PrintingMachineInfo> pmList = new List <PrintingMachineInfo>(); foreach (DataRow row in MySqlDbHelper.ExecuteDataTable("SELECT*FROM`PrintingMachine`").Rows) { pmList.Add(new PrintingMachineInfo(row)); } List <EvoProcessInfo> allList = new List <EvoProcessInfo>(); allList.AddRange(hisProcessList); allList.AddRange(dynProcessList); foreach (EvoProcessInfo pro in allList) { PrintingMachineInfo pmInfo = pmList.Find(p => p.PlantSize_L == pro.Plant_L && p.PlantSize_S == pro.Plant_S); if (pmInfo == null) { continue; } foreach (string fileName in pro.FileList) { StringBuilder sb = new StringBuilder(); //***咬口错误 if (pro.OffsetY > pmInfo.Bite || pro.OffsetY < 10 || pro.OffsetY < pmInfo.Bite - 30) { sb.Append("咬口错误<br />"); } //***最大过纸 //***最大印刷尺寸 if (sb.Length == 0) { if (pro.ImagingPosition != null) { CREO_TrimBox_MilliMetre imaging = pro.ImagingPosition.GetCREO_TrimBox_MilliMetre(); if (pmInfo.MaxPrinting_S + pmInfo.Bite < imaging.High.Length + pro.OffsetY - 10 || imaging.Left.Length < 0) { sb.Append("超出最大印刷面积<br />"); } } } //***最小过纸 //***重复提交 if (sb.Length == 0) { bool isRepeat = false; foreach (EvoProcessInfo pro_child in allList) { if (pro == pro_child) { continue; } if (pro_child.Equals(pro)) { isRepeat = true; break; } } if (isRepeat) { sb.Append("重复提交<br />"); } } //***汇总信息 if (sb.Length > 0) { DataRow row = dt_error.NewRow(); row["文件名"] = Path.GetFileNameWithoutExtension(fileName); row["错误"] = sb.ToString(); dt_error.Rows.Add(row); } } } if (dt_error.Rows.Count > 0) { this.GridViewError.Visible = true; this.LableError.Visible = true; this.GridViewError.DataSource = dt_error; this.GridViewError.DataBind(); } else { this.GridViewError.Visible = false; this.LableError.Visible = false; } } //else //{ // this.GridViewError.Visible = false; // this.LableError.Visible = false; //} } catch { } }