public void ResetDownloadStatus(int itemId)
        {
            var updateVer = new UpdateLocalVersion(itemId, string.Empty, 0);
            var queue     = new UpdateLocalVersionQueue(this);

            queue.QueueUpdate(updateVer);
            queue.Flush();
        }
Example #2
0
        public void UpdateLocalVersion(UpdateLocalVersionQueue queue)
        {
            Message msg = new Message(GetWebRequest(new Uri(Url)), "UpdateLocalVersion");

            queue.ToXml(msg.Body, "UpdateLocalVersion");

            HttpWebResponse response = Invoke(msg);

            response.Close();
        }
        internal void UpdateLocalVersion(UpdateLocalVersionQueue updateLocalVersionQueue)
        {
            var invoker = new SoapInvoker(this);
            var msg     = invoker.CreateEnvelope("UpdateLocalVersion");

            foreach (var el in updateLocalVersionQueue.ToXml(MessageNs))
            {
                msg.Add(el);
            }
            invoker.InvokeResult();
        }
Example #4
0
        public int PendRename(string oldPath, string newPath)
        {
            string newServerPath;

            if (VersionControlPath.IsServerItem(newPath))
            {
                newServerPath = GetServerItemForLocalItem(newPath);
            }
            else
            {
                newServerPath = newPath;
            }

            ItemType itemType = ItemType.File;

            if (Directory.Exists(oldPath))
            {
                itemType = ItemType.Folder;
            }

            List <ChangeRequest> changes = new List <ChangeRequest>();

            changes.Add(new ChangeRequest(oldPath, newServerPath, RequestType.Rename, itemType));

            GetOperation[] getOperations = Repository.PendChanges(this, changes.ToArray());

            if (itemType == ItemType.File)
            {
                File.Move(oldPath, newPath);
            }
            else
            {
                Directory.Move(oldPath, newPath);
            }

            UpdateLocalVersionQueue updates = new UpdateLocalVersionQueue(this);

            foreach (GetOperation getOperation in getOperations)
            {
                updates.QueueUpdate(getOperation.ItemId, getOperation.TargetLocalItem, getOperation.VersionServer);
            }

            updates.Flush();
            return(1);
        }
 internal void UpdateLocalVersion(UpdateLocalVersionQueue updateLocalVersionQueue)
 {
     var invoker = new SoapInvoker(this);
     var msg = invoker.CreateEnvelope("UpdateLocalVersion");
     foreach (var el in updateLocalVersionQueue.ToXml(MessageNs))
     {
         msg.Add(el);
     }
     invoker.InvokeResult();
 }
Example #6
0
        public int PendRename(string oldPath, string newPath)
        {
            string newServerPath;
            if (VersionControlPath.IsServerItem(newPath)) newServerPath = GetServerItemForLocalItem(newPath);
            else newServerPath = newPath;

            ItemType itemType = ItemType.File;
            if (Directory.Exists(oldPath)) itemType = ItemType.Folder;

            List<ChangeRequest> changes = new List<ChangeRequest>();
            changes.Add(new ChangeRequest(oldPath, newServerPath, RequestType.Rename, itemType));

            GetOperation[] getOperations = Repository.PendChanges(this, changes.ToArray());

            if (itemType == ItemType.File)
                File.Move(oldPath, newPath);
            else
                Directory.Move(oldPath, newPath);

            UpdateLocalVersionQueue updates = new UpdateLocalVersionQueue(this);
            foreach (GetOperation getOperation in getOperations)
                {
                    updates.QueueUpdate(getOperation.ItemId, getOperation.TargetLocalItem, getOperation.VersionServer);
                }

            updates.Flush();
            return 1;
        }
Example #7
0
        public int PendDelete(string[] paths, RecursionType recursionType)
        {
            List<ChangeRequest> changes = new List<ChangeRequest>();
            foreach (string path in paths)
                {
                    ItemType itemType = ItemType.File;
                    if (Directory.Exists(path)) itemType = ItemType.Folder;
                    changes.Add(new ChangeRequest(path, RequestType.Delete, itemType));
                }

            if (changes.Count == 0) return 0;

            GetOperation[] operations = Repository.PendChanges(this, changes.ToArray());
            UpdateLocalVersionQueue updates = new UpdateLocalVersionQueue(this);

            // first delete all files
            foreach (GetOperation operation in operations)
                {
                    if (operation.ItemType != ItemType.File) continue;
                    if (!File.Exists(operation.SourceLocalItem)) continue;

                    UnsetFileAttributes(operation.SourceLocalItem);
                    File.Delete(operation.SourceLocalItem);
                    updates.QueueUpdate(operation.ItemId, null, operation.VersionServer);
                }

            // then any directories
            foreach (GetOperation operation in operations)
                {
                    if (operation.ItemType != ItemType.Folder) continue;
                    if (!Directory.Exists(operation.SourceLocalItem)) continue;

                    //DirectoryInfo dir = new DirectoryInfo(operation.SourceLocalItem);
                    //FileInfo[] localFiles = dir.GetFiles("*", SearchOption.AllDirectories);
                    //foreach (FileInfo file in localFiles)
                    //	UnsetFileAttributes(file.FullName);

                    Directory.Delete(operation.SourceLocalItem, true);
                    updates.QueueUpdate(operation.ItemId, null, operation.VersionServer);
                }

            updates.Flush();
            return operations.Length;
        }
