public StatusControllerHelper(List <IStatusRepository> statusRepos, string serviceName, IServiceLogRepository log, string logSource) { StatusRepos = statusRepos; ServiceName = serviceName; Log = log; LogSource = logSource; }
internal SessionsController(ITimeoutManager <Guid> sessions, ObjectCache sessionsCache, ISessionsRepository repo, IServiceLogRepository log) { _sessions = sessions; _sessionsCache = sessionsCache; _repo = repo; _log = log; }
public static async Task ProcessMessages(string logSource, TenantInformation tenant, IServiceLogRepository serviceLogRepository, IList <IWorkflowMessage> messages, string exceptionMessagePrepender, IWorkflowMessagingProcessor workflowMessagingProcessor) { if (messages == null || messages.Count <= 0) { return; } var processor = workflowMessagingProcessor ?? WorkflowMessagingProcessor.Instance; foreach (var actionMessage in messages.Where(a => a != null)) { try { await ActionMessageSender.Send((ActionMessage)actionMessage, tenant, processor); string message = $"Sent {actionMessage.ActionType} message: {actionMessage.ToJSON()} with tenant id: {tenant.TenantId} to the Message queue"; await serviceLogRepository.LogInformation(logSource, message); } catch (Exception ex) { string message = $"Error while sending {actionMessage.ActionType} message with content {actionMessage.ToJSON()}. {exceptionMessagePrepender}. Exception: {ex.Message}. StackTrace: {ex.StackTrace ?? string.Empty}"; await serviceLogRepository.LogError(logSource, message); throw; } } }
internal TimeoutManager(ITimer timer, IServiceLogRepository log) { Timer = timer; _log = log; timer.AutoReset = false; Timer.Elapsed += TimerOnElapsed; }
public DataService( IClientRepository client, IOrgRepository org, ICostRepository cost, IDryBoxRepository dryBox, IAccountRepository account, IRoomRepository room, IActiveLogRepository activeLog, IServiceLogRepository serviceLog, IHolidayRepository holiday, IFeedRepository feed, IHelpRepository help, IGlobalSettingRepository globalSetting, IMenuRepository menu, INewsRepository news) { Client = client; Org = org; Cost = cost; DryBox = dryBox; Account = account; Room = room; ActiveLog = activeLog; ServiceLog = serviceLog; Holiday = holiday; Feed = feed; Help = help; GlobalSetting = globalSetting; Menu = menu; News = news; }
public AuthenticationRepository(IUserRepository userRepository, ISqlSettingsRepository settingsRepository, ILdapRepository ldapRepository, ISamlRepository samlRepository, IServiceLogRepository logRepository, IApplicationSettingsRepository applicationSettingsRepository) { _userRepository = userRepository; _settingsRepository = settingsRepository; _ldapRepository = ldapRepository; _samlRepository = samlRepository; _log = logRepository; _applicationSettingsRepository = applicationSettingsRepository; }
internal GroupsController(IGroupRepository groupRepository, IPrivilegesRepository privilegesRepository, IApplicationSettingsRepository applicationSettingsRepository, IServiceLogRepository serviceLogRepository, IItemInfoRepository itemInfoRepository, ISendMessageExecutor sendMessageExecutor, ISqlHelper sqlHelper) { _groupRepository = groupRepository; _privilegesManager = new PrivilegesManager(privilegesRepository); _applicationSettingsRepository = applicationSettingsRepository; _serviceLogRepository = serviceLogRepository; _itemInfoRepository = itemInfoRepository; _sendMessageExecutor = sendMessageExecutor; _sqlHelper = sqlHelper; }
public ArtifactController ( IArtifactRepository instanceRepository, IArtifactPermissionsRepository artifactPermissionsRepository, IPrivilegesRepository privilegesRepository, IServiceLogRepository log) : base(log) { _artifactRepository = instanceRepository; _artifactPermissionsRepository = artifactPermissionsRepository; _privilegesManager = new PrivilegesManager(privilegesRepository); }
public InstanceService( IInstanceRepository instanceRepository, IApplicationSettingsRepository applicationSettingsRepository, IServiceLogRepository serviceLogRepository, ISendMessageExecutor sendMessageExecutor) { _instanceRepository = instanceRepository; _applicationSettingsRepository = applicationSettingsRepository; _sendMessageExecutor = sendMessageExecutor; _serviceLogRepository = serviceLogRepository; }
public InstanceController ( IInstanceRepository instanceRepository, IServiceLogRepository log, IArtifactPermissionsRepository artifactPermissionsRepository, IPrivilegesRepository privilegesRepository, IInstanceService instanceService) : base(log) { _instanceRepository = instanceRepository; _artifactPermissionsRepository = artifactPermissionsRepository; _instanceService = instanceService; _privilegesManager = new PrivilegesManager(privilegesRepository); _privilegesRepository = privilegesRepository; }
internal ConfigController ( IApplicationSettingsRepository applicationSettingsRepository, ISqlSettingsRepository settingsRepository, IUserRepository userRepository, IFeaturesService featuresService, IHttpClientProvider httpClientProvider, IServiceLogRepository log) : base(log) { _applicationSettingsRepository = applicationSettingsRepository; _settingsRepository = settingsRepository; _userRepository = userRepository; _featuresService = featuresService; _httpClientProvider = httpClientProvider; }
/// <summary> /// Retrieve <see cref="IServiceLogRepository"/> based on AppSettings. /// </summary> /// <returns>The <see cref="IServiceLogRepository"/> implementation.</returns> public static IServiceLogRepository ServiceLogRepository() { IServiceLogRepository serviceLogRepository = null; string repositoryType = ConfigurationManager.AppSettings["Repository"].ToString(); switch (repositoryType) { case "SQLite": serviceLogRepository = new ServiceLogRepository(); break; default: throw new ArgumentException("Invalid repository type"); } return(serviceLogRepository); }
internal UsersController ( IAuthenticationRepository authenticationRepository, IUserRepository userRepository, ISqlSettingsRepository settingsRepository, IEmailHelper emailHelper, IApplicationSettingsRepository applicationSettingsRepository, IServiceLogRepository log, IHttpClientProvider httpClientProvider, IPrivilegesRepository privilegesRepository, IItemInfoRepository itemInfoRepository, ISendMessageExecutor sendMessageExecutor, IImageService imageService, ISqlHelper sqlHelper) { _authenticationRepository = authenticationRepository; _userRepository = userRepository; _settingsRepository = settingsRepository; _emailHelper = emailHelper; _applicationSettingsRepository = applicationSettingsRepository; _log = log; _httpClientProvider = httpClientProvider; _privilegesManager = new PrivilegesManager(privilegesRepository); _itemInfoRepository = itemInfoRepository; _sendMessageExecutor = sendMessageExecutor; _imageService = imageService; _sqlHelper = sqlHelper; }
public async Task ProcessMessages(string logSource, IApplicationSettingsRepository applicationSettingsRepository, IServiceLogRepository serviceLogRepository, IList <IWorkflowMessage> messages, string exceptionMessagePrepender, IDbTransaction transaction = null) { var tenantInfo = await applicationSettingsRepository.GetTenantInfo(transaction); if (string.IsNullOrWhiteSpace(tenantInfo?.TenantId)) { throw new TenantInfoNotFoundException("No tenant information found. Please contact your administrator."); } if (messages == null || messages.Count <= 0) { return; } foreach (var actionMessage in messages.Where(a => a != null)) { try { await WorkflowMessagingProcessor.Instance.SendMessageAsync(tenantInfo.TenantId, actionMessage); string message = $"Sent {actionMessage.ActionType} message: {actionMessage.ToJSON()} with tenant id: {tenantInfo.TenantId} to the Message queue"; await serviceLogRepository.LogInformation(logSource, message); } catch (Exception ex) { string message = $"Error while sending {actionMessage.ActionType} message with content {actionMessage.ToJSON()}. {exceptionMessagePrepender}. Exception: {ex.Message}. StackTrace: {ex.StackTrace ?? string.Empty}"; await serviceLogRepository.LogError(logSource, message); throw; } } }
public StateChangeExecutorRepositories(IArtifactVersionsRepository artifactVersionsRepository, IWorkflowRepository workflowRepository, IVersionControlService versionControlService, IReuseRepository reuseRepository, ISaveArtifactRepository saveArtifactRepository, IApplicationSettingsRepository applicationSettingsRepository, IServiceLogRepository serviceLogRepository, IUsersRepository usersRepository, IWebhooksRepository webhooksRepository, IProjectMetaRepository projectMetaRepository) { ArtifactVersionsRepository = artifactVersionsRepository; WorkflowRepository = workflowRepository; VersionControlService = versionControlService; ReuseRepository = reuseRepository; SaveArtifactRepository = saveArtifactRepository; ApplicationSettingsRepository = applicationSettingsRepository; ServiceLogRepository = serviceLogRepository; UsersRepository = usersRepository; WebhooksRepository = webhooksRepository; ProjectMetaRepository = projectMetaRepository; }
public WorkflowController(IWorkflowRepository workflowRepository, IWorkflowService workflowService, IServiceLogRepository log, IPrivilegesRepository privilegesRepository) : base(log) { _workflowService = workflowService; _workflowRepository = workflowRepository; _privilegesManager = new PrivilegesManager(privilegesRepository); }
internal static async Task <bool> ProcessCreatedArtifacts(TenantInformation tenant, ArtifactsPublishedMessage message, IArtifactsPublishedRepository repository, IServiceLogRepository serviceLogRepository, IWorkflowMessagingProcessor messageProcessor, int transactionCommitWaitTimeInMilliSeconds = 60000) { var createdArtifacts = message?.Artifacts?.Where(p => p.IsFirstTimePublished && repository.WorkflowRepository.IsWorkflowSupported((ItemTypePredefined)p.Predefined)).ToList(); if (createdArtifacts == null || createdArtifacts.Count <= 0) { Logger.Log("No created artifacts found", message, tenant); return(false); } Logger.Log($"{createdArtifacts.Count} created artifacts found", message, tenant); var artifactIds = createdArtifacts.Select(a => a.Id).ToHashSet(); var artifactInfos = (await repository.WorkflowRepository.GetWorkflowMessageArtifactInfoAsync(message.UserId, artifactIds, message.RevisionId)).ToDictionary(k => k.Id); Logger.Log($"{artifactInfos.Count} artifact infos found", message, tenant); var notificationMessages = new Dictionary <int, List <IWorkflowMessage> >(); foreach (var createdArtifact in createdArtifacts) { WorkflowMessageArtifactInfo artifactInfo; if (!artifactInfos.TryGetValue(createdArtifact.Id, out artifactInfo)) { await serviceLogRepository.LogInformation(LogSource, $"Could not recover information for artifact Id: {createdArtifact.Id} and Name: {createdArtifact.Name} and Project Id: {createdArtifact.ProjectId}"); Logger.Log($"Could not recover information for artifact Id: {createdArtifact.Id} and Name: {createdArtifact.Name} and Project Id: {createdArtifact.ProjectId}", message, tenant); continue; } var eventTriggers = await repository.WorkflowRepository.GetWorkflowEventTriggersForNewArtifactEvent(message.UserId, new[] { createdArtifact.Id }, message.RevisionId, true); if (eventTriggers?.AsynchronousTriggers == null || eventTriggers.AsynchronousTriggers.Count == 0) { Logger.Log($"Found no async triggers for artifact with ID {createdArtifact.Id}", message, tenant); continue; } Logger.Log($"Found {eventTriggers.AsynchronousTriggers.Count} async triggers for artifact with ID {createdArtifact.Id}", message, tenant); int artifactId = createdArtifact.Id; var currentState = await repository.WorkflowRepository.GetStateForArtifactAsync(message.UserId, createdArtifact.Id, int.MaxValue, true); var actionMessages = await WorkflowEventsMessagesHelper.GenerateMessages(message.UserId, message.RevisionId, message.UserName, message.TransactionId, eventTriggers.AsynchronousTriggers, artifactInfo, artifactInfo.ProjectName, new Dictionary <int, IList <Property> >(), currentState, createdArtifact.Url, createdArtifact.BaseUrl, createdArtifact.AncestorArtifactTypeIds, repository.UsersRepository, serviceLogRepository, repository.WebhooksRepository, repository.ProjectMetaRepository); if (actionMessages == null || actionMessages.Count == 0) { continue; } if (!notificationMessages.ContainsKey(artifactId)) { notificationMessages.Add(artifactId, new List <IWorkflowMessage>()); } notificationMessages[artifactId].AddRange(actionMessages); } if (notificationMessages.Count == 0) { Logger.Log("None of the created artifacts have async triggers", message, tenant); return(false); } Logger.Log($"Sending async trigger messages for artifacts: {string.Join(", ", notificationMessages.Select(kvp => kvp.Key))}", message, tenant); foreach (var notificationMessage in notificationMessages.Where(m => m.Value != null)) { await WorkflowEventsMessagesHelper.ProcessMessages(LogSource, tenant, serviceLogRepository, notificationMessage.Value, $"Error on new artifact creation with Id: {notificationMessage.Key}", messageProcessor); } return(true); }
internal LdapRepository(ISqlSettingsRepository settingsRepository, IServiceLogRepository log, IAuthenticator authenticator = null) { _settingsRepository = settingsRepository; _log = log; _authenticator = authenticator ?? this; }
/// <summary> /// /// </summary> /// <param name="stream"></param> /// <param name="fileChunk"></param> /// <param name="function">Function to be executed</param> /// <param name="log"></param> public PutMultipartReader(Stream stream, FileChunk fileChunk, Func <Stream, FileChunk, Task <long> > function, IServiceLogRepository log) : base(stream, log) { _function = function; _fileChunk = fileChunk; }
public MultipartPartParser(Stream multipartStream, Encoding encoding, IServiceLogRepository log, MemoryStream buffer = null) { this.MultipartStream = multipartStream; this.Encoding = encoding; this._log = log; LocalBuffer = new MemoryStream(); if (buffer != null) { buffer.CopyTo(LocalBuffer); } LocalBuffer.Position = 0; NewLine = Encoding.GetBytes("\r\n"); var DoubleNewLine = Encoding.GetBytes("\r\n\r\n"); // set boundary to empty for now, we dont know what it is until we process our header BoundaryWithNewLinePrepend = new byte[0]; byte[] headerBytes = new byte[1024]; int headerBytesRead = this.Read(headerBytes, 0, headerBytes.Length); int boundaryEnd; if (!SearchBytePattern(NewLine, headerBytes, out boundaryEnd)) { throw new Exception("No multipart boundary found. Data must begin with a content boundary"); } // copy our boundary so we can use it BoundaryWithNewLinePrepend = new byte[boundaryEnd + NewLine.Length]; Buffer.BlockCopy(NewLine, 0, BoundaryWithNewLinePrepend, 0, NewLine.Length); Buffer.BlockCopy(headerBytes, 0, BoundaryWithNewLinePrepend, NewLine.Length, boundaryEnd); // if we have reached the end of our stream at the end of our header then // this is the end of multipart part, we label this as the end part and return // we know we have reached the end when the number bytes we read was our header // plus our search pattern (newline) if (headerBytesRead == boundaryEnd + NewLine.Length) { IsEndPart = true; return; } int headerEnd; if (!SearchBytePattern(DoubleNewLine, headerBytes, boundaryEnd, out headerEnd)) { // if we cant find the end of the header it could mean our header is massive // and it wasnt in the initial block of bytes we read. throw new Exception("Content header is too large to process"); } headerEnd += DoubleNewLine.Length; // get the header and header derived fields Header = encoding.GetString(headerBytes, boundaryEnd, headerEnd - boundaryEnd).Trim(); ContentDisposition = RegexFirstGroup(Header, "^Content-Disposition:(.*)$"); ContentType = RegexFirstGroup(Header, "^Content-Type:(.*)$"); Filename = RegexFirstGroup(ContentDisposition, @"filename=""(.*?)"""); Name = RegexFirstGroup(ContentDisposition, @"name=""(.*?)"""); int CountOfNonHeaderBytes = headerBytesRead - headerEnd; // put back the extra non header content so it can be streamed out again ReinsertIntoLocalBuffer(headerBytes, headerEnd, CountOfNonHeaderBytes); }
internal JobsController(IJobsRepository jobsRepository, IServiceLogRepository serviceLogRepository, IFileRepository fileRepository = null) : base(serviceLogRepository) { _jobsRepository = jobsRepository; _fileRepository = fileRepository; }
internal LicensesController(ILicensesRepository repo, ISessionsRepository sessions, IServiceLogRepository log) { _repo = repo; _sessions = sessions; _log = log; }
public async Task Execute(IApplicationSettingsRepository applicationSettingsRepository, IServiceLogRepository serviceLogRepository, ActionMessage message, IDbTransaction transaction) { var tenantInfo = await applicationSettingsRepository.GetTenantInfo(transaction); var tenantId = tenantInfo?.TenantId; try { if (string.IsNullOrWhiteSpace(tenantId)) { throw new TenantInfoNotFoundException("No tenant information found. Please contact your administrator."); } await WorkflowMessagingProcessor.Instance.SendMessageAsync(tenantId, message); await serviceLogRepository.LogInformation("SendMessageExecutor", $"Sent {message.ActionType} message for tenant {tenantId}: {message.ToJSON()}"); } catch (Exception ex) { await serviceLogRepository.LogError("SendMessageExecutor", $"Failed to send {message.ActionType} message for tenant {tenantId}: {message.ToJSON()}. Exception: {ex.Message}"); throw; } }
internal ItemSearchController(IItemSearchRepository itemSearchRepo, ISearchConfiguration configuration, IServiceLogRepository serviceLogRepository) : base(serviceLogRepository) { _itemSearchRepository = itemSearchRepo; _searchConfigurationProvider = new SearchConfigurationProvider(configuration); _criteriaValidator = new CriteriaValidator(); }
public MultipartPartParser(Stream multipartStream, IServiceLogRepository log) : this(multipartStream, Encoding.UTF8, log) { }
internal static async Task <bool> ProcessUpdatedArtifacts( TenantInformation tenant, ArtifactsPublishedMessage message, IArtifactsPublishedRepository repository, IServiceLogRepository serviceLogRepository, IActionsParser actionsParser, IWorkflowMessagingProcessor messageProcessor) { var allUpdatedArtifacts = message?.Artifacts?.Where(p => !p.IsFirstTimePublished).ToList(); if (allUpdatedArtifacts == null || allUpdatedArtifacts.Count <= 0) { Logger.Log("No updated artifacts found", message, tenant); return(false); } Logger.Log($"{allUpdatedArtifacts.Count} updated artifacts found", message, tenant); var updatedArtifacts = allUpdatedArtifacts.Where(a => a.ModifiedProperties?.Count > 0).ToList(); if (updatedArtifacts.Count == 0) { Logger.Log("No modified properties found for updated artifacts", message, tenant); return(false); } // Get artifacts which have modified properties list populated var allArtifactsModifiedProperties = updatedArtifacts.ToDictionary(k => k.Id, v => v.ModifiedProperties ?? new List <PublishedPropertyInformation>()); Logger.Log( $"{allArtifactsModifiedProperties.Count} artifacts found: {string.Join(", ", allArtifactsModifiedProperties.Select(k => k.Key))}", message, tenant, LogLevel.Debug); if (allArtifactsModifiedProperties.Count == 0) { return(false); } // Get property transitions for published artifact ids. var publishedArtifactIds = updatedArtifacts.Select(a => a.Id).ToHashSet(); var artifactPropertyEvents = await repository.GetWorkflowPropertyTransitionsForArtifactsAsync(message.UserId, message.RevisionId, (int)TransitionType.Property, publishedArtifactIds); // If no property transitions found, then call does not need to proceed Logger.Log($"{artifactPropertyEvents?.Count ?? 0} workflow property events found", message, tenant, LogLevel.Debug); if (artifactPropertyEvents == null || artifactPropertyEvents.Count == 0) { Logger.Log("No property change triggers found", message, tenant); return(false); } // Convert all property transitions to a dictionary with artifact id as key var activePropertyTransitions = new Dictionary <int, IList <SqlWorkflowEvent> >(); var publishedArtifactEvents = artifactPropertyEvents.Where(ape => publishedArtifactIds.Contains(ape.VersionItemId)); // key = artifact id, value = all events foreach (var artifactPropertyEvent in publishedArtifactEvents) { if (activePropertyTransitions.ContainsKey(artifactPropertyEvent.VersionItemId)) { activePropertyTransitions[artifactPropertyEvent.VersionItemId].Add(artifactPropertyEvent); } else { activePropertyTransitions.Add(artifactPropertyEvent.VersionItemId, new List <SqlWorkflowEvent> { artifactPropertyEvent }); } } var sqlWorkflowStates = await repository.GetWorkflowStatesForArtifactsAsync(message.UserId, activePropertyTransitions.Keys, message.RevisionId); var workflowStates = sqlWorkflowStates.Where(w => w.WorkflowStateId > 0).ToDictionary(k => k.ArtifactId); Logger.Log( $"{workflowStates.Count} workflow states found for artifacts: {string.Join(", ", workflowStates.Select(k => k.Key))}", message, tenant, LogLevel.Debug); if (workflowStates.Count == 0) { return(false); } // Get project names var projectIds = updatedArtifacts.Select(a => a.ProjectId).ToList(); var projects = await repository.GetProjectNameByIdsAsync(projectIds); Logger.Log($"{projects.Count} project names found for project IDs: {string.Join(", ", projectIds)}", message, tenant, LogLevel.Debug); var notificationMessages = new Dictionary <int, List <IWorkflowMessage> >(); // For artifacts in active property transitions foreach (var artifactId in activePropertyTransitions.Keys) { Logger.Log($"Processing artifact with ID: {artifactId}", message, tenant, LogLevel.Debug); var artifactTransitionInfo = activePropertyTransitions[artifactId]; var notifications = actionsParser.GetNotificationActions(artifactTransitionInfo).ToList(); Logger.Log($"{notifications.Count} Notification actions found", message, tenant, LogLevel.Debug); if (notifications.Count == 0) { continue; } List <PublishedPropertyInformation> artifactModifiedProperties; if (!allArtifactsModifiedProperties.TryGetValue(artifactId, out artifactModifiedProperties)) { Logger.Log($"modified properties not found for {artifactId}", message, tenant, LogLevel.Debug); continue; } Logger.Log($"{artifactModifiedProperties?.Count ?? 0} modified properties found", message, tenant, LogLevel.Debug); if (artifactModifiedProperties == null || !artifactModifiedProperties.Any()) { continue; } SqlWorkFlowStateInformation currentStateInfo; if (!workflowStates.TryGetValue(artifactId, out currentStateInfo)) { continue; } var modifiedSystemPropertiesSet = artifactModifiedProperties.Where(a => a.PredefinedType == (int)PropertyTypePredefined.Name || a.PredefinedType == (int)PropertyTypePredefined.Description) .Select(a => (PropertyTypePredefined)a.PredefinedType) .ToHashSet(); await ProcessSystemPropertyChange(tenant, message, repository, notifications, modifiedSystemPropertiesSet, currentStateInfo, updatedArtifacts, artifactId, workflowStates, projects, notificationMessages); var modifiedCustomPropertiesSet = artifactModifiedProperties.Where(a => a.PredefinedType == (int)PropertyTypePredefined.CustomGroup) .Select(a => a.TypeId) .ToHashSet(); // Process custom properties Logger.Log( $"{modifiedCustomPropertiesSet.Count} instance property type IDs being located: {string.Join(", ", modifiedCustomPropertiesSet)}", message, tenant, LogLevel.Debug); await ProcessCustomPropertyChange(tenant, message, repository, notifications, modifiedCustomPropertiesSet, currentStateInfo, updatedArtifacts, artifactId, workflowStates, projects, notificationMessages); } if (notificationMessages.Count == 0) { Logger.Log("None of the modified properties have property change notification triggers", message, tenant); return(false); } Logger.Log($"Sending property change notifications for artifacts: {string.Join(", ", notificationMessages.Select(kvp => kvp.Key))}", message, tenant); foreach (var notificationMessage in notificationMessages) { await WorkflowEventsMessagesHelper.ProcessMessages(LogSource, tenant, serviceLogRepository, notificationMessage.Value, $"Error on new artifact creation with Id: {notificationMessage.Key}", messageProcessor); } return(true); }
public static async Task <IList <IWorkflowMessage> > GenerateMessages(int userId, int revisionId, string userName, long transactionId, WorkflowEventTriggers postOpTriggers, IBaseArtifactVersionControlInfo artifactInfo, string projectName, IDictionary <int, IList <Property> > modifiedProperties, WorkflowState currentState, string artifactUrl, string baseUrl, IEnumerable <int> ancestorArtifactTypeIds, IUsersRepository usersRepository, IServiceLogRepository serviceLogRepository, IWebhooksRepository webhooksRepository, IProjectMetaRepository projectMetaRepository) { var resultMessages = new List <IWorkflowMessage>(); var baseHostUri = baseUrl ?? ServerUriHelper.GetBaseHostUri()?.ToString(); foreach (var workflowEventTrigger in postOpTriggers) { if (workflowEventTrigger?.Action == null) { continue; } switch (workflowEventTrigger.ActionType) { case MessageActionType.Notification: var notificationAction = workflowEventTrigger.Action as EmailNotificationAction; if (notificationAction == null) { continue; } var notificationMessage = await GetNotificationMessage(userId, revisionId, transactionId, artifactInfo, projectName, notificationAction, artifactUrl, baseHostUri, usersRepository); if (notificationMessage == null) { await serviceLogRepository.LogInformation(LogSource, $"Skipping Email notification action for artifact {artifactInfo.Id}"); Log.Debug($" Skipping Email notification action for artifact {artifactInfo.Id}. Message: Notification."); continue; } resultMessages.Add(notificationMessage); break; case MessageActionType.GenerateChildren: var generateChildrenAction = workflowEventTrigger.Action as GenerateChildrenAction; if (generateChildrenAction == null) { continue; } var ancestors = new List <int>(ancestorArtifactTypeIds ?? new int[0]); ancestors.Add(artifactInfo.ItemTypeId); var generateChildrenMessage = new GenerateDescendantsMessage { TransactionId = transactionId, ChildCount = generateChildrenAction.ChildCount.GetValueOrDefault(10), DesiredArtifactTypeId = generateChildrenAction.ArtifactTypeId, ArtifactId = artifactInfo.Id, AncestorArtifactTypeIds = ancestors, RevisionId = revisionId, UserId = userId, ProjectId = artifactInfo.ProjectId, UserName = userName, BaseHostUri = baseHostUri, ProjectName = projectName, TypePredefined = (int)artifactInfo.PredefinedType }; resultMessages.Add(generateChildrenMessage); break; case MessageActionType.GenerateTests: var generateTestsAction = workflowEventTrigger.Action as GenerateTestCasesAction; if (generateTestsAction == null || artifactInfo.PredefinedType != ItemTypePredefined.Process) { await serviceLogRepository.LogInformation(LogSource, $"Skipping GenerateTestCasesAction for artifact {artifactInfo.Id} as it is not a process"); Log.Debug($"Skipping GenerateTestCasesAction for artifact {artifactInfo.Id} as it is not a process. Message: Notification."); continue; } var generateTestsMessage = new GenerateTestsMessage { TransactionId = transactionId, ArtifactId = artifactInfo.Id, RevisionId = revisionId, UserId = userId, ProjectId = artifactInfo.ProjectId, UserName = userName, BaseHostUri = baseHostUri, ProjectName = projectName }; resultMessages.Add(generateTestsMessage); break; case MessageActionType.GenerateUserStories: var generateUserStories = workflowEventTrigger.Action as GenerateUserStoriesAction; if (generateUserStories == null || artifactInfo.PredefinedType != ItemTypePredefined.Process) { await serviceLogRepository.LogInformation(LogSource, $"Skipping GenerateUserStories for artifact {artifactInfo.Id} as it is not a process"); Log.Debug($"Skipping GenerateUserStories for artifact {artifactInfo.Id} as it is not a process. Message: Notification."); continue; } var generateUserStoriesMessage = new GenerateUserStoriesMessage { TransactionId = transactionId, ArtifactId = artifactInfo.Id, RevisionId = revisionId, UserId = userId, ProjectId = artifactInfo.ProjectId, UserName = userName, BaseHostUri = baseHostUri, ProjectName = projectName }; resultMessages.Add(generateUserStoriesMessage); break; case MessageActionType.Webhooks: var webhookAction = workflowEventTrigger.Action as WebhookAction; if (webhookAction == null) { continue; } var customTypes = await projectMetaRepository.GetCustomProjectTypesAsync(artifactInfo.ProjectId, userId); var artifactType = customTypes.ArtifactTypes.FirstOrDefault(at => at.Id == artifactInfo.ItemTypeId); var artifactPropertyInfos = await webhooksRepository.GetArtifactsWithPropertyValuesAsync( userId, new List <int> { artifactInfo.Id }, new List <int> { (int)PropertyTypePredefined.Name, (int)PropertyTypePredefined.Description, (int)PropertyTypePredefined.ID, (int)PropertyTypePredefined.CreatedBy, (int)PropertyTypePredefined.LastEditedOn, (int)PropertyTypePredefined.LastEditedBy, (int)PropertyTypePredefined.CreatedOn }, artifactType.CustomPropertyTypeIds); var webhookArtifactInfo = new WebhookArtifactInfo { Id = Guid.NewGuid().ToString(), EventType = WebhookEventType, PublisherId = WebhookPublisherId, Scope = new WebhookArtifactInfoScope { Type = WebhookType, WorkflowId = currentState.WorkflowId }, Resource = new WebhookResource { Name = artifactInfo.Name, ProjectId = artifactInfo.ProjectId, ParentId = ((WorkflowMessageArtifactInfo)artifactInfo).ParentId, ArtifactTypeId = artifactInfo.ItemTypeId, ArtifactTypeName = artifactType?.Name, BaseArtifactType = artifactType?.PredefinedType?.ToString(), ArtifactPropertyInfo = await ConvertToWebhookPropertyInfo(artifactPropertyInfos, customTypes.PropertyTypes, usersRepository), State = new WebhookStateInfo { Id = currentState.Id, Name = currentState.Name, WorkflowId = currentState.WorkflowId }, Revision = revisionId, Version = WebhookArtifactVersion, Id = artifactInfo.Id, BlueprintUrl = string.Format($"{baseHostUri}?ArtifactId={artifactInfo.Id}"), Link = string.Format($"{baseHostUri}api/v1/projects/{artifactInfo.ProjectId}/artifacts/{artifactInfo.Id}") } }; var webhookMessage = await GetWebhookMessage(userId, revisionId, transactionId, webhookAction, webhooksRepository, webhookArtifactInfo); if (webhookMessage == null) { await serviceLogRepository.LogInformation(LogSource, $"Skipping Webhook action for artifact {artifactInfo.Id}: {artifactInfo.Name}."); continue; } resultMessages.Add(webhookMessage); break; } } return(resultMessages); }
internal ProjectSearchController(IProjectSearchRepository projectSearchRepository, IServiceLogRepository serviceLogRepository) : base(serviceLogRepository) { _projectSearchRepository = projectSearchRepository; }
internal CsvLogContent(ILogRepository repository, IServiceLogRepository log) { _repository = repository; _log = log; }
internal SessionsController(IAuthenticationRepository authenticationRepository, IHttpClientProvider httpClientProvider, IServiceLogRepository log) { _authenticationRepository = authenticationRepository; _httpClientProvider = httpClientProvider; _log = log; }