Пример #1
0
        public JsonResult GetTimerJobs()
        {
            List <CTimerMission> miss = CTimerManage.GetTimerJobsForCustom();
            List <object>        res  = new List <object>();

            for (int i = 0; i < miss.Count; i++)
            {
                var       m  = miss[i];
                CWorkFlow wf = m.GetAttachWorkFlow();
                object    o  = new
                {
                    ID           = m.ID,
                    job_name     = m.mission_name,
                    job_type     = m.type,
                    order_item   = i + 1,
                    workflow     = wf == null ? null : "{ \"id\" : " + wf.DefineID + ", \"name\" : \"" + wf.name + "\", \"desc\" : \"" + wf.description + "\"}",
                    status       = m.status,
                    pretime      = m.PerTime.ToString(),
                    corn_express = m.GetTriggerTimmingString(),
                    create_time  = m.CreateTime.ToString()
                };
                res.Add(o);
            }

            return(Json(new { data = res.ToArray() }));
        }
Пример #2
0
        /// <summary>
        /// 进入该事件
        /// </summary>
        /// <param name="strjson"></param>
        public override void EnterEvent(string strjson)
        {
            base.UpdateCurrentEvent();
            Parent.UpdateEntity(WE_STATUS.SUSPEND);

            DateTime dt = DateTime.Now;

            dt = dt.AddYears(m_waitingTime.Years);
            dt = dt.AddMonths(m_waitingTime.Months);
            dt = dt.AddDays(m_waitingTime.Days);
            dt = dt.AddHours(m_waitingTime.Hours);
            dt = dt.AddMinutes(m_waitingTime.Minute);

            string strCorn = string.Format("{0} {1} {2} {3} {4} {5} {6}",
                                           0,
                                           dt.Minute,
                                           dt.Hour,
                                           dt.Day,
                                           dt.Month,
                                           "?",
                                           dt.Year);

            m_timer.SetTriggerTiming(strCorn);
            m_timer.CreateTime = DateTime.Now;
            m_timer.AttachWFEntity(Parent);
            m_timer.Save();
            m_timerID = m_timer.ID;
            CTimerManage.AppendMissionToActiveList(m_timer);
            //m_timeout.RegTimeoutTimer(false);
        }
