コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["User"] == null)
        {
            Response.Redirect("../Login.aspx");
            Response.End();
        }
        m_User = (CUser)Session["User"];

        m_Company = (CCompany)Global.GetCtx(Session["TopCompany"].ToString()).CompanyMgr.Find(m_User.B_Company_id);

        string TbCode         = Request["TbCode"];
        string id             = Request["id"];
        string WF_Workflow_id = Request["WF_Workflow_id"];

        if (string.IsNullOrEmpty(TbCode) ||
            string.IsNullOrEmpty(id) ||
            string.IsNullOrEmpty(WF_Workflow_id))
        {
            Response.Write("数据不完整!");
            Response.End();
            return;
        }

        string ParentId = Request["ParentId"];

        if (!string.IsNullOrEmpty(ParentId))
        {
            m_guidParentId = new Guid(ParentId);
        }

        m_BaseObjectMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(TbCode, m_guidParentId);
        if (m_BaseObjectMgr == null)
        {
            m_BaseObjectMgr        = new CBaseObjectMgr();
            m_BaseObjectMgr.TbCode = TbCode;
            m_BaseObjectMgr.Ctx    = Global.GetCtx(Session["TopCompany"].ToString());
        }

        m_BaseObject = m_BaseObjectMgr.Find(new Guid(id));

        m_Workflow = (CWorkflow)m_BaseObjectMgr.WorkflowMgr.Find(new Guid(WF_Workflow_id));
        if (m_Workflow.State != enumApprovalState.Running)
        {
            Response.Write("只有进行中的工作流才能审批!");
            Response.End();
            return;
        }
        m_Actives = m_Workflow.ActivesMgr.FindNotApproval();
        if (m_Actives == null)
        {
            Response.Write("没有审批的活动!");
            Response.End();
            return;
        }

        if (m_Actives.AType == "按用户")
        {
            if (m_Actives.B_User_id != m_User.Id)
            {
                Response.Write("没有权限审批!");
                Response.End();
                return;
            }
        }
        else //按角色
        {
            CRole Role = (CRole)m_Company.RoleMgr.Find(m_Actives.B_Role_id);
            if (Role == null || Role.UserInRoleMgr.FindByUserid(m_User.Id) == null)
            {
                Response.Write("没有权限审批!");
                Response.End();
                return;
            }
        }

        if (Request.Params["Action"] == "Accept")
        {
            Accept();
            Response.End();
        }
        else if (Request.Params["Action"] == "Reject")
        {
            Reject();
            Response.End();
        }
    }
コード例 #2
0
    void PostData()
    {
        string UType       = Request["UType"];
        string Uid         = Request["Uid"];
        string GroupId     = Request["GroupId"];
        Guid   guidGroupId = Guid.Empty;

        if (!string.IsNullOrEmpty(GroupId))
        {
            guidGroupId = new Guid(GroupId);
        }
        string postData = Request["postData"];
        CUser  user     = null;
        CRole  role     = null;

        if (UType == "0") //用户
        {
            user = (CUser)Global.GetCtx(Session["TopCompany"].ToString()).UserMgr.Find(new Guid(Uid));

            user.UserMenuMgr.RemoveByDesktopGroupId(guidGroupId);
            string[] arr1 = postData.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (string sItem1 in arr1)
            {
                Guid      menuid   = new Guid(sItem1);
                CUserMenu UserMenu = new CUserMenu();
                UserMenu.B_User_id          = user.Id;
                UserMenu.UI_Menu_id         = menuid;
                UserMenu.UI_DesktopGroup_id = guidGroupId;

                CUser user0 = (CUser)Session["User"];
                UserMenu.Creator = user0.Id;
                user.UserMenuMgr.AddNew(UserMenu);
            }
            if (!user.UserMenuMgr.Save(true))
            {
                Response.Write("保存失败!");
            }
        }
        else if (UType == "1") //角色
        {
            role = (CRole)m_Company.RoleMgr.Find(new Guid(Uid));

            role.RoleMenuMgr.RemoveByDesktopGroupId(guidGroupId);
            string[] arr1 = postData.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (string sItem1 in arr1)
            {
                Guid      menuid   = new Guid(sItem1);
                CRoleMenu RoleMenu = new CRoleMenu();
                RoleMenu.B_Role_id          = role.Id;
                RoleMenu.UI_Menu_id         = menuid;
                RoleMenu.UI_DesktopGroup_id = guidGroupId;

                CUser user0 = (CUser)Session["User"];
                RoleMenu.Creator = user0.Id;
                role.RoleMenuMgr.AddNew(RoleMenu);
            }
            if (!role.RoleMenuMgr.Save(true))
            {
                Response.Write("保存失败!");
            }
        }
    }
