Exemplo n.º 1
0
        public static string Start(string AReportID, System.Data.DataTable AParameters)
        {
            string session        = TSession.GetSessionID();
            string configfilename = TAppSettingsManager.ConfigFileName;

            TParameterList ParameterList = new TParameterList();

            ParameterList.LoadFromDataTable(AParameters);

            String PathStandardReports = TAppSettingsManager.GetValue("Reporting.PathStandardReports");
            String PathCustomReports   = TAppSettingsManager.GetValue("Reporting.PathCustomReports");

            TRptDataCalculator Datacalculator = new TRptDataCalculator(PathStandardReports, PathCustomReports);

            ThreadStart myThreadStart = delegate {
                Run(configfilename, session, AReportID, Datacalculator, ParameterList);
            };
            Thread TheThread = new Thread(myThreadStart);

            TheThread.CurrentCulture = Thread.CurrentThread.CurrentCulture;
            TheThread.Name           = AReportID + "_" + UserInfo.GetUserInfo().UserID + "__TReportGeneratorUIConnector.Start_Thread";
            TLogging.LogAtLevel(7, TheThread.Name + " starting.");
            TheThread.Start();

            return(AReportID);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates the report, which is specified in the parameters table
        ///
        /// </summary>
        /// <returns>void</returns>
        public void Start(System.Data.DataTable AParameters)
        {
            FProgressID = "ReportCalculation" + Guid.NewGuid();
            TProgressTracker.InitProgressTracker(FProgressID, string.Empty, -1.0m);

            FParameterList = new TParameterList();
            FParameterList.LoadFromDataTable(AParameters);

            FSuccess = false;

            String PathStandardReports = TAppSettingsManager.GetValue("Reporting.PathStandardReports");
            String PathCustomReports   = TAppSettingsManager.GetValue("Reporting.PathCustomReports");

            FDatacalculator = new TRptDataCalculator(PathStandardReports, PathCustomReports);

            // setup the logging to go to the TProgressTracker
            TLogging.SetStatusBarProcedure(new TLogging.TStatusCallbackProcedure(WriteToStatusBar));

            string      session       = TSession.GetSessionID();
            ThreadStart myThreadStart = delegate {
                Run(session);
            };
            Thread TheThread = new Thread(myThreadStart);

            TheThread.CurrentCulture = Thread.CurrentThread.CurrentCulture;
            TheThread.Name           = FProgressID + "_" + UserInfo.GetUserInfo().UserID + "__TReportGeneratorUIConnector.Start_Thread";
            TLogging.LogAtLevel(7, TheThread.Name + " starting.");
            TheThread.Start();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Calculates the report, which is specified in the parameters table
        ///
        /// </summary>
        /// <returns>void</returns>
        public void Start(System.Data.DataTable AParameters)
        {
            TRptUserFunctionsFinance.FlushSqlCache();
            FProgressID = "ReportCalculation" + Guid.NewGuid();
            TProgressTracker.InitProgressTracker(FProgressID, string.Empty, -1.0m);
            FParameterList = new TParameterList();
            FParameterList.LoadFromDataTable(AParameters);
            FSuccess = false;
            String PathStandardReports = TAppSettingsManager.GetValue("Reporting.PathStandardReports");
            String PathCustomReports   = TAppSettingsManager.GetValue("Reporting.PathCustomReports");

            FDatacalculator = new TRptDataCalculator(DBAccess.GDBAccessObj, PathStandardReports, PathCustomReports);

            // setup the logging to go to the TProgressTracker
            TLogging.SetStatusBarProcedure(new TLogging.TStatusCallbackProcedure(WriteToStatusBar));
            string      session       = TSession.GetSessionID();
            ThreadStart myThreadStart = delegate {
                Run(session);
            };
            Thread TheThread = new Thread(myThreadStart);

            TheThread.Name           = FProgressID;
            TheThread.CurrentCulture = Thread.CurrentThread.CurrentCulture;
            TheThread.Start();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Calculates the report, which is specified in the parameters table
        ///
        /// </summary>
        /// <returns>void</returns>
        public void Start(System.Data.DataTable AParameters)
        {
            FProgressID = "ReportCalculation" + Guid.NewGuid();
            TProgressTracker.InitProgressTracker(FProgressID, string.Empty, -1.0m);

            // First check whether the 'globally available' DB Connection isn't busy - we must not allow the start of a
            // Report Calculation when that is the case (as this would lead to a nested DB Transaction exception,
            // EDBTransactionBusyException).
            if (DBAccess.GDBAccessObj.Transaction != null)
            {
                FErrorMessage = Catalog.GetString(SharedConstants.NO_PARALLEL_EXECUTION_OF_XML_REPORTS_PREFIX +
                                                  "The OpenPetra Server is currently too busy to prepare this Report. " +
                                                  "Please retry once other running tasks (eg. a Report) are finished!");
                TProgressTracker.FinishJob(FProgressID);
                FSuccess = false;

                // Return to the Client immediately!
                return;
            }

            TRptUserFunctionsFinance.FlushSqlCache();

            FParameterList = new TParameterList();
            FParameterList.LoadFromDataTable(AParameters);

            FSuccess = false;

            String PathStandardReports = TAppSettingsManager.GetValue("Reporting.PathStandardReports");
            String PathCustomReports   = TAppSettingsManager.GetValue("Reporting.PathCustomReports");

            FDatacalculator = new TRptDataCalculator(DBAccess.GDBAccessObj, PathStandardReports, PathCustomReports);

            // setup the logging to go to the TProgressTracker
            TLogging.SetStatusBarProcedure(new TLogging.TStatusCallbackProcedure(WriteToStatusBar));

            string      session       = TSession.GetSessionID();
            ThreadStart myThreadStart = delegate {
                Run(session);
            };
            Thread TheThread = new Thread(myThreadStart);

            TheThread.CurrentCulture = Thread.CurrentThread.CurrentCulture;
            TheThread.Name           = FProgressID + "_" + UserInfo.GUserInfo.UserID + "__TReportGeneratorUIConnector.Start_Thread";
            TLogging.LogAtLevel(7, TheThread.Name + " starting.");
            TheThread.Start();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Calculates the report, which is specified in the parameters table
        ///
        /// </summary>
        /// <returns>void</returns>
        public void Start(System.Data.DataTable AParameters)
        {
            TRptUserFunctionsFinance.FlushSqlCache();
            this.FAsyncExecProgress = new TAsynchronousExecutionProgress();
            this.FAsyncExecProgress.ProgressState = TAsyncExecProgressState.Aeps_Executing;
            FParameterList = new TParameterList();
            FParameterList.LoadFromDataTable(AParameters);
            FSuccess = false;
            String PathStandardReports = TAppSettingsManager.GetValue("Reporting.PathStandardReports");
            String PathCustomReports   = TAppSettingsManager.GetValue("Reporting.PathCustomReports");

            FDatacalculator = new TRptDataCalculator(DBAccess.GDBAccessObj, PathStandardReports, PathCustomReports);

            // setup the logging to go to the FAsyncExecProgress.ProgressInformation
            TLogging.SetStatusBarProcedure(new TLogging.TStatusCallbackProcedure(WriteToStatusBar));
            Thread TheThread = new Thread(new ThreadStart(Run));

            TheThread.CurrentCulture = Thread.CurrentThread.CurrentCulture;
            TheThread.Start();
        }
Exemplo n.º 6
0
        /// <summary>
        /// run the report
        /// </summary>
        private static void Run(string AConfigFileName, string ASessionID, string AReportID, TRptDataCalculator ADatacalculator, TParameterList AParameterList)
        {
            // need to initialize the database session
            TSession.InitThread("Reporting Webconnector", AConfigFileName, ASessionID);

            TDataBase db = DBAccess.Connect("TReportGeneratorWebConnector");

            TDBTransaction Transaction  = new TDBTransaction();
            bool           Success      = false;
            bool           Submit       = true;
            string         HTMLOutput   = String.Empty;
            HtmlDocument   HTMLDocument = new HtmlDocument();
            string         ErrorMessage = String.Empty;

            try
            {
                db.ReadTransaction(ref Transaction,
                                   delegate
                {
                    Exception myException = null;
                    if (ADatacalculator.GenerateResult(ref AParameterList, ref HTMLOutput, out HTMLDocument, ref ErrorMessage, ref myException, Transaction))
                    {
                        Success = true;
                    }
                    else
                    {
                        TLogging.Log(ErrorMessage);
                    }
                });
            }
            catch (Exception Exc)
            {
                TLogging.Log("Problem calculating report: " + Exc.ToString());
                TLogging.Log(Exc.StackTrace, TLoggingType.ToLogfile);

                Success      = false;
                ErrorMessage = Exc.Message;
            }

/*
 *          if (TDBExceptionHelper.IsTransactionSerialisationException(FException))
 *          {
 *              // do nothing - we want this exception to bubble up
 *          }
 *          else if (FException is Exception && FException.InnerException is EOPDBException)
 *          {
 *              EOPDBException DbExc = (EOPDBException)FException.InnerException;
 *
 *              if (DbExc.InnerException is Exception)
 *              {
 *                  if (DbExc.InnerException is PostgresException)
 *                  {
 *                      PostgresException PgExc = (PostgresException)DbExc.InnerException;
 *
 *                      if (PgExc.SqlState == "57014") // SQL statement timeout problem
 *                      {
 *                          FErrorMessage = Catalog.GetString(
 *                              "Error - Database took too long to respond. Try different parameters to return fewer results.");
 *                      }
 *                  }
 *                  else
 *                  {
 *                      FErrorMessage = DbExc.InnerException.Message;
 *                  }
 *
 *                  FException = null;
 *              }
 *          }
 */

            try
            {
                // store the report result
                db.WriteTransaction(ref Transaction,
                                    ref Submit,
                                    delegate
                {
                    // delete report results that are expired.
                    string sql = "DELETE FROM PUB_s_report_result WHERE s_valid_until_d < NOW()";
                    db.ExecuteNonQuery(sql, Transaction);

                    // TODO: only keep maximum of 10 report results per user (s_created_by_c)

                    // store success, store parameter list, store html document
                    SReportResultTable table = new SReportResultTable();
                    SReportResultRow row     = table.NewRowTyped();
                    row.ReportId             = AReportID;
                    row.SessionId            = TSession.GetSessionID();
                    row.ValidUntil           = DateTime.Now.AddHours(12);
                    row.ParameterList        = AParameterList.ToJson();
                    row.ResultHtml           = HTMLOutput;
                    row.Success      = Success;
                    row.ErrorMessage = ErrorMessage;
                    table.Rows.Add(row);
                    SReportResultAccess.SubmitChanges(table, Transaction);
                    Submit = true;
                });
            }
            catch (Exception Exc)
            {
                TLogging.Log("Problem storing report result: " + Exc.ToString());
                TLogging.Log(Exc.StackTrace, TLoggingType.ToLogfile);

                Success      = false;
                ErrorMessage = Exc.Message;
            }

            db.CloseDBConnection();

            TProgressTracker.FinishJob(AReportID);
        }