Exemplo n.º 1
0
        public static CakeMachine GetCakeMachine(DurationType durationType)
        {
            switch (durationType)
            {
            case DurationType.Seconds:
                var slowReportingDuration   = new Duration(1, durationType);
                var slowPrepareDuration     = new Duration(5, 8, durationType);
                var slowCookDuration        = new Duration(10, durationType);
                var slowPackageDuration     = new Duration(2, durationType);
                var slowDurationSettings    = new DurationSettings(slowPrepareDuration, slowCookDuration, slowPackageDuration);
                var slowReportingSettings   = new ReportingSettings(slowReportingDuration, true);
                var slowCakeMachineSettings = new CakeMachineSettings(slowDurationSettings, slowReportingSettings);
                return(new CakeMachine(slowCakeMachineSettings));

            case DurationType.Milliseconds:
                var fastReportingDuration   = new Duration(100, durationType);
                var fastPrepareDuration     = new Duration(50, 80, durationType);
                var fastCookDuration        = new Duration(70, 90, durationType);
                var fastPackageDuration     = new Duration(30, durationType);
                var fastDurationSettings    = new DurationSettings(fastPrepareDuration, fastCookDuration, fastPackageDuration);
                var fastReportingSettings   = new ReportingSettings(fastReportingDuration, true);
                var fastCakeMachineSettings = new CakeMachineSettings(fastDurationSettings, fastReportingSettings);
                return(new CakeMachine(fastCakeMachineSettings));

            default:
                throw new ArgumentOutOfRangeException($"{durationType}");
            }
        }
Exemplo n.º 2
0
        public void UpgradeIfNecessary_FullOldConfig_OldConfigMigrated()
        {
            var reportingSettings = new ReportingSettings
            {
                FirstLaunchDate            = DateTime.Now.AddYears(-1),
                HaveShowRegistrationDialog = false,
                Launches = 100,
                OkToPingBasicUsageData = true,
                PreviousLaunchDate     = DateTime.Now.AddDays(-1),
                PreviousVersion        = "Version 1.0.0"
            };

            XDocument oldConfigXml = CreateOldConfig(reportingSettings, true, "keyboards", "username", "password");
            var       appSettings  = new TestFwApplicationSettings {
                ConfigXml = oldConfigXml
            };

            appSettings.UpgradeIfNecessary();
            Assert.That(appSettings.Reporting.Launches, Is.EqualTo(reportingSettings.Launches));
            Assert.That(appSettings.Reporting.FirstLaunchDate, Is.EqualTo(reportingSettings.FirstLaunchDate));
            Assert.That(appSettings.Reporting.PreviousVersion, Is.EqualTo(reportingSettings.PreviousVersion));
            Assert.That(appSettings.LocalKeyboards, Is.EqualTo("keyboards"));
            Assert.That(appSettings.WebonaryUser, Is.EqualTo("username"));
            Assert.That(appSettings.WebonaryPass, Is.EqualTo("password"));
            // check if the old config sections were removed
            Assert.That(appSettings.ConfigXml.Root?.Element("configSections")?.Elements("sectionGroup")
                        .First(e => (string)e.Attribute("name") == "userSettings").HasElements, Is.False);
            Assert.That(appSettings.ConfigXml.Root?.Element("userSettings")?.HasElements, Is.False);
        }
Exemplo n.º 3
0
        public override void Upgrade()
        {
            string lastConfigFilePath = null;

            try
            {
                lastConfigFilePath = (string)GetPreviousVersion("LastConfigFilePath");
            }
            catch
            {
                // mono does not support GetPreviousVersion as of 23-Sep-2008
                // it doesn't matter if this fails
            }

            base.Upgrade();             // bring forward our MruConfigFilePaths and any other properties
            if (MruConfigFilePaths == null)
            {
                MruConfigFilePaths = new MruProjects();
            }
            if (Reporting == null)
            {
                Reporting = new ReportingSettings();
            }
            if (!string.IsNullOrEmpty(lastConfigFilePath))
            {
                MruConfigFilePaths.AddNewPath(lastConfigFilePath);
            }
        }