コード例 #3
0
    void GetActivesData()
    {
        CWorkflowDef       WorkflowDef = GetWorkflowDef();
        List <CBaseObject> lstObj      = WorkflowDef.ActivesDefMgr.GetList();
        //按序号排序
        SortedList <int, CActivesDef> sortObj = new SortedList <int, CActivesDef>();

        foreach (CBaseObject obj in lstObj)
        {
            CActivesDef ActivesDef = (CActivesDef)obj;
            sortObj.Add(ActivesDef.Idx, ActivesDef);
        }
        CActivesDef SuccessActivesDef = null;
        CActivesDef FailureActivesDef = null;

        string sData = "";

        foreach (KeyValuePair <int, CActivesDef> pair in sortObj)
        {
            CActivesDef ActivesDef = pair.Value;
            if (ActivesDef.WType == ActivesType.Success)
            {
                SuccessActivesDef = ActivesDef;
                continue;
            }
            if (ActivesDef.WType == ActivesType.Failure)
            {
                FailureActivesDef = ActivesDef;
                continue;
            }
            CUser  User = (CUser)Global.GetCtx(Session["TopCompany"].ToString()).UserMgr.Find(ActivesDef.B_User_id);
            CRole  Role = (CRole)Global.GetCtx(Session["TopCompany"].ToString()).CompanyMgr.FindTopCompany().RoleMgr.Find(ActivesDef.B_Role_id);
            string AType = "", UserName = "", RoleName = "";
            AType    = ActivesDef.AType;
            UserName = (User != null) ? User.Name : "";
            RoleName = (Role != null) ? Role.Name : "";

            sData += string.Format("{{ \"id\": \"{0}\",\"Name\":\"{1}\", \"Idx\":\"{2}\", \"WType\":\"{3}\", \"AType\":\"{4}\", \"UserName\":\"{5}\", \"RoleName\":\"{6}\" }},"
                                   , ActivesDef.Id
                                   , ActivesDef.Name
                                   , ActivesDef.Idx
                                   , ActivesDef.WType
                                   , AType
                                   , UserName
                                   , RoleName);
        }

        //成功/失败结束活动放最后
        if (SuccessActivesDef != null)
        {
            sData += string.Format("{{ \"id\": \"{0}\",\"Name\":\"{1}\", \"Idx\":\"{2}\", \"WType\":\"{3}\", \"B_User_id\":\"{4}\", \"UserName\":\"{5}\" }},"
                                   , SuccessActivesDef.Id
                                   , SuccessActivesDef.Name
                                   , SuccessActivesDef.Idx
                                   , SuccessActivesDef.WType
                                   , SuccessActivesDef.B_User_id
                                   , "");
        }
        if (FailureActivesDef != null)
        {
            sData += string.Format("{{ \"id\": \"{0}\",\"Name\":\"{1}\", \"Idx\":\"{2}\", \"WType\":\"{3}\", \"B_User_id\":\"{4}\", \"UserName\":\"{5}\" }},"
                                   , FailureActivesDef.Id
                                   , FailureActivesDef.Name
                                   , FailureActivesDef.Idx
                                   , FailureActivesDef.WType
                                   , FailureActivesDef.B_User_id
                                   , "");
        }

        sData = "[" + sData + "]";
        string sJson = string.Format("{{\"Rows\":{0},\"Total\":\"{1}\"}}"
                                     , sData, lstObj.Count);

        Response.Write(sJson);
    }
