protected override bool ValidateRoleDate(RoleCollection roles, MessageDisplay msgdisp)
        {
            bool returnValue = true;
            for (int i = 0; i < roles.Count; i++)
            {
                if (string.IsNullOrEmpty(roles[i].Title) || roles[i].Title.Trim() == string.Empty)
                {
                    msgdisp.AddError("title", i, Lang_Error.Role_EmptyTitleError);
                    returnValue = false;
                }

                for (int j = i + 1; j < roles.Count; j++)
                {
                    if (i!=j)
                    {
                        if (roles[i].RequiredPoint == roles[j].RequiredPoint)
                        {
                            msgdisp.AddError("RequiredPoint", i, string.Format(Lang_Error.Role_DuplicatePointError,i+1,j+1));
                            msgdisp.AddError("RequiredPoint", j, string.Format(Lang_Error.Role_DuplicatePointError, j+1,i+1));
                            returnValue = false;
                        }
                    }
                }
            }

            return returnValue;
        }
Esempio n. 2
0
        protected void CreatePassportClient()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("clientname", "url", "apifilepath");

            string clientname  = _Request.Get("clientname", Method.Post);
            string url         = _Request.Get("url", Method.Post);
            string apifilepath = _Request.Get("apifilepath", Method.Post);
            string accesskey   = _Request.Get("accesskey", Method.Post);

            InstructType[] structs = _Request.GetList <InstructType>("instructs", Method.Post, new InstructType[0]);

            using (ErrorScope es = new ErrorScope())
            {
                PassportClient client = PassportBO.Instance.CreatePassportClient(clientname, url, apifilepath, accesskey, structs);

                if (client != null)
                {
                    Return(true);
                    //ShowSuccess("创建客户端成功!");
                }
                else
                {
                    es.CatchError(delegate(ErrorInfo error) {
                        msgDisplay.AddError(error);
                    });
                }
            }
        }
Esempio n. 3
0
        protected void CreateDirectory()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();
            int            newDirId;
            int            dirId      = _Request.Get <int>("directoryid", Method.Get, 0);
            DiskDirectory  currentDir = DiskBO.Instance.GetDiskDirectory(MyUserID, dirId);

            string dirName = _Request.Get("directoryname", Method.Post);

            //if(new InvalidFileNameRegex().IsMatch(HttpUtility.HtmlDecode(dirName)))
            //{
            //    msgDisplay.AddError("目录名称能包含以下字符:"+HttpUtility.HtmlEncode(" \" | / \\ < > * ? "));
            //    return;
            //}

            using (ErrorScope es = new ErrorScope())
            {
                bool success = DiskBO.Instance.CreateDiskDirectory(MyUserID, dirId, dirName, out newDirId);

                if (success)
                {
                    Return(newDirId);
                }

                else
                {
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error) {
                        msgDisplay.AddError(error);
                    });
                }
            }
        }
Esempio n. 4
0
        private void Delete()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();

            bool success = false;

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    success = FriendBO.Instance.DeleteFriends(MyUserID, m_FriendUserIds);
                }
                catch (Exception ex)
                {
                    msgDisplay.AddException(ex);
                }

                if (success == false)
                {
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
            }

            if (success)
            {
                Return("targetUserIds", m_FriendUserIds);
            }
        }
Esempio n. 5
0
        private void Delete()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();

            CommentType type = _Request.Get <CommentType>("type", Method.Get, CommentType.All);

            bool success = false;

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    success = CommentBO.Instance.RemoveComment(MyUserID, commentID.Value);
                }
                catch (Exception ex)
                {
                    msgDisplay.AddException(ex);
                }
                if (success == false)
                {
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
            }


            if (success)
            {
                Return("commentID", commentID);
            }
        }
Esempio n. 6
0
        private void Add()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();

            m_UsernameToAdd = _Request.Get("username", Method.Post, string.Empty, false);

            try
            {
                using (ErrorScope es = new ErrorScope())
                {
                    bool sucess = FriendBO.Instance.AddUserToBlacklist(MyUserID, m_UsernameToAdd);
                    if (sucess == false || es.HasError)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error.Message);
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddException(ex);
            }
        }
Esempio n. 7
0
        private void DeleteAlbum()
        {
            bool success = false;

            using (ErrorScope es = new ErrorScope())
            {
                MessageDisplay msgDisplay = CreateMessageDisplay();

                try
                {
                    success = AlbumBO.Instance.DeleteAlbum(MyUserID, albumID.Value, true);
                }
                catch (Exception ex)
                {
                    msgDisplay.AddException(ex);
                }
                if (success == false)
                {
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
            }

            if (success)
            {
                Return("albumID", albumID.Value);
            }
        }
Esempio n. 8
0
        private void ResetRecoverPassword()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("newPassword", "password2");

            string password = _Request.Get("password", Method.Post, string.Empty, false);

            if (_Request.Get("password2", Method.Post, string.Empty, false) == password)
            {
                UserBO.Instance.ResetPasswordBySerial(_Request.Get("serial", Method.Get), password);
            }
            else
            {
                ThrowError(new PasswordInconsistentError("password2"));
            }
            if (HasUnCatchedError)
            {
                CatchError <ErrorInfo>(delegate(ErrorInfo errorinfo)
                {
                    msgDisplay.AddError(errorinfo.TatgetName, errorinfo.Message);
                });
            }
            else
            {
                //msgDisplay.ShowInfoPage(this);
                ShowSuccess("您已成功重设了密码!", IndexUrl);
            }
        }
Esempio n. 9
0
        private void SendInviteMail()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();
            string         obiterText;
            string         emailString;

            string[] emails;

            obiterText  = _Request.Get("message", Method.Post);
            emailString = _Request.Get("emails", Method.Post);

            using (ErrorScope es = new ErrorScope())
            {
                if (string.IsNullOrEmpty(emailString))
                {
                    ThrowError(new EmptyEmailError("emails"));
                }
                else
                {
                    emails = StringUtil.GetLines(emailString);
                    UserBO.Instance.MassEmailingInvite(My, emails, InviteBO.Instance.BuildFixInviteCode(MyUserID), obiterText);
                }

                if (es.HasUnCatchedError)
                {
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
            }
        }
