コード例 #1
0
        /// <summary>
        /// 初始化节点属性列表.
        /// </summary>
        /// <returns></returns>
        public string NodeAttrs_Init()
        {
            var strFlowId = GetRequestVal("FK_Flow");

            if (DataType.IsNullOrEmpty(strFlowId))
            {
                return("err@参数错误!");
            }

            Nodes nodes = new Nodes();

            nodes.Retrieve("FK_Flow", strFlowId);
            //因直接使用nodes.ToJson()无法获取某些字段(e.g.HisFormTypeText,原因:Node没有自己的Attr类)
            //故此处手动创建前台所需的DataTable
            DataTable dt = new DataTable();

            dt.Columns.Add("NodeID");      //节点ID
            dt.Columns.Add("Name");        //节点名称
            dt.Columns.Add("HisFormType"); //表单方案
            dt.Columns.Add("HisFormTypeText");
            dt.Columns.Add("HisRunModel"); //节点类型
            dt.Columns.Add("HisRunModelT");

            dt.Columns.Add("HisDeliveryWay");   //接收方类型
            dt.Columns.Add("HisDeliveryWayText");
            dt.Columns.Add("HisDeliveryWayJsFnPara");
            dt.Columns.Add("HisDeliveryWayCountLabel");
            dt.Columns.Add("HisDeliveryWayCount"); //接收方Count

            dt.Columns.Add("HisCCRole");           //抄送人
            dt.Columns.Add("HisCCRoleText");
            dt.Columns.Add("HisFrmEventsCount");   //消息&事件Count
            dt.Columns.Add("HisFinishCondsCount"); //流程完成条件Count
            DataRow dr;

            foreach (Node node in nodes)
            {
                dr                       = dt.NewRow();
                dr["NodeID"]             = node.NodeID;
                dr["Name"]               = node.Name;
                dr["HisFormType"]        = node.HisFormType;
                dr["HisFormTypeText"]    = node.HisFormTypeText;
                dr["HisRunModel"]        = node.HisRunModel;
                dr["HisRunModelT"]       = node.HisRunModelT;
                dr["HisDeliveryWay"]     = node.HisDeliveryWay;
                dr["HisDeliveryWayText"] = node.HisDeliveryWayText;

                //接收方数量
                var intHisDeliveryWayCount = 0;
                if (node.HisDeliveryWay == BP.WF.DeliveryWay.ByStation)
                {
                    dr["HisDeliveryWayJsFnPara"]   = "ByStation";
                    dr["HisDeliveryWayCountLabel"] = "岗位";
                    BP.WF.Template.NodeStations nss = new BP.WF.Template.NodeStations();
                    intHisDeliveryWayCount = nss.Retrieve(BP.WF.Template.NodeStationAttr.FK_Node, node.NodeID);
                }
                else if (node.HisDeliveryWay == BP.WF.DeliveryWay.ByDept)
                {
                    dr["HisDeliveryWayJsFnPara"]   = "ByDept";
                    dr["HisDeliveryWayCountLabel"] = "部门";
                    BP.WF.Template.NodeDepts nss = new BP.WF.Template.NodeDepts();
                    intHisDeliveryWayCount = nss.Retrieve(BP.WF.Template.NodeDeptAttr.FK_Node, node.NodeID);
                }
                else if (node.HisDeliveryWay == BP.WF.DeliveryWay.ByBindEmp)
                {
                    dr["HisDeliveryWayJsFnPara"]   = "ByDept";
                    dr["HisDeliveryWayCountLabel"] = "人员";
                    BP.WF.Template.NodeEmps nes = new BP.WF.Template.NodeEmps();
                    intHisDeliveryWayCount = nes.Retrieve(BP.WF.Template.NodeStationAttr.FK_Node, node.NodeID);
                }
                dr["HisDeliveryWayCount"] = intHisDeliveryWayCount;

                //抄送
                dr["HisCCRole"]     = node.HisCCRole;
                dr["HisCCRoleText"] = node.HisCCRoleText;

                //消息&事件Count
                BP.Sys.FrmEvents fes = new BP.Sys.FrmEvents();
                dr["HisFrmEventsCount"] = fes.Retrieve(BP.Sys.FrmEventAttr.FK_MapData, "ND" + node.NodeID);

                //流程完成条件Count
                BP.WF.Template.Conds conds = new BP.WF.Template.Conds(BP.WF.Template.CondType.Flow, node.NodeID);
                dr["HisFinishCondsCount"] = conds.Count;

                dt.Rows.Add(dr);
            }
            return(BP.Tools.Json.ToJson(dt));
        }
