Beispiel #1
0
        public void JudgeShape(ICustomLog log)
        {
            int tTypeCount     = 0;
            int revTTypeCount  = 0;
            int crossTypeCount = 0;

            foreach (KeyValuePair <DateTime, IStockData> entry in DailyStocks_)
            {
                if (ShapeJudger.IsCross(entry.Value))
                {
                    crossTypeCount++;
                }

                if (ShapeJudger.IsT(entry.Value))
                {
                    tTypeCount++;
                }

                if (ShapeJudger.IsReverseT(entry.Value))
                {
                    revTTypeCount++;
                }
            }

            log.LogInfo("Total Count = " + DailyStocks_.Count
                        + ", Cross = " + crossTypeCount
                        + ", T = " + tTypeCount
                        + ", Rev T = " + revTTypeCount);
        }
Beispiel #2
0
        /// <summary>
        /// Categorized stock performance by each day of one week
        /// </summary>
        /// <param name="log">logger for output results</param>
        public void AnalyzeEachDayOfOneWeek(ICustomLog log)
        {
            StockWeekData mondaydata = new StockWeekData();
            StockWeekData tuesdaydata = new StockWeekData();
            StockWeekData wednesdaydata = new StockWeekData();
            StockWeekData thursdaydata = new StockWeekData();
            StockWeekData fridaydata = new StockWeekData();

            foreach (WeeklyResult res in Results_.Values)
            {
                IStockData sdMonday = res.GetStockData(DayOfWeek.Monday);
                IStockData sdTuesday = res.GetStockData(DayOfWeek.Tuesday);
                IStockData sdWednesday = res.GetStockData(DayOfWeek.Wednesday);
                IStockData sdThursday = res.GetStockData(DayOfWeek.Thursday);
                IStockData sdFriday = res.GetStockData(DayOfWeek.Friday);

                mondaydata.AddStockData(sdMonday);
                tuesdaydata.AddStockData(sdTuesday);
                wednesdaydata.AddStockData(sdWednesday);
                thursdaydata.AddStockData(sdThursday);
                fridaydata.AddStockData(sdFriday);
            }

            log.LogInfo("Monday up percent: " + mondaydata.CalcUpPercent().ToString("F03")
                + ", Days = " + mondaydata.TotalDays);
            log.LogInfo("Tuesday up percent: " + tuesdaydata.CalcUpPercent().ToString("F03")
                + ", Days = " + tuesdaydata.TotalDays);
            log.LogInfo("Wednesday up percent: " + wednesdaydata.CalcUpPercent().ToString("F03")
                + ", Days = " + wednesdaydata.TotalDays);
            log.LogInfo("Thursday up percent: " + thursdaydata.CalcUpPercent().ToString("F03")
                + ", Days = " + thursdaydata.TotalDays);
            log.LogInfo("Friday up percent: " + fridaydata.CalcUpPercent().ToString("F03")
                + ", Days = " + fridaydata.TotalDays);
        }
Beispiel #3
0
        /// <summary>
        /// Categorized stock performance by each day of one week
        /// </summary>
        /// <param name="log">logger for output results</param>
        public void AnalyzeEachDayOfOneWeek(ICustomLog log)
        {
            StockWeekData mondaydata    = new StockWeekData();
            StockWeekData tuesdaydata   = new StockWeekData();
            StockWeekData wednesdaydata = new StockWeekData();
            StockWeekData thursdaydata  = new StockWeekData();
            StockWeekData fridaydata    = new StockWeekData();

            foreach (WeeklyResult res in Results_.Values)
            {
                IStockData sdMonday    = res.GetStockData(DayOfWeek.Monday);
                IStockData sdTuesday   = res.GetStockData(DayOfWeek.Tuesday);
                IStockData sdWednesday = res.GetStockData(DayOfWeek.Wednesday);
                IStockData sdThursday  = res.GetStockData(DayOfWeek.Thursday);
                IStockData sdFriday    = res.GetStockData(DayOfWeek.Friday);

                mondaydata.AddStockData(sdMonday);
                tuesdaydata.AddStockData(sdTuesday);
                wednesdaydata.AddStockData(sdWednesday);
                thursdaydata.AddStockData(sdThursday);
                fridaydata.AddStockData(sdFriday);
            }

            log.LogInfo("Monday up percent: " + mondaydata.CalcUpPercent().ToString("F03")
                        + ", Days = " + mondaydata.TotalDays);
            log.LogInfo("Tuesday up percent: " + tuesdaydata.CalcUpPercent().ToString("F03")
                        + ", Days = " + tuesdaydata.TotalDays);
            log.LogInfo("Wednesday up percent: " + wednesdaydata.CalcUpPercent().ToString("F03")
                        + ", Days = " + wednesdaydata.TotalDays);
            log.LogInfo("Thursday up percent: " + thursdaydata.CalcUpPercent().ToString("F03")
                        + ", Days = " + thursdaydata.TotalDays);
            log.LogInfo("Friday up percent: " + fridaydata.CalcUpPercent().ToString("F03")
                        + ", Days = " + fridaydata.TotalDays);
        }
 public BatchProcessing(ICustomLog log)
 {
     if (log == null)
     {
         throw new ArgumentNullException("log");
     }
     _log         = log;
     _ocrProvider = new OcrProvider(new GoogleOcrEngine(), new GoogleVisionLoader());
 }
