예제 #1
0
        /// <summary>
        /// The function sending to the tcp the command of closed handler to notify all clients
        /// </summary>
        /// <param name="dirPath"> dirPath of folder to remove </param>
        private void RemoveHandlerFromClients(string dirPath)
        {
            MessageCommand mc = new MessageCommand();

            mc.CommandID  = (int)CommandEnum.CloseCommand;
            mc.CommandMsg = dirPath;
            m_tcpServer.SendAll(mc.ToJSON());
        }
예제 #2
0
        /// <summary>
        /// Sends the remove dir.
        /// </summary>
        /// <param name="dir">The dir.</param>
        public void SendRemoveDir(string dir)
        {
            MessageCommand mc = new MessageCommand();

            mc.CommandID  = (int)CommandEnum.CloseCommand;
            mc.CommandMsg = dir;
            communicationHandler.Client.Send(mc.ToJSON());
        }
예제 #3
0
        public ActionResult DeleteHandler()
        {
            MessageCommand mc = new MessageCommand();

            mc.CommandID  = (int)CommandEnum.CloseCommand;
            mc.CommandMsg = m_directory;
            m_communication.Client.Send(mc.ToJSON());
            m_settingsModel.SettingsRequest();
            return(RedirectToAction("Settings"));
        }
예제 #4
0
        private void NewLogEntry(object sender, MessageRecievedEventArgs messageArgs)
        {
            MessageCommand mc = new MessageCommand();

            mc.CommandID = (int)CommandEnum.LogCommand;
            List <string> log = new List <string>();

            log.Add((messageArgs.Status as Enum).ToString() + ";" + messageArgs.Message);
            mc.CommandMsg = JsonConvert.SerializeObject(log);
            m_tcpServer.SendAll(mc.ToJSON());
        }
예제 #5
0
        /// <summary>
        /// C'tor
        /// </summary>
        public LogModel()
        {
            m_logEntries = new ObservableCollection <MessageRecievedEventArgs>();
            m_commands   = new Dictionary <int, CommandExecute>
            {
                { (int)CommandEnum.LogCommand, SetLogEntries }
            };
            communicationHandler = ModelCommunicationHandler.Instance;
            communicationHandler.DataReceived += GetCommand;
            MessageCommand mc = new MessageCommand();

            mc.CommandID  = (int)CommandEnum.LogCommand;
            mc.CommandMsg = "";
            communicationHandler.Client.Send(mc.ToJSON());
            Thread.Sleep(100);
        }
예제 #6
0
        private void DataReceviedServer(object sender, DataReceivedEventArgs e)
        {
            MessageCommand mc = MessageCommand.FromJSON(e.Message);

            if (mc.CommandID == (int)CommandEnum.CloseCommand)
            {
                CommandRecievedEventArgs comArgs = new CommandRecievedEventArgs((int)CommandEnum.CloseCommand, null, mc.CommandMsg);
                CommandRecieved?.Invoke(this, comArgs);
            }
            else
            {
                string convert = m_controller.ExecuteCommand(mc.CommandID, null, out bool result);
                mc.CommandMsg = convert;
                ClientHandler ch = sender as ClientHandler;
                ch.Send(mc.ToJSON());
            }
        }
예제 #7
0
        /// <summary>
        /// C'tor.
        /// </summary>
        public SettingsModel()

        {
            // need to remove this
            m_commands = new Dictionary <int, CommandExecute>
            {
                { (int)CommandEnum.GetConfigCommand, SetConfigSettings },
                { (int)CommandEnum.CloseCommand, RemoveDir }
            };
            communicationHandler = ModelCommunicationHandler.Instance;
            communicationHandler.DataReceived += GetCommand;
            MessageCommand mc = new MessageCommand();

            mc.CommandID  = (int)CommandEnum.GetConfigCommand;
            mc.CommandMsg = "";
            communicationHandler.Client.Send(mc.ToJSON());
            Thread.Sleep(1000);
        }