Ejemplo n.º 1
0
        } // End Sub ParametersToCommand

        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            CoreDb.ReadDAL readDAL = (CoreDb.ReadDAL)context.RequestServices.GetService(
                typeof(CoreDb.ReadDAL)
                );

            string sql = GetContentOfEmbeddedFile(GetParam(context, "sql"));

            using (System.Data.Common.DbCommand cmd = readDAL.CreateCommand(sql))
            {
                try
                {
                    ParametersToCommand(context, cmd, readDAL);

                    context.Response.StatusCode  = StatusCodes.Status200OK;
                    context.Response.ContentType = "application/json; charset=utf-8";

                    readDAL.SerializeDataTableAsAssociativeJsonArray(cmd, context.Response.Body);
                }
                catch (System.Exception ex)
                {
                    context.Response.StatusCode = StatusCodes.Status500InternalServerError;
                    context.Response.WriteAsync(ex.Message, System.Text.Encoding.UTF8).Wait();
                }
            } // End Using cmd

            // System.Web.HttpUtility.HtmlAttributeEncode(columns[i])
            // sb.Append(System.Web.HttpUtility.HtmlEncode(System.Convert.ToString(reader.GetValue(i))));
        } // End Sub ProcessRequest
Ejemplo n.º 2
0
        public LegendFragment(CoreDb.ReadDAL SQL, System.Data.DataRow dr, string pSVG_UID, string pdar_uid, string plegend) :
            base(SQL, dr, pSVG_UID, pdar_uid)
        {
            // ⁰¹²³⁴⁵⁶⁷⁸⁹ ₉₈₇₆₅₄₃₂₁₀
            // plegend = plegend.Replace("m²", "<span style=""letter-spacing: 1mm;"">m<sup>2</sup></span>")
            plegend = plegend.Replace("m²", @"<span style=""letter-spacing: 0.8mm;"">m²</span>");

            this.Legende = plegend;
        } // End Constructor
Ejemplo n.º 3
0
        } // End Constructor

        // https://stackoverflow.com/questions/40897781/why-middleware-in-asp-net-core-requires-specific-semantics-but-not-an-interface
        public async Task Invoke(HttpContext context)
        {
            context.Response.ContentType = "text/html; charset=utf-8";

            CoreDb.ReadDAL readDAL = (CoreDb.ReadDAL)context.RequestServices.GetService(
                typeof(CoreDb.ReadDAL)
                );


            await context.Response.WriteAsync(Portal.Visualiser.LegendGenerator.Test(readDAL));
        } // End Task Invoke
Ejemplo n.º 4
0
        public DrawingControl(CoreDb.ReadDAL SQL, System.Data.DataRow dr, string psvg_uid, string pdar_uid)
        {
            this.m_data   = dr;
            this.m_X      = (decimal)System.Convert.ChangeType(dr["PL_X"], typeof(decimal));
            this.m_Y      = (decimal)System.Convert.ChangeType(dr["PL_Y"], typeof(decimal));
            this.m_Width  = (decimal)System.Convert.ChangeType(dr["PL_W"], typeof(decimal));
            this.m_Height = (decimal)System.Convert.ChangeType(dr["PL_H"], typeof(decimal));
            this.m_Angle  = (decimal)System.Convert.ChangeType(dr["PL_Angle"], typeof(decimal));

            this.m_Text = System.Convert.ToString(dr["PL_Text"]);
            this.m_Sort = System.Convert.ToString(dr["PL_Sort"]);

            this.m_AspectRatio = System.Convert.ToString(dr["PL_AspectRatio"]);

            this.m_Format   = System.Convert.ToString(dr["PL_Format"]);
            this.m_Type     = System.Convert.ToString(dr["PL_Type"]);
            this.m_DataBind = (string)System.Convert.ChangeType(dr["PL_DataBind"], typeof(string));

            this.m_SVG_UID = psvg_uid;
            this.m_DAR_UID = pdar_uid;
        } // End Constructor
