Exemplo n.º 1
0
 private void OnRenamedChanged(object sender, FileArgs e)
 {
     if (e.RenamedArgs != null)
     {
         Queue.AddTask(Path.Combine(WorkDirectory, e.Project), e, e.Callback);
         return;
     }
     e.Files.ForEach(file => Queue.AddTask(Path.Combine(WorkDirectory, e.Project), e, e.Callback));
 }
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 DeleteFiles(FileArgs args)
        {
            bool   response = true;
            string message  = String.Empty;

            return(TransactionActionHelper.DoActionWithCheckOnTransaction((ref string s) =>
            {
                foreach (var file in args.Files)
                {
                    if (!response)
                    {
                        return false;
                    }
                    if (!TransactionActionHelper.CheckConditions((ref string mes) =>
                    {
                        if (!File.Exists(file))
                        {
                            mes = "Wrong path or file exists";
                            Transaction.Current.Rollback();
                            return false;
                        }
                        return true;
                    }, ref s))
                    {
                        return false;
                    }
                    SafeTransactionHandle txHandle = null;
                    try
                    {
                        IKernelTransaction kernelTx =
                            (IKernelTransaction)TransactionInterop.GetDtcTransaction(Transaction.Current);
                        kernelTx.GetHandle(out txHandle);
                        if (!DeleteFileTransacted(file, txHandle))
                        {
                            Transaction.Current.Rollback();
                            response = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        response = false;
                        s = ex.Message;
                        Transaction.Current.Rollback();
                    }
                    finally
                    {
                        if (txHandle != null && !txHandle.IsInvalid)
                        {
                            txHandle.Dispose();
                        }
                    }
                }
                return response;
            }, ref message));
        }
Exemplo n.º 4
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.º 5
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));
 }