Esempio n. 10
0
        private void SaveSetting()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("EnableShareFunction", "HotDays");

            ShareSettings shareSettings = new ShareSettings();

            shareSettings.EnableShareFunction = _Request.Get <bool>("EnableShareFunction", Method.Post, true);
            shareSettings.HotShareSortType    = _Request.Get <HotShareSortType>("HotShareSortType", Method.Post, HotShareSortType.ShareCount);

            int hotDays = _Request.Get <int>("HotDays", Method.Post, 3);


            if (hotDays < 1)
            {
                msgDisplay.AddError("HotDays", "天数必须大于0");
                return;
            }

            shareSettings.HotDays = hotDays;

            if (!msgDisplay.HasAnyError())
            {
                SettingManager.SaveSettings(shareSettings);
            }
        }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (_Request.IsClick("delete"))
            {
                int propID = _Request.Get <int>("id", Method.Get, 0);

                if (propID == 0)
                {
                    ShowError("缺少必要参数");
                }

                MessageDisplay msgDisplay = CreateMessageDisplay();
                using (ErrorScope es = new ErrorScope())
                {
                    bool succeed = PropBO.Instance.SaleUserProp(My, propID, 0, 0);

                    if (succeed == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                    }
                    else
                    {
                        Return(true);
                    }
                }
            }
        }
Esempio n. 12
0
        private void SetMyInviteSerial()
        {
            string myInviteSerial;

            myInviteSerial = _Request.Get("MyInviteSerial", Method.Post);

            using (ErrorScope es = new ErrorScope())
            {
                MessageDisplay msgDisplay = CreateMessageDisplayForForm("setSerial");

                if (!UserBO.Instance.SetUserInviteCode(MyUserID, myInviteSerial))
                {
                    ThrowError(new InviteSerialError("MyInviteSerial", myInviteSerial));
                }

                if (es.HasUnCatchedError)
                {
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
                else
                {
                    //msgDisplay.ShowInfo(this);
                    ShowSuccess();
                    //BbsRouter.JumpToCurrentUrl("success=1");
                }
            }
        }
Esempio n. 13
0
        private void Operation(string operationType)
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();
            string         selectedIDs;

            int[] userIDs;

            selectedIDs = _Request.Get("userids", Method.Post);
            userIDs     = StringUtil.Split <int>(selectedIDs);

            switch (operationType)
            {
            case "delete":
                //UserBO.Instance.DeleteUsers( MyUserID, userIDs);
                break;

            case "active":
                UserBO.Instance.AdminActivingUsers(My, userIDs, true);
                break;

            case "emailvalidated":
                break;

            default:
                break;
            }

            if (HasUnCatchedError)
            {
                CatchError <ErrorInfo>(delegate(ErrorInfo error) {
                    msgDisplay.AddError(error);
                });
            }
        }
Esempio n. 14
0
        private void SaveRealnameData()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("realname", "idnumber", "idcardfileface", "idcardfileback");

            string realname = _Request.Get("realname", Method.Post);
            string idNumber = _Request.Get("idnumber", Method.Post);

            HttpPostedFile idCardFileFace = null;
            HttpPostedFile idCardFileBack = null;

            if (UploadCardImage)
            {
                if (Request.Files.Count > 0)
                {
                    idCardFileFace = Request.Files[0].FileName != string.Empty ? Request.Files[0] : null;
                }
                if (Request.Files.Count > 1)
                {
                    idCardFileBack = Request.Files[1].FileName != string.Empty ? Request.Files[1] : null;
                }
            }

            using (ErrorScope es = new ErrorScope())
            {
                UserBO.Instance.SaveUserRealnameData(My, idNumber, realname, idCardFileFace, idCardFileBack);

                if (es.HasError)
                {
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo err){
                        msgDisplay.AddError(err.TatgetName, err.Message);
                    });
                }
            }
        }
        private bool CreateExtendField(ExtendedFieldType fieldType)
        {
            MessageDisplay msgDisplay  = CreateMessageDisplay();
            ExtendedField  extendFiled = GetExtendFieldInfo(fieldType);

            extendFiled.Key = Guid.NewGuid().ToString();

            ExtendedFieldSettings settings = SettingManager.CloneSetttings <ExtendedFieldSettings>(AllSettings.Current.ExtendedFieldSettings);

            settings.Version = Guid.NewGuid().ToString();

            foreach (ExtendedField field in AllSettings.Current.ExtendedFieldSettings.Fields)
            {
                if (string.Compare(extendFiled.Name, field.Name, true) == 0)
                {
                    msgDisplay.AddError("已经存在同名的扩展字段\"" + field.Name + "\",请更换名称");
                    break;
                }
            }

            if (msgDisplay.HasAnyError())
            {
                return(false);
            }

            settings.Fields.Add(extendFiled);

            SettingManager.SaveSettings(settings);
            return(true);
        }
        private void Approve()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();

            int[] ids     = StringUtil.Split <int>(_Request.Get("commentid", Method.All, ""));
            bool  success = false;

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    success = CommentBO.Instance.ApproveComments(MyUserID, ids);
                }
                catch (Exception ex)
                {
                    msgDisplay.AddException(ex);
                }

                if (success == false)
                {
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
            }

            if (success)
            {
                Return(true);
            }
        }
Esempio n. 17
0
        private void MoveForum()
        {
            bool success = false;

            using (ErrorScope es = new ErrorScope())
            {
                MessageDisplay msgDisplay = CreateMessageDisplay();

                int parentID = _Request.Get <int>("parentForum", Method.Post, 0);

                try
                {
                    success = ForumBO.Instance.MoveFourm(Forum.ForumID, parentID);
                    if (success == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                    }
                }
                catch (Exception ex)
                {
                    msgDisplay.AddException(ex);
                }
            }

            if (success)
            {
                Return(true);
            }
        }
        public void DeleteChatSession()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();

            bool success = false;


            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    success = ChatBO.Instance.DeleteChatSession(ChatSession.OwnerID, ChatSession.UserID);
                }
                catch (Exception ex)
                {
                    msgDisplay.AddException(ex);
                }

                if (success == false)
                {
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
            }


            if (success)
            {
                Return("sesionid", sessionID);
            }
        }
Esempio n. 19
0
        public void RecoverPassword()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("email", "username", GetValidateCodeInputName("recoverpassword"));

            using (ErrorScope es = new ErrorScope())
            {
                ValidateCodeManager.CreateValidateCodeActionRecode("recoverpassword");

                if (CheckValidateCode("recoverpassword", msgDisplay))
                {
                    string username = _Request.Get("username", Method.Post, string.Empty, false);
                    string email    = _Request.Get("email", Method.Post, string.Empty, false);

                    UserBO.Instance.TryRecoverPassword(username, email);

                    if (es.HasUnCatchedError)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                    }
                    else
                    {
                        ShowSuccess("已经有一封邮件发到你的邮箱,请收取邮件,按照提示进行下一步操作", IndexUrl);
                        //msgDisplay.ShowInfoPage(this);
                    }
                }
            }
        }
