public static void CreateNewConference(long APartnerKey)
        {
            TDBTransaction        Transaction;
            PcConferenceTable     ConferenceTable;
            PUnitTable            UnitTable;
            PPartnerLocationTable PartnerLocationTable;

            Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable);

            try
            {
                ConferenceTable      = PcConferenceAccess.LoadAll(Transaction);
                UnitTable            = PUnitAccess.LoadByPrimaryKey(APartnerKey, Transaction);
                PartnerLocationTable = PPartnerLocationAccess.LoadViaPPartner(APartnerKey, Transaction);

                DateTime Start = new DateTime();
                DateTime End   = new DateTime();

                foreach (PPartnerLocationRow PartnerLocationRow in PartnerLocationTable.Rows)
                {
                    if ((PartnerLocationRow.DateEffective != null) || (PartnerLocationRow.DateGoodUntil != null))
                    {
                        if (PartnerLocationRow.DateEffective != null)
                        {
                            Start = (DateTime)PartnerLocationRow.DateEffective;
                        }

                        if (PartnerLocationRow.DateGoodUntil != null)
                        {
                            End = (DateTime)PartnerLocationRow.DateGoodUntil;
                        }

                        break;
                    }
                }

                // set column values
                PcConferenceRow AddRow = ConferenceTable.NewRowTyped();
                AddRow.ConferenceKey = APartnerKey;

                string OutreachPrefix = ((PUnitRow)UnitTable.Rows[0]).OutreachCode;

                if (OutreachPrefix.Length > 4)
                {
                    AddRow.OutreachPrefix = OutreachPrefix.Substring(0, 5);
                }
                else
                {
                    AddRow.OutreachPrefix = OutreachPrefix;
                }

                if (Start != DateTime.MinValue)
                {
                    AddRow.Start = Start;
                }

                if (End != DateTime.MinValue)
                {
                    AddRow.End = End;
                }

                string CurrencyCode = ((PUnitRow)UnitTable.Rows[0]).OutreachCostCurrencyCode;

                if (!string.IsNullOrEmpty(CurrencyCode))
                {
                    AddRow.CurrencyCode = CurrencyCode;
                }
                else
                {
                    AddRow.CurrencyCode = "USD";
                }

                // add new row to database table
                ConferenceTable.Rows.Add(AddRow);
                PcConferenceAccess.SubmitChanges(ConferenceTable, Transaction);

                DBAccess.GDBAccessObj.CommitTransaction();
                TLogging.LogAtLevel(7, "TConferenceDataReaderWebConnector.CreateNewConference: commit own transaction.");
            }
            catch (Exception Exc)
            {
                TLogging.Log("An Exception occured during the creation of a new Conference:" + Environment.NewLine + Exc.ToString());

                DBAccess.GDBAccessObj.RollbackTransaction();

                throw;
            }
        }
Ejemplo n.º 2
0
        public static SelectConferenceTDS GetConferences(String AConferenceName, String APrefix)
        {
            SelectConferenceTDS ResultTable = new SelectConferenceTDS();

            PcConferenceTable ConferenceTable = new PcConferenceTable();
            PcConferenceRow   TemplateRow     = (PcConferenceRow)ConferenceTable.NewRow();

            TDBTransaction ReadTransaction;
            Boolean        NewTransaction = false;

            if (APrefix == "*")
            {
                APrefix = "";
            }

            if (AConferenceName == "*")
            {
                AConferenceName = "";
            }
            else if (AConferenceName.EndsWith("*"))
            {
                AConferenceName = AConferenceName.Substring(0, AConferenceName.Length - 1);
            }

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

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

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

            try
            {
                /* Load data */

                if (APrefix.Length > 0)
                {
                    APrefix = APrefix.Replace('*', '%') + "%";
                    TemplateRow.OutreachPrefix = APrefix;

                    StringCollection Operators = new StringCollection();
                    Operators.Add("LIKE");

                    ConferenceTable = PcConferenceAccess.LoadUsingTemplate(TemplateRow, Operators, null, ReadTransaction);
                }
                else
                {
                    ConferenceTable = PcConferenceAccess.LoadAll(ReadTransaction);
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    ReadTransaction.Commit();
                    TLogging.LogAtLevel(7, "TConferenceOptions.GetConferences: committed own transaction.");
                }
            }

            String        ShortName;
            TPartnerClass PartnerClass;

            foreach (PcConferenceRow ConferenceRow in ConferenceTable.Rows)
            {
                TPartnerServerLookups.GetPartnerShortName(ConferenceRow.ConferenceKey, out ShortName, out PartnerClass);

                if ((AConferenceName.Length > 0) &&
                    (!ShortName.StartsWith(AConferenceName, true, null)))
                {
                    continue;
                }

                ResultTable.PcConference.ImportRow(ConferenceRow);

                DataRow NewRow = ResultTable.PPartner.NewRow();
                NewRow[PPartnerTable.GetPartnerShortNameDBName()] = ShortName;
                NewRow[PPartnerTable.GetPartnerKeyDBName()]       = ConferenceRow.ConferenceKey;

                ResultTable.PPartner.Rows.Add(NewRow);
            }

            return(ResultTable);
        }
