示例#1
0
 void CleareContent()
 {
     Commits.Clear();
     Branches.Clear();
     Edges.Clear();
     View.Children.Clear();
 }
示例#2
0
 public void Clear()
 {
     Commits?.Clear();
     Branches?.Clear();
     Edges?.Clear();
     CommitToModel?.Clear();
     ContentCleared?.Invoke();
 }
示例#3
0
                /// <summary>
                /// 清空
                /// </summary>
                public PipeGroupCollection Clear()
                {
                    PipeGroupCollection collection = new PipeGroupCollection();

                    foreach (var branch in Branches)
                    {
                        collection.Add(branch.ToPipeGroup());
                    }
                    Branches.Clear();
                    LatestSkewPipe = null;
                    return(collection);
                }
示例#4
0
            public void Maintenance(int level, Token token)
            {
                if (HaveChildrenForMaintenance)
                {
                    MaintenanceHelper[] helpers = new MaintenanceHelper[Branches.Count];
                    for (int index = Branches.Count - 1; index >= 0; index--)
                    {
                        helpers[index] = new MaintenanceHelper(level, token, helpers, Branches[index], index);
                    }

                    Branches.Clear();
                    for (int index = 0; index < helpers.Length; index++)
                    {
                        var helper = helpers[index];
                        helper.Task.Wait();
                        Branches.AddRange(helper.List);
                    }

                    RebuildOptimizator();

                    HaveChildrenForMaintenance = false;

                    IsModified = true;
                }

                //sink branches
                int operationCount = Branches.Sum(x => x.Value.Cache.OperationCount);

                if (operationCount > Branch.Tree.MAX_OPERATIONS)
                {
                    //Debug.WriteLine(string.Format("{0}: {1} = {2}", level, Branch.NodeHandle, operationCount));
                    foreach (var kv in Branches.Where(x => x.Value.Cache.OperationCount > 0).OrderByDescending(x => x.Value.Cache.OperationCount))
                    {
                        Branch branch = kv.Value;

                        operationCount -= branch.Cache.OperationCount;
                        if (branch.Fall(level, token, new Params(WalkMethod.Current, WalkAction.None, null, true)))
                        {
                            IsModified = true;
                        }

                        if (operationCount <= Branch.Tree.MIN_OPERATIONS)
                        {
                            break;
                        }

                        //branch.WaitFall();
                    }
                }
            }
示例#5
0
        void RefreshBranches(IObservableRepository repo)
        {
            Branches.Clear();
            foreach (var branch in repo.Inner.Branches
                     .Select(x => new BranchViewModel {
                Name = x.Name, CanonicalName = x.CanonicalName
            }))
            {
                Branches.Add(branch);
            }

            SelectedBranch = Branches.FirstOrDefault(
                b => b.CanonicalName == repo.Inner.Head.CanonicalName);
        }
示例#6
0
        private void GetBranches()
        {
            using (var unitOfWork = new UnitOfWork())
            {
                if (!Branches.Any())
                {
                    Branches.Clear();
                    Branches.Add(new Branch()
                    {
                        branch_name = ""
                    });
                    Branches.AddRange(unitOfWork.BranchRepository.GetAll());
                }

                branchBindingSource.DataSource = Branches;
            }
        }
示例#7
0
        private void LoadSettingsFile(string filename)
        {
            Output.WriteLine("Loading settings file {0}...", filename);

            var errorMessage = string.Empty;

            try
            {
                UserSettings.ReadFromFile(filename);
            }
            catch (InvalidSettingsFileException ex)
            {
                errorMessage = ex.Message;
            }

            if (!string.IsNullOrEmpty(errorMessage) || !UserSettings.IsValid)
            {
                var msg = $"Failed to load settings file {filename}";
                if (!string.IsNullOrEmpty(errorMessage))
                {
                    msg += Environment.NewLine + errorMessage;
                }
                msg += Environment.NewLine + "Please fix the settings file and reload it with the button.";

                Output.WriteLine(msg);
                Popups.ShowMessage(null, msg, MessageBoxImage.Asterisk, "Load failed");

                return;
            }

            ServerAddress = UserSettings.ServerUri.ToString();
            TfsExePath    = UserSettings.TfsExecutable.FullName;

            Branches.Clear();
            foreach (var branch in UserSettings.BranchPathList)
            {
                var branchWm = new BranchViewModel(branch.Item2, branch.Item1);
                Branches.Add(branchWm);
            }

            Output.WriteLine("Reading settings finished.");
        }