Exemplo n.º 4
0
 public void Initialize(NSCRegDbContext context, ReportingSettings reportingSettings = null)
 {
     context.Database.ExecuteSqlCommand(dropStatUnitSearchViewTableSqliteInmemory);
     context.Database.ExecuteSqlCommand(dropStatUnitSearchViewSqliteInmemory);
     context.Database.ExecuteSqlCommand(createStatUnitSearchViewSqliteInmemory);
     context.Database.ExecuteSqlCommand(dropReportTreeTableSqliteInmemory);
 }
Exemplo n.º 5
0
        private string GetAccessToken(ReportingSettings settings, string sqlWalletUserName)
        {
            var authResponse = new SqlWalletResponse();

            var client = new HttpClient();

            try
            {
                var request = new HttpRequestMessage(HttpMethod.Post, $"http://{settings.HostName}/connect/token")
                {
                    Content = new StringContent(
                        $"client_secret={settings.SecretKey}&grant_type=client_credentials&client_id=sqlwallet&scope=sqlwallet",
                        Encoding.UTF8,
                        "application/x-www-form-urlencoded")
                };

                request.Headers.ExpectContinue = true;

                client.SendAsync(request).ContinueWith(responseTask =>
                {
                    var content = responseTask.Result.Content.ReadAsStringAsync().Result;

                    authResponse = JsonConvert.DeserializeObject <SqlWalletResponse>(content);
                }).Wait();


                var userRequest =
                    new HttpRequestMessage(HttpMethod.Post,
                                           $"http://{settings.HostName}/auth/accesstoken/{sqlWalletUserName}")
                {
                    Content = new StringContent("", Encoding.UTF8, "application/json")
                };

                userRequest.Headers.Authorization =
                    new AuthenticationHeaderValue(authResponse.Token_Type, authResponse.Access_Token);
                userRequest.Headers.CacheControl = new CacheControlHeaderValue {
                    NoCache = true
                };
                userRequest.Headers.Host = settings.HostName;

                var accessToken = "";
                client.SendAsync(userRequest).ContinueWith(respTask =>
                {
                    accessToken = respTask.Result.Content.ReadAsStringAsync().Result;
                }).Wait();

                return(accessToken);
            }
            catch (Exception e)
            {
                throw new Exception($"An error occured while trying getting access token. Message: {e.Message}");
            }
            finally
            {
                client.CancelPendingRequests();
            }
        }
Exemplo n.º 6
0
        internal ConfigurationReportsData Convert(ReportingSettings source)
        {
            ConfigurationReportsData result = new ConfigurationReportsData();

            if (source != null)
            {
                result.EmailAddresses = String.Join(", ", source.Recipients);
            }
            return(result);
        }
Exemplo n.º 7
0
 private void Initialize()
 {
     if (MruConfigFilePaths == null)
     {
         MruConfigFilePaths = new MruProjects();
     }
     if (Reporting == null)
     {
         Reporting = new ReportingSettings();
     }
 }
Exemplo n.º 8
0
        internal ReportingSettings CreateReportingSettings(ConfigurationReportsData source)
        {
            ReportingSettings result = new ReportingSettings();

            if (!String.IsNullOrWhiteSpace(source.EmailAddresses))
            {
                var emails = source.EmailAddresses.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
                if (emails.Count() > 0)
                {
                    result.Recipients.AddRange(emails);
                }
            }
            return(result);
        }
Exemplo n.º 9
0
 public HomeController(
     IHostingEnvironment env,
     IAntiforgery antiforgery,
     LocalizationSettings localization,
     DbMandatoryFields dbMandatoryFields,
     ReportingSettings reportingSettings,
     ValidationSettings validationSettings,
     StatUnitAnalysisRules analysisRules,
     NSCRegDbContext db)
 {
     _env                = env;
     _antiforgery        = antiforgery;
     _dbMandatoryFields  = dbMandatoryFields;
     _localization       = localization;
     _reportingSettings  = reportingSettings;
     _validationSettings = validationSettings;
     _analysisRules      = analysisRules;
     _ctx                = db;
 }
