/// <summary> /// constructor /// </summary> /// <param name="imageServer"></param> /// <param name="imageController"></param> /// <param name="logging"></param> /// <param name="port"></param> public MobileServer(ImageServer imageServer, IImageController imageController, ILoggingService logging, int port) { this.m_port = port; this.m_logging = logging; this.m_controller = imageController; this.m_imageServer = imageServer; this.m_ch = new ClientHandleForMobile(this.m_logging); }
/// <summary> /// Constractor. /// </summary> /// <param name="imageServer">The image server .</param> /// <param name="client"> The tcp client. </param> /// <param name="m_controller"> The image controller.</param> public HandleSettings(ImageServer imageServer, TcpClient client, IImageController m_controller) { imageServer.writeSocket(imageServer.AppConfigText(), client); NetworkStream ns = client.GetStream(); //string r = imageServer.readSocket(ns); if (client.Connected) { while (true) { string command = imageServer.readSocket(ns); string[] split = command.Split('$'); int id = 0; bool t = true; if (split[0] == "Exit Server") { break; } if (split[0] == "CloseCommand") { id = (int)CommandEnum.CloseCommand; imageServer.delete_handler(split[1]); m_controller.ExecuteCommand(id, split, out t); } if (split[0] == "Exit Server") { break; } if (!client.Connected) { break; } if (!client.Connected) { break; } } } }
/* * Construct ImageServic by app configurations, modal, controller and logger */ public ImageService(string[] args) { InitializeComponent(); ConfigurationData configData = new ConfigurationData(); // updates data from configurations manager string targetPath = ConfigurationManager.AppSettings["OutputDir"]; // destenation dir targetPath = targetPath.Replace(";", ""); configData.OutputDir = targetPath; configData.SourceName = ConfigurationManager.AppSettings["SourceName"]; // "MySource"; configData.LogName = ConfigurationManager.AppSettings["LogName"]; // "MyNewLog"; configData.ThumbnailSize = int.Parse(ConfigurationManager.AppSettings["ThumbnailSize"]); string[] handlers = ConfigurationManager.AppSettings["Handler"].Split(';'); if (handlers[handlers.Length - 1].Trim(' ') == string.Empty) { handlers = handlers.Take <string>(handlers.Length - 1).ToArray <string>(); } configData.Handlers = new List <string>(handlers); // create new eventLog by src eventLog1 = new EventLog(); if (!EventLog.SourceExists(configData.SourceName)) { EventLog.CreateEventSource(configData.SourceName, configData.LogName); } eventLog1.Source = configData.SourceName; eventLog1.Log = configData.LogName; // construct all members this.modal = new Modal.ImageServiceModal(targetPath, configData.ThumbnailSize); this.controller = new Controller.ImageController(this.modal); this.logging = new LoggingService(); this.logging.MessageRecieved += updateLog; Communicator communicator = new Communicator(configData, this.logging); this.m_imageServer = new Server.ImageServer(this.controller, this.logging, communicator); new Task(() => { communicator.StartAsync().Wait(); }).Start(); }
/// <summary> /// Set function. /// </summary> /// <param name="imageServer1">The image server.</param> /// <param name="loggingService1">The logging service.</param> /// <param name="tCP1">The tcp network stream.</param> public void SetAllProt(ImageServer imageServer1, ILoggingService loggingService1, TcpClient tCP1) { this.tCP = tCP1; this.imageServer = imageServer1; this.loggingService = loggingService1; sended_logs = new ObservableCollection <MessageRecievedEventArgs>(); ListLogg = loggingService.listOfLoggins(); ListLogg.CollectionChanged += collectionChange; //add all the logs message to the application. //send it by seperate by $. foreach (MessageRecievedEventArgs m in path_list.ToList()) { string b = m.Message; string c = m.Status.ToString(); string g = "$"; string colour = ""; if (c == "INFO") { colour = "Green"; } if (c == "ERROR") { colour = "Red"; } if (c == "WARNING") { colour = "Yello"; } imageServer.writeSocket("colour=" + colour + g + "log=" + c + g + "message=" + b + g, tCP1); i++; sended_logs.Add(m); } }