public WorkItemStore(EngineContext context) { _context = context; _clients = _context.Clients; _lazyGetWorkItemCategories = new Lazy <Task <IEnumerable <WorkItemTypeCategory> > >(async() => await GetWorkItemCategories_Internal()); _lazyGetBacklogWorkItemTypesAndStates = new Lazy <Task <IEnumerable <BacklogWorkItemTypeStates> > >(async() => await GetBacklogWorkItemTypesAndStates_Internal()); }
public EngineContext(IClientsContext clients, Guid projectId, string projectName, IAggregatorLogger logger) { Clients = clients; Logger = logger; Tracker = new Tracker(); ProjectId = projectId; ProjectName = projectName; }
/// <summary> /// Constructor /// </summary> /// <param name="configurationDbContext"></param> /// <param name="applicationDbContext"></param> /// <param name="roleManager"></param> /// <param name="logger"></param> /// <param name="permissionService"></param> public ClientsController(IClientsContext configurationDbContext, IPermissionsContext applicationDbContext, RoleManager <GearRole> roleManager, ILogger <ClientsController> logger, IPermissionService permissionService) { _configurationDbContext = configurationDbContext; _applicationDbContext = applicationDbContext; _roleManager = roleManager; _logger = logger; _permissionService = permissionService; }
public RolesController(SignInManager <GearUser> signInManager, ILogger <RolesController> logger, IPermissionService permissionService, IClientsContext configurationDbContext, IIdentityContext applicationDbContext, RoleManager <GearRole> roleManager, IUserManager <GearUser> userManager, INotify <GearRole> notify, IPermissionsContext permissionsContext) { _signInManager = signInManager; _logger = logger; _permissionService = permissionService; ConfigurationDbContext = configurationDbContext; _applicationDbContext = applicationDbContext; _roleManager = roleManager; _userManager = userManager; _notify = notify; _permissionsContext = permissionsContext; }
protected RuleExecutionContext CreateRuleExecutionContext(Guid projectId, WorkItemData workItemPayload, string eventType, IClientsContext clients, IRuleSettings ruleSettings) { var workItem = workItemPayload.WorkItem; var context = new EngineContext(clients, projectId, workItem.GetTeamProject(), logger, ruleSettings); var store = new WorkItemStore(context, workItem); var self = store.GetWorkItem(workItem.Id.Value); var selfChanges = new WorkItemUpdateWrapper(workItemPayload.WorkItemUpdate); logger.WriteInfo($"Initial WorkItem {self.Id} retrieved from {clients.WitClient.BaseAddress}"); var globals = new RuleExecutionContext { self = self, selfChanges = selfChanges, store = store, logger = logger, eventType = eventType }; return(globals); }
public async Task <string> RunAsync(IRule rule, Guid projectId, WorkItemData workItemPayload, string eventType, IClientsContext clients, CancellationToken cancellationToken = default) { var executionContext = CreateRuleExecutionContext(projectId, workItemPayload, eventType, clients, rule.Settings); var result = await ExecuteRuleAsync(rule, executionContext, cancellationToken); return(result); }
public async Task <string> ExecuteAsync(Guid projectId, WorkItemData workItemPayload, IClientsContext clients, CancellationToken cancellationToken) { if (State == EngineState.Error) { return(string.Empty); } var workItem = workItemPayload.WorkItem; var context = new EngineContext(clients, projectId, workItem.GetTeamProject(), logger); var store = new WorkItemStore(context, workItem); var self = store.GetWorkItem(workItem.Id.Value); var selfChanges = new WorkItemUpdateWrapper(workItemPayload.WorkItemUpdate); logger.WriteInfo($"Initial WorkItem {self.Id} retrieved from {clients.WitClient.BaseAddress}"); var globals = new Globals { self = self, selfChanges = selfChanges, store = store, logger = logger }; logger.WriteInfo($"Executing Rule..."); var result = await roslynScript.RunAsync(globals, cancellationToken); if (result.Exception != null) { logger.WriteError($"Rule failed with {result.Exception}"); State = EngineState.Error; } else { logger.WriteInfo($"Rule succeeded with {result.ReturnValue ?? "no return value"}"); State = EngineState.Success; } logger.WriteVerbose($"Post-execution, save any change (mode {saveMode})..."); var saveRes = await store.SaveChanges(saveMode, !DryRun, cancellationToken); if (saveRes.created + saveRes.updated > 0) { logger.WriteInfo($"Changes saved to Azure DevOps (mode {saveMode}): {saveRes.created} created, {saveRes.updated} updated."); } else { logger.WriteInfo($"No changes saved to Azure DevOps."); } return(result.ReturnValue); }
/// <summary> /// Constructor /// </summary> /// <param name="context"></param> public ClientResourcesController(IClientsContext context, IClientsService clientsService) { _context = context; _clientsService = clientsService; }
/// <summary> /// Constructor /// </summary> /// <param name="clientsContext"></param> /// <param name="cacheService"></param> public ClientsService(IClientsContext clientsContext, ICacheService cacheService) { _clientsContext = clientsContext; _cacheService = cacheService; }
public CustomCorsPolicyService(IClientsContext clientsContext) { _clientsContext = clientsContext; }