Exemplo n.º 10
0
        private static XDocument CreateOldConfig(ReportingSettings reportingSettings, bool?updateGlobalWSStore, string localKeyboards,
                                                 string webonaryUser, string webonaryPass)
        {
            var settingsElem = new XElement("SIL.CoreImpl.Properties.Settings",
                                            CreateStringSettingElement("IsBTE", false),
                                            CreateStringSettingElement("CheckForBetaUpdates", false),
                                            CreateStringSettingElement("AutoCheckForUpdates", true));

            if (reportingSettings != null)
            {
                settingsElem.Add(new XElement("setting", new XAttribute("name", "Reporting"), new XAttribute("serializeAs", "Xml"),
                                              new XElement("value", XElement.Parse(XmlSerializationHelper.SerializeToString(reportingSettings)))));
            }

            // Leave this obsolete value in in the old config to test that it doesn't cause problems
            if (updateGlobalWSStore != null)
            {
                settingsElem.Add(CreateStringSettingElement("UpdateGlobalWSStore", updateGlobalWSStore));
            }

            if (localKeyboards != null)
            {
                settingsElem.Add(CreateStringSettingElement("LocalKeyboards", localKeyboards));
            }

            if (webonaryUser != null)
            {
                settingsElem.Add(CreateStringSettingElement("WebonaryUser", webonaryUser));
            }

            if (webonaryPass != null)
            {
                settingsElem.Add(CreateStringSettingElement("WebonaryPass", webonaryPass));
            }

            return(new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
                                 new XElement("configuration",
                                              new XElement("configSections",
                                                           new XElement("sectionGroup", new XAttribute("name", "userSettings"),
                                                                        new XElement("section", new XAttribute("name", "SIL.CoreImpl.Properties.Settings")))),
                                              new XElement("userSettings", settingsElem))));
        }