Пример #3
0
        /// <summary>
        /// 取消该超时任务在定时任务管理器中的注册
        /// </summary>
        public void UnregTimeoutTimer()
        {
            var t = CTimerManage.LoadTimerMission(m_timerMissionID);

            if (t != null)
            {
                t.status = TM_STATUS.TM_FINISH;
                t.Save();
                CTimerManage.RemoveFromActiveList(t.ID);
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            CTimerManage.InitTimerManager();
            CTimerManage.Start();
            var wfe = CWFEngine.CreateAWFEntityByName("test1");

            wfe.Start(null);
            CWFEngine.SubmitSignal(wfe.EntityID, new Dictionary <string, string>());


            Thread.Sleep(10 * 60 * 1000);
        }
Пример #5
0
        /// <summary>
        /// 离开该事件
        /// </summary>
        /// <param name="strjson"></param>
        public override void LeaveEvent(string strjson)
        {
            //保存信息到数据库
            //base.InsertMissionToDB();
            //m_timeout.UnregTimeoutTimer();
            var t = CTimerManage.LoadTimerMission(m_timerID);

            if (t != null)
            {
                t.status = TM_STATUS.TM_FINISH;
                t.Save();
                CTimerManage.RemoveFromActiveList(t.ID);
            }
        }
Пример #6
0
        public string delete_job(string json)
        {
            JObject       item     = (JObject)JsonConvert.DeserializeObject(json);
            int           job_id   = Convert.ToInt32(item["job_id"].ToString());
            CTimerMission m        = CTimerManage.RemoveFromActiveList(job_id);
            List <string> property = new List <string>();

            property.Add("status");
            List <object> val = new List <object>();

            val.Add(TM_STATUS.TM_DELETE);
            CTimerManage.UpdateTimerMission(job_id, property, val);
            return("删除成功");
        }
Пример #7
0
        public string ZzSubmit_Bcsignal(string json1)
        {
            try
            {
                JObject item = (JObject)JsonConvert.DeserializeObject(json1);



                CTimerTimeout timeout_job = new CTimerTimeout();
                timeout_job.CreateTime   = DateTime.Now;
                timeout_job.for_using    = TIMER_USING.FOR_SYSTEM;
                timeout_job.mission_name = "";
                timeout_job.status       = TM_STATUS.TM_STATUS_ACTIVE;
                timeout_job.SetActionForWF("INVILID");
                timeout_job.AttachWFEntityID = Convert.ToInt32(item["wfe_id"]);
                timeout_job.CustomAction     = "http://localhost/CallBack/testCallBack";
                timeout_job.EventName        = "PqAessess";
                timeout_job.SetTriggerTiming("0 0 0 20 * ?");
                //保存该定时任务,并将其添加到激活任务列表
                timeout_job.Save();
                int m_timerMissionID = timeout_job.ID;
                CTimerManage.AppendMissionToActiveList(timeout_job);


                string[]   notgood    = item["Incomplete_content"].ToString().Split('|');
                A5dot1Tab1 a5dot1Tab1 = new A5dot1Tab1();
                DateTime   my         = DateTime.Now;
                string     yearmonth  = "";
                int        cjid       = Em.getEA_parentid(Convert.ToInt32(item["Zz_Id"]));
                string     cjname     = Eam.getEa_namebyId(cjid);
                string     Username   = (Session["User"] as EquipModel.Entities.Person_Info).Person_Name;
                if (my.Day >= 15)
                {
                    yearmonth = my.Year.ToString() + my.AddMonths(1).Month.ToString();
                }
                else
                {
                    yearmonth = my.Year.ToString() + my.Month.ToString();
                }

                if (notgood[notgood.Count() - 1] == "")
                {
                    for (int i = 0; i < notgood.Count() - 1; i++)
                    {
                        a5dot1Tab1.cjName                = cjname;
                        a5dot1Tab1.zzName                = item["Zz_Name"].ToString();
                        a5dot1Tab1.sbGyCode              = item["Equip_GyCode"].ToString();
                        a5dot1Tab1.sbCode                = item["Equip_Code"].ToString();
                        a5dot1Tab1.sbType                = item["Equip_Type"].ToString();
                        a5dot1Tab1.zyType                = item["Zy_Type"].ToString();
                        a5dot1Tab1.notGoodContent        = notgood[i];
                        a5dot1Tab1.isRectified           = 0;
                        a5dot1Tab1.zzSubmitTime          = DateTime.Now;
                        a5dot1Tab1.zzUserName            = Username;
                        a5dot1Tab1.yearMonthForStatistic = yearmonth;
                        a5dot1Tab1.temp3 = m_timerMissionID.ToString();
                        if (item["wfe_id"].ToString() != "")
                        {
                            a5dot1Tab1.dataSource = item["wfe_id"].ToString();
                        }
                        if (a5dot1Tab1.cjName == "消防队" || a5dot1Tab1.cjName == "计量站")
                        {
                            a5dot1Tab1.pqName = a5dot1Tab1.cjName;
                        }
                        else
                        {
                            a5dot1Tab1.pqName = pm.Get_PqnamebyCjname(a5dot1Tab1.cjName.ToString());
                        }
                        tm.Zzsubmit(a5dot1Tab1);
                    }
                }
                else
                {
                    for (int i = 0; i < notgood.Count(); i++)
                    {
                        a5dot1Tab1.cjName                = cjname;
                        a5dot1Tab1.zzName                = item["Zz_Name"].ToString();
                        a5dot1Tab1.sbGyCode              = item["Equip_GyCode"].ToString();
                        a5dot1Tab1.sbCode                = item["Equip_Code"].ToString();
                        a5dot1Tab1.sbType                = item["Equip_Type"].ToString();
                        a5dot1Tab1.zyType                = item["Zy_Type"].ToString();
                        a5dot1Tab1.notGoodContent        = notgood[i];
                        a5dot1Tab1.isRectified           = 0;
                        a5dot1Tab1.zzSubmitTime          = DateTime.Now;
                        a5dot1Tab1.zzUserName            = Username;
                        a5dot1Tab1.yearMonthForStatistic = yearmonth;
                        a5dot1Tab1.temp3 = m_timerMissionID.ToString();
                        if (item["wfe_id"].ToString() != "")
                        {
                            a5dot1Tab1.dataSource = item["wfe_id"].ToString();
                        }
                        if (a5dot1Tab1.cjName == "消防队" || a5dot1Tab1.cjName == "计量站")
                        {
                            a5dot1Tab1.pqName = a5dot1Tab1.cjName;
                        }
                        else
                        {
                            a5dot1Tab1.pqName = pm.Get_PqnamebyCjname(a5dot1Tab1.cjName.ToString());
                        }
                        tm.Zzsubmit(a5dot1Tab1);
                    }
                }
                string wfe_id = item["wfe_id"].ToString();
                //paras
                Dictionary <string, string> signal = new Dictionary <string, string>();
                signal["ZzSubmit_done"] = "true";

                //record
                Dictionary <string, string> record = new Dictionary <string, string>();
                record["username"] = (Session["User"] as EquipModel.Entities.Person_Info).Person_Name;
                record["time"]     = DateTime.Now.ToString();
                //submit
                CWFEngine.SubmitSignal(Convert.ToInt32(wfe_id), signal, record);
            }
            catch (Exception e)
            {
                return("");
            }
            return("/A5dot1/Index");
        }
Пример #8
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");
        }