Esempio n. 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int?propid = _Request.Get <int>("id");

            if (propid == null)
            {
                ShowError("缺少必要参数");
            }

            m_Prop = PropBO.Instance.GetUserProp(MyUserID, propid.Value);

            if (m_Prop == null)
            {
                ShowError("道具不存在");
            }

            if (_Request.IsClick("drop"))
            {
                MessageDisplay md = CreateMessageDisplay();

                int count = _Request.Get <int>("count", 0);

                if (count <= 0)
                {
                    md.AddError("数量必须大于0");
                    return;
                }

                using (ErrorScope es = new ErrorScope())
                {
                    bool succeed = PropBO.Instance.DropUserProp(My, propid.Value, count);

                    if (succeed == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            md.AddError(error);
                        });
                    }
                    else
                    {
                        Return(1);
                    }
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        /// 验证验证码
        /// </summary>
        /// <param name="actionType"></param>
        /// <param name="id"></param>
        /// <param name="msgDisplay"></param>
        /// <returns></returns>
        public static bool CheckValidateCode(string actionType, string id, MessageDisplay msgDisplay,bool removeSession)
        {
            HttpSessionState Session = HttpContext.Current.Session;

            if (MaxLabs.bbsMax.ValidateCodes.ValidateCodeManager.HasValidateCode(actionType) == false)
                return true;

            if (id == null)
                id = string.Empty;

            string inputName = string.Format(Consts.ValidateCode_InputName, actionType, id);


            string code = HttpContext.Current.Request.Form[inputName];

            string sessionKey = Consts.ValidateCode_SessionKey_Prefix + actionType + id.Trim().ToLower();

            if (string.IsNullOrEmpty(code))
            {
                if (msgDisplay != null)
                    msgDisplay.AddError(inputName, Lang_Error.ValidateCode_EmptyValidateCodeError);
                
                if (removeSession)
                    Session.Remove(sessionKey);
                return false;
            }

            object realCode = Session[sessionKey];
            if (realCode == null)
            {
                if (msgDisplay != null)
                    msgDisplay.AddError(inputName, Lang_Error.ValidateCode_EmptyValidateCodeError);
                return false;
            }

            if (string.Compare(code.Trim(), realCode.ToString(), true) != 0)
            {
                if (msgDisplay != null)
                    msgDisplay.AddError(inputName, Lang_Error.ValidateCode_InvalidValidateCodeError);

                if (removeSession)
                    Session.Remove(sessionKey);
                return false;
            }
            return true;
        }