コード例 #4
0
    void GetData()
    {
        string UType = Request["UType"];
        string Uid   = Request["Uid"];
        CUser  user  = null;
        CRole  role  = null;

        if (UType == "0") //用户
        {
            if (!string.IsNullOrEmpty(Uid))
            {
                user = (CUser)Global.GetCtx(Session["TopCompany"].ToString()).UserMgr.Find(new Guid(Uid));
            }
        }
        else if (UType == "1") //角色
        {
            if (!string.IsNullOrEmpty(Uid))
            {
                role = (CRole)m_Company.RoleMgr.Find(new Guid(Uid));
            }
        }

        string             sData  = "";
        List <CBaseObject> lstObj = Global.GetCtx(Session["TopCompany"].ToString()).ViewMgr.GetList();

        foreach (CBaseObject obj in lstObj)
        {
            CView view   = (CView)obj;
            int   iRead  = 0;
            int   iWrite = 0;
            if (UType == "0" && user != null) //用户
            {
                //管理员有所有权限
                if (user.IsRole("管理员"))
                {
                    iRead  = 1;
                    iWrite = 1;
                }
                else
                {
                    CViewAccessInUser vaiu = user.ViewAccessInUserMgr.FindByView(view.Id);
                    if (vaiu != null)
                    {
                        if (vaiu.Access == AccessType.read)
                        {
                            iRead = 1;
                        }
                        else if (vaiu.Access == AccessType.write)
                        {
                            iRead  = 1;
                            iWrite = 1;
                        }
                    }
                }
            }
            else if (UType == "1" && role != null) //用户
            {
                //管理员有所有权限
                if (role.Name == "管理员")
                {
                    iRead  = 1;
                    iWrite = 1;
                }
                else
                {
                    CViewAccessInRole vair = role.ViewAccessInRoleMgr.FindByView(view.Id);
                    if (vair != null)
                    {
                        if (vair.Access == AccessType.read)
                        {
                            iRead = 1;
                        }
                        else if (vair.Access == AccessType.write)
                        {
                            iRead  = 1;
                            iWrite = 1;
                        }
                    }
                }
            }
            string sRow = string.Format("\"id\":\"{0}\",\"Name\":\"{1}\",\"Read\":\"{2}\",\"Write\":\"{3}\",", view.Id, view.Name, iRead, iWrite);

            sRow   = "{" + sRow + "},";
            sData += sRow;
        }
        sData = sData.TrimEnd(",".ToCharArray());
        sData = "[" + sData + "]";
        string sJson = string.Format("{{\"Rows\":{0},\"Total\":\"{1}\"}}"
                                     , sData, lstObj.Count);

        Response.Write(sJson);
    }
コード例 #5
0
    void PostData()
    {
        string UType    = Request["UType"];
        string Uid      = Request["Uid"];
        string postData = Request["postData"];
        CUser  user     = null;
        CRole  role     = null;

        if (UType == "0") //用户
        {
            user = (CUser)Global.GetCtx(Session["TopCompany"].ToString()).UserMgr.Find(new Guid(Uid));
            //管理员有所有权限,不能修改!
            if (user.IsRole("管理员"))
            {
                Response.Write("管理员有所有权限,不能修改!");
                return;
            }
            //
            string[] arr1 = postData.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (string sItem1 in arr1)
            {
                string[]          arr2   = sItem1.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                Guid              viewid = new Guid(arr2[0]);
                CViewAccessInUser vaiu   = user.ViewAccessInUserMgr.FindByView(viewid);
                if (vaiu == null)
                {
                    vaiu            = new CViewAccessInUser();
                    vaiu.UI_View_id = viewid;
                    vaiu.B_User_id  = user.Id;
                    if (arr2[2] == "1")
                    {
                        vaiu.Access = AccessType.write;
                    }
                    else if (arr2[1] == "1")
                    {
                        vaiu.Access = AccessType.read;
                    }
                    else
                    {
                        vaiu.Access = AccessType.forbide;
                    }

                    CUser user0 = (CUser)Session["User"];
                    vaiu.Creator = user0.Id;
                    user.ViewAccessInUserMgr.AddNew(vaiu);
                }
                else
                {
                    if (arr2[2] == "1")
                    {
                        vaiu.Access = AccessType.write;
                    }
                    else if (arr2[1] == "1")
                    {
                        vaiu.Access = AccessType.read;
                    }
                    else
                    {
                        vaiu.Access = AccessType.forbide;
                    }

                    CUser user0 = (CUser)Session["User"];
                    vaiu.Updator = user0.Id;
                    user.ViewAccessInUserMgr.Update(vaiu);
                }
            }
            if (!user.ViewAccessInUserMgr.Save(true))
            {
                Response.Write("保存失败!");
            }
        }
        else if (UType == "1") //角色
        {
            role = (CRole)m_Company.RoleMgr.Find(new Guid(Uid));
            //管理员有所有权限,不能修改!
            if (role.Name == "管理员")
            {
                Response.Write("管理员有所有权限,不能修改!");
                return;
            }
            //
            string[] arr1 = postData.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (string sItem1 in arr1)
            {
                string[]          arr2   = sItem1.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                Guid              viewid = new Guid(arr2[0]);
                CViewAccessInRole vair   = role.ViewAccessInRoleMgr.FindByView(viewid);
                if (vair == null)
                {
                    vair            = new CViewAccessInRole();
                    vair.UI_View_id = viewid;
                    vair.B_Role_id  = role.Id;
                    if (arr2[2] == "1")
                    {
                        vair.Access = AccessType.write;
                    }
                    else if (arr2[1] == "1")
                    {
                        vair.Access = AccessType.read;
                    }
                    else
                    {
                        vair.Access = AccessType.forbide;
                    }

                    CUser user0 = (CUser)Session["User"];
                    vair.Creator = user0.Id;
                    role.ViewAccessInRoleMgr.AddNew(vair);
                }
                else
                {
                    if (arr2[2] == "1")
                    {
                        vair.Access = AccessType.write;
                    }
                    else if (arr2[1] == "1")
                    {
                        vair.Access = AccessType.read;
                    }
                    else
                    {
                        vair.Access = AccessType.forbide;
                    }

                    CUser user0 = (CUser)Session["User"];
                    vair.Updator = user0.Id;
                    role.ViewAccessInRoleMgr.Update(vair);
                }
            }
            if (!role.ViewAccessInRoleMgr.Save(true))
            {
                Response.Write("保存失败!");
            }
        }
    }
