Exemple #1
0
        /// <summary>
        /// Get the units which start with the same outreach code as given with the prefix.
        /// </summary>
        /// <param name="AUnitKey">Partner Key of the unit from which the outreach options are retrieved</param>
        /// <param name="AConferenceTable">A table with all the units</param>
        /// <returns></returns>
        private static System.Boolean GetOutreachOptions(long AUnitKey,
                                                         out System.Data.DataTable AConferenceTable)
        {
            AConferenceTable = new DataTable();
            AConferenceTable.Columns.Add("Partner Key", Type.GetType("System.Int64"));
            AConferenceTable.Columns.Add("Outreach Code");
            AConferenceTable.Columns.Add("Unit Name");

            String     ConferenceCodePrefix = "";
            PUnitTable UnitTable            = new PUnitTable();
            PUnitRow   TemplateRow          = UnitTable.NewRowTyped(false);

            TLogging.LogAtLevel(9, "TConferenceOptions.GetOutreachOptions called!");

            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(ref Transaction,
                                     delegate
            {
                /* Load data */
                UnitTable = PUnitAccess.LoadByPrimaryKey(AUnitKey, Transaction);

                if (UnitTable.Rows.Count > 0)
                {
                    ConferenceCodePrefix = ((PUnitRow)UnitTable.Rows[0]).OutreachCode.Substring(0, 5);

                    UnitTable = PUnitAccess.LoadUsingTemplate(TemplateRow, null, null, Transaction);
                }
            });

            foreach (PUnitRow UnitRow in UnitTable.Rows)
            {
                if (!UnitRow.OutreachCode.StartsWith(ConferenceCodePrefix, true, null))
                {
                    continue;
                }

                DataRow NewRow = AConferenceTable.NewRow();

                NewRow["Partner Key"]   = UnitRow.PartnerKey;
                NewRow["Outreach Code"] = UnitRow.OutreachCode;
                NewRow["Unit Name"]     = UnitRow.UnitName;

                AConferenceTable.Rows.Add(NewRow);
            }

            return(true);
        }
Exemple #2
0
        public static PUnitTable GetOutreachOptions(Int64 AUnitKey)
        {
            String         ConferenceCodePrefix = "";
            PUnitTable     UnitTable            = new PUnitTable();
            PUnitRow       TemplateRow          = UnitTable.NewRowTyped(false);
            TDBTransaction ReadTransaction;
            Boolean        NewTransaction = false;

            TLogging.LogAtLevel(9, "TConferenceOptions.GetOutreachOptions called!");

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

            ReadTransaction = db.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead,
                                                             out NewTransaction);

            try
            {
                /* Load data */
                UnitTable = PUnitAccess.LoadByPrimaryKey(AUnitKey, ReadTransaction);

                if (UnitTable.Rows.Count > 0)
                {
                    String ConferenceCode = ((PUnitRow)UnitTable.Rows[0]).OutreachCode;

                    if (ConferenceCode.Length >= 5)
                    {
                        ConferenceCodePrefix = ConferenceCode.Substring(0, 5) + "%";
                    }

                    StringCollection operators = new StringCollection();
                    operators.Add("LIKE");
                    TemplateRow.OutreachCode = ConferenceCodePrefix;

                    UnitTable = PUnitAccess.LoadUsingTemplate(TemplateRow, operators, null, ReadTransaction);
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    ReadTransaction.Commit();
                    TLogging.LogAtLevel(7, "TConferenceOptions.GetOutreachOptions: committed own transaction.");
                }
            }
            return(UnitTable);
        }
        public static PUnitTable GetOutreachOptions(Int64 AUnitKey)
        {
            String ConferenceCodePrefix = "";
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow TemplateRow = UnitTable.NewRowTyped(false);
            TDBTransaction ReadTransaction;
            Boolean NewTransaction = false;

            TLogging.LogAtLevel(9, "TConferenceOptions.GetOutreachOptions called!");

            ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead,
                TEnforceIsolationLevel.eilMinimum,
                out NewTransaction);

            try
            {
                /* Load data */
                UnitTable = PUnitAccess.LoadByPrimaryKey(AUnitKey, ReadTransaction);

                if (UnitTable.Rows.Count > 0)
                {
                    String ConferenceCode = ((PUnitRow)UnitTable.Rows[0]).OutreachCode;

                    if (ConferenceCode.Length >= 5)
                    {
                        ConferenceCodePrefix = ConferenceCode.Substring(0, 5) + "%";
                    }

                    StringCollection operators = new StringCollection();
                    operators.Add("LIKE");
                    TemplateRow.OutreachCode = ConferenceCodePrefix;

                    UnitTable = PUnitAccess.LoadUsingTemplate(TemplateRow, operators, null, ReadTransaction);
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TConferenceOptions.GetOutreachOptions: committed own transaction.");
                }
            }
            return UnitTable;
        }
        public static System.Boolean GetOutreachOptions(long AUnitKey,
            out System.Data.DataTable AConferenceTable)
        {
            AConferenceTable = new DataTable();
            AConferenceTable.Columns.Add("Partner Key", Type.GetType("System.Int64"));
            AConferenceTable.Columns.Add("Outreach Code");
            AConferenceTable.Columns.Add("Unit Name");

            String ConferenceCodePrefix = "";
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow TemplateRow = UnitTable.NewRowTyped(false);

            TLogging.LogAtLevel(9, "TConferenceOptions.GetOutreachOptions called!");

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(ref Transaction,
                delegate
                {
                    /* Load data */
                    UnitTable = PUnitAccess.LoadByPrimaryKey(AUnitKey, Transaction);

                    if (UnitTable.Rows.Count > 0)
                    {
                        ConferenceCodePrefix = ((PUnitRow)UnitTable.Rows[0]).OutreachCode.Substring(0, 5);

                        UnitTable = PUnitAccess.LoadUsingTemplate(TemplateRow, null, null, Transaction);
                    }
                });

            foreach (PUnitRow UnitRow in UnitTable.Rows)
            {
                if (!UnitRow.OutreachCode.StartsWith(ConferenceCodePrefix, true, null))
                {
                    continue;
                }

                DataRow NewRow = AConferenceTable.NewRow();

                NewRow["Partner Key"] = UnitRow.PartnerKey;
                NewRow["Outreach Code"] = UnitRow.OutreachCode;
                NewRow["Unit Name"] = UnitRow.UnitName;

                AConferenceTable.Rows.Add(NewRow);
            }

            return true;
        }