internal static void NotifyTaskStatus( IRestApi restApi, string owner, string message, List <MultilinerBotConfiguration.Notifier> notifiers) { if (notifiers == null || notifiers.Count == 0) { return; } foreach (MultilinerBotConfiguration.Notifier notifier in notifiers) { try { List <string> recipients = GetNotificationRecipients( restApi, owner, notifier); MultilinerMergebotApi.Notify.Message( restApi, notifier.Plug, message, recipients); } catch (Exception e) { mLog.ErrorFormat("Error notifying task status message '{0}', notifier '{1}': {2}", message, notifier.Name, e.Message); mLog.DebugFormat("StackTrace:{0}{1}", Environment.NewLine, e.StackTrace); } } }
public Manager(IReplayStorage storage, IRestApi restApi) { _storage = storage; _restApi = restApi; Files.ItemPropertyChanged += (_, __) => { OnStatusChanged(); }; Files.CollectionChanged += (_, __) => { OnStatusChanged(); }; }
public RestApiViewModel(IRestApi model) { Model = model; BodyProperties.CollectionChanged += BodyProperties_CollectionChanged; BodyProperties.PropertyChanged += BodyProperties_PropertyChanged; }
public static RestApiViewModel Create(IRestApi api) { switch (api.GetType().Name) { case "UserApi": return(new UserApiViewModel(api)); case "ItemApi": return(new ItemApiViewModel(api)); case "WorkbookApi": return(new WorkbookApiViewModel(api)); case "WorksheetApi": return(new WorksheetApiViewModel(api)); case "RangeApi": return(new RangeApiViewModel(api)); case "TableApi": return(new TableApiViewModel(api)); case "ChartApi": return(new ChartApiViewModel(api)); case "NamedItemApi": return(new NamedItemApiViewModel(api)); default: throw new ArgumentOutOfRangeException($"{api.GetType().Name} is not a valid API type"); } }
public PaymentAuthRateTicker(IHubContext <PaymentAuthRateHub> clients, IRestApi restApi) { Clients = clients; RestApi = restApi; _timer = new Timer(UpdateStockPrices, null, _updateInterval, _updateInterval); }
internal static string GetBranchAttribute( IRestApi restApi, string repoName, string branchName, string attributeName) { return(restApi.GetAttribute(repoName, attributeName, AttributeTargetType.Branch, branchName).Value); }
public ArQueueSizeTicker(IHubContext <ArQueueSizeHub> clients, IRestApi restApi) { Clients = clients; RestApi = restApi; _timer = new Timer(UpdateStockPrices, null, _updateInterval, _updateInterval); }
static void ReportMerge( IRestApi restApi, string repository, string branchName, string botName, MergeReport mergeReport) { if (mergeReport == null) { return; } try { MultilinerMergebotApi.MergeReports.ReportMerge(restApi, botName, mergeReport); } catch (Exception ex) { mLog.ErrorFormat( "Unable to report merge for branch '{0}' on repository '{1}': {2}", branchName, repository, ex.Message); mLog.DebugFormat( "StackTrace:{0}{1}", Environment.NewLine, ex.StackTrace); } }
static BuildProperties CreateBuildProperties( IRestApi restApi, string taskNumber, string branchName, string labelName, string buildStagePreCiOrPostCi, string destinationBranch, MultilinerBotConfiguration botConfig) { int branchHeadChangesetId = MultilinerMergebotApi.GetBranchHead( restApi, botConfig.Repository, branchName); ChangesetModel branchHeadChangeset = MultilinerMergebotApi.GetChangeset( restApi, botConfig.Repository, branchHeadChangesetId); int trunkHeadChangesetId = MultilinerMergebotApi.GetBranchHead( restApi, botConfig.Repository, destinationBranch); ChangesetModel trunkHeadChangeset = MultilinerMergebotApi.GetChangeset( restApi, botConfig.Repository, trunkHeadChangesetId); return(new BuildProperties { BranchName = branchName, TaskNumber = taskNumber, BranchHead = branchHeadChangeset.ChangesetId.ToString(), BranchHeadGuid = branchHeadChangeset.Guid.ToString(), ChangesetOwner = branchHeadChangeset.Owner, TrunkBranchName = destinationBranch, TrunkHead = trunkHeadChangeset.ChangesetId.ToString(), TrunkHeadGuid = trunkHeadChangeset.Guid.ToString(), RepSpec = string.Format("{0}@{1}", botConfig.Repository, botConfig.Server), LabelName = labelName, Stage = buildStagePreCiOrPostCi }); }
internal static List <string> ResolveFieldForUsers( IRestApi restApi, List <string> users, string profileFieldQualifiedName) { IEnumerable <string> uniqueUsers = users.Distinct(); if (string.IsNullOrEmpty(profileFieldQualifiedName)) { return(uniqueUsers.ToList()); } string[] profileFieldsPath = profileFieldQualifiedName.Split( new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); return(uniqueUsers.Select(user => { string solvedUser; if (!TryResolveUserProfileValue( restApi, user, profileFieldsPath, out solvedUser)) { return user; } return solvedUser; }).Distinct().ToList()); }
static bool GetIssueInfo( IRestApi restApi, string taskNumber, MultilinerBotConfiguration.IssueTracker issuesConfig, out string taskTittle, out string taskUrl) { taskTittle = null; taskUrl = null; if (issuesConfig == null) { return(false); } mLog.InfoFormat("Obtaining task {0} title...", taskNumber); taskTittle = MultilinerMergebotApi.Issues.GetIssueField( restApi, issuesConfig.Plug, issuesConfig.ProjectKey, taskNumber, issuesConfig.TitleField); mLog.InfoFormat("Obtaining task {0} URL...", taskNumber); taskUrl = MultilinerMergebotApi.Issues.GetIssueUrl( restApi, issuesConfig.Plug, issuesConfig.ProjectKey, taskNumber); return(true); }
static bool HasToTriggerTryMerge( IRestApi restApi, string taskNumber, BotConfiguration.IssueTracker issueTrackerConfig) { if (issueTrackerConfig == null) //no issue tracker config -> just check the branch status attr { return(true); } mLog.InfoFormat("Checking if issue tracker [{0}] is available...", issueTrackerConfig.PlugName); if (!restApi.IsIssueTrackerConnected(issueTrackerConfig.PlugName)) { mLog.WarnFormat("Issue tracker [{0}] is NOT available...", issueTrackerConfig.PlugName); return(false); } mLog.InfoFormat("Checking if task {0} is ready in the issue tracker [{1}].", taskNumber, issueTrackerConfig.PlugName); string status = restApi.GetIssueTrackerField( issueTrackerConfig.PlugName, issueTrackerConfig.ProjectKey, taskNumber, issueTrackerConfig.StatusField.Name); mLog.DebugFormat("Issue tracker status for task [{0}]: expected [{1}], was [{2}]", taskNumber, issueTrackerConfig.StatusField.ResolvedValue, status); return(status.ToLowerInvariant().Trim().Equals( issueTrackerConfig.StatusField.ResolvedValue.ToLowerInvariant().Trim())); }
internal static void NotifyMerge( IRestApi restApi, string mergeBotName, string repository, string branchFullName, bool bHasManualMergeConflicts, string mergeMessage) { string repId; int branchId; bool bSuccessful = restApi.GetBranchIdData(repository, branchFullName, out repId, out branchId); if (!bSuccessful) { return; } MergeReport report = new MergeReport(); report.Timestamp = DateTime.UtcNow; report.RepositoryId = repId; report.BranchId = branchId; report.Properties = new List <MergeReport.Entry>(); MergeReport.Entry mergeProperty = new MergeReport.Entry(); mergeProperty.Type = bHasManualMergeConflicts ? "merge_failed" : "merge_ok"; mergeProperty.Value = mergeMessage; report.Properties.Add(mergeProperty); restApi.SendMergeReport(mergeBotName, report); }
internal static List <string> ResolveUserField( IRestApi restApi, List <string> users, string profileFieldQualifiedName) { string[] profileFieldsPath = profileFieldQualifiedName.Split( new char[] { '.' }, System.StringSplitOptions.RemoveEmptyEntries); List <string> result = new List <string>(); foreach (string user in users) { JObject profile = restApi.GetUserProfile(user); if (profile == null || !profile.HasValues) { result.Add(user); continue; } string solvedUser = GetFieldFromProfile(profile, profileFieldsPath); if (string.IsNullOrEmpty(solvedUser)) { continue; } result.Add(solvedUser); } return(result); }
public Bot(IConfigurationRoot configuration, IHostingEnvironment env) { _configuration = configuration; _env = env; _restApi = new RestApi(configuration, env, this); //configFilePath = string.Format("{0}\\botSetting.json", _env.WebRootPath); configFilePath = Path.Combine(_env.WebRootPath, "botSetting.json"); }
public WebFileUpdaterViewModel(IRestApi restApi, IToastService toastSevice) { _restApi = restApi; _toastService = toastSevice; _localDir = Const.LOCAL_WEB_FILE_DIR; _remoteUrl = "get/filelist"; _visibility = Visibility.Hidden; }
internal static bool Connected( IRestApi restApi, string issueTrackerName) { SingleResponse response = restApi.Issues.IsConnected(issueTrackerName); return(GetBoolValue(response.Value, false)); }
public Repository(IScheduler uiThreadScheduler, ISimpleDb simpleDb, IRestApi restApi, IEntityFactory entityFactory, IValueFactory valueFactory) { this.uiThreadScheduler = uiThreadScheduler; this.simpleDb = simpleDb; this.restApi = restApi; this.entityFactory = entityFactory; this.valueFactory = valueFactory; }
public async Task <IActionResult> GetLondonPeople( IRestApi innerApi, ILogger log) { try { //RestApi innerApi = new RestApi(BASE_URL); var allTask = innerApi.GetEndPointAsync(ALL_USERS_ENDPOINT); var ctyTask = innerApi.GetEndPointAsync(CTY_USERS_ENDPOINT); JArray cityUsers = new JArray(); JToken[] ldnUsers = new JToken[0]; var allTasks = new List <Task> { allTask, ctyTask }; while (allTasks.Any()) { Task finished = await Task.WhenAny(allTasks); if (finished == allTask) { if (finished.IsCompletedSuccessfully) { // Filter users on location var users = JArray.Parse(allTask.Result); var london = new Locale(LONDON_LAT, LONDON_LONG, DISTANCE_FROM_CENTER); ldnUsers = users.Where(u => london.IsLocationInLocale((double)u["latitude"], (double)u["longitude"])).ToArray(); } else { return(new ObjectResult(new ObjectResult(new { statusCode = System.Convert.ToInt32(allTask.Result), message = "Http Error" }))); } } else if (finished == ctyTask) { if (finished.IsCompletedSuccessfully) { cityUsers = JArray.Parse(ctyTask.Result); } else { return(new ObjectResult(new ObjectResult(new { statusCode = System.Convert.ToInt32(ctyTask.Result), message = "Http Error" }))); } } allTasks.Remove(finished); } var res = ldnUsers.Concat(cityUsers); // Remove Duplicates res = res.GroupBy(j => j["id"]).Select(g => g.First()); return(new OkObjectResult(JsonConvert.SerializeObject(res))); } catch (Exception ex) { return(new ExceptionResult(ex, true)); } }
internal static string GetIssueField( IRestApi restApi, string issueTrackerName, string projectKey, string taskNumber, string fieldName) { return(restApi.Issues.GetIssueField(issueTrackerName, projectKey, taskNumber, fieldName).Value); }
internal static string GetIssueUrl( IRestApi restApi, string issueTrackerName, string projectKey, string taskNumber) { return(restApi.Issues.GetIssueUrl(issueTrackerName, projectKey, taskNumber).Value); }
public GalleryViewModel(INavigation navigation) { _navigation = navigation; _restApi = App.RestApiService; EventsGallery = new ObservableCollection <Event>(); GetEventsGalleryAsync(); }
internal static JArray Find( IRestApi restApi, string repName, string query, string queryDateFormat, string actionDescription, string[] fields) { return(restApi.Find(repName, query, queryDateFormat, actionDescription, fields)); }
internal static ShelveResult TryMergeToShelves( IRestApi restApi, Branch branch, string[] destinationBranches, MergeReport mergeReport, string taskTitle, string botName) { ShelveResult result = new ShelveResult(); foreach (string destinationBranch in destinationBranches) { MergeToResponse mergeToResult = MultilinerMergebotApi.MergeBranchTo( restApi, branch.Repository, branch.FullName, destinationBranch, GetComment(branch.FullName, destinationBranch, taskTitle, botName), MultilinerMergebotApi.MergeToOptions.CreateShelve); result.MergeStatusByTargetBranch[destinationBranch] = mergeToResult.Status; if (mergeToResult.Status == MergeToResultStatus.MergeNotNeeded) { string warningMessage = string.Format( "Branch [{0}] was already merged to [{1}] (No merge needed).", branch.FullName, destinationBranch); result.MergesNotNeededMessages.Add(warningMessage); continue; } if (IsFailedMergeTo(mergeToResult)) { string errorMsg = string.Format( "Can't merge branch [{0}] to [{1}]. Reason: {2}.", branch.FullName, destinationBranch, mergeToResult.Message); result.ErrorMessages.Add(errorMsg); BuildMergeReport.AddFailedMergeProperty( mergeReport, mergeToResult.Status, mergeToResult.Message); continue; } result.ShelvesByTargetBranch[destinationBranch] = mergeToResult.ChangesetNumber; BuildMergeReport.AddSucceededMergeProperty(mergeReport, mergeToResult.Status); } return(result); }
static string[] GetMergeToDestinationBranches( IRestApi restApi, Branch branch, string mergeToBranchesAttrName) { string rawAttrValue = string.Empty; try { rawAttrValue = MultilinerMergebotApi.GetBranchAttribute( restApi, branch.Repository, branch.FullName, mergeToBranchesAttrName); } catch (Exception e) { mLog.WarnFormat( "Unable to retrieve attribute [{0}] value from branch [{1}]. Error: {2}", mergeToBranchesAttrName, branch.FullName, e.Message); return(new string[] { }); } if (string.IsNullOrWhiteSpace(rawAttrValue)) { return new string[] { } } ; List <string> destinationBranchesList = new List <string>(); string[] rawSplittedDestinationBranches = rawAttrValue.Split( new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); string cleanDstBranchName; foreach (string rawSplittedDestinationBranch in rawSplittedDestinationBranches) { cleanDstBranchName = rawSplittedDestinationBranch.Trim(); if (string.IsNullOrWhiteSpace(cleanDstBranchName)) { continue; } if (destinationBranchesList.Contains(cleanDstBranchName)) { continue; } destinationBranchesList.Add(cleanDstBranchName); } return(destinationBranchesList.ToArray()); }
internal static MergeToResponse MergeBranchTo( IRestApi restApi, string repoName, string sourceBranch, string destinationBranch, string comment, MergeToOptions options) { return(MergeTo( restApi, repoName, sourceBranch, MergeToSourceType.Branch, destinationBranch, comment, options)); }
internal static MergeToResponse MergeShelveTo( IRestApi restApi, string repoName, int shelveId, string destinationBranch, string comment, MergeToOptions options) { return(MergeTo( restApi, repoName, shelveId.ToString(), MergeToSourceType.Shelve, destinationBranch, comment, options)); }
internal static bool IsMergeAllowed( IRestApi restApi, string repoName, string sourceBranchName, string destinationBranchName) { MergeToAllowedResponse response = restApi.IsMergeAllowed( repoName, sourceBranchName, destinationBranchName); return (response.Result.Trim().Equals("ok", StringComparison.InvariantCultureIgnoreCase)); }
internal static void Create( IRestApi restApi, string repoName, string labelName, int csetId, string comment) { CreateLabelRequest request = new CreateLabelRequest() { Name = labelName, Changeset = csetId, Comment = comment }; restApi.Labels.Create(repoName, request); }
public void DeleteShelve(IRestApi restApi, string repository, int shelveId) { Uri endpoint = ApiUris.GetFullUri( mBaseUri, ApiEndpoints.DeleteShelve, repository, shelveId.ToString()); string actionDescription = string.Format( "delete shelve sh:{0}@{1}", shelveId, repository); Internal.MakeApiRequest <SingleResponse>( endpoint, HttpMethod.Delete, actionDescription, mPlasticBotUserToken); }
internal AuthApi(IRestApi restApi) { RestApi = restApi; }
/// <summary> /// Instantiates a <see cref="TrackApi"/> /// </summary> public TrackApi(IRestApi restApi) { RestApi = restApi; }
public SequenceProvider(IRestApi graphDb) { _graphDb = graphDb; }