Ejemplo n.º 3
0
        public static bool GetEarliestAndLatestDate(Int64 AConferenceKey, out DateTime AEarliestArrivalDate,
                                                    out DateTime ALatestDepartureDate, out DateTime AStartDate, out DateTime AEndDate)
        {
            AEarliestArrivalDate = DateTime.Today;
            ALatestDepartureDate = DateTime.Today;
            AStartDate           = DateTime.Today;
            AEndDate             = DateTime.Today;
            PmShortTermApplicationTable ShortTermerTable;
            PcConferenceTable           ConferenceTable;

            TDBTransaction ReadTransaction;
            Boolean        NewTransaction = false;

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

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

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

            try
            {
                /* Load data */
                if (AConferenceKey == -1)
                {
                    ShortTermerTable = PmShortTermApplicationAccess.LoadAll(ReadTransaction);
                    ConferenceTable  = PcConferenceAccess.LoadAll(ReadTransaction);
                }
                else
                {
                    ShortTermerTable = PmShortTermApplicationAccess.LoadViaPUnitStConfirmedOption(AConferenceKey, ReadTransaction);
                    ConferenceTable  = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, ReadTransaction);
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    ReadTransaction.Commit();
                    TLogging.LogAtLevel(7, "TConferenceOptions.GetEarliestAndLatestDates: committed own transaction.");
                }
            }

            DateTime TmpEarliestArrivalTime = DateTime.MaxValue;
            DateTime TmpLatestDepartureTime = DateTime.MinValue;
            DateTime TmpStartTime           = DateTime.MaxValue;
            DateTime TmpEndTime             = DateTime.MinValue;

            foreach (PmShortTermApplicationRow ShortTermerRow in ShortTermerTable.Rows)
            {
                if ((!ShortTermerRow.IsArrivalNull()) &&
                    (ShortTermerRow.Arrival < TmpEarliestArrivalTime))
                {
                    TmpEarliestArrivalTime = ShortTermerRow.Arrival.Value;
                }

                if ((!ShortTermerRow.IsDepartureNull()) &&
                    (ShortTermerRow.Departure > TmpLatestDepartureTime))
                {
                    TmpLatestDepartureTime = ShortTermerRow.Departure.Value;
                }
            }

            foreach (PcConferenceRow ConferenceRow in ConferenceTable.Rows)
            {
                if ((!ConferenceRow.IsStartNull()) &&
                    (ConferenceRow.Start.Value < TmpStartTime))
                {
                    TmpStartTime = ConferenceRow.Start.Value;
                }

                if ((!ConferenceRow.IsEndNull()) &&
                    (ConferenceRow.End.Value > TmpEndTime))
                {
                    TmpEndTime = ConferenceRow.End.Value;
                }
            }

            if (TmpEarliestArrivalTime != DateTime.MaxValue)
            {
                AEarliestArrivalDate = TmpEarliestArrivalTime;
            }

            if (TmpLatestDepartureTime != DateTime.MinValue)
            {
                ALatestDepartureDate = TmpLatestDepartureTime;
            }

            if (TmpStartTime != DateTime.MaxValue)
            {
                AStartDate = TmpStartTime;
            }

            if (TmpEndTime != DateTime.MinValue)
            {
                AEndDate = TmpEndTime;
            }

            return(true);
        }
Ejemplo n.º 4
0
        public static void CreateNewConference(long APartnerKey)
        {
            TDBTransaction Transaction  = new TDBTransaction();
            TDataBase      db           = DBAccess.Connect("CreateNewConference");
            bool           SubmissionOK = false;

            PcConferenceTable     ConferenceTable;
            PUnitTable            UnitTable;
            PPartnerLocationTable PartnerLocationTable;

            db.WriteTransaction(ref Transaction, ref SubmissionOK,
                                delegate
            {
                try
                {
                    ConferenceTable      = PcConferenceAccess.LoadAll(Transaction);
                    UnitTable            = PUnitAccess.LoadByPrimaryKey(APartnerKey, Transaction);
                    PartnerLocationTable = PPartnerLocationAccess.LoadViaPPartner(APartnerKey, Transaction);

                    DateTime Start = new DateTime();
                    DateTime End   = new DateTime();

                    foreach (PPartnerLocationRow PartnerLocationRow in PartnerLocationTable.Rows)
                    {
                        if ((PartnerLocationRow.DateEffective != null) || (PartnerLocationRow.DateGoodUntil != null))
                        {
                            if (PartnerLocationRow.DateEffective != null)
                            {
                                Start = (DateTime)PartnerLocationRow.DateEffective;
                            }

                            if (PartnerLocationRow.DateGoodUntil != null)
                            {
                                End = (DateTime)PartnerLocationRow.DateGoodUntil;
                            }

                            break;
                        }
                    }

                    // set column values
                    PcConferenceRow AddRow = ConferenceTable.NewRowTyped();
                    AddRow.ConferenceKey   = APartnerKey;

                    string OutreachPrefix = ((PUnitRow)UnitTable.Rows[0]).OutreachCode;

                    if (OutreachPrefix.Length > 4)
                    {
                        AddRow.OutreachPrefix = OutreachPrefix.Substring(0, 5);
                    }
                    else
                    {
                        AddRow.OutreachPrefix = OutreachPrefix;
                    }

                    if (Start != DateTime.MinValue)
                    {
                        AddRow.Start = Start;
                    }

                    if (End != DateTime.MinValue)
                    {
                        AddRow.End = End;
                    }

                    string CurrencyCode = ((PUnitRow)UnitTable.Rows[0]).OutreachCostCurrencyCode;

                    if (!string.IsNullOrEmpty(CurrencyCode))
                    {
                        AddRow.CurrencyCode = CurrencyCode;
                    }
                    else
                    {
                        AddRow.CurrencyCode = "USD";
                    }

                    // add new row to database table
                    ConferenceTable.Rows.Add(AddRow);
                    PcConferenceAccess.SubmitChanges(ConferenceTable, Transaction);

                    SubmissionOK = true;
                }
                catch (Exception Exc)
                {
                    TLogging.Log("An Exception occured during the creation of a new Conference:" + Environment.NewLine + Exc.ToString());
                }
            });
        }