Exemple #1
0
        public static SReportTemplateTable GetTemplateVariants(String AReportType, String AAuthor, Boolean ADefaultOnly = false)
        {
            LoadTemplatesFromBackupFile(AReportType);
            SReportTemplateTable Tbl         = new SReportTemplateTable();
            SReportTemplateRow   TemplateRow = Tbl.NewRowTyped(false);

            TemplateRow.ReportType = AReportType;
            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                      TEnforceIsolationLevel.eilMinimum,
                                                                      ref Transaction,
                                                                      delegate
            {
                Tbl = SReportTemplateAccess.LoadUsingTemplate(TemplateRow, Transaction);
            });

            String filter = String.Format("(s_author_c ='{0}' OR s_private_l=false)", AAuthor);

            if (ADefaultOnly)
            {
                filter += " AND (s_default_l=true OR s_private_default_l=true)";
            }

            Tbl.DefaultView.RowFilter = filter;
            Tbl.DefaultView.Sort      =
                (ADefaultOnly) ? "s_private_default_l DESC, s_default_l DESC" : "s_readonly_l DESC, s_default_l DESC, s_private_default_l DESC";

            SReportTemplateTable Ret = new SReportTemplateTable();

            Ret.Merge(Tbl.DefaultView.ToTable());
            Ret.AcceptChanges();
            return(Ret);
        }
Exemple #2
0
        public static SReportTemplateTable GetTemplateVariants(String AReportType, String AAuthor, Boolean ADefaultOnly = false)
        {
            SReportTemplateTable Tbl          = new SReportTemplateTable();
            SReportTemplateTable Ret          = new SReportTemplateTable();
            TDBTransaction       Transaction  = null;
            TDataBase            dbConnection = new TDataBase();

            try
            {
                dbConnection = TReportingDbAdapter.EstablishDBConnection(true, "GetTemplateVariants");
                LoadTemplatesFromBackupFile(AReportType, dbConnection);

                dbConnection.BeginAutoReadTransaction(
                    ref Transaction,
                    delegate
                {
                    SReportTemplateRow TemplateRow = Tbl.NewRowTyped(false);
                    TemplateRow.ReportType         = AReportType;

                    Tbl = SReportTemplateAccess.LoadUsingTemplate(TemplateRow, Transaction);
                });

                String filter = String.Format("(s_author_c ='{0}' OR s_private_l=false)", AAuthor);

                if (ADefaultOnly)
                {
                    filter += " AND (s_default_l=true OR s_private_default_l=true)";
                }

                Tbl.DefaultView.RowFilter = filter;

                if (Tbl.DefaultView.Count > 0)
                {
                    Tbl.DefaultView.Sort =
                        (ADefaultOnly) ? "s_private_default_l DESC, s_default_l DESC" :
                        "s_readonly_l DESC, s_default_l DESC, s_private_default_l DESC";
                }
                else // Something went wrong, but I'll try not to return empty-handed.
                {
                    Tbl.DefaultView.RowFilter = "";
                }

                Ret.Merge(Tbl.DefaultView.ToTable());
                Ret.AcceptChanges();
            }
            finally
            {
                dbConnection.CloseDBConnection();
            }
            return(Ret);
        }