コード例 #6
0
ファイル: DesktopPanel.cs プロジェクト: stonezhu870/RapidCore
        void LoadList()
        {
            if (string.IsNullOrEmpty(Program.User.Name))
            {
                return;
            }

            this.flowLayoutPanel.Controls.Clear();

            if (Program.User.IsRole("管理员") && m_guidDesktopGroupId == Guid.Empty)
            {
                DesktopItem adminBox = new DesktopItem();
                adminBox.Title      = "系统管理";
                adminBox.Icon       = "admin.png";
                adminBox.ItemType   = enumDesktopItemType.Admin;
                adminBox.ClickItem += new ClickEventHandler(adminBox_ClickItem);
                this.flowLayoutPanel.Controls.Add(adminBox);
            }
            //用户菜单
            List <CBaseObject> lstObj = Program.User.UserMenuMgr.GetList();

            foreach (CBaseObject obj in lstObj)
            {
                CUserMenu UserMenu = (CUserMenu)obj;
                if (UserMenu.UI_DesktopGroup_id != m_guidDesktopGroupId)
                {
                    continue;
                }
                CMenu menu = (CMenu)Program.Ctx.MenuMgr.Find(UserMenu.UI_Menu_id);
                if (menu == null)
                {
                    continue;
                }

                DesktopItem Item = new DesktopItem();
                Item.Title        = menu.Name;
                Item.Icon         = menu.IconUrl;
                Item.ItemType     = (enumDesktopItemType)Convert.ToInt32(menu.MType);
                Item.m_BaseObject = menu;
                Item.ClickItem   += new ClickEventHandler(menu_ClickItem);
                this.flowLayoutPanel.Controls.Add(Item);
            }
            //角色菜单
            CCompany Company = (CCompany)Program.Ctx.CompanyMgr.Find(Program.User.B_Company_id);

            if (Company != null)
            {
                List <CBaseObject> lstObjR = Company.RoleMgr.GetList();
                foreach (CBaseObject objR in lstObjR)
                {
                    CRole Role = (CRole)objR;
                    if (!Program.User.IsRole(Role.Name))
                    {
                        continue;
                    }
                    List <CBaseObject> lstObjRM = Role.RoleMenuMgr.GetList();
                    foreach (CBaseObject objRM in lstObjRM)
                    {
                        CRoleMenu RoleMenu = (CRoleMenu)objRM;
                        if (RoleMenu.UI_DesktopGroup_id != m_guidDesktopGroupId)
                        {
                            continue;
                        }
                        CMenu menu = (CMenu)Program.Ctx.MenuMgr.Find(RoleMenu.UI_Menu_id);
                        if (menu == null)
                        {
                            continue;
                        }

                        DesktopItem Item = new DesktopItem();
                        Item.Title        = menu.Name;
                        Item.Icon         = menu.IconUrl;
                        Item.ItemType     = (enumDesktopItemType)Convert.ToInt32(menu.MType);
                        Item.m_BaseObject = menu;
                        Item.ClickItem   += new ClickEventHandler(menu_ClickItem);
                        this.flowLayoutPanel.Controls.Add(Item);
                    }
                }
            }
            //应用
            lstObj = Program.User.DesktopAppMgr.GetList();
            foreach (CBaseObject obj in lstObj)
            {
                CDesktopApp App = (CDesktopApp)obj;
                if (App.UI_DesktopGroup_id != m_guidDesktopGroupId)
                {
                    continue;
                }

                DesktopItem Item = new DesktopItem();
                Item.Title        = App.Name;
                Item.Icon         = App.IconUrl;
                Item.ItemType     = enumDesktopItemType.DesktopApp;
                Item.m_BaseObject = App;
                Item.ClickItem   += new ClickEventHandler(App_ClickItem);
                Item.ClickClose  += new ClickEventHandler(App_ClickClose);
                this.flowLayoutPanel.Controls.Add(Item);
            }
            //添加
            DesktopItem addBox = new DesktopItem();

            addBox.Title      = "添加应用";
            addBox.Icon       = "add.png";
            addBox.ItemType   = enumDesktopItemType.AddDesktopApp;
            addBox.ClickItem += new ClickEventHandler(addBox_ClickItem);
            this.flowLayoutPanel.Controls.Add(addBox);
        }