Example #8
0
        public GetStatus Get(GetRequest[] requests, GetOptions options, 
												 GetFilterCallback filterCallback, object userData)
        {
            bool force = ((GetOptions.Overwrite & options) == GetOptions.Overwrite);
            bool noGet = false; // not implemented below: ((GetOptions.Preview & options) == GetOptions.Preview);

            SortedList<int, DateTime> changesetDates = new SortedList<int, DateTime>();
            GetOperation[] getOperations = Repository.Get(Name, OwnerName, requests, force, noGet);
            if (null != filterCallback) filterCallback(this, getOperations, userData);

            UpdateLocalVersionQueue updates = new UpdateLocalVersionQueue(this);
            foreach (GetOperation getOperation in getOperations)
                {
                    string uPath = null;
                    GettingEventArgs args = new GettingEventArgs(this, getOperation);

                    // Console.WriteLine(getOperation.ToString());

                    if (getOperation.DeletionId != 0)
                        {
                            if ((getOperation.ItemType == ItemType.Folder)&&
                                    (Directory.Exists(getOperation.SourceLocalItem)))
                                {
                                    UnsetDirectoryAttributes(getOperation.SourceLocalItem);
                                    Directory.Delete(getOperation.SourceLocalItem, true);
                                }
                            else if ((getOperation.ItemType == ItemType.File)&&
                                             (File.Exists(getOperation.SourceLocalItem)))
                                {
                                    UnsetFileAttributes(getOperation.SourceLocalItem);
                                    File.Delete(getOperation.SourceLocalItem);
                                }
                        }
                    else if ((!String.IsNullOrEmpty(getOperation.TargetLocalItem))&&
                                     (!String.IsNullOrEmpty(getOperation.SourceLocalItem))&&
                                     (getOperation.SourceLocalItem != getOperation.TargetLocalItem))
                        {
                            uPath = getOperation.TargetLocalItem;
                            try
                                {
                                    File.Move(getOperation.SourceLocalItem, getOperation.TargetLocalItem);
                                }
                            catch (IOException)
                                {
                                    args.Status = OperationStatus.TargetIsDirectory;
                                }
                        }
                    else if (getOperation.ChangeType == ChangeType.None &&
                                     getOperation.VersionServer != 0)
                        {
                            uPath = getOperation.TargetLocalItem;
                            string directory = uPath;

                            if (getOperation.ItemType == ItemType.File)
                                directory = Path.GetDirectoryName(uPath);

                            if (!Directory.Exists(directory))
                                Directory.CreateDirectory(directory);

                            if (getOperation.ItemType == ItemType.File)
                                {
                                    DownloadFile.WriteTo(uPath, Repository, getOperation.ArtifactUri);

                                    // ChangesetMtimes functionality : none standard!
                                    if (mTimeSetting)
                                        {
                                            int cid = getOperation.VersionServer;
                                            DateTime modDate;

                                            if (!changesetDates.TryGetValue(cid, out modDate))
                                                {
                                                    Changeset changeset = VersionControlServer.GetChangeset(cid);
                                                    modDate = changeset.CreationDate;
                                                    changesetDates.Add(cid, modDate);
                                                }

                                            File.SetLastWriteTime(uPath, modDate);
                                        }

                                    // do this after setting the last write time!
                                    SetFileAttributes(uPath);
                                }
                        }

                    versionControlServer.OnDownloading(args);
                    updates.QueueUpdate(getOperation.ItemId, uPath, getOperation.VersionServer);
                }

            updates.Flush();
            return new GetStatus(getOperations.Length);
        }
        private void UndoGetOperations(List <GetOperation> getOperations, IProgressMonitor monitor = null)
        {
            if (getOperations == null || getOperations.Count == 0)
            {
                return;
            }
            var downloadService       = this.VersionControlService.Collection.GetService <VersionControlDownloadService>();
            IProgressMonitor progress = monitor ?? new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor(DispatchService.IsGuiThread, false, false);

            try
            {
                progress.BeginTask("Undo", getOperations.Count);
                UpdateLocalVersionQueue updates = new UpdateLocalVersionQueue(this);
                foreach (var operation in getOperations)
                {
                    try
                    {
                        if (progress.IsCancelRequested)
                        {
                            break;
                        }
                        string stepName = operation.ChangeType == ChangeType.None ? "Undo " : operation.ChangeType.ToString();
                        progress.BeginTask(stepName + " " + operation.TargetLocalItem, 1);
                        UpdateLocalVersion update = null;

                        if (operation.IsAdd)
                        {
                            update = ProcessAdd(operation, ProcessDirection.Undo);
                            if (update != null)
                            {
                                updates.QueueUpdate(update);
                            }
                            continue;
                        }

                        if (operation.IsDelete)
                        {
                            update = ProcessDelete(operation, downloadService, ProcessDirection.Undo, ProcessType.Delete);
                            if (update != null)
                            {
                                updates.QueueUpdate(update);
                            }
                        }

                        if (operation.IsRename)
                        {
                            update = ProcessRename(operation, ProcessDirection.Undo, progress);
                            if (update != null)
                            {
                                updates.QueueUpdate(update);
                            }
                        }
                        if (operation.IsEdit || operation.IsEncoding)
                        {
                            update = ProcessEdit(operation, downloadService, ProcessDirection.Undo);
                            if (update != null)
                            {
                                updates.QueueUpdate(update);
                            }
                        }
                    }
                    finally
                    {
                        progress.EndTask();
                    }
                }
                updates.Flush();
                progress.EndTask();
            }
            finally
            {
                if (monitor == null && progress != null)
                {
                    progress.Dispose();
                }
            }
        }
        private void ProcessGetOperations(List <GetOperation> getOperations, ProcessType processType, IProgressMonitor monitor = null)
        {
            if (getOperations == null || getOperations.Count == 0)
            {
                return;
            }
            var downloadService       = this.VersionControlService.Collection.GetService <VersionControlDownloadService>();
            IProgressMonitor progress = monitor ?? new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor(DispatchService.IsGuiThread, false, false);

            try
            {
                progress.BeginTask("Process", getOperations.Count);
                UpdateLocalVersionQueue updates = new UpdateLocalVersionQueue(this);
                foreach (var operation in getOperations)
                {
                    try
                    {
                        if (progress.IsCancelRequested)
                        {
                            break;
                        }
                        progress.BeginTask(processType + " " + operation.TargetLocalItem, 1);
                        UpdateLocalVersion update = null;

                        switch (processType)
                        {
                        case ProcessType.Add:
                            update = ProcessAdd(operation, ProcessDirection.Normal);
                            break;

                        case ProcessType.Edit:
                            update = ProcessEdit(operation, downloadService, ProcessDirection.Normal);
                            break;

                        case ProcessType.Get:
                            update = ProcessGet(operation, downloadService, ProcessDirection.Normal);
                            break;

                        case ProcessType.Rename:
                            update = ProcessRename(operation, ProcessDirection.Normal, progress);
                            break;

                        case ProcessType.Delete:
                        case ProcessType.DeleteKeep:
                            update = ProcessDelete(operation, downloadService, ProcessDirection.Normal, processType);
                            break;

                        default:
                            update = ProcessGet(operation, downloadService, ProcessDirection.Normal);
                            break;
                        }

                        if (update != null)
                        {
                            updates.QueueUpdate(update);
                        }
                    }
                    finally
                    {
                        progress.EndTask();
                    }
                }
                updates.Flush();
                progress.EndTask();
            }
            finally
            {
                if (monitor == null && progress != null)
                {
                    progress.Dispose();
                }
            }
        }
