Esempio n. 1
0
 public SignWindowViewModel(ApplicationViewModel applicationViewModel)
 {
     _applicationViewModel = applicationViewModel;
     CancelCommand         = new UniversalCommand(CancelExecute);
     SignCommand           = new UniversalCommand(SignExecute, CanSign);
     AutofillCommand       = new UniversalCommand(AutofillExecute);
 }
        public bool ProcessUniversalPacketCommand(UniversalPacket universalPacket, ClientWorkObject client, AsynchronousSocketListener server)
        {
            bool sentClientData = false;

            string[] commandArgs = ((string[])JsonConvert.DeserializeObject <string[]>(universalPacket.MessageData.Data));

            //Process plugins
            UniversalPlugin plugin = server.GetPlugin(commandArgs[0]);

            if (plugin != null)
            {
                sentClientData = plugin.core.Invoke(client, commandArgs);
                server.serverPluginLogger.AddToLog(ILogger.Levels.INFO, "Client [" + client.clientTracker.userID + "] has used command [" + plugin.core.Name + ".");
            }

            //Processes default commands
            if (!sentClientData)
            {
                foreach (IUniversalCommand universalCommand in UniversalCommand.GetDefaultCommands())
                {
                    if (universalCommand.GetNamespace().ToLower() == commandArgs[0].ToLower())
                    {
                        bool tmpbool = universalCommand.Invoke(commandArgs, universalPacket, client);
                        server.serverPluginLogger.AddToLog(ILogger.Levels.INFO, "Client [" + client.clientTracker.userID + "] has used command [" + universalCommand.GetNamespace() + ".");
                        if (tmpbool == true)
                        {
                            sentClientData = true; return(tmpbool);
                        }
                    }
                }
            }
            return(sentClientData);
        }
        public void UniversalCommand_Verify_1()
        {
            Mock <IIrbisConnection> mock       = GetConnectionMock();
            IIrbisConnection        connection = mock.Object;
            UniversalCommand        command
                = new UniversalCommand(connection, commandCode);

            Assert.IsTrue(command.Verify(false));
        }
Esempio n. 4
0
 public LoginWindowViewModel(ApplicationViewModel applicationViewModel)
 {
     _applicationViewModel    = applicationViewModel;
     CancelCommand            = new UniversalCommand(CancelExecute);
     RefreshVerifyCodeCommand = new UniversalCommand(RefreshVerifyCode);
     LoginCommand             = new UniversalCommand(LoginExecute, CanLogin);
     VerifyQuestionIndex      = -1;
     RefreshVerifyCodeCommand.Execute(null);
 }
        public void UniversalCommand_Construciton_1()
        {
            Mock <IIrbisConnection> mock       = GetConnectionMock();
            IIrbisConnection        connection = mock.Object;
            UniversalCommand        command
                = new UniversalCommand(connection, commandCode);

            Assert.AreSame(connection, command.Connection);
            Assert.AreEqual(commandCode, command.CommandCode);
        }
Esempio n. 6
0
        private string[] _ReadRawRecords
        (
            [NotNull] int[] mfnList
        )
        {
            if (mfnList.Length == 0)
            {
                return(new string[0]);
            }
            if (mfnList.Length == 1)
            {
                return(new string[0]); // TODO FIXME!
            }

            List <object> arguments = new List <object>
                                      (
                mfnList.Length + 3
                                      )
            {
                Database,
                IrbisFormat.All,
                mfnList.Length
            };

            foreach (int mfn in mfnList)
            {
                arguments.Add(mfn);
            }

            UniversalCommand command
                = Connection.CommandFactory.GetUniversalCommand
                  (
                      CommandCode.FormatRecord,
                      arguments.ToArray()
                  );

            command.AcceptAnyResponse = true;

            ServerResponse response
                = Connection.ExecuteCommand(command);

            string[] result = response.RemainingUtfStrings()
                              .Skip(1)
                              .ToArray();

            return(result);
        }
Esempio n. 7
0
 private ApplicationViewModel()
 {
     ShowEditDialogCommand = new UniversalCommand(ShowEditDialogExecute);
 }
Esempio n. 8
0
 public AutofillDataViewModel()
 {
     AddCommand = new UniversalCommand(AddExecute, CanAdd);
 }
Esempio n. 9
0
 public AboutWindowViewModel()
 {
     _version            = VersionString;
     _checkUpdateCommand = new UniversalCommand(CheckUpdateExecute);
 }