public void OpenWebSite(RadioButton rbB2B, RadioButton rbB2C, RadioButton rbKPMRead, TextBox tB2BID, TextBox tB2BPW, ref List <Process> processes) { g_Util.DebugPrint("I'm accessing KPM..."); Process[] processesBefore = Process.GetProcessesByName("geckodriver"); //var Dir = System.IO.Directory.GetCurrentDirectory(); //FirefoxDriverService FF_driverSerivce = FirefoxDriverService.CreateDefaultService("C:\\KPM_Creator\\WebDriver"); FirefoxDriverService FF_driverSerivce = FirefoxDriverService.CreateDefaultService(); FF_driverSerivce.HideCommandPromptWindow = true; FirefoxOptions FF_options = new FirefoxOptions(); FF_driver = new FirefoxDriver(FF_driverSerivce, FF_options); //WA.wait = new WebDriverWait(FF_driver, TimeSpan.FromMinutes(1)); WA.wait = new WebDriverWait(FF_driver, TimeSpan.FromMilliseconds(100)); Process[] processesAfter = Process.GetProcessesByName("geckodriver"); FindNewProcess(processesBefore, processesAfter, ref processes); string URL = ""; //rbB2B.Checked = true; //rbB2C.Checked = false; if (rbKPMRead.Checked == true || rbB2B.Checked == true) { if (tB2BID.Text != null && tB2BPW.Text != null) { URL = "https://" + tB2BID.Text + ":" + tB2BPW.Text + "@sso.volkswagen.de/kpmweb/Index.action"; } else { URL = "https://sso.volkswagen.de/kpmweb/Index.action"; } } else { URL = "https://quasi.vw.vwg/kpm/kpmweb/Index.action"; } GoToURL(URL, rbB2C); }
public void OpenWebSite(RadioButton rbB2B, RadioButton rbB2C, RadioButton rbKPMRead, TextBox tB2BID, TextBox tB2BPW, ref List <Process> processes) { g_Util.DebugPrint("I'm accessing KPM..."); Process[] processesBefore = Process.GetProcessesByName("iexplore"); IE = new InternetExplorer(); webBrowser = (IWebBrowserApp)IE; Process[] processesAfter = Process.GetProcessesByName("iexplore"); FindNewProcess(processesBefore, processesAfter, ref processes); object URL = null; //rbB2B.Checked = true; //rbB2C.Checked = false; if (rbKPMRead.Checked == true || rbB2B.Checked == true) { //if (sID != null && sPW != null) //{ // URL = "https://" + sID + ":" + sPW + "@sso.volkswagen.de/kpmweb/Index.action"; //} //else { URL = "https://sso.volkswagen.de/kpmweb/Index.action"; } } else { URL = "https://quasi.vw.vwg/kpm/kpmweb/Index.action"; } //if (rbB2C.Checked == true) //{ // MessageBox.Show("Wait!!! Login and Go to Main page. And then press OK", "Please Login KPM"); //} GoToURL(URL, rbB2C); }
public void CloseExcelControl(ref Excel.Worksheet ws, ref Excel.Workbook wb, ref Excel.Application app, ref List<Process> processes) { if (ws != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(ws); } if (wb != null) { g_Util.DebugPrint("I'm saving Excel File..."); if (wb.ReadOnly == false) { wb.Save(); } wb.Close(); System.Runtime.InteropServices.Marshal.ReleaseComObject(wb); wb = null; } if (app != null) { g_Util.DebugPrint("I'm closing Excel File..."); app.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(app); app = null; } if (processes != null && processes.Count > 0) { g_Util.DebugPrint("I'm killing Excel processes..."); foreach (Process Iter in processes) { if (Iter.ProcessName == "EXCEL") { try { Process.GetProcessById(Iter.Id); Iter.Kill(); } catch { continue; } } } } }
private void bStartCreation_Click(object sender, EventArgs e) { try { List <Dictionary <string, string> > LTicketItemList = new List <Dictionary <string, string> >(); List <Dictionary <string, string> > LActionList = new List <Dictionary <string, string> >(); var nStartTick = DateTime.Now; bool bExcelReadResult = true; bool bCreateResult = false; int tryCnt = 0; if (rbKPMRead.Checked == true || rbTKCancel.Checked == true) { rbB2B.Checked = true; rbIE.Checked = true; } if (rbB2C.Checked == true) { // Because of the error below, IE can't be used for B2C. (Use FF) // The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)' rbFirefox.Checked = true; } g_ExcelTool = new ExcelControl(ref g_Util); int nTicketCNT = 0; if (g_ExcelTool.ReadExcelValue(tExcelPath, rbB2B, rbB2C, rbKPMRead, rbTKCancel, ref LTicketItemList, ref LActionList, ref processes) == true) // Data read from Excel Files { if (rbIE.Checked == true) { g_WebControl_SHDOC = new WebControl_SHDoc(ref g_Util); g_WebControl_SHDOC.OpenWebSite(rbB2B, rbB2C, rbKPMRead, tB2BID, tB2BPW, ref processes); // Go to KPM site g_WebControl_SHDOC.GoToMainPage(LActionList[0]); if (rbKPMRead.Checked == true) { while (bCreateResult == false && tryCnt < 3) { bCreateResult = g_WebControl_SHDOC.KPMRead(ref LActionList, ref g_ExcelTool); // KPM Read tryCnt++; } } else if (rbTKCancel.Checked == true) { bCreateResult = g_WebControl_SHDOC.Delete(ref LTicketItemList, ref LActionList, ref g_ExcelTool); // Cancel Ticket } else { while (bCreateResult == false && tryCnt < 3) { bCreateResult = g_WebControl_SHDOC.CreateTickets(ref LTicketItemList, ref LActionList); // Start Ticket Creation tryCnt++; } } } else { g_WebControl_Selenium = new WebControl_Selenium(ref g_Util); g_WebControl_Selenium.OpenWebSite(rbB2B, rbB2C, rbKPMRead, tB2BID, tB2BPW, ref processes); // Go to KPM site g_WebControl_Selenium.GoToMainPage(ref LTicketItemList, ref LActionList, rbB2C); while (bCreateResult == false && tryCnt < 3) { bCreateResult = g_WebControl_Selenium.CreateTickets(ref LTicketItemList, ref LActionList, rbB2C, ref nTicketCNT); // Start Ticket Creation tryCnt++; } } g_ExcelTool.UpdateKPMDocument(LTicketItemList); } else { bExcelReadResult = false; } var nEndTick = DateTime.Now; long nGap = nEndTick.Ticks - nStartTick.Ticks; var nDiffSpan = new TimeSpan(nGap); string ResultReport = ""; if (bExcelReadResult == false) { ResultReport = "[Abnormal Termination!] Excel Path is Strange or ReadOnly. Please check your Excel File."; } else if (bCreateResult == false) { ResultReport = "[Abnormal Termination!] Something happen during creation. Please try it later. Try Count= " + tryCnt; } else { ResultReport = "Creation Success. " + nTicketCNT + " Tickets (" + nDiffSpan.Hours + "hr:" + nDiffSpan.Minutes + "min:" + nDiffSpan.Seconds + "sec). Try Count= " + tryCnt; } g_Util.DebugPrint(ResultReport); } catch (Exception error) { g_Util.DebugPrint(error.ToString()); CloseAll(); } }
public void ManualWait(int nTimer = 3000) { int nCurTime = 0; int nTickGap = 1000; while (nCurTime < nTimer) { #if (DEBUG) g_Util.DebugPrint("Manuel Wait. (" + nCurTime / 1000 + "/" + nTimer / 1000 + "sec)"); #endif System.Threading.Thread.Sleep(nTickGap); nCurTime += nTickGap; } }