protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //lhm 批处理
            if (!string.IsNullOrEmpty(Request.QueryString["WorkIDs"]))
            {
                string   strWorkIDs = Request.QueryString["WorkIDs"];
                string[] workIDList = strWorkIDs.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

                var taskIDList          = new List <string>();
                var subTaskIDList       = new List <string>();
                var monitorResultIDList = new List <string>();

                foreach (var workID in workIDList)
                {
                    var monitorResult = new TMisMonitorResultLogic().Details(new TMisMonitorResultVo {
                        CCFLOW_ID1 = workID
                    });
                    monitorResultIDList.Add(monitorResult.ID);

                    var parentWorkid = CCFlowFacade.GetFatherIDOfSubFlow(LogInfo.UserInfo.USER_NAME, Convert.ToInt64(workID));

                    TMisContractPlanVo objPlanVo = new TMisContractPlanLogic().DetailsByCCFlowID(parentWorkid.ToString());

                    if (objPlanVo.ID.Length > 0 && objPlanVo.REAMRK1 == "1")
                    {
                        var tempTaskId = new TMisMonitorTaskLogic().Details(new TMisMonitorTaskVo {
                            PLAN_ID = objPlanVo.ID
                        }).ID;
                        if (!taskIDList.Contains(tempTaskId))
                        {
                            //当前流程属于送样的
                            taskIDList.Add(tempTaskId);
                            subTaskIDList.Add("");
                        }
                    }
                    else if (objPlanVo.ID.Length > 0)
                    {
                        //当前流程属于采样的
                        var taskId = new TMisMonitorTaskLogic().Details(new TMisMonitorTaskVo {
                            PLAN_ID = objPlanVo.ID
                        }).ID;

                        if (!taskIDList.Contains(taskId))
                        {
                            TMisMonitorSubtaskVo sub = new TMisMonitorSubtaskVo();
                            sub.TASK_ID = taskId;
                            DataTable dt = new TMisMonitorSubtaskLogic().SelectByTable(sub);

                            foreach (DataRow row in dt.Rows)
                            {
                                taskIDList.Add(taskId);
                                var subTaskId = row["ID"].ToString();
                                subTaskIDList.Add(subTaskId);
                            }
                        }
                    }
                }

                this.TASK_ID.Value      = string.Join(",", taskIDList);
                this.SUBTASK_ID.Value   = string.Join(",", subTaskIDList);
                this.hidResultIDs.Value = string.Join(",", monitorResultIDList);
            }
            else if (!string.IsNullOrEmpty(Request.QueryString["WorkID"]))
            {
                var FID = Convert.ToInt64(Request.QueryString["WorkID"]); //获取主流程ID

                var monitorResult = new TMisMonitorResultLogic().Details(new TMisMonitorResultVo {
                    CCFLOW_ID1 = FID.ToString()
                });
                this.hidResultIDs.Value = monitorResult.ID;

                var workid = CCFlowFacade.GetFatherIDOfSubFlow(LogInfo.UserInfo.USER_NAME, FID);

                TMisContractPlanVo objPlanVo = new TMisContractPlanLogic().DetailsByCCFlowID(workid.ToString());

                if (objPlanVo.ID.Length > 0 && objPlanVo.REAMRK1 == "1")
                {
                    //当前流程属于送样的
                    this.TASK_ID.Value = new TMisMonitorTaskLogic().Details(new TMisMonitorTaskVo {
                        PLAN_ID = objPlanVo.ID
                    }).ID;
                    this.SUBTASK_ID.Value = "";
                }
                else if (objPlanVo.ID.Length > 0)
                {
                    //当前流程属于采样的
                    this.TASK_ID.Value = new TMisMonitorTaskLogic().Details(new TMisMonitorTaskVo {
                        PLAN_ID = objPlanVo.ID
                    }).ID;
                    TMisMonitorSubtaskVo sub = new TMisMonitorSubtaskVo();
                    sub.TASK_ID = this.TASK_ID.Value;
                    DataTable dt = new TMisMonitorSubtaskLogic().SelectByTable(sub);
                    this.SUBTASK_ID.Value = dt.Rows[0]["ID"].ToString();
                }

                ////常规监测
                //if (string.IsNullOrEmpty(this.TASK_ID.Value))
                //{
                //    TMisContractPlanVo objPlanVo = new TMisContractPlanLogic().DetailsByCCFlowID(workid.ToString());

                //    if (objPlanVo.ID.Length > 0 && objPlanVo.REAMRK1 == "1")
                //    {
                //        //当前流程属于送样的
                //        this.TASK_ID.Value = new TMisMonitorTaskLogic().Details(new TMisMonitorTaskVo { PLAN_ID = objPlanVo.ID }).ID;
                //        this.SUBTASK_ID.Value = "";
                //    }
                //    else if (objPlanVo.ID.Length > 0)
                //    {
                //        //当前流程属于采样的
                //        this.TASK_ID.Value = new TMisMonitorTaskLogic().Details(new TMisMonitorTaskVo { PLAN_ID = objPlanVo.ID }).ID;
                //        TMisMonitorSubtaskVo sub = new TMisMonitorSubtaskVo();
                //        sub.TASK_ID = this.TASK_ID.Value;
                //        DataTable dt = new TMisMonitorSubtaskLogic().SelectByTable(sub);
                //        this.SUBTASK_ID.Value = dt.Rows[0]["ID"].ToString();

                //    }
                //}
            }

            //定义结果
            string strResult = "";

            //任务信息
            if (Request["type"] != null && Request["type"].ToString() == "getOneGridInfo")
            {
                strResult = getOneGridInfo(Request["strTaskID"].ToString(), Request["strSubTaskID"].ToString());
                Response.Write(strResult);
                Response.End();
            }

            //获取样品信息
            if (Request["type"] != null && Request["type"].ToString() == "getSampleGridInfo")
            {
                strResult = getSampleGridInfo(Request["strTaskID"].ToString());
                Response.Write(strResult);
                Response.End();
            }
            //获取监测项目信息
            if (Request["type"] != null && Request["type"].ToString() == "getItemGridInfo")
            {
                strResult = getItemGridInfo(Request["SampleGridId"].ToString());
                Response.Write(strResult);
                Response.End();
            }
            //获取现场质控信息
            if (Request["type"] != null && Request["type"].ToString() == "getQCGrid1Info")
            {
                strResult = getQCGrid1Info(Request["ResultId"].ToString(), Request["strItemID"].ToString());
                Response.Write(strResult);
                Response.End();
            }
            //获取实验室质控信息
            if (Request["type"] != null && Request["type"].ToString() == "getQCGrid2Info")
            {
                strResult = getQCGrid2Info(Request["ResultId"].ToString());
                Response.Write(strResult);
                Response.End();
            }
        }
    }