Exemplo n.º 1
0
        public int UpdateScheduleMaster(ScheduleMasterQuery query)
        {
            try
            {
                return _secheduleServiceDao.UpdateScheduleMaster(query);
            }
            catch (Exception ex)
            {

                throw new Exception("SecheduleServiceMgr-->UpdateScheduleMaster-->" + ex.Message, ex);
            }
        }
Exemplo n.º 2
0
        public List<ScheduleMasterQuery> GetExeScheduleMasterList(ScheduleMasterQuery query)
        {
            try
            {
                return _secheduleServiceDao.GetExeScheduleMasterList(query);
            }
            catch (Exception ex)
            {

                throw new Exception("SecheduleServiceMgr-->GetExeScheduleMasterList-->" + ex.Message, ex);
            }
        }
Exemplo n.º 3
0
          public List<ScheduleMasterQuery> GetExeScheduleMasterList(ScheduleMasterQuery query)
          {
              StringBuilder sql = new StringBuilder();
              try
              {
                  sql.AppendFormat("SELECT `rowid`, `schedule_code`, `schedule_name`, `schedule_api`, `schedule_description`, `schedule_state`, `previous_execute_time`, `next_execute_time`, `schedule_period_id`, `create_user`, `create_time`, `change_user`, `change_time` FROM `schedule_master` WHERE schedule_state = '{0}' AND  next_execute_time<='{1}' and next_execute_time > 0 ;", query.schedule_state, Common.CommonFunction.GetPHPTime(DateTime.Now.ToString()));

                  return _access.getDataTableForObj<ScheduleMasterQuery>(sql.ToString());
              }
              catch (Exception ex)
              {
                  throw new Exception("ScheduleServiceDao-->GetExeScheduleMasterList-->" + ex.Message, ex);
              }
          }
