コード例 #1
0
ファイル: WF_WorkOpt_OneWork.cs プロジェクト: splanton/CCFlow
        /// <summary>
        /// 获取流程的JSON数据,以供显示工作轨迹/流程设计
        /// </summary>
        /// <param name="fk_flow">流程编号</param>
        /// <param name="workid">工作编号</param>
        /// <param name="fid">父流程编号</param>
        /// <returns></returns>
        public string Chart_Init()
        {
            string fk_flow = this.FK_Flow;
            Int64  workid  = this.WorkID;
            Int64  fid     = this.FID;

            DataSet   ds   = new DataSet();
            DataTable dt   = null;
            string    json = string.Empty;

            try
            {
                //获取流程信息
                var sql = "SELECT No \"No\", Name \"Name\", Paras \"Paras\", ChartType \"ChartType\" FROM WF_Flow WHERE No='" + fk_flow + "'";
                dt           = DBAccess.RunSQLReturnTable(sql);
                dt.TableName = "WF_Flow";
                ds.Tables.Add(dt);

                //获取流程中的节点信息
                sql = "SELECT NodeID \"ID\", Name \"Name\", ICON \"Icon\", X \"X\", Y \"Y\", NodePosType \"NodePosType\",RunModel \"RunModel\",HisToNDs \"HisToNDs\",TodolistModel \"TodolistModel\" FROM WF_Node WHERE FK_Flow='" +
                      fk_flow + "' ORDER BY Step";
                dt           = DBAccess.RunSQLReturnTable(sql);
                dt.TableName = "WF_Node";
                ds.Tables.Add(dt);

                //获取流程中的标签信息
                sql          = "SELECT MyPK \"MyPK\", Name \"Name\", X \"X\", Y \"Y\" FROM WF_LabNote WHERE FK_Flow='" + fk_flow + "'";
                dt           = DBAccess.RunSQLReturnTable(sql);
                dt.TableName = "WF_LabNote";
                ds.Tables.Add(dt);

                //获取流程中的线段方向信息
                sql          = "SELECT Node \"Node\", ToNode \"ToNode\", 0 as  \"DirType\", 0 as \"IsCanBack\",Dots \"Dots\" FROM WF_Direction WHERE FK_Flow='" + fk_flow + "'";
                dt           = DBAccess.RunSQLReturnTable(sql);
                dt.TableName = "WF_Direction";
                ds.Tables.Add(dt);

                if (workid != 0)
                {
                    //获取流程信息,added by liuxc,2016-10-26
                    //sql =
                    //    "SELECT wgwf.Starter,wgwf.StarterName,wgwf.RDT,wgwf.WFSta,wgwf.WFState FROM WF_GenerWorkFlow wgwf WHERE wgwf.WorkID = " +
                    //    workid;
                    sql = "SELECT wgwf.Starter as \"Starter\","
                          + "        wgwf.StarterName as \"StarterName\","
                          + "        wgwf.RDT as \"RDT\","
                          + "        wgwf.WFSta as \"WFSta\","
                          + "        se.Lab  as   \"WFStaText\","
                          + "        wgwf.WFState as \"WFState\","
                          + "        wgwf.FID as \"FID\","
                          + "        wgwf.PWorkID as \"PWorkID\","
                          + "        wgwf.PFlowNo as \"PFlowNo\","
                          + "        wgwf.PNodeID as \"PNodeID\","
                          + "        wgwf.FK_Flow as \"FK_Flow\","
                          + "        wgwf.FK_Node as \"FK_Node\","
                          + "        wgwf.Title as \"Title\","
                          + "        wgwf.WorkID as \"WorkID\","
                          + "        wgwf.NodeName as \"NodeName\","
                          + "        wf.Name  as   \"FlowName\""
                          + " FROM   WF_GenerWorkFlow wgwf"
                          + "        INNER JOIN WF_Flow wf"
                          + "             ON  wf.No = wgwf.FK_Flow"
                          + "        INNER JOIN Sys_Enum se"
                          + "             ON  se.IntKey = wgwf.WFSta"
                          + "             AND se.EnumKey = 'WFSta'"
                          + " WHERE  wgwf.WorkID = {0}"
                          + "        OR  wgwf.FID = {0}"
                          + "        OR  wgwf.PWorkID = {0}"
                          + " ORDER BY"
                          + "        wgwf.RDT DESC";

                    dt           = DBAccess.RunSQLReturnTable(string.Format(sql, workid));
                    dt.TableName = "FlowInfo";
                    ds.Tables.Add(dt);

                    //获得流程状态.
                    WFState wfState = (WFState)int.Parse(dt.Rows[0]["WFState"].ToString());

                    String fk_Node = dt.Rows[0]["FK_Node"].ToString();
                    //把节点审核配置信息.
                    FrmWorkCheck fwc = new FrmWorkCheck(fk_Node);
                    ds.Tables.Add(fwc.ToDataTableField("FrmWorkCheck"));


                    //获取工作轨迹信息
                    var trackTable = "ND" + int.Parse(fk_flow) + "Track";
                    sql = "SELECT FID \"FID\",NDFrom \"NDFrom\",NDFromT \"NDFromT\",NDTo  \"NDTo\", NDToT \"NDToT\", ActionType \"ActionType\",ActionTypeText \"ActionTypeText\",Msg \"Msg\",RDT \"RDT\",EmpFrom \"EmpFrom\",EmpFromT \"EmpFromT\", EmpToT \"EmpToT\",EmpTo \"EmpTo\" FROM " + trackTable +
                          " WHERE WorkID=" +
                          workid + (fid == 0 ? (" OR FID=" + workid) : (" OR WorkID=" + fid + " OR FID=" + fid)) + " ORDER BY RDT ASC";

                    dt = DBAccess.RunSQLReturnTable(sql);

                    //判断轨迹数据中,最后一步是否是撤销或退回状态的,如果是,则删除最后2条数据
                    if (dt.Rows.Count > 0)
                    {
                        if (Equals(dt.Rows[0]["ACTIONTYPE"], (int)ActionType.Return) || Equals(dt.Rows[0]["ACTIONTYPE"], (int)ActionType.UnSend))
                        {
                            if (dt.Rows.Count > 1)
                            {
                                dt.Rows.RemoveAt(0);
                                dt.Rows.RemoveAt(0);
                            }
                            else
                            {
                                dt.Rows.RemoveAt(0);
                            }
                        }
                    }

                    dt.TableName = "Track";
                    ds.Tables.Add(dt);

                    //获取预先计算的节点处理人,以及处理时间,added by liuxc,2016-4-15
                    sql = "SELECT wsa.FK_Node as \"FK_Node\",wsa.FK_Emp as \"FK_Emp\",wsa.EmpName as \"EmpName\",wsa.TimeLimit as \"TimeLimit\",wsa.TSpanHour as \"TSpanHour\",wsa.ADT as \"ADT\",wsa.SDT as \"SDT\" FROM WF_SelectAccper wsa WHERE wsa.WorkID = " + workid;
                    dt  = DBAccess.RunSQLReturnTable(sql);
                    // dt.TableName = "POSSIBLE";
                    dt.TableName = "Possible";
                    ds.Tables.Add(dt);

                    //获取节点处理人数据,及处理/查看信息
                    sql = "SELECT wgw.FK_Emp as \"FK_Emp\",wgw.FK_Node as \"FK_Node\",wgw.FK_EmpText as \"FK_EmpText\",wgw.RDT as \"RDT\",wgw.IsRead as \"IsRead\",wgw.IsPass as \"IsPass\" FROM WF_GenerWorkerlist wgw WHERE wgw.WorkID = " +
                          workid + (fid == 0 ? (" OR FID=" + workid) : (" OR WorkID=" + fid + " OR FID=" + fid));
                    dt           = DBAccess.RunSQLReturnTable(sql);
                    dt.TableName = "DISPOSE";
                    ds.Tables.Add(dt);



                    //如果流程没有完成.
                    if (wfState != WFState.Complete)
                    {
                        GenerWorkerLists gwls = new GenerWorkerLists();
                        Int64            id   = this.FID;
                        if (id == 0)
                        {
                            id = this.WorkID;
                        }

                        QueryObject qo = new QueryObject(gwls);
                        qo.AddWhere(GenerWorkerListAttr.FID, id);
                        qo.addOr();
                        qo.AddWhere(GenerWorkerListAttr.WorkID, id);
                        qo.DoQuery();

                        DataTable dtGwls = gwls.ToDataTableField("WF_GenerWorkerList");
                        ds.Tables.Add(dtGwls);
                    }
                }
                else
                {
                    var trackTable = "ND" + int.Parse(fk_flow) + "Track";
                    sql = "SELECT NDFrom \"NDFrom\", NDTo \"NDTo\",ActionType \"ActionType\",ActionTypeText \"ActionTypeText\",Msg \"Msg\",RDT \"RDT\",EmpFrom \"EmpFrom\",EmpFromT \"EmpFromT\",EmpToT \"EmpToT\",EmpTo \"EmpTo\" FROM " + trackTable +
                          " WHERE WorkID=0 ORDER BY RDT ASC";
                    dt           = DBAccess.RunSQLReturnTable(sql);
                    dt.TableName = "TRACK";
                    ds.Tables.Add(dt);
                }

                //for (int i = 0; i < ds.Tables.Count; i++)
                //{
                //    dt = ds.Tables[i];
                //    dt.TableName = dt.TableName.ToUpper();
                //    for (int j = 0; j < dt.Columns.Count; j++)
                //    {
                //        dt.Columns[j].ColumnName = dt.Columns[j].ColumnName.ToUpper();
                //    }
                //}

                string str = BP.Tools.Json.DataSetToJson(ds);
                //  DataType.WriteFile("c:\\GetFlowTrackJsonData_CCflow.txt", str);
                return(str);
            }
            catch (Exception ex)
            {
                return("err@" + ex.Message);
            }
            return(json);
        }