Пример #9
0
        /// <summary>
        /// 处理datatables请求
        /// </summary>
        /// <param name="data"></param>
        private DtResponse ProcessRequest(List <KeyValuePair <string, string> > data)
        {
            DtResponse dt = new DtResponse();

            var http = DtRequest.HttpData(data);

            if (http.ContainsKey("action"))
            {
                string action = http["action"] as string;
                if (action == "edit")
                {
                    var Data = http["data"] as Dictionary <string, object>;
                    foreach (var d in Data)
                    {
                        int           id   = Convert.ToInt32(d.Key);
                        List <string> pros = new List <string>();
                        List <object> vals = new List <object>();
                        Dictionary <string, object> m_kv = new Dictionary <string, object>();
                        foreach (var dd in d.Value as Dictionary <string, object> )
                        {
                            pros.Add(dd.Key);
                            if (dd.Key == "job_type")
                            {
                                switch (dd.Value as string)
                                {
                                case "CreateWorkFlow":
                                    vals.Add(TIMER_JOB_TYPE.CREATE_WORKFLOW);
                                    break;

                                default:
                                case "Empty":
                                    vals.Add(TIMER_JOB_TYPE.EMPTY);
                                    break;
                                }
                            }
                            else if (dd.Key == "workflow")
                            {
                                JObject obj = JObject.Parse((string)dd.Value);
                                vals.Add(Convert.ToInt32(obj["id"]));
                            }
                            else
                            {
                                vals.Add(dd.Value);
                            }
                        }
                        CTimerMission m = CTimerManage.UpdateTimerMission(id, pros, vals);


                        m_kv["ID"]       = m.ID;
                        m_kv["job_name"] = m.mission_name;
                        m_kv["job_type"] = m.type;
                        CWorkFlow wf = m.GetAttachWorkFlow();

                        m_kv["workflow"]     = wf == null ? null : "{ \"id\" : " + wf.DefineID + ", \"name\" : \"" + wf.name + "\", \"desc\" : \"" + wf.description + "\"}";
                        m_kv["status"]       = m.status;
                        m_kv["pretime"]      = m.PerTime.ToString();
                        m_kv["corn_express"] = m.GetTriggerTimmingString();
                        m_kv["create_time"]  = m.CreateTime.ToString();
                        dt.data.Add(m_kv);
                    }
                }
                else if (action == "create") //新建工作流
                {
                    CTimerMission m = CTimerManage.CreateAEmptyMission();
                    m.mission_name = "新建任务";
                    m.SetTriggerTiming("0 0 0 * * ?");
                    m.Save();

                    Dictionary <string, object> m_kv = new Dictionary <string, object>();
                    m_kv["ID"]         = m.ID;
                    m_kv["order_item"] = 1;
                    m_kv["job_name"]   = m.mission_name;
                    m_kv["job_type"]   = m.type;
                    CWorkFlow wf = m.GetAttachWorkFlow();

                    m_kv["workflow"]     = wf == null ? null : "{ \"id\" : " + wf.DefineID + ", \"name\" : \"" + wf.name + "\", \"desc\" : \"" + wf.description + "\"}";
                    m_kv["status"]       = m.status;
                    m_kv["pretime"]      = m.PerTime.ToString();
                    m_kv["corn_express"] = m.GetTriggerTimmingString();
                    m_kv["create_time"]  = m.CreateTime.ToString();
                    dt.data.Add(m_kv);
                }
                else if (action == "remove")
                {
                    var Data = http["data"] as Dictionary <string, object>;
                    foreach (var d in Data)
                    {
                        int id = Convert.ToInt32(d.Key);

                        CTimerMission m = CTimerManage.DeleteTimerJob(id);
                    }
                }
            }
            return(dt);
        }