Exemplo n.º 11
0
        public void Initialize(NSCRegDbContext context, ReportingSettings reportingSettings = null)
        {
            #region Scripts

            const string dropStatUnitSearchViewTable = @"DROP TABLE IF EXISTS V_StatUnitSearch;";

            const string dropStatUnitSearchView = @"DROP VIEW IF EXISTS V_StatUnitSearch;";

            const string createStatUnitSearchView = @"
                CREATE VIEW V_StatUnitSearch
                AS
                SELECT
                    RegId,
                    Name,
                    TaxRegId,
                    StatId,
                    ExternalId,
                    Region_id AS RegionId,
                    Employees,
                    Turnover,
                    InstSectorCodeId AS SectorCodeId,
                    LegalFormId,
                    DataSourceClassificationId,
                    ChangeReason,
                    StartPeriod,
                    IsDeleted,
                    LiqReason,
                    LiqDate,
                    Address_part1 AS AddressPart1,
                    Address_part2 AS AddressPart2,
                    Address_part3 AS AddressPart3,
                    CASE
                        WHEN Discriminator = 'LocalUnit' THEN 1
                        WHEN Discriminator = 'LegalUnit' THEN 2
                        WHEN Discriminator = 'EnterpriseUnit' THEN 3

                    END
                    AS UnitType
                FROM	StatisticalUnits
                    LEFT JOIN Address
                        ON AddressId = Address_id

                UNION ALL

                SELECT
                    RegId,
                    Name,
                    TaxRegId,
                    StatId,
                    ExternalId,
                    Region_id AS RegionId,
                    Employees,
                    Turnover,
                    NULL AS SectorCodeId,
                    NULL AS LegalFormId,
                    DataSourceClassificationId,
                    ChangeReason,
                    StartPeriod,
                    IsDeleted,
                    LiqReason,
                    LiqDateEnd,
                    Address_part1 AS AddressPart1,
                    Address_part2 AS AddressPart2,
                    Address_part3 AS AddressPart3,
                    4 AS UnitType
                FROM	EnterpriseGroups
                    LEFT JOIN Address
                        ON AddressId = Address_id;
            ";

            const string dropReportTreeTable = @"DROP TABLE IF EXISTS ReportTree;";

            const string dropProcedureGetActivityChildren = @"DROP PROCEDURE IF EXISTS GetActivityChildren;";

            const string createProcedureGetActivityChildren = @"
                CREATE PROCEDURE GetActivityChildren (activityId INT, activitiesIds VARCHAR(400))
                BEGIN
                WITH RECURSIVE ActivityCte (Id, Code, DicParentId, IsDeleted, Name, NameLanguage1, NameLanguage2, ParentId, Section, VersionId, ActivityCategoryLevel) AS 
	                  (
		                SELECT 
		                   Id
		                  ,Code
		                  ,DicParentId
		                  ,IsDeleted
		                  ,Name
                          ,NameLanguage1
                          ,NameLanguage2
		                  ,ParentId
		                  ,Section
		                  ,VersionId
                          ,ActivityCategoryLevel
		                FROM ActivityCategories
		                WHERE CONCAT(',', activitiesIds, ',') LIKE CONCAT('%,',Id, ',%') OR Id = activityId

		                UNION ALL

		                SELECT 
		                   ac.Id
		                  ,ac.Code
		                  ,ac.DicParentId
		                  ,ac.IsDeleted
		                  ,ac.Name
                          ,ac.NameLanguage1
                          ,ac.NameLanguage2
		                  ,ac.ParentId
		                  ,ac.Section
		                  ,ac.VersionId
                          ,ac.ActivityCategoryLevel
		                FROM ActivityCategories ac
			                INNER JOIN ActivityCte  
			                ON ActivityCte.Id = ac.ParentId
		
	                )

	                SELECT * FROM ActivityCte;
            END;";

            const string dropProcedureGetRegionChildren = @"DROP PROCEDURE IF EXISTS GetRegionChildren;";

            const string createProcedureGetRegionChildren = @"
                CREATE PROCEDURE GetRegionChildren(regionId INT)
                BEGIN
	                 WITH RECURSIVE RegionsCte (Id, AdminstrativeCenter, Code, IsDeleted, Name, NameLanguage1, NameLanguage2, ParentId, FullPath, FullPathLanguage1, FullPathLanguage2, RegionLevel) AS 
	                  (
		                SELECT 
		                   Id
		                  ,AdminstrativeCenter
		                  ,Code
		                  ,IsDeleted
		                  ,Name
                          ,NameLanguage1
                          ,NameLanguage2
		                  ,ParentId
		                  ,FullPath
                          ,FullPathLanguage1
                          ,FullPathLanguage2
                          ,RegionLevel
		                FROM Regions
		                WHERE Id = regionId

		                UNION ALL

		                SELECT 
		                   r.Id
		                  ,r.AdminstrativeCenter
		                  ,r.Code
		                  ,r.IsDeleted
		                  ,r.Name
                          ,r.NameLanguage1
                          ,r.NameLanguage2
		                  ,r.ParentId
		                  ,r.FullPath
                          ,r.FullPathLanguage1
                          ,r.FullPathLanguage2
                          ,r.RegionLevel
		                FROM Regions r
			                INNER JOIN RegionsCte rc
			                ON rc.Id = r.ParentId
		
	                  )

	                 SELECT * FROM RegionsCte;
                END";

            #endregion

            context.Database.ExecuteSqlCommand(dropStatUnitSearchViewTable);
            context.Database.ExecuteSqlCommand(dropStatUnitSearchView);
            context.Database.ExecuteSqlCommand(createStatUnitSearchView);
            context.Database.ExecuteSqlCommand(dropReportTreeTable);
            context.Database.ExecuteSqlCommand(dropProcedureGetActivityChildren);
            context.Database.ExecuteSqlCommand(createProcedureGetActivityChildren);
            context.Database.ExecuteSqlCommand(dropProcedureGetRegionChildren);
            context.Database.ExecuteSqlCommand(createProcedureGetRegionChildren);
        }
Exemplo n.º 12
0
 public ReportsController(
     NSCRegDbContext context,
     ReportingSettings settings, IConfiguration configuration)
 {
     _reportService = new ReportService(context, settings, configuration);
 }