Example #11
0
        public int PendDelete(string[] paths, RecursionType recursionType)
        {
            List <ChangeRequest> changes = new List <ChangeRequest>();

            foreach (string path in paths)
            {
                ItemType itemType = ItemType.File;
                if (Directory.Exists(path))
                {
                    itemType = ItemType.Folder;
                }
                changes.Add(new ChangeRequest(path, RequestType.Delete, itemType));
            }

            if (changes.Count == 0)
            {
                return(0);
            }

            GetOperation[]          operations = Repository.PendChanges(this, changes.ToArray());
            UpdateLocalVersionQueue updates    = new UpdateLocalVersionQueue(this);

            // first delete all files
            foreach (GetOperation operation in operations)
            {
                if (operation.ItemType != ItemType.File)
                {
                    continue;
                }
                if (!File.Exists(operation.SourceLocalItem))
                {
                    continue;
                }

                UnsetFileAttributes(operation.SourceLocalItem);
                File.Delete(operation.SourceLocalItem);
                updates.QueueUpdate(operation.ItemId, null, operation.VersionServer);
            }

            // then any directories
            foreach (GetOperation operation in operations)
            {
                if (operation.ItemType != ItemType.Folder)
                {
                    continue;
                }
                if (!Directory.Exists(operation.SourceLocalItem))
                {
                    continue;
                }

                //DirectoryInfo dir = new DirectoryInfo(operation.SourceLocalItem);
                //FileInfo[] localFiles = dir.GetFiles("*", SearchOption.AllDirectories);
                //foreach (FileInfo file in localFiles)
                //	UnsetFileAttributes(file.FullName);

                Directory.Delete(operation.SourceLocalItem, true);
                updates.QueueUpdate(operation.ItemId, null, operation.VersionServer);
            }

            updates.Flush();
            return(operations.Length);
        }