Esempio n. 22
0
        private void DeleteMedals(List <int> medalIDs)
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();

            MedalCollection medals = new MedalCollection();

            int i = 0;

            foreach (Medal medal in MedalList)
            {
                if (medalIDs.Contains(medal.ID) == false)
                {
                    medals.Add(medal);
                }
            }

            MedalSettings setting = new MedalSettings();

            setting.Medals     = medals;
            setting.MaxMedalID = AllSettings.Current.MedalSettings.MaxMedalID;

            try
            {
                if (!SettingManager.SaveSettings(setting))
                {
                    CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
                else
                {
                    UserBO.Instance.RemoveAllUserCache();

                    m_MedalList = null;
                    _Request.Clear(Method.Post);
                    Logs.LogManager.LogOperation(
                        new Medal_DeleteMedalByIDs(MyUserID, My.Name, _Request.IpAddress, medalIDs)
                        );
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }
Esempio n. 23
0
        public void CreateGroup(int sortorder, string GroupName, MessageDisplay msgdisplay)
        {
            if (GroupName != null && GroupName.Trim() != string.Empty)
            {
                GroupName = GroupName.Trim();
                if (GetEmoticonGroupByName(GroupName) != null)
                {
                    msgdisplay.AddError("groupname", "分组:" + GroupName + " 已经存在");
                }
                else
                {
                    if (Regex.IsMatch(GroupName, "[\\/:\\*\\?\"\\<\\>\\|]+"))
                    {
                        msgdisplay.AddError("分组是以文件夹的形式存在。因此,分组名称里不能包含下列字符:/ : * ? \" < > |");
                    }
                    else
                    {
                        bool error = false;
                        try
                        {
                            Directory.CreateDirectory(IOUtil.JoinPath(this.FaceDirectory, GroupName));
                        }
                        catch (Exception ex)
                        {
                            error = true;
                            msgdisplay.AddError("创建表情分组失败, 可能的原因是: 对 " + this.FaceDirectory + " 无写入权限! 具体错误信息: " + ex.Message);
                        }

                        if (error == false)
                        {
                            init();
                            DefaultEmoticonGroup newGroup = GetEmoticonGroupByName(GroupName);
                            if (newGroup != null)
                            {
                                newGroup.SortOrder = sortorder;
                            }
                            SettingManager.SaveSettings(this);
                        }
                    }
                }
            }
            else
            {
                msgdisplay.AddError("groupname", "分组名称不能为空。");
            }
        }
Esempio n. 24
0
        public void CreateGroup(int sortorder,string GroupName,MessageDisplay msgdisplay)
        {
            if (GroupName!=null && GroupName.Trim()!=string.Empty)
            {
                GroupName = GroupName.Trim();
                if ( GetEmoticonGroupByName(GroupName) != null)
                {
                    msgdisplay.AddError("groupname", "分组:"+GroupName+" 已经存在");
                }
                else
                {
                    if (Regex.IsMatch(GroupName, "[\\/:\\*\\?\"\\<\\>\\|]+"))
                    {
                        msgdisplay.AddError("分组是以文件夹的形式存在。因此,分组名称里不能包含下列字符:/ : * ? \" < > |");
                    }
                    else
                    {

                        bool error = false;
                        try
                        {
                            Directory.CreateDirectory(IOUtil.JoinPath(this.FaceDirectory, GroupName));
                        }
                        catch (Exception ex)
                        {
                            error = true;
                            msgdisplay.AddError("创建表情分组失败, 可能的原因是: 对 " + this.FaceDirectory + " 无写入权限! 具体错误信息: " + ex.Message);
                        }

                        if (error == false)
                        {
                            init();
                            DefaultEmoticonGroup newGroup = GetEmoticonGroupByName(GroupName);
                            if(newGroup!=null)
                                newGroup.SortOrder = sortorder;
                            SettingManager.SaveSettings(this);
                        }
                    }
                }
            }
            else
            {
                msgdisplay.AddError("groupname", "分组名称不能为空。");
            }
        }
Esempio n. 25
0
        public void AddTimeSpan()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();
            int            scopetype  = _Request.Get <int>("timescopetype", Method.Post, 0);
            string         timespan   = _Request.Get("timespan", Method.Post, string.Empty, false);
            DateTime       definedate = _Request.Get <DateTime>("definedate", Method.Post, DateTime.MinValue);
            string         week       = _Request.Get("week", Method.Post, string.Empty, false);
            string         month      = _Request.Get("month", Method.Post, string.Empty, false);

            int type = _Request.Get <int>("type", Method.Post, 0);

            if (definedate == DateTime.MinValue && scopetype == 0)
            {
                msgDisplay.AddError("指定日期未填!");
                return;
            }

            if (week == string.Empty && scopetype == 2)
            {
                msgDisplay.AddError("未选择星期");
                return;
            }

            if (month == string.Empty && scopetype == 3)
            {
                msgDisplay.AddError("未选择日期");
                return;
            }

            DateTime? ts1 = null;
            DateTime? ts2 = null;
            ScopeBase scopebase;

            if (TimeSpanIsInMatch(timespan, ref ts1, ref ts2))
            {
                scopebase = GetScopeTypeClass(scopetype, definedate, week, month, ts1, ts2);
                scopebase.OperetorName = My.Name;
                AddToListByType(scopebase, type);
                ShowSuccess("操作成功", scopebase);
            }
            else
            {
                msgDisplay.AddError("时间范围格式错误,请重新输入!");
            }
        }
Esempio n. 26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (_Request.IsClick("CreateImpression"))
            {
                MessageDisplay msgDisplay = CreateMessageDisplayForForm("ImpressionForum");
                string         text       = _Request.Get("Text", Method.Post, string.Empty);

                bool success;

                using (ErrorScope es = new ErrorScope())
                {
                    try
                    {
                        success = ImpressionBO.Instance.CreateImpression(My, User, text);
                        if (success == false)
                        {
                            es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                            {
                                msgDisplay.AddError(error);
                            });
                        }
                        else
                        {
                            m_IsShowImpressionInput = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        msgDisplay.AddException(ex);
                    }

                    if (msgDisplay.HasAnyError())
                    {
                        m_IsShowImpressionInput = true;
                    }
                }
            }
            else if (_Request.Get <int>("typeid", Method.Get, 0) > 0)
            {
                MessageDisplay msgDisplay = CreateMessageDisplay();
                int            typeID     = _Request.Get <int>("TypeID", Method.Get, 0);
                using (ErrorScope es = new ErrorScope())
                {
                    try
                    {
                        ImpressionBO.Instance.DeleteImpressionTypeForUser(My, typeID);
                    }
                    catch (Exception ex)
                    {
                        msgDisplay.AddError(ex.Message);
                    }
                }
            }

            WaitForFillSimpleUsers <ImpressionRecord>(ImpressionRecordList, 0);
            WaitForFillSimpleUsers <Impression>(ImpressionList);
        }
        private void Upload()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();

            if (Dir == null)
            {
                return;
            }

            if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
            {
                bool           isAllowFileType = false;
                string[]       allowFileTypes  = new string[] { ".jpg", ".gif", ".png", ".bmp", ".jpeg" };
                HttpPostedFile file            = Request.Files[0];

                foreach (string s in allowFileTypes)
                {
                    if (file.FileName.EndsWith(s, StringComparison.OrdinalIgnoreCase))
                    {
                        isAllowFileType = true;
                        break;
                    }
                }

                if (isAllowFileType)
                {
                    string filePath = Globals.GetPath(Dir.Value);

                    if (!Directory.Exists(filePath))
                    {
                        Directory.CreateDirectory(filePath);
                    }

                    string fileName = Path.GetFileName(file.FileName);
                    filePath = IOUtil.JoinPath(filePath, fileName);
                    if (File.Exists(filePath))
                    {
                        IOUtil.DeleteFile(filePath);
                    }
                    try
                    {
                        file.SaveAs(filePath);
                    }
                    catch (Exception ex)
                    {
                        msgDisplay.AddError("写入文件出错,错误信息: " + ex.Message + "  可能的情况是, 对该目录:" + Globals.GetPath(Dir.Value) + "  的IO操作被限制。");
                        return;
                    }
                    UploadSuccess   = true;
                    this.m_FileJson = string.Format("{{url:'{0}',value:'{1}',filename:'{2}'}}", StringUtil.ToJavaScriptString(GetUrl(fileName)), StringUtil.ToJavaScriptString(GetRelativeUrl(fileName)), StringUtil.ToJavaScriptString(fileName));
                }
                else
                {
                    //TODO Throw FiletypeInvalid
                }
            }
        }