Exemplo n.º 4
0
          public ScheduleMasterQuery GetScheduleMaster(ScheduleMasterQuery query)
          {
              StringBuilder sql = new StringBuilder();
              try
              {
                  sql.AppendFormat("SELECT `rowid`, `schedule_code`, `schedule_name`, `schedule_api`, `schedule_description`, `schedule_state`, `previous_execute_time`, `next_execute_time`, `schedule_period_id`, `create_user`, `create_time`, `change_user`, `change_time` FROM `schedule_master` WHERE schedule_code = '{0}';", query.schedule_code);

                  return _access.getSinggleObj<ScheduleMasterQuery>(sql.ToString());
              }
              catch (Exception ex)
              {

                  throw new Exception("ScheduleServiceDao-->GetScheduleMaster-->" + ex.Message, ex);
              }
          }
        //保存排程_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;

        }
        //schedule_master 中的狀態啟用
        public HttpResponseBase UpdateStats_Schedule_master()
        {
            string json = string.Empty;
            try
            {
                _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString);
                ScheduleMasterQuery query = new ScheduleMasterQuery();

                if (!string.IsNullOrEmpty(Request.Params["id"]))
                {
                    query.rowid = Convert.ToInt32(Request.Params["id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["active"]))
                {
                    query.schedule_state = Convert.ToInt32(Request.Params["active"]);
                }
                query.change_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;

                json = _secheduleServiceMgr.UpdateStats_Schedule_master(query);
            }
            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 this.Response;
        }
        public HttpResponseBase GetScheduleMasterList()
        {
            string json = string.Empty;
            int totalcount = 0;
            try
            {
                ScheduleMasterQuery query = new ScheduleMasterQuery();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
                _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString);
                List<ScheduleMasterQuery> list = _secheduleServiceMgr.GetScheduleMasterList(query);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                // timeConverter.DateTimeFormat = "yyyy-MM-dd ";
                json = "{success:true,totalCount:" + totalcount + ",data:" + JsonConvert.SerializeObject(list, Formatting.Indented, timeConverter) + "}";
            }
            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;
 
        } // 獲取 master數據
        //可以多行刪除數據_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 ScheduleMasterDelete()
        {
            string json = string.Empty;
            ScheduleMasterQuery query = new ScheduleMasterQuery();
            _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString);
            try
            {
                string id = Request.Params["id"];
                string[] ids = id.Split(',');
                for (int i = 0; i < ids.Length - 1; i++)
                {
                    query.rowid = int.Parse(ids[i].ToString());
                    _secheduleServiceMgr.ScheduleMasterDelete(query.rowid.ToString());

                }
                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;
        }
Exemplo n.º 10
0
        public List<ScheduleMasterQuery> GetScheduleMasterList(ScheduleMasterQuery query) // master 
        {
            try
            {
                List<ScheduleMasterQuery> store = new List<ScheduleMasterQuery>();
                store = _secheduleServiceDao.GetScheduleMasterList(query);
                foreach (var item in store)
                {
                    if (item.schedule_state == 0)
                    {
                        item.sschedule_state = "停用";
                    }
                    if (item.schedule_state == 1)
                    {
                        item.sschedule_state = "啟用";
                    }
                    if (item.previous_execute_time == 0)
                    {
                        item.show_previous_execute_time = string.Empty;
                    }
                    else
                    {
                        item.show_previous_execute_time = CommonFunction.GetNetTime(item.previous_execute_time).ToString("yyyy-MM-dd HH:mm:ss ");
                    }
                    if (item.next_execute_time == 0)
                    {
                        item.show_next_execute_time = string.Empty;
                    }
                    else
                    {
                        item.show_next_execute_time = CommonFunction.GetNetTime(item.next_execute_time).ToString("yyyy-MM-dd HH:mm:ss ");
                    }
                    item.show_create_time = CommonFunction.GetNetTime(item.create_time).ToString("yyyy-MM-dd HH:mm:ss ");
                    item.show_change_time = CommonFunction.GetNetTime(item.change_time).ToString("yyyy-MM-dd HH:mm:ss ");
                }
                return store;

            }
            catch (Exception ex)
            {

                throw new Exception("SecheduleServiceMgr-->GetScheduleMasterList-->" + ex.Message, ex);
            }
        }
Exemplo n.º 11
0
          public int UpdateScheduleMaster(ScheduleMasterQuery query)
          {
              StringBuilder sql = new StringBuilder();
              try
              {
                  sql.AppendFormat(@"UPDATE `schedule_master` SET `schedule_code`='{0}', `schedule_name`='{1}', `schedule_api`='{2}', `schedule_description`='{3}', `schedule_state`='{4}', `previous_execute_time`='{5}', `next_execute_time`='{6}',`schedule_period_id`='{7}', `create_user`='{8}', `create_time`='{9}', `change_user`='{10}', `change_time`='{11}' WHERE `rowid`='{12}';", query.schedule_code, query.schedule_name, query.schedule_api, query.schedule_description, query.schedule_state, query.previous_execute_time, query.next_execute_time, query.schedule_period_id, query.create_user, query.create_time, query.change_user, Common.CommonFunction.GetPHPTime(), query.rowid);
                  return _access.execCommand(sql.ToString());
              }
              catch (Exception ex)
              {

                  throw new Exception("ScheduleServiceDao-->UpdateScheduleMaster-->" + ex.Message, ex);
              }
          }
Exemplo n.º 12
0
 public int ScheduleMasterInfoUpdate(ScheduleMasterQuery query)//更新schedule_master信息
 {
     StringBuilder sql = new StringBuilder();
     query.Replace4MySQL();
     try
     {
         sql.AppendFormat("update schedule_master set schedule_code = '{0}', schedule_name = '{1}', schedule_api = '{2}',schedule_description='{3}',schedule_state='{4}',schedule_period_id='{5}',create_user='******',change_user='******',change_time='{8}', previous_execute_time='{9}', next_execute_time='{10}' where rowid='{11}'", query.schedule_code, query.schedule_name, query.schedule_api, query.schedule_description, query.schedule_state, query.schedule_period_id, query.create_user, query.change_user, CommonFunction.GetPHPTime(DateTime.Now.ToString()), query.previous_execute_time, query.next_execute_time, query.rowid);
         return _access.execCommand(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("ScheduleServiceDao-->ScheduleMasterInfoUpdate-->" + sql.ToString() + ex.Message);
     }
 }
Exemplo n.º 13
0
          public int ScheduleMasterInfoInsert(ScheduleMasterQuery query) //插入schedule_master信息
          {
              StringBuilder sql = new StringBuilder();
              query.Replace4MySQL();
              try
              {

                  sql.Append("insert into schedule_master ( schedule_code, schedule_name, schedule_api,schedule_description,schedule_state,schedule_period_id,create_user,change_user, create_time, change_time, previous_execute_time,next_execute_time) values ");
                  sql.AppendFormat("('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')", query.schedule_code, query.schedule_name, query.schedule_api, query.schedule_description, query.schedule_state, query.schedule_period_id, query.create_user, query.change_user, CommonFunction.GetPHPTime(DateTime.Now.ToString()), CommonFunction.GetPHPTime(), query.previous_execute_time, query.next_execute_time);

                  return _access.execCommand(sql.ToString());
              }
              catch (Exception ex)
              {
                  throw new Exception("ScheduleServiceDao-->ScheduleMasterInfoInsert-->" + sql.ToString() + ex.Message);
              }
          }
Exemplo n.º 14
0
 public string UpdateStats_Schedule_master(ScheduleMasterQuery query)  // master 狀態更新
 {
     StringBuilder strSql = new StringBuilder();
     try
     {
         strSql.AppendFormat(@"Update schedule_master set schedule_state='{0}',change_user='******',change_time='{2}' WHERE rowid='{3}'", query.schedule_state,query.change_user, CommonFunction.GetPHPTime(), query.rowid);
         return strSql.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception("ScheduleServiceDao-->UpdateStats_Schedule_master-->" + ex.Message + strSql.ToString(), ex);
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// 獲取需要執行的排程列表并逐個執行,添加日誌和更新排程;
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetExeScheduleServiceList()
        {
            //獲取需要執行的排程

            List<ScheduleMasterQuery> store = new List<ScheduleMasterQuery>();
            _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString);

            try
            {
                ScheduleMasterQuery query = new ScheduleMasterQuery();
                query.schedule_state = 1;
                store = _secheduleServiceMgr.GetExeScheduleMasterList(query);
                foreach (ScheduleMasterQuery item in store)
                {
                    try
                    {
                            //執行排程
                            bool result = ExeScheduleService(item.schedule_api,item.schedule_code);
                            
                            //更新SchedulePeriod表的current_nums;ScheduleMaster表的previous_execute_time、next_execute_time、state;
                            //更新current_nums欄位;
                            SchedulePeriodQuery query_period = new SchedulePeriodQuery();
                            query_period.rowid = item.schedule_period_id;
                            query_period = _secheduleServiceMgr.GetSchedulePeriod(query_period);
                            if (query_period != null)
                            {
                                query_period.current_nums += 1;
                                _secheduleServiceMgr.UpdateSchedulePeriod(query_period);
                            }

                            //更新ScheduleMaster表的previous_execute_time、next_execute_time、state;
                            item.previous_execute_time = (int)CommonFunction.GetPHPTime();
                            //獲取next_execute_time和schedule_period_id
                            int schedule_period_id = 0;
                            item.next_execute_time = _secheduleServiceMgr.GetNext_Execute_Time(item.schedule_code, out schedule_period_id);
                            item.schedule_period_id = schedule_period_id;
                            if (item.next_execute_time == 0)
                            {
                                item.schedule_state = 0;
                            }
                            _secheduleServiceMgr.UpdateScheduleMaster(item);
                    }
                    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);
                    }
                    
                }
                
            }
            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);
            }
            //this.Response.Clear();
            //this.Response.Write();
            //this.Response.End();
            return this.Response;
        }
