//添加排程執行日誌 private void ScheduleAddLog(string schedule_code) { ScheduleLogQuery query_log = new ScheduleLogQuery(); query_log.schedule_code = schedule_code; try { //如果通過瀏覽器登陸; query_log.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; } catch (Exception) { //根據schedule_code獲取相應period的change_user ScheduleMasterQuery query_master = new ScheduleMasterQuery(); query_master.schedule_code = schedule_code; _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString); ScheduleMasterQuery master = _secheduleServiceMgr.GetScheduleMaster(query_master); if (master.schedule_period_id != 0) { SchedulePeriodQuery query_period = new SchedulePeriodQuery(); query_period.rowid = master.schedule_period_id; query_period = _secheduleServiceMgr.GetSchedulePeriod(query_period); query_log.create_user = query_period.change_user; } } query_log.ipfrom = BLL.gigade.Common.CommonFunction.GetIP4Address(Request.UserHostAddress.ToString()); _secheduleServiceMgr.AddScheduleLog(query_log); }
//保存排程_period信息 public HttpResponseBase SaveSchedulePeriodInfo() { string json = string.Empty; try { SchedulePeriodQuery query = new SchedulePeriodQuery(); _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString); if (!string.IsNullOrEmpty(Request.Params["rowid"])) { query.rowid = Convert.ToInt32(Request.Params["rowid"]); } if (!string.IsNullOrEmpty(Request.Params["schedule_code"])) { query.schedule_code = Request.Params["schedule_code"]; } if (!string.IsNullOrEmpty(Request.Params["period_type"])) { query.period_type = Convert.ToUInt32(Request.Params["period_type"]); } if (!string.IsNullOrEmpty(Request.Params["period_nums"])) { query.period_nums = Convert.ToUInt32(Request.Params["period_nums"]); } if (!string.IsNullOrEmpty(Request.Params["current_nums"])) { query.current_nums = Convert.ToUInt32(Request.Params["current_nums"]); } if (!string.IsNullOrEmpty(Request.Params["limit_nums"])) { query.limit_nums = Convert.ToUInt32(Request.Params["limit_nums"]); } if (!string.IsNullOrEmpty(Request.Params["begin_datetime"])) { query.begin_datetime = (int)CommonFunction.GetPHPTime(Request.Params["begin_datetime"]); } query.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; query.change_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; int _dt = _secheduleServiceMgr.SaveSchedulePeriodInfo(query); if (_dt > 0) { json = "{success:true}"; //根據schedule_code獲取相應的ScheduleMaster信息 ScheduleMasterQuery query_master = new ScheduleMasterQuery(); query_master.schedule_code = query.schedule_code; ScheduleMasterQuery item = _secheduleServiceMgr.GetScheduleMaster(query_master); //更新ScheduleMaster表的previous_execute_time、next_execute_time、state; //獲取next_execute_time和schedule_period_id int schedule_period_id = 0; int next_execute_time = _secheduleServiceMgr.GetNext_Execute_Time(item.schedule_code, out schedule_period_id); if (item.next_execute_time > next_execute_time || (item.next_execute_time == 0 && item.next_execute_time < next_execute_time)) { item.next_execute_time = next_execute_time; ; item.schedule_period_id = schedule_period_id; _secheduleServiceMgr.UpdateScheduleMaster(item); } } else { json = "{success:false}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return Response; }
//可以多行刪除數據_period public HttpResponseBase SchedulePeriodDelete() { string json = string.Empty; SchedulePeriodQuery period = new SchedulePeriodQuery(); _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString); try { string id = Request.Params["id"]; id = id.Substring(0, id.Length - 1).ToString(); string[] ids = id.Split(','); if (ids.Length>0) { period.rowid = int.Parse(ids[0].ToString()); period = _secheduleServiceMgr.GetSchedulePeriod(period); ScheduleMasterQuery query_master = new ScheduleMasterQuery(); query_master.schedule_code = period.schedule_code; //刪除 int result = _secheduleServiceMgr.SchedulePeriodDelete(id); if (result > 0) { ScheduleMasterQuery item = _secheduleServiceMgr.GetScheduleMaster(query_master); //更新ScheduleMaster表的previous_execute_time、next_execute_time、state; //獲取next_execute_time和schedule_period_id int schedule_period_id = 0; int next_execute_time = _secheduleServiceMgr.GetNext_Execute_Time(item.schedule_code, out schedule_period_id); //if (item.next_execute_time > next_execute_time || (item.next_execute_time == 0 && item.next_execute_time < next_execute_time)) { item.next_execute_time = next_execute_time; if (item.next_execute_time == 0) { item.schedule_state = 0; } item.schedule_period_id = schedule_period_id; //修改ScheduleMaster _secheduleServiceMgr.UpdateScheduleMaster(item); } } } json = "{success:true}"; } #region 只刪除一行數據時的代碼段 //if (!string.IsNullOrEmpty(Request.Params["id"])) //{ // query.id = Convert.ToUInt32(Request.Params["id"]); //} // int _dt = informationMgr.PersonInfromationDelete(query); //if (_dt > 0) //{ // json = "{success:true}"; //} //else //{ // json = "{success:false}"; //} #endregion catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
//保存排程_master信息 public HttpResponseBase SaveScheduleMasterInfo() { string json = string.Empty; try { ScheduleMasterQuery query = new ScheduleMasterQuery(); _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString); if (!string.IsNullOrEmpty(Request.Params["rowid"])) { query.rowid = Convert.ToInt32(Request.Params["rowid"]); } if (!string.IsNullOrEmpty(Request.Params["schedule_code"])) { query.schedule_code = Request.Params["schedule_code"]; } if (!string.IsNullOrEmpty(Request.Params["schedule_name"])) { query.schedule_name = Request.Params["schedule_name"]; } if (!string.IsNullOrEmpty(Request.Params["schedule_api"])) { query.schedule_api = Request.Params["schedule_api"]; } if (!string.IsNullOrEmpty(Request.Params["schedule_description"])) { query.schedule_description = Request.Params["schedule_description"]; } if (!string.IsNullOrEmpty(Request.Params["schedule_state"])) { query.schedule_state = Convert.ToInt32(Request.Params["schedule_state"]); } if (!string.IsNullOrEmpty(Request.Params["schedule_period_id"])) { query.schedule_period_id = Convert.ToInt32(Request.Params["schedule_period_id"]); } query.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; query.change_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; //判斷該schedule_code是否已存在 if (query.rowid == 0)//新增 { ScheduleMasterQuery query_chongfu = new ScheduleMasterQuery(); query_chongfu.schedule_code = query.schedule_code; query_chongfu = _secheduleServiceMgr.GetScheduleMaster(query_chongfu); if (query_chongfu != null) { json = "{success:false,msg:3}"; } else { int _dt = _secheduleServiceMgr.SaveScheduleMasterInfo(query); if (_dt > 0) { json = "{success:true}"; } else { json = "{success:false,msg:2}"; } } } else { int _dt = _secheduleServiceMgr.SaveScheduleMasterInfo(query); if (_dt > 0) { json = "{success:true}"; } else { json = "{success:false,msg:2}"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return Response; }