public IEnumerable <ClearanceCode> GetAll()
 {
     lock (_session)
     {
         return(_session.GetAll <ClearanceCode>());
     }
 }
Exemple #2
0
        public void Apply()
        {
            foreach (string tenantConnectionString in _tenantConnectionStrings)
            {
                using (IDocumentStore documentStore = DocumentStoreFactory.CreateStore(tenantConnectionString))
                    using (IDocumentSession session = documentStore.OpenSession())
                    {
                        var awsconfigs      = session.GetAll <AWSInstanceConfiguration>();
                        var autobookconfigs = session.GetAll <AutoBookInstanceConfiguration>();

                        foreach (AutoBookInstanceConfiguration abic in autobookconfigs)
                        {
                            var aws = awsconfigs.Find(x => x.Id == abic.Id);
                            if (aws != null)
                            {
                                abic.InstanceType  = aws.InstanceType;
                                abic.StorageSizeGb = aws.StorageSizeGb;
                                abic.Cost          = aws.Cost;
                            }
                        }

                        awsconfigs.ForEach(aws => session.Delete(aws));

                        session.SaveChanges();
                    }
            }
        }
 public IEnumerable <Restriction> GetAll()
 {
     lock (_session)
     {
         return(_session.GetAll <Restriction>().ToList());
     }
 }
Exemple #4
0
 public IEnumerable <PipelineAuditEvent> GetAll()
 {
     lock (_session)
     {
         return(_session.GetAll <PipelineAuditEvent>());
     }
 }
Exemple #5
0
 public IEnumerable <AutoBookTaskReport> GetAll()
 {
     lock (_session)
     {
         return(_session.GetAll <AutoBookTaskReport>());
     }
 }
Exemple #6
0
        public IEnumerable <Demographic> GetByExternalRef(List <string> externalRefs)
        {
            var items = _session.GetAll <Demographic>(d => d.ExternalRef.In(externalRefs),
                                                      indexName: Demographic_BySearch.DefaultIndexName, isMapReduce: false);

            return(items.ToList());
        }
 public IEnumerable <Recommendation> GetByScenarioId(Guid scenarioId)
 {
     lock (_session)
     {
         var recommendations = _session.GetAll <Recommendation>(recommendation => recommendation.ScenarioId == scenarioId,
                                                                indexName: Recommendations_Default.DefaultIndexName, isMapReduce: false).ToList();
         return(recommendations);
     }
 }
Exemple #8
0
 public void DeleteRange(IEnumerable <int> ids)
 {
     lock (_session)
     {
         var rules = _session.GetAll <RatingsPredictionSchedule>(s => s.Id.In(ids.ToList()));
         foreach (var rule in rules)
         {
             _session.Delete(rule);
         }
     }
 }
Exemple #9
0
 public void Delete(IEnumerable <int> ids)
 {
     lock (_session)
     {
         var rules = _session.GetAll <AutopilotRule>(s => s.Id.In(ids.ToList()));
         foreach (var rule in rules)
         {
             _session.Delete(rule);
         }
     }
 }
 public void DeleteRangeByGroupId(IEnumerable <int> ids)
 {
     lock (_session)
     {
         var bookingPositionGroups = _session.GetAll <BookingPositionGroup>(s => s.Id.In(ids.ToList()));
         foreach (var positionGroup in bookingPositionGroups)
         {
             _session.Delete(positionGroup);
         }
     }
 }
Exemple #11
0
        public void DeleteBySalesAreaName(string name)
        {
            lock (_session)
            {
                var salesAreaDemographics = _session.GetAll <SalesAreaDemographic>(x => x.SalesArea == name);

                foreach (var salesAreaDemographic in salesAreaDemographics)
                {
                    _session.Delete <SalesAreaDemographic>(salesAreaDemographic.Id);
                }
            }
        }
