Ejemplo n.º 1
0
        /// <summary>
        /// 注册用户
        /// </summary>
        /// <param name="tenantId"></param>
        /// <param name="mobile"></param>
        /// <param name="code"></param>
        /// <param name="codeType"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="inviteUserId"></param>
        /// <param name="message"></param>
        /// <param name="registerType"></param>
        /// <returns></returns>
        public bool Register(int tenantId, string mobile, int code, int codeType, string userName, string password, int inviteUserId, out string message, int registerType = 1)
        {
            ArgumentHelper.AssertPositive(tenantId, "tenantId is 0");
            ArgumentHelper.AssertPositive(inviteUserId, "inviteUserId is 0");
            ArgumentHelper.AssertNotNullOrEmpty(mobile, "mobile is null");
            ArgumentHelper.AssertNotNullOrEmpty(userName, "userName is null");
            ArgumentHelper.AssertNotNullOrEmpty(password, "password is null");

            message = string.Empty;

            var registerUserInfo = new RegisterUserInfo
            {
                TenantId = tenantId,
                //Email = GetVirtualEmail(mobile),
                Name         = userName,
                Password     = password,
                InviteUser   = inviteUserId,
                Mobile       = mobile,
                RegisterType = registerType
            };

            if (Validate(registerUserInfo, code, codeType, out message))
            {
                var userId = ProviderGateway.StaffProvider.CreateStaff(registerUserInfo);
                message = userId > 0 ? "注册成功" : "注册失败";
                return(userId > 0);
            }

            return(false);
        }
        public bool DeleteAppUser(int tenantId, int userId)
        {
            ArgumentHelper.AssertPositive(tenantId, "DeleteAppUser tenantId is not positive");
            ArgumentHelper.AssertPositive(userId, "DeleteAppUser userId is not positive");
            int sqlCount = AppUserAccountDao.DeleteAppUser(tenantId, userId);

            if (sqlCount > 0)
            {
                AppUserAccountDao.DeleteCLoud(tenantId, userId);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
        private string GetDingTalkPCUrl(int tenantId, string appaccount_id, string app_id, string return_url)
        {
            ArgumentHelper.AssertPositive(tenantId, "GetDingTalkPCUrl tenantId is not positive");
            ArgumentHelper.AssertNotNull(appaccount_id, "GetDingTalkPCUrl appaccount_id is null");
            ArgumentHelper.AssertNotNull(app_id, "GetDingTalkPCUrl app_id is null");
            if (string.IsNullOrEmpty(return_url))
            {
                return(null);
            }
            var    encodeRedirectUrl = HttpUtility.UrlEncode(string.Format("{0}?return_url={1}", AppConnectHostConfig.Cache[2], HttpUtility.UrlEncode(return_url)));
            string redirectUrl       = string.Format("{0}/user/authorizeformsg?tenant_id={1}&appaccount_id={2}&app_id={3}&login_type=0&redirect_url={4}", AppConnectHostConfig.Cache[0], tenantId, appaccount_id, app_id, encodeRedirectUrl);

            AppConnectLogHelper.DebugFormat("PC端拼接后详情页RedirectUrl:{0}", redirectUrl);
            return(redirectUrl);
        }
        /// <summary>
        /// 生成ISV验证码,并发送到用户手机
        /// </summary>
        /// <param name="tenantId"></param>
        /// <param name="userId"></param>
        /// <param name="isv"></param>
        /// <param name="mobile"></param>
        /// <param name="type">0:注册验证码</param>
        /// <returns></returns>
        public bool SendISVMessage(int tenantId, string isv, string mobile, out string msg, int type = 0)
        {
            ArgumentHelper.AssertPositive(tenantId, "tenantId is 0");
            ArgumentHelper.AssertNotNullOrEmpty(isv, "isv is null");
            ArgumentHelper.AssertNotNullOrEmpty(mobile, "mobile is null");

            msg = string.Empty;
            if (string.IsNullOrEmpty(isv) || string.IsNullOrWhiteSpace(mobile))
            {
                msg = string.Format("isv或手机号不能为空,isv:{0},mobile:{1}", isv, mobile);
                return(false);
            }
            var check = MobileVerificationDao.Get(mobile, type, DateTime.Now.AddMinutes(-1));

            if (check == 1)
            {
                msg = string.Format("验证码发送过于频繁");
                return(false);
            }
            var isvSMSTemplate = GetISVSMSTemplate(isv, mobile, type);

            if (isvSMSTemplate == null)
            {
                msg = string.Format("{0}未找到设置,mobile:{1},type:{2}", isv, mobile, type);
                return(false);
            }

            var code = GetCode();

            //将验证码和手机号存入数据库
            MobileVerificationDao.Add(mobile, code, type);
            //发送短信
            string message = string.Format(isvSMSTemplate.Message, code);
            var    result  =
                ProviderGateway.SMSProvider.SendISVMobileValCode(tenantId, isv, isvSMSTemplate.SMSChannelId, message, mobile,
                                                                 SMSType.MobileVerification, null);

            if (!result)
            {
                MobileVerificationDao.Abate(mobile, code, type);
                msg = string.Format("发送失败,tenantId:{0},isv:{1},mobile:{2}", tenantId, isv, mobile);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
        private static void SendMessage(int tenantId, AddMessageModel model)
        {
            ArgumentHelper.AssertNotNull(model);
            ArgumentHelper.AssertPositive(tenantId);
            ArgumentHelper.AssertPositive(model.FromUserId);

            string url = string.Format(TitaApiUrl + "/api/v1/{0}/{1}/message", tenantId, model.FromUserId);

            try
            {
                var resultStr = HttpClientHelper.HttpPost(url, model);
                var result    = JsonConvert.DeserializeObject <ApiResult <object> >(resultStr);
                if (result.code != 0)
                {
                    AppConnectLogHelper.ErrorFormat("Tita发送消息接口出错!租户:{0},发送人:{1}", tenantId, model.FromUserId);
                }
            }
            catch (Exception ex)
            {
                AppConnectLogHelper.ErrorFormat("发送消息出错!接口Url:{0},租户:{1},发送人:{2},异常信息:{3}", url, tenantId, model.FromUserId, JsonConvert.SerializeObject(ex));
            }
        }