示例#1
0
        public string Incluir(Exist_UsersDto Models)
        {
            try
            {
                string   senha = Models.user_password;
                DateTime now   = new DateTime();
                now   = DateTime.Now;
                senha = PwdEncript.criptograph.Criptografar(senha);
                conexao.LimparParametros();
                string date = "";

                date = GetFormatDateForDB(now, false, true);

                string sql = "INSERT INTO exist_users (user_name,user_password,user_company,user_country,user_email,user_phone,user_date_register,treatment) ";
                sql = sql + " VALUES ('" + Models.user_name + "','" + senha + "','" + Models.user_company + "','"
                      + Models.user_country + "','" + Models.user_email + "','" + Models.user_phone + "','" + date + "', ' " + Models.treatment + "'); select 1;";

                var retorno = conexao.ExecutarQuery(CommandType.Text, sql).ToString();

                return(retorno);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        public bool IsNewUser(string email)
        {
            Exist_UsersDto usuario = new Exist_UsersDto();

            try
            {
                string sql = "SELECT * FROM exist_users";
                if (email != null)
                {
                    sql = sql + " where user_email ='" + email + "'";
                }
                conexao.LimparParametros();
                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);
                if (tabela.Rows.Count == 0)
                {
                    return(true);
                }
                foreach (DataRow item in tabela.Rows)
                {
                    if (item["user_date_expire"] == DBNull.Value)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        public List <string> pegarOsAdmsPais(long country)
        {
            try
            {
                List <string> usuarios = new List <string>();

                string sql = "SELECT * FROM exist_users";
                if (country != 0)
                {
                    sql = sql + " inner join region_for_users on exist_users.user_id = region_for_users.user_id WHERE user_admin = 1  and country_id =" + country;
                }

                conexao.LimparParametros();
                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);
                foreach (DataRow item in tabela.Rows)
                {
                    Exist_UsersDto usuario = new Exist_UsersDto();

                    usuario.user_email = item["user_email"].ToString();
                    usuarios.Add(usuario.user_email);
                }
                return(usuarios);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#4
0
        public ActionResult editarUsuario(long user_id)
        {
            exist_users    user   = new exist_users();
            Exist_UsersDto Models = new Exist_UsersDto();

            Models = user.consultarUsuario(user_id);
            string cSenha  = Request.Form["user_password_confirm"];
            object retorno = new object();

            RemoveReferences(ModelState, "user_country");

            if (Models.countries.country_id == 0)
            {
                ModelState.AddModelError("user_country.country_id", "pais é obrigatório");
                paises();
                tratamentos();
                string contentView = RenderViewToString("~/Views/Home/editarForm.cshtml", Models);
                return(Json(new { status = "validation", view = contentView }));
            }
            if (!ModelState.IsValid)
            {
                paises();
                tratamentos();
                string contentView = RenderViewToString("~/Views/Home/editarForm.cshtml", Models);
                return(Json(new { status = "validation", view = contentView }));
            }
            retorno = user.Editar(Models);

            if (retorno == "0")
            {
                return(Json(new { status = "validation", message = "Erro ao conectar na Database" }));
            }
            return(Json(new { status = "success", message = "cadastro com sucesso" }));
        }
示例#5
0
        public void GetConfigEnergia(Exist_UsersDto usuario)
        {
            enunit_config enunit_config = new enunit_config();
            long          en_measure_id = 0;

            en_measure_id = enunit_config.ConsultarSistemaEnergia(usuario.system_id.Value, usuario.measure_config_id);

            ViewBag.en_measure_id = en_measure_id;
        }
        public ActionResult Index()
        {
            Exist_UsersDto usuario = getUser();

            GetDropDownRegioes();
            paises();
            tratamentos();
            ViewBag.usuario = usuario;

            return(View());
        }
        public ActionResult Excluir(Exist_UsersDto model)
        {
            try
            {
                exist_users user = new exist_users();
                user.Excluir(model.user_id);

                return(Json(new { status = "success" }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "error" }));
            }
        }
        public ActionResult Editar(Exist_UsersDto model)
        {
            try
            {
                RemoveReferences(ModelState, "country_id");
                exist_users exist_users = new exist_users();
                string      retorno     = exist_users.Editar(model);

                return(Json(new { status = "success" }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "error" }));
            }
        }
示例#9
0
        public string AtualizaConfiguracoes(Exist_UsersDto model)
        {
            try
            {
                conexao.LimparParametros();
                string query = "update exist_users set system_id=" + model.system_id + ", base_calc=" + model.base_calc + ", dose=" + model.dose + "  where user_id=" + model.user_id + "; select 1;";

                string retorno = conexao.ExecutarQuery(CommandType.Text, query).ToString();

                return(retorno);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#10
0
        public void SetAction2(Exist_UsersDto Models)
        {
            try
            {
                string sql = "";

                sql = "UPDATE exist_users SET action='2' WHERE user_id='" + Models.user_id + "'";

                conexao.LimparParametros();
                conexao.ExecutarQuery(CommandType.Text, sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#11
0
        public ActionResult Justificar(string user_email, string Justificativa, string email_adm)
        {
            try
            {
                exist_users           user            = new exist_users();
                LoginController       control         = new LoginController();
                List <string>         admsEmail       = new List <string>();
                List <string>         admsEmailMaster = new List <string>();
                countries_for_region  regXpais        = new countries_for_region();
                historic_action_users just            = new historic_action_users();
                long           userCountry;
                long           userReg = 0;
                bool           flag    = true;
                Exist_UsersDto Models  = new Exist_UsersDto();
                string         ip      = GetLocalIpAddress();

                Models          = user.consultarUsuario(user_email);
                userCountry     = Convert.ToInt64(Models.user_country);
                userReg         = regXpais.PegarRegiaoViaPais(userCountry);
                admsEmail       = user.pegarOsAdms(userReg);
                admsEmailMaster = user.pegarOsMasters();
                string aviso = @GeralResource.RecRes(634);

                just.InserirJustificativa(Justificativa, email_adm, Models.user_id, ip);

                foreach (var email in admsEmail)
                {
                    control.JustifyEmail(email, aviso);
                }
                foreach (var email in admsEmailMaster)
                {
                    control.JustifyEmail(email, aviso);
                }

                control.JustifyEmail(user_email, aviso);
                ViewBag.mensagem = @GeralResource.RecRes(582);

                user.BlockUser(Models.user_id);

                return(Json(new { status = "success", message = @GeralResource.RecRes(582), JsonRequestBehavior.AllowGet }));
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#12
0
        public bool ExistUser(string email)
        {
            string         sql     = "SELECT * FROM exist_users where user_email='" + email + "'";
            Exist_UsersDto usuario = new Exist_UsersDto();

            conexao.LimparParametros();
            DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);

            if (tabela.Rows.Count == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#13
0
        public object UnBlockUser(long id)
        {
            Exist_UsersDto user = new Exist_UsersDto();

            try
            {
                string sql = "UPDATE exist_users SET user_blocked =0 where user_id=" + id;
                conexao.LimparParametros();
                var retorno = conexao.ExecutarQuery(CommandType.Text, sql);

                return(retorno);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#14
0
        public string pegarSenhaViaEmail(string user_email)
        {
            try
            {
                string         sql     = "SELECT * FROM exist_users WHERE user_email='" + user_email + "'";
                Exist_UsersDto usuario = new Exist_UsersDto();

                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);
                foreach (DataRow item in tabela.Rows)
                {
                    usuario.user_password = item["user_password"].ToString();
                }

                return(usuario.user_password);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#15
0
        public string AlterarSenha(Exist_UsersDto Models)
        {
            try
            {
                string senha = Models.user_password;
                senha = PwdEncript.criptograph.Criptografar(senha);
                string sql = "";

                sql = "update exist_users SET user_password= '******' WHERE user_id= " + Models.user_id + "; select 1;";

                conexao.LimparParametros();
                string retorno = conexao.ExecutarQuery(CommandType.Text, sql).ToString();

                return(retorno);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult Incluir(Exist_UsersDto model)
        {
            try
            {
                RemoveReferences(ModelState, "country_id");

                //if (!ModelState.IsValid)
                //{
                //    return Json(new { status = "validation", view = "" });
                //}

                exist_users exist_users = new exist_users();
                string      retorno     = exist_users.Incluir(model);


                return(Json(new { status = "success" }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "error" }));
            }
        }
示例#17
0
        public string Editar(Exist_UsersDto Models)
        {
            try
            {
                string senha = Models.user_password;
                senha = PwdEncript.criptograph.Criptografar(senha);

                string sql = "";

                sql = "update exist_users SET user_name= '" + Models.user_name + "' " +
                      ", user_phone=' " + Models.user_phone + "', last_name= '" + Models.last_name + "' , user_country= '" + Models.user_country + "' , treatment= '" + Models.treatment + "' , user_email='" + Models.user_email + "', user_password='******', user_company='" + Models.user_company + "' WHERE user_id='" + Models.user_id + "'; select 1;";


                var retorno = conexao.ExecutarQuery(CommandType.Text, sql).ToString();
                return(retorno);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#18
0
        public List <string> pegarOsMasters()
        {
            try
            {
                string        sql      = "select * from exist_users where user_accesslevel =9";
                List <string> usuarios = new List <string>();
                conexao.LimparParametros();
                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);
                foreach (DataRow item in tabela.Rows)
                {
                    Exist_UsersDto usuario = new Exist_UsersDto();

                    usuario.user_email = item["user_email"].ToString();
                    usuarios.Add(usuario.user_email);
                }
                return(usuarios);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#19
0
        public ActionResult AlterarSenha(Exist_UsersDto Models)
        {   // alterar senha quando o usuario digitou senha temporaria
            try
            {
                exist_users user     = new exist_users();
                string      cSenha   = Request.Form["user_password_confirm"];
                string      truePass = Models.user_password;
                Models = user.consultarUsuario(Models.user_id);
                Models.user_password         = truePass;
                Models.user_password_confirm = cSenha;
                RemoveReferences(ModelState, "user_country");

                if (Models.user_password != Models.user_password_confirm)
                {
                    ModelState.AddModelError("user_password", GeralResource.RecRes(120));
                    paises();
                    tratamentos();
                    string contentView = RenderViewToString("~/Views/Home/FormPass.cshtml", Models);
                    return(Json(new { status = "validation", view = contentView }));
                }
                if (CalculateEntropy(Models.user_password) < 2)
                {
                    ModelState.AddModelError("user_password", GeralResource.RecRes(626));
                    paises();
                    tratamentos();
                    string contentView = RenderViewToString("~/Views/Home/FormPass.cshtml", Models);
                    return(Json(new { status = "validation", view = contentView }));
                }
                string retorno = user.AlterarSenha(Models);
                if (retorno != "1")
                {
                }
                return(Json(new { status = "success", message = GeralResource.RecRes(448) }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "error", message = GeralResource.RecRes(561) }));
            }
        }
示例#20
0
        public object AlterarDadosADM(Exist_UsersDto Models)
        {
            try
            {
                string senha = Models.user_password;
                senha = PwdEncript.criptograph.Criptografar(senha);

                string sql = "";

                sql = "update exist_users SET user_name='" + Models.user_name + "' " +
                      ", user_phone=' " + Models.user_phone + "' , user_email='" + Models.user_email + "', user_password= '******', user_company='" + Models.user_company + "' WHERE user_id= '" + Models.user_id + "', user_acesslevel= '" + Models.user_accesslevel + "' , treatment= '" + Models.treatment + "' , user_date_expire= '" + Models.user_date_expire +
                      "' ,  user_country ='" + Models.user_country + "'";
                ;

                conexao.LimparParametros();
                var retorno = conexao.ExecutarQuery(CommandType.Text, sql);
                return(retorno);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#21
0
        // GET: Home

        public ActionResult License(string emailUser, string aprovar, string lang, string emailAdm)
        {
            LoginController       utilidade = new LoginController();
            exist_users           user      = new exist_users();
            Exist_UsersDto        Models    = new Exist_UsersDto();
            Exist_UsersDto        adm       = new Exist_UsersDto();
            historic_action_users just      = new historic_action_users();


            byte[] byteEmailUser = System.Convert.FromBase64String(emailUser.Replace(" ", ""));
            emailUser = System.Text.Encoding.UTF8.GetString(byteEmailUser);

            byte[] byteEmailAdmin = System.Convert.FromBase64String(emailAdm.Replace(" ", ""));
            emailAdm = System.Text.Encoding.UTF8.GetString(byteEmailAdmin);

            //  emailUser = PwdEncript.criptograph.Descriptografar(emailUser);
            // emailAdm = PwdEncript.criptograph.Descriptografar(emailAdm);

            Models = user.consultarUsuario(emailUser);
            adm    = user.consultarUsuario(emailAdm);
            string ip = GetLocalIpAddress();

            bool userIsnew = true;
            bool approve   = false;

            if (adm == null)
            {
                return(Content("<label>" + @GeralResource.RecRes(580) + "</label>"));
            }
            if (adm.user_accesslevel < 1)
            {
                return(Content("<label>" + @GeralResource.RecRes(580) + "</label>"));
            }

            if (aprovar == "1")
            {
                approve = true;
            }
            userIsnew = user.IsNewUser(Models.user_id);

            if (!approve)
            {
                ViewBag.mensagem = "";
                ViewBag.user     = emailUser;
                ViewBag.data     = DateTime.Now;
                ViewBag.email    = emailAdm;
                ViewBag.approve  = 0;
                user.SetAction2(Models);
            }
            else
            {
                if (Models.user_date_expire != null)
                {
                    if (Models.user_date_expire > DateTime.Now)
                    {
                        ViewBag.mensagem = @GeralResource.RecRes(138);
                        ViewBag.approve  = 1;
                    }
                }
                else
                {
                    ViewBag.mensagem = @GeralResource.RecRes(138);
                    ViewBag.approve  = 1;
                    user.license(Models.user_id);
                    just.InserirJustificativa(emailAdm, Models.user_id, ip);
                }
            }
            return(View());
        }
示例#22
0
        public ActionResult Formulation()
        {
            try
            {
                // var usuario = getUser();
                //var user_id = usuario.user_id;
                //var lang_id = usuario.lang_id;
                //var table_id = usuario.table_id;
                //var langcode = usuario.lang_id.lang_mmc;

                //var langcode = GetLangCode(this);
                ViewBag.langcode = Session["lang_code"];

                Exist_UsersDto usuario = (Exist_UsersDto)Session["usuario"];


                exist_base_tables           basetb  = new exist_base_tables();
                List <Exist_Base_TablesDto> tabelas = basetb.Consultar(usuario.user_id, usuario.lang_id.lang_id);
                ViewBag.tabelas = tabelas;
                var tabela = tabelas.Where(f => f.table_id == usuario.table_id).ToList()[0];
                ViewBag.tabela_ativa_id   = usuario.table_id;
                ViewBag.tabela_ativa_nome = tabela.table_description;

                Measure_Systems MeasSystem = new Measure_Systems();
                Measure_SystemsDtoCollection measure_systems = MeasSystem.Consultar();
                ViewBag.units = measure_systems;

                List <SelectListItem> BaseCalcs = new List <SelectListItem>();
                BaseCalcs.Add(new SelectListItem()
                {
                    Text = GeralResource.RecRes(242), Value = "0"
                });
                BaseCalcs.Add(new SelectListItem()
                {
                    Text = GeralResource.RecRes(243), Value = "1"
                });

                ViewBag.BaseCalcs = BaseCalcs;

                List <SelectListItem> EnUnits = new List <SelectListItem>();
                EnUnits.Add(new SelectListItem()
                {
                    Text = GeralResource.RecRes(1112), Value = "1"
                });
                EnUnits.Add(new SelectListItem()
                {
                    Text = GeralResource.RecRes(1113), Value = "2"
                });

                ViewBag.EnUnits = EnUnits;
                ViewBag.Dose    = usuario.dose;
                GetConfigEnergia(usuario);

                paises();
                tratamentos();
                ViewBag.usuario = usuario;
                ViewBag.specie  = usuario.specie_id;
                GetSelectionSubProducts();
            }
            catch (Exception ex)
            {
                ViewBag.ErrorPage = ex.Message;
            }
            return(View());
        }
示例#23
0
        public Exist_UsersDto consultarUsuario(long user_id)
        {
            Exist_UsersDto usuario = new Exist_UsersDto();

            try
            {
                Exist_UsersDtoCollection usuarios = new Exist_UsersDtoCollection();

                string sql = "SELECT *FROM exist_users";
                if (user_id != 0)
                {
                    sql = sql + " WHERE user_id='" + user_id + "'";
                }
                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);
                foreach (DataRow item in tabela.Rows)
                {
                    usuario.user_email   = item["user_email"].ToString();
                    usuario.user_company = item["user_company"].ToString();
                    usuario.user_name    = item["user_name"].ToString();
                    usuario.user_phone   = item["user_phone"].ToString();
                    exist_languages exist_languages  = new exist_languages();
                    long            lang_id          = Convert.ToInt64(item["lang_id"]);
                    var             lang_collections = exist_languages.Consultar(lang_id);
                    if (lang_collections.Count > 0)
                    {
                        usuario.lang_id = lang_collections[0];
                    }
                    if (item["user_date_expire"] != DBNull.Value)
                    {
                        usuario.user_date_expire = Convert.ToDateTime(item["user_date_expire"]);
                    }
                    if (item["user_date_register"] != DBNull.Value)
                    {
                        usuario.user_date_register = Convert.ToDateTime(item["user_date_register"]);
                    }
                    if (item["date_answer"] != DBNull.Value)
                    {
                        usuario.date_answer = Convert.ToDateTime(item["date_answer"]);
                    }
                    if (item["treatment"] != DBNull.Value)
                    {
                        usuario.treatment = item["treatment"].ToString();
                    }
                    usuario.currency_id = Convert.ToInt64(item["currency_id"]);
                    usuario.base_calc   = Convert.ToInt32(item["base_calc"]);
                    usuario.specie_id   = Convert.ToInt64(item["specie_id"]);
                    usuario.dose        = Convert.ToInt64(item["dose"]);

                    usuario.user_blocked  = Convert.ToBoolean(item["user_blocked"]);
                    usuario.user_id       = Convert.ToInt64(item["user_id"]);
                    usuario.user_password = item["user_password"].ToString();
                    usuario.user_country  = Convert.ToInt64(item["user_country"]);
                    CountriesDto countries = new CountriesDto()
                    {
                        country_id = Convert.ToInt64(item["user_country"])
                    };
                    usuario.user_admin = Convert.ToBoolean(item["user_admin"]);

                    if (item["comments"] != DBNull.Value)
                    {
                        usuario.comments = item["comments"].ToString();
                    }
                    if (item["user_accesslevel"] != DBNull.Value)
                    {
                        usuario.user_accesslevel = Convert.ToInt32(item["user_accesslevel"]);
                    }
                    if (item["lang_id"] != DBNull.Value)
                    {
                        usuario.lang_id.lang_id = Convert.ToInt64(item["lang_id"]);
                    }
                    if (item["table_id"] != DBNull.Value)
                    {
                        usuario.table_id = Convert.ToInt64(item["table_id"]);
                    }
                    if (item["measure_config_id"] != DBNull.Value)
                    {
                        usuario.measure_config_id = Convert.ToInt64(item["measure_config_id"]);
                    }
                    if (item["system_id"] != DBNull.Value)
                    {
                        usuario.system_id = Convert.ToInt64(item["system_id"]);
                    }
                    if (item["action"] != DBNull.Value)
                    {
                        usuario._action = Convert.ToInt32(item["action"]);
                    }
                    if (item["last_name"] != DBNull.Value)
                    {
                        usuario.last_name = item["last_name"].ToString();
                    }
                    return(usuario);
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#24
0
        private Exist_UsersDtoCollection GetExist_UsersDtoCollection(DataTable tabela)
        {
            try
            {
                Exist_UsersDtoCollection usuarios = new Exist_UsersDtoCollection();

                foreach (DataRow item in tabela.Rows)
                {
                    Exist_UsersDto usuario = new Exist_UsersDto();
                    usuario.user_id      = Convert.ToInt64(item["user_id"]);
                    usuario.user_email   = item["user_email"].ToString();
                    usuario.user_company = item["user_company"].ToString();
                    usuario.user_name    = item["user_name"].ToString();
                    usuario.user_phone   = item["user_phone"].ToString();
                    usuario.dose         = Convert.ToInt64(item["dose"]);
                    usuario.user_blocked = Convert.ToBoolean(item["user_blocked"]);
                    usuario.currency_id  = Convert.ToInt64(item["currency_id"]);
                    if (item["user_accesslevel"] != DBNull.Value)
                    {
                        usuario.user_accesslevel = Convert.ToInt32(item["user_accesslevel"]);
                    }
                    if (item["user_date_expire"] != DBNull.Value)
                    {
                        usuario.user_date_expire = Convert.ToDateTime(item["user_date_expire"]);
                    }
                    if (item["user_date_register"] != DBNull.Value)
                    {
                        usuario.user_date_register = Convert.ToDateTime(item["user_date_register"]);
                    }
                    if (item["date_answer"] != DBNull.Value)
                    {
                        usuario.date_answer = Convert.ToDateTime(item["date_answer"]);
                    }
                    if (item["last_name"] != DBNull.Value)
                    {
                        usuario.last_name = item["last_name"].ToString();
                    }
                    if (item["treatment"] != DBNull.Value)
                    {
                        usuario.treatment = item["treatment"].ToString();
                    }
                    usuario.user_blocked = Convert.ToBoolean(item["user_blocked"]);
                    exist_countries paises       = new exist_countries();
                    long            user_country = Convert.ToInt64(item["user_country"]);

                    usuario.user_country = user_country;

                    var collection = paises.Consultar(user_country);
                    if (collection.Count > 0)
                    {
                        usuario.countries = collection[0];
                    }

                    if (item["comments"] != DBNull.Value)
                    {
                        usuario.comments = item["comments"].ToString();
                    }
                    if (item["user_admin"] != DBNull.Value)
                    {
                        usuario.user_admin = Convert.ToBoolean(item["user_admin"]);
                    }
                    usuario.user_password = item["user_password"].ToString();

                    if (tabela.Columns.Contains("chbx"))
                    {
                        usuario.chbx = Convert.ToBoolean(item["chbx"]);
                    }
                    usuarios.Add(usuario);
                }
                return(usuarios);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }