public static bool PostToSiteimproveServer(TreeNode node, PushType pushType) { var pp = new PushParameters(); pp.url = GetFullUrl(node); // if it is a full site recrawl, get the root if (pushType == PushType.recrawl) { pp.url = GetSiteRoot(node.Site); } pp.token = GetAuthToken(node.Site); pp.type = pushType.ToString(); var paramaters = new System.Collections.Specialized.NameValueCollection(); // TODO: Map it automatically paramaters.Add("url", pp.url); paramaters.Add("token", pp.token); paramaters.Add("type", pp.type); // TODO: Error handling var response = CommonUtility.Post(ApiUrl + "/cms-recheck", paramaters); if (response == @"{ ""ordered"": true }") { return(true); } else { throw new Exception("Siteimprove Error: " + response); } }
private static Task PushAsync(Repository repository, PushParameters parameters, IProgress <OperationProgress> progress, CancellationToken cancellationToken) { var notificationsBlock = repository.Monitor.BlockNotifications(RepositoryNotifications.BranchChanged); return(repository.Accessor .Push.InvokeAsync(parameters, progress, cancellationToken) .ContinueWith(task => { notificationsBlock.Dispose(); var res = TaskUtility.UnwrapResult(task); bool changed = false; for (int i = 0; i < res.Count; ++i) { if (res[i].Type != PushResultType.UpToDate && res[i].Type != PushResultType.Rejected) { changed = true; break; } } if (changed) { repository.Refs.Remotes.Refresh(); } }, cancellationToken)); }
public Task <IList <ReferencePushResult> > InvokeAsync(PushParameters parameters, IProgress <OperationProgress> progress, CancellationToken cancellationToken) { Verify.Argument.IsNotNull(parameters, nameof(parameters)); var command = _commandFactory(parameters, true); progress?.Report(new OperationProgress(Resources.StrsConnectingToRemoteHost.AddEllipsis())); var errorMessages = default(List <string>); var stdOutReceiver = new AsyncTextReader(); var stdErrReceiver = new NotifyingAsyncTextReader(); stdErrReceiver.TextLineReceived += (s, e) => { if (!string.IsNullOrWhiteSpace(e.Text)) { var parser = new GitParser(e.Text); var operationProgress = parser.ParseProgress(); progress?.Report(operationProgress); if (operationProgress.IsIndeterminate) { if (errorMessages == null) { errorMessages = new List <string>(); } errorMessages.Add(operationProgress.ActionName); } else { errorMessages?.Clear(); } } }; return(_commandExecutor .ExecuteCommandAsync( command, stdOutReceiver, stdErrReceiver, CommandExecutionFlags.None, cancellationToken) .ContinueWith(task => { int exitCode = TaskUtility.UnwrapResult(task); if (exitCode != 0) { var errorMessage = errorMessages != null && errorMessages.Count != 0 ? string.Join(Environment.NewLine, errorMessages) : string.Format(CultureInfo.InvariantCulture, "git process exited with code {0}", exitCode); throw new GitException(errorMessage); } return _resultsParser(stdOutReceiver.GetText()); }, cancellationToken, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default)); }
public IList <ReferencePushResult> Invoke(PushParameters parameters) { Verify.Argument.IsNotNull(parameters, nameof(parameters)); var command = _commandFactory(parameters, false); var output = _commandExecutor.ExecuteCommand(command, CommandExecutionFlags.None); output.ThrowOnBadReturnCode(); return(_resultsParser(output.Output)); }
private static async Task PushAsync(Repository repository, PushParameters parameters, IProgress <OperationProgress> progress, CancellationToken cancellationToken) { var notificationsBlock = repository.Monitor.BlockNotifications(RepositoryNotifications.BranchChanged); var res = await repository.Accessor .Push .InvokeAsync(parameters, progress, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); notificationsBlock.Dispose(); bool changed = false; for (int i = 0; i < res.Count; ++i) { if (res[i].Type != PushResultType.UpToDate && res[i].Type != PushResultType.Rejected) { changed = true; break; } } if (changed) { repository.Refs.Remotes.Refresh(); } //return repository.Accessor // .Push.InvokeAsync(parameters, progress, cancellationToken) // .ContinueWith(task => // { // notificationsBlock.Dispose(); // var res = TaskUtility.UnwrapResult(task); // bool changed = false; // for(int i = 0; i < res.Count; ++i) // { // if(res[i].Type != PushResultType.UpToDate && res[i].Type != PushResultType.Rejected) // { // changed = true; // break; // } // } // if(changed) // { // repository.Refs.Remotes.Refresh(); // } // }, // cancellationToken); }
public virtual Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Document doc = uidoc.Document; if (!Utils.CheckFamilyDocument(doc)) { return(Result.Cancelled); //The method should only be used inside a FamilyDocument } PushParameters push = new PushParameters(app, uidoc, doc); push.Push(); return(Result.Succeeded); }
private static PushParameters GetPushParameters(string remoteRepository, ICollection <Branch> branches, bool forceOverwrite, bool thinPack, bool sendTags) { var names = new List <string>(branches.Count); foreach (var branch in branches) { names.Add(branch.Name); } var parameters = new PushParameters { Repository = remoteRepository, PushMode = sendTags ? PushMode.Tags : PushMode.Default, Force = forceOverwrite, ThinPack = thinPack, Refspecs = names, }; return(parameters); }
public Command GetPushCommand(PushParameters parameters, bool isAsync) { Assert.IsNotNull(parameters); var args = new List<ICommandArgument>(); switch(parameters.PushMode) { case PushMode.Default: break; case PushMode.AllLocalBranches: args.Add(PushCommand.All()); break; case PushMode.Mirror: args.Add(PushCommand.Mirror()); break; case PushMode.Tags: args.Add(PushCommand.Tags()); break; } if(!string.IsNullOrEmpty(parameters.ReceivePack)) { args.Add(PushCommand.ReceivePack(parameters.ReceivePack)); } if(parameters.Force) { args.Add(PushCommand.Force()); } if(parameters.Delete) { args.Add(PushCommand.Delete()); } if(parameters.SetUpstream) { args.Add(PushCommand.SetUpstream()); } args.Add(parameters.ThinPack ? PushCommand.Thin() : PushCommand.NoThin()); args.Add(PushCommand.Porcelain()); if(isAsync && GitFeatures.ProgressFlag.IsAvailableFor(_gitCLI)) { args.Add(PushCommand.Progress()); } if(!string.IsNullOrWhiteSpace(parameters.Repository)) { args.Add(new CommandParameter(parameters.Repository)); } if(parameters.Refspecs != null && parameters.Refspecs.Count != 0) { foreach(var refspec in parameters.Refspecs) { args.Add(new CommandParameter(refspec)); } } return new PushCommand(args); }
/// <inheritdoc cref="IPushAllApi.SendBroadcastAsync(PushParameters)"/> public async Task <ulong> SendBroadcastAsync(PushParameters parameters) { return(await Execute("broadcast", parameters)); }