Example #1
0
        public ValidacaoAcessoSoapClient SetConfigValidacaoAcessoService()
        {
            ValidacaoAcessoSoapClient client = new ValidacaoAcessoSoapClient();

            if (String.IsNullOrEmpty(SettingsServer.Default.AccessedUrl))
            {
                string url = GetUrlConnected("ValidacaoAcesso.asmx");

                if (url == null)
                {
                    return(null);
                }

                SettingsServer.Default.AccessedUrl = url;
                SettingsServer.Default.Save();
            }
            else
            {
                if (!VerifyInternet.VerifyConnection(SettingsServer.Default.AccessedUrl))
                {
                    return(null);
                }
            }

            client.Endpoint.Address = new EndpointAddress(SettingsServer.Default.AccessedUrl);
            return(client);
        }
Example #2
0
        private void EndSession()
        {
            try
            {
                ValidacaoAcessoSoapClient acessoSoapClient = Settings.DefiniServer.Instance(LanguageDefault).SetConfigValidacaoAcessoService();
                acessoSoapClient.FinalizarSessao(Utility.Cript(_codigoSessao));
            }
            finally
            {
                SettingsServer.Default.AccessedUrl = "";
                SettingsServer.Default.Save();

                //_threadEndSession.Abort();
                //_threadEndSession = null;
            }
        }
Example #3
0
        public bool ReloadLogin(string login, string password, string codigoSessao)
        {
            ValidacaoAcessoSoapClient acessoSoapClient = Settings.DefiniServer.Instance(LanguageDefault).SetConfigValidacaoAcessoService();

            if (acessoSoapClient == null)
            {
                ReconnectRevalidation(login, password, codigoSessao);
            }

            XElement xElement = acessoSoapClient.RevalidarUsuario(login, password, codigoSessao);

            XmlDocument xmlServer = new XmlDocument();

            using (XmlReader xmlReader = xElement.CreateReader())
            {
                xmlServer.Load(xmlReader);
            }

            acessoSoapClient.Close();

            xmlServer.ChildNodes[0].InnerXml = Utility.Decript(xmlServer.ChildNodes[0].InnerXml);

            if (xmlServer.DocumentElement != null)
            {
                XmlNode xmlFechamento = xmlServer.DocumentElement.SelectSingleNode("FECHAMENTO");
                XmlNode xmlStatus     = xmlServer.DocumentElement.SelectSingleNode("STATUS");
                XmlNode xmlInformacao = xmlServer.DocumentElement.SelectSingleNode("INFORMACAO");


                if ((xmlStatus != null) && (xmlStatus.InnerText == "1"))
                {
                    return(true);
                }
                else
                {
                    Console.Write(xmlInformacao.InnerText);
                    return(false);
                }
            }

            return(false);
        }
