Esempio n. 1
0
        private string GetStructureTreeTable()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("NO", typeof(string));
            dt.Columns.Add("PARENTNO", typeof(string));
            dt.Columns.Add("NAME", typeof(string));
            dt.Columns.Add("TTYPE", typeof(string));

            if (BP.WF.Glo.OSModel == OSModel.OneOne)
            {
                BP.WF.Port.Depts depts = new BP.WF.Port.Depts();
                depts.RetrieveAll();
                BP.WF.Port.Stations sts = new BP.WF.Port.Stations();
                sts.RetrieveAll();
                BP.WF.Port.Emps emps = new BP.WF.Port.Emps();
                emps.RetrieveAll(BP.WF.Port.EmpAttr.Name);
                BP.WF.Port.EmpStations empsts = new BP.WF.Port.EmpStations();
                empsts.RetrieveAll();
                BP.GPM.DeptEmps empdetps = new BP.GPM.DeptEmps();
                empdetps.RetrieveAll();

                //部门人员
                Dictionary <string, List <string> > des = new Dictionary <string, List <string> >();
                //岗位人员
                Dictionary <string, List <string> > ses = new Dictionary <string, List <string> >();
                //部门岗位
                Dictionary <string, List <string> > dss = new Dictionary <string, List <string> >();
                BP.WF.Port.Station stt  = null;
                BP.WF.Port.Emp     empt = null;

                foreach (BP.WF.Port.Dept dept in depts)
                {
                    //增加部门
                    dt.Rows.Add(dept.No, dept.ParentNo, dept.Name, "DEPT");
                    des.Add(dept.No, new List <string>());
                    dss.Add(dept.No, new List <string>());

                    //获取部门下的岗位
                    empdetps.Retrieve(BP.GPM.DeptEmpAttr.FK_Dept, dept.No);
                    foreach (BP.GPM.DeptEmp empdept in empdetps)
                    {
                        des[dept.No].Add(empdept.FK_Emp);
                        //判断该人员拥有的岗位
                        empsts.Retrieve(BP.WF.Port.EmpStationAttr.FK_Emp, empdept.FK_Emp);
                        foreach (BP.WF.Port.EmpStation es in empsts)
                        {
                            if (ses.ContainsKey(es.FK_Station))
                            {
                                if (ses[es.FK_Station].Contains(es.FK_Emp) == false)
                                {
                                    ses[es.FK_Station].Add(es.FK_Emp);
                                }
                            }
                            else
                            {
                                ses.Add(es.FK_Station, new List <string> {
                                    es.FK_Emp
                                });
                            }

                            //增加部门的岗位
                            if (dss[dept.No].Contains(es.FK_Station) == false)
                            {
                                stt = sts.GetEntityByKey(es.FK_Station) as BP.WF.Port.Station;

                                if (stt == null)
                                {
                                    continue;
                                }

                                dss[dept.No].Add(es.FK_Station);
                                dt.Rows.Add(dept.No + "|" + es.FK_Station, dept.No, stt.Name, "STATION");
                            }
                        }
                    }
                }

                foreach (KeyValuePair <string, List <string> > ds in dss)
                {
                    foreach (string st in ds.Value)
                    {
                        foreach (string emp in ses[st])
                        {
                            empt = emps.GetEntityByKey(emp) as BP.WF.Port.Emp;

                            if (empt == null)
                            {
                                continue;
                            }

                            dt.Rows.Add(ds.Key + "|" + st + "|" + emp, ds.Key + "|" + st, empt.Name, "EMP");
                        }
                    }
                }
            }
            else
            {
                BP.GPM.Depts depts = new BP.GPM.Depts();
                depts.RetrieveAll();
                BP.GPM.Stations sts = new BP.GPM.Stations();
                sts.RetrieveAll();
                BP.GPM.Emps emps = new BP.GPM.Emps();
                emps.RetrieveAll(BP.WF.Port.EmpAttr.Name);
                BP.GPM.DeptStations dss = new BP.GPM.DeptStations();
                dss.RetrieveAll();
                BP.GPM.DeptEmpStations dess = new BP.GPM.DeptEmpStations();
                dess.RetrieveAll();
                BP.GPM.Station stt  = null;
                BP.GPM.Emp     empt = null;

                foreach (BP.GPM.Dept dept in depts)
                {
                    //增加部门
                    dt.Rows.Add(dept.No, dept.ParentNo, dept.Name, "DEPT");

                    //增加部门岗位
                    dss.Retrieve(BP.GPM.DeptStationAttr.FK_Dept, dept.No);
                    foreach (BP.GPM.DeptStation ds in dss)
                    {
                        stt = sts.GetEntityByKey(ds.FK_Station) as BP.GPM.Station;

                        if (stt == null)
                        {
                            continue;
                        }

                        dt.Rows.Add(dept.No + "|" + ds.FK_Station, dept.No, stt.Name, "STATION");

                        //增加部门岗位人员
                        dess.Retrieve(BP.GPM.DeptEmpStationAttr.FK_Dept, dept.No, BP.GPM.DeptEmpStationAttr.FK_Station,
                                      ds.FK_Station);

                        foreach (BP.GPM.DeptEmpStation des in dess)
                        {
                            empt = emps.GetEntityByKey(des.FK_Emp) as BP.GPM.Emp;

                            if (empt == null)
                            {
                                continue;
                            }

                            dt.Rows.Add(dept.No + "|" + ds.FK_Station + "|" + des.FK_Emp, dept.No + "|" + ds.FK_Station,
                                        empt.Name, "EMP");
                        }
                    }
                }
            }

            return(Newtonsoft.Json.JsonConvert.SerializeObject(dt));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取指定部门下一级子部门及人员列表
        /// </summary>
        /// <returns></returns>
        public string Dot2DotTreeDeptEmpModel_GetSubDepts()
        {
            string parentid = this.GetRequestVal("parentid");
            string nid      = this.GetRequestVal("nodeid");

            if (string.IsNullOrWhiteSpace(parentid))
            {
                throw new Exception("参数parentid不能为空");
            }
            if (string.IsNullOrWhiteSpace(nid))
            {
                throw new Exception("参数nodeid不能为空");
            }

            EasyuiTreeNode        node = null;
            List <EasyuiTreeNode> d    = new List <EasyuiTreeNode>();

            BP.WF.Template.NodeEmps semps = new BP.WF.Template.NodeEmps();

            semps.Retrieve(BP.WF.Template.NodeEmpAttr.FK_Node, int.Parse(nid));

            if (BP.WF.Glo.OSModel == OSModel.OneOne)
            {
                BP.Port.Dept  parentDept = new BP.Port.Dept(parentid);
                BP.Port.Depts depts      = new BP.Port.Depts();
                depts.Retrieve(BP.Port.DeptAttr.ParentNo, parentid, BP.Port.DeptAttr.Name);
                BP.Port.Emps emps = new BP.Port.Emps();
                emps.Retrieve(BP.Port.EmpAttr.FK_Dept, parentid, BP.Port.EmpAttr.Name);

                //增加部门
                foreach (BP.Port.Dept dept in depts)
                {
                    node                     = new EasyuiTreeNode();
                    node.id                  = "DEPT_" + dept.No;
                    node.text                = dept.Name;
                    node.iconCls             = "icon-department";
                    node.attributes          = new EasyuiTreeNodeAttributes();
                    node.attributes.No       = dept.No;
                    node.attributes.Name     = dept.Name;
                    node.attributes.ParentNo = dept.ParentNo;
                    node.attributes.TType    = "DEPT";
                    node.attributes.Code     = BP.Tools.chs2py.ConvertStr2Code(dept.Name);
                    node.state               = "closed";
                    node.children            = new List <EasyuiTreeNode>();
                    node.children.Add(new EasyuiTreeNode());
                    node.children[0].text = "loading...";

                    d.Add(node);
                }

                //增加人员
                foreach (BP.Port.Emp emp in emps)
                {
                    node                       = new EasyuiTreeNode();
                    node.id                    = "EMP_" + parentid + "_" + emp.No;
                    node.text                  = emp.Name;
                    node.iconCls               = "icon-user";
                    node.@checked              = semps.GetEntityByKey(BP.WF.Template.NodeEmpAttr.FK_Emp, emp.No) != null;
                    node.attributes            = new EasyuiTreeNodeAttributes();
                    node.attributes.No         = emp.No;
                    node.attributes.Name       = emp.Name;
                    node.attributes.ParentNo   = parentDept.No;
                    node.attributes.ParentName = parentDept.Name;
                    node.attributes.TType      = "EMP";
                    node.attributes.Code       = BP.Tools.chs2py.ConvertStr2Code(emp.Name);

                    d.Add(node);
                }
            }
            else
            {
                BP.GPM.Dept  parentDept = new BP.GPM.Dept(parentid);
                BP.GPM.Depts depts      = new BP.GPM.Depts();
                depts.Retrieve(BP.GPM.DeptAttr.ParentNo, parentid, BP.GPM.DeptAttr.Name);
                BP.GPM.DeptEmps des = new BP.GPM.DeptEmps();
                des.Retrieve(BP.GPM.DeptEmpAttr.FK_Dept, parentid);
                BP.GPM.Emps emps = new BP.GPM.Emps();
                emps.RetrieveAll(BP.GPM.EmpAttr.Name);
                BP.GPM.Emp emp = null;

                //增加部门
                foreach (BP.GPM.Dept dept in depts)
                {
                    node                       = new EasyuiTreeNode();
                    node.id                    = "DEPT_" + dept.No;
                    node.text                  = dept.Name;
                    node.iconCls               = "icon-department";
                    node.attributes            = new EasyuiTreeNodeAttributes();
                    node.attributes.No         = dept.No;
                    node.attributes.Name       = dept.Name;
                    node.attributes.ParentNo   = parentDept.No;
                    node.attributes.ParentName = parentDept.Name;
                    node.attributes.TType      = "DEPT";
                    node.attributes.Code       = BP.Tools.chs2py.ConvertStr2Code(dept.Name);
                    node.state                 = "closed";
                    node.children              = new List <EasyuiTreeNode>();
                    node.children.Add(new EasyuiTreeNode());
                    node.children[0].text = "loading...";

                    d.Add(node);
                }

                //增加人员
                foreach (BP.GPM.DeptEmp de in des)
                {
                    emp = emps.GetEntityByKey(BP.GPM.EmpAttr.No, de.FK_Emp) as BP.GPM.Emp;

                    if (emp == null)
                    {
                        continue;
                    }

                    node                       = new EasyuiTreeNode();
                    node.id                    = "EMP_" + parentid + "_" + emp.No;
                    node.text                  = emp.Name;
                    node.iconCls               = "icon-user";
                    node.@checked              = semps.GetEntityByKey(BP.WF.Template.NodeEmpAttr.FK_Emp, emp.No) != null;
                    node.attributes            = new EasyuiTreeNodeAttributes();
                    node.attributes.No         = emp.No;
                    node.attributes.Name       = emp.Name;
                    node.attributes.ParentNo   = parentDept.No;
                    node.attributes.ParentName = parentDept.Name;
                    node.attributes.TType      = "EMP";
                    node.attributes.Code       = BP.Tools.chs2py.ConvertStr2Code(emp.Name);

                    d.Add(node);
                }
            }

            return(Newtonsoft.Json.JsonConvert.SerializeObject(d));
        }