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


C# ErrorScope类代码示例

本文整理汇总了C#中ErrorScope的典型用法代码示例。如果您正苦于以下问题:C# ErrorScope类的具体用法?C# ErrorScope怎么用?C# ErrorScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: EmailBind

        private void EmailBind()
        {
            string password = _Request.Get("password", Method.Post, string.Empty, false);
            string email = _Request.Get("email", Method.Post, string.Empty, false);
            CheckUser();

            //UserBO.Instance.UpdateEmail(LoginUser, email);
            using (ErrorScope es = new ErrorScope())
            {
                m_Success = UserBO.Instance.LoginEmailBind(LoginUser, password, email);

                if (Success)
                {
                    ShowSuccess("Email绑定成功");
                }
                else
                {
                    es.CatchError<UserNotActivedError>(delegate(UserNotActivedError err)
                    {
                        Response.Redirect(err.ActiveUrl);
                    });
                    es.CatchError<EmailNotValidatedError>(delegate(EmailNotValidatedError err)
                    {
                        Response.Redirect(err.ValidateUrl);
                    });
                    es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                    {
                        ShowError(error);
                    });
                }
            }

        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:33,代码来源:loginemailbind.aspx.cs

示例2: 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

示例3: DeleteCategory

        private void DeleteCategory()
        {
            bool success = false;
            using (ErrorScope es = new ErrorScope())
            {
                MessageDisplay msgDisplay = CreateMessageDisplay();

                bool isDeleteArticle = _Request.Get<bool>("witharticle", Method.Post, false);

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

            if (success)
            {
                Return("id", categoryID.Value);
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:32,代码来源:blog-blogcategory-delete.aspx.cs

示例4: 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

示例5: DeleteMedals

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

            int[] userIDs = _Request.GetList<int>("userids", Method.Post, new int[0] { });
            bool success = false;

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    success = UserBO.Instance.DeleteUserMedals(My, Medal.ID, userIDs);
                }
                catch (Exception ex)
                {
                    msgDisplay.AddException(ex);
                }

                if (success == false)
                {
                    es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
                else
                {
                    _Request.Clear(Method.Post);
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:31,代码来源:medal-users.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: CreatePassportClient

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

示例8: Friend_AcceptAddFriend

        public APIResult Friend_AcceptAddFriend(int operatorID, int notifyID, int groupIDToAdd)
        {
            if (!CheckClient()) return null;
            APIResult result = new APIResult();
            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    result.IsSuccess = FriendBO.Instance.Server_AcceptAddFriend(operatorID, notifyID, groupIDToAdd);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            result.AddError(error.TatgetName,error.Message);
                        });
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorCode = Consts.ExceptionCode;
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                }
            }

            return result;
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:27,代码来源:Service_Friend.cs

示例9: 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

示例10: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            string passportRoot = _Request.Get("passportroot", Method.Post);

            if (string.IsNullOrEmpty(passportRoot))
            {
                ShowError("请填写Passport服务器地址");
                return;
            }

            bool success;
            string errMsg = string.Empty;

            using (ErrorScope es = new ErrorScope())
            {
                PassportClientConfig setting = new PassportClientConfig();

                success = setting.TestPassportService(passportRoot, 5000);

                if (es.HasUnCatchedError)
                {
                    CatchError<ErrorInfo>(delegate(ErrorInfo error)
                    {
                        ShowError(error);
                        return;
                        //errMsg += error.Message;
                    });
                }
            }

            if (success)
                ShowSuccess("Passport服务器通讯正常!");
            else
                ShowError("无法连接" + passportRoot + "上的Passport服务!");
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:35,代码来源:passport-test.aspx.cs

示例11: 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

示例12: 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

示例13: OnLoadComplete

		protected override void OnLoadComplete(EventArgs e)
		{
			using (ErrorScope es = new ErrorScope())
			{
				int pageNumber = _Request.Get<int>("page", 0);

				m_AlbumListPageSize = Consts.DefaultPageSize;

				m_AlbumList = AlbumBO.Instance.GetUserAlbums(MyUserID, SpaceOwnerID, pageNumber, m_AlbumListPageSize);

				if (m_AlbumList != null)
				{
					m_AlbumTotalCount = m_AlbumList.TotalRecords;

					UserBO.Instance.CacheSimpleUsers(m_AlbumList.GetUserIds());
				}
				else
				{
					es.CatchError<ErrorInfo>(delegate(ErrorInfo error) {
						ShowError(error);
					});
				}

				base.OnLoadComplete(e);
			}
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:26,代码来源:album-list.aspx.cs

示例14: 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

示例15: 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


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