Beispiel #1
0
        public bool valida()
        {
            hm = new HashMachine();
            string idMachine = hm.getHashMachine();
            string idLicenca = HashMachine.criptoMD5(Glass.usuario.token + idMachine, "tech");

            idLicenca = ValidaLogin.sReplace(idLicenca);

            return(Glass.usuario.licenca.Equals(idLicenca));
        }
Beispiel #2
0
        public static User buscaUser()
        {
            var  request  = (HttpWebRequest)WebRequest.Create(GlassService.GetUrl("sistema.php"));
            var  postData = "";
            User user     = null;

            postData  = "tipo=" + BUSCA_USUARIO;
            postData += "&cnpj=" + ValidaLogin.cnpj;
            postData += "&name=" + ValidaLogin.nome;
            postData += "&pass="******"&machine_name=" + Environment.MachineName;
            postData += "&key=cutfilmecf";

            var data = Encoding.ASCII.GetBytes(postData);

            request.Method        = "POST";
            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = data.Length;

            using (var stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            try
            {
                var response       = (HttpWebResponse)request.GetResponse();
                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd().Replace("[", "").Replace("]", "");

                if (responseString.Length > 0)
                {
                    user         = JsonConvert.DeserializeObject <User>(responseString);
                    user.licenca = ValidaLogin.sReplace(user.licenca);
                }
            }
            catch (Exception ex)
            {
                Logs.Log(ex.Message);
                throw;
            }

            return(user);
        }
Beispiel #3
0
        public static bool atualizaHashUser(string hash)
        {
            var  request  = (HttpWebRequest)WebRequest.Create(GlassService.GetUrl("sistema.php"));
            var  postData = "";
            bool retorno  = false;

            postData  = "tipo=" + ATUALIZA_HASH_USER;
            postData += "&licenca=" + ValidaLogin.sReplace(hash);
            postData += "&machine_name=" + Environment.MachineName;
            postData += "&token=" + Glass.usuario.token;
            postData += "&ultimo_acesso=" + DateTime.Now.ToString("dd'/'MM'/'yyyy HH:mm:ss");;
            postData += "&key=cutfilmecf";

            var data = Encoding.ASCII.GetBytes(postData);

            request.Method        = "POST";
            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = data.Length;

            using (var stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            try
            {
                var response       = (HttpWebResponse)request.GetResponse();
                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd().Replace("[", "").Replace("]", "");
                retorno = JsonConvert.DeserializeObject <bool>(responseString);
            }
            catch (Exception ex)
            {
                Logs.Log(ex.Message);
                throw;
            }

            return(retorno);
        }