Ejemplo n.º 5
0
        } // End Function GetParameters

        public static void ParametersToCommand(
            HttpContext context
            , System.Data.Common.DbCommand cmd
            , CoreDb.ReadDAL readDAL)
        {
            System.Collections.Generic.Dictionary <string, Microsoft.Extensions.Primitives.StringValues>
            dict = new System.Collections.Generic.Dictionary
                   <string, Microsoft.Extensions.Primitives.StringValues>
                       (System.StringComparer.InvariantCultureIgnoreCase);


            // TODO: Add parameters from PARAMS
            readDAL.AddParameter(cmd, "BE_ID", 12572);


            foreach (System.Collections.Generic.KeyValuePair <string
                                                              , Microsoft.Extensions.Primitives.StringValues> kvp in context.Request.Query)
            {
                readDAL.AddParameter(cmd, kvp.Key, (string)kvp.Value);
            } // Next kvp


            if (context.Request.HasFormContentType)
            {
                foreach (System.Collections.Generic.KeyValuePair <string
                                                                  , Microsoft.Extensions.Primitives.StringValues> kvp in context.Request.Form)
                {
                    readDAL.AddParameter(cmd, kvp.Key, (string)kvp.Value);
                } // Next kvp
            }     // End if (context.Request.HasFormContentType)


            //foreach (System.Collections.Generic.KeyValuePair<string
            //       , Microsoft.Extensions.Primitives.StringValues> kvp in context.Request.Headers)
            //{
            //    readDAL.AddParameter(cmd, kvp.Key, (string)kvp.Value);
            //}
        } // End Sub ParametersToCommand
Ejemplo n.º 6
0
        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html; charset=utf-8";

            string html = @"<!DOCTYPE html>
<html xmlns=""http://www.w3.org/1999/xhtml"" lang=""en"">
<head>
    <meta http-equiv=""X-UA-Compatible"" content=""IE=edge,chrome=1"" />

    <meta http-equiv=""cache-control"" content=""max-age=0"" />
    <meta http-equiv=""cache-control"" content=""no-cache"" />
    <meta http-equiv=""expires"" content=""0"" />
    <meta http-equiv=""expires"" content=""Tue, 01 Jan 1980 1:00:00 GMT"" />
    <meta http-equiv=""pragma"" content=""no-cache"" />

    <meta charset=""utf-8"" />
    <meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />

    <meta http-equiv=""Content-Language"" content=""en"" />
    <meta name=""viewport"" content=""width=device-width,initial-scale=1"" />


    <!--
    <meta name=""author"" content=""name"" />
    <meta name=""description"" content=""description here"" />
    <meta name=""keywords"" content=""keywords,here"" />

    <link rel=""shortcut icon"" href=""favicon.ico"" type=""image/vnd.microsoft.icon"" />
    <link rel=""stylesheet"" href=""stylesheet.css"" type=""text/css"" />
    -->

    <title>Title</title>
    <style type=""text/css"" media=""all"">
        body
        {
            background-color: #0c70b4;
            color: #546775;
            font: normal 400 18px ""PT Sans"", sans-serif;
            -webkit-font-smoothing: antialiased;
        }

        .Table 
        {
            display: -webkit-box;
            display: -moz-box;
            display: box;
            display: -webkit-flex;
            display: -moz-flex;
            display: -ms-flexbox;
            display: flex;
            -webkit-flex-flow: column nowrap;
            -moz-flex-flow: column nowrap;
            flex-flow: column nowrap;
            -webkit-box-pack: justify;
            -moz-box-pack: justify;
            box-pack: justify;
            -webkit-justify-content: space-between;
            -moz-justify-content: space-between;
            -ms-justify-content: space-between;
            -o-justify-content: space-between;
            justify-content: space-between;
            -ms-flex-pack: justify;
            border: 1px solid #f2f2f2;
            font-size: 1rem;
            margin: 0.5rem;
            line-height: 1.5;
        }

        .Table-header 
        {
            display: none;
        }


        @media (min-width: 500px) 
        {

            .Table-header 
            {
            font-weight: 700;
            background-color: #f2f2f2;
            }

        }


        .Table-row 
        {
            width: 100%;
        }

        .Table-row:nth-of-type(even) 
        {
            background-color: #f2f2f2;
        }

        .Table-row:nth-of-type(odd) 
        {
            background-color: #ffffff;
        }


        @media (min-width: 500px) 
        {

            .Table-row 
            {
                display: -webkit-box;
                display: -moz-box;
                display: box;
                display: -webkit-flex;
                display: -moz-flex;
                display: -ms-flexbox;
                display: flex;
                -webkit-flex-flow: row nowrap;
                -moz-flex-flow: row nowrap;
                flex-flow: row nowrap;
            }

            .Table-row:nth-of-type(even) 
            {
                background-color: #ffffff;
            }

            .Table-row:nth-of-type(odd) 
            {
                background-color: #f2f2f2;
            }
        }


        .Table-row-item 
        {
            display: -webkit-box;
            display: -moz-box;
            display: box;
            display: -webkit-flex;
            display: -moz-flex;
            display: -ms-flexbox;
            display: flex;
            -webkit-flex-flow: row nowrap;
            -moz-flex-flow: row nowrap;
            flex-flow: row nowrap;
            -webkit-flex-grow: 1;
            -moz-flex-grow: 1;
            flex-grow: 1;
            -ms-flex-positive: 1;
            -webkit-flex-basis: 0;
            -moz-flex-basis: 0;
            flex-basis: 0;
            -ms-flex-preferred-size: 0;
            word-wrap: break-word;
            overflow-wrap: break-word;
            word-break: break-all;
            padding: 0.5em;
            word-break: break-word;
        }

        .Table-row-item:before 
        {
            content: attr(data-header);
            width: 30%;
            font-weight: 700;
        }


        @media (min-width: 500px) 
        {

            .Table-row-item 
            {
            border: 1px solid #ffffff;
            padding: 0.5em;
            }

            .Table-row-item:before 
            {
            content: none;
            }

        }

    </style>
