Exemplo n.º 1
0
        private bool RenameFile(string pathFrom, string pathTo)
        {
            string message = string.Empty;

            return(TransactionFile.MoveFile(
                       pathFrom, pathTo,
                       ref message));
        }
Exemplo n.º 2
0
        public static bool RenameFile(FileArgs args, IBasicPanel <Project> control, ref string message)
        {
            string path = Path.Combine(control.FSWorker.WorkDirectory, args.Project, BrowseSystem.SubFolder);

            TransactionFile.MoveFile(Path.Combine(path, args.RenamedArgs.From),
                                     Path.Combine(path, args.RenamedArgs.To), ref message);
            return(Save(control.Save(args.Project, control.SaveItemManager.DoSave(args)),
                        Path.Combine(control.FSWorker.WorkDirectory, args.Project, args.Project + ProjectExtension), ref message));
        }
Exemplo n.º 3
0
        public static bool CreateFile(FileArgs args, IBasicPanel <Project> control, ref string message)
        {
            string path = Path.Combine(control.FSWorker.WorkDirectory, args.Project, BrowseSystem.SubFolder);

            foreach (string file in args.Files)
            {
                if (!TransactionFile.CreateFile(Path.Combine(path, file + Extension), ref message))
                {
                    return(false);
                }
            }
            return(Save(control.Save(args.Project, control.SaveItemManager.DoSave(args)),
                        Path.Combine(control.FSWorker.WorkDirectory, args.Project, args.Project + ProjectExtension), ref message));
        }
Exemplo n.º 4
0
 private static void CopyDirectories(string path, string pathTo, ref string message)
 {
     //pathTo = Path.Combine(pathTo, Path.GetDirectoryName(path));
     if (!CreateDirectory(pathTo, ref message))
     {
         return;
     }
     foreach (var file in Directory.GetFiles(path))
     {
         if (!TransactionFile.MoveFile(Path.Combine(path, file), Path.Combine(pathTo, Path.GetFileName(file)), ref message))
         {
             return;
         }
     }
     foreach (var directory in Directory.GetDirectories(path))
     {
         string name = new DirectoryInfo(directory).Name;
         CopyDirectories(Path.Combine(path, name), Path.Combine(pathTo, name), ref message);
     }
 }
Exemplo n.º 5
0
        private bool Do(Happened happened, bool isFolder, EventArgs args, ref string message)
        {
            switch (happened)
            {
            case Happened.Created:
            {
                return(isFolder
                        ? BrowseSystem.CreateProject((ProjectArgs)args, Control, ref message)
                        : BrowseSystem.CreateFile((FileArgs)args, Control, ref message));
            }

            case Happened.Deleted:
            {
                return(isFolder
                        ? TransactionDirectory.RemoveDirectory(Path.Combine(Control.FSWorker.WorkDirectory, ((ProjectArgs)args).Project))
                        : TransactionFile.DeleteFiles((FileArgs)args));
            }
            }
            return(false);
        }
Exemplo n.º 6
0
        public static bool RenameProject(ProjectArgs args, IBasicPanel <Project> control, ref string message)
        {
            string             path        = Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.From);
            ComplexTransaction transaction = new ComplexTransaction();

            transaction.AddOperation(() =>
                                     TransactionDirectory.CopyDirectory(path,
                                                                        Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To)), () =>
            {
                if (!TransactionDirectory.RemoveDirectory(
                        Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To)))
                {
                    Transaction.Current.Rollback();
                }
            });
            transaction.AddOperation(() =>
            {
                TransactionDirectory.RemoveDirectory(path);
            }, new List <string> {
                path
            });
            transaction.AddOperation(() =>
            {
                TransactionFile.DeleteFiles(
                    new FileArgs(
                        new List <string>
                {
                    Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To,
                                 args.RenamedArgs.From + ProjectExtension)
                }, args.RenamedArgs.From, Happened.Deleted,
                        (b, s, arg) => { }));
            }, new List <string>
            {
                Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To,
                             args.RenamedArgs.From + ProjectExtension)
            });
            transaction.DoOperation();
            return(Save(control.Save(args.RenamedArgs.To, control.SaveItemManager.DoSave(args)),
                        Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To,
                                     args.RenamedArgs.To + ProjectExtension), ref message));
        }
Exemplo n.º 7
0
 public static bool RemoveFile(FileArgs args, IBasicPanel <Project> control, ref string message)
 {
     TransactionFile.DeleteFiles(args);
     return(Save(control.Save(args.Project, control.SaveItemManager.DoSave(args)),
                 Path.Combine(control.FSWorker.WorkDirectory, args.Project, args.Project + ProjectExtension), ref message));
 }