private void resetTestFilename(string file)
        {
            _engine     = new AutomationEngineInstance(null);
            _renameFile = new RenameFileCommand();

            _renameFile.v_SourceFilePath = file;
            _renameFile.v_NewName        = "toRename.txt";

            _renameFile.RunCommand(_engine);
        }
        private void RaiseCanExecuteChanged()
        {
            RenameDirCommand.RaiseCanExecuteChanged();
            DeleteDirCommand.RaiseCanExecuteChanged();
            NewFolderCommand.RaiseCanExecuteChanged();

            RenameFileCommand.RaiseCanExecuteChanged();
            DeleteFileCommand.RaiseCanExecuteChanged();
            RunCommand.RaiseCanExecuteChanged();
            SetAsMainCommand.RaiseCanExecuteChanged();
        }
Exemple #3
0
        private async void OnRenamed(object sender, RenamedEventArgs e)
        {
            var item = SyncTableManager.GetByPath(e.OldFullPath);

            if (item != null)
            {
                var command = (Command)null;

                if (item.Type == "F")
                {
                    var folder = new DirectoryInfo(e.FullPath);

                    var ticket = await DokuFlexService.GetTicketAsync();

                    var topLevelPath = ConfigurationManager.GetValue(Resources.SyncDirectoryPathKey);

                    command = new RenameDirectoryCommand(ticket, folder.Name, e.FullPath, e.OldFullPath, topLevelPath);
                }
                else
                {
                    var file = new FileInfo(e.FullPath);

                    //check if file is open by a program
                    if (!file.IsLocked())
                    {
                        var ticket = await DokuFlexService.GetTicketAsync();

                        var topLevelPath = ConfigurationManager.GetValue(Resources.SyncDirectoryPathKey);

                        command = new RenameFileCommand(ticket, file.Name, e.FullPath, e.OldFullPath, topLevelPath);
                    }
                }

                //Attach error event handler
                command.ExecuteError += OnExecuteError;

                //Detect the synchronizer object state
                if (_syncing || _synchronizer.Paused)
                {
                    _synchronizer.Synchronize(command);
                }
                else
                {
                    await _synchronizer.SynchronizeAsync(command);
                }
            }
        }
        public async global::System.Threading.Tasks.Task HandlesInvalidFileInput()
        {
            _engine     = new AutomationEngineInstance(null);
            _renameFile = new RenameFileCommand();

            string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string inputPath        = Path.Combine(projectDirectory, @"Resources\noFile.txt");

            VariableMethods.CreateTestVariable(inputPath, _engine, "inputPath", typeof(string));

            string newName = "newname.txt";

            VariableMethods.CreateTestVariable(newName, _engine, "newName", typeof(string));

            _renameFile.v_SourceFilePath = "{inputPath}";
            _renameFile.v_NewName        = "{newName}";

            await Assert.ThrowsAsync <FileNotFoundException>(() => _renameFile.RunCommand(_engine));
        }
Exemple #5
0
        public static void Command()
        {
            IFileOperator fileOperator = new FileSystemOperator(Path.GetTempPath());
            //IFileOperator fileOperator = new FtpFileOperator(new Uri("ftp://tepuri.org"));

            var      invoker = new FileOperationInvoker();
            ICommand command;

            command = new CreateFileCommand(fileOperator, "HelloWorld.txt");
            invoker.Enqueue(command);

            command = new RenameFileCommand(fileOperator, "HelloWorld.txt", "GoodbyeWorld.txt");
            invoker.Enqueue(command);

            command = new DeleteFileCommand(fileOperator, "GoodbyeWorld.txt");
            invoker.Enqueue(command);

            invoker.InvokeAll();
        }
        public override IoCommand GetIoCommand()
        {
            bool revert = ProgramItem.Name == OldName;

            var oldPaths = ProgramItem.Locations.ToList();
            ProgramItem.Name = NewName;
            var newPaths = ProgramItem.Locations.ToList();

            var dict = new Dictionary<string, string>();

            for (int i = 0; i < oldPaths.Count; i++)
            {
                if ((ProgramItem.IsDirectory && Directory.Exists(oldPaths[i])) ||  File.Exists(oldPaths[i]) )
                {
                    dict.Add(oldPaths[i], newPaths[i]);
                }
            }

            var cmd = new RenameFileCommand(dict);

            if(revert)
                ProgramItem.Name = OldName;

            return cmd;
        }