</head>
<body>
    {@HTML}
</body>
</html>
";

            string sql = (string)context.Request.Query["sql"] ?? (string)context.Request.Form["sql"];

            sql = System.Net.WebUtility.UrlDecode(sql);
            sql = sql.Replace("\r", "").Replace("\n", System.Environment.NewLine);


            CoreDb.ReadDAL readDAL = (CoreDb.ReadDAL)context.RequestServices.GetService(
                typeof(CoreDb.ReadDAL)
                );

            readDAL.ExecuteReader(sql,
                                  delegate(System.Data.Common.DbDataReader dr)
            {
                string table = responsiveTable("foo", dr);
                html         = html.Replace("{@HTML}", table);
            }
                                  );

            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(html);
            context.Response.Body.Write(buffer, 0, buffer.Length);
        }
Ejemplo n.º 7
0
        public static TreeInfo GetAncestors()
        {
            TreeInfo ti = new TreeInfo();

            CoreDb.DalConfig config = new CoreDb.DalConfig(
                typeof(System.Data.SqlClient.SqlClientFactory)
                , delegate(CoreDb.DalConfig conf)
            {
                System.Data.SqlClient.SqlConnectionStringBuilder csb = new System.Data.SqlClient.SqlConnectionStringBuilder();

                csb.DataSource = "127.0.0.1";

                // Set during installation
                // csb.DataSource = System.Environment.GetEnvironmentVariable("COMPUTERNAME");
                // https://stackoverflow.com/questions/804700/how-to-find-fqdn-of-local-machine-in-c-net

                // https://stackoverflow.com/questions/1233217/difference-between-systeminformation-computername-environment-machinename-and
                // Environment.MachineName : NetBIOS name of local computer read from registry

                // TCP-Based network-name
                csb.DataSource = System.Net.Dns.GetHostName();


                csb.InitialCatalog     = "Ahnen";
                csb.IntegratedSecurity = true;
                if (!csb.IntegratedSecurity)
                {
                    csb.UserID   = "GenealogicalResearchWebServices";
                    csb.Password = "******";
                }

                csb.PersistSecurityInfo = false;
                csb.PacketSize          = 4096;
                csb.Pooling             = true;
                return(csb.ConnectionString);
            }
                );


            CoreDb.ReadDAL DAL = new CoreDb.ReadDAL(config);

            using (System.Data.Common.DbCommand cmd = DAL.CreateCommandFromFile(typeof(Program), "Ahnen.sql"))
            {
                ti.AllData = DAL.GetList <PersonData>(cmd);
            }

            System.Console.WriteLine(ti.AllData);

            var lsAncestorGenerations = (
                from ancestorList in ti.AllData
                orderby ancestorList.generation ascending, ancestorList.Id ascending
                group ancestorList by new { ancestorList.generation } into g
                select new
            {
                Generation = g.Key.generation,
                PresenceCount = g.Count(x => x.Id > -1)
            }
                ).ToList();


            ti.MaxGeneration = lsAncestorGenerations.Max(x => x.Generation);;
            ti.MaxPresence   = lsAncestorGenerations.Max(x => x.PresenceCount);

            System.Console.WriteLine(ti.MaxGeneration);
            System.Console.WriteLine(ti.MaxPresence);



            for (int i = 0; i < ti.MaxGeneration; ++i)
            {
                ti.ls.Add(new System.Collections.Generic.List <PersonData>());
                ti.ls[i].AddRange(
                    (
                        from ancestorList in ti.AllData
                        where ancestorList.generation == i
                        orderby
                        ancestorList.generation ascending
                        , ancestorList.Child ascending
                        , ancestorList.Id ascending
                        , ancestorList.gender descending

                        select ancestorList
                    ).ToList()
                    );
            }

            System.Console.WriteLine(ti);
            return(ti);
        }
