Ejemplo n.º 1
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.º 2
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