Пример #10
0
        public string ZzSubmit_Bcsignal(string json1)
        {
            try
            {
                JObject item = (JObject)JsonConvert.DeserializeObject(json1);

                CTimerTimeout timeout_job = new CTimerTimeout();
                timeout_job.CreateTime   = DateTime.Now;
                timeout_job.for_using    = TIMER_USING.FOR_SYSTEM;
                timeout_job.mission_name = "";
                timeout_job.status       = TM_STATUS.TM_STATUS_ACTIVE;
                timeout_job.SetActionForWF("INVILID");
                timeout_job.AttachWFEntityID = Convert.ToInt32(item["wfe_id"]);
                timeout_job.CustomAction     = "http://localhost/CallBack/testCallBack";
                timeout_job.EventName        = "PqAessess";
                timeout_job.SetTriggerTiming("0 0 0 20 * ?");
                //保存该定时任务,并将其添加到激活任务列表
                timeout_job.Save();
                int m_timerMissionID = timeout_job.ID;
                CTimerManage.AppendMissionToActiveList(timeout_job);


                //  A5dot1Tab1 a5dot1Tab1 = new A5dot1Tab1();
                DateTime my     = DateTime.Now;
                int      cjid   = Em.getEA_parentid(Convert.ToInt32(item["Zz_Id"]));
                string   cjname = Eam.getEa_namebyId(cjid);

                A5dot2Tab1 new_5dot2 = new A5dot2Tab1();
                new_5dot2.cjName             = cjname;
                new_5dot2.zzName             = item["Zz_Name"].ToString();
                new_5dot2.sbGyCode           = item["Equip_GyCode"].ToString();
                new_5dot2.sbCode             = item["Equip_Code"].ToString();
                new_5dot2.sbType             = item["Equip_Type"].ToString();
                new_5dot2.zyType             = item["Zy_Type"].ToString();
                new_5dot2.problemDescription = item["problemDescription"].ToString();
                new_5dot2.jxSubmitTime       = DateTime.Now;
                new_5dot2.jxUserName         = (Session["User"] as EquipModel.Entities.Person_Info).Person_Name;
                new_5dot2.isRectified        = 0;
                new_5dot2.state = 0;
                new_5dot2.temp2 = item["wfe_id"].ToString();
                new_5dot2.temp3 = m_timerMissionID.ToString();
                bool res = Sx.AddSxItem(new_5dot2);

                string wfe_id = item["wfe_id"].ToString();
                //paras
                Dictionary <string, string> signal = new Dictionary <string, string>();
                signal["ZzSubmit_done"] = "true";

                //record
                Dictionary <string, string> record = new Dictionary <string, string>();
                record["username"] = (Session["User"] as EquipModel.Entities.Person_Info).Person_Name;
                record["time"]     = DateTime.Now.ToString();
                //submit
                CWFEngine.SubmitSignal(Convert.ToInt32(wfe_id), signal, record);
            }
            catch (Exception e)
            {
                return("");
            }
            return("/A5dot2/Index");
        }