Exemple #12
0
        public void Apply()
        {
            foreach (string tenantConnectionString in _tenantConnectionStrings)
            {
                using (IDocumentStore documentStore = DocumentStoreFactory.CreateStore(tenantConnectionString))
                    using (IDocumentSession session = documentStore.OpenSession())
                    {
                        var programmeRuleId     = (int)ToleranceRuleId.Programme;
                        var programmeRuleTypeId = (int)RuleCategory.Tolerances;
                        var rules = session.GetAll <Rule>();

                        if (!rules.Any(r => r.RuleId == programmeRuleId))
                        {
                            session.Store(
                                new Rule
                            {
                                RuleTypeId   = programmeRuleTypeId,
                                RuleId       = programmeRuleId,
                                Description  = "Programme",
                                InternalType = "Campaign",
                                Type         = "tolerances"
                            });

                            session.SaveChanges();
                        }

                        var isAllowedAutopilot = session.GetAll <RuleType>()
                                                 .Any(rt => rt.AllowedForAutopilot && rt.Id == programmeRuleTypeId);

                        var hasProgrammeAutopilotRule = session.GetAll <AutopilotRule>()
                                                        .Any(rt => rt.RuleId == programmeRuleId);

                        if (isAllowedAutopilot && !hasProgrammeAutopilotRule)
                        {
                            var newAutopilotRules = new List <AutopilotRule>();
                            newAutopilotRules.Add(AutopilotRule.Create((int)AutopilotFlexibilityLevel.Low, programmeRuleId, programmeRuleTypeId, 5, 5, 10, 10));
                            newAutopilotRules.Add(AutopilotRule.Create((int)AutopilotFlexibilityLevel.Medium, programmeRuleId, programmeRuleTypeId, 10, 10, 20, 20));
                            newAutopilotRules.Add(AutopilotRule.Create((int)AutopilotFlexibilityLevel.High, programmeRuleId, programmeRuleTypeId, 15, 15, 30, 30));
                            newAutopilotRules.Add(AutopilotRule.Create((int)AutopilotFlexibilityLevel.Extreme, programmeRuleId, programmeRuleTypeId, 20, 20, 40, 40));

                            foreach (var autopilotRule in newAutopilotRules)
                            {
                                session.Store(autopilotRule);
                            }

                            session.SaveChanges();
                        }
                    }
            }
        }
Exemple #13
0
        ///<summary>Find all scenarios with the given ids.</summary>
        /// <remarks>RavenDB will throw an exception (Lucene.Net.Search.BooleanQuery.TooManyClauses)
        /// if more than 1,024 items are passed to its in() function.
        /// </remarks>
        public IEnumerable <Scenario> FindByIds(IEnumerable <Guid> ids)
        {
            const int BatchSize = 1000;

            if (!ids.Any())
            {
                return(new List <Scenario>(0));
            }

            IReadOnlyCollection <Guid> sourceIds = ids.ToList();

            lock (_session)
            {
                if (sourceIds.Count < BatchSize)
                {
                    return(GetBatch(sourceIds));
                }

                var result = new List <Scenario>();

                int pageNumber = 0;

                do
                {
                    var batch = sourceIds
                                .Skip(BatchSize * pageNumber)
                                .Take(BatchSize)
                                .ToList();

                    if (batch.Count == 0)
                    {
                        return(result);
                    }

                    result.AddRange(
                        GetBatch(batch)
                        );

                    ++pageNumber;
                } while (true);

                //----------------------
                IReadOnlyCollection <Scenario> GetBatch(IEnumerable <Guid> batch) =>
                _session.GetAll <Scenario>(
                    s => s.Id.In(batch),
                    indexName: Scenarios_Default.DefaultIndexName,
                    isMapReduce: false
                    );
            }
        }
Exemple #14
0
 public IEnumerable <RuleType> GetAll(bool onlyAllowedAutopilot = false)
 {
     return(_session
            .GetAll <RuleType>()
            .Where(p => onlyAllowedAutopilot == false || p.AllowedForAutopilot)
            .ToList());
 }
 public List <AWSInstanceConfiguration> GetAll()
 {
     lock (_session)
     {
         return(_session.GetAll <AWSInstanceConfiguration>());
     }
 }
 public IEnumerable <CampaignSettings> GetAll()
 {
     lock (_session)
     {
         return(_session.GetAll <CampaignSettings>().ToList());
     }
 }
