Ejemplo n.º 1
0
        public void SyncValidator_FullPath_is_valid_if_is_valid_path()
        {
            var command = new SyncCommand(_validPath);

            _validator
            .ShouldNotHaveValidationErrorFor(t => t.FullPath, command);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Event handler for sync menu entries
        /// </summary>
        private void OnSyncWithSafeVault(object sender, EventArgs e)
        {
            ToolStripItem item        = (ToolStripItem)sender;
            SyncCommand   syncCommand = (SyncCommand)Enum.Parse(typeof(SyncCommand), item.Name);

            SyncWithSafeVault(syncCommand);
        }
Ejemplo n.º 3
0
        public (SyncSummary sum, List <PreSyncDetails> Changes) SyncDecr2andEncr1(Action <PreSyncDetails> onPreSyncDetails = null)
        {
            List <PreSyncDetails> changes = new List <PreSyncDetails>();

            SyncOptions options = new SyncOptions
            {
                DecrDirectory = Decr2.DirectoryPath,
                EncrDirectory = Encr1.DirectoryPath,
                Password      = "******",
                Initialize    = true
            };
            ConsoleEx console = new ConsoleEx
            {
                BeforeWriteLine = (o) =>
                {
                    if (o is PreSyncDetails preSync)
                    {
                        onPreSyncDetails?.Invoke(preSync);
                        changes.Add(preSync);
                    }
                    System.Diagnostics.Debug.WriteLine(o);
                }
            };

            var sum = SyncCommand.Sync(options, console, HelixFileVersion.UnitTest);

            return(sum, changes);
        }
Ejemplo n.º 4
0
        public MainViewModel(FileService fileService)
        {
            _fileService = fileService;

            SelectSourcePathCommand = new SyncCommand(p => { SourcePath = _fileService.SelectPath(); }, p => CopyCommand.Task.IsNotRunning);
            SelectTargetPathCommand = new SyncCommand(p => { TargetPath = _fileService.SelectPath(); }, p => CopyCommand.Task.IsNotRunning);

            CopyCommand = new ProgressiveAsyncCommand <ProgressModel>(
                async(parameter, token, progress) =>
            {
                Log = string.Empty;
                try
                {
                    await _fileService.CopyFiles(SourcePath, TargetPath, progress, token);
                }
                catch (TaskCanceledException)
                {
                    progress.Report(new ProgressModel("Cancelled."));
                }
            },
                progress =>
            {
                CopyProgress = progress.ProgressValue;
                MaxProgress  = progress.MaxProgress;
                Log         += $"{progress.LogMessage}{Environment.NewLine}";
            },
                parameter => _fileService.PathIsValid(SourcePath) && _fileService.PathIsValid(TargetPath));
        }
Ejemplo n.º 5
0
 public SpeechesListViewModel()
 {
     SelectedItemCommand = new SyncCommand <int>(SpeakerSelected);
     Speeches            = new ObservableCollection <Speech>();
     ShowSpeakerCommand  = new ReverseCommand <Speaker>();
     LoadSpeeches();
 }
Ejemplo n.º 6
0
        public ICommand DefineSyncCommand(string name, Action OnExecute, Action OnCancel = null)
        {
            var cmd = new SyncCommand(name, task_manager, OnExecute, OnCancel);

            defined_cmds.Add(cmd.GetNameHash(), cmd);
            return(cmd);
        }
Ejemplo n.º 7
0
 public TabItemViewModel(ViewModel viewModel, TabViewModel ownerViewModel)
 {
     _mainViewModel  = viewModel;
     _ownerViewModel = ownerViewModel;
     CloseCommand    = new SyncCommand(Close);
     Add(_mainViewModel);
 }
        public void SyncValidator_InvalidPlatform()
        {
            var command_with_invalidPlatform = new SyncCommand(_validPath, "Invalid");

            _validator
            .ShouldHaveValidationErrorFor(t => t.Platform, command_with_invalidPlatform);
        }
Ejemplo n.º 9
0
        public async Task <SyncCommandResult> Sync(string syncKey, string folderId, ExchangeChangeSet changeset)
        {
            if (string.IsNullOrEmpty(syncKey))
            {
                throw new ArgumentNullException(nameof(syncKey));
            }
            if (string.IsNullOrEmpty(folderId))
            {
                throw new ArgumentNullException(nameof(folderId));
            }
            if (changeset == null)
            {
                throw new ArgumentNullException(nameof(changeset));
            }

            LogService.Log("ActiveSyncServer", string.Format("Syncing key: {0} folder id: {1}", syncKey.TakeLast(5), folderId != null ? folderId.TakeLast(5) : "<none>"));

            SyncCommand command = new SyncCommand(new SyncCommandParameter(syncKey, folderId, changeset), this.settings);

            ResponseResult <SyncCommandResult> result = await command.Execute();

            if (ActiveSyncErrorHelper.IsStatusProvisioningError(result.Data?.Status, result?.Error))
            {
                await this.TryDoProvisioning();

                result = await command.Execute();
            }

            if (result.Error != null)
            {
                throw result.Error;
            }

            return(result.Data);
        }
Ejemplo n.º 10
0
        private void HandleCameraSyncProposal(UserContext context, SyncCommand command)
        {
            // Client requests OTHER clients to sync to his camera
            // Re-send data to clients
            var users = command.Data.Users.ToObject <List <User> >();
            //var users = (List<User>)JsonConvert.DeserializeObject<List<User>>(command.Data.Users.ToString());

            var response = new SyncResponse(SyncResponse.ResponseTypes.ProposeSyncCameras);

            response.Data = command.Data;
            var responseString = response.ToString();

            foreach (var user in users)
            {
                var conn = FindConnection(user);
                if (conn != null && conn.ClientAddress == context.ClientAddress.ToString())
                {
                    continue;                                                                         // skip requesting user
                }
                if (conn != null)
                {
                    conn.Context.Send(responseString);
                }
            }
        }
Ejemplo n.º 11
0
        public async Task DoSimpleSyncT()
        {
            var syncCmd      = new SyncCommand();
            var packagesJson = new PackagesJson();

            packagesJson.dependencies = new Dictionary <string, string>();
            packagesJson.dependencies.Add("xunit.core", "2.4.1");
            packagesJson.dependencies.Add("CommandLineParser", "2.3.0");

            var packagesJsonPath = Path.Combine(_prjConfig.RootPath, _prjConfig.Nuget2BazelConfigName);
            await File.WriteAllTextAsync(packagesJsonPath, JsonConvert.SerializeObject(packagesJson));

            await syncCmd.Do(_prjConfig);

            var readback = await File.ReadAllTextAsync(packagesJsonPath);

            var readbackJson = JsonConvert.DeserializeObject <PackagesJson>(readback);

            var filtered = readbackJson.dependencies.Select(y => y.Key).ToList();

            Assert.Equal(18, filtered.Count);
            Assert.Contains("CommandLineParser", filtered);
            Assert.Contains("xunit.abstractions", filtered);
            Assert.Contains("xunit.core", filtered);
            Assert.Contains("xunit.extensibility.core", filtered);
            Assert.Contains("xunit.extensibility.execution", filtered);
        }
Ejemplo n.º 12
0
        public DirectoryViewModel()
        {
            AnalizedFiles = new ObservableCollection <FileResult>();

            OpenDirectoryCommand = new SyncCommand(OpenDirectory);
            AnalizeCommand       = new AsyncCommand(async() => await AnalizeDirectory());
        }
Ejemplo n.º 13
0
        private void SetSyncStatus()
        {
            IsSynced = _modifiedProperties.Count == 0;

            SyncCommand.TriggerCanExecuteChanged();
            RevertAllCommand.TriggerCanExecuteChanged();
        }
Ejemplo n.º 14
0
        public void SyncValidator_Path_is_valid_if_is_not_null_or_empty()
        {
            var command = new SyncCommand(_validPath);

            _validator
            .ShouldNotHaveValidationErrorFor(t => t.Path, command);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Event handler for sync menu entries
        /// </summary>
        private void OnSyncWithGoogle(object sender, EventArgs e)
        {
            ToolStripItem item        = (ToolStripItem)sender;
            SyncCommand   syncCommand = (SyncCommand)Enum.Parse(typeof(SyncCommand), item.Name);

            syncWithGoogle(syncCommand, false);
        }
Ejemplo n.º 16
0
        public void SyncValidator_FullPath_failed_if_is_invalid_path()
        {
            var command_with_invalid_path = new SyncCommand("invalidPath");

            _validator
            .ShouldHaveValidationErrorFor(t => t.FullPath, command_with_invalid_path)
            .WithErrorMessage(StringRes.BadReqInvalidPath);
        }
Ejemplo n.º 17
0
            public boolean equals(IQueueCommand obj)
            {
                SyncCommand oSyncCmd = (SyncCommand)obj;

                return(m_nCmdCode == oSyncCmd.m_nCmdCode && m_nCmdParam == oSyncCmd.m_nCmdParam &&
                       (m_strCmdParam == oSyncCmd.m_strCmdParam ||
                        (m_strCmdParam != null && oSyncCmd.m_strCmdParam != null && m_strCmdParam.equals(oSyncCmd.m_strCmdParam))));
            }
Ejemplo n.º 18
0
 public ProductVM(IStartUpData _productData)
 {
     productData = _productData;
     ShowProgressBar();
     OpenAddProductWindow_Command = new SyncCommand(OpenAddProductWindow);
     Products = new ObservableCollection <ProductModel>();
     Window_ContentRendered_Command = new SyncCommand(Window_ContentRendered);
 }
Ejemplo n.º 19
0
 public AddInvoiceVM(IInvoiceData _invoiceData)
 {
     invoiceData              = _invoiceData;
     SubmitForm_Command       = new SyncCommand(SubmitForm);
     AddNewRow_Command        = new SyncCommand(AddNewRow, ValidateInvoice);
     InvoiceDetailsCollection = new ObservableCollection <InvoiceDetailsModelUI>();
     ValidateInput();
 }
Ejemplo n.º 20
0
        private void DatabindSyncTab()
        {
            var syncCmd = new SyncCommand();

            syncsourceProviderBox.DataBindings.Add("Text", syncCmd, "SourceProvider", true, DataSourceUpdateMode.OnPropertyChanged);
            syncdestProviderBox.DataBindings.Add("Text", syncCmd, "DestProvider", true, DataSourceUpdateMode.OnPropertyChanged);
            _commands[Verb.sync] = syncCmd;
        }
Ejemplo n.º 21
0
 public AddInvoiceDetailsVM(IStartUpData _productData)
 {
     productData = _productData;
     Products_EnterKeyUpAsync_Command      = new AsyncCommand(Products_EnterKeyUpAsync);
     Products_DropDownClosingAsync_Command = new AsyncCommand(Products_DropDownClosingAsync);
     AddDetails_Command = new SyncCommand(AddDetails);
     GetProducts();
 }
Ejemplo n.º 22
0
        protected static IEnumerable <Tuple <SyncCommand, string> > SyncRequests(SyncCommand command, string path, SyncCommand command2, string path2, SyncCommand command3, string path3)
        {
            yield return(new Tuple <SyncCommand, string>(command, path));

            yield return(new Tuple <SyncCommand, string>(command2, path2));

            yield return(new Tuple <SyncCommand, string>(command3, path3));
        }
Ejemplo n.º 23
0
 public InvoiceVM(IInvoiceData _invoiceData)
 {
     ShowProgressBar();
     invoiceData = _invoiceData;
     OpenAddInvoiceWindow_Command = new SyncCommand(OpenAddInvoiceWindow);
     DeleteInvoice_Command        = new SyncCommand(DeleteInvoice, EnableDeleteButton);
     Invoices = new ObservableCollection <InvoiceModelUI>();
     Window_ContentRendered_Command = new SyncCommand(Window_ContentRendered);
 }
Ejemplo n.º 24
0
        public StartPageViewModel()
        {
            Customer = new CustomerModel();

            SyncCommand = new SyncCommand(this);
            LocalRealmInitialization();

            LoginToServerAsync();
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Set user id
        /// </summary>
        /// <param name="command"></param>
        protected void HandleUserIdentifier(SyncCommand command)
        {
            UserId = (Guid.Empty != _currentUser.UserId) ? _currentUser.UserId : command.UserId;

            if (UserId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(UserId));
            }
        }
 internal void UpdateFilterStateWithAddOrChange(ISyncItemId itemId, bool calendar, bool recurring, ExDateTime endTime)
 {
     if (itemId == null)
     {
         throw new ArgumentNullException("itemId");
     }
     DateTimeCustomSyncFilter.FilterState filterState = null;
     if (this.CustomFilterState == null)
     {
         this.CustomFilterState = new Dictionary <ISyncItemId, DateTimeCustomSyncFilter.FilterState>();
     }
     try
     {
         if (!this.CustomFilterState.ContainsKey(itemId))
         {
             filterState = new DateTimeCustomSyncFilter.FilterState();
             this.CustomFilterState[itemId] = filterState;
         }
         else
         {
             filterState = this.CustomFilterState[itemId];
         }
         filterState.IsCalendarItem = calendar;
         if (calendar)
         {
             filterState.IsRecurring = recurring;
             if (recurring)
             {
                 if (endTime.Equals(ExDateTime.MinValue))
                 {
                     filterState.DoesRecurrenceEnd = false;
                 }
                 else
                 {
                     filterState.DoesRecurrenceEnd = true;
                     filterState.EndTime           = endTime;
                 }
             }
             else
             {
                 filterState.EndTime = endTime;
             }
         }
     }
     catch (Exception ex)
     {
         if (ex is ObjectNotFoundException || !SyncCommand.IsItemSyncTolerableException(ex))
         {
             throw;
         }
         if (filterState != null)
         {
             filterState.IsCalendarItem = false;
         }
     }
 }
Ejemplo n.º 27
0
        void checkShowStatus(SyncCommand oSyncCmd)
        {
            boolean bShowStatus = oSyncCmd.m_bShowStatus && !this.isNoThreadedMode();

            m_oSyncEngine.getNotify().enableReporting(bShowStatus);
            if (m_oSyncEngine.getNotify().isReportingEnabled())
            {
                m_statusListener.createStatusPopup(RhoAppAdapter.getMessageText("syncronizing_data"));
            }
        }
Ejemplo n.º 28
0
        public async Task Process()
        {
            var syncCommand = new SyncCommand();

            syncCommand.SetCommandAction(_actions[1]);
            syncCommand.FinishedSyncEvent += () => { _processOutputLines.Add("Finished"); };
            await syncCommand.Process();

            Assert.Equal("Process action1|Finished", string.Join('|', _processOutputLines.ToArray()));
        }
Ejemplo n.º 29
0
        public override void SendSyncRequest(SyncCommand command, int length)
        {
            var trace = new StackTrace((Exception)null, false);

            if (trace.GetFrames()[0].GetMethod().DeclaringType != typeof(AdbSocket))
            {
                this.SyncRequests.Add(new Tuple <SyncCommand, string>(command, length.ToString()));
            }

            base.SendSyncRequest(command, length);
        }
Ejemplo n.º 30
0
        /// <inheritdoc/>
        public virtual void SendSyncRequest(SyncCommand command, string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            byte[] pathBytes = AdbClient.Encoding.GetBytes(path);
            this.SendSyncRequest(command, pathBytes.Length);
            this.Write(pathBytes);
        }
Ejemplo n.º 31
0
 public static SyncCommand ProposeSyncCameras(List<User> admins, CameraDetails camera)
 {
     var command = new SyncCommand(SyncCommand.CommandTypes.ProposeSyncCameras);
     command.Data = new
                    {
                        Users = admins,
                        CameraDetails = camera,
                        Force = false,
                        ProposingAdmin = SyncManager.Instance.User.CustId
                    };
     return command;
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Gets the byte array that represents the <see cref="SyncCommand"/>.
        /// </summary>
        /// <param name="command">
        /// The <see cref="SyncCommand"/> to convert.
        /// </param>
        /// <returns>
        /// A byte array that represents the <see cref="SyncCommand"/>.
        /// </returns>
        public static byte[] GetBytes(SyncCommand command)
        {
            if (!Values.ContainsKey(command))
            {
                throw new ArgumentOutOfRangeException(nameof(command), $"{command} is not a valid sync command");
            }

            string commandText = Values[command];
            byte[] commandBytes = AdbClient.Encoding.GetBytes(commandText);

            return commandBytes;
        }
Ejemplo n.º 33
0
        private void RegisterUser(UserContext context, SyncCommand command)
        {
            // Client is trying to register
            // Find his connection and link it to a new user
            var conn = FindConnection(context);
            if (conn != null)
            {
                if (!conn.IsRegistered)
                {
                    var id = (int)command.Data.Id;
                    var ssid = (long)command.Data.Ssid;
                    var name = command.Data.Name.ToString();
                    var shortname = command.Data.ShortName.ToString();
                    var password = command.Data.Password.ToString();

                    // Check password
                    if (password == _password)
                    {
                        // Check subsession ID
                        if (ssid == _subSessionId)
                        {
                            // Check name length
                            if (!string.IsNullOrWhiteSpace(name) && name.Length >= MIN_NAME_LENGTH)
                            {
                                
                                // Try to find previously connected user
                                var user = this.State.Users.FromId(id);
                                if (user == null)
                                {
                                    // New user
                                    user = new User();
                                    user.CustId = id;
                                    this.State.Users.Add(user);

                                    UserColors.SetColor(user);
                                }

                                if (!user.IsConnected)
                                {
                                    user.Name = name;
                                    user.ShortName = shortname;
                                    user.IsRegistered = true;
                                    user.IsConnected = true;
                                    user.IsHost = id == _adminId;

                                    // Link him to his connection
                                    conn.User = user;

                                    this.OnLog("User registered: " + name);

                                    var response = new SyncResponse(SyncResponse.ResponseTypes.Connect);
                                    response.Data = new { Success = true, User = user };

                                    this.Reply(context, response);
                                    this.BroadcastUserlist();
                                    this.SendState(context);
                                }
                                else
                                {
                                    this.OnLog("Already connected: " + name);
                                    this.FailRegistration(context, "You are already connected.");
                                }
                            }
                            else
                            {
                                this.OnLog("Name too short: " + name);
                                this.FailRegistration(context,
                                    string.Format("Please choose a name with a minimum of {0} characters.", MIN_NAME_LENGTH));
                            }
                        }
                        else
                        {
                            this.OnLog("Incorrect session ID.");
                            this.FailRegistration(context, "Incorrect subsession ID: you must join the same session as the server host.");
                        }
                    }
                    else
                    {
                        this.OnLog("Incorrect password attempt: " + password);
                        this.FailRegistration(context, "Incorrect password.");
                    }
                }
                else
                {
                    this.OnLog("Already registered: " + conn.Username);
                    this.FailRegistration(context, "You are already registered.");
                }
            }
            else
            {
                this.OnLog("Unknown client tried to register: " + context.ClientAddress);
                this.FailRegistration(context, "Unknown client.");
            }
        }
Ejemplo n.º 34
0
        public void SyncTaskCategories(TaskCategorySyncRequest syncRequest)
        {
            //var syncItems = syncRequest.TaskCategoryItems;
            //var commands = new List<ISyncCommand>();
            foreach (var category in syncRequest.TaskCategoryItems)
            {
                if (category.ActionType == (int)EntityActionType.Create)
                {
                    var syncCommand = new SyncCommand
                    {
                        //ActionTypeOwner = (AppType)syncRequest.AppType,
                        SyncId = category.SyncId,
                        //Data = new CreateTaskCategoryCommand
                        //{
                        //    Title = category.Title
                        //}
                    };
                    //syncService.SyncByCreate(syncCommand);
                    //commands.Add(new SyncCommand<CreateTaskCategoryCommand>
                    //{
                    //    ActionTypeOwner = (AppType) syncRequest.AppType,
                    //    SyncId = category.SyncId,
                    //    Data = new CreateTaskCategoryCommand
                    //    {
                    //        Title = category.Title
                    //    }
                    //});
                }
            }

            //var syncCommands = syncItems.Select(i => new SyncCommand<TaskCategory>
            //{

            //    SyncId = i.SyncId,
            //    ActionTypeOwner = (AppType) syncRequest.AppType,
            //    Data =,
            //});

        }
Ejemplo n.º 35
0
 public void RepositionPlayer(SyncCommand command)
 {
     stage.CharacterExit((int)this.transform.position.x, (int)this.transform.position.z);
     this.transform.position = new Vector3((float)command.x, 1f, (float)command.z);
 }
Ejemplo n.º 36
0
	    void checkShowStatus(SyncCommand oSyncCmd)
	    {
		    boolean bShowStatus = oSyncCmd.m_bShowStatus && !this.isNoThreadedMode();
		    m_oSyncEngine.getNotify().enableReporting(bShowStatus);
		    if (m_oSyncEngine.getNotify().isReportingEnabled())
			    m_statusListener.createStatusPopup(RhoAppAdapter.getMessageText("syncronizing_data"));
	    }	
Ejemplo n.º 37
0
 public void SendSyncRequest(SyncCommand command, int length)
 {
     this.SyncRequests.Add(new Tuple<SyncCommand, string>(command, length.ToString()));
 }
Ejemplo n.º 38
0
 /// <inheritdoc/>
 public virtual void SendSyncRequest(SyncCommand command, string path, int permissions)
 {
     this.SendSyncRequest(command, $"{path},0{permissions}");
 }
Ejemplo n.º 39
0
        private void ReceivedPong(UserContext context, SyncCommand command)
        {
            var conn = this.FindConnection(context);
            if (conn != null && conn.IsRegistered)
            {
                var user = conn.User;

                user.LastPongReceived = DateTime.Now.ToUniversalTime();
                var ping = (user.LastPongReceived.GetValueOrDefault() - user.LastPingSent.GetValueOrDefault()).Ticks / 2f;

                user.Ping = (int)Math.Round(ping / 10000f); // ms
            }
        }
Ejemplo n.º 40
0
        private void HandleCameraSyncProposal(UserContext context, SyncCommand command)
        {
            // Client requests OTHER clients to sync to his camera
            // Re-send data to clients
            var users = command.Data.Users.ToObject<List<User>>();
            //var users = (List<User>)JsonConvert.DeserializeObject<List<User>>(command.Data.Users.ToString());

            var response = new SyncResponse(SyncResponse.ResponseTypes.ProposeSyncCameras);
            response.Data = command.Data;
            var responseString = response.ToString();

            foreach (var user in users)
            {
                var conn = FindConnection(user);
                if (conn != null && conn.ClientAddress == context.ClientAddress.ToString()) continue; // skip requesting user
                if (conn != null)
                {
                    conn.Context.Send(responseString);
                }
            }
        }
Ejemplo n.º 41
0
 public void SendSyncRequest(SyncCommand command, string path)
 {
     this.SyncRequests.Add(new Tuple<SyncCommand, string>(command, path));
 }
Ejemplo n.º 42
0
        /// <inheritdoc/>
        public virtual void SendSyncRequest(SyncCommand command, int length)
        {
            // The message structure is:
            // First four bytes: command
            // Next four bytes: length of the path
            // Final bytes: path
            byte[] commandBytes = SyncCommandConverter.GetBytes(command);

            byte[] lengthBytes = BitConverter.GetBytes(length);

            if (!BitConverter.IsLittleEndian)
            {
                // Convert from big endian to little endian
                Array.Reverse(lengthBytes);
            }

            this.Write(commandBytes);
            this.Write(lengthBytes);
        }
Ejemplo n.º 43
0
 protected static IEnumerable<Tuple<SyncCommand, string>> SyncRequests(SyncCommand command, string path, SyncCommand command2, string path2, SyncCommand command3, string path3)
 {
     yield return new Tuple<SyncCommand, string>(command, path);
     yield return new Tuple<SyncCommand, string>(command2, path2);
     yield return new Tuple<SyncCommand, string>(command3, path3);
 }
Ejemplo n.º 44
0
 private void StartSyncEvent(PhotonRPCModel model)
 {
     SyncCommand command = new SyncCommand();
     command.x = (int)transform.position.x;
     command.z = (int)transform.position.z;
     PhotonRPCModel rpcmodel = new PhotonRPCModel();
     rpcmodel.command = PhotonRPCCommand.SyncPosition;
     rpcmodel.senderId = gameObject.name;
     rpcmodel.message = JsonUtility.ToJson(command);
     PhotonRPCHandler.GetInstance().PostRPC(rpcmodel);
 }
Ejemplo n.º 45
0
        private void HandleStateUpdate(UserContext context, SyncCommand command)
        {
            Debug.WriteLine(">> Received state update: " + command);

            var conn = this.FindConnection(context);
            if (conn != null && conn.IsRegistered)
            {
                var message = (SyncStateCommand)command;

                switch (message.StateUpdateType)
                {
                    case SyncStateCommand.StateUpdateTypes.WatchedDriverChanged:
                        this.UpdateWatchedDriver(conn, message);
                        break;

                    case SyncStateCommand.StateUpdateTypes.LiveStatusChanged:
                        this.UpdateLiveStatus(conn, message);
                        break;

                    case SyncStateCommand.StateUpdateTypes.AddPenalty:
                        this.AddPenalty(conn, message);
                        break;

                    case SyncStateCommand.StateUpdateTypes.EditPenalty:
                        this.EditPenalty(conn, message);
                        break;

                    case SyncStateCommand.StateUpdateTypes.DeletePenalty:
                        this.DeletePenalty(conn, message);
                        break;

                        case SyncStateCommand.StateUpdateTypes.AddEvent:
                        this.AddEvent(conn, message);
                        break;

                    case SyncStateCommand.StateUpdateTypes.Offtracks:
                        this.UpdateOfftracks(conn, message);
                        break;

                    case SyncStateCommand.StateUpdateTypes.ClearOfftracks:
                        this.ClearOfftracks();
                        break;
                }

                // Save state to file
                this.SaveState();

                // Broadcast the new state to all clients
                this.BroadcastState();
            }
        }
Ejemplo n.º 46
0
        /// <inheritdoc/>
        public virtual void SendSyncRequest(SyncCommand command, string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            this.SendSyncRequest(command, path.Length);

            byte[] pathBytes = AdbClient.Encoding.GetBytes(path);
            this.Write(pathBytes);
        }
Ejemplo n.º 47
0
 private void HandleCameraStateRequest(SyncCommand command)
 {
     // Client requests camera state of one other user
     
     // Obtain camera details and then 
 }
Ejemplo n.º 48
0
 public override void SendSyncRequest(SyncCommand command, string path)
 {
     this.SyncRequests.Add(new Tuple<SyncCommand, string>(command, path));
     base.SendSyncRequest(command, path);
 }
Ejemplo n.º 49
0
        /// <summary>
        /// Places a sync command onto the buffer
        /// and resets the buffer timer.
        /// </summary>
        /// <param name="syncCommand">The command to be pushed onto the buffer</param>
        /// <param name="objectID">The ID of the object which to manipulate (not used for Create command)</param>
        /// <param name="objectType">The type of the object to act on (not used for Execute command).</param>
        /// <param name="data">
        /// Object structure if Update or Create, command if Execute, otherwise empty.
        /// </param>
        private void Buffer(SyncCommand syncCommand, uint objectID, string objectType, string data)
        {
            // create query string
            switch (syncCommand)
            {
                case SyncCommand.Execute:
                    syncInBuffer[Tuple.Create<SyncCommand, uint, string>(syncCommand, objectID, objectType)] = data;
                    break;

                case SyncCommand.Create:
                    syncInBuffer[Tuple.Create<SyncCommand, uint, string>(syncCommand, 0, objectType)] = data;
                    break;

                case SyncCommand.Delete:
                    var updateTuple = Tuple.Create<SyncCommand, uint, string>(syncCommand, objectID, objectType);

                    // remove any updates
                    if (syncInBuffer.ContainsKey(updateTuple))
                        syncInBuffer.Remove(updateTuple);

                    syncInBuffer[Tuple.Create<SyncCommand, uint, string>(syncCommand, objectID, objectType)] = "";
                    break;

                case SyncCommand.Update:
                    syncInBuffer[Tuple.Create<SyncCommand, uint, string>(syncCommand, objectID, objectType)] = data;
                    break;

                default:
                    return;
            }

            if (syncInDelay != null)
                syncInDelay.Dispose();
            syncInDelay = new Timer(PerformSyncIn, null, 500, Timeout.Infinite);
        }
Ejemplo n.º 50
0
        public override void SendSyncRequest(SyncCommand command, int length)
        {
            StackTrace trace = new StackTrace(false);

            if (trace.GetFrame(1).GetMethod().DeclaringType != typeof(AdbSocket))
            {
                this.SyncRequests.Add(new Tuple<SyncCommand, string>(command, length.ToString()));
            }

            base.SendSyncRequest(command, length);
        }
Ejemplo n.º 51
0
 public static SyncCommand Pong()
 {
     var command = new SyncCommand(SyncCommand.CommandTypes.Pong);
     return command;
 }
Ejemplo n.º 52
0
 public void SendSyncRequest(SyncCommand command, string path, int permissions)
 {
     this.SyncRequests.Add(new Tuple<SyncCommand, string>(command, $"{path},{permissions}"));
 }
Ejemplo n.º 53
0
 public async void SendCommand(SyncCommand command)
 {
     if (this.Status == ConnectionStatus.Connected && this.User != null)
     {
         try
         {
             await Task.Run(() => _client.Send(command.ToString()));
         }
         catch (Exception) { }
     }
 }
Ejemplo n.º 54
0
        private IEnumerable<SyncCommand> ExtractCommands(string rawString)
        {
            // split into commands
            var commandStrings = rawString.Split(new string[] { SYMBOL_commandSeparator }, StringSplitOptions.RemoveEmptyEntries);

            // format commands
            return commandStrings.Select(cs => 
            {
                var command = new SyncCommand();

                // split command and parameters
                var commandParts = cs.Split(new string[] { SYMBOL_parametersSeparator }, StringSplitOptions.RemoveEmptyEntries);

                // add command text
                command.Command = commandParts[0];

                // format parameters
                var parameters = new List<object>();
                if(commandParts.Length>1)
                {
                    // split parameters
                    var parameterParts = commandParts[1].Split(new string[] { SYMBOL_paramSeparator}, StringSplitOptions.RemoveEmptyEntries);
                    
                    // format each pairs
                    foreach(var parameter in parameterParts)
                    {
                        var kvp = parameter.Split(new string[] { SYMBOL_paramKeyValueSeparator }, StringSplitOptions.None);
                        parameters.Add(kvp[1]); // hack: quick test with string
                    }
                }
                command.Parameters = parameters.ToArray();

                // return command
                return command;
            });
        }
Ejemplo n.º 55
0
        private void HandleCameraStateRequest(SyncCommand command)
        {
            // Client requests camera state of one other user
            var clientAddress = (string)command.Data.UserAddress;

        }
Ejemplo n.º 56
0
        private void OnConnected(UserContext context)
        {
            // Connected - send registration command
            var command = new SyncCommand(SyncCommand.CommandTypes.Register);
            command.Data = new
            {
                Id = _custid,
                Name = _name,
                ShortName = _shortname,
                Password = _password,
                Ssid = _subSessionId
            };

            _client.Send(command.ToString());
        }