Esempio n. 1
0
        /// <summary>
        /// run the report
        /// </summary>
        private void Run(string ASessionID)
        {
            // need to initialize the database session
            TSession.InitThread(ASessionID);
            IsolationLevel Level;

            if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "readuncommitted")
            {
                // for long reports, that should not take out locks;
                // the data does not need to be consistent or will most likely not be changed during the generation of the report
                Level = IsolationLevel.ReadUncommitted;
            }
            else if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "repeatableread")
            {
                // for financial reports: it is important to have consistent data; e.g. for totals
                Level = IsolationLevel.RepeatableRead;
            }
            else if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "serializable")
            {
                // for creating extracts: we need to write to the database
                Level = IsolationLevel.Serializable;
            }
            else
            {
                // default behaviour for normal reports
                Level = IsolationLevel.ReadCommitted;
            }

            FSuccess = false;

            TDBTransaction Transaction  = null;
            bool           SubmissionOK = false;

            try
            {
                DBAccess.GDBAccessObj.BeginAutoTransaction(Level, ref Transaction,
                                                           ref SubmissionOK,
                                                           delegate
                {
                    if (FDatacalculator.GenerateResult(ref FParameterList, ref FResultList, ref FErrorMessage))
                    {
                        FSuccess     = true;
                        SubmissionOK = true;
                    }
                    else
                    {
                        TLogging.Log(FErrorMessage);
                    }
                });
            }
            catch (Exception e)
            {
                TLogging.Log("problem calculating report: " + e.Message);
                TLogging.Log(e.StackTrace, TLoggingType.ToLogfile);
            }

            TProgressTracker.FinishJob(FProgressID);
        }
Esempio n. 2
0
        /// <summary>
        /// run the report
        /// </summary>
        private void Run()
        {
            try
            {
                if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "readuncommitted")
                {
                    // for long reports, that should not take out locks;
                    // the data does not need to be consistent or will most likely not be changed during the generation of the report
                    DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadUncommitted);
                }
                else if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "repeatableread")
                {
                    // for financial reports: it is important to have consistent data; e.g. for totals
                    DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.RepeatableRead);
                }
                else if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "serializable")
                {
                    // for creating extracts: we need to write to the database
                    DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable);
                }
                else
                {
                    // default behaviour for normal reports
                    DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);
                }

                FSuccess = false;

                if (FDatacalculator.GenerateResult(ref FParameterList, ref FResultList, ref FErrorMessage))
                {
                    FSuccess = true;
                }
                else
                {
                    TLogging.Log(FErrorMessage);
                }
            }
            catch (Exception e)
            {
                TLogging.Log("problem calculating report: " + e.Message);
                TLogging.Log(e.StackTrace, TLoggingType.ToLogfile);
            }
            DBAccess.GDBAccessObj.RollbackTransaction();
            FAsyncExecProgress.ProgressState = TAsyncExecProgressState.Aeps_Finished;
        }
Esempio n. 3
0
        /// <summary>
        /// run the report
        /// </summary>
        private void Run(string ASessionID)
        {
            // need to initialize the database session
            TSession.InitThread(ASessionID);
            IsolationLevel Level;

            if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "readuncommitted")
            {
                // for long reports, that should not take out locks;
                // the data does not need to be consistent or will most likely not be changed during the generation of the report
                Level = IsolationLevel.ReadUncommitted;
            }
            else if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "repeatableread")
            {
                // for financial reports: it is important to have consistent data; e.g. for totals
                Level = IsolationLevel.RepeatableRead;
            }
            else if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "serializable")
            {
                // for creating extracts: we need to write to the database
                Level = IsolationLevel.Serializable;
            }
            else
            {
                // default behaviour for normal reports
                Level = IsolationLevel.ReadCommitted;
            }

            FSuccess = false;

            TDBTransaction Transaction  = null;
            bool           SubmissionOK = false;

            try
            {
                DBAccess.GDBAccessObj.BeginAutoTransaction(Level, ref Transaction,
                                                           ref SubmissionOK,
                                                           delegate
                {
                    if (FDatacalculator.GenerateResult(ref FParameterList, ref FResultList, ref FErrorMessage, ref FException))
                    {
                        FSuccess     = true;
                        SubmissionOK = true;
                    }
                    else
                    {
                        TLogging.Log(FErrorMessage);
                    }
                });
            }
            catch (Exception Exc)
            {
                TLogging.Log("Problem calculating report: " + Exc.ToString());
                TLogging.Log(Exc.StackTrace, TLoggingType.ToLogfile);

                FSuccess      = false;
                FErrorMessage = Exc.Message;
                FException    = Exc;
            }

            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;
                }
            }

            TProgressTracker.FinishJob(FProgressID);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        /// <summary>
        /// run the report
        /// </summary>
        private void Run(string ASessionID)
        {
            // need to initialize the database session
            TSession.InitThread(ASessionID);
            IsolationLevel Level;

            FSuccess = false;

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

            TDBTransaction Transaction = new TDBTransaction();

            try
            {
                db.ReadTransaction(ref Transaction,
                                   delegate
                {
                    if (FDatacalculator.GenerateResult(ref FParameterList, ref FHTMLOutput, out FHTMLDocument, ref FErrorMessage, ref FException, Transaction))
                    {
                        FSuccess = true;
                    }
                    else
                    {
                        TLogging.Log(FErrorMessage);
                    }
                });
            }
            catch (Exception Exc)
            {
                TLogging.Log("Problem calculating report: " + Exc.ToString());
                TLogging.Log(Exc.StackTrace, TLoggingType.ToLogfile);

                FSuccess      = false;
                FErrorMessage = Exc.Message;
                FException    = Exc;
            }

            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;
                }
            }

            TProgressTracker.FinishJob(FProgressID);
        }