private static async Task ProcessCustomPropertyChange(TenantInformation tenant,
                                                              ArtifactsPublishedMessage message,
                                                              IArtifactsPublishedRepository repository,
                                                              List <EmailNotificationAction> notifications,
                                                              HashSet <int> modifiedCustomPropertiesSet,
                                                              SqlWorkFlowStateInformation currentStateInfo,
                                                              List <PublishedArtifactInformation> updatedArtifacts,
                                                              int artifactId,
                                                              Dictionary <int, SqlWorkFlowStateInformation> workflowStates,
                                                              List <SqlProject> projects,
                                                              Dictionary <int, List <IWorkflowMessage> > notificationMessages)
        {
            if (modifiedCustomPropertiesSet.Count == 0)
            {
                return;
            }
            ////Dictionary<int, List<int>> instancePropertyTypeIds
            var instancePropertyTypeIds = await repository.GetInstancePropertyTypeIdsMap(modifiedCustomPropertiesSet);

            Logger.Log(
                $"{instancePropertyTypeIds.Count} instance property type IDs found: {string.Join(", ", instancePropertyTypeIds.Select(k => k.Key))}",
                message, tenant, LogLevel.Debug);

            foreach (var notificationAction in notifications)
            {
                Logger.Log("Processing notification action", message, tenant, LogLevel.Debug);

                if (!notificationAction.EventPropertyTypeId.HasValue)
                {
                    continue;
                }

                int eventPropertyTypeId = notificationAction.EventPropertyTypeId.Value;
                if (!instancePropertyTypeIds.ContainsKey(eventPropertyTypeId))
                {
                    Logger.Log(
                        $"The property type ID {notificationAction.EventPropertyTypeId} was not found in the dictionary of instance property type IDs.",
                        message, tenant, LogLevel.Debug);
                    continue;
                }

                List <int> propertyTypeIds;
                if (!instancePropertyTypeIds.TryGetValue(eventPropertyTypeId, out propertyTypeIds) || propertyTypeIds.IsEmpty())
                {
                    Logger.Log(
                        $"The property type ID {notificationAction.EventPropertyTypeId} was not found in the dictionary of instance property type IDs.",
                        message, tenant, LogLevel.Debug);
                    continue;
                }

                if (notificationAction.ConditionalStateId.HasValue &&
                    (currentStateInfo == null ||
                     currentStateInfo.WorkflowStateId != notificationAction.ConditionalStateId.Value))
                {
                    // The conditional state id is present, but either the current state info is not present or the current state is not same as conditional state
                    var currentStateId = currentStateInfo?.WorkflowStateId.ToString() ?? "none";
                    Logger.Log(
                        $"Conditional state ID {notificationAction.ConditionalStateId.Value} does not match current state ID: {currentStateId}",
                        message, tenant, LogLevel.Debug);
                    continue;
                }

                var artifact = updatedArtifacts.First(a => a.Id == artifactId);

                string messageHeader =
                    I18NHelper.FormatInvariant("You are being notified because artifact with Id: {0} has been updated.",
                                               artifactId);
                var artifactPartUrl = artifact.Url ?? ServerUriHelper.GetArtifactUrl(artifactId, true);
                var blueprintUrl    = artifact.BaseUrl ?? ServerUriHelper.GetBaseHostUri()?.ToString();
                var emails          = await WorkflowEventsMessagesHelper.GetEmailValues(message.RevisionId, artifactId,
                                                                                        notificationAction, repository.UsersRepository);

                var notificationMessage = new NotificationMessage
                {
                    TransactionId          = message.TransactionId,
                    ArtifactName           = workflowStates[artifactId].Name,
                    ProjectName            = projects.First(p => p.ItemId == artifact.ProjectId).Name,
                    Subject                = notificationAction.Subject,
                    From                   = notificationAction.FromDisplayName,
                    To                     = emails,
                    Header                 = messageHeader,
                    Message                = notificationAction.Message,
                    RevisionId             = message.RevisionId,
                    UserId                 = message.UserId,
                    ArtifactTypeId         = currentStateInfo.ItemTypeId,
                    ArtifactId             = artifactId,
                    ArtifactUrl            = artifactPartUrl,
                    ArtifactTypePredefined = artifact.Predefined,
                    ProjectId              = artifact.ProjectId,
                    BlueprintUrl           = blueprintUrl
                };

                if (notificationMessages.ContainsKey(artifactId))
                {
                    notificationMessages[artifactId].Add(notificationMessage);
                }
                else
                {
                    notificationMessages.Add(artifactId,
                                             new List <IWorkflowMessage>
                    {
                        notificationMessage
                    });
                }
            }
        }
        private static async Task ProcessSystemPropertyChange(TenantInformation tenant,
                                                              ArtifactsPublishedMessage message,
                                                              IArtifactsPublishedRepository repository,
                                                              List <EmailNotificationAction> notifications,
                                                              HashSet <PropertyTypePredefined> modifiedSystemPropertiesSet,
                                                              SqlWorkFlowStateInformation currentStateInfo,
                                                              List <PublishedArtifactInformation> updatedArtifacts,
                                                              int artifactId,
                                                              Dictionary <int, SqlWorkFlowStateInformation> workflowStates,
                                                              List <SqlProject> projects,
                                                              Dictionary <int, List <IWorkflowMessage> > notificationMessages)
        {
            if (modifiedSystemPropertiesSet.Count == 0)
            {
                return;
            }

            foreach (var notificationAction in notifications)
            {
                Logger.Log("Processing notification action", message, tenant, LogLevel.Debug);

                if (!notificationAction.EventPropertyTypeId.HasValue)
                {
                    continue;
                }

                int eventPropertyTypeId = notificationAction.EventPropertyTypeId.Value;

                // If system property provided is neither name or description
                if (eventPropertyTypeId != WorkflowConstants.PropertyTypeFakeIdName &&
                    eventPropertyTypeId != WorkflowConstants.PropertyTypeFakeIdDescription)
                {
                    Logger.Log(
                        $"The system property type ID {notificationAction.EventPropertyTypeId} is not supported. Only Name and Description are supported.",
                        message, tenant, LogLevel.Debug);
                    continue;
                }

                // If modified properties does not conatin event property type Id
                if (!modifiedSystemPropertiesSet.Contains(GetPropertyTypePredefined(notificationAction.EventPropertyTypeId.Value)))
                {
                    continue;
                }

                if (notificationAction.ConditionalStateId.HasValue &&
                    (currentStateInfo == null ||
                     currentStateInfo.WorkflowStateId != notificationAction.ConditionalStateId.Value))
                {
                    // The conditional state id is present, but either the current state info is not present or the current state is not same as conditional state
                    var currentStateId = currentStateInfo?.WorkflowStateId.ToString() ?? "none";
                    Logger.Log(
                        $"Conditional state ID {notificationAction.ConditionalStateId.Value} does not match current state ID: {currentStateId}",
                        message, tenant, LogLevel.Debug);
                    continue;
                }

                var artifact = updatedArtifacts.First(a => a.Id == artifactId);

                string messageHeader =
                    I18NHelper.FormatInvariant("You are being notified because artifact with Id: {0} has been updated.",
                                               artifactId);
                var artifactPartUrl = artifact.Url ?? ServerUriHelper.GetArtifactUrl(artifactId, true);
                var blueprintUrl    = artifact.BaseUrl ?? ServerUriHelper.GetBaseHostUri()?.ToString();
                var emails          = await WorkflowEventsMessagesHelper.GetEmailValues(message.RevisionId, artifactId,
                                                                                        notificationAction, repository.UsersRepository);

                var notificationMessage = new NotificationMessage
                {
                    TransactionId          = message.TransactionId,
                    ArtifactName           = workflowStates[artifactId].Name,
                    ProjectName            = projects.First(p => p.ItemId == artifact.ProjectId).Name,
                    Subject                = notificationAction.Subject,
                    From                   = notificationAction.FromDisplayName,
                    To                     = emails,
                    Header                 = messageHeader,
                    Message                = notificationAction.Message,
                    RevisionId             = message.RevisionId,
                    UserId                 = message.UserId,
                    ArtifactTypeId         = currentStateInfo.ItemTypeId,
                    ArtifactId             = artifactId,
                    ArtifactUrl            = artifactPartUrl,
                    ArtifactTypePredefined = artifact.Predefined,
                    ProjectId              = artifact.ProjectId,
                    BlueprintUrl           = blueprintUrl
                };

                if (notificationMessages.ContainsKey(artifactId))
                {
                    notificationMessages[artifactId].Add(notificationMessage);
                }
                else
                {
                    notificationMessages.Add(artifactId,
                                             new List <IWorkflowMessage>
                    {
                        notificationMessage
                    });
                }
            }
        }