Example #1
0
        public async Task <IActionResult> ResetPassword(string userId)
        {
            CommonResult result = new CommonResult();

            try
            {
                string where = string.Format("UserId='{0}'", userId);
                UserLogOn userLogOn = userLogOnService.GetWhere(where);
                Random    random    = new Random();
                string    strRandom = random.Next(100000, 999999).ToString(); //生成编号
                userLogOn.UserSecretkey      = MD5Util.GetMD5_16(GuidUtils.NewGuidFormatN()).ToLower();
                userLogOn.UserPassword       = MD5Util.GetMD5_32(DEncrypt.Encrypt(MD5Util.GetMD5_32(strRandom).ToLower(), userLogOn.UserSecretkey).ToLower()).ToLower();
                userLogOn.ChangePasswordDate = DateTime.Now;
                bool bl = await userLogOnService.UpdateAsync(userLogOn, userLogOn.Id);

                if (bl)
                {
                    result.ErrCode = ErrCode.successCode;
                    result.ErrMsg  = strRandom;
                    result.Success = true;
                }
                else
                {
                    result.ErrMsg  = ErrCode.err43002;
                    result.ErrCode = "43002";
                }
            }catch (Exception ex)
            {
                Log4NetHelper.Error("重置密码异常", ex);//错误记录
                result.ErrMsg = ex.Message;
            }
            return(ToJsonContent(result));
        }
Example #2
0
        /// <summary>
        /// 微信注册普通会员用户
        /// </summary>
        /// <param name="userInPut">第三方类型</param>
        /// <returns></returns>
        public bool CreateUserByWxOpenId(UserInputDto userInPut)
        {
            User        user            = userInPut.MapTo <User>();
            UserLogOn   userLogOnEntity = new UserLogOn();
            UserOpenIds userOpenIds     = new UserOpenIds();

            user.Id              = user.CreatorUserId = GuidUtils.CreateNo();
            user.Account         = "Wx" + GuidUtils.CreateNo();
            user.CreatorTime     = userLogOnEntity.FirstVisitTime = DateTime.Now;
            user.IsAdministrator = false;
            user.EnabledMark     = true;
            user.Description     = "第三方注册";
            user.IsMember        = true;
            user.UnionId         = userInPut.UnionId;
            user.ReferralUserId  = userInPut.ReferralUserId;
            if (userInPut.NickName == "游客")
            {
                user.RoleId = _roleService.GetRole("guest").Id;
            }
            else
            {
                user.RoleId = _roleService.GetRole("usermember").Id;
            }

            userLogOnEntity.UserId = user.Id;

            userLogOnEntity.UserPassword = GuidUtils.NewGuidFormatN() + new Random().Next(100000, 999999).ToString();
            userLogOnEntity.Language     = userInPut.language;

            userOpenIds.OpenId     = userInPut.OpenId;
            userOpenIds.OpenIdType = userInPut.OpenIdType;
            userOpenIds.UserId     = user.Id;
            return(_userRepository.Insert(user, userLogOnEntity, userOpenIds));
        }
