/// <summary> /// start function of the service: /// - creats output directory /// - creats server, modal, conntroler and logger. /// </summary> /// <param name="args">arguments</param> protected override void OnStart(string[] args) { this.m_logging = new LoggingService(); this.m_logging.AddEvent(OnMsg); m_logging.Log("In OnStart", MessageTypeEnum.INFO); // Set up a timer to trigger every minute. System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 60000; // 60 seconds timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer); timer.Start(); timer.Enabled = true; // Update the service state to Start Pending. ServiceStatus serviceStatus = new ServiceStatus(); serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING; serviceStatus.dwWaitHint = 100000; SetServiceStatus(this.ServiceHandle, ref serviceStatus); // Update the service state to Running. serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING; SetServiceStatus(this.ServiceHandle, ref serviceStatus); string outputFolder = CreateOutputDirFolder(); int thumbnailSize = int.Parse(ConfigurationManager.AppSettings["ThumbnailSize"]); this.m_modal = new ImageServiceModal(outputFolder, thumbnailSize); this.m_controller = new ImageController(this.m_modal); Console.WriteLine("creating Server"); this.m_imageServer = new ImageServer(this.m_controller, this.m_logging); this.m_imageServer.Start(); }
protected override void OnStart(string[] args) { string outputDir = ConfigurationManager.AppSettings.Get("OutputDir"); int thumbnailSize = Int32.Parse(ConfigurationManager.AppSettings.Get("ThumbnailSize")); modal = new ImageServiceModal(outputDir, thumbnailSize); logger = new LoggingService(); logger.MessageRecieved += OnMessage; controller = new ImageController(modal, logger); this.logger.Log("On Start", MessageTypeEnum.INFO); server = new ImageServer(controller, logger); // Update the service state to Start Pending. ServiceStatus serviceStatus = new ServiceStatus(); serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING; serviceStatus.dwWaitHint = 100000; SetServiceStatus(this.ServiceHandle, ref serviceStatus); // Set up a timer to trigger every minute. System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 60000; // 60 seconds timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer); timer.Start(); // Update the service state to Running. serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING; SetServiceStatus(this.ServiceHandle, ref serviceStatus); }
private void CreateParts() { // now reading from configuration file: ConfigData conf = new ConfigData ( ConfigurationManager.AppSettings["Handler"].Split(';'), ConfigurationManager.AppSettings["OutputDir"], ConfigurationManager.AppSettings["SourceName"], ConfigurationManager.AppSettings["LogName"], int.Parse(ConfigurationManager.AppSettings["ThumbnailSize"]) ); this.config = conf; // model create: this.modal = new ImageServiceModal(conf.OutputDir, conf.ThumbnailSize); // Logger create and assign to event(in LoggingService) this.logging = new LoggingService(); this.logging.MessageRecieved += eventLog1_EntryWritten; this.m_imageServer = new ImageServer(this.controller, this.logging, conf.OutputDir, conf.Paths); this.controller = new ImageController(this.modal, this.logging, this.m_imageServer); }
/// <summary> /// Service constructor /// </summary> public ImageService() { try { //read params from app config eventLog1 = new System.Diagnostics.EventLog(); eventLog1.Source = ConfigurationManager.AppSettings.Get("SourceName"); eventLog1.Log = ConfigurationManager.AppSettings.Get("LogName"); //initialize members this.logging = new LoggingService(this.eventLog1); this.logging.MessageRecieved += WriteMessage; string output = ConfigurationManager.AppSettings.Get("OutputDir"); int thumbSize = Int32.Parse(ConfigurationManager.AppSettings.Get("ThumbnailSize")); this.modal = new ImageServiceModal(output, thumbSize); this.controller = new ImageController(this.modal, this.logging); this.m_imageServer = new ImageServer(controller, logging); this.controller.Server = m_imageServer; int port = 8000; IClientHandler handler = new ClientHandler(controller, logging); ServiceServer = new ServiceServer(logging, handler, port); ImageServer.UpdateOnRemovingHandler += ServiceServer.Update; this.logging.UpdateLogItems += ServiceServer.Update; ServiceServer.StartServer(); //TCP server starting ITCPClientHandler tcpHandler = new TCPClientHandler(controller, logging); ITCPServer tcpServer = new TCPServer(7000, logging, tcpHandler); tcpServer.StartServer(); } catch (Exception e) { this.eventLog1.WriteEntry(e.Message, EventLogEntryType.Error); } }
/// <summary> /// ImageService constructor. /// </summary> /// <param name="args">command line args</param> public ImageService(string[] args) { InitializeComponent(); // 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"]; 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; // create LoggingService, ImageServiceModal, ImageController logging = new LoggingService(); logging.MessageRecieved += eventLog1_EntryWritten; modal = new ImageServiceModal(outputFolder, thumbnailSize); controller = new ImageController(modal); }
/// <summary> /// starts service /// </summary> /// <param name="args"> for starting service. </param> protected override void OnStart(string[] args) { // Update the service state to Start Pending. ServiceStatus serviceStatus = new ServiceStatus(); serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING; serviceStatus.dwWaitHint = 100000; SetServiceStatus(this.ServiceHandle, ref serviceStatus); logging.Log("In OnStart", MessageTypeEnum.INFO); // Set up a timer to trigger every minute. System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 60000; // 60 seconds timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer); timer.Start(); // Update the service state to Running. serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING; SetServiceStatus(this.ServiceHandle, ref serviceStatus); modal = new ImageServiceModal(); controller = new ImageController(modal, logging); m_imageServer = new ImageServer(logging, modal, controller); logging.MessageRecieved += m_imageServer.UpdateLog; }
private Dictionary <int, ICommand> commands; //contains all the possible commands //c'tor for ImageController public ImageController(IImageServiceModal modal, ILoggingService ils) { commands = new Dictionary <int, ICommand>(); commands.Add((int)CommandsEnum.NewFileCommand, new NewFileCommand(modal)); commands.Add((int)CommandsEnum.GetConfigCommand, new GetConfigCommand()); commands.Add((int)CommandsEnum.LogsCommand, new LogsCommand(ils)); }
/// <summary> /// Initializes a new instance of the <see cref="ImageController"/> class. /// </summary> /// <param name="modal">The modal.</param> public ImageController(IImageServiceModal modal, ILoggingService loggingService) { m_modal = modal; // Storing the Modal Of The System CommandEnum y = CommandEnum.NewFileCommand; CommandEnum g = CommandEnum.GetConfigCommand; CommandEnum l = CommandEnum.LogCommand; //CommandEnum a = CommandEnum.AddLog; CommandEnum c = CommandEnum.CloseCommand; CommandEnum d = CommandEnum.DeleteFileCommand; // CommandEnum cc = CommandEnum.CloseClient; commands = new Dictionary <int, ICommand>() { // For Now will contain NEW_FILE_COMMAND { (int)y, new NewFileCommand(m_modal) }, { (int)g, new GetConfigCommand() }, { (int)l, new LogCommand(loggingService) }, //{ (int)a, new AddLog(m_modal)}, { (int)c, new CloseCommand(m_modal) }, { (int)d, new DeleteFileCommand(m_modal) }, // { (int)ch, new CloseHandlerCommand(imageServer)} // { (int)cc, new CloseClient()} }; }
public ImageService(string[] args) { InitializeComponent(); string eventSourceName = ConfigurationManager.AppSettings.Get("SourceName"); string 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; //initialize the members this.modal = new ImageServiceModal() { OutputFolder = ConfigurationManager.AppSettings.Get("OutputDir"), thumbnailSize = Int32.Parse(ConfigurationManager.AppSettings.Get("ThumbnailSize")) }; this.controller = new ImageController(this.modal); this.logging = new LoggingService(); this.logging.MessageRecieved += this.WriteMessage; string[] directories = (ConfigurationManager.AppSettings.Get("Handler").Split(';')); this.imageServer = new ImageServer(this.controller, this.logging, directories, directories.Length); }
/// <summary> /// constructor /// </summary> /// <param name="args"></param> public ImageService(string[] args) { InitializeComponent(); string outputFolder = ConfigurationManager.AppSettings.Get("OutputDir"); int thumbnailSize = Int32.Parse(ConfigurationManager.AppSettings.Get("ThumbnailSize")); this.modal = new ImageServiceModal(outputFolder, thumbnailSize); this.controller = new ImageController(this.modal); string eventSourceName = ConfigurationManager.AppSettings.Get("SourceName"); string logName = ConfigurationManager.AppSettings.Get("LogName"); if (args.Count() > 0) { eventSourceName = args[0]; } if (args.Count() > 1) { logName = args[1]; } eventLog = new System.Diagnostics.EventLog(); if (!System.Diagnostics.EventLog.SourceExists(eventSourceName)) { System.Diagnostics.EventLog.CreateEventSource(eventSourceName, logName); } eventLog.Source = eventSourceName; eventLog.Log = logName; }
/** * constructor for the current class. */ public ImageController(IImageServiceModal model1) { this.model = model1; commands = new Dictionary <int, ICommand>(); commands.Add((int)CommandEnum.NewFileCommand, new AddFile(model)); //commands.Add((int)CommandEnum.CloseCommand, new AddFile(model)); - possible to next exercise }
/// <summary> /// getting the settings from the app config and Initializing the service /// </summary> /// <param name="args">arguments</param> public ImageService(string[] args) { InitializeComponent(); string handler = ConfigurationManager.AppSettings.Get("Handler"); string outputDir = ConfigurationManager.AppSettings.Get("OutputDir"); string thumbnailSize = ConfigurationManager.AppSettings.Get("ThumbnailSize"); string eventSourceName = ConfigurationManager.AppSettings.Get("SourceName"); string 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; logging = new LoggingService(); logging.MessageRecieved += OnMsg; modal = new ImageServiceModal(outputDir, int.Parse(thumbnailSize)); controller = new ImageController(modal, logging); imageServer = new ImageServer(controller, logging, handler); //clientHandler = new HandleGuiClient(controller, logging, imageServer); clientHandler = new HandleAndroidClient(controller, logging, imageServer); serverChannel = new TcpServerChannel(8000, logging, clientHandler); clientHandler.NotifyClients += serverChannel.NotifyClients; }
public ImageService(string[] args) { InitializeComponent(); this.logCollectionSingleton = LogCollectionSingleton.Instance; eventLog1 = new System.Diagnostics.EventLog(); //app config values string eventSourceName = ConfigurationManager.AppSettings.Get("SourceName"); string logName = ConfigurationManager.AppSettings.Get("LogName"); if (!System.Diagnostics.EventLog.SourceExists(eventSourceName)) { System.Diagnostics.EventLog.CreateEventSource(eventSourceName, logName); } eventLog1.Source = eventSourceName; eventLog1.Log = logName; this.logger = new LoggingService(); //register this messageRecived function to the MessageRecieved event in the logger this.logger.MessageRecieved += MessageRecievedOperation; this.model = new ImageServiceModal() { OutputFolder = ConfigurationManager.AppSettings.Get("OutputDir"), ThumbnailSize = Int32.Parse(ConfigurationManager.AppSettings.Get("ThumbnailSize")) }; this.controller = new ImageController(this.model); this.m_imageServer = new ImageServer(this.controller, this.logger); this.controller.ImageServer = this.m_imageServer; this.m_appServer = new AppServer(this.controller, this.logger); }
/// <summary> /// starts service and creates the main objects of the exercise /// </summary> /// <param name="args"> for starting service. </param> protected override void OnStart(string[] args) { // In order to create the ImageServiceModal we need to read two fields from the App.config string outputFolder = ConfigurationManager.AppSettings["OutputDir"]; int thumbnailSize = Int32.Parse(ConfigurationManager.AppSettings["ThumbnailSize"]); logger = new LoggingService(); modal = new ImageServiceModal(outputFolder, 120); controller = new ImageController(modal); m_imageServer = new ImageServer(logger, controller); m_imageServer.createHandlers(); ServiceStatus serviceStatus = new ServiceStatus(); serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING; serviceStatus.dwWaitHint = 100000; SetServiceStatus(this.ServiceHandle, ref serviceStatus); eventLog1.WriteEntry("In OnStart"); System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 60000; // 60 seconds timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer); timer.Start(); timer.Enabled = true; // Update the service state to Running. serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING; SetServiceStatus(this.ServiceHandle, ref serviceStatus); }
private Dictionary <int, ICommand> commands; // A dictionary for the commands /// <summary>ImageController Cntr.</summary> /// <param name="modal">System modal</param> public ImageController(IImageServiceModal modal) { m_modal = modal; // Storing the Modal Of The System commands = new Dictionary <int, ICommand>(); //Creating a new dictionary // As given - will only contain new file command this.commands[((int)CommandEnum.NewFileCommand)] = new NewFileCommand(this.m_modal); }
public ImageController(IImageServiceModal modal) { Modal = modal; // Storing the Modal Of The System Commands = new Dictionary <CommandEnum, ICommand>() { { CommandEnum.NewFile, new NewFileCommand(Modal) } }; }
public ImageController(IImageServiceModal modal) { imageModal = modal; // Storing the Modal Of The System commands = new Dictionary <int, ICommand>() { }; commands[0] = new NewFileCommand(modal); }
/// <summary> /// constructor that creates a dictionary of the commands /// </summary> /// <param name="m_modal"></param> public ImageController(IImageServiceModal m_modal) { this.m_modal = m_modal; commands = new Dictionary <int, ICommand>() { { (int)CommandEnum.NewFileCommand, new NewFileCommand(m_modal) }, }; }
public ImageController(IImageServiceModal modal) { m_modal = modal; // Storing the Modal Of The System commands = new Dictionary <int, ICommand>() { { (int)CommandEnum.NewFileCommand, new NewFileCommand(m_modal) } }; }
public ImageController(IImageServiceModal modal) { m_modal = modal; // Storing the Modal Of The System commands = new Dictionary <int, ICommand>() { { (int)commandsEnum.NewFileCommand, new NewFileCommand(modal) } // For Now will contain NEW_FILE_COMMAND }; }
/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="modal">The modal.</param> public ImageController(IImageServiceModal modal) { m_modal = modal; // Storing the Modal Of The System commands = new Dictionary <int, ICommand>(); commands.Add((int)CommandEnum.NewFileCommand, new NewFileCommand(this.m_modal)); commands.Add((int)CommandEnum.GetConfigCommand, new GetConfigCommand()); //commands.Add((int)CommandEnum.CloseCommand, new CloseCommand()); }
/// <summary> /// Constructor for ImageController. /// </summary> /// <param name="modal"> Image service modal. </param> public ImageController(IImageServiceModal modal) { //storing the system's modal. m_modal = modal; commands = new Dictionary <int, ICommand>() { { (int)CommandEnum.NewFileCommand, new NewFileCommand(m_modal) } }; }
public ImageController(IImageServiceModal modal, Logger logs) { m_modal = modal; // Storing the Modal Of The System commands = new Dictionary <int, ICommand>(); commands.Add(1, new NewFileCommand(m_modal)); commands.Add(2, new GetConfigCommand()); commands.Add(3, new LogCommand(logs)); }
public ImageController(IImageServiceModal modal) { // Storing the Modal of the system m_modal = modal; commands = new Dictionary <int, ICommand>(); commands.Add((int)(CommandEnum.NewFileCommand), new NewFileCommand(modal)); commands.Add((int)(CommandEnum.GetConfigCommand), new GetConfigCommand()); commands.Add((int)(CommandEnum.LogCommand), new LogCommand()); }
/** * initialize all classes. */ public void initilaizeClasses() { modal = new ImageServiceModal(this.outputDir, this.thumbnailSize); eventLog1.WriteEntry("initilaizeClasses: " + this.outputDir); controller = new ImageController(modal); m_imageServer = new ImageServer(this.controller, this.logging); m_imageServer.Start(); logging.MessageRecieved += Logging_MessageRecieved;// (this,eventArgs) ; }
/// <summary> /// Initializes a new instance of the <see cref="ImageController"/> class. /// </summary> /// <param name="modal">The modal which manages the output directory.</param> public ImageController(IImageServiceModal modal) { m_modal = modal; commands = new Dictionary <int, ICommand>() { { (int)CommandEnum.NewFileCommand, new NewFileCommand(m_modal) } // For Now will contain NEW_FILE_COMMAND, since CLOSE_COMMAND is activated by server }; }
/// <summary> /// Constructor. Creates a new image controller. /// </summary> /// <param name="modal">The image service modal.</param> public ImageController(IImageServiceModal modal, ILoggingService logging) { m_modal = modal; // Storing the Modal Of The System m_logging = logging; commands = new Dictionary <int, ICommand>(); commands[(int)CommandEnum.NewFileCommand] = new NewFileCommand(m_modal); commands[(int)CommandEnum.GetConfigCommand] = new GetConfigCommand(); commands[(int)CommandEnum.LogCommand] = new LogCommand(m_logging); }
/// <summary> /// ImageController constructor /// </summary> /// <param name="modal"> the service modal</param> public ImageController(IImageServiceModal modal) { m_modal = modal; // Storing the Modal Of The System NewFileCommand nfc = new NewFileCommand(m_modal); commands = new Dictionary <int, ICommand>() { { 1, nfc } }; }
/// <summary> /// ImageController constructor from IImageServiceModal (that actually handles the image). /// </summary> /// <param name="modal"> IImageServiceModal the handles pictures </param> public ImageController(IImageServiceModal modal, ILoggingService loggingService) { imageModal = modal; // Storing the Modal Of The System commands = new Dictionary <int, ICommand>() { }; commands[0] = new NewFileCommand(modal); commands[1] = new GetConfigCommand(); commands[2] = new LogCommand(loggingService); }
//We want to pass via the thread the boolean result and the string of the result so we need to define a struct. /// <summary> /// the ImageController constructor, creates the commands dictionary. /// </summary> /// <param name="modal">An image modal</param> public ImageController(IImageServiceModal modal) { m_modal = modal; // Storing the Modal Of The System commands = new Dictionary <int, ICommand>(); //First put into the dictionary the new file command. //We have the command id on CommandEnum commands.Add((int)CommandEnum.NewFileCommand, new NewFileCommand(m_modal)); commands.Add((int)CommandEnum.GetConfigCommand, new GetConfigCommand()); //LogCollection logs = new LogCollection(); //logs.AddLog(new Log(1, "a")); }