Пример #1
0
        /// <summary>
        /// 带事务的Update
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="trans">The trans.</param>
        /// <returns></returns>
        /// <remarks>2015/10/19 10:48:08</remarks>
        public bool Update(ConfigScheduleEntity entity, DbTransaction trans)
        {
            var       database       = new SqlDatabase(this.ConnectionString);
            DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_ConfigSchedule_Update");

            database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, entity.Idx);
            database.AddInParameter(commandWrapper, "@Name", DbType.AnsiString, entity.Name);
            database.AddInParameter(commandWrapper, "@Category", DbType.Int32, entity.Category);
            database.AddInParameter(commandWrapper, "@ActionType", DbType.Int32, entity.ActionType);
            database.AddInParameter(commandWrapper, "@TimeType", DbType.Int32, entity.TimeType);
            database.AddInParameter(commandWrapper, "@Setting", DbType.AnsiString, entity.Setting);
            database.AddInParameter(commandWrapper, "@Times", DbType.Int32, entity.Times);
            database.AddInParameter(commandWrapper, "@RetryTimes", DbType.Int32, entity.RetryTimes);
            database.AddInParameter(commandWrapper, "@Parameters", DbType.AnsiString, entity.Parameters);
            database.AddInParameter(commandWrapper, "@RunDelay", DbType.Int32, entity.RunDelay);
            database.AddInParameter(commandWrapper, "@Description", DbType.String, entity.Description);


            int results = 0;

            if (trans != null)
            {
                results = database.ExecuteNonQuery(commandWrapper, trans);
            }
            else
            {
                results = database.ExecuteNonQuery(commandWrapper);
            }


            return(Convert.ToBoolean(results));
        }
Пример #2
0
 internal ScheduleInfo(ScheduleManager.ScheduleDelegate scheduleDelegate, ConfigScheduleEntity configSchedule)
 {
     if (scheduleDelegate == null)
     {
         throw new Exception("Init ScheduleInfo fail,scheduleDelegate is null");
     }
     _launcher = new ScheduleLauncher(scheduleDelegate);
     Init(configSchedule);
 }
Пример #3
0
        /// <summary>
        /// 将IDataReader的当前记录读取到ConfigScheduleEntity 对象
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public ConfigScheduleEntity LoadSingleRow(IDataReader reader)
        {
            var obj = new ConfigScheduleEntity();

            obj.Idx         = (System.Int32)reader["Idx"];
            obj.Name        = (System.String)reader["Name"];
            obj.Category    = (System.Int32)reader["Category"];
            obj.ActionType  = (System.Int32)reader["ActionType"];
            obj.TimeType    = (System.Int32)reader["TimeType"];
            obj.Setting     = (System.String)reader["Setting"];
            obj.Times       = (System.Int32)reader["Times"];
            obj.RetryTimes  = (System.Int32)reader["RetryTimes"];
            obj.Parameters  = (System.String)reader["Parameters"];
            obj.RunDelay    = (System.Int32)reader["RunDelay"];
            obj.Description = (System.String)reader["Description"];

            return(obj);
        }
Пример #4
0
        /// <summary>
        /// GetById
        /// </summary>
        /// <param name="idx">idx</param>
        /// <returns>ConfigScheduleEntity</returns>
        /// <remarks>2015/10/19 10:48:08</remarks>
        public ConfigScheduleEntity GetById(System.Int32 idx)
        {
            var database = new SqlDatabase(this.ConnectionString);

            DbCommand commandWrapper = database.GetStoredProcCommand("P_ConfigSchedule_GetById");

            database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, idx);


            ConfigScheduleEntity obj = null;

            using (IDataReader reader = database.ExecuteReader(commandWrapper))
            {
                if (reader.Read())
                {
                    obj = LoadSingleRow(reader);
                }
            }
            return(obj);
        }
Пример #5
0
        private void Init(ConfigScheduleEntity configSchedule)
        {
            _monitor = SystemlogMgr.GetScheduleMonitor(configSchedule.Idx);
            if (_monitor == null)
            {
                throw new Exception("[ScheduleInfo] no monitor,schedule id:" + configSchedule.Idx);
            }
            _monitor.ScheduleTimeType = configSchedule.TimeType;
            _scheduleConfig           = configSchedule;
            _scheduleTimes            = configSchedule.Times;
            bool isChampion = CheckIsChampion(configSchedule.Idx);

            switch (configSchedule.TimeType)
            {
            default:
            case (int)EnumScheduleTimeType.TimeTable:
                _timeConfig = new ScheduleTimeConfigTimeTable(configSchedule.Setting, isChampion);
                break;

            case (int)EnumScheduleTimeType.Interval:
                _timeConfig = new ScheduleTimeConfigInterval(configSchedule.Setting);
                break;
            }
            if (_scheduleConfig.RetryTimes > 0)
            {
                _maxRetryTimes = _scheduleConfig.RetryTimes - 1;
            }
            if (configSchedule.RunDelay >= 0)
            {
                _nextInvokedDateTime = DateTime.Now.AddMinutes(configSchedule.RunDelay);
            }
            else
            {
                _nextInvokedDateTime = _timeConfig.GetNext(DateTime.Now);
            }
            if (_scheduleConfig.TimeType == (int)EnumScheduleTimeType.Interval && _timeConfig.GetIntervalTime() < 1000)
            {
                _isIntensive = true;
            }
            Log("下次时间" + _nextInvokedDateTime);
        }
Пример #6
0
        public static bool Update(ConfigScheduleEntity configScheduleEntity, DbTransaction trans = null, string zoneId = "")
        {
            var provider = new ConfigScheduleProvider(zoneId);

            return(provider.Update(configScheduleEntity, trans));
        }
Пример #7
0
 internal ScheduleInfo(ScheduleManager.ScheduleDelegateNextTime scheduleDelegate, ConfigScheduleEntity configSchedule)
 {
     if (scheduleDelegate == null)
     {
         throw new Exception("Init ScheduleInfo fail,scheduleDelegate is null");
     }
     Init(configSchedule);
     _launcher = new ScheduleLauncherNextTime(scheduleDelegate, _timeConfig.GetIntervalTime());
 }
Пример #8
0
 /// <summary>
 /// Update
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 /// <remarks>2015/10/19 10:48:08</remarks>
 public bool Update(ConfigScheduleEntity entity)
 {
     return(Update(entity, null));
 }
Пример #9
0
 /// <summary>
 /// Insert
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="trans">The trans.</param>
 /// <returns></returns>
 /// <remarks>2015/10/19 10:48:08</remarks>
 public bool Insert(ConfigScheduleEntity entity)
 {
     return(Insert(entity, null));
 }