示例#1
0
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="controller"> Image controller</param>
        /// <param name="logger">Image logger</param>
        public ImageServer(IImageController controller, ILoggingModel logger)
        {
            c_controller = controller;
            m_logging    = logger;
            //gets all paths of directory that needed to be handeled
            string[]      dir = AppSettingValue.Handlers.Split(';');
            StringBuilder sb  = new StringBuilder();

            foreach (string path in dir)
            {
                if (Directory.Exists(path))
                {
                    CreateHandler(path);
                    sb.Append(path).Append(';');
                }
                else
                {
                    m_logging.Log(path + " Directory dosen't found - can't handler this", MessageTypeEnum.FAIL);
                }
            }
            if (sb.Length != 0)
            {
                sb.Length--;
            }
            AppSettingValue.Handlers = sb.ToString();
        }
 /// <summary>
 /// cons't
 /// </summary>
 /// <param name="loggingModel"> loggingModal</param>
 /// <param name="imageController">Controller</param>
 /// <param name="path">which dorectory to listen</param>
 public DirectoyHandler(ILoggingModel loggingModel, IImageController imageController, string path)
 {
     c_imageController = imageController;
     m_loggingModel    = loggingModel;
     dirPath           = path;
     // list of filters to this directory
     watchers = new List <FileSystemWatcher>();
     this.StartHandleDirectory(path);
 }
示例#3
0
 public TcpServer(string ip, int port, IClientHandler handler, ILoggingModel log)
 {
     Ip      = ip;
     Port    = port;
     ch      = handler;
     logger  = log;
     clients = new List <TcpClient>();
     m_mutex = new Mutex();
 }
示例#4
0
        public ImageController(IImageServiceModel Model, ILoggingModel log)
        {
            m_Model  = Model;            // Storing the Model Of The System
            m_log    = log;
            commands = new Dictionary <int, ICommand>();

            commands.Add((int)CommandEnum.NewFileCommand, new NewFileCommand(m_Model));
            commands.Add((int)CommandEnum.LogHistoryCommand, new LogHistoryCommand(m_log));
            commands.Add((int)CommandEnum.CloseCommand, new CloseCommand());
        }
示例#5
0
 public ImageServer(string[] paths, IImageServiceModel imageModel, ILoggingModel log, IImageController controller)
 {
     m_logger     = log;
     m_controller = controller;
     pathList     = new List <string>(paths);
     foreach (string path in paths)
     {
         CreateHandler(path);
     }
 }
示例#6
0
        protected override void OnStart(string[] args)
        {
            string[] paths         = ConfigurationManager.AppSettings["Handler"].Split(';');
            string   outputDir     = ConfigurationManager.AppSettings["OutputDir"];
            string   sourceName    = ConfigurationManager.AppSettings["SourceName"];
            string   logName       = ConfigurationManager.AppSettings["LogName"];
            int      thumbnailSize = int.Parse(ConfigurationManager.AppSettings["ThumbnailSize"]);


            List <string> pathsList = new List <string>();

            foreach (string path in paths)
            {
                if (Directory.Exists(path))
                {
                    pathsList.Add(path);
                }
                else
                {
                    eventLogger.WriteEntry(DateTime.Now.ToString() + " " + path + ": Invalid Path To Directory");
                }
            }

            paths = pathsList.ToArray <string>();

            eventLogger = new System.Diagnostics.EventLog();
            if (!System.Diagnostics.EventLog.SourceExists(sourceName))
            {
                System.Diagnostics.EventLog.CreateEventSource(
                    sourceName, logName);
            }
            eventLogger.Source = sourceName;
            eventLogger.Log    = logName;

            eventLogger.WriteEntry(DateTime.Now.ToString() + " Service Started");


            // initialize logging
            logging = new LoggingModel();
            logging.MessageRecieved += OnMessageRecieved;
            // initialize servers controllers and modals
            imageModel        = new ImageServiceModel(outputDir, thumbnailSize);
            controller        = new ImageController(imageModel, logging);
            m_imageServer     = new ImageServer(paths, imageModel, logging, controller);
            controller.Server = m_imageServer;
            srv      = new TcpServer("127.0.0.1", 8000, (IClientHandler)controller, logging);
            receiver = new ImageReceiver(8001, m_imageServer, logging);
            ImageServer.NotifyHandlerRemoved += srv.Notify;
            this.logging.NotifyLogChanged    += srv.Notify;

            // start handeling clients
            receiver.Start();
            srv.Start();
        }
        /// <summary>
        /// cons't
        /// </summary>
        /// <param name="logModal">ILoggingModal</param>
        /// <param name="server"> ImageServer</param>
        public ServerController(ILoggingModel logModal, ImageServer server)
        {
            //Dictionary: key - CommandState , value - command to execute
            this.commands   = new Dictionary <int, ICommand>();
            this.m_logModal = logModal;
            this.sever      = server;

            //Get App Config command
            commands[(int)CommandStateEnum.GET_APP_CONFIG] = new GetAppConfigCommand();

            //Get All Log command
            commands[(int)CommandStateEnum.GET_ALL_LOG] = new GetLogCommand(this.m_logModal);

            //Close Handler command
            commands[(int)CommandStateEnum.CLOSE_HANDLER] = new CloseHandleCommand(this.sever);
        }