コード例 #7
0
    void GetData()
    {
        string UType = Request["UType"];
        string Uid   = Request["Uid"];
        CUser  user  = null;
        CRole  role  = null;

        if (UType == "0") //用户
        {
            if (!string.IsNullOrEmpty(Uid))
            {
                user = (CUser)Global.GetCtx(Session["TopCompany"].ToString()).UserMgr.Find(new Guid(Uid));
            }
        }
        else if (UType == "1") //角色
        {
            if (!string.IsNullOrEmpty(Uid))
            {
                role = (CRole)m_Company.RoleMgr.Find(new Guid(Uid));
            }
        }
        string FW_Table_id = Request["FW_Table_id"];
        CTable table       = null;

        if (!string.IsNullOrEmpty(FW_Table_id))
        {
            table = (CTable)Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Find(new Guid(FW_Table_id));
        }

        string sData  = "";
        int    iCount = 0;

        if (table != null)
        {
            List <CBaseObject> lstObj = table.ColumnMgr.GetList();
            iCount = lstObj.Count;

            foreach (CBaseObject obj in lstObj)
            {
                CColumn column = (CColumn)obj;
                int     iRead  = 0;
                int     iWrite = 0;
                if (UType == "0" && user != null) //用户
                {
                    //管理员有所有权限
                    if (user.IsRole("管理员"))
                    {
                        iRead  = 1;
                        iWrite = 1;
                    }
                    else
                    {
                        CColumnAccessInUser caiu = user.ColumnAccessInUserMgr.FindByColumn(column.Id);
                        if (caiu != null)
                        {
                            if (caiu.Access == AccessType.read)
                            {
                                iRead = 1;
                            }
                            else if (caiu.Access == AccessType.write)
                            {
                                iRead  = 1;
                                iWrite = 1;
                            }
                        }
                        else  //没有手动设置字段权限, 则默认都可写
                        {
                            iRead  = 1;
                            iWrite = 1;
                        }
                    }
                }
                else if (UType == "1" && role != null) //用户
                {
                    //管理员有所有权限
                    if (role.Name == "管理员")
                    {
                        iRead  = 1;
                        iWrite = 1;
                    }
                    else
                    {
                        CColumnAccessInRole cair = role.ColumnAccessInRoleMgr.FindByColumn(column.Id);
                        if (cair != null)
                        {
                            if (cair.Access == AccessType.read)
                            {
                                iRead = 1;
                            }
                            else if (cair.Access == AccessType.write)
                            {
                                iRead  = 1;
                                iWrite = 1;
                            }
                        }
                        else  //没有手动设置字段权限, 则默认都可写
                        {
                            iRead  = 1;
                            iWrite = 1;
                        }
                    }
                }
                string sRow = string.Format("\"id\":\"{0}\",\"Name\":\"{1}\",\"Read\":\"{2}\",\"Write\":\"{3}\",", column.Id, column.Name, iRead, iWrite);

                sRow   = "{" + sRow + "},";
                sData += sRow;
            }
        }
        sData = sData.TrimEnd(",".ToCharArray());
        sData = "[" + sData + "]";
        string sJson = string.Format("{{\"Rows\":{0},\"Total\":\"{1}\"}}"
                                     , sData, iCount);

        Response.Write(sJson);
    }