コード例 #2
0
        /// <summary>
        /// 获取指定部门下一级子部门及人员列表
        /// </summary>
        /// <returns></returns>
        public string Dot2DotStationModel_GetSubUnits()
        {
            string parentid = this.GetRequestVal("parentid");
            string nid      = this.GetRequestVal("nodeid");
            string tp       = this.GetRequestVal("stype"); //ST,UNIT
            string ttype    = this.GetRequestVal("ttype"); //STROOT,UNITROOT,ST,CST,S

            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>();
            string    sql = string.Empty;
            DataTable dt  = null;

            BP.WF.Template.NodeStations sts = new BP.WF.Template.NodeStations();
            string sortField = CheckStationTypeIdxExists() ? "Idx" : "No";

            sts.Retrieve(BP.WF.Template.NodeStationAttr.FK_Node, int.Parse(nid));

            if (tp == "ST")
            {
                if (ttype == "STROOT")
                {
                    sql = "SELECT No,Name FROM Port_StationType ORDER BY " + sortField + " ASC";
                    dt  = DBAccess.RunSQLReturnTable(sql);

                    foreach (DataRow row in dt.Rows)
                    {
                        node                     = new EasyuiTreeNode();
                        node.id                  = "ST_" + row["No"];
                        node.text                = row["Name"] as string;
                        node.iconCls             = "icon-department";
                        node.attributes          = new EasyuiTreeNodeAttributes();
                        node.attributes.No       = row["No"] as string;
                        node.attributes.Name     = row["Name"] as string;
                        node.attributes.ParentNo = "-1";
                        node.attributes.TType    = "ST";
                        node.state               = "closed";
                        node.children            = new List <EasyuiTreeNode>();
                        node.children.Add(new EasyuiTreeNode());
                        node.children[0].text = "loading...";

                        d.Add(node);
                    }
                }
                else
                {
                    sql =
                        string.Format(
                            "SELECT ps.No,ps.Name,ps.FK_StationType,pst.Name FK_StationTypeName FROM Port_Station ps"
                            + " INNER JOIN Port_StationType pst ON pst.No = ps.FK_StationType"
                            + " WHERE ps.FK_StationType = '{0}' ORDER BY ps.Name ASC", parentid);
                    dt = DBAccess.RunSQLReturnTable(sql);

                    foreach (DataRow row in dt.Rows)
                    {
                        node          = new EasyuiTreeNode();
                        node.id       = "S_" + parentid + "_" + row["No"];
                        node.text     = row["Name"] as string;
                        node.iconCls  = "icon-user";
                        node.@checked =
                            sts.GetEntityByKey(BP.WF.Template.NodeStationAttr.FK_Station, row["No"]) != null;
                        node.attributes            = new EasyuiTreeNodeAttributes();
                        node.attributes.No         = row["No"] as string;
                        node.attributes.Name       = row["Name"] as string;
                        node.attributes.ParentNo   = row["FK_StationType"] as string;
                        node.attributes.ParentName = row["FK_StationTypeName"] as string;
                        node.attributes.TType      = "S";
                        node.attributes.Code       = BP.Tools.chs2py.ConvertStr2Code(row["Name"] as string);

                        d.Add(node);
                    }
                }
            }
            else
            {
                //岗位所属单位UNIT
                dt = DBAccess.RunSQLReturnTable(string.Format("SELECT * FROM Port_Dept WHERE IsUnit = 1 AND ParentNo='{0}' ORDER BY Name ASC", parentid));

                foreach (DataRow dept in dt.Rows)
                {
                    node                     = new EasyuiTreeNode();
                    node.id                  = "UNIT_" + dept["No"];
                    node.text                = dept["Name"] as string;
                    node.iconCls             = "icon-department";
                    node.attributes          = new EasyuiTreeNodeAttributes();
                    node.attributes.No       = dept["No"] as string;
                    node.attributes.Name     = dept["Name"] as string;
                    node.attributes.ParentNo = dept["ParentNo"] as string;
                    node.attributes.TType    = "UNIT";
                    node.attributes.Code     = BP.Tools.chs2py.ConvertStr2Code(dept["Name"] as string);
                    node.state               = "closed";
                    node.children            = new List <EasyuiTreeNode>();
                    node.children.Add(new EasyuiTreeNode());
                    node.children[0].text = "loading...";

                    d.Add(node);
                }

                dt = DBAccess.RunSQLReturnTable(
                    string.Format(
                        "SELECT ps.No,ps.Name,pst.No FK_StationType, pst.Name FK_StationTypeName,ps.FK_Unit,pd.Name FK_UnitName FROM Port_Station ps"
                        + " INNER JOIN Port_StationType pst ON pst.No = ps.FK_StationType"
                        + " INNER JOIN Port_Dept pd ON pd.No = ps.FK_Unit"
                        + " WHERE ps.FK_Unit = '{0}' ORDER BY pst.{1} ASC,ps.Name ASC", parentid, sortField));

                //增加岗位
                foreach (DataRow st in dt.Rows)
                {
                    node                       = new EasyuiTreeNode();
                    node.id                    = "S_" + st["FK_Unit"] + "_" + st["No"];
                    node.text                  = st["Name"] + "[" + st["FK_StationTypeName"] + "]";
                    node.iconCls               = "icon-user";
                    node.@checked              = sts.GetEntityByKey(BP.WF.Template.NodeStationAttr.FK_Station, st["No"]) != null;
                    node.attributes            = new EasyuiTreeNodeAttributes();
                    node.attributes.No         = st["No"] as string;
                    node.attributes.Name       = st["Name"] as string;
                    node.attributes.ParentNo   = st["FK_Unit"] as string;
                    node.attributes.ParentName = st["FK_UnitName"] as string;
                    node.attributes.TType      = "S";
                    node.attributes.Code       = BP.Tools.chs2py.ConvertStr2Code(st["Name"] as string);

                    d.Add(node);
                }
            }

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