示例#1
0
        /// <summary>
        /// The method creates directory handlers based on the directories received from app.config.
        /// </summary>
        private void CreateHandlers()
        {
            string handlerPaths = ConfigurationManager.AppSettings["Handler"];

            string[] paths = handlerPaths.Split(';');
            foreach (string path in paths)
            {
                imageServer.CreateHandler(path);
            }
        }
示例#2
0
        /// <summary>
        /// Constructor for ImageService.
        /// </summary>
        /// <param name="args"> Arguments. </param>
        public ImageService(string[] args)
        {
            InitializeComponent();
            string eventSourceName = ConfigurationManager.AppSettings.Get("SourceName");
            string logName         = ConfigurationManager.AppSettings.Get("LogName");
            string outputDir       = ConfigurationManager.AppSettings.Get("OutputDir");
            string handler         = ConfigurationManager.AppSettings.Get("Handler");
            int    ThumbnailSize   = int.Parse(ConfigurationManager.AppSettings.Get("ThumbnailSize"));

            if (args.Count() > 0)
            {
                eventSourceName = args[0];
            }
            if (args.Count() > 1)
            {
                logName = args[1];
            }
            if (eventSourceName == null)
            {
                eventSourceName = "MySource";
            }
            if (logName == null)
            {
                logName = "MyNewLog";
            }

            eventLog1 = new System.Diagnostics.EventLog();
            try {
                if (!System.Diagnostics.EventLog.SourceExists(eventSourceName))
                {
                    System.Diagnostics.EventLog.CreateEventSource(eventSourceName, logName);
                }
            } catch (Exception e)
            {
                return;
            }

            eventLog1.Source         = eventSourceName;
            eventLog1.Log            = logName;
            logging                  = new LoggingService();
            logging.MessageRecieved += MessageTypes;

            // create image service model
            modal = new ImageServiceModal(outputDir, ThumbnailSize);

            // create image controller
            controller    = new ImageController(modal);
            m_imageServer = new ImageServer(controller, logging);
            m_imageServer.CreateHandler(handler);
        }
示例#3
0
        /// <summary>
        ///     Initializes the settings information.
        /// </summary>
        private void InitializeSettingsInfo()
        {
            _settingsInfo = new SettingsInfo
            {
                OutputDirectory = ConfigurationManager.AppSettings["OutputDir"],
                SourceName      = ConfigurationManager.AppSettings["SourceName"],
                LogName         = ConfigurationManager.AppSettings["LogName"],
                ThumbnailSize   = !int.TryParse(ConfigurationManager.AppSettings["ThumbnailSize"], out int thumbnailSize)
                    ? 100
                    : thumbnailSize
            };

            string handledDirInfo = ConfigurationManager.AppSettings["HandledDirectories"];

            string[] handeledDirectories = handledDirInfo.Split(';');

            foreach (string handeledDir in handeledDirectories)
            {
                _settingsInfo.HandledDirectories.Add(handeledDir);
                _imageServer.CreateHandler(handeledDir);
            }
        }