Beispiel #1
0
        public static void InitPrincipal(string userKey)
        {
            GenericTicketTokenContainer tokenContainer = new GenericTicketTokenContainer();

            tokenContainer.User     = new GenericTicketToken(Consts.Users[userKey]);
            tokenContainer.RealUser = new GenericTicketToken(Consts.Users[userKey]);

            DeluxeIdentity identity = new DeluxeIdentity(tokenContainer, null);

            DeluxePrincipal principal = new DeluxePrincipal(identity);

            PrincipaContextAccessor.SetPrincipalInContext(WfClientServiceBrokerContext.Current, principal);
        }
        private static void DoPrincipalAction(IUser user, Action action)
        {
            IPrincipal originalPrincipal = Thread.CurrentPrincipal;

            try
            {
                if (user != null)
                {
                    DeluxeIdentity identity = new DeluxeIdentity(user);
                    Thread.CurrentPrincipal = new DeluxePrincipal(identity);
                }

                if (action != null)
                {
                    action();
                }
            }
            finally
            {
                Thread.CurrentPrincipal = originalPrincipal;
            }
        }
Beispiel #3
0
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            this.bindingControl.CollectData();
            if (string.IsNullOrEmpty(this.Data.PostName))
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('请填写岗位名称!');", true);
                return;
            }
            DeluxeIdentity identity = HttpContext.Current.User.Identity as DeluxeIdentity;

            ExceptionHelper.TrueThrow(identity == null, "无法获取登陆用户");
            bool newGroup = string.IsNullOrEmpty(Data.PostID);

            try
            {
                this.bindingControl.CollectData();
                if (newGroup)
                {
                    Data.PostID     = Guid.NewGuid().ToString();
                    Data.CreateTime = System.DateTime.Now;
                    Data.Creator    = identity.User;
                }
                WfPostAdapter.Instance.Update(Data);
            }
            catch (SqlException sqlEx)
            {
                if (newGroup)
                {
                    Data.PostID = string.Empty;
                }
                WebUtility.ShowClientError(sqlEx.Message, sqlEx.StackTrace, "错误");
            }
            catch (Exception ex)
            {
                WebUtility.ShowClientError(ex.Message, ex.StackTrace, "错误");
            }
        }
Beispiel #4
0
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            DeluxeIdentity identity = HttpContext.Current.User.Identity as DeluxeIdentity;

            ExceptionHelper.TrueThrow(identity == null, "无法获取登陆用户");
            bool newGroup = string.IsNullOrEmpty(Data.GroupID);

            try
            {
                this.bindingControl.CollectData();
                IUser mangerUser = this.OuUserInputControlManager.SelectedSingleData as IUser;
                //新增组
                if (newGroup)
                {
                    Data.GroupID    = Guid.NewGuid().ToString();
                    Data.CreateTime = System.DateTime.Now;
                    Data.Creator    = identity.User;
                    Data.Manager    = mangerUser;
                    WfGroupAdapter.Instance.Update(Data);

                    //把开始设置的负责人,自动添加到用户组内.
                    if (mangerUser != null)
                    {
                        IList <IUser> users = new List <IUser>();
                        users.Add(mangerUser);
                        WfGroupAdapter.Instance.AddGroupUsers(this.Data, users);
                        RefreshGrid();
                    }
                }
                else
                {
                    if (mangerUser != null)
                    {
                        //检查所设置的群组负责人是否有效
                        if (WfGroupAdapter.Instance.CheckGroupManager(this.Data, mangerUser))
                        {
                            Data.Manager = this.OuUserInputControlManager.SelectedSingleData as IUser;
                            WfGroupAdapter.Instance.Update(Data);
                        }
                        else
                        {
                            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "",
                                                                        "alert('群组负责人必须为当前组内用户!');", true);
                            return;
                        }
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                if (newGroup)
                {
                    Data.GroupID = string.Empty;
                }
                WebUtility.ShowClientError(sqlEx.Message, sqlEx.StackTrace, "错误");
            }
            catch (Exception ex)
            {
                WebUtility.ShowClientError(ex.Message, ex.StackTrace, "错误");
            }
        }
        public static void InitPrincipal(string userKey)
        {
            GenericTicketTokenContainer tokenContainer = new GenericTicketTokenContainer();

            tokenContainer.User = new GenericTicketToken(Consts.Users[userKey]);
            tokenContainer.RealUser = new GenericTicketToken(Consts.Users[userKey]);

            DeluxeIdentity identity = new DeluxeIdentity(tokenContainer, null);

            DeluxePrincipal principal = new DeluxePrincipal(identity);

            PrincipaContextAccessor.SetPrincipalInContext(WfClientServiceBrokerContext.Current, principal);
        }
        private static void DoPrincipalAction(IUser user, Action action)
        {
            IPrincipal originalPrincipal = Thread.CurrentPrincipal;

            try
            {
                if (user != null)
                {
                    DeluxeIdentity identity = new DeluxeIdentity(user);
                    Thread.CurrentPrincipal = new DeluxePrincipal(identity);
                }

                if (action != null)
                    action();
            }
            finally
            {
                Thread.CurrentPrincipal = originalPrincipal;
            }
        }