Exemple #1
0
        public int Update(ASSETKKF_MODEL.Data.Mssql.Asset.STUSERASSET d, string EditUser = "", SqlTransaction transac = null, string conStr = null)
        {
            DynamicParameters param = new DynamicParameters();
            //param.Add("@UserCode", d.UserCode);

            string cmd = "";
            var    res = ExecuteNonQuery(transac, cmd, param, conStr);

            return(res);
        }
Exemple #2
0
        public List <ASSETKKF_MODEL.Data.Mssql.Asset.STUSERASSET> CheckApprover(ASSETKKF_MODEL.Data.Mssql.Asset.STUSERASSET d, string conStr = null)
        {
            DynamicParameters param = new DynamicParameters();

            param.Add("@USERCODE", d.UCODE);

            string cmd = "SELECT * FROM [dbo].[FT_UserAsset] (" + QuoteStr(d.UCODE) + ")" +
                         $" where A_Approv = 'Y'";

            var res = Query <ASSETKKF_MODEL.Data.Mssql.Asset.STUSERASSET>(cmd, param, conStr).ToList();

            return(res);
        }
Exemple #3
0
        public List <ASSETKKF_MODEL.Data.Mssql.Asset.STUSERASSET> Search(ASSETKKF_MODEL.Data.Mssql.Asset.STUSERASSET d, SqlTransaction transac = null, string conStr = null)
        {
            DynamicParameters param = new DynamicParameters();

            param.Add("@USERCODE", d.UCODE);
            param.Add("@UserName", d.OFFICECODE);

            string cmd = "SELECT * FROM [dbo].[FT_UserAsset] (" + QuoteStr(d.UCODE) + ") where 1 = 1";

            if (!String.IsNullOrEmpty(d.COMPANY))
            {
                cmd += " and COMPANY = " + QuoteStr(d.COMPANY);
            }

            var res = Query <ASSETKKF_MODEL.Data.Mssql.Asset.STUSERASSET>(cmd, param, conStr).ToList();

            return(res);
        }
Exemple #4
0
        protected override void ExecuteChild(OauthLoginReq dataReq, ResponseAPI dataRes)
        {
            DBMode = dataReq.DBMode;

            var res = new OauthLoginRes();

            res._result.ServerAddr = ConnectionString();
            res._result.DBMode     = DBMode;

            var userApprove = new ASSETKKF_MODEL.Data.Mssql.Asset.STUSERASSET();

            userApprove.UCODE = dataReq.usercode;



            try
            {
                var roles = ASSETKKF_ADO.Mssql.Asset.STUSERASSETAdo.GetInstant().CheckApprover(userApprove, conString);

                if (roles.Count <= 0)
                {
                    res                  = new OauthLoginRes();
                    res.usercode         = dataReq.usercode;
                    res._result._status  = "F";
                    res._result._code    = "F0002";
                    res._result._message = "ไม่มีสิทธิ์ การอนุมัติ";
                }
                else
                {
                    var user = ASSETKKF_ADO.Mssql.Asset.STUSERASSETAdo.GetInstant().Search(new ASSETKKF_MODEL.Data.Mssql.Asset.STUSERASSET()
                    {
                        UCODE = dataReq.usercode.Trim()
                    }, null, conString).FirstOrDefault();
                    if (user == null)
                    {
                        throw new Exception("Username Not Found.");
                    }
                    if (user.STAEMP == "9")
                    {
                        throw new Exception("พ้นสภาพพนักงาน ไม่มีสิทธิ์เข้าใช้โปรแกรม.");
                    }
                    if (user.A_Review == "N")
                    {
                        throw new Exception("ถูกยกเลิกสิทธิ์เข้าใช้โปรแกรม.");
                    }

                    //var pass = Core.Util.EncryptUtil.Hash(dataReq.password.Trim());
                    var pass = Core.Util.EncryptUtil.ENDCodeNEW(dataReq.password.Trim());


                    if (user.PCODE == pass)
                    {
                        var _token = Core.Util.EncryptUtil.Hash(pass);
                        res.token    = _token.NewID();
                        res.username = user.OFFICECODE;
                        res.usercode = user.UCODE;

                        res._result._status  = "S";
                        res._result._code    = "S0000";
                        res._result._message = "username และ password ถูกต้อง";


                        StaticValue.GetInstant().TokenKey();
                    }
                    else
                    {
                        res                  = new OauthLoginRes();
                        res.usercode         = dataReq.usercode;
                        res._result._status  = "F";
                        res._result._code    = "F0002";
                        res._result._message = "username และ password ไม่ถูกต้อง";
                    }
                }
            }
            catch
            {
                res.usercode         = dataReq.usercode;
                res._result._status  = "F";
                res._result._code    = "F0002";
                res._result._message = "การเชื่อมต่อฐานข้อมูลมีปัญหา...";
            }

            dataRes.data = res;
        }