예제 #1
0
        public JsonResult ListKeyParams(int defId)
        {
            List <object> pars = new List <object>();

            if (defId == -1)
            {
                return(Json(new { data = pars.ToArray() }));
            }

            CWorkFlow   wf  = new CWorkFlow();
            WorkFlows   wfs = new WorkFlows();
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(Encoding.Default.GetString(wfs.GetWorkFlowDefineByID(defId).W_Xml));
            wf.InstFromXmlNode((XmlNode)doc.DocumentElement);

            var ev = wf.events["Start"];

            foreach (var k in ev.paramlist)
            {
                pars.Add(new
                {
                    par_name  = k.Value.name,
                    par_desc  = k.Value.description,
                    par_value = ""
                });
            }

            return(Json(new { data = pars.ToArray() }));
        }
예제 #2
0
        /// <summary>
        /// 从数据库记录加载类对象
        /// </summary>
        /// <param name="job">数据库记录</param>
        public override void Load(Timer_Jobs job)
        {
            //加载工作流定义
            WorkFlows       wfs       = new WorkFlows();
            WorkFlow_Define wf_define = wfs.GetWorkFlowDefineByID(job.workflow_ID);

            m_workFlow = null;
            if (wf_define != null)
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(Encoding.Default.GetString(wf_define.W_Xml));
                m_workFlow = new CWorkFlow();
                m_workFlow.InstFromXmlNode((XmlNode)doc.DocumentElement);
                m_workFlow.DefineID = job.workflow_ID;
            }

            base.Load(job);

            CreateCallback = CustomAction;
        }
예제 #3
0
        //设置临时任务
        public string LSJob_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;
            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[] { ',' });
            string         Depts      = item["Dept"].ToString();
            string         qr_endtime = item["ZhengGaiTime"].ToString();
            CTimerCreateWF m          = new CTimerCreateWF();

            //使用lambda表达式过滤掉空字符串
            zzids = zzids.Where(t => !string.IsNullOrEmpty(t)).ToArray();

            //这里需要创建一个回调函数
            string TempJobName = item["Job_Name"].ToString();

            string corn            = "0 0 0 * * ?";
            string ReservationTime = item["ReservationTime"].ToString();


            m.Set_Res_Value("STR_RES_1", Depts);

            string[] s = ReservationTime.Split(new char[] { '-' });

            string[] ss      = s[0].Split(new char[] { '/' });
            string   endtime = s[1].Replace(" ", "");
            DateTime Endtime = DateTime.Parse(endtime);

            m.Set_Res_Value("STR_RES_2", Endtime);
            //11.12改
            if (qr_endtime != "")
            {
                m.Set_Res_Value("STR_RES_3", DateTime.Parse(qr_endtime));
            }

            corn = "0 0 0 " + ss[2] + "" + ss[1] + " " + "? " + ss[0];

            //未写
            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_temporary");
                    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  = Endtime.ToString();
                    time_set.Offset_time = "";
                    time_set.Action      = "SUSPEND";
                    time_set.Call_back   = "";
                    TCP.AppendTimer("Xc_Sample", time_set);
                }
            }
            else if (WorkFlowName == "A5dot1")
            {
                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_temporary");
                    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  = Endtime.ToString();
                    time_set.Offset_time = "";
                    time_set.Action      = "SUSPEND";
                    time_set.Call_back   = "";
                    TCP.AppendTimer("ZzSubmit", time_set);
                }
            }
            else if (WorkFlowName == "A11dot2dot1")
            {
                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_temporary");
                    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  = Endtime.ToString();
                    time_set.Offset_time = "";
                    time_set.Action      = "SUSPEND";
                    time_set.Call_back   = "";
                    TCP.AppendTimer("ZzSubmit", time_set);
                }
            }
            else if (WorkFlowName == "A6dot2dot2")
            {
                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", cjids[i]);
                    param.Add("Job_Name", TempJobName);
                    param.Add("Job_Ztdanwei", Depts);
                    record.Add("username", "system_temporary");
                    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  = Endtime.ToString();
                    time_set.Offset_time = "";
                    time_set.Action      = "SUSPEND";
                    time_set.Call_back   = "";
                    TCP.AppendTimer("ZzSubmit", time_set);
                }
            }
            else if (WorkFlowName == "A5dot2dot1")
            {
                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_temporary");
                    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  = Endtime.ToString();
                    time_set.Offset_time = "";
                    time_set.Action      = "SUSPEND";
                    time_set.Call_back   = "";
                    TCP.AppendTimer("ZzSubmit", time_set);
                }
            }

            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 = 1;

            WorkFlow_Define wfd = wfs.GetWorkFlowDefineByID(workflow_id);

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

            CTimerManage.ActiveListActionForMission(m);
            return("/TempJob/index");
        }
예제 #4
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("该工作流已经提报过,请删除后再发起");
            }
        }