Пример #11
0
        /// <summary>
        /// 注册到Timer管理器
        /// </summary>
        /// <param name="bCreateWF">是否为创建工作流时刻</param>
        public void RegTimeoutTimer(bool bCreateWF)
        {
            //如果含义无效,直接返回
            if (!IsEnable())
            {
                return;
            }

            CTimerTimeout timeout_job = new CTimerTimeout();

            timeout_job.CreateTime   = DateTime.Now;
            timeout_job.for_using    = TIMER_USING.FOR_SYSTEM;
            timeout_job.mission_name = string.Format("{0}:{1}", Parent.Parent.name, Parent.name);
            timeout_job.status       = TM_STATUS.TM_STATUS_ACTIVE;
            timeout_job.SetActionForWF(m_action);
            timeout_job.AttachWFEntityID = Parent.Parent.EntityID;
            timeout_job.CustomAction     = CallbackUrl;
            timeout_job.EventName        = Parent.name;


            string strCorn = "";

            //如果该函数是调用于工作流创建时刻,但是偏移时间的起始不是TIME_START.TIME_WF_CREATE 则注册失败, 直接返回
            if (bCreateWF)
            {
                if ((m_ExactTime == null) && (m_startTime != TIME_START.TIME_WF_CREATE))
                {
                    return;
                }
            }
            else //如果该函数是调用于进入Event时刻,但是偏移时间的起始不是TIME_START.TIME_WF_CREATE 则注册失败, 直接返回
            {
                if (m_ExactTime != null || m_startTime != TIME_START.TIME_EVENT_ENTER)
                {
                    return;
                }
            }

            if (m_ExactTime != null)
            {
                strCorn = string.Format("{0} {1} {2} {3} {4} {5} {6}",
                                        m_ExactTime.Value.Second,
                                        m_ExactTime.Value.Minute,
                                        m_ExactTime.Value.Hour,
                                        m_ExactTime.Value.Day,
                                        m_ExactTime.Value.Month,
                                        "?",
                                        m_ExactTime.Value.Year);
                timeout_job.SetTriggerTiming(strCorn);
            }
            else
            {
                DateTime run_time = DateTime.Now + m_timeOffset.Value;
                strCorn = string.Format("{0} {1} {2} {3} {4} {5} {6}",
                                        run_time.Second,
                                        run_time.Minute,
                                        run_time.Hour,
                                        run_time.Day,
                                        run_time.Month,
                                        "?",
                                        run_time.Year);
                timeout_job.SetTriggerTiming(strCorn);
            }

            //保存该定时任务,并将其添加到激活任务列表
            timeout_job.Save();
            m_timerMissionID = timeout_job.ID;
            CTimerManage.AppendMissionToActiveList(timeout_job);
        }
