//実行 MAIN public void DoAll() { Pub_Com = new Com("見出明細作成" + DateTime.Now.ToString("yyyyMMddHHmmss")); if (Pub_Com.file_list_hattyuu.Count == 0) { ProBar = 100; return; } lv1 = System.Convert.ToDouble(90 / Pub_Com.file_list_hattyuu.Count); object authHeader = "Authorization: Basic " + Convert.ToBase64String(System.Text.UnicodeEncoding.UTF8.GetBytes(string.Format("{0}:{1}", Pub_Com.user, Pub_Com.password))) + "\\r\\n"; //*** OnSiteパスワード入力画面 Ie.Navigate(Pub_Com.url, null, null, null, authHeader); Ie.Silent = true; Ie.Visible = IeVisible; //***ログイン 1 ProBar = 5; DoStep1_Login(); //***CSV 読み 2 ProBar = 10; foreach (string fl in Pub_Com.file_list_hattyuu) { lv2 = lv1 / 10; Pub_Com.AddMsg("取込:" + fl); string 事業所 = System.Convert.ToString(fl.Split('-')[0]); string 得意先 = System.Convert.ToString(fl.Split('-')[1]); string 店 = System.Convert.ToString(fl.Split('-')[2]); string 現場名 = System.Convert.ToString(fl.Split('-')[3]); string 備考 = System.Convert.ToString(fl.Split('-')[4]); string 日付連番 = System.Convert.ToString(fl.Split('-')[5]); //While DoStep2_Sinki(事業所, 得意先, 店, 現場名, 備考, 日付連番, fl); Pub_Com.AddMsg("移動CSV:" + fl + "→" + Pub_Com.folder_Hattyuu_kanryou); Com.MoveFile(Pub_Com.folder_Hattyuu + fl, Pub_Com.folder_Hattyuu_kanryou + fl); AddProBar(lv2); //10 } ProBar = 100; }
//Step 1 LOGIN IN public void DoStep1_Login() { Pub_Com.AddMsg("OnSiteパスワード入力"); //*** OnSiteパスワード入力 Pub_Com.GetElementBy(ref Ie, "", "input", "name", "strPassWord").setAttribute("value", ConfigurationManager.AppSettings["OnSitePassword"].ToString()); Pub_Com.GetElementBy(ref Ie, "", "input", "value", "ログオン").click(); Pub_Com.AddMsg("業務別総合メニュー"); //'*** 業務別総合メニュー Pub_Com.GetElementBy(ref Ie, "SubHeader", "a", "innertext", "[見積]").click(); CloseChildPage(); Pub_Com.AddMsg("物販明細"); //'*** 物販明細 Pub_Com.GetElementBy(ref Ie, "Main", "input", "value", "物販明細").click(); Pub_Com.SleepAndWaitComplete(Ie, 100); Pub_Com.SleepAndWaitComplete(Ie, 100); }
//実行 MAIN public void DoAll() { //SavePdf("aaaa.csv") Pub_Com = new Com("納期指定発注" + DateTime.Now.ToString("yyyyMMddHHmmss")); if (Pub_Com.file_list_Nouki.Count == 0) { ProBar = 100; return; } lv1 = System.Convert.ToDecimal(90 / Pub_Com.file_list_Nouki.Count); lv2 = lv1 / 15; //一回目 bool firsOpenKbn = true; object authHeader = "Authorization: Basic " + Convert.ToBase64String(System.Text.UnicodeEncoding.UTF8.GetBytes(string.Format("{0}:{1}", Pub_Com.user, Pub_Com.password))) + "\\r\\n"; //*** OnSiteパスワード入力画面 Ie.Navigate(Pub_Com.url, null, null, null, authHeader); Ie.Silent = true; Ie.Visible = IeVisible; ProBar = 5; //***ログイン DoStep1_Login(); //CSV ファイルs 取込 ProBar = 10; for (int fileIdx = 0; fileIdx <= Pub_Com.file_list_Nouki.Count - 1; fileIdx++) { string csvFileName = System.Convert.ToString(Pub_Com.file_list_Nouki[fileIdx].ToString().Trim()); string[] csvNameSplitor = csvFileName.Split('-'); string 事業所 = csvNameSplitor[0]; string 得意先 = csvNameSplitor[1]; string 店 = csvNameSplitor[2]; string 現場名 = csvNameSplitor[3]; string 備考 = csvNameSplitor[4]; string 日付連番 = csvNameSplitor[5]; //一回目ではなく 実行 if (firsOpenKbn == false) { Pub_Com.GetElementBy(ref Ie, "fraHead", "input", "value", "絞込検索").click(); Pub_Com.SleepAndWaitComplete(Ie); } firsOpenKbn = false; AddProBar(lv2); //1 Pub_Com.AddMsg("取込:" + Pub_Com.file_list_Nouki[fileIdx].ToString().Trim()); //見積検索 Pub_Com.AddMsg("見積検索"); DoStep1_PoupuSentaku(事業所, 得意先, 店, 現場名, 備考, 日付連番, csvFileName); Pub_Com.SleepAndWaitComplete(Ie); AddProBar(lv2); //2 //納期日設定 if (!DoStep2_Set()) { continue; } Pub_Com.SleepAndWaitComplete(Ie); Pub_Com.SleepAndWaitComplete(Ie); Pub_Com.SleepAndWaitComplete(Ie); //該当データがありません NEXT mshtml.HTMLWindow2 fraTmp = Pub_Com.GetFrameByName(ref Ie, "fraHyou"); if (fraTmp != null) { if (fraTmp.document.body.innerText.IndexOf("該当データがありません") >= 0) { continue; } } //CSVファイル内容取込 string[] csvDataLines = System.IO.File.ReadAllLines(Pub_Com.folder_Nouki + csvFileName); string code = ""; string nouki = ""; AddProBar(lv2); //3 mshtml.HTMLWindow2 fra = Pub_Com.GetFrameWait(ref Ie, "fraMitBody"); mshtml.HTMLDocument Doc = (mshtml.HTMLDocument)fra.document; mshtml.IHTMLElementCollection eles = Doc.getElementsByTagName("input"); //Radio 明細Key mshtml.IHTMLElementCollection cbEles = Doc.getElementsByName("strMeisaiKey"); //指定納期 mshtml.IHTMLElementCollection nouhinDateEles = Doc.getElementsByName("strSiteiNouhinDate"); int csvIdx = 0; int sameCdSuu = 0; int gamenSameCdSuu = 0; //CSV LINES for (int csvLinesIdx = 0; csvLinesIdx <= csvDataLines.Length - 1; csvLinesIdx++) { if (!string.IsNullOrEmpty(csvDataLines[csvLinesIdx].Trim())) { //コード 納期 code = System.Convert.ToString(csvDataLines[csvLinesIdx].Split(',')[1].Trim()); nouki = System.Convert.ToString((System.Convert.ToDateTime(csvDataLines[csvLinesIdx].Split(',')[2].Trim())).ToString("yyyy/MM/dd")); sameCdSuu = 0; gamenSameCdSuu = 0; for (csvIdx = 0; csvIdx <= csvLinesIdx; csvIdx++) { if (csvDataLines[csvIdx].Split(',')[1].Trim() == code) { sameCdSuu++; } } for (int i = 0; i <= cbEles.length - 1; i++) { mshtml.IHTMLElement cb = (mshtml.IHTMLElement)(cbEles.item(i)); mshtml.IHTMLTableRow tr = (mshtml.IHTMLTableRow)cb.parentElement.parentElement; mshtml.HTMLTableCell td = (mshtml.HTMLTableCell)(tr.cells.item(1)); mshtml.IHTMLTable table = (mshtml.IHTMLTable)cb.parentElement.parentElement.parentElement.parentElement; bool isHaveDate = false; if (td.innerText == code) { gamenSameCdSuu++; if (sameCdSuu == gamenSameCdSuu) { mshtml.IHTMLSelectElement sel = (mshtml.IHTMLSelectElement)(nouhinDateEles.item(i)); for (int j = 0; j <= sel.length - 1; j++) { mshtml.IHTMLOptionElement opEle = (mshtml.IHTMLOptionElement)(sel.item(j)); if (opEle.value.IndexOf(nouki) > 0) { opEle.selected = true; isHaveDate = true; break; } } } else { continue; } if (!isHaveDate) { MessageBox.Show("コード:[" + code + "] 納品希望日:[" + nouki + "]がありません"); return; } } } } } AddProBar(lv2); //4 Pub_Com.GetElementBy(ref Ie, "fraMitBody", "select", "name", "strBukkenKbn").setAttribute("value", "01"); Pub_Com.GetElementBy(ref Ie, "fraMitBody", "input", "value", "発 注").click(); Pub_Com.SleepAndWaitComplete(Ie); Pub_Com.SleepAndWaitComplete(Ie); Pub_Com.SleepAndWaitComplete(Ie); AddProBar(lv2); //5 Pub_Com.GetElementBy(ref Ie, "fraMitBody", "input", "value", "発注結果照会へ").click(); Pub_Com.SleepAndWaitComplete(Ie); AddProBar(lv2); //6 //PDF 印刷 if (insatu) { SHDocVw.InternetExplorerMedium childIe = default(SHDocVw.InternetExplorerMedium); int RebackKaisu = -1; Reback: RebackKaisu++; Com.Sleep5(1000); //前回印刷画面 Close ClosePrintPage(); Pub_Com.GetElementBy(ref Ie, "fraMitBody", "input", "value", "結果印刷").click(); int wait_print; wait_print = int.Parse(Com.GetAppSetting("wait_print")); AutoResetEvent myEvent = new AutoResetEvent(false); myEvent.WaitOne(wait_print * 1000); myEvent.Close(); try { //印刷画面取得する childIe = GetPrintPage(); } catch (Exception) { } Com.Sleep5(1000); //IE エラー判定する if (GetErrCon() == false) { Com.Sleep5(1000); if (RebackKaisu <= 1) { goto Reback; } else { if (MessageBox.Show("帳票Download エラーしました、終了ですか?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { System.Environment.Exit(0); } } } string flName = Pub_Com.pdfPath + csvFileName; try { bool rtv = GetFcwInfo(childIe, flName); ClosePrintPage(); if (rtv == false) { if (RebackKaisu <= 1) { goto Reback; } else { if (MessageBox.Show("帳票Download エラーしました、終了ですか?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { System.Environment.Exit(0); } } } } catch (Exception) { ClosePrintPage(); if (RebackKaisu <= 1) { goto Reback; } else { if (MessageBox.Show("帳票Download エラーしました、終了ですか?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { System.Environment.Exit(0); } } } } AddProBar(lv2); //10 Pub_Com.AddMsg("移動CSV:" + csvFileName + "→" + Pub_Com.folder_Nouki_kanryou); Com.MoveFile(Pub_Com.folder_Nouki + csvFileName, Pub_Com.folder_Nouki_kanryou + csvFileName); AddProBar(lv2); //11 Pub_Com.GetElementBy(ref Ie, "fraMitMenu", "a", "innertext", "[見積一覧を再表示]").click(); Pub_Com.SleepAndWaitComplete(Ie); } ProBar = 100; }