예제 #1
0
        /// <summary>
        /// 添加运营商
        /// </summary>
        public bool AddMerchant(VMerchant merchant, out string msg)
        {
            msg = string.Empty;

            //检查是否存在注册用户
            if (DACFacade.Movo.UserDAC.SelectByName(merchant.UserName) != null)
            {
                msg = "用户名重复,请重新输入";
                return false;
            }

            //检查是否存在运营商
            if (DACFacade.Movo.TenantDAC.SelectByName(merchant.TenantName) != null)
            {
                msg = "公司名称重复,请重新输入";
                return false;
            }

            //创建运营商tenant
            ETenant tenant = new ETenant();
            tenant.ContactName = merchant.ContactName;
            tenant.ExpireTime = merchant.ExpireTime.Equals(DateTime.MaxValue) ? null : (DateTime?)merchant.ExpireTime;
            tenant.TenantName = merchant.TenantName;
            tenant.TenantCode = DACFacade.Movo.IdentityNoDAC.GetTenantSerialNo();
            tenant.SuperTenantID = merchant.SuperTenantID;
            tenant.Email = merchant.Email;
            tenant.QQ = merchant.QQ;
            tenant.PhoneNumber = merchant.PhoneNumber;
            tenant.LogoUrl = UploadImageHelper.GetImgName(merchant.TenantLogoImgURl);
            tenant.TenantType = EnumTenantType.OperatingMerchant;
            tenant.OperatorLevel = merchant.OperatorLevel;
            tenant.CreateTime = DateTime.Now;
            tenant.IsFreeze = false;
            tenant.RegisterUserName = merchant.UserName;
            tenant.IsEnableAddDevice = merchant.IsEnableAddDevice;

            //创建用户组userGroup
            EUserGroup userGroup = new EUserGroup();
            userGroup.IsAdminGroup = true;
            userGroup.TenantCode = tenant.TenantCode;
            userGroup.UserGroupID = DACFacade.Movo.IdentityNoDAC.GetUserGroupID();
            userGroup.UserGroupName = merchant.UserName;

            //创建注册用户User
            EUser user = new EUser();
            user.PassWord = merchant.Password;
            user.UserCode = DACFacade.Movo.IdentityNoDAC.GetUserSerialNo();
            user.UserName = merchant.UserName;
            user.CreateTime = DateTime.Now;
            user.IsRegisterUser = true;
            user.UserGroupID = userGroup.UserGroupID;
            user.TenantCode = tenant.TenantCode;

            tenant.RegisterUserCode = user.UserCode;

            using (var trans = DACFacade.Movo.TenantDAC.BeginTransaction())
            {
                try
                {
                    int addtenant = DACFacade.Movo.TenantDAC.Insert(trans, tenant);
                    int addusergroup = DACFacade.Movo.UserGroupDAC.Insert(trans, userGroup);
                    int adduser = DACFacade.Movo.UserDAC.Insert(trans, user);
                    if (addtenant >= 1 && addusergroup >= 1 && adduser >= 1)
                    {
                        trans.Commit();
                        return true;
                    }
                    else
                    {
                        trans.Rollback();
                        msg = "添加运营商数据异常(addtenant:" + addtenant.ToString() + "addusergroup:" + addusergroup.ToString() + "adduser:"******")";
                        Logger.Error(msg);
                        return false;
                    }
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                    trans.Rollback();
                    Logger.Error(ex.Message, ex);
                }
            }

            return false;
        }
예제 #2
0
        /// <summary>
        /// 修改运营商
        /// </summary>
        /// <returns></returns>
        public JsonResult ModifyMerchant(string UserName, string Password, string ExpireTime, string ContactName, string TenantName, string PhoneNumber, string QQ, string Email, string TenantCode, string UserCode, string TenantLogoImgURl, bool IsEnableAddDevice)
        {
            JsonResult json = new JsonResult();
            VMerchant operatingMerchant = new VMerchant();
            operatingMerchant.UserName = UserName;
            operatingMerchant.ExpireTime = Convert.ToDateTime(ExpireTime);
            operatingMerchant.ContactName = ContactName;
            operatingMerchant.TenantName = TenantName;
            operatingMerchant.PhoneNumber = PhoneNumber;
            operatingMerchant.QQ = QQ;
            operatingMerchant.Email = Email;
            operatingMerchant.TenantCode = TenantCode;
            operatingMerchant.UserCode = UserCode;
            operatingMerchant.SuperTenantID = Passport.TenantCode;
            operatingMerchant.TenantLogoImgURl = TenantLogoImgURl;
            operatingMerchant.IsEnableAddDevice = IsEnableAddDevice;
            string msg = string.Empty;
            bool isSuccess = ModelFacade.Platform.TenantModel.ModifyMerchant(operatingMerchant, out msg);

            if (isSuccess)
            {
                json.Data = new
                {
                    res = true
                };
            }
            else
            {
                json.Data = new
                {
                    res = false,
                    message = msg
                };
            }
            return json;
        }