コード例 #2
0
ファイル: WF_WorkOpt_OneWork.cs プロジェクト: splanton/CCFlow
        /// <summary>
        /// 时间轴
        /// </summary>
        /// <returns></returns>
        public string TimeBase_Init()
        {
            DataSet ds = new DataSet();

            //获取track.
            DataTable dt = BP.WF.Dev2Interface.DB_GenerTrackTable(this.FK_Flow, this.WorkID, this.FID);

            ds.Tables.Add(dt);


            #region  父子流程数据存储到这里.
            Hashtable ht = new Hashtable();
            foreach (DataRow dr in dt.Rows)
            {
                ActionType at = (ActionType)int.Parse(dr[TrackAttr.ActionType].ToString());

                string tag  = dr[TrackAttr.Tag].ToString();  //标识.
                string mypk = dr[TrackAttr.MyPK].ToString(); //主键.

                string msg = "";
                if (at == ActionType.CallChildenFlow)
                {
                    //被调用父流程吊起。
                    if (DataType.IsNullOrEmpty(tag) == false)
                    {
                        AtPara        ap    = new AtPara(tag);
                        GenerWorkFlow mygwf = new GenerWorkFlow();
                        mygwf.WorkID = ap.GetValInt64ByKey("PWorkID");
                        if (mygwf.RetrieveFromDBSources() == 1)
                        {
                            msg = "<p>操作员:{" + dr[TrackAttr.EmpFromT].ToString() + "}在当前节点上,被父流程{" + mygwf.FlowName + "},<a target=b" + ap.GetValStrByKey("PWorkID") + " href='Track.aspx?WorkID=" + ap.GetValStrByKey("PWorkID") + "&FK_Flow=" + ap.GetValStrByKey("PFlowNo") + "' >" + msg + "</a></p>";
                        }
                        else
                        {
                            msg = "<p>操作员:{" + dr[TrackAttr.EmpFromT].ToString() + "}在当前节点上,被父流程调用{" + mygwf.FlowName + "},但是该流程被删除了.</p>" + tag;
                        }

                        msg = "<a target=b" + ap.GetValStrByKey("PWorkID") + " href='Track.aspx?WorkID=" + ap.GetValStrByKey("PWorkID") + "&FK_Flow=" + ap.GetValStrByKey("PFlowNo") + "' >" + msg + "</a>";
                    }

                    //放入到ht里面.
                    ht.Add(mypk, msg);
                }

                if (at == ActionType.StartChildenFlow)
                {
                    if (DataType.IsNullOrEmpty(tag) == false)
                    {
                        if (tag.Contains("Sub"))
                        {
                            tag = tag.Replace("Sub", "C");
                        }

                        AtPara        ap    = new AtPara(tag);
                        GenerWorkFlow mygwf = new GenerWorkFlow();
                        mygwf.WorkID = ap.GetValInt64ByKey("CWorkID");
                        if (mygwf.RetrieveFromDBSources() == 1)
                        {
                            msg  = "<p>操作员:{" + dr[TrackAttr.EmpFromT].ToString() + "}在当前节点上调用了子流程{" + mygwf.FlowName + "}, <a target=b" + ap.GetValStrByKey("CWorkID") + " href='Track.aspx?WorkID=" + ap.GetValStrByKey("CWorkID") + "&FK_Flow=" + ap.GetValStrByKey("CFlowNo") + "' >" + msg + "</a></p>";
                            msg += "<p>当前子流程状态:{" + mygwf.WFStateText + "},运转到:{" + mygwf.NodeName + "},最后处理人{" + mygwf.TodoEmps + "},最后处理时间{" + mygwf.RDT + "}。</p>";
                        }
                        else
                        {
                            msg = "<p>操作员:{" + dr[TrackAttr.EmpFromT].ToString() + "}在当前节点上调用了子流程{" + mygwf.FlowName + "},但是该流程被删除了.</p>" + tag;
                        }
                    }

                    //放入到ht里面.
                    ht.Add(mypk, msg);
                }
            }
            #endregion

            //获取 WF_GenerWorkFlow
            GenerWorkFlow gwf = new GenerWorkFlow();
            gwf.WorkID = this.WorkID;
            gwf.RetrieveFromDBSources();
            ds.Tables.Add(gwf.ToDataTableField("WF_GenerWorkFlow"));

            if (gwf.WFState != WFState.Complete)
            {
                GenerWorkerLists gwls = new GenerWorkerLists();
                gwls.Retrieve(GenerWorkerListAttr.WorkID, this.WorkID);

                ds.Tables.Add(gwls.ToDataTableField("WF_GenerWorkerList"));
            }

            //把节点审核配置信息.
            FrmWorkCheck fwc = new FrmWorkCheck(gwf.FK_Node);
            ds.Tables.Add(fwc.ToDataTableField("FrmWorkCheck"));

            //返回结果.
            return(BP.Tools.Json.DataSetToJson(ds, false));
        }