Ejemplo n.º 8
0
        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            object parent = context.Request.Query["id"].ToString();

            string contentType = context.Request.Headers["content-type"];

            if (string.IsNullOrWhiteSpace((string)parent) &&
                "application/x-www-form-urlencoded".Equals(contentType,
                                                           System.StringComparison.InvariantCultureIgnoreCase))
            {
                if (context.Request.Form != null)
                {
                    parent = context.Request.Form["id"].ToString();
                }
            }

            if ("null".Equals((string)parent, System.StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace((string)parent))
            {
                parent = System.DBNull.Value;
            }


            string sql = @"
-- DECLARE  @__in_parent varchar(36)  
-- SET @__in_parent = 'F0000000-E000-0000-0000-000000000002'
-- -- SET @__in_parent =  'BEB6CD1D-5ACB-4FB1-93F4-A3F07A053DB7'
-- SET @__in_parent = NULL 

SELECT 
T_FMS_Navigation.NA_UID AS id 
    ,T_FMS_Navigation.NA_NA_UID AS parent 
    ,T_FMS_Translation.FT_DE AS text 
    --,T_FMS_Navigation.NA_Sort 

    ,CASE 
    WHEN EXISTS
(
    SELECT * 
    FROM T_FMS_Navigation AS Children 
    WHERE Children.NA_Status = 1 
AND Children.NA_NA_UID = T_FMS_Navigation.NA_UID 
    ) 
THEN 1 
ELSE 0 
END AS hasChildren 
    FROM T_FMS_Navigation 
    LEFT JOIN T_FMS_Translation ON T_FMS_Translation.FT_UID = T_FMS_Navigation.NA_FT_UID 
WHERE T_FMS_Navigation.NA_Status = 1 
AND 
(
    NA_NA_UID = @__in_parent 
OR 
(
    @__in_parent IS NULL 
AND 
    NA_NA_UID IS NULL 
    )
    )

ORDER BY 
-- T_FMS_Navigation.NA_Sort,
text 
";

            CoreDb.ReadDAL readDAL = (CoreDb.ReadDAL)context.RequestServices.GetService(
                typeof(CoreDb.ReadDAL)
                );


            using (System.Data.Common.DbCommand cmd = readDAL.CreateCommand(sql))
            {
                System.Data.Common.DbParameter param = cmd.CreateParameter();

                param.ParameterName = "__in_parent";
                param.DbType        = System.Data.DbType.AnsiString;
                param.Size          = 36;
                param.Value         = parent;

                cmd.Parameters.Add(param);

                using (System.Data.DataTable dt = readDAL.GetDataTable(cmd))
                {
                    // https://stackoverflow.com/questions/17154967/is-content-encoding-being-set-to-utf-8-invalid
                    // context.Response.Headers["content-encoding"] = "utf-8";
                    // context.Response.ContentType = "text/plain; charset=utf-8";
                    context.Response.StatusCode  = StatusCodes.Status200OK;
                    context.Response.ContentType = "application/json; charset=utf-8";
                    DataTableHelper.Serialize(context, dt);
                } // End Using dt
            }     // End Using cmd
        }         // End Sub ProcessRequest
