/// <summary> /// Constructor for ImageServer class /// </summary> /// <param name="logging">the logging service that will be connected to the image service</param> /// <param name="port">the port of the tcp server the constructor creates</param> public ImageServer(ILoggingService logging, int port) { m_logging = logging; IImageServiceModal modal = new ImageServiceModal(); m_controller = new ImageController(modal); m_clientHandler = new ClientHandler(m_controller); m_TCPServer = new TcpServerChannel(port, m_clientHandler); m_handlerManager = HandlerManager.Instance; m_handlerManager.Logging = m_logging; m_handlerManager.Controller = m_controller; m_handlerManager.CommandRecieved += delegate(object sender, CommandRecievedEventArgs e) { switch (e.CommandID) { case (int)CommandEnum.RemoveHandler: CommandMessage message = new CommandMessage { Status = true, Type = CommandEnum.RemoveHandler, Message = @"Removed handler " + e.RequestDirPath, Handlers = new string[] { e.RequestDirPath } }; m_logging.Log(message.Message, LogMessageTypeEnum.INFO); m_TCPServer.SendMessage(message.ToJSONString(), ServerMessageTypeEnum.CloseHandlerMessage); break; default: break; } }; m_logStorage = LogStorage.Instance; m_logging.MessageRecieved += m_logStorage.AddLog; }
public void TestMethod1() { int tumb = 120; bool result; string OutputDir = "C:\\Users\\Orian Edri\\Desktop\\ImageServiceDir\\Images"; IImageServiceModal imageModal = new ImageServiceModal(OutputDir, tumb); string ss = imageModal.AddFile("C:\\Users\\Orian Edri\\Desktop\\ImageServiceDir\\Handler1\\ll.jpg", out result); Assert.AreEqual(result, true, ss); }
/// <summary> /// constructor /// </summary> /// <param name="logger">logging service</param> public ImageServer(ILoggingService logger) { System.Text.Encoding enc = System.Text.Encoding.ASCII; this.m_logging = logger; this.m_logging.MessageRecieved += WriteLogMessage; //split all directories to handle from the appconfig string paths = ConfigurationManager.AppSettings["Handler"]; this.seperatedPaths = paths.Split(';'); //save the outputDir from appconfig string outPutDir = ConfigurationManager.AppSettings["outputDir"]; //save the source name from appconfig string sourceName = ConfigurationManager.AppSettings["SourceName"]; //save the log name from appconfig string logNmae = ConfigurationManager.AppSettings["LogName"]; //extract thumbnail size from appconfig string thumbnailSize = ConfigurationManager.AppSettings["ThumbnailSize"]; //create a new modal - send as inputs the outputDir path and desiered thumbnail size IImageServiceModal imageModal = new ImageServiceModal(outPutDir, Int32.Parse(thumbnailSize), m_logging); this.m_controller = new ImageController(imageModal); //create a direcotry handler for each path in the handler section extracted from the appconfig foreach (string path in seperatedPaths) { CreateHandler(path); } //creates the tcpServer and register to it's events of getting a new client and reciving commands new Task(() => { this.androidServer = new TcpAndroidServer(this.seperatedPaths); this.tcpServer = new TcpTimeServer(); this.tcpServer.NewClientConnected += this.SendSettingsAndLog; this.tcpServer.PassInfoFromClientHandlerToServer += this.GetCommandFromService; this.androidServer.Start(); this.tcpServer.Start(); }).Start(); }