示例#8
0
        public async Task UpdateBranchesAsync()
        {
            var previousBranch = Branch;

            Dictionary <string, int> branchStats = new Dictionary <string, int>();

            foreach (var repository in settings_.GetValidatedGitRepositories())
            {
                var branches = await GitHelper.GetBranchesAsync(repository);

                foreach (var branch in branches)
                {
                    if (branchStats.TryGetValue(branch, out int count))
                    {
                        branchStats[branch] = ++count;
                    }
                    else
                    {
                        branchStats[branch] = 1;
                    }
                }
            }

            Branches.Clear();


            Branches.Add(null);

            foreach (var branch in branchStats.OrderByDescending(b => b.Value).ThenBy(b => b.Key))
            {
                Branches.Add(branch.Key);
            }

            if (previousBranch != null && Branches.Contains(previousBranch))
            {
                Branch = previousBranch;
            }
            else
            {
                Branch = null;
            }
        }
        private void ReloadBranches()
        {
            var selectedBranch = SelectedBranch?.Name;

            Branches.Clear();
            var branches = new ShellCommand().ExecuteGit("branch", GitRoot).Select(p => p.Trim());

            foreach (var branch in branches)
            {
                Branches.Add(new Branch {
                    Name = branch
                });
            }
            if (selectedBranch != null)
            {
                SelectedBranch = Branches.SingleOrDefault(p => p.Name == selectedBranch);
            }
            else
            {
                SelectedBranch = Branches.FirstOrDefault(p => p.Name == "master") ?? Branches.FirstOrDefault();
            }
        }
        public override bool TryParse()
        {
            if (!base.TryParse())
            {
                return(false);
            }

            // groups, flows, branches, bcs
            Groups.Clear();
            Flows.Clear();
            Branches.Clear();
            BusinessComponents.Clear();
            RecoverySteps.Clear();
            GeneralSteps.Clear();

            ReportNodeType[] childNodes = Node.ReportNode;
            if (childNodes != null)
            {
                foreach (ReportNodeType node in childNodes)
                {
                    // business component
                    BusinessComponentReport bc = BusinessComponents.TryParseAndAdd(node, this.Node);
                    if (bc != null)
                    {
                        AllBCsEnumerator.Add(bc);
                        continue;
                    }

                    // group
                    GroupReport group = Groups.TryParseAndAdd(node, this.Node);
                    if (group != null)
                    {
                        AllBCsEnumerator.Merge(group.AllBCsEnumerator);
                        continue;
                    }

                    // flow
                    FlowReport flow = Flows.TryParseAndAdd(node, this.Node);
                    if (flow != null)
                    {
                        AllBCsEnumerator.Merge(flow.AllBCsEnumerator);
                        continue;
                    }

                    // branch
                    BranchReport branch = Branches.TryParseAndAdd(node, this.Node);
                    if (branch != null)
                    {
                        AllBCsEnumerator.Merge(branch.AllBCsEnumerator);
                        continue;
                    }

                    // recovery step
                    RecoveryStepReport recovery = RecoverySteps.TryParseAndAdd(node, this.Node);
                    if (recovery != null)
                    {
                        AllBCsEnumerator.Merge(recovery.AllBCsEnumerator);
                        continue;
                    }

                    // general step
                    GeneralStepReport generalStep = GeneralSteps.TryParseAndAdd(node, this.Node);
                    if (generalStep != null)
                    {
                        AllBCsEnumerator.Merge(generalStep.AllBCsEnumerator);
                        continue;
                    }
                }
            }

            return(true);
        }
示例#11
0
        /// <summary>
        /// Loads branches and commits.
        /// </summary>
        /// <param name="repo"></param>
        private void LoadBranchesAndCommits(LibGit2Sharp.Repository repo)
        {
            var dispose = false;

            if (repo == null)
            {
                repo    = new LibGit2Sharp.Repository(RepositoryFullPath);
                dispose = true;
            }

            // Small performance boosts.
            Commits.DisableNotifications();
            Branches.DisableNotifications();

            // Create commits.
            Commits.Clear();
            List <Commit> commitList = new List <Commit>();

            foreach (LibGit2Sharp.Commit commit in repo.Commits.QueryBy(new LibGit2Sharp.Filter {
                Since = repo.Branches
            }).Take(CommitsPerPage))
            {
                commitList.Add(Commit.Create(repo, commit, Tags));
            }
            Commits.AddRange(commitList);

            // Create branches.
            Branches.Clear();
            foreach (LibGit2Sharp.Branch branch in repo.Branches)
            {
                Branch b = Branch.Create(this, repo, branch);
                Branches.Add(b);
            }

            // Post-process branches (tips and tracking branches).
            foreach (Branch branch in Branches)
            {
                // Set the HEAD property if it matches.
                if (repo.Head.Name == branch.Name)
                {
                    Head = branch;
                    branch.Tip.IsHead = true;
                }

                branch.PostProcess(Branches, Commits);
            }

            // Post-process commits (commit parents).
            foreach (Commit commit in Commits)
            {
                // Set the HEAD property to a DetachedHead branch if the HEAD matched and it was null.
                if (Head == null && repo.Head.Tip.Sha == commit.Hash)
                {
                    Head = new DetachedHead
                    {
                        Tip = commit
                    };

                    commit.IsHead = true;
                }

                commit.PostProcess(Commits, Branches);
            }

            // Calculate commit visual positions for each branch tree.
            foreach (Branch branch in Branches)
            {
                RepoUtil.IncrementCommitTreeVisualPositionsRecursively(branch.Tip);
            }

            Commits.EnableNotifications();
            Branches.EnableNotifications();

            if (dispose)
            {
                repo.Dispose();
            }
        }
