Пример #1
0
 public ProjectArgs(RenamedArgs args)
 {
     Happened    = args.Happened;
     RenamedArgs = args;
     Project     = args.From;
     Callback    = args.Callback;
 }
Пример #2
0
 public FileArgs(string project, RenamedArgs args)
 {
     Project     = project;
     Happened    = args.Happened;
     RenamedArgs = args;
     Callback    = args.Callback;
 }
Пример #3
0
 private bool DoParseAndDo(FileSystemTask task, ref string message)
 {
     if (task.IsFolder == true)
     {
         var args = task.Args as ProjectArgs;
         if (args == null)
         {
             message = "Invalid cast";
             return(false);
         }
         RenamedArgs renamedArgs = args.RenamedArgs;
         if (renamedArgs != null)
         {
             return(BrowseSystem.RenameProject(args, Control, ref message));
         }
         return(Do(args.Happened, true, args, ref message));
     }
     else if (task.IsFolder == false)
     {
         bool resposne = true;
         var  args     = task.Args as FileArgs;
         if (args == null)
         {
             message = "Invalid cast";
             return(false);
         }
         RenamedArgs renamedArgs = args.RenamedArgs;
         if (renamedArgs != null)
         {
             string             path        = Path.Combine(task.Path, "Files");
             ComplexTransaction transaction = new ComplexTransaction();
             transaction.AddOperation(() =>
                                      RenameFile(Path.Combine(path, renamedArgs.From + BrowseSystem.Extension), Path.Combine(path, renamedArgs.To + BrowseSystem.Extension)),
                                      () =>
                                      RenameFile(Path.Combine(path, renamedArgs.To + BrowseSystem.Extension), Path.Combine(path, renamedArgs.From + BrowseSystem.Extension)));
             if (File.Exists(Path.Combine(path, renamedArgs.From + NoteExtension)))
             {
                 transaction.AddOperation(
                     () =>
                     RenameFile(Path.Combine(path, renamedArgs.From + NoteExtension),
                                Path.Combine(path, renamedArgs.To + NoteExtension)),
                     () =>
                     RenameFile(Path.Combine(path, renamedArgs.To + NoteExtension),
                                Path.Combine(path, renamedArgs.From + NoteExtension)));
             }
             transaction.DoOperation();
             return(File.Exists(Path.Combine(path, renamedArgs.To + BrowseSystem.Extension)));
             //bool res =  TransactionFile.MoveFile(
             //        Path.Combine(path, renamedArgs.From + BrowseSystem.Extension), Path.Combine(path, renamedArgs.To + BrowseSystem.Extension),
             //        ref message);
             //if(!File.Exists(Path.Combine(path, renamedArgs.From + NoteExtension))) { return res; }
             //     res &= TransactionFile.MoveFile(
             //               Path.Combine(path, renamedArgs.From + NoteExtension),
             //               Path.Combine(path, renamedArgs.To + NoteExtension),
             //               ref message);
             //    renamedArgs = new RenamedArgs(Path.Combine(path, renamedArgs.From + BrowseSystem.Extension), Path.Combine(path, renamedArgs.To + BrowseSystem.Extension), renamedArgs.Callback);
             // return res;
         }
         resposne = Do(args.Happened, false, args, ref message);
         return(resposne);
     }
     message = "Invalid parameter";
     return(false);
 }