Exemplo n.º 13
0
        public void Initialize(NSCRegDbContext context, ReportingSettings reportingSettings = null)
        {
            #region Scripts

            const string dropStatUnitSearchViewTable = @"DO
                                                         $$
                                                         BEGIN
                                                         IF EXISTS 
                                                         (
                                                            SELECT 1
                                                            FROM information_schema.tables 
                                                            WHERE table_name = 'V_StatUnitSearch'
                                                            AND table_type = 'BASE TABLE'
                                                         )
                                                         THEN 
                                                         DROP TABLE ""V_StatUnitSearch"";
                                                         END IF;
                                                         END
                                                         $$ language 'plpgsql'";

            const string dropStatUnitSearchView = @"DO
                                                    $$
                                                    BEGIN
                                                    IF EXISTS 
                                                    (
                                                        SELECT 1
                                                        FROM information_schema.tables 
                                                        WHERE table_name = 'V_StatUnitSearch'
                                                        AND table_type = 'VIEW'
                                                    )
                                                    THEN 
                                                    DROP VIEW ""V_StatUnitSearch"";
                                                    END IF;
                                                    END
                                                    $$ language 'plpgsql'";

            const string createStatUnitSearchView = @"
                                                    CREATE VIEW ""V_StatUnitSearch""
                                                     AS
                                                     SELECT
                                                         ""RegId"",
                                                         ""Name"",
                                                         ""TaxRegId"",
                                                         ""StatId"",
                                                         ""ExternalId"",
                                                         ""Region_id"" AS ""RegionId"",
                                                         ""Employees"",
                                                         ""Turnover"",
                                                        ""InstSectorCodeId"" AS ""SectorCodeId"",
                                                        ""LegalFormId"",
                                                         ""DataSourceClassificationId"",
                                                         ""ChangeReason"",
                                                         ""StartPeriod"",
                                                         ""IsDeleted"",
                                                         ""LiqReason"",
                                                         ""LiqDate"",
                                                         ""Address_part1"" AS ""AddressPart1"",
                                                         ""Address_part2"" AS ""AddressPart2"",
                                                         ""Address_part3"" AS ""AddressPart3"",
                                                         CASE
                                                             WHEN ""Discriminator"" = 'LocalUnit' THEN 1
                                                             WHEN ""Discriminator"" = 'LegalUnit' THEN 2
                                                             WHEN ""Discriminator"" = 'EnterpriseUnit' THEN 3

                                                         END
                                                         AS ""UnitType""
                                                     FROM    ""StatisticalUnits""
                                                         LEFT JOIN ""Address""
                                                             ON ""AddressId"" = ""Address_id""

                                                     UNION ALL

                                                     SELECT
                                                         ""RegId"",
                                                         ""Name"",
                                                         ""TaxRegId"",
                                                         ""StatId"",
                                                         ""ExternalId"",
                                                         ""Region_id"" AS ""RegionId"",
                                                         ""Employees"",
                                                         ""Turnover"",
                                                           NULL AS ""SectorCodeId"",
                                                           NULL AS ""LegalFormId"",
                                                         ""DataSourceClassificationId"",
                                                         ""ChangeReason"",
                                                         ""StartPeriod"",
                                                         ""IsDeleted"",
                                                         ""LiqReason"",
                                                         ""LiqDateEnd"",
                                                         ""Address_part1"" AS ""AddressPart1"",
                                                         ""Address_part2"" AS ""AddressPart2"",
                                                         ""Address_part3"" AS ""AddressPart3"",
                                                         4 AS ""UnitType""
                                                     FROM    ""EnterpriseGroups""
                                                         LEFT JOIN ""Address""
                                                             ON ""AddressId"" = ""Address_id""
            ";

            const string dropReportTreeTable = @"DO
                                                         $$
                                                         BEGIN
                                                         IF EXISTS 
                                                         (
                                                            SELECT 1
                                                            FROM information_schema.tables 
                                                            WHERE table_name = 'ReportTree'
                                                            AND table_type = 'BASE TABLE'
                                                         )
                                                         THEN 
                                                         DROP TABLE ""ReportTree"";
                                                         END IF;
                                                         END
                                                         $$ language 'plpgsql'";

            const string dropFunctionGetActivityChildren = @"DO
                                                            $$
                                                            BEGIN
                                                            IF EXISTS 
                                                            (
                                                                SELECT 1
                                                                FROM information_schema.routines 
                                                                WHERE routine_name = 'GetActivityChildren'
                                                                AND routine_type = 'FUNCTION'
                                                            )
                                                            THEN 
                                                            DROP FUNCTION ""GetActivityChildren"";
                                                            END IF;
                                                            END
                                                            $$ language 'plpgsql'";

            const string createFunctionGetActivityChildren = @"CREATE OR REPLACE FUNCTION public.""GetActivityChildren""(activityid integer,activitiesids varchar(400))
                                                               RETURNS TABLE(""Id"" integer, ""Code"" character varying, ""DicParentId"" integer, ""IsDeleted"" boolean, ""Name"" text, ""NameLanguage1"" text, ""NameLanguage2"" text, ""ParentId"" integer, ""Section"" character varying, ""VersionId"" integer, ""ActivityCategoryLevel"" integer) 
                                                               LANGUAGE 'plpgsql'
                                                               AS $BODY$
                                                               BEGIN
                                                                   RETURN QUERY(
                                                                   WITH RECURSIVE ""ActivityCte"" AS
                                                                   (
                                                                       SELECT
                                                                         ac.""Id""
                                                                       , ac.""Code""
                                                                       , ac.""DicParentId""
                                                                       , ac.""IsDeleted""
                                                                       , ac.""Name""
                                                                       , ac.""NameLanguage1""
                                                                       , ac.""NameLanguage2""
                                                                       , ac.""ParentId""
                                                                       , ac.""Section""
                                                                       , ac.""VersionId""
                                                                       , ac.""ActivityCategoryLevel""
                                                                       FROM ""ActivityCategories"" ac
                                                                       WHERE CONCAT(',', activitiesids, ',') LIKE CONCAT('%,',ac.""Id"", ',%') OR ac.""Id"" = activityid

                                                                   UNION ALL

                                                                       SELECT
                                                                         ac.""Id""
                                                                       , ac.""Code""
                                                                       , ac.""DicParentId""
                                                                       , ac.""IsDeleted""
                                                                       , ac.""Name""
                                                                       , ac.""NameLanguage1""
                                                                       , ac.""NameLanguage2""
                                                                       , ac.""ParentId""
                                                                       , ac.""Section""
                                                                       , ac.""VersionId""
                                                                       , ac.""ActivityCategoryLevel""
                                                                   FROM ""ActivityCategories"" ac
                                                                       INNER JOIN ""ActivityCte""
                                                                   ON ""ActivityCte"".""Id"" = ac.""ParentId"")

                                                                   SELECT * FROM ""ActivityCte"");
                                                               END;
                                                               $BODY$; ";


            const string dropFunctionGetRegionChildren = @"DO
                                                           $$
                                                           BEGIN
                                                           IF EXISTS 
                                                           (
                                                            SELECT 1
                                                            FROM information_schema.routines 
                                                            WHERE routine_name = 'GetRegionChildren'
                                                            AND routine_type = 'FUNCTION'
                                                           )
                                                           THEN 
                                                           DROP FUNCTION ""GetRegionChildren"";
                                                           END IF;
                                                           END
                                                           $$ language 'plpgsql'";

            const string createFunctionGetRegionChildren = @"CREATE OR REPLACE FUNCTION ""GetRegionChildren""(regionId integer)
                                                             RETURNS TABLE(""Id"" integer, ""AdminstrativeCenter"" text, ""Code"" text, ""IsDeleted"" boolean, ""Name"" text, ""NameLanguage1"" text, ""NameLanguage2"" text, ""ParentId"" integer, ""FullPath"" text, ""FullPathLanguage1"" text, ""FullPathLanguage2"" text, ""RegionLevel"" integer)
                                                             LANGUAGE 'plpgsql'
                                                             AS
                                                             $$
                                                             BEGIN
                                                                 RETURN QUERY
                                                             (
                                                                 WITH RECURSIVE ""RegionsCte"" AS
                                                                 (
                                                                     SELECT
                                                                       r.""Id""
                                                                     , r.""AdminstrativeCenter""
                                                                     , r.""Code""
                                                                     , r.""IsDeleted""
                                                                     , r.""Name""
                                                                     , r.""NameLanguage1""
                                                                     , r.""NameLanguage2""
                                                                     , r.""ParentId""
                                                                     , r.""FullPath""
                                                                     , r.""FullPathLanguage1""
                                                                     , r.""FullPathLanguage2""
                                                                     , r.""RegionLevel""
                                                                 FROM ""Regions"" r
                                                                 WHERE r.""Id"" = regionId

                                                                 UNION ALL

                                                                 SELECT
                                                                       r.""Id""
                                                                     , r.""AdminstrativeCenter""
                                                                     , r.""Code""
                                                                     , r.""IsDeleted""
                                                                     , r.""Name""
                                                                     , r.""NameLanguage1""
                                                                     , r.""NameLanguage2""
                                                                     , r.""ParentId""
                                                                     , r.""FullPath""
                                                                     , r.""FullPathLanguage1""
                                                                     , r.""FullPathLanguage2""
                                                                     , r.""RegionLevel""
                                                                 FROM ""Regions"" r
                                                                     INNER JOIN ""RegionsCte"" rc
                                                                     ON rc.""Id"" = r.""ParentId""
                                                                 )

                                                             SELECT * FROM ""RegionsCte""
                                                             );
                                                             END;
                                                             $$; ";
            #endregion


            context.Database.ExecuteSqlCommand(dropStatUnitSearchViewTable);
            context.Database.ExecuteSqlCommand(dropStatUnitSearchView);
            context.Database.ExecuteSqlCommand(createStatUnitSearchView);
            context.Database.ExecuteSqlCommand(dropReportTreeTable);
            context.Database.ExecuteSqlCommand(dropFunctionGetActivityChildren);
            context.Database.ExecuteSqlCommand(createFunctionGetActivityChildren);
            context.Database.ExecuteSqlCommand(dropFunctionGetRegionChildren);
            context.Database.ExecuteSqlCommand(createFunctionGetRegionChildren);
        }