Example #3
0
        public async Task <IActionResult> ModifyPassword(string oldpassword, string password, string password2)
        {
            CommonResult result = new CommonResult();

            try
            {
                if (string.IsNullOrEmpty(oldpassword))
                {
                    result.ErrMsg = "原密码不能为空!";
                }
                else if (string.IsNullOrEmpty(password))
                {
                    result.ErrMsg = "密码不能为空!";
                }
                else if (string.IsNullOrEmpty(password2))
                {
                    result.ErrMsg = "重复输入密码不能为空!";
                }
                else if (password == password2)
                {
                    var    userSinginEntity = userLogOnService.GetByUserId(CurrentUser.UserId);
                    string inputPassword    = MD5Util.GetMD5_32(DEncrypt.Encrypt(MD5Util.GetMD5_32(oldpassword).ToLower(), userSinginEntity.UserSecretkey).ToLower()).ToLower();
                    if (inputPassword != userSinginEntity.UserPassword)
                    {
                        result.ErrMsg = "原密码错误!";
                    }
                    else
                    {
                        string where = string.Format("UserId='{0}'", CurrentUser.UserId);
                        UserLogOn userLogOn = userLogOnService.GetWhere(where);

                        userLogOn.UserSecretkey      = MD5Util.GetMD5_16(GuidUtils.NewGuidFormatN()).ToLower();
                        userLogOn.UserPassword       = MD5Util.GetMD5_32(DEncrypt.Encrypt(MD5Util.GetMD5_32(password).ToLower(), userLogOn.UserSecretkey).ToLower()).ToLower();
                        userLogOn.ChangePasswordDate = DateTime.Now;
                        bool bl = await userLogOnService.UpdateAsync(userLogOn, userLogOn.Id);

                        if (bl)
                        {
                            result.ErrCode = ErrCode.successCode;
                        }
                        else
                        {
                            result.ErrMsg  = ErrCode.err43002;
                            result.ErrCode = "43002";
                        }
                    }
                }
                else
                {
                    result.ErrMsg = "两次输入的密码不一样";
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("重置密码异常", ex);//错误记录
                result.ErrMsg = ex.Message;
            }
            return(ToJsonContent(result));
        }
Example #4
0
 /// <summary>
 /// 注册用户
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="userLogOnEntity"></param>
 /// <param name="trans"></param>
 public bool Insert(User entity, UserLogOn userLogOnEntity, IDbTransaction trans = null)
 {
     userLogOnEntity.Id            = GuidUtils.CreateNo();
     userLogOnEntity.UserId        = entity.Id;
     userLogOnEntity.UserSecretkey = MD5Util.GetMD5_16(GuidUtils.NewGuidFormatN()).ToLower();
     userLogOnEntity.UserPassword  = MD5Util.GetMD5_32(DEncrypt.Encrypt(MD5Util.GetMD5_32(userLogOnEntity.UserPassword).ToLower(), userLogOnEntity.UserSecretkey).ToLower()).ToLower();
     DbContext.GetDbSet <User>().Add(entity);
     DbContext.GetDbSet <UserLogOn>().Add(userLogOnEntity);
     return(DbContext.SaveChanges() > 0);
 }
Example #5
0
 /// <summary>
 /// 注册租户
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="tenantLogOnEntity"></param>
 public async Task <bool> InsertAsync(Tenant entity, TenantLogon tenantLogOnEntity)
 {
     tenantLogOnEntity.Id              = GuidUtils.CreateNo();
     tenantLogOnEntity.TenantId        = entity.Id;
     tenantLogOnEntity.TenantSecretkey = MD5Util.GetMD5_16(GuidUtils.NewGuidFormatN()).ToLower();
     tenantLogOnEntity.TenantPassword  = MD5Util.GetMD5_32(DEncrypt.Encrypt(MD5Util.GetMD5_32(tenantLogOnEntity.TenantPassword).ToLower(), tenantLogOnEntity.TenantSecretkey).ToLower()).ToLower();
     DbContext.GetDbSet <Tenant>().Add(entity);
     DbContext.GetDbSet <TenantLogon>().Add(tenantLogOnEntity);
     return(await DbContext.SaveChangesAsync() > 0);
 }
Example #6
0
 /// <summary>
 /// 新增前处理数据
 /// </summary>
 /// <param name="info"></param>
 protected override void OnBeforeInsert(APP info)
 {
     info.Id        = GuidUtils.CreateNo();
     info.AppSecret = MD5Util.GetMD5_32(GuidUtils.NewGuidFormatN()).ToUpper();
     if (info.IsOpenAEKey)
     {
         info.EncodingAESKey = MD5Util.GetMD5_32(GuidUtils.NewGuidFormatN()).ToUpper();
     }
     info.CreatorTime   = DateTime.Now;
     info.CreatorUserId = CurrentUser.UserId;
     info.CompanyId     = CurrentUser.OrganizeId;
     info.DeptId        = CurrentUser.DeptId;
     info.DeleteMark    = false;
 }
Example #7
0
        public async Task <IActionResult> ResetEncodingAESKey(string id)
        {
            CommonResult result = new CommonResult();
            APP          aPP    = iService.Get(id);

            aPP.EncodingAESKey = MD5Util.GetMD5_32(GuidUtils.NewGuidFormatN()).ToUpper();
            bool bl = await iService.UpdateAsync(aPP, id);

            if (bl)
            {
                result.ErrCode = ErrCode.successCode;
                result.ErrMsg  = aPP.EncodingAESKey;
                result.Success = true;
            }
            else
            {
                result.ErrMsg  = ErrCode.err43002;
                result.ErrCode = "43002";
            }
            return(ToJsonContent(result));
        }
Example #8
0
        /// <summary>
        /// 获取最新业务单据编码
        /// </summary>
        /// <param name="sequenceName">业务单据编码名称</param>
        /// <returns></returns>
        public async Task <CommonResult> GetSequenceNextTask(string sequenceName)
        {
            CommonResult result = new CommonResult();
            //生成编号
            string sequenceNewNo = "";

            #region 获取序号生成器属性
            if (string.IsNullOrWhiteSpace(sequenceName))
            {
                result.ErrMsg = "参数错误:业务编码编号";
                return(result);
            }
            //获取序号生成器属性
            Sequence sequence = _repository.GetWhere("SequenceName='" + sequenceName + "'");
            if (sequence != null)
            {
                IEnumerable <SequenceRule> list = _repositoryRule.GetListWhere("SequenceName='" + sequenceName + "' order by RuleOrder asc");
                if (list.Any())
                {
                    int delimiterNum = 0;
                    foreach (SequenceRule item in list)
                    {
                        delimiterNum++;

                        switch (item.RuleType)
                        {
                        case "const":    //常量方式
                            sequenceNewNo += item.RuleValue;
                            break;

                        case "shortdate":    //短日期 年2位月2位日期2位
                            sequenceNewNo += DateTime.Now.ToString("yyyyMMdd").Substring(2);
                            break;

                        case "date":    //日期,年4位
                            sequenceNewNo += DateTime.Now.ToString("yyyyMMdd");
                            break;

                        case "ydate":    //年月,年4位月2位
                            sequenceNewNo += DateTime.Now.ToString("yyyyMMdd").Substring(0, 6);
                            break;

                        case "timestamp":    //日期时间精确到毫秒
                            sequenceNewNo += DateTime.Now.ToString("yyyyMMddHHmmssffff");
                            break;

                        case "number":    //计数,流水号
                            int num = CurrentReset(sequence, item);
                            //计数拼接
                            sequenceNewNo += NumberingSeqRule(item, num).ToString();
                            //更新当前序号
                            sequence.CurrentNo = num;
                            break;

                        case "guid":    //Guid
                            sequenceNewNo += GuidUtils.NewGuidFormatN();
                            break;

                        case "random":    //随机数
                            Random random    = new Random();
                            string strMax    = "9".ToString().PadLeft(item.RuleValue.Length - 1, '9');
                            string strRandom = random.Next(item.RuleValue.ToInt(), strMax.ToInt()).ToString();     //生成随机编号
                            sequenceNewNo += strRandom;
                            break;
                        }
                        if (!string.IsNullOrEmpty(sequence.SequenceDelimiter) && delimiterNum != list.Count())
                        {
                            sequenceNewNo += sequence.SequenceDelimiter;
                        }
                    }
                    //当前编号
                    sequence.CurrentCode  = sequenceNewNo;
                    sequence.CurrentReset = DateTime.Now.ToString("yyyyMMdd");
                    await _repository.UpdateAsync(sequence, sequence.Id);

                    result.ResData = sequenceNewNo;
                    result.Success = true;
                }
                else
                {
                    result.Success = false;
                    result.ErrMsg  = "未查询到业务编码对应的编码规则配置, 请检查编码规则配置";
                    return(result);
                }
            }
            else
            {
                result.Success = false;
                result.ErrMsg  = "请定义" + sequenceName + "的单据编码!";
                return(result);
            }
            #endregion
            return(result);
        }
        public IActionResult YuebonConnecSys(string systype)
        {
            CommonResult result = new CommonResult();

            try
            {
                if (!string.IsNullOrEmpty(systype))
                {
                    SystemType        systemType        = iService.GetByCode(systype);
                    string            openmf            = MD5Util.GetMD5_32(DEncrypt.Encrypt(CurrentUser.UserId + systemType.Id, GuidUtils.NewGuidFormatN())).ToLower();
                    YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
                    TimeSpan          expiresSliding    = DateTime.Now.AddSeconds(20) - DateTime.Now;
                    yuebonCacheHelper.Add("openmf" + openmf, CurrentUser.UserId, expiresSliding, false);
                    result.ErrCode = ErrCode.successCode;
                    result.ResData = systemType.Url + "?openmf=" + openmf;
                }
                else
                {
                    result.ErrCode = ErrCode.failCode;
                    result.ErrMsg  = "切换子系统参数错误";
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("切换子系统异常", ex);
                result.ErrMsg  = ErrCode.err40110;
                result.ErrCode = "40110";
            }
            return(ToJsonContent(result));
        }