Exemple #17
0
        public void Apply()
        {
            foreach (string tenantConnectionString in _tenantConnectionStrings)
            {
                using (IDocumentStore documentStore = DocumentStoreFactory.CreateStore(tenantConnectionString))
                {
                    using (IDocumentSession session = documentStore.OpenSession())
                    {
                        var functionalArea = session
                                             .GetAll <FunctionalArea>()
                                             .Where(a => a.Description.Values.Contains("Slotting Controls"))
                                             .FirstOrDefault();

                        if (functionalArea != null)
                        {
                            var faultType = functionalArea.FaultTypes
                                            .Where(b => b.Description.Values.Contains("Miniumum Break Availability"))
                                            .Select(c =>
                            {
                                c.Description["ARA"] = "Minimum Break Availability";
                                c.Description["ENG"] = "Minimum Break Availability";
                                return(c);
                            })
                                            .FirstOrDefault();

                            session.SaveChanges();
                        }
                    }
                }
            }
        }
        public void Apply()
        {
            foreach (string tenantConnectionString in _tenantConnectionStrings)
            {
                using (IDocumentStore documentStore = DocumentStoreFactory.CreateStore(tenantConnectionString))
                    using (IDocumentSession session = documentStore.OpenSession())
                    {
                        var passes = session.GetAll <Pass>();
                        passes
                        .ForEach(pass =>
                        {
                            if (pass.Tolerances.All(x => x.RuleId != (int)ToleranceRuleId.Programme))
                            {
                                pass.Tolerances.Add(new Tolerance
                                {
                                    RuleId         = (int)ToleranceRuleId.Programme,
                                    Description    = "Programme",
                                    InternalType   = "Campaign",
                                    Type           = "tolerances",
                                    Value          = null,
                                    Ignore         = true,
                                    ForceOverUnder = ForceOverUnder.None
                                });
                            }
                        });

                        session.SaveChanges();
                    }
            }
        }
Exemple #19
0
        /// <summary>
        /// Added field IsLibraried for scenarios and passes
        /// </summary>
        public void Apply()
        {
            foreach (string tenantConnectionString in _tenantConnectionStrings)
            {
                using (IDocumentStore documentStore = DocumentStoreFactory.CreateStore(tenantConnectionString))
                {
                    using (IDocumentSession session = documentStore.OpenSession())
                    {
                        var passes = session.GetAll <Pass>();
                        // Add new General rule to the Pass with default value 0
                        passes
                        .ForEach(pass =>
                        {
                            if (!pass.General.Any(rule => rule.RuleId == (int)RuleID.UseCampaignMaxSpotRatings))
                            {
                                pass.General.Add(new General
                                {
                                    RuleId       = (int)RuleID.UseCampaignMaxSpotRatings,
                                    Description  = "Use Max Spot Ratings Set By Campaigns",
                                    InternalType = "Defaults",
                                    Type         = "general",
                                    Value        = "0"
                                });
                            }
                        });

                        session.SaveChanges();
                    }
                }
            }
        }
 public IEnumerable <IndexType> GetAll()
 {
     lock ( _session)
     {
         return(_session.GetAll <IndexType>());
     }
 }
 public List <KPIComparisonConfig> GetAll()
 {
     lock (_session)
     {
         return(_session.GetAll <KPIComparisonConfig>().ToList());
     }
 }
 public IEnumerable <ProgrammeClassification> GetAll()
 {
     lock (_session)
     {
         return(_session.GetAll <ProgrammeClassification>().ToList());
     }
 }
Exemple #23
0
        public void DeleteRangeByExternalRefs(IEnumerable <string> externalRefs)
        {
            var products = _session.GetAll <Product>(s => s.Externalidentifier.In(externalRefs.ToList()));

            foreach (var product in products)
            {
                _session.Delete(product);
            }
        }
        public void Apply()
        {
            foreach (string tenantConnectionString in _tenantConnectionStrings)
            {
                using (IDocumentStore documentStore = DocumentStoreFactory.CreateStore(tenantConnectionString))
                    using (IDocumentSession session = documentStore.OpenSession())
                    {
                        var scenarios = session.GetAll <Scenario>();

                        var passes = session.GetAll <Pass>();

                        var rules = session.GetAll <Rule>();

                        UpdateRules(rules);

                        var notStartedRuns = session.GetAll <Run>()
                                             .FindAll(r => r.RunStatus == RunStatus.NotStarted && r.Scenarios.Any());

                        var notStartedRunScenarios = new List <Scenario>();

                        foreach (var run in notStartedRuns)
                        {
                            var scenarioIds = run.Scenarios.Select(x => x.Id);

                            notStartedRunScenarios.AddRange(scenarios.FindAll(s => scenarioIds.Contains(s.Id)));
                        }

                        var scenarioPasses = GetScenariosPasses(notStartedRunScenarios, passes);

                        var libraryScenarios = scenarios.FindAll(s => s.IsLibraried == true);

                        var libraryScenariosPasses = GetScenariosPasses(libraryScenarios, passes);

                        var libraryPasses = passes.FindAll(p => p.IsLibraried == true);

                        scenarioPasses.ForEach(UpdatePassRules);

                        libraryScenariosPasses.ForEach(UpdatePassRules);

                        libraryPasses.ForEach(UpdatePassRules);

                        session.SaveChanges();
                    }
            }
        }