Esempio n. 28
0
        private void DeleteChecked()
        {
            int[] shareIDs    = StringUtil.Split <int>(_Request.Get("shareids", Method.Post, string.Empty));
            bool  updatePoint = (_Request.Get("updatePoint", Method.Post) == "1");

            MessageDisplay msgDisplay = CreateMessageDisplay();


            if (shareIDs == null || shareIDs.Length == 0)
            {
                msgDisplay.AddError("请至少选择一条要删除的数据");
                return;
            }

            try
            {
                using (new ErrorScope())
                {
                    bool success = false;

                    if (_Request.Get("type") != "share")
                    {
                        success = FavoriteBO.Instance.DeleteShares(MyUserID, shareIDs, updatePoint);
                    }
                    else
                    {
                        success = ShareBO.Instance.DeleteShares(MyUserID, shareIDs, updatePoint);
                    }

                    if (!success)
                    {
                        CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }
Esempio n. 29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (_Request.IsClick("savemissions"))
            {
                SaveMissions();
            }

            else if (_Request.IsClick("deletemissions"))
            {
                DeleteMissions();
            }

            else if (_Request.Get("disable", Method.Get) != null)
            {
                MessageDisplay msgDisplay = CreateMessageDisplay();

                bool disable = _Request.Get("disable", Method.Get, string.Empty).ToLower() == "true";

                MissionSettings missionSettings = new MissionSettings();
                missionSettings.EnableMissionFunction = !disable;

                try
                {
                    if (!SettingManager.SaveSettings(missionSettings))
                    {
                        CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error.Message);
                        });
                    }
                    else
                    {
                        BbsRouter.JumpToCurrentUrl(true);
                    }
                }
                catch (Exception ex)
                {
                    msgDisplay.AddError(ex.Message);
                }
            }

            m_CategoryList = MissionBO.Instance.GetMissionCategories();
        }
        private void EditCategory()
        {
            string categoryName = _Request.Get("name", Method.Post);

            bool success = false;

            using (ErrorScope es = new ErrorScope())
            {
                MessageDisplay msgDisplay = CreateMessageDisplay();

                if (categoryID == null)
                {
                    msgDisplay.AddError(new InvalidParamError("categoryID").Message);
                    return;
                }

                try
                {
                    success = BlogBO.Instance.UpdateBlogCategory(MyUserID, categoryID.Value, categoryName);
                }
                catch (Exception ex)
                {
                    msgDisplay.AddException(ex);
                }

                if (success == false)
                {
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
            }

            if (success)
            {
                JsonBuilder json = new JsonBuilder();
                json.Set("id", categoryID);
                json.Set("name", categoryName);

                Return(json);
            }
        }
Esempio n. 31
0
        private void DeleteNotify()
        {
            using (new ErrorScope())
            {
                MessageDisplay msgDisplay = CreateMessageDisplay();

                int[] notifyIDs = _Request.GetList <int>("notifyid", Method.All, new int[0]);
                int   notifyID  = _Request.Get <int>("notifyid", Method.All, 0);
                bool  success   = false;

                if (notifyID < 0)
                {
                    SystemNotifyProvider.IgnoreNotify(MyUserID, notifyID);
                    success = true;
                }
                else
                {
                    try
                    {
                        if (NotifyBO.Instance.DeleteNotifies(MyUserID, notifyIDs))
                        {
                            success = true;
                        }
                        else
                        {
                            CatchError <ErrorInfo>(delegate(ErrorInfo error)
                            {
                                msgDisplay.AddError(error);
                            }
                                                   );
                        }
                    }
                    catch (Exception ex)
                    {
                        msgDisplay.AddError(ex.Message);
                    }
                }
                if (success)
                {
                    Return(notifyIDs);
                }
            }
        }
Esempio n. 32
0
        private void Save()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("modelname");

            int[] modelIDs  = _Request.GetList <int>("modelIDs", Method.Post, new int[] { });
            int[] enableIDs = _Request.GetList <int>("enableIDs", Method.Post, new int[] { });

            List <int>    sortOrders = new List <int>();
            List <string> names      = new List <string>();

            foreach (int modelID in modelIDs)
            {
                int    sortOrder = _Request.Get <int>("sortorder_" + modelID, Method.Post, 0);
                string name      = _Request.Get("modelname_" + modelID, Method.Post, string.Empty);

                sortOrders.Add(sortOrder);
                names.Add(name);
            }

            bool success;

            try
            {
                success = ThreadCateBO.Instance.UpdateModels(My, modelIDs, sortOrders, names, enableIDs);
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
                return;
            }

            if (success == false)
            {
                CatchError <ErrorInfo>(delegate(ErrorInfo error)
                {
                    msgDisplay.AddError(error);
                });
            }
            else
            {
                Return(true);
            }
        }
Esempio n. 33
0
        private void SaveEmailSettings()
        {
            MessageDisplay            msgDisplay = CreateMessageDisplay("smtpserver", "SmtpServerAccount", "SmtpServerPassword", "SenderEmail", "Port");
            int                       line       = 0;
            EmailSendServerCollection emails     = new EmailSendServerCollection();

            int[] emailIDs = _Request.GetList <int>("emailids", Method.Post, new int[0]);

            EmailSettings settings = new EmailSettings();

            bool enableSend = _Request.Get <bool>("EnableSendEmail", Method.Post, false);

            if (enableSend)
            {
                foreach (int i in emailIDs)
                {
                    bool            isnew     = _Request.Get <bool>("isnew." + i, Method.Post, false);
                    string          keysubfix = isnew ? ".new." + i : "." + i;
                    EmailSendServer email     = new EmailSendServer();

                    email.EmailID            = i;
                    email.SmtpServer         = _Request.Get("smtpserver" + keysubfix, Method.Post);
                    email.SmtpServerAccount  = _Request.Get("SmtpServerAccount" + keysubfix, Method.Post);
                    email.SmtpServerPassword = _Request.Get("SmtpServerPassword" + keysubfix, Method.Post);
                    email.SenderEmail        = _Request.Get("senderemail" + keysubfix, Method.Post);
                    email.EnableSSL          = _Request.Get <bool>("EnableSSL" + keysubfix, Method.Post, false);
                    email.Port = _Request.Get <int>("Port" + keysubfix, Method.Post, 0);

                    ValidateEmail(email, msgDisplay, line);

                    emails.Add(email);

                    line++;
                }
                settings.SendServers = emails;

                if (emails.Count == 0)
                {
                    msgDisplay.AddError(new CustomError("开启邮件发送功能时至少填写一个Email帐号"));
                }
            }
            else
            {
                settings.SendServers = AllSettings.Current.EmailSettings.SendServers;
            }

            settings.EnableSendEmail = enableSend;

            if (!msgDisplay.HasAnyError())
            {
                SettingManager.SaveSettings(settings);
            }

            m_Emails = settings.SendServers;
        }
Esempio n. 34
0
        protected virtual bool ValidateRoleDate(RoleCollection roles, MessageDisplay msgdisp)
        {
            Role myMaxRole = My.MaxRole;
            bool returnValue = true;
            for (int i = 0; i < roles.Count; i++)
            {
                if (string.IsNullOrEmpty(roles[i].Name) || roles[i].Name.Trim() == string.Empty)
                {
                    msgdisp.AddError("name", i, Lang_Error.Role_EmptyRoleNameError);
                    returnValue = false;
                }

                if ( !My.IsOwner && roles[i].IsNew && roles[i].IsManager && roles[i].Level >= myMaxRole.Level)
                {
                    msgdisp.AddError("level", i, string.Format("您当前的用户组为{0}。因此,您不能添加和{0}同级别或级别更高的用户组",myMaxRole.Name));
                    returnValue = false;
                }
            }

            return returnValue;
        }
