public M(WorkSet _WS) { InitializeComponent(); WS = _WS; this.OuterPath.Text = WS.Work_Path.OuterPath; this.BaseBNo.Text = WS.BaseBNo; this.BaseJNo.Text = WS.BaseJNo; }
public ChildListSet(WorkSet _WS) { InitializeComponent(); WS = _WS; this.BNoCol.Value = WS.BNoCol; this.JNoCol.Value = WS.JNoCol; this.ChildStartRow.Value = WS.ChildStartRow; Encoding fe = Encoding.Default; try { fe = Encoding.GetEncoding(WS.Work_Path.BaseRepTemp_Path); } catch { fe = Encoding.Default; } Console.WriteLine(fe.EncodingName); List <string> ztno = new List <string>(); string pattern = @"[^(],""\d{6}"""; using (StreamReader sr = new StreamReader(WS.Work_Path.BaseRepTemp_Path)) { string line; // 从文件读取并显示行,直到文件的末尾 while ((line = sr.ReadLine()) != null) { foreach (Match match in Regex.Matches(line, pattern)) { if (ztno.IndexOf(match.Value.Replace(",\"", "").Replace("\"", "")) < 0) { ztno.Add(match.Value.Replace(",\"", "").Replace("\"", "")); } } } sr.Close(); } if (ztno.Count >= 2) { this.BaseBNo.Text = ztno[0]; this.BaseJNo.Text = ztno[1]; } foreach (string no in ztno) { string nos = no; if (BaseNoErrList.Text.Length > 1) { nos = "," + nos; } BaseNoErrList.AppendText(nos); } }
public portal(WorkSet _WS) { InitializeComponent(); WS = _WS; if (WS.Work_Path != null) { if (!string.IsNullOrEmpty(WS.Work_Path.OuterPath)) { this.OuterPath.Text = WS.Work_Path.OuterPath; } if (!string.IsNullOrEmpty(WS.Work_Path.BaseRepTemp_Path)) { this.BaseRepTemp_Path.Text = WS.Work_Path.BaseRepTemp_Path; } if (!string.IsNullOrEmpty(WS.Work_Path.BCD_Path)) { this.BCD_Path.Text = WS.Work_Path.BCD_Path; } if (!string.IsNullOrEmpty(WS.Work_Path.JCD_Path)) { this.JCD_Path.Text = WS.Work_Path.JCD_Path; } if (!string.IsNullOrEmpty(WS.Work_Path.BZCFZ_Path)) { this.BZCFZ_Path.Text = WS.Work_Path.BZCFZ_Path; } if (!string.IsNullOrEmpty(WS.Work_Path.JZCFZ_Path)) { this.JZCFZ_Path.Text = WS.Work_Path.JZCFZ_Path; } if (!string.IsNullOrEmpty(WS.Work_Path.BLR_Path)) { this.BLR_Path.Text = WS.Work_Path.BLR_Path; } if (!string.IsNullOrEmpty(WS.Work_Path.JLR_Path)) { this.JLR_Path.Text = WS.Work_Path.JLR_Path; } } else { WS.Work_Path = new WorkPath(); } }
public void Work_Do(object sender, DoWorkEventArgs e) { List <object> arg = (List <object>)e.Argument; BackgroundWorker BW = (BackgroundWorker)sender; WorkSet WS = (WorkSet)arg[0]; DataTable ChildDT = (DataTable)arg[1]; int si = 1; foreach (DataRow dr in ChildDT.Rows) { string filename = dr["ChildIndex"].ToString() + "-" + dr["ShortTitle"].ToString() + ".txt"; if (string.IsNullOrWhiteSpace(dr["ChildIndex"].ToString()) || string.IsNullOrWhiteSpace(dr["ShortTitle"].ToString()) || string.IsNullOrWhiteSpace(dr["BNo"].ToString()) || string.IsNullOrWhiteSpace(dr["JNo"].ToString())) { MessageBox.Show("关键参数不能为空"); BW.ReportProgress(si, filename + " 有空参数"); } else { using (StreamReader sr = new StreamReader(WS.Work_Path.BaseRepTemp_Path)) { string outtxtfilepath = WS.Work_Path.OuterPath + "/" + filename; if (!File.Exists(outtxtfilepath)) { FileStream fs = new FileStream(outtxtfilepath, FileMode.Create, FileAccess.Write); fs.Close(); } using (StreamWriter sw = new StreamWriter(outtxtfilepath)) { string line; // 从文件读取并显示行,直到文件的末尾 while ((line = sr.ReadLine()) != null) { sw.Write(""); sw.WriteLine(line.Replace(WS.BaseBNo, dr["BNo"].ToString()).Replace(WS.BaseJNo, dr["JNo"].ToString())); } sw.Close(); BW.ReportProgress(si, filename + " 写入完成"); } sr.Close(); } } si++; } }
public A(WorkSet _WS, DataTable _ChildDT) { InitializeComponent(); WS = _WS; ChildDT = _ChildDT; this.OuterPath.Text = WS.Work_Path.OuterPath; this.BaseBNo.Text = WS.BaseBNo; this.BaseJNo.Text = WS.BaseJNo; if (string.IsNullOrEmpty(WS.Work_Path.BCD_Path) || string.IsNullOrEmpty(WS.Work_Path.BZCFZ_Path) || string.IsNullOrEmpty(WS.Work_Path.BLR_Path)) { this.SetB.Enabled = false; } if (string.IsNullOrEmpty(WS.Work_Path.JCD_Path) || string.IsNullOrEmpty(WS.Work_Path.JZCFZ_Path) || string.IsNullOrEmpty(WS.Work_Path.JLR_Path)) { this.SetJ.Enabled = false; } }
public JRepWork(WorkSet _ws, DataTable _ChildDT) { InitializeComponent(); WS = _ws; ChildDTin = _ChildDT; }
public void Work_Do(object sender, DoWorkEventArgs e) { List <object> arg = (List <object>)e.Argument; BackgroundWorker BW = (BackgroundWorker)sender; WorkSet WS = (WorkSet)arg[0]; DataGridView DGV1 = (DataGridView)arg[1]; TempRepCol _trc = (TempRepCol)arg[2]; BW.ReportProgress(1); if (_trc.state) { List <string> cd_fl = new List <string>(); List <string> zcfz_fl = new List <string>(); List <string> lr_fl = new List <string>(); using (StreamReader sr = new StreamReader(this.JCD_Path.Text)) { string line; while ((line = sr.ReadLine()) != null) { if (line.IndexOf("=") >= 0) { if (line.Substring(0, _trc.cd.Length) == _trc.cd) { cd_fl.Add(line); //Console.WriteLine(line); } } } sr.Close(); } BW.ReportProgress(1); using (StreamReader sr = new StreamReader(this.JZCFZ_Path.Text)) { string line; while ((line = sr.ReadLine()) != null) { if (line.IndexOf("=") >= 0) { if (line.Substring(0, _trc.zcfz1.Length) == _trc.zcfz1) { zcfz_fl.Add(line); //Console.WriteLine(line); } if (line.Substring(0, _trc.zcfz2.Length) == _trc.zcfz2) { zcfz_fl.Add(line); //Console.WriteLine(line); } } } sr.Close(); } BW.ReportProgress(1); using (StreamReader sr = new StreamReader(this.JLR_Path.Text)) { string line; while ((line = sr.ReadLine()) != null) { if (line.IndexOf("=") >= 0) { if (line.Substring(0, _trc.lr1.Length) == _trc.lr1) { lr_fl.Add(line); //Console.WriteLine(line); } if (line.Substring(0, _trc.lr2.Length) == _trc.lr2) { lr_fl.Add(line); //Console.WriteLine(line); } } } sr.Close(); } BW.ReportProgress(1); foreach (DataGridViewRow vr in DGV1.Rows) { // Boolean isselect = (Boolean)vr.Cells["Select"].EditedFormattedValue; if ((Boolean)vr.Cells["Select"].EditedFormattedValue) { using (StreamWriter sw = new StreamWriter(this.JCD_Path.Text, append: true)) { foreach (string f in cd_fl) { sw.WriteLine(f.Replace(_trc.RepNo, vr.Cells["RepNo"].Value.ToString()).Replace(_trc.cd, vr.Cells["CD_Cname"].Value.ToString())); } sw.Close(); //BW.ReportProgress(si, filename + " 写入完成"); } BW.ReportProgress(1); using (StreamWriter sw = new StreamWriter(this.JZCFZ_Path.Text, append: true)) { foreach (string f in zcfz_fl) { sw.WriteLine(f.Replace(_trc.RepNo, vr.Cells["RepNo"].Value.ToString()).Replace(_trc.zcfz1, vr.Cells["zcfz1_Cname"].Value.ToString()).Replace(_trc.zcfz2, vr.Cells["zcfz2_Cname"].Value.ToString())); } sw.Close(); //BW.ReportProgress(si, filename + " 写入完成"); } BW.ReportProgress(1); using (StreamWriter sw = new StreamWriter(this.JLR_Path.Text, append: true)) { foreach (string f in lr_fl) { sw.WriteLine(f.Replace(_trc.RepNo, vr.Cells["RepNo"].Value.ToString()).Replace(_trc.lr1, vr.Cells["lr1_Cname"].Value.ToString()).Replace(_trc.lr2, vr.Cells["lr2_Cname"].Value.ToString())); } sw.Close(); //BW.ReportProgress(si, filename + " 写入完成"); } BW.ReportProgress(1); } } } }