Exemple #1
0
        public User GetUserList(string UserName = "", string PassWord = "")
        {
            User model = new User();

            if (UserName == "007" && PassWord == "007")
            {
                return(model = new User
                {
                    LUserId = 1,
                    UserName = "******",
                    UserPass = "******",
                    CatId = 0,
                    DisplayName = "Admin",
                    DesigName = "Administrator",
                    IsInactive = true,
                    IsMaster = true,
                    RefId = 1
                });
            }
            else
            {
                model = null;
                CoreSQLConnection CoreSQL = new CoreSQLConnection();
                //var url = "http://203.80.189.18:5190/acl.sales/LoginUser/GetUserList";
                //var url = "http://202.51.188.186:5190/acl.sales/LoginUser/GetUserList";
                //string json = new WebClient().DownloadString(url);

                var listdata = JsonConvert.DeserializeObject <List <User> >(GetJsonUserList()).
                               Where(x => x.UserName.ToLower() == UserName.ToLower() &&
                                     CoreSQL.GetDecryptedData(x.UserPass) == PassWord)
                               .FirstOrDefault <User>();

                if (listdata == null)
                {
                    return(model = null);
                }
                else
                {
                    model             = listdata;
                    model.OldPassword = CoreSQL.GetDecryptedData(model.UserPass);
                }
            }
            return(model);
        }
        public User LoginUser(string UserName, string UserPassword)
        {
            DataSet           dsList  = new DataSet();
            CoreSQLConnection CoreSQL = new CoreSQLConnection();
            User model = new User();

            try
            {
                if (UserName != null && UserPassword != null)
                {
                    if (UserName.Trim() != "" && UserPassword.Trim() != "")
                    {
                        String strQuery = "Exec prcGetValidateLogin '" + UserName.ToLower() + "'";
                        dsList = CoreSQL.CoreSQL_GetDataSet(strQuery);
                        dsList.Tables[0].TableName = "Login";
                        foreach (DataRow row in dsList.Tables[0].Rows)
                        {
                            if (CoreSQL.GetDecryptedData(row[2].ToString()) == UserPassword)
                            {
                                model.prcSetData(row);
                                model.UserPassword = CoreSQL.GetDecryptedData(model.UserPassword);
                                return(model);
                            }
                        }
                    }
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
            }
        }