Ejemplo n.º 1
0
        /// <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));
        }
Ejemplo n.º 2
0
        public event EventHandler <CommandRecievedEventArgs> CommandRecieved;          // The event that notifies about a new Command being recieved
        #endregion

        /// <summary>
        /// constructor.
        /// </summary>
        /// <param name="controller">controller</param>
        /// <param name="logging">logger</param>
        public ImageServer(IImageController controller, ILoggingService logging, ICurrentRunLog currentLog)
        {
            m_controller = controller;
            m_logging    = logging;
            m_currentLog = currentLog;
            m_ch         = new ClientHandler(m_controller, m_logging);
            m_tcpserver  = new TCPServer(port, m_ch, m_logging);
            // read from App config and put handlers in array of string.
            // string[] directories = ConfigurationManager.AppSettings.Get("Handler").Split(';');
            foreach (string directoryPath in ConfigInfomation.Instance.handlerPaths)
            {
                // create handler for each path.
                CreateHandler(directoryPath);
            }
            m_controller.SpecialCommanndAppeared += SendCommand;
            // m_controller.SpecialCommanndAppeared += PassLog;
            // m_logging.MessageRecieved += m_ch.UpdateClientsNewLog;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="cLog">The log from start of the service</param>
 public GetCurrentRunLogCommand(ICurrentRunLog cLog)
 {
     m_currentLog = cLog;
 }