<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace WebReportPreview
{
    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
        }
        protected void Application_Error(Object sender, EventArgs e)
        {

            // cattura l'ultimo errore verificatosi nal server
			Exception objErr = Server.GetLastError().GetBaseException();
            System.Diagnostics.Debug.WriteLine("Error DEBUG WRP: " + objErr.Message);
            // [!] todo 
            // transfer control to error page
            /*
            if ((string)Session["HandleGlobalError"] == "1")
                Server.Transfer("Errors.aspx");
             */


        }
    }
}<commit_msg>fix for report cleanup in session end<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace WebReportPreview
{
    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
        }
        protected void Application_Error(Object sender, EventArgs e)
        {

            // cattura l'ultimo errore verificatosi nal server
			Exception objErr = Server.GetLastError().GetBaseException();
            System.Diagnostics.Debug.WriteLine("Error DEBUG WRP: " + objErr.Message);
        }

        protected void Session_End(Object sender, EventArgs e)
		{
            //[!] todo: test (no in windows 10 machine)
            // 
            // Current verssion and Service Pack (SP 14) of SAP Crystal Reports, Developer Version for Visual Studio .NET do not support Windows 10 

            // Clean up report documents in sessione
            //
            try
            {
                // Test id sessione
                string id = Session.SessionID.ToString();
                // Cerco report documnent in session
                string prefixIdReportDocument = (string)Session["PrefixIdReportDocument"];
                string cleanUpRepDocEndSession = (string)Session["CleanUpRepDocEndSession"];
                if (cleanUpRepDocEndSession == "1" && prefixIdReportDocument != "")
                {
                    // se abiltato cleanup su sessione cerco i reportdocument validi e eseguo cleanup
                    for (int i = 0; i < Session.Contents.Count; i++)
                    {
                        string renamedItem;
                        renamedItem = Session.Keys[i];
                        int findPrefix = 0;
                        findPrefix = renamedItem.IndexOf(prefixIdReportDocument);
                        if (findPrefix == 0)
                        {
                            // Trovato
                            CrystalDecisions.CrystalReports.Engine.ReportDocument lReportDocument;
                            lReportDocument = (CrystalDecisions.CrystalReports.Engine.ReportDocument)Session[renamedItem];
                            if (lReportDocument != null)
                            {
                                // new:
                                WRP.Engine.CrystalReport.CloseReportDocument(lReportDocument);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string error = ex.Message;
                System.Diagnostics.Debug.WriteLine("Error DEBUG WRP - Session_End: " + error);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07962912462503409, 'fraction_numerical': 0.0029997272975184073, 'mean_word_length': 1.5686274509803921, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6850437', 'n_tokens_mistral': 905, 'n_tokens_neox': 853, 'n_words': 217}