Example #4
0
        public LoginAuthentication LoadLogin(string login, string password, string codigoSessao)
        {
            LoginAuthentication loginAuthentication = null;

            ValidacaoAcessoSoapClient acessoSoapClient = Settings.DefiniServer.Instance(LanguageDefault).SetConfigValidacaoAcessoService();


            //var c = acessoSoapClient.State;
            if (acessoSoapClient == null)
            {
                ReconnectValidation(login, password, codigoSessao);
            }
            XElement    xElement;
            XmlDocument xmlServer = new XmlDocument();

            try
            {
                xElement = acessoSoapClient.ValidarUsuario(login, password, codigoSessao);

                //c = acessoSoapClient.State;
                using (XmlReader xmlReader = xElement.CreateReader())
                {
                    xmlServer.Load(xmlReader);
                }

                acessoSoapClient.Close();


                xmlServer.ChildNodes[0].InnerXml = Utility.Decript(xmlServer.ChildNodes[0].InnerXml);

                if (xmlServer.DocumentElement != null)
                {
                    XmlNode xmlFechamento = xmlServer.DocumentElement.SelectSingleNode("FECHAMENTO");

                    if (xmlFechamento == null)
                    {
                        ReconnectValidation(login, password, codigoSessao);
                    }

                    XmlNode xmlStatus = xmlServer.DocumentElement.SelectSingleNode("STATUS");

                    XmlNode xmlIpServer = xmlServer.DocumentElement.SelectSingleNode("IPSERVER");

                    if ((xmlStatus != null) && (xmlStatus.HasChildNodes))
                    {
                        if (xmlStatus.InnerText == "1")
                        {
                            XmlNode xmlCodigoSessao = xmlServer.DocumentElement.SelectSingleNode("CODIGOSESSAO");

                            XmlNode xmlDataExpiracao = xmlServer.DocumentElement.SelectSingleNode("DATAEXPIRACAO");

                            XmlNodeList acessos = xmlServer.GetElementsByTagName("ACESSO");

                            XmlNode xmlId = xmlServer.DocumentElement.SelectSingleNode("ID");

                            XmlNode xmlLogin = xmlServer.DocumentElement.SelectSingleNode("LOGIN");

                            XmlNode xmlSenha = xmlServer.DocumentElement.SelectSingleNode("SENHA");

                            XmlNode xmlNome = xmlServer.DocumentElement.SelectSingleNode("NOME");

                            XmlNode xmlSobreNome = xmlServer.DocumentElement.SelectSingleNode("SOBRENOME");

                            XmlNode xmlCpf = xmlServer.DocumentElement.SelectSingleNode("CPF");

                            XmlNode xmlEmail = xmlServer.DocumentElement.SelectSingleNode("EMAIL");

                            XmlNode xmlNascimento = xmlServer.DocumentElement.SelectSingleNode("DATANASCIMENTO");

                            XmlNode xmlCep = xmlServer.DocumentElement.SelectSingleNode("CEP");

                            XmlNode xmlEstado = xmlServer.DocumentElement.SelectSingleNode("ESTADO");

                            XmlNode xmlCidade = xmlServer.DocumentElement.SelectSingleNode("CIDADE");

                            XmlNode xmlBairro = xmlServer.DocumentElement.SelectSingleNode("BAIRRO");

                            XmlNode xmlLagradouro = xmlServer.DocumentElement.SelectSingleNode("LAGRADOURO");

                            XmlNode xmlNumero = xmlServer.DocumentElement.SelectSingleNode("NUMERO");

                            XmlNode xmlComplemento = xmlServer.DocumentElement.SelectSingleNode("COMPLEMENTO");

                            XmlNode xmlTipo = xmlServer.DocumentElement.SelectSingleNode("TIPO");

                            loginAuthentication = new LoginAuthentication
                            {
                                CodeSession = xmlCodigoSessao.InnerText,
                                Login       = login,
                                Password    = password,
                                LastDate    = DateTime.Now,
                                LimitDate   = String.IsNullOrEmpty(xmlDataExpiracao.InnerText) ? DateTime.Now.AddDays(2) : DateTime.Parse(xmlDataExpiracao.InnerText),
                                Remember    = true,
                                Features    = new List <Features>(),
                                IpServer    = xmlIpServer.InnerText,
                                UserProfile = new UserRegister()
                                {
                                    Id              = int.Parse(xmlId.InnerText),
                                    Birthday        = String.IsNullOrEmpty(xmlDataExpiracao.InnerText) ? new DateTime(1900, 1, 1) : DateTime.Parse(xmlNascimento.InnerText),
                                    CEP             = xmlCep.InnerText,
                                    City            = xmlCidade.InnerText,
                                    Complement      = xmlComplemento.InnerText,
                                    ConfirmPassword = xmlSenha.InnerText,
                                    CPF             = xmlCpf.InnerText,
                                    District        = xmlBairro.InnerText,
                                    Email           = xmlEmail.InnerText,
                                    FirstName       = xmlNome.InnerText,
                                    LastName        = xmlSobreNome.InnerText,
                                    Number          = xmlNumero.InnerText,
                                    Password        = xmlSenha.InnerText,
                                    State           = xmlEstado.InnerText,
                                    Street          = xmlLagradouro.InnerText,
                                    UserName        = xmlLogin.InnerText,
                                    Tipo            = (EPerfil)int.Parse(xmlTipo.InnerText)
                                }
                            };

                            foreach (Features features in from XmlNode acesso in acessos
                                     select new Features
                            {
                                Description = (EFeatures)StringValue.Parse(typeof(EFeatures), acesso["CODIGOACESSO"].InnerText),
                                Permission = (EPermission)StringValue.Parse(typeof(EPermission), acesso["MODO"].InnerText)
                            })
                            {
                                loginAuthentication.Features.Add(features);
                            }
                        }
                        else if (xmlStatus.InnerText == "0")
                        {
                            XmlNode xmlInformacao = xmlServer.DocumentElement.SelectSingleNode("INFORMACAO");
                            throw new Exception(xmlInformacao.InnerText);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                acessoSoapClient.Close();
                throw ex;
                //ReconnectValidation(login, password, codigoSessao);
            }


            return(loginAuthentication);
        }