示例#12
0
        public override bool TryParse()
        {
            if (!base.TryParse())
            {
                return(false);
            }

            // name
            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Properties.Resources.Test_Step;
            }

            // groups, flows, branches, bcs
            Groups.Clear();
            Flows.Clear();
            Branches.Clear();
            BusinessComponents.Clear();
            RecoverySteps.Clear();
            SubGeneralSteps.Clear();

            ReportNodeType[] childNodes = Node.ReportNode;
            if (childNodes != null)
            {
                foreach (ReportNodeType node in childNodes)
                {
                    // business component
                    BusinessComponentReport bc = BusinessComponents.TryParseAndAdd(node, this.Node);
                    if (bc != null)
                    {
                        AllBCsEnumerator.Add(bc);
                        continue;
                    }

                    // group
                    GroupReport group = Groups.TryParseAndAdd(node, this.Node);
                    if (group != null)
                    {
                        AllBCsEnumerator.Merge(group.AllBCsEnumerator);
                        continue;
                    }

                    // flow
                    FlowReport flow = Flows.TryParseAndAdd(node, this.Node);
                    if (flow != null)
                    {
                        AllBCsEnumerator.Merge(flow.AllBCsEnumerator);
                        continue;
                    }

                    // branch
                    BranchReport branch = Branches.TryParseAndAdd(node, this.Node);
                    if (branch != null)
                    {
                        AllBCsEnumerator.Merge(branch.AllBCsEnumerator);
                        continue;
                    }

                    // recovery steps
                    RecoveryStepReport recovery = RecoverySteps.TryParseAndAdd(node, this.Node);
                    if (recovery != null)
                    {
                        AllBCsEnumerator.Merge(recovery.AllBCsEnumerator);
                        continue;
                    }

                    // sub general steps
                    GeneralStepReport subStep = SubGeneralSteps.TryParseAndAdd(node, this.Node);
                    if (subStep != null)
                    {
                        AllBCsEnumerator.Merge(subStep.AllBCsEnumerator);
                        continue;
                    }
                }
            }

            return(true);
        }
        public GetAppInstallFilesBlobDialogViewModel()
        {
            // Show/Hide Blob
            ShowHideBlobSectionCommand.Subscribe(_ =>
            {
                ShowHideBlobSectionButtonLabel.Value = ShowBlobSectionVisibility.Value == Visibility.Collapsed
                    ? ExpandButtonLabel
                    : CollapseButtonLabel;
                ShowBlobSectionVisibility.Value = ShowBlobSectionVisibility.Value == Visibility.Collapsed
                    ? Visibility.Visible
                    : Visibility.Collapsed;
            })
            .AddTo(disposable);

            // Storage Credential Input
            StorageConnectionInput = new ReactiveProperty <string>(blobConnectionUseCase.Read <string>("blob_connection_string"));
            StorageConnectionInput.Subscribe(x => blobConnectionUseCase.Save("blob_connection_string", x)).AddTo(disposable);
            StorageContainerInput = new ReactiveProperty <string>(blobConnectionUseCase.Read <string>("container"));
            StorageContainerInput.Subscribe(x => blobConnectionUseCase.Save("container", x)).AddTo(disposable);

            // Copy Button
            CopyButtonContent  = new ReactiveProperty <string>("Copy SasUrl");
            CopyButtonEnabled  = ArtifactUrl.Select(x => !string.IsNullOrWhiteSpace(x)).ToReactiveProperty();
            OnClickCopyCommand = CopyButtonEnabled.ToReactiveCommand();
            OnClickCopyCommand
            .Do(_ => blobSasUrlUseCase.CopySasUrl(ArtifactUrl.Value, StorageConnectionInput.Value, StorageContainerInput.Value, SelectedArtifact.Value.Name))
            .SelectMany(x => TemporaryDisableCopyButtonAsObservable(TimeSpan.FromMilliseconds(500), "Copy SasUrl"))
            .Subscribe()
            .AddTo(disposable);

            // Download Button
            blobArtifactUsecase.DownloadStatus.Subscribe(x => DownloadStatus.Value = x).AddTo(disposable);
            OnClickDownloadCommand = CopyButtonEnabled.ToAsyncReactiveCommand();
            OnClickDownloadCommand
            .Subscribe(async _ => await blobArtifactUsecase.DownloadHoloLensPackagesAsync(StorageConnectionInput.Value, StorageContainerInput.Value, SelectedArtifact.Value.Name, SelectedArtifact.Value.Size, SelectedArtifact.Value.FileName))
            .AddTo(disposable);

            // OpenFolder Button
            OnClickOpenDownloadFolderCommand.Subscribe(_ => blobArtifactUsecase.OpenFolderAsync()).AddTo(disposable);
            OnClickOpenDownloadBlobFolderCommand.Subscribe(_ => blobArtifactUsecase.OpenDownloadFolderAsync()).AddTo(disposable);

            // Initialize by obtain artifact informations
            blobArtifactUsecase.Artifacts
            .Where(x => x != null)
            .Do(x =>
            {
                Projects.Add(x);
                BlobResult.Value = $"Found {Projects.Count} projects.";
            })
            .Subscribe()
            .AddTo(disposable);
            blobArtifactUsecase.RequestFailedMessage
            .Do(x => BlobResult.Value = x)
            .Subscribe()
            .AddTo(disposable);

            // Blob Download
            ComboBoxEnabled         = Projects.CollectionChangedAsObservable().Any().ToReactiveProperty();
            IsEnableCheckBlobButton = StorageConnectionInput
                                      .CombineLatest(StorageContainerInput, (r, l) => !string.IsNullOrWhiteSpace(r) && !string.IsNullOrWhiteSpace(l))
                                      .ToReadOnlyReactiveProperty();
            OnClickCheckBlobCommand = IsEnableCheckBlobButton.ToAsyncReactiveCommand();
            OnClickCheckBlobCommand.Subscribe(async _ =>
            {
                var task             = blobArtifactUsecase.RequestHoloLensPackagesAsync(StorageConnectionInput.Value, StorageContainerInput.Value);
                IsBlobChecking.Value = true;
                Projects.Clear();
                Branches?.Clear();
                Artifacts?.Clear();
                BlobResult.Value = "Trying obtain project infomations.";
                await task;
                IsBlobChecking.Value = false;
            })
            .AddTo(disposable);
            OnClickCancelBlobCommand = IsBlobChecking.Select(x => x).ToReactiveCommand();
            OnClickCancelBlobCommand
            .Do(_ => Projects.Clear())
            .Subscribe(_ => blobArtifactUsecase.CancelRequest())
            .AddTo(disposable);

            // Update Collection with Clear existing collection when selected.
            Branches = SelectedProject.Where(x => x != null)
                       .Do(_ => Branches?.Clear())
                       .Do(_ => Artifacts?.Clear())
                       .SelectMany(x => blobArtifactUsecase.GetArtifactCache(x.Project))
                       .ToReactiveCollection();
            Artifacts = SelectedBranch.Where(x => x != null)
                        .Do(x => Artifacts?.Clear())
                        .SelectMany(x => blobArtifactUsecase.GetArtifactCache(SelectedProject.Value?.Project, x.Branch))
                        .ToReactiveCollection();
            SelectedArtifact
            .Where(x => x != null)
            .Do(x =>
            {
                ArtifactName.Value    = x.Name;
                ArtifactCaption.Value = $"(Size: {x.Size}, MD5: {x.MD5}, LeaseState: {x.LeaseState})";
                ArtifactUrl.Value     = x.Uri.AbsoluteUri;
            })
            .ToReactiveProperty();
        }
