Beispiel #1
0
        public string DSJob_Submit(string json1)
        {
            JObject item         = (JObject)JsonConvert.DeserializeObject(json1);
            string  WorkFlowName = item["Work_Name"].ToString();
            // WorkFlows ws = new WorkFlows();
            int  workflow_id           = wfs.GetWorkFlowDefine(WorkFlowName).W_ID;
            Jobs job                   = new Jobs();
            List <Timer_Jobs> job_list = job.GetDSbyWorkflow(workflow_id);

            if (job_list.Count == 0)
            {
                string         cj_ids = item["Cj_Name"].ToString();
                string         Zz_ids = item["Zz_Name"].ToString();
                string[]       cjids  = cj_ids.Split(new char[] { ',' });
                string[]       zzids  = Zz_ids.Split(new char[] { ',' });
                CTimerCreateWF m      = new CTimerCreateWF();
                //这里需要创建一个回调函数
                string DingShiJobName = item["Job_Name"].ToString();

                //使用lambda表达式过滤掉空字符串
                zzids = zzids.Where(s => !string.IsNullOrEmpty(s)).ToArray();
                //未写
                if (WorkFlowName == "A6dot2")
                {
                    for (int i = 0; i < cjids.Count(); i++)
                    {
                        TimerCreateWFPa             TCP    = new TimerCreateWFPa();//
                        Dictionary <string, string> param  = new Dictionary <string, string>();
                        Dictionary <string, string> record = new Dictionary <string, string>();
                        param.Add("Cj_Name", Em.getEa_namebyId(Convert.ToInt16(cjids[i])));
                        record.Add("username", "system_scheduled");
                        record.Add("time", DateTime.Now.ToString());
                        TCP.wf_params = param;
                        TCP.wf_record = record;
                        m.AppendCreateParam(TCP);

                        TimerCreateWFPa.TimerSetting time_set = new TimerCreateWFPa.TimerSetting();
                        time_set.Time_start  = "wf_create";
                        time_set.Exact_time  = "";
                        time_set.Offset_time = (DateTime.Now.AddDays(5) - DateTime.Now).ToString();
                        //time_set.Offset_time = (DateTime.Now.AddMinutes(3) - DateTime.Now).ToString();
                        time_set.Action    = "INVILID";
                        time_set.Call_back = "http://localhost/CallBack/testCallBack";
                        TCP.AppendTimer("Xc_Sample", time_set);
                    }
                }
                if (WorkFlowName == "A15dot1")
                {
                    List <string> pq_list = new List <string>();
                    pq_list.Add("联合一片区");
                    pq_list.Add("联合二片区");
                    pq_list.Add("联合三片区");
                    pq_list.Add("联合四片区");
                    pq_list.Add("化工片区");
                    pq_list.Add("综合片区");
                    pq_list.Add("其他");
                    //pq_list.Add("检修单位");
                    for (int i = 0; i < pq_list.Count(); i++)
                    {
                        TimerCreateWFPa             TCP    = new TimerCreateWFPa();//
                        Dictionary <string, string> param  = new Dictionary <string, string>();
                        Dictionary <string, string> record = new Dictionary <string, string>();
                        param.Add("Pqname", pq_list[i]);
                        record.Add("username", "system_scheduled");
                        record.Add("time", DateTime.Now.ToString());
                        TCP.wf_params = param;
                        TCP.wf_record = record;
                        m.AppendCreateParam(TCP);


                        TimerCreateWFPa.TimerSetting time_set = new TimerCreateWFPa.TimerSetting();
                        time_set.Time_start  = "wf_create";
                        time_set.Exact_time  = "";
                        time_set.Offset_time = (DateTime.Now.AddDays(1) - DateTime.Now).ToString();
                        //time_set.Offset_time = (DateTime.Now.AddMinutes(3) - DateTime.Now).ToString();
                        time_set.Action    = "INVILID";
                        time_set.Call_back = "http://localhost/CallBack/testCallBack";
                        TCP.AppendTimer("ZzSubmit", time_set);
                    }
                }
                else if (WorkFlowName == "A5dot1dot2")
                {
                    for (int i = 0; i < zzids.Count(); i++)
                    {
                        TimerCreateWFPa             TCP    = new TimerCreateWFPa();//
                        Dictionary <string, string> param  = new Dictionary <string, string>();
                        Dictionary <string, string> record = new Dictionary <string, string>();
                        param.Add("Zz_Name", Em.getEa_namebyId(Convert.ToInt16(zzids[i])));
                        record.Add("username", "system_scheduled");
                        record.Add("time", DateTime.Now.ToString());
                        TCP.wf_params = param;
                        TCP.wf_record = record;
                        m.AppendCreateParam(TCP);

                        TimerCreateWFPa.TimerSetting time_set = new TimerCreateWFPa.TimerSetting();
                        time_set.Time_start  = "wf_create";
                        time_set.Exact_time  = "";
                        time_set.Offset_time = (DateTime.Now.AddDays(5) - DateTime.Now).ToString();
                        //time_set.Offset_time = (DateTime.Now.AddMinutes(3) - DateTime.Now).ToString();
                        time_set.Action    = "INVILID";
                        time_set.Call_back = "http://localhost/CallBack/testCallBack";
                        TCP.AppendTimer("ZzSubmit", time_set);
                    }
                }
                else if (WorkFlowName == "A5dot2dot2")
                {
                    for (int i = 0; i < zzids.Count(); i++)
                    {
                        TimerCreateWFPa             TCP    = new TimerCreateWFPa();//
                        Dictionary <string, string> param  = new Dictionary <string, string>();
                        Dictionary <string, string> record = new Dictionary <string, string>();
                        param.Add("Zz_Name", Em.getEa_namebyId(Convert.ToInt16(zzids[i])));
                        record.Add("username", "system_scheduled");
                        record.Add("time", DateTime.Now.ToString());
                        TCP.wf_params = param;
                        TCP.wf_record = record;
                        m.AppendCreateParam(TCP);

                        TimerCreateWFPa.TimerSetting time_set = new TimerCreateWFPa.TimerSetting();
                        time_set.Time_start  = "wf_create";
                        time_set.Exact_time  = "";
                        time_set.Offset_time = (DateTime.Now.AddDays(5) - DateTime.Now).ToString();
                        //time_set.Offset_time = (DateTime.Now.AddMinutes(3) - DateTime.Now).ToString();
                        time_set.Action    = "INVILID";
                        time_set.Call_back = "http://localhost/CallBack/testCallBack";
                        TCP.AppendTimer("ZzSubmit", time_set);
                    }
                }
                else if (WorkFlowName == "A11dot2dot2")
                {
                    for (int i = 0; i < zzids.Count(); i++)
                    {
                        TimerCreateWFPa             TCP    = new TimerCreateWFPa();//
                        Dictionary <string, string> param  = new Dictionary <string, string>();
                        Dictionary <string, string> record = new Dictionary <string, string>();
                        param.Add("Zz_Name", Em.getEa_namebyId(Convert.ToInt16(zzids[i])));
                        record.Add("username", "system_scheduled");
                        record.Add("time", DateTime.Now.ToString());
                        TCP.wf_params = param;
                        TCP.wf_record = record;
                        m.AppendCreateParam(TCP);

                        TimerCreateWFPa.TimerSetting time_set = new TimerCreateWFPa.TimerSetting();
                        time_set.Time_start  = "wf_create";
                        time_set.Exact_time  = "";
                        time_set.Offset_time = (DateTime.Now.AddDays(5) - DateTime.Now).ToString();
                        //time_set.Offset_time = (DateTime.Now.AddMinutes(3) - DateTime.Now).ToString();
                        time_set.Action    = "INVILID";
                        time_set.Call_back = "http://localhost/CallBack/testCallBack";
                        TCP.AppendTimer("ZzSubmit", time_set);
                    }
                }
                if (WorkFlowName == "A12dot2dot1")
                {
                    for (int i = 0; i < zzids.Count(); i++)
                    {
                        TimerCreateWFPa             TCP    = new TimerCreateWFPa();//
                        Dictionary <string, string> param  = new Dictionary <string, string>();
                        Dictionary <string, string> record = new Dictionary <string, string>();
                        param.Add("Zz_Name", Em.getEa_namebyId(Convert.ToInt16(zzids[i])));
                        record.Add("username", "system_scheduled");
                        record.Add("time", DateTime.Now.ToString());
                        TCP.wf_params = param;
                        TCP.wf_record = record;
                        m.AppendCreateParam(TCP);

                        TimerCreateWFPa.TimerSetting time_set = new TimerCreateWFPa.TimerSetting();
                        time_set.Time_start  = "wf_create";
                        time_set.Exact_time  = "";
                        time_set.Offset_time = (DateTime.Now.AddDays(5) - DateTime.Now).ToString();
                        time_set.Action      = "INVILID";
                        time_set.Call_back   = "http://localhost/CallBack/testCallBack";
                        TCP.AppendTimer("ZzSubmit", time_set);
                    }
                }
                else if (WorkFlowName == "A6dot3")
                {
                    for (int i = 0; i < cjids.Count(); i++)
                    {
                        TimerCreateWFPa             TCP    = new TimerCreateWFPa();//
                        Dictionary <string, string> param  = new Dictionary <string, string>();
                        Dictionary <string, string> record = new Dictionary <string, string>();
                        param.Add("Zz_Name", Em.getEa_namebyId(Convert.ToInt16(zzids[i])));
                        record.Add("username", "system_scheduled");
                        record.Add("time", DateTime.Now.ToString());
                        TCP.wf_params = param;
                        TCP.wf_record = record;
                        m.AppendCreateParam(TCP);

                        TimerCreateWFPa.TimerSetting time_set = new TimerCreateWFPa.TimerSetting();
                        time_set.Time_start  = "wf_create";
                        time_set.Exact_time  = "";
                        time_set.Offset_time = (DateTime.Now.AddDays(1) - DateTime.Now).ToString();
                        time_set.Action      = "INVILID";
                        time_set.Call_back   = "http://localhost/CallBack/testCallBack";
                        TCP.AppendTimer("Ineligible_Submit", time_set);
                    }
                }
                else if (WorkFlowName == "A7dot1dot1")
                {
                    List <Equip_Info> Th_sb = new List <Equip_Info>();
                    EquipManagment    Epm   = new EquipManagment();
                    Th_sb = Epm.getAllThEquips();
                    for (int i = 0; i < Th_sb.Count(); i++)
                    {
                        TimerCreateWFPa             TCP    = new TimerCreateWFPa();//
                        Dictionary <string, string> param  = new Dictionary <string, string>();
                        Dictionary <string, string> record = new Dictionary <string, string>();
                        param.Add("Equip_GyCode", Th_sb[i].Equip_GyCode);
                        record.Add("username", "system_scheduled");
                        record.Add("time", DateTime.Now.ToString());
                        TCP.wf_params = param;
                        TCP.wf_record = record;
                        m.AppendCreateParam(TCP);

                        TimerCreateWFPa.TimerSetting time_set = new TimerCreateWFPa.TimerSetting();
                        time_set.Time_start  = "wf_create";
                        time_set.Exact_time  = "";
                        time_set.Offset_time = (DateTime.Now.AddDays(1) - DateTime.Now).ToString();
                        time_set.Action      = "INVILID";
                        time_set.Call_back   = "http://localhost/CallBack/testCallBack";
                        TCP.AppendTimer("ZzSubmit", time_set);
                    }
                }
                else if (WorkFlowName == "A14dot2")
                {
                    for (int i = 0; i < zzids.Count(); i++)
                    {
                        TimerCreateWFPa             TCP    = new TimerCreateWFPa();//
                        Dictionary <string, string> param  = new Dictionary <string, string>();
                        Dictionary <string, string> record = new Dictionary <string, string>();
                        param.Add("Zz_Name", Em.getEa_namebyId(Convert.ToInt16(zzids[i])));
                        record.Add("username", "system_scheduled");
                        record.Add("time", DateTime.Now.ToString());
                        TCP.wf_params = param;
                        TCP.wf_record = record;
                        m.AppendCreateParam(TCP);

                        TimerCreateWFPa.TimerSetting time_set = new TimerCreateWFPa.TimerSetting();
                        time_set.Time_start  = "wf_create";
                        time_set.Exact_time  = "";
                        time_set.Action      = "INVILID";
                        time_set.Call_back   = "http://localhost/CallBack/testCallBack";
                        time_set.Offset_time = (DateTime.Now.AddDays(5) - DateTime.Now).ToString();
                        TCP.AppendTimer("JxdwSubmit", time_set);
                        //TCP.AppendTimer("ZzConfirm", time_set);
                    }
                }
                else if (WorkFlowName == "A14dot3dot2")
                {
                    for (int i = 0; i < zzids.Count(); i++)
                    {
                        TimerCreateWFPa             TCP    = new TimerCreateWFPa();//
                        Dictionary <string, string> param  = new Dictionary <string, string>();
                        Dictionary <string, string> record = new Dictionary <string, string>();
                        param.Add("Zz_Name", Em.getEa_namebyId(Convert.ToInt16(zzids[i])));
                        record.Add("username", "system_scheduled");
                        record.Add("time", DateTime.Now.ToString());
                        TCP.wf_params = param;
                        TCP.wf_record = record;
                        m.AppendCreateParam(TCP);

                        TimerCreateWFPa.TimerSetting time_set = new TimerCreateWFPa.TimerSetting();
                        time_set.Time_start  = "wf_create";
                        time_set.Exact_time  = "";
                        time_set.Offset_time = (DateTime.Now.AddDays(5) - DateTime.Now).ToString();
                        time_set.Action      = "SUSPEND";
                        time_set.Call_back   = "http://localhost/CallBack/testCallBack";
                        TCP.AppendTimer("ZzSubmit", time_set);
                    }
                }



                string corn            = "0 0 0 * * ?";
                string corn_express    = item["corn_express"].ToString();
                string ReservationTime = item["reservationtime"].ToString();
                m.Set_Res_Value("STR_RES_2", ReservationTime);
                corn         = corn_express;
                m.for_using  = TIMER_USING.FOR_CUSTOM;
                m.CreateTime = DateTime.Now;
                m.SetTriggerTiming(corn);
                m.mission_name = item["Job_Name"].ToString();
                m.status       = TM_STATUS.TM_STATUS_ACTIVE;
                //m.CreateCallback = "/zxhtest/QxFunction?depts="+Depts+"";//和权限有关的回调函数
                m.CustomFlag = 0;

                WorkFlow_Define wfd = wfs.GetWorkFlowDefineByID(workflow_id);

                m.attachTarget(wfd);
                m.GetAttachWorkFlow();//0910
                m.Save();

                CTimerManage.ActiveListActionForMission(m);
                return("成功发起定时任务");
            }
            else
            {
                return("该工作流已经提报过,请删除后再发起");
            }
        }