Пример #12
0
        public JsonResult Pq_submitsignal(string json1)
        {
            JObject item = (JObject)JsonConvert.DeserializeObject(json1);

            A5dot2Tab1 new_5dot21 = new A5dot2Tab1();

            new_5dot21.pqCheckTime = DateTime.Now;
            new_5dot21.pqUserName  = (Session["User"] as EquipModel.Entities.Person_Info).Person_Name;

            new_5dot21.isRectified = Convert.ToInt32(item["isRectified"]);
            new_5dot21.state       = 1;
            if (Convert.ToInt32(item["isRectified"]) == 1)
            {
                //string[] str = (item["problemDescription"].ToString()).Split(new[] { "(未整改)" }, StringSplitOptions.None);//以字符串作为分割条件
                new_5dot21.problemDescription = item["problemDescription"].ToString() + "(已整改)";
            }
            if (Convert.ToInt32(item["isRectified"]) == 0)
            {
                new_5dot21.problemDescription = item["problemDescription"].ToString() + "(未整改)";
            }
            new_5dot21.Id = Convert.ToInt32(item["A5dot2Tab1_id"].ToString());
            string res = Sx.ModifySxItem(new_5dot21);



            int a_id = Convert.ToInt32(item["A5dot2Tab1_id"].ToString());

            if (Sx.getAllbyid(a_id).temp3 != null)
            {
                int missId = Convert.ToInt32(Sx.getAllbyid(a_id).temp3);
                var t      = CTimerManage.LoadTimerMission(missId);

                if (t != null)
                {
                    t.status = TM_STATUS.TM_FINISH;
                    t.Save();
                    CTimerManage.RemoveFromActiveList(t.ID);
                }
            }


            //接收返回的设备工艺号

            A5dot2Tab2        new_5dot22 = new A5dot2Tab2();
            List <A5dot2Tab2> IsExist    = Sx.GetA5dot2Tab2Item(res);

            if (IsExist.Count == 0)
            {
                //传到表2若没有则添加一条数据,如果有则修改该条数据
                DateTime i         = DateTime.Now;
                string   yearmonth = "";
                if (i.Day >= 15)
                {
                    yearmonth = i.Year.ToString() + "年" + i.AddMonths(1).Month.ToString();
                }
                else
                {
                    yearmonth = i.Year.ToString() + "年" + i.Month.ToString();
                }
                new_5dot22.cjName   = item["cjName"].ToString();
                new_5dot22.zzName   = item["zzName"].ToString();
                new_5dot22.sbGyCode = item["sbGyCode"].ToString();
                new_5dot22.sbCode   = item["sbCode"].ToString();
                new_5dot22.sbType   = item["sbType"].ToString();
                new_5dot22.zyType   = item["zyType"].ToString();
                if (Convert.ToInt32(item["isRectified"]) == 1)
                {
                    new_5dot22.problemDescription = item["problemDescription"].ToString() + "(已整改)";
                }
                if (Convert.ToInt32(item["isRectified"]) == 0)
                {
                    new_5dot22.problemDescription = item["problemDescription"].ToString() + "(未整改)";
                }

                new_5dot22.state = 1;
                new_5dot22.nProblemsInCurMonth   = 1;
                new_5dot22.nProblemsInCurYear    = 1;
                new_5dot22.isSetAsTop10Worst     = 0;
                new_5dot22.yearMonthForStatistic = yearmonth;
                bool has = Sx.AddA5dot2Tab2Item(new_5dot22);
            }
            //修改该条数据
            else
            {
                DateTime i         = DateTime.Now;
                string   yearmonth = "";
                if (i.Day >= 15)
                {
                    yearmonth = i.Year.ToString() + "年" + i.AddMonths(1).Month.ToString();
                }
                else
                {
                    yearmonth = i.Year.ToString() + "年" + i.Month.ToString();
                }
                new_5dot22.cjName   = item["cjName"].ToString();
                new_5dot22.zzName   = item["zzName"].ToString();
                new_5dot22.sbGyCode = item["sbGyCode"].ToString();
                new_5dot22.sbCode   = item["sbCode"].ToString();
                new_5dot22.sbType   = item["sbType"].ToString();
                if (Convert.ToInt32(item["isRectified"]) == 1)
                {
                    new_5dot22.problemDescription = item["problemDescription"].ToString() + "(已整改)";
                }
                if (Convert.ToInt32(item["isRectified"]) == 0)
                {
                    new_5dot22.problemDescription = item["problemDescription"].ToString() + "(未整改)";
                }

                new_5dot22.zyType = item["zyType"].ToString();
                new_5dot22.sbCode = item["sbCode"].ToString();
                new_5dot22.state  = 1;
                new_5dot22.nProblemsInCurMonth   = 1;
                new_5dot22.nProblemsInCurYear    = 1;
                new_5dot22.isSetAsTop10Worst     = 0;
                new_5dot22.yearMonthForStatistic = yearmonth;
                bool has = Sx.ModifyA5dot2Tab2Item(new_5dot22);
            }



            return(Json(new { result = res }));
        }
Пример #13
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("该工作流已经提报过,请删除后再发起");
            }
        }