Esempio n. 35
0
        private void ValidateEmail( EmailSendServer email,MessageDisplay msgDisplay,int line )
        {
            if ( string.IsNullOrEmpty(email.SmtpServer))
            {
                msgDisplay.AddError(new CustomError("SmtpServer", line, "smtp服务器地址不能为空!"));
            }

            if (string.IsNullOrEmpty(email.SenderEmail))
            {
                msgDisplay.AddError(new CustomError("SenderEmail", line, "发送端Email地址不能为空"));
            }
            else if (!emailreg.IsMatch(email.SenderEmail))
            {
                msgDisplay.AddError(new CustomError("SenderEmail", line, "发送端Email地址格式错误"));
            }
            

            if (string.IsNullOrEmpty(email.SmtpServerAccount))
            {
                msgDisplay.AddError(new CustomError("SmtpServerAccount",line,"邮箱用户名不能为空"));
            }

            if (string.IsNullOrEmpty(email.SmtpServerPassword))
            {
                msgDisplay.AddError(new CustomError("SmtpServerPassword", line, "邮箱密码不能为空"));
            }

            if (email.Port > 65535 || email.Port < 2)
            {
                msgDisplay.AddError(new CustomError("Port", line, "SMTP服务器端口错误"));
            }
        }
Esempio n. 36
0
 private long GetSeconds(string name,MessageDisplay msgDisplay)
 {
     string valueString = _Request.Get(name + "Value", Method.Post, string.Empty);
     if(string.IsNullOrEmpty(valueString))
         return 0;
     long value;
     if (long.TryParse(valueString, out value))
     {
         TimeUnit unit = _Request.Get<TimeUnit>(name + "Unit", Method.Post, TimeUnit.Second);
         return DateTimeUtil.GetSeconds(value, unit);
     }
     else
     {
         msgDisplay.AddError(name, "请填写整数");
         return 0;
     }
 }
Esempio n. 37
0
        private void GetAttachments(int postUserID, MessageDisplay msgDisplay, ref AttachmentCollection attachs)
        {
            AttachmentCollection attachments = new AttachmentCollection();
            DiskFileCollection diskFiles = null;

            List<int> tempFileIds = new List<int>(), diskFileIds=new List<int>();

            string[] attachIndexs = _Request.Get("attachIndex", Method.Post,string.Empty).Split( new string[]{ ","}, StringSplitOptions.RemoveEmptyEntries);


            foreach (string i in attachIndexs)
            {
                if (i == "{index}")
                    continue;
                int id = _Request.Get<int>("attachid_" + i, Method.Post, 0);
                int attachType=_Request.Get<int>("attachtype_" + i, Method.Post, 0);
                if ( attachType == 0)
                    tempFileIds.Add(id);
                else if( attachType==1 )
                    diskFileIds.Add(id);
            }

           diskFiles = DiskBO.Instance.GetDiskFiles(diskFileIds);
            
                Attachment attach;

                string extendName = string.Empty;
                foreach (DiskFile file in diskFiles)
                {
                    attach = new Attachment();
                    attach.DiskFileID = file.DiskFileID;
                    attach.FileID = file.FileID;
                    attach.FileSize = file.Size;
                    attach.FileName = _Request.Get("filename_1_" + file.DiskFileID, Method.Post, "未命名", false);
                    attach.Price = _Request.Get("price_1_" + file.DiskFileID, Method.Post, 0);
                    extendName = _Request.Get("extname_1_" + file.DiskFileID, Method.Post, string.Empty);
                    attach.AttachType = AttachType.DiskFile;
                    if (!string.IsNullOrEmpty(attach.FileName) && !string.IsNullOrEmpty(extendName))
                        attach.FileName += "." + extendName;

                    attach.FileType = extendName;
                    attachments.Add(attach);
                }

                foreach (int id in tempFileIds)
                {
                    attach = new Attachment();
                    attach.AttachmentID = id;
                    attach.FileName = _Request.Get("filename_0_" + id, Method.Post, "未命名", false);
                    attach.Price = _Request.Get("price_0_" + id, Method.Post, 0);

                    attach.AttachType = AttachType.TempAttach;

                    extendName = _Request.Get("extname_0_" + id, Method.Post, string.Empty);
                    if (!string.IsNullOrEmpty(attach.FileName) && !string.IsNullOrEmpty(extendName))
                        attach.FileName += "." + extendName;

                    attach.FileType = extendName;
                    attachments.Add(attach);
                }

            foreach(Attachment att in attachments)
            {
                att.PostID = 0;

                if (IsEditPost || IsEditThread)
                    att.UserID = postUserID;
                
                else
                    att.UserID = MyUserID;

                if (att.Price < 0)
                {
                    msgDisplay.AddError("附件售价不能小于0");
                    return;
                }
            }
            attachs.AddRange(attachments);
        }