示例#8
0
        /// <summary>
        /// constructor - init logger, modal,server,controller
        /// </summary>
        /// <param name="args">Not used</param>
        public ImageService(string[] args)
        {
            InitializeComponent();

            eventSourceName = ConfigurationManager.AppSettings.Get("SourceName");
            logName         = ConfigurationManager.AppSettings.Get("LogName");



            eventLog1 = new System.Diagnostics.EventLog();


            if (!System.Diagnostics.EventLog.SourceExists(eventSourceName))
            {
                System.Diagnostics.EventLog.CreateEventSource(eventSourceName, logName);
            }
            eventLog1.Source = eventSourceName;
            eventLog1.Log    = logName;
            m_logging        = new LoggingModel(eventLog1);

            m_imageService = new ImageModel();
            c_controller   = new ImageController(m_imageService);
            server         = new ImageServer(c_controller, m_logging);

            IClientHandler ch = new ClientHandler(new ServerController(m_logging, this.server), this.m_logging);

            tcpServer = new TcpServer(8005, ch);

            m_logging.MessageRecieved += OnMsg;
            m_logging.MessageRecieved += tcpServer.NewLogArriaved;


            Task t = new Task(() =>
            {
                tcpServer.Start();
            });

            t.Start();
        }
 private ToolBarViewModel(ILoggingModel model) : base("Menu")
 {
     _model   = model;
     CanClose = false;
     Title    = string.Empty;
 }
示例#10
0
        public event EventHandler <DirectoryCloseEventArgs> DirectoryClose;              // The Event That Notifies that the Directory is being closed

        public DirectoyHandler(IImageController controller, ILoggingModel log)
        {
            m_controller = controller;
            m_logging    = log;
        }
示例#11
0
 /// <summary>
 /// constructor to Command
 /// </summary>
 /// <param name="logModal"> ILoggingModel</param>
 public GetLogCommand(ILoggingModel logModal)
 {
     this.log_Modal = logModal;
 }
 public LogHistoryCommand(ILoggingModel mod)
 {
     m_log = mod;
 }
示例#13
0
 /// <summary>
 /// constructor of ClientHandler
 /// </summary>
 /// <param name="ic"> Image controller</param>
 /// <param name="lm">IloggingModel</param>
 public ClientHandler(IImageController ic, ILoggingModel lm)
 {
     imageController = ic;
     loggingModel    = lm;
 }
示例#14
0
 public ImageReceiver(int port, ImageServer server, ILoggingModel log)
 {
     serv   = server;
     Port   = port;
     logger = log;
 }