Exemplo n.º 1
0
 //============================================================
 // <T>格式化。</T>
 //
 // @param buffer 字符串对象
 // @param level 级别
 //============================================================
 public virtual void Format(FString format, ELoggerLevel level, object refer, string method, Exception exception, string message, object[] parameters)
 {
     // 追加时间
     format += RDate.Format(_dateFormat) + ' ';
     // 追加级别
     AppendLevel(format, level);
     // 追加线程编号
     format += ':' + Thread.CurrentThread.ManagedThreadId.ToString("X2");
     // 追加函数信息
     if (refer is Type)
     {
         format += "-<static> [";
         format += ((Type)refer).Name + '.' + method;
     }
     else
     {
         format += "-" + refer.GetHashCode().ToString("X8") + " [";
         format += refer.GetType().Name + '.' + method;
     }
     format.AppendRepeat(' ', LOGGER_SPACE - format.Length);
     format += "] ";
     // 追加信息内容
     if (null != parameters)
     {
         format += String.Format(message, parameters);
     }
     // 追加例外内容
     if (null != exception)
     {
         format.AppendLine();
         RException.MakeMessage(format, exception);
     }
 }
Exemplo n.º 2
0
 public virtual void SaveConfig(FXmlNode config)
 {
     // Type
     config[PTY_TYPE] = _type.ToString();
     config.Set(PTY_VALID, _valid);
     // Day config
     config.Set(PTY_DAY_INTERVAL, _dayInterval);
     // Week config
     config.Set(PTY_WEEK_INTERVAL, _weekInterval);
     config[PTY_WEEKDAYS] = ((int)_weekDays).ToString();
     // Month config
     config[PTY_MONTH_TYPE] = ((int)_monthType).ToString();
     config.Set(PTY_MONTH_INTERVAL, _monthInterval);
     config.Set(PTY_MONTH_DAY, _monthDay);
     config[PTY_MONTH_WEEK] = ((int)_monthWeek).ToString();
     config.Set(PTY_MONTH_WEEK_DAY, _monthWeekDay);
     config[PTY_MONTHS] = ((int)_months).ToString();
     // Once config
     config[PTY_ONCE_DATE] = RDate.Format(_onceDate, FMT_DATE);
     // Public config
     config[PTY_BEGIN_DATE] = RDate.Format(_beginDate, FMT_DATE);
     config.Set(PTY_END_VALID, _endValid);
     config[PTY_END_DATE] = RDate.Format(_endDate, FMT_DATE);
     config[PTY_TIME]     = RDate.Format(_time, FMT_TIME);
 }
Exemplo n.º 3
0
        public void Load()
        {
            // Create AppDomain
            string domainName = RDate.Format("Domain-HH24MISS");

            _domain = AppDomain.CreateDomain(domainName, _evidence, _setup);
            // Create Loader
            string assemblyName = typeof(FAppLoader).Assembly.FullName;
            string loaderName   = typeof(FAppLoader).FullName;

            _loader = (FAppLoader)_domain.CreateInstanceAndUnwrap(assemblyName, loaderName);
        }
Exemplo n.º 4
0
        protected void QueryNextJobs(DateTime date)
        {
            // Query next datetime
            DateTime result = DateTime.MaxValue;

            while (true)
            {
                result = DateTime.MaxValue;
                foreach (FSchedule schedule in _console.Schedules)
                {
                    if (schedule.Valid)
                    {
                        DateTime next = schedule.QueryNextRunTime(_lastDateTime);
                        result = (next < result) ? next : result;
                    }
                }
                if (result == DateTime.MaxValue || result > date)
                {
                    break;
                }
                if (result <= date)
                {
                    UpdateJobs(result, _lastDateTime);
                    _lastDateTime = result;
                }
            }
            if (!_scheduleJobs.IsEmpty())
            {
                FScheduleThread thread = new FScheduleThread(_scheduleJobs.Flush());
                thread.Process();
            }
            // Set next timer
            TimeSpan intervalSpan = result - date;

            if (intervalSpan == TimeSpan.Zero)
            {
                throw new FFatalException("Invalid interval(zero)");
            }
            if (intervalSpan > MAX_INTERVAL)
            {
                intervalSpan = MAX_INTERVAL;
            }
            else
            {
                UpdateJobs(result, _lastDateTime);
            }
            _lastDateTime = date;
            if (_logger.DebugAble)
            {
                _logger.Debug(this, "QueryNextJobs", "Last=[{0}] next=[{1}] count=[{2}] interval=[{3}]",
                              RDate.Format(_lastDateTime, "yymmdd hh24miss"),
                              RDate.Format(result, "yymmdd hh24miss"),
                              _scheduleJobs.Count, intervalSpan.ToString());
            }
            // Set next timer
            _timer.Interval = intervalSpan.TotalMilliseconds;
            if (!_isActive)
            {
                _timer.Start();
                _isActive = true;
            }
        }
Exemplo n.º 5
0
 public void Process()
 {
     if (CheckCondition())
     {
         _logger.Debug(this, "Process", "Process schedule - start (date=[{0}] text=[{1}])", RDate.Format(DateTime.Now, "yymmdd hh24miss"), _text);
         _events.Process();
         _logger.Debug(this, "Process", "Process schedule - end");
     }
 }