Example #12
0
        public GetStatus Get(GetRequest[] requests, GetOptions options,
                             GetFilterCallback filterCallback, object userData)
        {
            bool force = ((GetOptions.Overwrite & options) == GetOptions.Overwrite);
            bool noGet = false;             // not implemented below: ((GetOptions.Preview & options) == GetOptions.Preview);

            SortedList <int, DateTime> changesetDates = new SortedList <int, DateTime>();

            GetOperation[] getOperations = Repository.Get(Name, OwnerName, requests, force, noGet);
            if (null != filterCallback)
            {
                filterCallback(this, getOperations, userData);
            }

            UpdateLocalVersionQueue updates = new UpdateLocalVersionQueue(this);

            foreach (GetOperation getOperation in getOperations)
            {
                string           uPath = null;
                GettingEventArgs args  = new GettingEventArgs(this, getOperation);

                // Console.WriteLine(getOperation.ToString());

                if (getOperation.DeletionId != 0)
                {
                    if ((getOperation.ItemType == ItemType.Folder) &&
                        (Directory.Exists(getOperation.SourceLocalItem)))
                    {
                        UnsetDirectoryAttributes(getOperation.SourceLocalItem);
                        Directory.Delete(getOperation.SourceLocalItem, true);
                    }
                    else if ((getOperation.ItemType == ItemType.File) &&
                             (File.Exists(getOperation.SourceLocalItem)))
                    {
                        UnsetFileAttributes(getOperation.SourceLocalItem);
                        File.Delete(getOperation.SourceLocalItem);
                    }
                }
                else if ((!String.IsNullOrEmpty(getOperation.TargetLocalItem)) &&
                         (!String.IsNullOrEmpty(getOperation.SourceLocalItem)) &&
                         (getOperation.SourceLocalItem != getOperation.TargetLocalItem))
                {
                    uPath = getOperation.TargetLocalItem;
                    try
                    {
                        File.Move(getOperation.SourceLocalItem, getOperation.TargetLocalItem);
                    }
                    catch (IOException)
                    {
                        args.Status = OperationStatus.TargetIsDirectory;
                    }
                }
                else if (getOperation.ChangeType == ChangeType.None &&
                         getOperation.VersionServer != 0)
                {
                    uPath = getOperation.TargetLocalItem;
                    string directory = uPath;

                    if (getOperation.ItemType == ItemType.File)
                    {
                        directory = Path.GetDirectoryName(uPath);
                    }

                    if (!Directory.Exists(directory))
                    {
                        Directory.CreateDirectory(directory);
                    }

                    if (getOperation.ItemType == ItemType.File)
                    {
                        DownloadFile.WriteTo(uPath, Repository, getOperation.ArtifactUri);

                        // ChangesetMtimes functionality : none standard!
                        if (mTimeSetting)
                        {
                            int      cid = getOperation.VersionServer;
                            DateTime modDate;

                            if (!changesetDates.TryGetValue(cid, out modDate))
                            {
                                Changeset changeset = VersionControlServer.GetChangeset(cid);
                                modDate = changeset.CreationDate;
                                changesetDates.Add(cid, modDate);
                            }

                            File.SetLastWriteTime(uPath, modDate);
                        }

                        // do this after setting the last write time!
                        SetFileAttributes(uPath);
                    }
                }

                versionControlServer.OnDownloading(args);
                updates.QueueUpdate(getOperation.ItemId, uPath, getOperation.VersionServer);
            }

            updates.Flush();
            return(new GetStatus(getOperations.Length));
        }
Example #13
0
        public void UpdateLocalVersion(UpdateLocalVersionQueue queue)
        {
            Message msg = new Message(GetWebRequest (new Uri(Url)), "UpdateLocalVersion");
            queue.ToXml(msg.Body, "UpdateLocalVersion");

            HttpWebResponse response = Invoke(msg);
            response.Close();
        }