//添加排程執行日誌
        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);
        }
        public HttpResponseBase GetScheduleLogList()// 獲取Log數據
        {
            string json = string.Empty;
            int totalcount = 0;
            ScheduleLogQuery query = new ScheduleLogQuery();
            try
            {
                List<ScheduleLogQuery> Store = new List<ScheduleLogQuery>();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
                if (!string.IsNullOrEmpty(Request.Params["schedule_code"]))
                {
                    query.schedule_code = Request.Params["schedule_code"];
                }

                if (!string.IsNullOrEmpty(Request.Params["start_time"]))//開始時間
                {
                    query.start_time = (int)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["start_time"]).ToString("yyyy-MM-dd HH:mm:ss"));
                }
                if (!string.IsNullOrEmpty(Request.Params["end_time"]))//結束時間
                {
                    query.end_time = (int)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["end_time"]).ToString("yyyy-MM-dd HH:mm:ss"));
                }
              

                _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString);
                Store = _secheduleServiceMgr.GetScheduleLogList(query, out totalcount);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
               // json = "{success:true,data:" + JsonConvert.SerializeObject(Store, Formatting.Indented, timeConverter) + "}";//返回json數據
                json = "{success:true,totalCount:" + totalcount + ",data:" + JsonConvert.SerializeObject(Store, 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,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;

        }
Exemplo n.º 3
0
        public List<ScheduleLogQuery> GetScheduleLogList(ScheduleLogQuery query, out int totalCount)// Log 
        {
            try
            {
                List<ScheduleLogQuery> store = new List<ScheduleLogQuery>();
                store = _secheduleServiceDao.GetScheduleLogList(query, out totalCount);
                foreach (var item in store)
                {
                    item.show_create_time = CommonFunction.GetNetTime(item.create_time).ToString("yyyy-MM-dd HH:mm:ss ");
                }
                return store;

            }
            catch (Exception ex)
            {

                throw new Exception("SecheduleServiceMgr-->GetScheduleLogList-->" + ex.Message, ex);
            }
        }
Exemplo n.º 4
0
        public int AddScheduleLog(ScheduleLogQuery query)
        {
            try
            {
                return _secheduleServiceDao.AddScheduleLog(query);
            }
            catch (Exception ex)
            {

                throw new Exception("SecheduleServiceMgr-->AddScheduleLog-->" + ex.Message, ex);
            }
        }
Exemplo n.º 5
0
 public List<ScheduleLogQuery> GetScheduleLogList(ScheduleLogQuery query, out int totalCount)// 得到 period表中的記錄
 {
     StringBuilder sql = new StringBuilder();
     StringBuilder sqlCondi = new StringBuilder();
     StringBuilder sqlCount = new StringBuilder();
     totalCount = 0;
     try
     {
         sqlCount.AppendFormat("SELECT count(sl.rowid) as totalCount from schedule_log sl ");
         sql.AppendFormat("select sl.rowid,sl.schedule_code,schedule_master.schedule_name,mu1.user_username as create_username,sl.create_time,sl.ipfrom ");
         sql.Append(" from schedule_log sl left join schedule_master on schedule_master.schedule_code=sl.schedule_code LEFT JOIN manage_user mu1 on mu1.user_id=sl.create_user ");
         sqlCondi.Append(" where 1=1 ");
         if (!string.IsNullOrEmpty(query.schedule_code))
         {
             sqlCondi.AppendFormat(" and sl.schedule_code='{0}' ", query.schedule_code);
         }
         if (query.start_time != 0)
         {
             sqlCondi.AppendFormat(" and sl.create_time >= '{0}' ", query.start_time);
         }
         if (query.end_time != 0)
         {
             sqlCondi.AppendFormat(" and sl.create_time <= '{0}' ", query.end_time);
         }
         
         if (query.IsPage)
         {
             //StringBuilder strpage = new StringBuilder();
             //StringBuilder strcontpage = new StringBuilder();
             //strpage.AppendFormat(" SELECT count(rowid) as totalCount FROM schedule_log  ");
             DataTable _dt = _access.getDataTable(sqlCount.ToString()+ sqlCondi.ToString());
             if (_dt.Rows.Count > 0)
             {
                 totalCount = Convert.ToInt32(_dt.Rows[0]["totalCount"]);
                 sqlCondi.AppendFormat(" order by sl.rowid desc  limit {0},{1} ", query.Start, query.Limit);
             }
         }
         return _access.getDataTableForObj<ScheduleLogQuery>(sql.ToString() + sqlCondi.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("ScheduleServiceDao-->GetScheduleLogList-->" + ex.Message, ex);
     }
 }
Exemplo n.º 6
0
 public int AddScheduleLog(ScheduleLogQuery query)
 {
     StringBuilder sql = new StringBuilder();
     try
     {
         sql.AppendFormat(@"INSERT INTO `schedule_log` ( `schedule_code`,  `create_user`, `create_time`, `ipfrom`) VALUES ('{0}', '{1}', '{2}', '{3}');", query.schedule_code, query.create_user, Common.CommonFunction.GetPHPTime(), query.ipfrom);
         return _access.execCommand(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("ScheduleServiceDao-->AddScheduleLog-->" + ex.Message, ex);
     }
 }