示例#14
0
        public override bool TryParse()
        {
            if (!base.TryParse())
            {
                return(false);
            }

            // for the branch (case) report node, the next level node is "Step" type
            // case name and description is retrieved from the "Step" type node
            ReportNodeType[] childNodes = Node.ReportNode;
            if (childNodes == null || childNodes.Length == 0)
            {
                return(false);
            }
            ReportNodeType caseStepNode = childNodes[0];

            if (caseStepNode.type.ToLower() != NodeType_Step)
            {
                return(false);
            }
            CaseName        = caseStepNode.Data.Name;
            CaseDescription = caseStepNode.Data.Description;

            // groups, flows, branches, bcs
            Groups.Clear();
            Flows.Clear();
            Branches.Clear();
            BusinessComponents.Clear();
            RecoverySteps.Clear();
            GeneralSteps.Clear();

            childNodes = caseStepNode.ReportNode;
            if (childNodes != null)
            {
                foreach (ReportNodeType node in childNodes)
                {
                    // business component
                    BusinessComponentReport bc = BusinessComponents.TryParseAndAdd(node, this.Node);
                    if (bc != null)
                    {
                        AllBCsEnumerator.Add(bc);
                        continue;
                    }

                    // group
                    GroupReport group = Groups.TryParseAndAdd(node, this.Node);
                    if (group != null)
                    {
                        AllBCsEnumerator.Merge(group.AllBCsEnumerator);
                        continue;
                    }

                    // flow
                    FlowReport flow = Flows.TryParseAndAdd(node, this.Node);
                    if (flow != null)
                    {
                        AllBCsEnumerator.Merge(flow.AllBCsEnumerator);
                        continue;
                    }

                    // branch
                    BranchReport branch = Branches.TryParseAndAdd(node, this.Node);
                    if (branch != null)
                    {
                        AllBCsEnumerator.Merge(branch.AllBCsEnumerator);
                        continue;
                    }

                    // recovery step
                    RecoveryStepReport recovery = RecoverySteps.TryParseAndAdd(node, this.Node);
                    if (recovery != null)
                    {
                        AllBCsEnumerator.Merge(recovery.AllBCsEnumerator);
                        continue;
                    }

                    // general step
                    GeneralStepReport generalStep = GeneralSteps.TryParseAndAdd(node, this.Node);
                    if (generalStep != null)
                    {
                        AllBCsEnumerator.Merge(generalStep.AllBCsEnumerator);
                        continue;
                    }
                }
            }

            return(true);
        }