Esempio n. 38
0
        private PointActionItem GetNeedValuePointActionItem(string action, int id, bool isNew, MessageDisplay msgDisplay)
        {
            string pointTypeName, minRemainName, maxValueName, minValueName;
            Guid roleID;
            int sortOrder;
            if (isNew)
            { 
                pointTypeName = "pointaction.new." + action;
                minRemainName = "minremaining.new." + action;
                maxValueName = "maxvalue.new." + action;
                minValueName = "minvalue.new." + action;
            }
            else
            {
                pointTypeName = "pointaction." + action + "." + id;
                minRemainName = "minremaining." + action + "." + id;
                maxValueName = "maxvalue." + action + "." + id;
                minValueName = "minvalue." + action + "." + id;
            }

            if (id == 0 && isNew == false)
            {
                roleID = Guid.Empty;
                sortOrder = 0;
            }
            else
            {
                string roleIDName, sortOrderName;
                if (isNew)
                {
                    roleIDName = "pointtype.new.role." + action;
                    sortOrderName = "pointtype.new.sortorder." + action;
                }
                else
                {
                    roleIDName = "pointtype.role." + action + "." + id;
                    sortOrderName = "pointtype.sortorder." + action + "." + id;
                }

                roleID = _Request.Get<Guid>(roleIDName, Method.Post, Guid.Empty);
                if (roleID == Guid.Empty)
                {
                    if (isNew && _Request.Get("display.tr.pointtype." + action, Method.Post, "0") == "1")
                    {
                        msgDisplay.AddError("pointtype.new." + action , Lang_Error.User_UserPointActionEmptyRoleIDError);
                    }
                    else
                        return null;
                }
                string tempValueString = _Request.Get(sortOrderName, Method.Post, string.Empty);

                if (!int.TryParse(tempValueString, out sortOrder))
                {
                    if (isNew)
                        msgDisplay.AddError("pointtype.new." + action , Lang_Error.User_UserPointActionInvalidSortOrderError);
                    else
                        msgDisplay.AddError("pointtype." + action, id, Lang_Error.User_UserPointActionInvalidSortOrderError);
                }
            }

            UserPointType pointType = _Request.Get<UserPointType>(pointTypeName, Method.Post, UserPointType.Point1);

            int? minRemaining, maxValue;
            int minValue;


            #region minRemaining, maxValue ,minValue

            StringBuilder errorMessages = new StringBuilder();

            int value;
            string valueString = _Request.Get(minRemainName, Method.Post, string.Empty);
            if (valueString.Trim() == string.Empty)
            {
                minRemaining = null;
            }
            else if (int.TryParse(valueString, out value))
            {
                minRemaining = value;


                if (minRemaining < AllSettings.Current.PointSettings.GetUserPoint(pointType).MinValue)
                    errorMessages.Append(Lang_Error.User_UserPointInvalidMinRemainingError).Append("<br />");
            }
            else
            {
                errorMessages.Append(Lang_Error.User_UserPointMinRemainingFormatError).Append("<br />");
                minRemaining = null;
            }

            valueString = _Request.Get(minValueName, Method.Post, string.Empty);
            if (valueString.Trim() == string.Empty)
            {
                minValue = 1;
            }
            else if (int.TryParse(valueString, out value))
            {
                minValue = value;
                if (minValue < 1)
                    errorMessages.Append(Lang_Error.User_UserPointTradeMinValueFormatError).Append("<br />");
            }
            else
            {
                errorMessages.Append(Lang_Error.User_UserPointTradeMinValueFormatError).Append("<br />");
                minValue = 1;
            }

            valueString = _Request.Get(maxValueName, Method.Post, string.Empty);
            if (valueString.Trim() == string.Empty)
            {
                maxValue = null;
            }
            else if (int.TryParse(valueString, out value))
            {
                maxValue = value;
                if (maxValue < minValue)
                    errorMessages.Append(Lang_Error.User_UserPointInvalidTradeMaxValueError).Append("<br />");
            }
            else
            {
                errorMessages.Append(Lang_Error.User_UserPointTradeMaxValueFormatError).Append("<br />");
                maxValue = null;
            }

            if (errorMessages.Length > 0)
            {
                if (isNew)
                    msgDisplay.AddError("pointtype.new." + action, errorMessages.ToString(0, errorMessages.Length - 6));
                else
                    msgDisplay.AddError("pointtype." + action, id, errorMessages.ToString(0, errorMessages.Length - 6));
            }

            #endregion


            PointActionItem item = new PointActionItem();
            item.Action = action;
            item.PointType = pointType;
            item.MaxValue = maxValue == null ? int.MaxValue : maxValue.Value;
            item.MinRemaining = minRemaining == null ? int.MinValue : minRemaining.Value;
            item.MinValue = minValue;
            item.RoleID = roleID;
            item.RoleSortOrder = sortOrder;

            return item;
        }
 private int[] GetPoint(string formName,bool isSetIntMinValue,MessageDisplay msgDisplay)
 {
     UserPointCollection allPoints = AllSettings.Current.PointSettings.UserPoints;
     int[] points = new int[allPoints.Count];
     StringBuilder pointNames = new StringBuilder();
     for (int i = 0; i < points.Length;i++ )
     {
         UserPoint point = allPoints[i];
         if (point.Enable)
         {
             int value;
             string valueString;
             if (!GetIntValue(formName + "." + (int)point.Type, isSetIntMinValue, out value, out valueString))
             {
                 pointNames.Append(point.Name+",");
             }
             points[i] = value;
         }
         else
             points[i] = 0;
     }
     if (pointNames.Length > 0)
         msgDisplay.AddError(formName, new PointFormatError(formName, pointNames.ToString(0, pointNames.Length - 1),string.Empty).Message);
     return points;
 }
Esempio n. 40
0
 private void ValidateLink(Link link, MessageDisplay msgDsp, int line)
 {
     if (string.IsNullOrEmpty(link.Name))
     {
         msgDsp.AddError("name", line, Lang_Error.Link_EmptyNameError);
     }
     if (string.IsNullOrEmpty(link.Url))
     {
         msgDsp.AddError("url", line, Lang_Error.Link_EmptyUrlError);
     }
 }
Esempio n. 41
0
        private void ValidateJudgment(Judgement jud, MessageDisplay msgDisp, int rowindex)
        {

            if (string.IsNullOrEmpty(jud.Description))
            {
                msgDisp.AddError(new CustomError("description", rowindex, Lang_Error.Judgement_EmptyDescriptionError));
            }

            if (string.IsNullOrEmpty(jud.LogoUrl))
            {
                msgDisp.AddError(new CustomError("logourl", rowindex, Lang_Error.Judgement_EmptyLogoUrlError));
            }
        }