Exemplo n.º 16
0
        //保存排程_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;

        }
Exemplo n.º 17
0
 public string UpdateStats_Schedule_master(ScheduleMasterQuery query)  
 {
     string json;
     string sql = "";
     try
     {
         if (query.schedule_state == 0)
         {
             query.schedule_state = 1;
         }
         else
         {
             query.schedule_state = 0;
         }
         sql = _secheduleServiceDao.UpdateStats_Schedule_master(query);
         if (_dbAccess.execCommand(sql) > 0)
         {
             json = "{success:true}";
         }
         else
         {
             json = "{success:false}";
         }
         return json;
     }
     catch (Exception ex)
     {
         throw new Exception("SecheduleServiceMgr-->UpdateStats_Schedule_master-->" + ex.Message + sql, ex);
     }
 }// master 的狀態改變
Exemplo n.º 18
0
 //立即執行選中的排程
 public HttpResponseBase ScheduleMasterRunOnce()
 {
     string json = string.Empty;
     bool result = false;
     ScheduleMasterQuery query = new ScheduleMasterQuery();
     _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString);
     try
     {
         string id = Request.Params["id"];
         string[] ids = id.Split(',');
         for (int i = 0; i < ids.Length - 1; i++)
         {
             string[] scheduleapis = ids[i].Split('&');
             if(scheduleapis.Length==2)
             {
                 
                 if (!string.IsNullOrEmpty(scheduleapis[0].ToString())&&!string.IsNullOrEmpty(scheduleapis[1].ToString()))
                 {
                     result = ExeScheduleService(scheduleapis[0].ToString(),scheduleapis[1].ToString());
                 }
             }
         }
         if (result)
         {
             json = "{success:true}";
         }
         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}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Exemplo n.º 19
0
        }// master 的狀態改變

        //schedule_master判断是新增 还是 编辑 
        public int SaveScheduleMasterInfo(ScheduleMasterQuery query)
        {
            try
            {
                if (query.rowid == 0)//新增
                {
                    return _secheduleServiceDao.ScheduleMasterInfoInsert(query);
                }
                else//編輯
                {
                    return _secheduleServiceDao.ScheduleMasterInfoUpdate(query);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("ScheduleServiceMgr-->SaveScheduleMasterInfo-->" + ex.Message);
            }
        }
Exemplo n.º 20
0
        //添加排程執行日誌
        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);
        }
Exemplo n.º 21
0
 public List<ScheduleMasterQuery> GetScheduleMasterList(ScheduleMasterQuery query)// 得到 master表中的記錄
 {
     StringBuilder sql = new StringBuilder();
     StringBuilder str = new StringBuilder();
     try
     {
         sql.AppendFormat(" SELECT sm.rowid,sm.schedule_code,sm.schedule_name,sm.schedule_api,sm.schedule_description,sm.schedule_state,sm.previous_execute_time,sm.next_execute_time,sm.schedule_period_id, mu1.user_username as create_username,sm.create_time,mu2.user_username as change_username,sm.change_time  FROM schedule_master sm ");
         str.Append(" LEFT JOIN manage_user mu1 on mu1.user_id=sm.create_user ");
         str.Append(" LEFT JOIN manage_user mu2 on mu2.user_id=sm.change_user ");
         sql.Append(str.ToString());
         return _access.getDataTableForObj<ScheduleMasterQuery>(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("ScheduleServiceDao-->GetScheduleMasterList-->" + ex.Message, ex);
     }
 }