예제 #1
0
        /// <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;
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Function that send log to client.
        /// </summary>
        /// <param name="g"> Message of the log. </param>
        public void SendLog(MessageRecievedEventArgs g)
        {
            try
            {
                //send all the new messages.
                foreach (MessageRecievedEventArgs m in path_list.ToList())
                {
                    if (!sended_logs.Contains(m))
                    {
                        string b      = m.Message;
                        string c      = m.Status.ToString();
                        string f      = "$";
                        string colour = "";
                        if (c == "INFO")
                        {
                            colour = "Green";
                        }
                        if (c == "ERROR")
                        {
                            colour = "Red";
                        }
                        if (c == "WARNING")
                        {
                            colour = "Yello";
                        }
                        imageServer.writeSocket("colour=" + colour + f + "log=" + c + f + "message="
                                                + b + f, tCP);

                        sended_logs.Add(m);
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
예제 #3
0
        /// <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);
            }
        }