private void runLogin(string serverName, string userName, string password, string accountNumber) { int timeout = 60; iMacros.App oApp = new iMacros.App(); // C# snippet generated by iMacros Editor. // See http://wiki.imacros.net/Web_Scripting for details on how to use the iMacros Scripting Interface. iMacros.AppClass iim = new iMacros.AppClass(); // iMacros.Status status = iim.iimOpen("", true, timeout); iMacros.Status status; StringBuilder macro = new StringBuilder(); macro.AppendLine(@"VERSION BUILD=7401110 RECORDER=FX"); macro.AppendLine(@"SET !TIMEOUT 180"); macro.AppendLine(@"SET !ENCRYPTION NO"); macro.AppendLine(@"SET !EXTRACT_TEST_POPUP NO"); macro.AppendLine(@"TAB T=1"); //macro.AppendLine(@"URL GOTO=https://qatelau40/CAT/Login.aspx?gru=000000000"); //macro.AppendLine(@"URL GOTO=https://" + ServerName.Text + @"/CAT/Login.aspx?gru=000000000"); macro.AppendLine(@"URL GOTO=https://" + serverName + @"/CAT/Login.aspx?gru=000000000"); //macro.AppendLine(@"TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form1 ATTR=ID:Login1_UserName CONTENT=admin"); //macro.AppendLine(@"TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form1 ATTR=ID:Login1_UserName CONTENT=" + UserName.Text); macro.AppendLine(@"TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form1 ATTR=ID:Login1_UserName CONTENT=" + userName); //macro.AppendLine(@"TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:form1 ATTR=ID:Login1_Password CONTENT=admin"); //macro.AppendLine(@"TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:form1 ATTR=ID:Login1_Password CONTENT=" + Password.Text); macro.AppendLine(@"TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:form1 ATTR=ID:Login1_Password CONTENT=" + password); macro.AppendLine(@"TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:form1 ATTR=ID:Login1_Login"); macro.AppendLine(@"TAG POS=1 TYPE=SPAN ATTR=ID:MainNavigation1_lblClientName"); macro.AppendLine(@"TAG POS=1 TYPE=TD ATTR=TXT:Telstra"); macro.AppendLine(@"TAG POS=1 TYPE=TD ATTR=CLASS:homeleftcolumn"); macro.AppendLine(@"TAG POS=1 TYPE=SPAN ATTR=TXT:Find<SP>Account"); //macro.AppendLine(@"TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form1 ATTR=ID:AccountSearch1_SearchBox CONTENT=1525853400"); //macro.AppendLine(@"TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form1 ATTR=ID:AccountSearch1_SearchBox CONTENT=" + AccountNumber.Text); macro.AppendLine(@"TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form1 ATTR=ID:AccountSearch1_SearchBox CONTENT=" + accountNumber); macro.AppendLine(@"TAG POS=1 TYPE=INPUT:RADIO FORM=ID:form1 ATTR=ID:AccountSearch1_rblSearchType_1"); macro.AppendLine(@"TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:form1 ATTR=ID:AccountSearch1_SearchButton"); macro.AppendLine(@"'TAG POS=1 TYPE=TD ATTR=TXT:CSR<SP>Login"); macro.AppendLine(@"TAG POS=1 TYPE=A ATTR=ID:FindAccountGridView_ctl02_linkCSRLogin"); macro.AppendLine(@"FRAME F=2"); macro.AppendLine(@"'TAG POS=1 TYPE=IMG ATTR=SRC:*cv/scripts/images/eng/telstra*/b_logout_off.gif"); string macroCode = macro.ToString(); //status = iim.iimOpen("-V7", true, timeout); status = iim.iimOpen("-FX", true, timeout); OutputBox.Text += status.ToString() + "\r\n"; status = iim.iimDisplay("Interface version =\n" + iim.iimGetInterfaceVersion().ToString(), timeout); OutputBox.Text += status.ToString() + "\r\n"; status = iim.iimPlayCode(macroCode, timeout); OutputBox.Text += status.ToString() + "\r\n"; status = iim.iimClose(timeout); OutputBox.Text += status.ToString() + "\r\n"; }
/*Constructor SegundaMano*/ #region Constructor Clase public SegundaMano() { this.iWaitTime = 1; //Tiempo de espera para scrapear cada pagina globalCountMax = 25; //Cantidade de iteraciones para reiniciar el imacros this.globalCount = globalCountMax; this.context.Configuration.AutoDetectChangesEnabled = false; this.context.Configuration.ValidateOnSaveEnabled = false; this.htmlDoc = new HtmlDocument(); //Declaracion de la Instancia del imacros #region Instancia Imacros iMacros.Status status; app = new iMacros.AppClass(); status = app.iimInit("-tray", false); #endregion }
/*Gestion de Memoria*/ #region Metodo responsable por gestionar la memoria limitada del imacros public void controlMemoriaImacros() { if (globalCount == 0) { app.iimClose(); app = new iMacros.AppClass(); status = app.iimInit("-tray", false); string sScript = ""; sScript = "CODE:" + Environment.NewLine; sScript += "CLEAR" + Environment.NewLine; sScript += "VERSION BUILD=9002379" + Environment.NewLine; sScript += "TAB T=1" + Environment.NewLine; sScript += "TAB CLOSEALLOTHERS" + Environment.NewLine; sScript += "FILTER TYPE=IMAGES STATUS=ON " + Environment.NewLine; app.iimPlay(sScript); globalCount = globalCountMax; } else { globalCount--; } }