コード例 #1
0
        public static void IdentifyAndRemoveOldExtractionResults(IRDMPPlatformRepositoryServiceLocator repo, ICheckNotifier checkNotifier, IExtractionConfiguration configuration)
        {
            var oldResults = configuration.CumulativeExtractionResults
                             .Where(cer => !configuration.GetAllExtractableDataSets().Contains(cer.ExtractableDataSet))
                             .ToArray();

            if (oldResults.Any())
            {
                string message = "In Configuration " + configuration + ":" + Environment.NewLine + Environment.NewLine +
                                 "The following CumulativeExtractionResults reflect datasets that were previously extracted under the existing Configuration but are no longer in the CURRENT configuration:";

                message = oldResults.Aggregate(message, (s, n) => s + Environment.NewLine + n);

                if (
                    checkNotifier.OnCheckPerformed(new CheckEventArgs(message, CheckResult.Fail, null,
                                                                      "Delete expired CumulativeExtractionResults for configuration." + Environment.NewLine +
                                                                      "Not doing so may result in failures at Release time.")))
                {
                    foreach (var result in oldResults)
                    {
                        result.DeleteInDatabase();
                    }
                }
            }

            var oldLostSupplemental = configuration.CumulativeExtractionResults
                                      .SelectMany(c => c.SupplementalExtractionResults)
                                      .Union(configuration.SupplementalExtractionResults)
                                      .Where(s => !repo.ArbitraryDatabaseObjectExists(s.ReferencedObjectRepositoryType, s.ReferencedObjectType, s.ReferencedObjectID))
                                      .ToArray();

            if (oldLostSupplemental.Any())
            {
                string message = "In Configuration " + configuration + ":" + Environment.NewLine + Environment.NewLine +
                                 "The following list reflect objects (supporting sql, lookups or documents) " +
                                 "that were previously extracted but have since been deleted:";

                message = oldLostSupplemental.Aggregate(message, (s, n) => s + Environment.NewLine + n.DestinationDescription);

                if (
                    checkNotifier.OnCheckPerformed(new CheckEventArgs(message, CheckResult.Fail, null,
                                                                      "Delete expired Extraction Results for configuration." + Environment.NewLine +
                                                                      "Not doing so may result in failures at Release time.")))
                {
                    foreach (var result in oldLostSupplemental)
                    {
                        result.DeleteInDatabase();
                    }
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Returns true if the object referenced by this class still exists in the database
 /// </summary>
 /// <param name="repositoryLocator"></param>
 /// <returns></returns>
 public bool ReferencedObjectExists(IRDMPPlatformRepositoryServiceLocator repositoryLocator)
 {
     return(repositoryLocator.ArbitraryDatabaseObjectExists(ReferencedObjectRepositoryType, ReferencedObjectType, ReferencedObjectID));
 }