/// <summary>
        /// Create an <see cref="IEnumerable{T}"/> of type <see cref="ModelLogEntryData"/> for a specific <see cref="EngineeringModel"/>
        /// base on a list of filtered <see cref="ModelLogEntry"/>s
        /// </summary>
        /// <param name="transaction">
        /// The current <see cref="NpgsqlTransaction"/> to the database.
        /// </param>
        /// <param name="engineeringModelPartition">
        /// The partition in the database
        /// </param>
        /// <param name="container">
        /// The <see cref="IContainer"/> used to resolve injectable objects
        /// </param>
        /// <param name="modelLogEntries">
        /// The <see cref="ModelLogEntry"/>s
        /// </param>
        /// <param name="domains">
        /// The <see cref="DomainOfExpertise.Iid"/>s used to filter <see cref="LogEntryChangelogItem"/>s to be used.
        /// </param>
        /// <param name="changeNotificationSubscriptionUserPreference">
        /// The <see cref="ChangeNotificationSubscriptionUserPreference"/> that contains the change notification subscriptions
        /// </param>
        /// <returns>
        /// The created <see cref="IEnumerable{T}"/> of type <see cref="ModelLogEntryData"/>
        /// </returns>
        public IEnumerable <ModelLogEntryData> Create(
            NpgsqlTransaction transaction,
            string engineeringModelPartition,
            IContainer container,
            IEnumerable <ModelLogEntry> modelLogEntries,
            IEnumerable <Guid> domains,
            ChangeNotificationSubscriptionUserPreference changeNotificationSubscriptionUserPreference)
        {
            var modelLogEntryDataList = new List <ModelLogEntryData>();

            var domainOfExpertiseDao     = container.Resolve <IDomainOfExpertiseDao>();
            var logEntryChangeLogItemDao = container.Resolve <ILogEntryChangelogItemDao>();

            var domainOfExpertises = domainOfExpertiseDao.Read(transaction, "SiteDirectory", domains).ToList();

            foreach (var changeNotificationSubscription in changeNotificationSubscriptionUserPreference.ChangeNotificationSubscriptions)
            {
                var changeNotificationFilter = this.CreateChangeLogNotificationFilter(changeNotificationSubscription, domainOfExpertises);

                foreach (var modelLogEntry in modelLogEntries.OrderBy(x => x.CreatedOn))
                {
                    if (changeNotificationFilter.CheckFilter(modelLogEntry))
                    {
                        var modelLogEntryData    = new ModelLogEntryData(modelLogEntry);
                        var addModelLogEntryData = false;

                        var logEntryChangeLogItems =
                            logEntryChangeLogItemDao.Read(transaction, engineeringModelPartition, modelLogEntry.LogEntryChangelogItem).ToList();

                        foreach (var logEntryChangelogItem in logEntryChangeLogItems)
                        {
                            if (changeNotificationFilter.CheckFilter(logEntryChangelogItem))
                            {
                                addModelLogEntryData = true;
                                modelLogEntryData.TryAddLogEntryChangelogData(logEntryChangelogItem, changeNotificationSubscription);
                            }
                        }

                        if (addModelLogEntryData)
                        {
                            modelLogEntryDataList.Add(modelLogEntryData);
                        }
                    }
                }
            }

            return(modelLogEntryDataList);
        }
Esempio n. 2
0
 /// <summary>
 /// Creates a new instance of <see cref="LogEntryChangelogItemData"/>
 /// </summary>
 /// <param name="logEntryChangelogItem">
 /// The <see cref="CDP4Common.DTO.LogEntryChangelogItem"/>
 /// </param>
 /// <param name="modelLogEntryData">
 /// The <see cref="Data.ModelLogEntryData"/>
 /// </param>
 public LogEntryChangelogItemData(LogEntryChangelogItem logEntryChangelogItem, ModelLogEntryData modelLogEntryData)
 {
     this.ModelLogEntryData     = modelLogEntryData;
     this.LogEntryChangelogItem = logEntryChangelogItem;
 }