示例#15
0
        /// <summary>
        /// Loads branches and commits.
        /// </summary>
        /// <param name="repo"></param>
        private void LoadBranchesAndCommits(LibGit2Sharp.Repository repo = null)
        {
            var dispose = false;

            if (repo == null)
            {
                repo    = new LibGit2Sharp.Repository(RepositoryFullPath);
                dispose = true;
            }

            // Small performance boosts.
            Commits.DisableNotifications();
            Branches.DisableNotifications();

            // Create commits.
            Commits.Clear();
            var commitList = new List <Commit>();

            foreach (var commit in repo.Commits.QueryBy(new LibGit2Sharp.Filter {
                Since = repo.Branches
            }).Take(CommitsPerPage))
            {
                commitList.Add(Commit.Create(repo, commit, Tags));
            }
            Commits.AddRange(commitList);

            // Create branches.
            Branches.Clear();
            foreach (var branch in repo.Branches)
            {
                var b = Branch.Create(this, repo, branch);
                Branches.Add(b);
            }

            // Post-process branches (tips and tracking branches).
            foreach (var branch in Branches)
            {
                // Set the HEAD property if it matches.
                if (repo.Head.Name == branch.Name)
                {
                    Head = branch;
                    branch.Tip.IsHead = true;
                }

                branch.PostProcess(Branches, Commits);
            }

            // Post-process commits (commit parents).
            foreach (var commit in Commits)
            {
                // Set the HEAD property to a DetachedHead branch if the HEAD matched and it was null.
                if (Head == null && repo.Head.Tip.Sha == commit.Hash)
                {
                    Head = new DetachedHead
                    {
                        Tip = commit
                    };

                    commit.IsHead = true;
                }

                commit.PostProcess(Commits, Branches);
            }

            // Calculate commit visual positions for each branch tree.
            foreach (var branch in Branches)
            {
                RepoUtil.IncrementCommitTreeVisualPositionsRecursively(branch.Tip);
            }

            // Fire notifications for the collections on the UI thread.
            Application.Current.Dispatcher.Invoke(
                DispatcherPriority.Normal,
                (Action)(() =>
            {
                Commits.EnableNotifications(true);
                Branches.EnableNotifications(true);

                var tabControl = UIHelper.FindChild <TabControl>(Application.Current.MainWindow, "RepositoryTabs");
                var changesetHistory = UIHelper.FindChild <ChangesetHistory>(tabControl);

                if (changesetHistory != null)
                {
                    changesetHistory.RedrawGraph();
                }
            })
                );

            if (dispose)
            {
                repo.Dispose();
            }
        }