Esempio n. 42
0
        private RateSetItem GetRankSetItem(UserPointType pointType, int id, bool isNew, MessageDisplay msgDisplay)
        {
            Guid roleID;
            string value;

            int sortOrder = 0;
            if (id == 0 && isNew == false)
                roleID = Guid.Empty;
            else
            {
                string roleIDName, sortOrderName;
                if (isNew)
                {
                    roleIDName = "new_role_" + pointType.ToString();
                    sortOrderName = "new_sortorder_" + pointType.ToString();
                }
                else
                {
                    roleIDName = "role_" + pointType.ToString() + "_" + id;
                    sortOrderName = "sortorder_" + pointType.ToString() + "_" + id;
                }

                roleID = _Request.Get<Guid>(roleIDName, Method.Post, Guid.Empty);
                if (roleID == Guid.Empty)
                {
                    if (isNew && _Request.Get("display_tr_" + pointType.ToString(), Method.Post, "0") == "1")
                    {
                        msgDisplay.AddError("new_" + pointType.ToString(), "请选择一个用户组");
                    }
                    else
                        return null;
                }
                value = _Request.Get(sortOrderName, Method.Post, string.Empty);

                if (!int.TryParse(value, out sortOrder))
                {
                    if (isNew)
                        msgDisplay.AddError("new_" + pointType.ToString(), "排序必须为整数");
                    else
                        msgDisplay.AddError(pointType.ToString(), id, "排序必须为整数");
                }
            }

            RateSetItem rankSetItem = new RateSetItem();
            rankSetItem.PointType = pointType;
            rankSetItem.RoleID = roleID;
            rankSetItem.RoleSortOrder = sortOrder;

            string minValueName,maxValueName,maxValueInTimeName;
            if (isNew)
            {
                minValueName = "new_minvalue_" + pointType.ToString();
                maxValueName = "new_maxvalue_" + pointType.ToString();
                maxValueInTimeName = "new_maxvalueintime_" + pointType.ToString();
            }
            else
            {
                minValueName = "minvalue_" + pointType.ToString() + "_" + id;
                maxValueName = "maxvalue_" + pointType.ToString() + "_" + id;
                maxValueInTimeName = "maxvalueintime_" + pointType.ToString() + "_" + id;
            }

            int minValue = 0, maxValue = 0, maxValueInTime = 0;

            StringBuilder errors = new StringBuilder();

            value = _Request.Get(minValueName, Method.Post, string.Empty);
            if (value == string.Empty)
            {
                minValue = 0;
            }
            else
            {
                if (!int.TryParse(value, out minValue))
                {
                    errors.Append("最小值,");
                }
            }

            value = _Request.Get(maxValueName, Method.Post, string.Empty);
            if (value == string.Empty)
            {
                maxValue = 0;
            }
            else
            {
                if (!int.TryParse(value, out maxValue))
                {
                    errors.Append("最大值,");
                }
            }

            value = _Request.Get(maxValueInTimeName, Method.Post, string.Empty);
            if (value == string.Empty)
            {
                maxValueInTime = 0;
            }
            else
            {
                if (ForumID == 0)//全局设置 才能设置最大评分数
                {
                    if (!int.TryParse(value, out maxValueInTime))
                    {
                        errors.Append("1天内最大评分数,");
                    }
                }
            }

            string errorName;
            if(isNew)
                errorName = "new_"+pointType.ToString();
            else
                errorName = pointType.ToString();

            if (errors.Length > 0)
            {
                msgDisplay.AddError(errorName, id, errors.ToString(0, errors.Length - 1) + "必须为整数");

                return null;
            }

            if (maxValue < minValue)
            {
                msgDisplay.AddError(errorName, id, "“评分最小值”不能大于“评分最大值”");
                return null;
            }

            if (maxValueInTime < 0)
            {
                msgDisplay.AddError(errorName, id, "1天内最大评分数必须大于0");
                return null;
            }

            if (Math.Abs(minValue) > maxValueInTime)
            {
                msgDisplay.AddError(errorName, id, "1天内最大评分数必须大等于“评分最小值”的绝对值");
                return null;
            }

            if (Math.Abs(maxValue) > maxValueInTime)
            {
                msgDisplay.AddError(errorName, id, "1天内最大评分数必须大等于“评分最大值”的绝对值");
                return null;
            }

            rankSetItem.MaxValue = maxValue;
            rankSetItem.MinValue = minValue;
            rankSetItem.MaxValueInTime = maxValueInTime;

            return rankSetItem;

        }
Esempio n. 43
0
        private PointActionItem GetPointActionItem(string action,int id,bool isNew,MessageDisplay msgDisplay)
        {
            Guid roleID;
            int sortOrder = 0;
            if (id == 0 && isNew == false)
                roleID = Guid.Empty;
            else
            {
                string roleIDName, sortOrderName;
                if (isNew)
                {
                    roleIDName = "new.role." + action;
                    sortOrderName = "new.sortorder." + action;
                }
                else
                {
                    roleIDName = "role." + action + "." + id;
                    sortOrderName = "sortorder." + action + "." + id;
                }

                roleID = _Request.Get<Guid>(roleIDName, Method.Post, Guid.Empty);
                if (roleID == Guid.Empty)
                {
                    if (isNew && _Request.Get("display.tr." + action, Method.Post, "0") == "1")
                    {
                        msgDisplay.AddError("new." + action, Lang_Error.User_UserPointActionEmptyRoleIDError);
                    }
                    else
                        return null;
                }
                string value = _Request.Get(sortOrderName, Method.Post, string.Empty);

                if (!int.TryParse(value, out sortOrder))
                {
                    if (isNew)
                        msgDisplay.AddError("new." + action, Lang_Error.User_UserPointActionInvalidSortOrderError);
                    else
                        msgDisplay.AddError(action, id, Lang_Error.User_UserPointActionInvalidSortOrderError);
                }
            }

            PointActionItem pointActionItem = new PointActionItem();
            pointActionItem.RoleID = roleID;
            pointActionItem.RoleSortOrder = sortOrder;

            int[] points = new int[8];
            StringBuilder pointNames = new StringBuilder();


            foreach (UserPoint userPoint in AllSettings.Current.PointSettings.EnabledUserPoints)
            {
                int pointID = (int)userPoint.Type;

                int point;
                string name;
                if (isNew)
                    name = "new.pointaction." + action + "." + pointID;
                else
                    name = "pointaction." + action + "." + pointID + "." + id;

                string value = _Request.Get(name, Method.Post, string.Empty);
                if (value == string.Empty)
                {
                    point = 0;
                }
                else
                {
                    if (!int.TryParse(value, out point))
                    {
                        pointNames.Append(userPoint.Name).Append(",");
                    }
                }
                points[pointID] = point;
            }
            if (pointNames.Length > 0)
            {
                if(isNew)
                    msgDisplay.AddError("new."+action, id, string.Format(Lang_Error.User_PointFormatError2, pointNames.ToString(0, pointNames.Length - 1)));
                else
                    msgDisplay.AddError(action, id, string.Format(Lang_Error.User_PointFormatError2, pointNames.ToString(0, pointNames.Length - 1)));
            }

            pointActionItem.Action = action;
            foreach (int point in points)
            {
                pointActionItem.PointValues.Add(point.ToString());
            }

            return pointActionItem;

        }
Esempio n. 44
0
        public void DeleteGroup(int groupID,MessageDisplay msgdisplay)
        {
            DefaultEmoticonGroup group = m_groups.GetValue(groupID);// m_groups[groupName];
            if (group != null)
            {
                bool error = false;

                if (string.IsNullOrEmpty(group.DirectoryName))
                {
                    msgdisplay.AddError("groupname", "不能删除默认分组");
                }
                else
                {
                    //全部文件监控都关闭然后再删除文件夹, 否则会导致重启 ||  事实证明停止监视也会重启
                    EndWach();
                    foreach (DefaultEmoticonGroup tempgroup in m_groups)
                    {
                        tempgroup.EndWach();
                    }

                    try
                    {
                      
                        Directory.Delete(m_groups .GetValue(groupID).FilePath,true);
                    }
                    catch (Exception ex)
                    {
                        group.BeginWach();
                        msgdisplay.AddError("删除表情出错,错误信息:" + ex.Message);
                        error = true;
                    }

                    if (error == false)
                    {
                        SettingManager.SaveSettings(this);
                        init(group.DirectoryName);
                    }
                    else
                    {
                        foreach (DefaultEmoticonGroup tempgroup in m_groups)
                        {
                            tempgroup.BeginWach();
                        }
                        BeginWach();
                    }
                }   
            }
        }