Ejemplo n.º 9
0
 public HtmlTextFragment(CoreDb.ReadDAL SQL, System.Data.DataRow dr, string pSVG_UID, string pdar_uid) :
     base(SQL, dr, pSVG_UID, pdar_uid)
 {
 }
Ejemplo n.º 10
0
        } // End Sub Test

        public static string Test(CoreDb.ReadDAL SQL, string svg_uid, string dar_uid, string legend)
        {
            //  -- TRUNCATE TABLE T_VWS_PdfLegende
            string strSQL = @"
DECLARE @in_sprache varchar(3) 
SET @in_sprache = 'DE'


SELECT 
	 T_VWS_Ref_PaperSize.PS_Width_mm
	,T_VWS_Ref_PaperSize.PS_Height_mm
	 
	,T_VWS_PdfLegende.PL_UID
	,T_VWS_PdfLegende.PL_PLK_UID
	,T_VWS_PdfLegende.PL_Type
	,T_VWS_PdfLegende.PL_Format

	,T_VWS_PdfLegende.PL_X
	,T_VWS_PdfLegende.PL_Y
	,T_VWS_PdfLegende.PL_W
	,T_VWS_PdfLegende.PL_H

	,T_VWS_PdfLegende.PL_Angle
	,T_VWS_PdfLegende.PL_AspectRatio
	,T_VWS_PdfLegende.PL_AlignH
	,T_VWS_PdfLegende.PL_AlignV
	 
	,
	CASE @in_sprache
		WHEN 'FR' THEN T_VWS_PdfLegende.PL_Text_FR
		WHEN 'IT' THEN T_VWS_PdfLegende.PL_Text_IT
		WHEN 'EN' THEN T_VWS_PdfLegende.PL_Text_EN
		ELSE T_VWS_PdfLegende.PL_Text_DE
	END AS PL_Text 
	
	,T_VWS_PdfLegende.PL_Outline
	,T_VWS_PdfLegende.PL_Style
	,T_VWS_PdfLegende.PL_DataBind

	,
	CASE 
		WHEN T_VWS_PdfLegende.PL_Type = 'rectangle' THEN 1 
		WHEN T_VWS_PdfLegende.PL_Type = 'legend' THEN 2 
		WHEN T_VWS_PdfLegende.PL_Type = 'image' THEN 3 
		WHEN T_VWS_PdfLegende.PL_Type = 'text' THEN 4 
		ELSE NULL
	END AS RPT_TypeSort 

	,100 + ROW_NUMBER() OVER 
    (
         ORDER BY 
		 ISNULL(T_VWS_PdfLegende.PL_Sort, 666666666) 
		,CASE 
			WHEN T_VWS_PdfLegende.PL_Type = 'rectangle' THEN 1 
			WHEN T_VWS_PdfLegende.PL_Type = 'legend' THEN 2 
			WHEN T_VWS_PdfLegende.PL_Type = 'image' THEN 3 
			WHEN T_VWS_PdfLegende.PL_Type = 'text' THEN 4 
			ELSE NULL 
		END 
		,T_VWS_PdfLegende.PL_Type 
    ) AS PL_Sort 
    
    --,T_VWS_Ref_PdfLegendenKategorie.* 
FROM T_VWS_Ref_PdfLegendenKategorie 

LEFT JOIN T_VWS_Ref_PaperSize 
	ON T_VWS_Ref_PaperSize.PS_UID = T_VWS_Ref_PdfLegendenKategorie.PLK_PS_UID 
    
LEFT JOIN T_VWS_PdfLegende 
	ON T_VWS_PdfLegende.PL_PLK_UID = T_VWS_Ref_PdfLegendenKategorie.PLK_UID 
    
WHERE T_VWS_Ref_PdfLegendenKategorie.PLK_DAR_UID IS NULL 
AND T_VWS_Ref_PdfLegendenKategorie.PLK_IsDefault = 1 

ORDER BY 
	 PL_Sort 
";


            System.Data.DataTable dt = SQL.GetDataTable(strSQL);
            System.Collections.Generic.List <DrawingControl> ls = new System.Collections.Generic.List <DrawingControl>();
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                string pl_type = System.Convert.ToString(dr["PL_Type"]);

                if ("image".Equals(pl_type, System.StringComparison.InvariantCultureIgnoreCase))
                {
                    ls.Add(new ImageFragment(SQL, dr, svg_uid, dar_uid));
                }
                else if ("text".Equals(pl_type, System.StringComparison.InvariantCultureIgnoreCase))
                {
                    ls.Add(new PlainTextFragment(SQL, dr, svg_uid, dar_uid));
                }
                else if ("legend".Equals(pl_type, System.StringComparison.InvariantCultureIgnoreCase))
                {
                    ls.Add(new LegendFragment(SQL, dr, svg_uid, dar_uid, legend));
                }
                else if ("rectangle".Equals(pl_type, System.StringComparison.InvariantCultureIgnoreCase))
                {
                    ls.Add(new RectangleFragment(SQL, dr, svg_uid, dar_uid));
                }
                else
                {
                    throw new System.NotSupportedException(("type \""
                                                            + (pl_type + "\" is not supported in legend ")));
                }
            } // Next dr


            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            foreach (DrawingControl thisControl in ls)
            {
                sb.AppendLine(thisControl.RenderFragment());
            } // Next thisControl

            sb.Insert(0, @"
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv=""X-UA-Compatible"" content=""IE=edge,chrome=1"" />
    <meta http-equiv=""Content-Type"" content=""text/html;charset=utf-8"" />
    <meta charset=""utf-8"" />

    <meta http-equiv=""cache-control"" content=""max-age=0"" />
    <meta http-equiv=""cache-control"" content=""no-cache"" />
    <meta http-equiv=""expires"" content=""0"" />
    <meta http-equiv=""expires"" content=""Tue, 01 Jan 1980 1:00:00 GMT"" />
    <meta http-equiv=""pragma"" content=""no-cache"" />

    <title>Legende</title>

    <meta name=""viewport"" content=""width=device-width, initial-scale=1.00, minimum-scale=0.00, maximum-scale=10.00, user-scalable=yes"" />

    <style type=""text/css"">
        
        *
        {
            margin: 0px;
            padding: 0px;
            box-sizing: border-box;
            #white-space-collapse: discard;
        }

        body 
        {
            width: 84.1cm;
            height: 118.9cm;
            background-color: lightgrey; 
            background-color: white; 
            z-index: 999999; 
            position:relative;

            font-family: Arial;
            font-size: 11px;
            height: 12.4px;
        }

    </style>

    <script>

    </script>

</head>
<body>
");
            sb.AppendLine(@"</body>
</ html > ");

            string html = sb.ToString();

            sb.Clear();
            sb = null;

            return(html);
        } // End Sub Test
Ejemplo n.º 11
0
 public static string Test(CoreDb.ReadDAL SQL)
 {
     return(Test(SQL, "6B360D55-901D-487F-AF4A-189BC0906E5B", "71C16DAD-DADB-4BA2-A380-7ED3029DEEE0", ""));
 } // End Sub Test
Ejemplo n.º 12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAuthentication(AuthTest.JwtAuthentication.SetCookieSchemes)
            .AddCookie(AuthTest.JwtAuthentication.SetupCookie)
            // .AddJwtBearer(AuthTest.JwtAuthentication.SetupBearer)
            ;

            /*
             * services.AddAntiforgery(
             *  delegate (Microsoft.AspNetCore.Antiforgery.AntiforgeryOptions options)
             *  {
             *       // https://damienbod.com/2017/05/09/anti-forgery-validation-with-asp-net-core-mvc-and-angular/
             *       options.HeaderName = "X-XSRF-TOKEN";
             *       //options.CookieDomain = "localhost";
             *       options.Cookie.Name = "XSRF";
             *  }
             * );
             */
            // services.AddMvc();

            // https://geeks.ms/clanderas/2016/10/18/asp-net-core-node-services-to-execute-your-nodejs-scripts/
            // https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/
            services.AddNodeServices(options => {
                // options.DebuggingPort
            });

            services.AddRouting(delegate(Microsoft.AspNetCore.Routing.RouteOptions options)
                                { });


            services.AddMvc(

                /*
                 * delegate (Microsoft.AspNetCore.Mvc.MvcOptions config)
                 * {
                 *  Microsoft.AspNetCore.Authorization.AuthorizationPolicy policy =
                 *      new Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder()
                 *                   .RequireAuthenticatedUser()
                 *                   // .AddRequirements( new NoBannedIPsRequirement(new HashSet<string>() { "127.0.0.1", "0.0.0.1" } ))
                 *                   .Build();
                 *
                 *  config.Filters.Add(new Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter(policy));
                 * }
                 */
                )
            .AddJsonOptions(options =>
            {
#if DEBUG
                options.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
#else
                options.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.None;
#endif
            });


            services.Configure <Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions>(options =>
            {
                options.ViewLocationExpanders.Add(new CoreCMS.Routing.SubdomainViewLocationExpander());
            });



            Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions
            .Configure <ConfigData.SmtpConfig>(services, Configuration.GetSection("Smtp"));


            /*
             * Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions
             *  .Configure<Dictionary<string, ConfigData.cConnectionString>>(services
             *  , Configuration.GetSection("ConnectionStrings")
             * );
             *
             * Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions
             *  .Configure<ConfigData.cConnectionStrings>(services
             *      , Configuration.GetSection("DataBase"));
             *
             * string foo = Configuration.GetValue<string>("data:userID");
             * System.Console.WriteLine(foo);
             * // https://msdn.microsoft.com/en-us/magazine/mt632279.aspx
             */

            ConfigData.Databases dbs = Configuration.Get <ConfigData.Databases>();

            // System.Console.WriteLine(cs);
            // services.AddSingleton<ConfigData.Database>(cs);

            DbConfig dbConfig = null;

            if (dbs.ConnectionStrings.ContainsKey(System.Environment.MachineName))
            {
                dbConfig = dbs.ConnectionStrings[System.Environment.MachineName];
            }


            if (dbConfig == null)
            {
                if (dbs.ConnectionStrings.ContainsKey("server"))
                {
                    dbConfig = dbs.ConnectionStrings["server"];
                }
            }


            if (dbConfig == null)
            {
                throw new System.IO.InvalidDataException("Connection string not configured...");
            }


            CoreDb.DalConfig dalConfig =
                new CoreDb.DalConfig(dbConfig.ProviderName, dbConfig.ConnectionString);

            CoreDb.ReadDAL  readData  = new CoreDb.ReadDAL(dalConfig);
            CoreDb.WriteDAL writeData = new CoreDb.WriteDAL(dalConfig);

            services.AddSingleton <CoreDb.ReadDAL>(readData);
            services.AddSingleton <CoreDb.WriteDAL>(writeData);
        }