예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Expires = -1;
            width            = URLHelper.GetRequestQuery <int>("w", width, Convert.ToInt32);
            height           = URLHelper.GetRequestQuery("h", height, Convert.ToInt32);
            //string checkCode = CreateRandomCode(4);
            string checkCode = RandomCode.GetRandomCode(StringPlus.NumberConst, 4);

            Session["CheckCode"] = checkCode;             //checkCode;
            RandomCode.ResopnseColorImage(Context, width, height, checkCode);
            //CreateImage(checkCode);
        }
예제 #2
0
        public string Add(OperateUserMasterModel addModel)
        {
            if (!ModelState.IsValid)
            {
                return(JSONHelper.ToJsonSuggest(ResSuggest.OperateFail + ResMessage.WrongFormat));
            }

            if (_userMasterService.GetCachedModel(addModel.UserID) != null)
            {
                return(JSONHelper.ToJsonSuggest(ResUserMaster.UserIDExist));
            }

            var userMasterModel = new UserMaster();
            var roleUserModel   = new RoleUser();
            var host            = "crm3.chowtaifook.sz";

            if (addModel.UserIDTemplate != "0" && addModel.UserIDTemplate != "")
            {
                var templateRoleUserModel = _roleUserService.GetCachedModel(t => t.UserID == addModel.UserIDTemplate);
                host = _userSiteService.GetUserSite(addModel.UserIDTemplate);   //获取服务器域名

                if (templateRoleUserModel == null)
                {
                    return(JSONHelper.ToJsonSuggest(ResUserMaster.EquelPrivilegeUserID + ResMessage.NotExist));
                }
                else
                {
                    roleUserModel.RoleID = templateRoleUserModel.RoleID;
                }
            }
            else if (string.IsNullOrEmpty(addModel.RoleID))
            {
                roleUserModel.RoleID    = short.Parse(addModel.RoleID);
                addModel.UserIDTemplate = _roleUserService.GetCachedModel(t => t.RoleID == short.Parse(addModel.RoleID)).UserID;
                host = _userSiteService.GetUserSite(addModel.UserIDTemplate);
            }
            else
            {
                return(JSONHelper.ToJsonSuggest(ResUserMaster.PlearsEnterEquelPrivilegeUserIDOrRoleID));
            }

            var randomCode = new RandomCode();

            addModel.Password = randomCode.GetRandomCode("1,2,3,4,5,6,7,8,9", 4) + randomCode.GetRandomCode("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z", 4);

            userMasterModel = Mapper.Map <OperateUserMasterModel, UserMaster>(addModel);
            //userMasterModel.PasswordExprityDate = DateAndTime.DateAdd("d", 90, DateTime.Now.ToShortDateString());

            userMasterModel.PasswordExprityDate = DateTime.Now.AddDays(90);

            roleUserModel.UserID = addModel.UserID;

            var context       = ResUserMaster.LoginAddress + "http://" + host + "/Login.aspx " + ResUserMaster.UserID + ":" + userMasterModel.UserID + " " + ResUserMaster.Password + ":" + addModel.Password;
            var bllUserMaster = new UserMasterService();

            if (bllUserMaster.AddUserTemplate(userMasterModel, roleUserModel, addModel.UserIDTemplate, "ctfsystem", addModel.EmailAdd, ResUserMaster.COUPriviligeOpen, context, "HTML"))
            {
                return(JSONHelper.ToJsonSuggest(ResSuggest.AddSuccess));
            }
            else
            {
                return(JSONHelper.ToJsonSuggest(ResSuggest.AddFail));
            }
        }