/// <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; } }
/// <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; } }
/// <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 { } }
/// <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; } }
/// <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 { } }
/// <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; } }