Exemplo n.º 14
0
 public CakeMachineSettings(DurationSettings durationSettings, ReportingSettings reportingSettings)
 {
     DurationSettings    = durationSettings;
     ReportingSettings   = reportingSettings;
     ParallelismSettings = new ParallelismSettings();
 }
Exemplo n.º 15
0
 public ReportService(NSCRegDbContext context, ReportingSettings settings, IConfiguration configuration)
 {
     _ctx           = context;
     _settings      = settings;
     _configuration = configuration;
 }
Exemplo n.º 16
0
        public static void SeedData(ModelBuilder modelBuilder)
        {
            /*
             * uint tpccDaabaseID = 371580;
             * uint testDatabaseID = 16393;
             * //workloads
             * var tpccWorkload = new Workload()
             * {
             *  ID = 1,
             *  Name = "TPCC",
             *  DatabaseID = tpccDaabaseID,
             *  CreatedDate = DateTime.Now,
             *  Definition = new WorkloadDefinition()
             *  {
             *      Applications = new WorkloadPropertyValuesDefinition<string>(),
             *      DateTimeSlots = new WorkloadPropertyValuesDefinition<WorkloadDateTimeSlot>(),
             *      QueryThresholds = new WorkloadQueryThresholds(),
             *      Relations = new WorkloadPropertyValuesDefinition<uint>(),
             *      Users = new WorkloadPropertyValuesDefinition<string>()
             *  }
             * };
             * tpccWorkload.Definition.Relations.ForbiddenValues.AddRange(new uint[] { 2619, 3118, 1260, 1418, 6100, 2613, 1247, 1249, 1255, 1259, 2604, 2606, 2611, 2610, 2617, 2753, 2616, 2601, 2602, 2603, 2612, 2995, 2600, 3381, 2618, 2620, 3466, 2609, 2605, 3501, 2615, 2607, 2608, 1262, 2964, 1213, 1136, 1261, 1214, 2396, 3602, 3603, 3600, 3601, 3764, 3079, 2328, 1417, 3256, 6000, 826, 3394, 3596, 3592, 3456, 3350, 3541, 3576, 2224, 6104, 6106, 6102, 12847, 12852, 12857, 12862, 12867, 12872, 12877 });
             * tpccWorkload.DefinitionData = SerializeToJson(tpccWorkload.Definition);
             *
             *
             * var testWorkload = new Workload()
             * {
             *  ID = 2,
             *  Name = "MM test",
             *  DatabaseID = testDatabaseID,
             *  CreatedDate = DateTime.Now,
             *  Definition = new WorkloadDefinition()
             *  {
             *      Applications = new WorkloadPropertyValuesDefinition<string>(),
             *      DateTimeSlots = new WorkloadPropertyValuesDefinition<WorkloadDateTimeSlot>(),
             *      QueryThresholds = new WorkloadQueryThresholds(),
             *      Relations = new WorkloadPropertyValuesDefinition<uint>(),
             *      Users = new WorkloadPropertyValuesDefinition<string>()
             *  }
             * };
             * testWorkload.Definition.Relations.ForbiddenValues.AddRange(new uint[] { 2619, 3118, 1260, 1418, 6100, 2613, 1247, 1249, 1255, 1259, 2604, 2606, 2611, 2610, 2617, 2753, 2616, 2601, 2602, 2603, 2612, 2995, 2600, 3381, 2618, 2620, 3466, 2609, 2605, 3501, 2615, 2607, 2608, 1262, 2964, 1213, 1136, 1261, 1214, 2396, 3602, 3603, 3600, 3601, 3764, 3079, 2328, 1417, 3256, 6000, 826, 3394, 3596, 3592, 3456, 3350, 3541, 3576, 2224, 6104, 6106, 6102, 12847, 12852, 12857, 12862, 12867, 12872, 12877 });
             * testWorkload.DefinitionData = SerializeToJson(testWorkload.Definition);
             *
             * modelBuilder.Entity<Workload>().HasData(tpccWorkload);
             * modelBuilder.Entity<Workload>().HasData(testWorkload);*/
            //

            // settings
            modelBuilder.Entity <SettingProperty>().HasData(new SettingProperty()
            {
                ID = 1, Key = SettingPropertyKeys.LAST_PROCESSED_LOG_ENTRY_TIMESTAMP
            });

            ReportingSettings reportingSettings = new ReportingSettings();

            reportingSettings.Recipients.Add("*****@*****.**");
            modelBuilder.Entity <SettingProperty>().HasData(new SettingProperty()
            {
                ID = 2, Key = SettingPropertyKeys.REPORTING_SETTINGS, StrValue = SerializeToJson(reportingSettings)
            });

            SmtpConfiguration smtpConfiguration = new SmtpConfiguration();

            smtpConfiguration.SmtpHost           = "smtp.gmail.com";
            smtpConfiguration.SmtpPasswordCipher = Common.Cryptography.EncryptionSupport.Instance.Encrypt("mm.d1pl0ma.thes1s.p$$s");
            smtpConfiguration.SmtpPort           = 587;
            smtpConfiguration.SmtpUsername       = "******";
            smtpConfiguration.SystemEmailSender  = "*****@*****.**";
            modelBuilder.Entity <SettingProperty>().HasData(new SettingProperty()
            {
                ID = 3, Key = SettingPropertyKeys.SMTP_CONFIGURATION, StrValue = SerializeToJson(smtpConfiguration)
            });

            EmailTemplate summaryReportTemplate = new EmailTemplate();

            summaryReportTemplate.IsBodyHtml   = true;
            summaryReportTemplate.Subject      = "DBMS statistics - summary report";
            summaryReportTemplate.BodyTemplate = Internal.DefaultEmailTemplates.SummaryReport;
            modelBuilder.Entity <SettingProperty>().HasData(new SettingProperty()
            {
                ID = 4, Key = SettingPropertyKeys.EMAIL_TEMPLATE_SUMMARY_REPORT, StrValue = SerializeToJson(summaryReportTemplate)
            });

            CollectorConfiguration collectorConfiguration = new CollectorConfiguration();

            //collectorConfiguration.Databases.Add(tpccDaabaseID, new CollectorDatabaseConfiguration() { DatabaseID = tpccDaabaseID, IsEnabledGeneralCollection = true, IsEnabledStatementCollection = true });
            //collectorConfiguration.Databases.Add(testDatabaseID, new CollectorDatabaseConfiguration() { DatabaseID = testDatabaseID, IsEnabledGeneralCollection = true, IsEnabledStatementCollection = true });
            modelBuilder.Entity <SettingProperty>().HasData(new SettingProperty()
            {
                ID = 5, Key = SettingPropertyKeys.COLLECTOR_CONFIGURATION, StrValue = SerializeToJson(collectorConfiguration)
            });
        }
Exemplo n.º 17
0
        /// <summary>
        /// Drop and re-create statunit search view
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        public static void CreateViewsProceduresAndFunctions(NSCRegDbContext context, ConnectionProvider provider, ReportingSettings reportingSettings = null)
        {
            IDbInitializer initializer;

            switch (provider)
            {
            case ConnectionProvider.InMemory: initializer = new InMemoryDbInitializer();
                break;

            case ConnectionProvider.SqlServer: initializer = new MsSqlDbInitializer();
                break;

            case ConnectionProvider.PostgreSql: initializer = new PostgreSqlDbInitializer();
                break;

            case ConnectionProvider.MySql: initializer = new MySqlDbInitializer();
                break;

            default: throw new Exception(Resources.Languages.Resource.ProviderIsNotSet);
            }

            initializer.Initialize(context, reportingSettings);
        }