/// <summary>
        /// Called when [server data recieved].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="Communication.Model.Event.DataReceivedEventArgs"/> instance containing the event data.</param>
        private void OnServerDataRecieved(object sender, Communication.Model.Event.DataReceivedEventArgs <string> e)
        {
            CommandMessage cmdMsg = CommandMessage.FromJSON(e.Data);
            IClientCommunicationChannel <string> receiver = (IClientCommunicationChannel <string>)sender;
            string msg = null;

            if (cmdMsg.CmdId == CommandEnum.CloseClientCommand)
            {
                receiver.Close();
            }
            else if (cmdMsg.CmdId == CommandEnum.CloseCommand)
            {
                m_imageServer.sendCommand(CommandEnum.CloseCommand, new string[] { }, cmdMsg.Args[0]);
                ServerCommunication.Instance.Send(new CommandMessage(CommandEnum.CloseCommand, cmdMsg.Args).ToJSON());
            }
            else
            {
                bool result;
                msg = m_controller.ExecuteCommand((int)cmdMsg.CmdId, cmdMsg.Args, out result);
            }

            if (msg != null)
            {
                receiver.Send(msg);
            }
        }
Exemple #2
0
        /// <summary>
        /// Called when [client close].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="Communication.Model.Event.DataReceivedEventArgs"/> instance containing the event data.</param>
        private void OnClientClose(object sender, Communication.Model.Event.DataReceivedEventArgs e)
        {
            CommandMessage cmdMsg = CommandMessage.FromJSON(e.Data);

            if (cmdMsg.CmdId == CommandEnum.CloseCommand && Folder.Equals(cmdMsg.Args[0]))
            {
                ClientCommunication.Instance.OnDataRecieved -= OnClientClose;
                finished = true;
            }
        }
Exemple #3
0
        /// <summary>
        /// Gets the photos amount.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="Communication.Model.Event.DataReceivedEventArgs"/> instance containing the event data.</param>
        private void GetPhotosAmount(object sender, Communication.Model.Event.DataReceivedEventArgs e)
        {
            CommandMessage cmdMsg = CommandMessage.FromJSON(e.Data);

            if (cmdMsg.CmdId == CommandEnum.GetConfigCommand)
            {
                PhotosAmount = Directory.GetFiles(Path.Combine(cmdMsg.Args[2], "Thumbnails"), "*", SearchOption.AllDirectories).Length.ToString();

                ClientCommunication.Instance.OnDataRecieved -= GetPhotosAmount;
                finishedPhotosAmount = true;
            }
        }
Exemple #4
0
        /// <summary>
        /// Adds the logs to the logs list.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="Communication.Model.Event.DataReceivedEventArgs"/> instance containing the event data.</param>
        private void AddLogs(object sender, Communication.Model.Event.DataReceivedEventArgs e)
        {
            try {
                CommandMessage cmdMsg = CommandMessage.FromJSON(e.Data);

                if (cmdMsg.CmdId == CommandEnum.LogCommand)
                {
                    foreach (string logMsg in cmdMsg.Args)
                    {
                        this.LogMessages.Add(LogMessageRecord.FromJSON(logMsg));
                    }
                }
            } catch { }
        }
Exemple #5
0
        /// <summary>
        /// Gets the students information.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="Communication.Model.Event.DataReceivedEventArgs"/> instance containing the event data.</param>
        private void GetStudentsInfo(object sender, Communication.Model.Event.DataReceivedEventArgs e)
        {
            CommandMessage cmdMsg = CommandMessage.FromJSON(e.Data);

            if (cmdMsg.CmdId == CommandEnum.GetStudentsInfoCommand)
            {
                foreach (string student in cmdMsg.Args)
                {
                    string[] studentInfo = student.Split(',');
                    Students.Add(new Student(studentInfo[0], studentInfo[1], int.Parse(studentInfo[2])));
                }

                ClientCommunication.Instance.OnDataRecieved -= GetStudentsInfo;
                finishedStudentsInfo = true;
            }
        }
Exemple #6
0
        /// <summary>
        /// Adds the logs to the logs list.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="Communication.Model.Event.DataReceivedEventArgs" /> instance containing the event data.</param>
        private void AddLogs(object sender, Communication.Model.Event.DataReceivedEventArgs e)
        {
            try {
                CommandMessage cmdMsg = CommandMessage.FromJSON(e.Data);

                if (cmdMsg.CmdId == CommandEnum.LogCommand)
                {
                    foreach (string logMsg in cmdMsg.Args)
                    {
                        LogMessageRecord msgRcrd = LogMessageRecord.FromJSON(logMsg);
                        if (m_typeFilter == null || msgRcrd.Type.ToString().Equals(m_typeFilter))
                        {
                            this.LogMessages.Add(new LogMessageRecord(msgRcrd.Message, msgRcrd.Type));
                        }
                    }

                    ClientCommunication.Instance.OnDataRecieved -= AddLogs;
                    finishedGettingLogs = true;
                }
            } catch { }
        }
Exemple #7
0
        /// <summary>
        /// Gets the configs.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="Communication.Model.Event.DataReceivedEventArgs"/> instance containing the event data.</param>
        private void GetConfigs(object sender, Communication.Model.Event.DataReceivedEventArgs e)
        {
            CommandMessage cmdMsg = CommandMessage.FromJSON(e.Data);

            if (cmdMsg.CmdId == CommandEnum.GetConfigCommand)
            {
                this.SourceName    = cmdMsg.Args[0];
                this.LogName       = cmdMsg.Args[1];
                this.OutputDirPath = cmdMsg.Args[2];
                this.ThumbnailSize = cmdMsg.Args[3];

                foreach (string folder in cmdMsg.Args[4].Trim().Split(';'))
                {
                    if (!folder.Equals(""))
                    {
                        Folders.Add(folder);
                    }
                }

                ClientCommunication.Instance.OnDataRecieved -= GetConfigs;
                finished = true;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SettingsModel"/> class.
        /// </summary>
        public SettingsModel()
        {
            Folders = new ObservableCollection <string>();
            BindingOperations.EnableCollectionSynchronization(Folders, new object());
            Folders.CollectionChanged += (sender, e) => NotifyProperyChanged("Folders");

            OutputDirPath = "Not Connected";

            m_actions = new Dictionary <CommandEnum, CommandAction>();
            m_actions.Add(CommandEnum.GetConfigCommand, OnConfigRefresh);
            m_actions.Add(CommandEnum.CloseCommand, OnRemoveHandler);

            ClientCommunication.Instance.OnDataRecieved += (s, e) => {
                CommandMessage cmdMsg = CommandMessage.FromJSON(e.Data);

                if (m_actions.ContainsKey(cmdMsg.CmdId))
                {
                    m_actions[cmdMsg.CmdId](cmdMsg);
                }
            };

            ClientCommunication.Instance.Send(new CommandMessage(CommandEnum.GetConfigCommand, new string[] { }));
        }