Exemple #25
0
 public IEnumerable <Sponsorship> GetAll()
 {
     lock (_session)
     {
         return(_session.GetAll <Sponsorship>(p =>
                                              !p.Id.In(ForceRavenDbToStreamResults),
                                              indexName: Sponsorship_ById.DefaultIndexName,
                                              isMapReduce: false));
     }
 }
 /// <summary>
 /// GetSchedule by list sales area names and schedule dates
 /// </summary>
 /// <param name="salesAreaNames"></param>
 /// <param name="fromDate"></param>
 /// <param name="toDate"></param>
 /// <returns></returns>
 public List <Schedule> GetSchedule(List <string> salesAreaNames, DateTime fromDate, DateTime toDate)
 {
     return(_session.GetAll <Schedule>(
                s => s.Date >= fromDate.Date &&
                s.Date < toDate.Date.AddDays(1) &&
                s.SalesArea.In(salesAreaNames),
                indexName: Schedules_ByIdAndBreakIdAndSalesAreaAndDate.DefaultIndexName,
                isMapReduce: false).ToList());
 }
        public IEnumerable <Break> FindByExternal(string externalref)
        {
            lock (_session)
            {
                List <Break> results = _session.GetAll <Break>(x =>
                                                               x.ExternalBreakRef == externalref,
                                                               Breaks_ByManyFields.DefaultIndexName,
                                                               isMapReduce: false
                                                               );

                return(results);
            }
        }
 /// <summary>
 /// Add ProgrammeName to ProgrammeDictionary
 /// </summary>
 public void Apply()
 {
     foreach (string tenantConnectionString in _tenantConnectionStrings)
     {
         using (IDocumentStore documentStore = DocumentStoreFactory.CreateStore(tenantConnectionString))
         {
             using (IDocumentSession session = documentStore.OpenSession())
             {
                 var programmeDictionaries = session.GetAll <ProgrammeDictionary>();
                 var allProgrammes         = session.GetAll <Programme>();
                 programmeDictionaries
                 .ForEach(programmeDictionary =>
                 {
                     var programme = allProgrammes.FirstOrDefault(p => p.ExternalReference == programmeDictionary.ExternalReference);
                     if (programme != null)
                     {
                         programmeDictionary.ProgrammeName = programme.ProgrammeName;
                     }
                 });
                 session.SaveChanges();
             }
         }
     }
 }
Exemple #29
0
        public void Apply()
        {
            foreach (string tenantConnectionString in _tenantConnectionStrings)
            {
                using (IDocumentStore documentStore = DocumentStoreFactory.CreateStore(tenantConnectionString))
                    using (IDocumentSession session = documentStore.OpenSession())
                    {
                        var runs = session.GetAll <Run>();
                        foreach (var run in runs)
                        {
                            if (run.ISR)
                            {
                                run.ISRDateRange = new DateRange()
                                {
                                    Start = run.StartDate.Date, End = run.EndDate.Date
                                };
                            }

                            if (run.Smooth)
                            {
                                run.SmoothDateRange = new DateRange()
                                {
                                    Start = run.StartDate.Date, End = run.EndDate.Date
                                };
                            }

                            if (run.Optimisation)
                            {
                                run.OptimisationDateRange = new DateRange()
                                {
                                    Start = run.StartDate.Date, End = run.EndDate.Date
                                };
                            }

                            if (run.RightSizer)
                            {
                                run.RightSizerDateRange = new DateRange()
                                {
                                    Start = run.StartDate.Date, End = run.EndDate.Date
                                };
                            }
                        }

                        session.SaveChanges();
                    }
            }
        }
Exemple #30
0
        public void Apply()
        {
            var maximumValidUntilDate = new DateTimeOffset(DateTime.Now.AddYears(1));
            var accessTokensToRemove  = new List <AccessToken>(default(int));

            using (IDocumentStore documentStore = DocumentStoreFactory.CreateStore(_masterConnectionString))
                using (IDocumentSession session = documentStore.OpenSession())
                {
                    var existingTokens = session.GetAll <AccessToken>(accessToken => accessToken.ValidUntilValue <= maximumValidUntilDate);

                    accessTokensToRemove.AddRange(existingTokens);
                    BackupAccessTokens(accessTokensToRemove);

                    accessTokensToRemove.ForEach(token => session.Delete(token));

                    session.SaveChanges();
                }
        }