当前位置: 首页>>代码示例>>C#>>正文


C# ErrorScope.CatchError方法代码示例

本文整理汇总了C#中ErrorScope.CatchError方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorScope.CatchError方法的具体用法?C# ErrorScope.CatchError怎么用?C# ErrorScope.CatchError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ErrorScope的用法示例。


在下文中一共展示了ErrorScope.CatchError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeletePhotos

        private void DeletePhotos(string[] ids)
        {
            using (ErrorScope es = new ErrorScope())
            {
                if (ids.Length == 1 && ids[0] == string.Empty)
                {
                    ShowError("请先选择要删除的相片");
                    return;
                }

                int[] photoIDs = new int[ids.Length];

                for (int i = 0; i < ids.Length; i++)
                {
                    photoIDs[i] = int.Parse(ids[i]);
                }

                if (AlbumBO.Instance.DeletePhotos(MyUserID, photoIDs, true))
                {
                    ShowSuccess("删除成功", new object());
                }
                else
                {
                    es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                    {
                        ShowError(error);
                    });

                    ShowError("您所在的用户组没有权限删除该相片");
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:32,代码来源:album-deletephotos.aspx.cs

示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            m_GroupID = _Request.Get<int>("groupid", Method.Get, 0);

            if (m_GroupID <= 0)
                ShowError(new InvalidParamError("groupid"));


            using (ErrorScope es = new ErrorScope())
            {
                m_Group = FriendBO.Instance.GetFriendGroup(MyUserID, m_GroupID);

                if (es.HasUnCatchedError)
                {
                    es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                    {
                        ShowError(error);
                    });
                }
                else if (m_Group == null)
                    ShowError(new NotExistsFriendGroupError(m_GroupID));
            }

            if (_Request.IsClick("delete"))
            {
                Delete();
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:28,代码来源:friendgroup-delete.aspx.cs

示例3: CreateDirectory

        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);
                    });
                }
            }

        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:31,代码来源:disk-createdirectory.aspx.cs

示例4: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            int? userID = _Request.Get<int>("uid", Method.Get);
			int pageNumber = _Request.Get<int>("page", 1);

			m_DoingListPageSize = Consts.DefaultPageSize;

			if (_Request.IsClick("addcomment"))
				AddComment("space/" + SpaceOwnerID + "/doing", "#doing_" + CommentTargetID);

			using (ErrorScope es = new ErrorScope())
			{
				m_DoingList = DoingBO.Instance.GetUserDoingsWithComments(MyUserID, userID.Value, pageNumber, m_DoingListPageSize);

				if (m_DoingList != null)
				{
					m_TotalDoingCount = m_DoingList.TotalRecords;

					UserBO.Instance.WaitForFillSimpleUsers<Doing>(m_DoingList);

					foreach (Doing doing in m_DoingList)
					{
						UserBO.Instance.WaitForFillSimpleUsers<Comment>(doing.CommentList);
					}
				}

				if (es.HasUnCatchedError)
				{
					es.CatchError<ErrorInfo>(delegate(ErrorInfo error) {
						ShowError(error);
					});
				}
			}
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:34,代码来源:doing-list.aspx.cs

示例5: DeleteChatSession

        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);
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:31,代码来源:chat-admindelete-session.aspx.cs

示例6: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (_Request.IsClick("create"))
            {
                using (ErrorScope es = new ErrorScope())
                {
                    MessageDisplay md = CreateMessageDisplay();

                    int albumID = 0;

                    string albumName = _Request.Get("albumname");
                    string description = _Request.Get("description");
                    string albumPassword = _Request.Get("albumpassword");

                    PrivacyType privacyType = _Request.Get<PrivacyType>("albumprivacy", Method.Post, PrivacyType.AllVisible);

                    if (AlbumBO.Instance.CreateAlbum(MyUserID, albumName, description, null, privacyType, albumPassword, out albumID) == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            ShowError(error);
                        });
                    }
                    else
                    {
                        ShowSuccess("相册创建成功", new object());
                    }
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:30,代码来源:album-create.aspx.cs

示例7: Page_Load

        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);
                    }
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:28,代码来源:prop-soldout.aspx.cs

