Пример #1
0
        private string BuildToken(MasUserModel masUser)
        {
            List <Claim> claims = new List <Claim>
            {
                new Claim("name", masUser.USER_NM),
                new Claim("nameidentifier", masUser.USER_ID.ToString()),
                new Claim("identityprovider", "AtmanEuler"),
                new Claim("fullname", masUser.USER_NM),
                new Claim("companyid", masUser.COMPANY_ID.ToString()),
            };

            var extra = new ClaimsIdentity();

            extra.AddClaim(new Claim(ClaimTypes.Name, masUser.USER_NM));
            extra.AddClaims(claims);

            //var claims = new[] { new Claim(ClaimTypes.Name, masUser.USER_NM) }

            var key   = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"]));
            var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);

            var token = new JwtSecurityToken(
                _config["Jwt:Issuer"],
                _config["Jwt:Issuer"],
                extra.Claims,
                expires: DateTime.Now.AddHours(10),
                signingCredentials: creds);

            return(new JwtSecurityTokenHandler().WriteToken(token));
        }
Пример #2
0
        public async Task <int> InsertMasUser(MasUserModel pMasUser = null)
        {
            int iResult = -1;

            try
            {
                iResult = await ProcessSql("INSERT", pMasUser);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(iResult);
        }
Пример #3
0
 public async Task <int> ResetMasUser(MasUserModel pMasUser = null)
 {
     return(await ProcessSql("RESET", pMasUser));
 }
Пример #4
0
 public async Task <int> DeleteMasUser(MasUserModel pMasUser = null)
 {
     return(await ProcessSql("DELETE", pMasUser));
 }
Пример #5
0
 public async Task <int> UpdateMasUser(MasUserModel pMasUser = null)
 {
     return(await ProcessSql("UPDATE", pMasUser));
 }
Пример #6
0
 public async Task <int> ProcessSql(string status = null, MasUserModel pMasUser = null)
 {
     return(await Task.Run(() => MasUserManager.Instance.ProcessSql(status, pMasUser)));
 }
Пример #7
0
        public int ProcessSql(string status = null, MasUserModel pMasUser = null)
        {
            int iResult = -1;
            var conn    = openConnection();

            try
            {
                DynamicParameters param = new DynamicParameters();
                param.Add("p_status", status);
                if (pMasUser != null)
                {
                    param.Add("P_COMPANY_ID", pMasUser.COMPANY_ID);
                    //param.Add("P_USER_CD", pMasUser.USER_CD);
                    param.Add("P_USER_ID", pMasUser.USER_ID);
                    param.Add("P_USER_NM", pMasUser.USER_NM);
                    //param.Add("P_FULLNAME", pMasUser.FULL_NAME);
                    param.Add("P_PASSWORD", pMasUser.PASSWORD);
                    // param.Add("P_PASSWORD_SALT", pMasUser.PASSWORD_SALT);
                    param.Add("P_FULL_NAME", pMasUser.FULL_NAME);
                    param.Add("P_EMAIL", pMasUser.EMAIL);                 // CHANGED USER_EMAIL TO EMAIL
                    param.Add("P_USER_MAIN_SCR", pMasUser.USER_MAIN_SCR);
                    param.Add("P_USER_LANGUAGE", pMasUser.USER_LANGUAGE); // CHANGED FROM PROFILE_IMAGE

                    param.Add("P_AVATAR", pMasUser.AVATAR);               // CHANGED FROM PROFILE_IMAGE
                    param.Add("P_ORG_ID", pMasUser.ORG_ID);
                    param.Add("P_POSITION_GEN_CD", pMasUser.POSITION_GEN_CD);


                    param.Add("P_SUPER_YN", pMasUser.SUPER_YN);
                    param.Add("P_TEMP_PASS_CHANGE_YN", pMasUser.TEMP_PASS_CHANGE_YN);


                    //param.Add("P_SETTING_YMD", pMasUser.SETTING_YMD);
                    //param.Add("P_USE_SYS", pMasUser.USE_SYS);

                    param.Add("P_USE_YN", pMasUser.USE_YN);
                    param.Add("P_REMARK", pMasUser.REMARK);

                    if (pMasUser.CREATED_TIME == DateTime.MinValue || pMasUser.CHANGED_TIME == DateTime.MinValue)
                    {
                        pMasUser.CREATED_TIME = DateTime.Now;
                        pMasUser.CHANGED_TIME = DateTime.Now;
                    }

                    param.Add("P_CREATOR", pMasUser.CREATOR);
                    param.Add("P_CREATED_TIME", pMasUser.CREATED_TIME);

                    param.Add("P_CHANGER", pMasUser.CHANGER);
                    param.Add("P_CHANGED_TIME", pMasUser.CHANGED_TIME);

                    /*param.Add("P_BIZ_UNIT_UID", pMasUser.BIZ_UNIT_UID);
                     *                  param.Add("P_BIZPLACE_CD", pMasUser.BIZPLACE_CD);
                     *                  param.Add("P_HR_CD", pMasUser.HR_CD);*/

                    param.Add("P_DEL_YN", pMasUser.DEL_YN);
                }

                param.Add("@p_outValue", dbType: DbType.Int64, direction: ParameterDirection.Output);

                conn.Open();
                iResult = conn.Execute("sp_zm_mas_user", param, null, null, commandType: CommandType.StoredProcedure);

                if (status == "INSERT")
                {
                    Int64 outValue = param.Get <Int64>("@p_outValue");
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return(iResult);
        }