Example #1
0
        private void DoDelete(IEnumerable <string> keys)
        {
            try
            {
                Util.EnsureOperationSafe();
                var mySelf = (SCUser)DbUtil.GetEffectiveObject(this.UserObject);

                var actor   = SCObjectOperations.InstanceWithPermissions;
                var adapter = SchemaObjectAdapter.Instance;
                ISecretaryAction executor = this.GetAction();
                var errorAdapter          = new ListErrorAdapter(this.notice.Errors);

                var objects = DbUtil.LoadAndCheckObjects("人员", errorAdapter, keys.ToArray());

                foreach (SCUser user in objects)
                {
                    try
                    {
                        executor.DoRemove(user, mySelf);
                    }
                    catch (Exception ex)
                    {
                        this.notice.AddErrorInfo(string.Format("指定秘书/上司关系人员 {0} 时出错:{1}", user.DisplayName, ex.Message));
                        MCS.Web.Library.WebUtility.ShowClientError(ex);
                    }

                    this.InnerRefreshList();
                }
            }
            catch (Exception ex)
            {
                this.notice.AddErrorInfo(ex);
                MCS.Web.Library.WebUtility.ShowClientError(ex);
            }
        }
Example #2
0
        protected void HandleAddUser(object sender, EventArgs e)
        {
            string[] keys = this.GetPostedKeys();

            if (keys.Length > 0)
            {
                try
                {
                    Util.EnsureOperationSafe();
                    var adapter      = SchemaObjectAdapter.Instance;
                    var myself       = (SCUser)DbUtil.GetEffectiveObject(this.UserObject);
                    var errorAdapter = new ListErrorAdapter(this.notice.Errors);

                    ISecretaryAction executor = this.GetAction();

                    foreach (SCUser user in DbUtil.LoadAndCheckObjects("人员", errorAdapter, keys))
                    {
                        try
                        {
                            executor.DoAdd(user, myself);
                        }
                        catch (Exception ex)
                        {
                            this.notice.AddErrorInfo(ex);
                            MCS.Web.Library.WebUtility.ShowClientError(ex);
                        }
                    }

                    this.InnerRefreshList();
                }
                catch (Exception ex)
                {
                    this.notice.AddErrorInfo(ex);
                    MCS.Web.Library.WebUtility.ShowClientError(ex);
                }
            }
            else
            {
                this.notice.Text       = "在执行操作前至少应选择一个项目";
                this.notice.RenderType = WebControls.NoticeType.Info;
            }
        }