protected static FR_CAS_CGR_1400 Execute(DbConnection connection, DbTransaction transaction, P_CAS_CGR_1400 parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_CAS_CGR_1400();
            returnValue.Result = new CAS_CGR_1400();
            Thread.CurrentThread.CurrentCulture   = CultureInfo.GetCultureInfo("de-DE");
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de-DE");
            string   downloadURL    = "";
            Guid     prev_case_id   = Guid.Empty;
            DateTime DateForElastic = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local);
            var      cases          = cls_Generate_Report.Invoke(connection, transaction, new P_CAS_GR_1608()
            {
            }, securityTicket, parameter.ShowOnlyAok).Result.cases.ToList();

            List <Documents> documentList = new List <Documents>();
            if (cases.Count() > 0)
            {
                Documents documentExcel = new Documents();
                // documentExcel.documentName = "ExcelReport" + DateTime.Now.ToString("dd.MM.yyyy_HH.mm");

                if (parameter.ShowOnlyAok.HasValue)
                {
                    if (parameter.ShowOnlyAok.Value == true)
                    {
                        documentExcel.documentName = "AokReport" + DateTime.Now.ToString("dd.MM.yyyy_HH.mm");
                    }
                    else
                    {
                        documentExcel.documentName = "!AokReport" + DateTime.Now.ToString("dd.MM.yyyy_HH.mm");
                    }
                }
                else
                {
                    documentExcel.documentName = "ExcelReport" + DateTime.Now.ToString("dd.MM.yyyy_HH.mm");
                }

                documentExcel.documentOutputLocation = GenerateReportCases.CreateCaseXlsReport(cases, documentExcel.documentName);
                documentExcel.mimeType = UtilMethods.GetMimeType(documentExcel.documentOutputLocation);
                documentExcel.receiver = "MM";
                documentList.Add(documentExcel);
                foreach (var item in documentList)
                {
                    MemoryStream ms               = new MemoryStream(File.ReadAllBytes(item.documentOutputLocation));
                    byte[]       byteArrayFile    = ms.ToArray();
                    var          _providerFactory = ProviderFactory.Instance;
                    var          documentProvider = _providerFactory.CreateDocumentServiceProvider();
                    var          uploadedFrom     = HttpContext.Current.Request.UserHostAddress;
                    Guid         documentID       = documentProvider.UploadDocument(byteArrayFile, item.documentOutputLocation, securityTicket.SessionTicket, uploadedFrom);
                    downloadURL = documentProvider.GenerateDownloadLink(documentID, securityTicket.SessionTicket, true, true);


                    P_ARCH_UD_1326 parameterDoc = new P_ARCH_UD_1326();
                    parameterDoc.DocumentID   = documentID;
                    parameterDoc.Mime         = UtilMethods.GetMimeType(item.documentName + ".xlsx");
                    parameterDoc.DocumentName = item.documentName;
                    parameterDoc.DocumentDate = DateForElastic;
                    parameterDoc.Receiver     = "MM";
                    parameterDoc.Description  = "Vollständiger Bericht";
                    cls_Upload_Report.Invoke(connection, transaction, parameterDoc, securityTicket);
                }
            }

            returnValue.Result.DownloadURL = downloadURL;
            return(returnValue);

            #endregion UserCode
        }
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_CAS_CGR_1400 Invoke(DbConnection connection, DbTransaction transaction, string connectionString, P_CAS_CGR_1400 parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            var cleanupConnection  = connection == null;
            var cleanupTransaction = transaction == null;

            var functionReturn = new FR_CAS_CGR_1400();

            try
            {
                if (cleanupConnection)
                {
                    connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(connectionString);
                    connection.Open();
                }
                if (cleanupTransaction)
                {
                    transaction = connection.BeginTransaction();
                }

                functionReturn = Execute(connection, transaction, parameter, securityTicket);

                #region Cleanup Connection/Transaction
                //Commit the transaction
                if (cleanupTransaction)
                {
                    transaction.Commit();
                }
                //Close the connection
                if (cleanupConnection)
                {
                    connection.Close();
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction)
                    {
                        transaction?.Rollback();
                    }
                }
                catch
                {
                    // ignored
                }

                try
                {
                    if (cleanupConnection)
                    {
                        connection?.Close();
                    }
                }
                catch
                {
                    // ignored
                }

                throw new Exception("Exception occurred in method cls_Create_Report_for_All_Cases", ex);
            }
            return(functionReturn);
        }