Beispiel #5
0
		public DefaultLogger(ICustomLog innerLogger)
		{
			if (innerLogger == null)
			{
				throw new ArgumentNullException("innerLogger");
			}

			this.innerLogger = innerLogger;
		}
Beispiel #6
0
        /// <summary>
        /// 错误异常日志
        /// </summary>
        /// <param name="exceptionLog"></param>
        /// <param name="msg"></param>
        /// <param name="ex"></param>
        public static void ErrorExLog(ICustomLog <ILogger> exceptionLog, string msg, Exception ex)
        {
            if (null == exceptionLog)
            {
                return;
            }

            exceptionLog.GetLogger().Error(ex, msg);
        }
Beispiel #7
0
        /// <summary>
        /// 错误异常日志
        /// </summary>
        /// <param name="fatalLog"></param>
        /// <param name="msg"></param>
        /// <param name="ex"></param>
        public static void FatalLog(ICustomLog <ILogger> fatalLog, string msg, Exception ex)
        {
            if (null == fatalLog)
            {
                return;
            }

            fatalLog.GetLogger().Fatal(ex, msg);
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="log"></param>
        /// <param name="msg"></param>
        public static void InfoLog(ICustomLog <ILogger> log, string msg)
        {
            if (null == log)
            {
                return;
            }

            log.GetLogger().Info(msg);
        }
Beispiel #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="log"></param>
        /// <param name="msg"></param>
        public static void TraceLog(ICustomLog <ILogger> log, string msg)
        {
            if (null == log)
            {
                return;
            }

            log.GetLogger().Trace(msg);
        }
Beispiel #10
0
 /// <summary>
 /// Lookup the wrapper objects for the loggers specified
 /// </summary>
 /// <param name="loggers">the loggers to get the wrappers for</param>
 /// <returns>Lookup the wrapper objects for the loggers specified</returns>
 private static ICustomLog[] WrapLoggers(ILogger[] loggers)
 {
     ICustomLog[] results = new ICustomLog[loggers.Length];
     for (int i = 0; i < loggers.Length; i++)
     {
         results[i] = WrapLogger(loggers[i]);
     }
     return(results);
 }
Beispiel #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="log"></param>
        /// <param name="msg"></param>
        public static void DebugLog(ICustomLog <ILogger> log, string msg)
        {
            if (null == log)
            {
                return;
            }

            log.GetLogger().Debug(msg);
        }
Beispiel #12
0
        public void Check(ICustomLog log)
        {
            DateTime startDate = MinDate;

            while (startDate < MaxDate)
            {
                if ((GetStock(startDate) == null) && !Holidays.IsWeekend(startDate))
                {
                    log.LogInfo("Date: " + startDate.ToLongDateString() + ", has no stock data.");
                }
                startDate = startDate.AddDays(1);
            }

            JudgeShape(log);
        }
Beispiel #13
0
        /// <summary>
        /// Categorize the stock data
        /// </summary>
        /// <param name="log">logger for output results</param>
        public void CalcResult(ICustomLog log)
        {
            int notCalcWeeks = 0;
            Dictionary <string, int> templateNumbers = new Dictionary <string, int>();

            foreach (WeeklyResult res in Results_.Values)
            {
                string s = res.CalcUpTemplate();

                if (string.IsNullOrEmpty(s))
                {
                    notCalcWeeks++;
                    continue;
                }

                if (templateNumbers.ContainsKey(s))
                {
                    templateNumbers[s] = templateNumbers[s] + 1;
                }
                else
                {
                    templateNumbers.Add(s, 1);
                }
            }

            var keys  = templateNumbers.Keys;
            var query = keys.OrderBy(x => x);

            foreach (string item in query)
            {
                log.LogInfo(item + ": " + templateNumbers[item]);
            }

            log.LogInfo("Complete. Total weeks = " + Results_.Count
                        + ", categorized types = " + templateNumbers.Count
                        + ", error weeks = " + notCalcWeeks);
        }
        /// <summary>
        /// Print results to a logger
        /// </summary>
        /// <param name="log">a logger</param>
        public void PrintResult(ICustomLog log)
        {
            results_.CalcResult(log);

            results_.AnalyzeEachDayOfOneWeek(log);
        }
Beispiel #15
0
		private InternalLogService(ICustomLog log)
		{
			this.logger = log;
		}
Beispiel #16
0
        public void Check(ICustomLog log)
        {
            DateTime startDate = MinDate;
            while (startDate < MaxDate)
            {
                if ((GetStock(startDate) == null) && !Holidays.IsWeekend(startDate))
                {
                    log.LogInfo("Date: " + startDate.ToLongDateString() + ", has no stock data.");
                }
                startDate = startDate.AddDays(1);
            }

            JudgeShape(log);
        }
Beispiel #17
0
        public void JudgeShape(ICustomLog log)
        {
            int tTypeCount = 0;
            int revTTypeCount = 0;
            int crossTypeCount = 0;
            foreach (KeyValuePair<DateTime, IStockData> entry in DailyStocks_)
            {
                if (ShapeJudger.IsCross(entry.Value))
                {
                    crossTypeCount++;
                }

                if (ShapeJudger.IsT(entry.Value))
                {
                    tTypeCount++;
                }

                if (ShapeJudger.IsReverseT(entry.Value))
                {
                    revTTypeCount++;
                }
            }

            log.LogInfo("Total Count = " + DailyStocks_.Count
                + ", Cross = " + crossTypeCount
                + ", T = " + tTypeCount
                + ", Rev T = " + revTTypeCount);
        }
        /// <summary>
        /// Print results to a logger
        /// </summary>
        /// <param name="log">a logger</param>
        public void PrintResult(ICustomLog log)
        {
            results_.CalcResult(log);

            results_.AnalyzeEachDayOfOneWeek(log);
        }
Beispiel #19
0
		private void configService_ConfigFileChanged(object sender, ConfigFileChangedEventArgs e)
		{
			if (e.ConfigFileType == ConfigFileType.Log)
			{
				log4net.Repository.ILoggerRepository oldRepository = this.repository;
				ICustomLog oldLog4release = this.logger4release;
				ICustomLog oldLog4demo = this.logger4demo;

				log4net.Repository.ILoggerRepository newRepository = null;
				ICustomLog newLog4release = null;
				ICustomLog newLog4demo = null;

				lock (syncForRepository)
				{
					this.repository = null;
					this.logger4release = null;
					this.logger4demo = null;

					// 输出所有当前未输出日志然后关闭当前日志
					try
					{
						log4net.Appender.IAppender[] oldAppenders = oldRepository.GetAppenders();
						if (oldAppenders != null && oldAppenders.Length > 0)
						{
							for (int i = 0; i < oldAppenders.Length; i++)
							{
								if (oldAppenders[i] is log4net.Appender.BufferingAppenderSkeleton)
								{
									((log4net.Appender.BufferingAppenderSkeleton)oldAppenders[i]).Flush();
								}
							}
						}
					}
					catch{
					}
					finally
					{
						oldRepository.Shutdown();
					}

					// 创建新日志
					try
					{
						StringBuilder sb = new StringBuilder();

						newRepository = CustomLogManager.CreateRepository(Guid.NewGuid().ToString());

						log4net.Config.XmlConfigurator.Configure(newRepository, new FileInfo(AppDomain.CurrentDomain.MapPhysicalPath("conf\\log.config")));

						newLog4release = CustomLogManager.GetLogger(newRepository, "release");

						newLog4demo = CustomLogManager.GetLogger(newRepository, "demo");

						FormatConfigurationErrorMessages(sb, newRepository.ConfigurationMessages);

						if (sb.Length > 0) //出错时
						{
							sb.Insert(0, "在响应日志配置文件变化的过程中发生错误,仍将使用距变化发生时最近一次正确的配置。");

							// 输出 errorMessages
							LogUtil.LogToErrorLog(sb.ToString(), log4net.Core.Level.Error, LogCategory.Configuration, null);

							// 继续使用现有日志
							this.repository = null;
							this.logger4release = null;
							this.logger4demo = null;
						}
						else// 成功应用新配置时
						{
							// 应用新日志
							this.lastSuccessConfig = File.ReadAllText(AppDomain.CurrentDomain.MapPhysicalPath("conf\\log.config"));

							this.repository = newRepository;
							this.logger4release = newLog4release;
							this.logger4demo = newLog4demo;

							this.lock4loggers.EnterWriteLock();
							try
							{
								this.loggers.Clear();
							}
							finally
							{
								this.lock4loggers.ExitWriteLock();
							}
						}
					}
					catch (Exception err)
					{
						XMS.Core.Container.LogService.Warn("在响应日志配置文件变化的过程中发生错误,仍将使用距变化发生时最近一次正确的配置。", Logging.LogCategory.Configuration, err);

						if (newRepository != null)
						{
							try
							{
								newRepository.Shutdown();
							}
							catch { }
						}
					}
					finally
					{
						// 更新未成功,使用上次正确的日志配置重新初始化日志
						if (this.repository == null)
						{
							if(this.lastSuccessConfig != null)
							{
								this.repository = CustomLogManager.CreateRepository(Guid.NewGuid().ToString());
							
								using(MemoryStream stream = new MemoryStream(System.Text.Encoding.Default.GetBytes(this.lastSuccessConfig)))
								{
									log4net.Config.XmlConfigurator.Configure(this.repository,  stream);
								}

								this.logger4release = CustomLogManager.GetLogger(this.repository, "release");

								this.logger4demo = CustomLogManager.GetLogger(this.repository, "demo");
							}
							else
							{
								this.repository = oldRepository;
								this.logger4release = oldLog4release;
								this.logger4demo = oldLog4demo;
							}
						}
					}
				}
			}
		}
Beispiel #20
0
        /// <summary>
        /// Lookup the wrapper objects for the loggers specified
        /// </summary>
        /// <param name="loggers">the loggers to get the wrappers for</param>
        /// <returns>Lookup the wrapper objects for the loggers specified</returns>
		private static ICustomLog[] WrapLoggers(log4net.Core.ILogger[] loggers)
        {
            ICustomLog[] results = new ICustomLog[loggers.Length];
            for (int i = 0; i < loggers.Length; i++)
            {
                results[i] = WrapLogger(loggers[i]);
            }
            return results;
        }
Beispiel #21
0
        /// <summary>
        /// Categorize the stock data
        /// </summary>
        /// <param name="log">logger for output results</param>
        public void CalcResult(ICustomLog log)
        {
            int notCalcWeeks = 0;
            Dictionary<string, int> templateNumbers = new Dictionary<string, int>();
            foreach (WeeklyResult res in Results_.Values)
            {
                string s = res.CalcUpTemplate();

                if (string.IsNullOrEmpty(s))
                {
                    notCalcWeeks++;
                    continue;
                }

                if (templateNumbers.ContainsKey(s))
                {
                    templateNumbers[s] = templateNumbers[s] + 1;
                }
                else
                {
                    templateNumbers.Add(s, 1);
                }
            }

            var keys = templateNumbers.Keys;
            var query = keys.OrderBy(x => x);

            foreach (string item in query)
            {
                log.LogInfo(item + ": " + templateNumbers[item]);
            }

            log.LogInfo("Complete. Total weeks = " + Results_.Count
                + ", categorized types = " + templateNumbers.Count
                + ", error weeks = " + notCalcWeeks);
        }