示例#1
0
        //public string ReadScreen(int position, int lenght)
        //{
        //    var outParam= "";
        //    EhllapiWrapper.ReadScreen(position, lenght, out outParam);
        //    EhllapiWrapper.Wait();
        //    return outParam.Substring(0,lenght);
        //}

        public string ReadScreen(string position, int lenght)
        {
            var Spliteo = position.Split(',');
            int x, y;

            Int32.TryParse(Spliteo[0], out x);
            Int32.TryParse(Spliteo[1], out y);
            var outParam = "";

            EhllapiWrapper.ReadScreen(Methods.GetWSPosition(x, y), lenght, out outParam);
            Methods.LogProceso("Se leyó la posición \t\t [" + x + "/" + y + "]");
            EhllapiWrapper.Wait();
            return(outParam.Substring(0, lenght));
        }
示例#2
0
        public static Boolean OpenWS(string EmulatorURL, string SessionId, string Username, string Password, out int Id)
        {
            Console.Write("Inicializando IBS... ");
            string IsShowWindow = ConfigurationManager.AppSettings["ShowWindow"].ToString().Trim();
            string Session      = ConfigurationManager.AppSettings["SessionId"].ToString().Trim();

            Process[] pcscmProcesses = Process.GetProcessesByName("pcsws");
            if (pcscmProcesses.Length == 0)
            {
                Process.Start("taskkill", "/F /IM [pcsws].exe");
                Process.Start("taskkill", "/F /IM [pcscm].exe");
            }
            //Funciona correcto
            Process px = Process.Start(EmulatorURL);
            //Process px = new Process();
            //try
            //{
            //    px.StartInfo = new ProcessStartInfo(EmulatorURL);
            //    px.StartInfo.CreateNoWindow = true;
            //    px.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
            //    px.Start();

            //} catch (Exception e)
            //{
            //    LogProceso(e.ToString());
            //}

            //Thread.Sleep(4000);
            int _i = 0;

            Id = 0;
            do
            {
                try
                {
                    pcscmProcesses = Process.GetProcessesByName("pcsws");
                    Id             = pcscmProcesses.ToList().Find(x => x.MainWindowTitle.Contains(Session)).Id;
                    _i             = 1;
                    if (IsShowWindow.Equals("SI"))
                    {
                        ShowWindow(Process.GetProcessById(Id).MainWindowHandle, 2);
                    }
                }
#pragma warning disable CS0168 // La variable 'e' se ha declarado pero nunca se usa
                catch (Exception e)
#pragma warning restore CS0168 // La variable 'e' se ha declarado pero nunca se usa
                {
                    //throw new Exception("No se inició correctamente la sesión B");
                    Thread.Sleep(1000);
                }
            } while (_i == 0);

            Boolean isOpenWS = false;
            string  validationPass;
            int     i = 0;
            do
            {
                try
                {
                    AutomationElement           _0 = AutomationElement.FromHandle(px.MainWindowHandle);
                    AutomationElementCollection _0_Descendants_1 = _0.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "ID de usuario:"));
                    ValuePattern etb = _0_Descendants_1[1].GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
                    etb.SetValue(Username);

                    AutomationElementCollection _0_Descendants_2 = _0.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Contraseña:"));
                    ValuePattern etb2 = _0_Descendants_2[1].GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
                    etb2.SetValue(Password);

                    AutomationElementCollection _0_Descendants_3 = _0.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Aceptar"));

                    var invokePattern = _0_Descendants_3[0].GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
                    invokePattern.Invoke();
                }
#pragma warning disable CS0168 // La variable 'e' se ha declarado pero nunca se usa
                catch (Exception e)
#pragma warning restore CS0168 // La variable 'e' se ha declarado pero nunca se usa
                {
                }


                EhllapiWrapper.Connect(SessionId);
                EhllapiWrapper.Wait();
                EhllapiWrapper.SetCursorPos(GetWSPosition(6, 17));
                EhllapiWrapper.Wait();
                EhllapiWrapper.ReadScreen(GetWSPosition(6, 17), 7, out validationPass);
                EhllapiWrapper.Wait();
                try
                {
                    if (validationPass.Substring(0, 7) == "Usuario")
                    {
                        var ValidationMsg = "";

                        EhllapiWrapper.Wait();
                        EhllapiWrapper.Connect(SessionId);
                        EhllapiWrapper.Wait();
                        EhllapiWrapper.SetCursorPos(GetWSPosition(6, 53));
                        EhllapiWrapper.Wait();
                        EhllapiWrapper.SendStr(Username);
                        EhllapiWrapper.Wait();
                        EhllapiWrapper.SetCursorPos(GetWSPosition(7, 53));
                        EhllapiWrapper.Wait();
                        EhllapiWrapper.SendStr(Password);
                        EhllapiWrapper.Wait();
                        EhllapiWrapper.SendStr("@E");
                        EhllapiWrapper.Wait();
                        ValidationMsg = "";
                        EhllapiWrapper.SetCursorPos(GetWSPosition(1, 26));
                        EhllapiWrapper.Wait();
                        EhllapiWrapper.ReadScreen(GetWSPosition(1, 26), 31, out ValidationMsg);
                        EhllapiWrapper.Wait();
                        if (ValidationMsg.Substring(0, 31).Equals("Visualizar Mensajes de Programa"))
                        {
                            EhllapiWrapper.SendStr("@E");
                            EhllapiWrapper.Wait();
                            isOpenWS = true;
                        }
                        else
                        {
                            Console.Write("OK\n");
                            isOpenWS = true;
                        }
                        i = 1;
                    }
                }
#pragma warning disable CS0168 // La variable 'e' se ha declarado pero nunca se usa
                catch (Exception e)
#pragma warning restore CS0168 // La variable 'e' se ha declarado pero nunca se usa
                {
                }
            } while (i == 0);
            return(isOpenWS);
        }