예제 #3
0
        /// <summary>
        /// 更新运营商
        /// </summary>
        public bool ModifyMerchant(VMerchant merchant, out string msg)
        {
            msg = string.Empty;

            //检查是否存在重复运营商
            ETenant tenant = DACFacade.Movo.TenantDAC.SelectByName(merchant.TenantName);
            if (tenant != null && tenant.TenantCode != merchant.TenantCode)
            {
                msg = "公司名称重复,请重新输入";
                return false;
            }

            //修改运营商tenant
            tenant = DACFacade.Movo.TenantDAC.Select(merchant.TenantCode);
            tenant.ContactName = merchant.ContactName;
            tenant.ExpireTime = merchant.ExpireTime.Equals(DateTime.MaxValue) ? null : (DateTime?)merchant.ExpireTime;
            tenant.TenantName = merchant.TenantName;
            tenant.Email = merchant.Email;
            tenant.QQ = merchant.QQ;
            tenant.PhoneNumber = merchant.PhoneNumber;
            tenant.LogoUrl = UploadImageHelper.GetImgName(merchant.TenantLogoImgURl);
            tenant.IsEnableAddDevice = merchant.IsEnableAddDevice;
            //修改注册用户User
            EUser user = DACFacade.Movo.UserDAC.Select(merchant.UserCode);
            user.UserName = merchant.UserName;

            //开始事务
            using (var trans = DACFacade.Movo.TenantDAC.BeginTransaction())
            {
                try
                {
                    int updatetenant = DACFacade.Movo.TenantDAC.Update(trans, tenant);
                    int updateuser = DACFacade.Movo.UserDAC.Update(trans, user);
                    if (updatetenant >= 1 && updateuser >= 1)
                    {
                        trans.Commit();
                        return true;
                    }
                    else
                    {
                        trans.Rollback();
                        msg = "更新运营商数据异常(updatetenant:" + updatetenant.ToString() + "adduser:"******")";
                        Logger.Error(msg);
                        return false;
                    }
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                    Logger.Error(ex.Message, ex);
                    trans.Rollback();
                }
            }

            return false;
        }
예제 #4
0
        /// <summary>
        /// 增加运营商
        /// </summary>
        /// <returns></returns>
        public JsonResult AddMerchant(string UserName, string Password, string ExpireTime, string ContactName, string TenantName, string PhoneNumber, string QQ, string Email, string TenantLogoImgURl, bool IsEnableAddDevice)
        {
            JsonResult json = new JsonResult();

            VMerchant operatingMerchant = new VMerchant();
            operatingMerchant.UserName = UserName;
            operatingMerchant.Password = MD5Core.Encrypt(Password);
            operatingMerchant.ExpireTime = Convert.ToDateTime(ExpireTime);
            operatingMerchant.ContactName = ContactName;
            operatingMerchant.TenantName = TenantName;
            operatingMerchant.PhoneNumber = PhoneNumber;
            operatingMerchant.QQ = QQ;
            operatingMerchant.Email = Email;
            operatingMerchant.SuperTenantID = Passport.TenantCode;
            operatingMerchant.OperatorLevel = Passport.OperatorLevel + 1;
            operatingMerchant.TenantLogoImgURl = TenantLogoImgURl;
            operatingMerchant.IsEnableAddDevice = IsEnableAddDevice;

            if (string.IsNullOrEmpty(operatingMerchant.TenantLogoImgURl) || operatingMerchant.TenantLogoImgURl == UploadImageHelper.TenantImgUrl)
            {
                operatingMerchant.TenantLogoImgURl = UploadImageHelper.TenantImgUrl;
            }
            else
            {
                operatingMerchant.TenantLogoImgURl = BaseController.UploadImgPath + @"/" + operatingMerchant.TenantLogoImgURl;
            }

            string msg = string.Empty;
            bool isSuccess = ModelFacade.Platform.TenantModel.AddMerchant(operatingMerchant, out msg);

            if (isSuccess)
            {
                json.Data = new
                {
                    res = true
                };
            }
            else
            {
                json.Data = new
                {
                    res = false,
                    message = msg
                };
            }
            return json;
        }