//private void timer1_Tick(object sender, EventArgs e) //{ // if (Comm_Method.AiFileList.Count > 0) // { // this.timer1.Stop(); // this.thSavePdf = new Thread(new ThreadStart(SavePdf_Illustrator)); // thSavePdf.Start(); // } //} private void SavePdf_Illustrator() { while (true) { if (IsClose) { break; } try { while (Comm_Method.AiFileList.Count == 0 && !this.IsClose) { Thread.Sleep(5000); } // this.timer1.Stop(); //判断Adobe Illustrator CS6 (64 Bit)是否运行 string aiexe = @"C:\Program Files\Adobe\AdobeIllustratorCS6_x64\Support Files\Contents\Windows\Illustrator.exe"; if (File.Exists(aiexe)) { if (Process.GetProcessesByName("Illustrator").Length == 0) { Comm_Method.ExecuteCom(string.Format("\"{0}\"", aiexe), false); } Illustrator.ApplicationClass app = new Illustrator.ApplicationClass(); while (Comm_Method.AiFileList.Count > 0) { while (app.Documents.Count > 0 && !this.IsClose) { Thread.Sleep(5000); } string aiFile = Comm_Method.AiFileList[0]; app.DoJavaScript(Resources.AutoSavePdf.Replace ("*文件名*", aiFile.Replace('\\', '/'))); Comm_Method.AiFileList.RemoveAt(0); if (File.Exists(@"\\128.1.30.144\HotFolders\RefineToPDF\" + Path.GetFileNameWithoutExtension(aiFile) + ".pdf")) { string okDir = Path.GetDirectoryName(aiFile) + "\\ok\\"; if (!Directory.Exists(okDir)) { Directory.CreateDirectory(okDir); } FileSystem.MoveFile(aiFile, okDir + Path.GetFileName(aiFile) , UIOption.AllDialogs, UICancelOption.DoNothing); } } } } catch { } finally { Thread.Sleep(5000); } } }
private void FormFindOld_Load(object sender, EventArgs e) { //关闭多余的窗体 foreach (Form f in this.ParentForm.MdiChildren) { if (f.Name == this.Name && f.Handle != this.Handle) { f.Dispose(); } } //下拉框 if (File.Exists(KeyWordTxt)) { this.KeyWordList = File.ReadAllLines(KeyWordTxt).ToList <string>(); } if (KeyWordList.Count > 1000) { for (int i = KeyWordList.Count - 1; i >= 1000; i--) { KeyWordList.RemoveAt(i); } } if (Job != null) { KeyWordList_Add(GetString(Job.Cpmc)); } if (KeyWordList.Count > 0) { this.comboBoxKeyword.Text = KeyWordList[0]; } //**根据客户智能生产搜索关键字 if (Job != null) { Regex regex = new Regex("\\d{8,}"); if (regex.IsMatch(Job.Cpmc)) { this.comboBoxKeyword.Text = regex.Match(Job.Cpmc).Value; } else { this.comboBoxKeyword.Text = Job.Cpmc.TrimEnd("-AB面".ToCharArray()); } } comboBoxKeyword.Items.Clear(); comboBoxKeyword.Items.AddRange(KeyWordList.ToArray()); Comm_Method.Init_Tabel_Excel(); Comm_Method.Init_PdfFileList(); SearchOldFile(); }
private void Stop_JPrinterJTP(string ip) { if (MessageBox.Show("确定要停止进程'JPrinterJTP'吗?" + "\n\n以下进程将受影响:" + "\n1.打印到设备" + "\n2.打印到高分辨率文件" + "\n3.打印到低分辨率文件", "确认?" , MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { MessageBox.Show(Comm_Method.ExecuteCom("taskkill /S " + ip + " /U Administrator /P creo /IM JPrinterJTP.exe", true)); } }
/// <summary> /// 执行压缩数据库 /// </summary> /// <returns>压缩数据库</returns> public void ExecuteZip() { using (SQLiteConnection connection = new SQLiteConnection(ConnectionString, true)) { using (SQLiteCommand cmd = new SQLiteCommand("VACUUM", connection)) { try { connection.Open(); cmd.ExecuteNonQuery(); } catch (System.Data.SQLite.SQLiteException E) { connection.Close(); Comm_Method.ShowErrorMessage(E.Message); //throw new Exception(E.Message); } } } }
private void buttonSave_Click(object sender, EventArgs e) { foreach (Control item in this.Controls) { if (item is TextBox) { if (string.IsNullOrWhiteSpace(((TextBox)item).Text)) { Comm_Method.ShowErrorMessage("不能为空!"); } } } if (this.ID == 0) { string sqlStr = "INSERT INTO [Ywj]([Name],[Path],[PathMove])VALUES(" + "'" + this.textBoxName.Text.Trim() + "'," + "'" + this.textBoxYwjPath.Text.Trim() + "'," + "'" + this.textBoxYwjPathMove.Text.Trim() + "');"; if (SQLiteList.Ybf.ExecuteNonQuery(sqlStr) > 0) { this.DialogResult = DialogResult.OK; } } else if (this.ID > 0) { string sqlStr = "UPDATE [Ywj] SET " + "[Name]='" + this.textBoxName.Text.Trim() + "'," + "[Path]='" + this.textBoxYwjPath.Text.Trim() + "'," + "[PathMove]='" + this.textBoxYwjPathMove.Text.Trim() + "'" + " WHERE ID=" + this.ID; if (SQLiteList.Ybf.ExecuteNonQuery(sqlStr) > 0) { this.DialogResult = DialogResult.OK; } } }
private void tsmiBaoBiao_Click(object sender, EventArgs e) { char[] InvalidFileNameChars = Path.GetInvalidFileNameChars(); string[] pdfFiles = Directory.GetFiles(@"\\128.1.30.144\JobData\pdf\已下单PDF" , "*.pdf", SearchOption.AllDirectories); List <DataTable> dtList = new List <DataTable>(); foreach (TreeNode item in this.treeViewExcel.Nodes) { if (item.Checked) { ExcelFileInfo excel = item.Tag as ExcelFileInfo; DataTable dt = Comm_Method.GetPublishDataTableFromExcelFile(excel.FileFullName); if (dt != null && dt.Rows.Count > 0) { dtList.Add(dt); } } } if (dtList.Count > 0) { DataTable dtAll = dtList[0].Clone(); foreach (DataTable item in dtList) { dtAll.Merge(item); } //剔除旧版 DataTable dt_baobiao = new DataTable(); dt_baobiao.Columns.Add("日期"); dt_baobiao.Columns.Add("产品名称"); dt_baobiao.Columns.Add("制造尺寸"); dt_baobiao.Columns.Add("面纸尺寸"); dt_baobiao.Columns.Add("输出颜色"); dt_baobiao.Columns.Add("网线"); dt_baobiao.Columns.Add("机台"); dt_baobiao.Columns.Add("咬口"); dt_baobiao.Columns.Add("备注"); foreach (DataRow row in dtAll.Select("备注<>'旧版'")) { DataRow newRow = dt_baobiao.NewRow(); newRow["日期"] = DateTime.Now.AddHours(-6).ToString("yyyy-MM-dd"); //newRow["产品名称"] = row["客户简称"].ToString()+row["产品名称"].ToString(); // newRow["产品名称"] = pdfFiles.First<string>(pp => pp.Contains(row["产品名称"].ToString())); newRow["制造尺寸"] = row["制造尺寸"].ToString().Replace('x', '*'); newRow["面纸尺寸"] = row["面纸尺寸"].ToString().Replace('x', '*'); newRow["网线"] = "175"; newRow["机台"] = dic_jitai[row["上机机台"].ToString()]; newRow["咬口"] = ""; newRow["备注"] = ""; //***确认产品名称 string cpmc = row["产品名称"].ToString().Replace('*', 'x'); bool cunzai = false; foreach (string pdffile in pdfFiles) { foreach (char Invalid in InvalidFileNameChars) { cpmc = cpmc.Replace(Invalid, '-'); } if (pdffile.Contains(cpmc)) { cpmc = Path.GetFileNameWithoutExtension(pdffile); cunzai = true; break; } } if (cunzai) { newRow["产品名称"] = cpmc; } else { newRow["产品名称"] = "【【" + cpmc + "】】"; } //输出颜色 string scys = ""; string ss1 = row["色数1"].ToString(); string ss2 = row["色数2"].ToString(); if (ss1 == "4") { scys = "CMYK"; } if (!string.IsNullOrWhiteSpace(ss2)) { if (ss2 == "1") { scys += (string.IsNullOrWhiteSpace(ss1)?"专":"+专"); } else { string zs = string.Format("{0}专", ss2); scys += (string.IsNullOrWhiteSpace(ss1) ? zs : "+" + zs); } } newRow["输出颜色"] = scys; //进行AB面完全一致的判断 bool isAB = false; foreach (DataRow row_Baobiao in dt_baobiao.Rows) { isAB = IsABside(row_Baobiao, newRow); if (isAB) { if (row_Baobiao["输出颜色"].ToString().Contains('+')) { row_Baobiao["输出颜色"] = "(" + row_Baobiao["输出颜色"] + ")*2"; } else { row_Baobiao["输出颜色"] = row_Baobiao["输出颜色"] + "*2"; } row_Baobiao["产品名称"] = row_Baobiao["产品名称"].ToString().Replace("B面", "A面").Replace("b面", "A面"); break; } } if (isAB) { continue; } dt_baobiao.Rows.Add(newRow); } new FormBaoBiao(dt_baobiao).ShowDialog(); } else { return; } }
//private void tsmiChuBan_Click(object sender, EventArgs e) //{ // //获取选择到的列和行 // List<int> selectRows= new List<int>(); // // List<int> selectColumns = new List<int>(); // foreach (DataGridViewCell cell in this.dgvJob.SelectedCells) // { // if (!selectRows.Contains(cell.RowIndex)) // { // selectRows.Add(cell.RowIndex); // } // //if (!selectColumns.Contains(cell.ColumnIndex)) // //{ // // selectColumns.Add(cell.ColumnIndex); // //} // } // List <string> sqlList=new List<string>() ; // foreach (int selectRowIndex in selectRows) // { // DataGridViewRow dgvr = this.dgvJob.Rows[selectRowIndex]; // string InsertString = "INSERT INTO [JobPublished]([gdh],[sjjt]," // + "[khjc],[cpmc],[zzcc],[mzcc],[ss1],[ss2],[sbs],[bz],[yk]," // + "[ExcelFile],[Published])VALUES(" // +"'" +this.dgvJob["ColumnGdh", selectRowIndex].Value.ToString() + "'," // + "'" + this.dgvJob["ColumnSjjt", selectRowIndex].Value.ToString() + "'," // + "'" + this.dgvJob["ColumnKhjc", selectRowIndex].Value.ToString() + "'," // + "'" + this.dgvJob["ColumnCpmc", selectRowIndex].Value.ToString() + "'," // + "'" + this.dgvJob["ColumnZzcc", selectRowIndex].Value.ToString() + "'," // + "'" + this.dgvJob["ColumnMzcc", selectRowIndex].Value.ToString() + "'," // + "'" + this.dgvJob["ColumnSs1", selectRowIndex].Value.ToString() + "'," // + "'" + this.dgvJob["ColumnSs2", selectRowIndex].Value.ToString() + "'," // + "'" + this.dgvJob["ColumnSbs", selectRowIndex].Value.ToString() + "'," // + "'" + this.dgvJob["ColumnBz", selectRowIndex].Value.ToString() + "'," // + "'" + this.dgvJob["ColumnYk", selectRowIndex].Value.ToString() + "'," // + "'" + this.dgvJob["ColumnExcelFile", selectRowIndex].Value.ToString() + "'," // + 1+");"; // sqlList.Add(InsertString); // } // SQLiteList.YbfSQLite.ExecuteSqlTran(sqlList); //} private void tsmiStatistics_Click(object sender, EventArgs e) { List <DataTable> dtList = new List <DataTable>(); foreach (TreeNode item in this.treeViewExcel.Nodes) { try { if (item.Checked) { ExcelFileInfo excel = item.Tag as ExcelFileInfo; DataTable dt = Comm_Method.GetPublishDataTableFromExcelFile(excel.FileFullName); if (dt != null && dt.Rows.Count > 0) { dtList.Add(dt); } } } catch (Exception) { continue; } } if (dtList.Count > 0) { DataTable dtAll = dtList[0].Clone(); foreach (DataTable item in dtList) { dtAll.Merge(item); } //分类汇总 Dictionary <string, int> dicCount = new Dictionary <string, int>(); foreach (DataRow row in dtAll.Rows) { try { string jitai = dic_jitai[row["上机机台"].ToString()]; int shuliang = Convert.ToInt32(row["晒版数"]); if (dicCount.ContainsKey(jitai)) { dicCount[jitai] += shuliang; } else { dicCount.Add(jitai, shuliang); } } catch (Exception) { continue; } } //显示数量 StringBuilder sb = new StringBuilder(); int sum = 0; foreach (string key in dicCount.Keys) { sb.AppendLine(key + ":" + dicCount[key]); sum += dicCount[key]; } if (sum > 0 && sb.Length > 0) { sb.AppendLine("------------"); sb.AppendLine(" 共计:" + sum); } MessageBox.Show(sb.ToString()); } else { return; } }
private void tsmiShow_Click(object sender, EventArgs e) { this.dgvJob.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; this.dgvJob.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None; //this.dgvJob.Rows.Clear(); List <DataTable> dtList = new List <DataTable>(); foreach (TreeNode item in this.treeViewExcel.Nodes) { if (item.Checked) { ExcelFileInfo excel = item.Tag as ExcelFileInfo; DataTable dt = Comm_Method.GetPublishDataTableFromExcelFile(excel.FileFullName); if (dt != null && dt.Rows.Count > 0) { dtList.Add(dt); } } } if (dtList.Count < 1) { return; } // AddToDgv(dtList); //********** DataTable dtAll = dtList[0].Clone(); foreach (DataTable item in dtList) { dtAll.Merge(item); } //删除重复的数据 for (int i = dtAll.Rows.Count - 1; i > 0; i--) { bool isCome = true; foreach (DataRow row in dtAll.Rows) { foreach (DataColumn column in dtAll.Columns) { if (!dtAll.Rows[i][column].ToString().Equals(row[column].ToString())) { isCome = false; break; } } if (isCome) { break; } } if (isCome) { dtAll.Rows.RemoveAt(i); } } this.dgvJob.DataSource = dtAll; this.dgvJob.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; this.dgvJob.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.True; }
private void SearchOldFile() { Comm_Method.Init_Tabel_Excel(); this.dgvExcel.DataSource = null; string kw = this.comboBoxKeyword.Text; if (string.IsNullOrWhiteSpace(kw)) { return; } DataTable dt = Comm_Method.Table_Excel.Clone(); dt.Columns.RemoveAt(dt.Columns.Count - 1); dt.Columns.RemoveAt(dt.Columns.Count - 1); dt.Columns.RemoveAt(dt.Columns.Count - 1); if (checkBoxSize.Checked) { } else { foreach (DataRow row in Comm_Method.Table_Excel.Rows) { string cpmc = row[keyWordColumnName].ToString(); if (IsEachContain(cpmc, kw)) { DataRow newRow = dt.NewRow(); foreach (DataColumn dc in dt.Columns) { newRow[dc] = row[dc.ColumnName]; } dt.Rows.Add(newRow); } } if (dt.Rows.Count > 0 && Job != null) { DataRow newRow = dt.NewRow(); newRow["产 品 名 称"] = Job.Khjc + Job.Cpmc; newRow[" 制造尺寸"] = Job.Zzcc.Replace("x", "*"); newRow["下料尺寸"] = Job.Mzcc; newRow["输出颜色"] = "普:" + Job.Ss1 + " 专:" + Job.Ss2; newRow["印刷机台"] = Job.Sjjt; dt.Rows.InsertAt(newRow, 0); } this.dgvExcel.DataSource = dt; //ListView this.listViewFile.Items.Clear(); foreach (string file in Comm_Method.PdfFileList.FindAll(f => IsEachContain(Path.GetFileNameWithoutExtension(f), kw))) { FileInfo fileInfo = new FileInfo(file); if (fileInfo.Exists) { ListViewItem item = this.listViewFile.Items.Add(fileInfo.Name); item.SubItems.Add(fileInfo.LastWriteTime.ToString()); item.SubItems.Add(Math.Round(1.0 * fileInfo.Length / 1024 / 1024, 2) + "MB"); item.SubItems.Add(fileInfo.DirectoryName); item.Tag = file; } } } KeyWordList_Add(kw); this.comboBoxKeyword.Items.Clear(); this.comboBoxKeyword.Items.AddRange(this.KeyWordList.ToArray()); this.listViewFile.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); //确定分割线的位置 int dgvRowCount = dgvExcel.RowCount; int listViewCount = listViewFile.Items.Count; if (dgvRowCount == 0 || listViewCount == 0) { dgvRowCount++; listViewCount++; this.splitContainer1.SplitterDistance = Convert.ToInt32((1.0 * dgvRowCount / (dgvRowCount + listViewCount) * this.splitContainer1.Height)); } else { this.splitContainer1.SplitterDistance = Convert.ToInt32((1.0 * dgvRowCount / (dgvRowCount + listViewCount) * this.splitContainer1.Height)); } //文字对齐 dgvExcel.Columns["产 品 名 称"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; }
private string GetString(string str) { return(Comm_Method.ToDBC(str.Replace("\\", "-") .Replace("/", "-").Replace("*", "x").ToLower())); }