示例8: Page_Load

        protected void Page_Load(object sender, EventArgs e)
		{
			if (_Request.IsClick("searchdoing"))
				Search();
			else if (_Request.IsClick("deletedoing"))
				DeleteBySelect();
			else if (_Request.IsClick("deletesearch"))
				DeleteBySearch();

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

			using (ErrorScope es = new ErrorScope())
			{
				m_DoingList = DoingBO.Instance.GetDoingsForAdmin(MyUserID, Filter, pageNumber);

				if (m_DoingList != null)
				{
					UserBO.Instance.WaitForFillSimpleUsers<Doing>(m_DoingList);

					m_DoingTotalCount = m_DoingList.TotalRecords;
				}

				if (es.HasUnCatchedError)
				{
					es.CatchError<ErrorInfo>(delegate(ErrorInfo error) {
						ShowError(error);
					});
				}
			}
		}
开发者ID:huchao007,项目名称:bbsmax,代码行数:30,代码来源:manage-doing.aspx.cs

示例9: Delete

        private void Delete()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();

            bool success = false;

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

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

            if (success)
                Return("removedUserID", m_UserIDToRemove);
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:29,代码来源:blacklist-remove.aspx.cs

示例10: ChangePassword

        private void ChangePassword()
        {
            string oldPassword;
            string newPassword, newPassword2;
            oldPassword = _Request.Get("password", Method.Post, string.Empty, false);
            newPassword = _Request.Get("newpassword", Method.Post, string.Empty, false);
            newPassword2 = _Request.Get("newpassword2", Method.Post, string.Empty, false);

            using (ErrorScope es = new ErrorScope())
            {
                MessageDisplay msgDisplay = CreateMessageDisplayForForm("changePwd", new string[] { "oldpassword", "newpassword", "newpassword2" });

                if (newPassword != newPassword2)
                {
                    msgDisplay.AddError(new PasswordInconsistentError("newpassword2"));
                }
                else
                {
                    if (UserBO.Instance.ResetPassword(My, oldPassword, newPassword) == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                    }
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:28,代码来源:changepassword.aspx.cs

示例11: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            m_FriendUserIdsText = _Request.Get("uid");
            m_FriendUserIds = StringUtil.Split<int>(m_FriendUserIdsText, ',');

            if (_Request.IsClick("movefriend"))
            {
                Move();
            }

            using (ErrorScope es = new ErrorScope())
            {
                m_FriendListToMove = FriendBO.Instance.GetFriends(MyUserID, m_FriendUserIds);

                WaitForFillSimpleUsers<Friend>(m_FriendListToMove);

                if (es.HasUnCatchedError)
                {
                    es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                    {
                        ShowError(error);
                        return;
                    });
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:26,代码来源:friend-move.aspx.cs

示例12: Delete

        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);
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:31,代码来源:comment-delete.aspx.cs

示例13: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {

            m_FriendUserID = _Request.Get<int>("uid", Method.Get, 0);

            if (_Request.IsClick("shieldfriend"))
            {
                Shield();
                return;
            }

            using (ErrorScope es = new ErrorScope())
            {
                m_FriendToShield = FriendBO.Instance.GetFriend(MyUserID, m_FriendUserID);
                WaitForFillSimpleUser<Friend>(m_FriendToShield);

                if (es.HasUnCatchedError)
                {
                    es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                    {
                        ShowError(error);
                        return;
                    });
                }
            }

        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:27,代码来源:friend-shield.aspx.cs

示例14: Page_Load

	protected void Page_Load(object sender, EventArgs e)
	{
		m_ClubName = _Request.Get("ClubName", MaxLabs.WebEngine.Method.Post);
		m_ClubCategoryID = _Request.Get<int>("ClubCategoryID", MaxLabs.WebEngine.Method.Post, 0);

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

			using (ErrorScope es = new ErrorScope())
			{
				int newClubID = 0;

				if (ClubBO.Instance.CreateClub(MyUserID, m_ClubCategoryID, m_ClubName, out newClubID))
				{
					BbsRouter.JumpTo("club/" + newClubID + "/setting");
				}
				else
				{
					es.CatchError<ErrorInfo>(delegate(ErrorInfo error) {
						md.AddError(error);
					});

					m_HasError = true;
				}
			}
		}

		m_ClubCategoryList = ClubBO.Instance.GetClubCategories();
	}
开发者ID:huchao007,项目名称:bbsmax,代码行数:30,代码来源:club-create.aspx.cs

示例15: Delete

        private void Delete()
        {
            bool success = false;

            MessageDisplay msgDisplay = CreateMessageDisplay();

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

            if (success)
                Return("id", doingID);
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:29,代码来源:doing-delete.aspx.cs


注:本文中的ErrorScope.CatchError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。