コード例 #1
0
ファイル: ImageService.cs プロジェクト: orrpaz/ImageService01
        /// <summary>
        /// ImageService constructor.
        /// </summary>
        /// <param name="args">command line args</param>
        public ImageService(string[] args)
        {
            InitializeComponent();
            info = ConfigInfomation.Instance;
            // for APP.config
            // string outputFolder = ConfigurationManager.AppSettings["OutputDir"];
            //int thumbnailSize = Int32.Parse(ConfigurationManager.AppSettings["ThumbnailSize"]);
            // string eventSourceName = ConfigurationManager.AppSettings["SourceName"];
            // string logName = ConfigurationManager.AppSettings["LogName"];
            string eventSourceName = info.eventSourceName;
            string logName         = info.logName;

            //Change to insert params (if exist)
            //if (args.Count() > 0)
            //{
            //   eventSourceName = args[0];
            //}
            //if (args.Count() > 1)
            //{
            //    logName = args[1];
            //}
            eventLog1 = new System.Diagnostics.EventLog();
            if (!System.Diagnostics.EventLog.SourceExists(eventSourceName))
            {
                System.Diagnostics.EventLog.CreateEventSource(eventSourceName, logName);
            }
            eventLog1.Source = eventSourceName;
            eventLog1.Log    = logName;
            eventLog1.Clear();
            int a = eventLog1.Entries.Count;

            //eventLog1.WriteEntry("Num of entries: " + a, EventLogEntryType.Information, eventId++);
            //eventLog1.WriteEntry("eventId: " + eventId, EventLogEntryType.Information, eventId++);

            // create LoggingService, CurrentRunLog, ImageServiceModal, ImageController
            m_currentLog             = new CurrentRunLog();
            logging                  = new LoggingService();
            logging.MessageRecieved += m_currentLog.AddToLog;  //Write log in CurrentRunLog
            logging.MessageRecieved += eventLog1_EntryWritten; //Write log in entry

            modal      = new ImageServiceModal(ConfigInfomation.Instance.outputDir, ConfigInfomation.Instance.thumbnailSize);
            controller = new ImageController(modal);
            //Adding new option of LogCommand
            controller.insertCommand((int)CommandEnum.LogCommand, new GetCurrentRunLogCommand(m_currentLog));
        }