コード例 #1
0
        public static DataTable GetOutreachTypes(long APartnerKey)
        {
            TDBTransaction ReadTransaction = new TDBTransaction();

            DataTable Table = new PUnitTable();

            DBAccess.ReadTransaction(ref ReadTransaction,
                                     delegate
            {
                string OutreachPrefixCode =
                    ((PcConferenceRow)PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction).Rows[0]).OutreachPrefix;

                string Query = "SELECT" +
                               " p_unit.p_partner_key_n," +
                               " SUBSTRING (p_unit.p_outreach_code_c,6,6) AS p_outreach_code_c," +
                               " p_unit.p_unit_name_c" +

                               " FROM p_unit" +

                               " WHERE LENGTH(p_unit.p_outreach_code_c) = 13" +
                               " AND SUBSTRING(p_unit.p_outreach_code_c,1,5) = '" + OutreachPrefixCode + "'";

                ReadTransaction.DataBaseObj.SelectDT(Table, Query, ReadTransaction);
            });

            return(Table);
        }
コード例 #2
0
        public static Boolean IsPUnitAConference(Int64 APartnerKey)
        {
            Boolean        NewTransaction;
            TDBTransaction ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(
                IsolationLevel.ReadCommitted,
                TEnforceIsolationLevel.eilMinimum,
                out NewTransaction);

            try
            {
                PcConferenceTable ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);

                if (ConferenceTable.Count == 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TPartnerDataReaderWebConnector.IsPUnitAConference: commit own transaction.");
                }
            }
        }
コード例 #3
0
        public static Boolean GetConferenceApplications(ref ConferenceApplicationTDS AMainDS, Int64 AConferenceKey)
        {
            // make sure outreach codes are up to date in case it has changed in Unit record
            TAttendeeManagement.RefreshOutreachCode(AConferenceKey);

            TDataBase      db = DBAccess.Connect("GetConferenceApplications");
            TDBTransaction ReadTransaction = db.BeginTransaction(IsolationLevel.ReadCommitted);

            PcConferenceTable ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, ReadTransaction);

            if (ConferenceTable.Count == 0)
            {
                ReadTransaction.Rollback();
                throw new Exception("Cannot find conference " + AConferenceKey.ToString("0000000000"));
            }

            string OutreachPrefix = ConferenceTable[0].OutreachPrefix;

            // load application data for all conference attendees from db
            TApplicationManagement.GetApplications(ref AMainDS, AConferenceKey, OutreachPrefix, "all", -1, true, null, false);

            // obtain PPartner records for all the home offices
            foreach (PcAttendeeRow AttendeeRow in AMainDS.PcAttendee.Rows)
            {
                if (AMainDS.PPartner.Rows.Find(new object[] { AttendeeRow.HomeOfficeKey }) == null)
                {
                    PPartnerAccess.LoadByPrimaryKey(AMainDS, AttendeeRow.HomeOfficeKey, ReadTransaction);
                }
            }

            ReadTransaction.Rollback();

            return(true);
        }
コード例 #4
0
        /// <summary>
        /// Refresh Outreach Code for applications and conference
        /// </summary>
        public static void RefreshOutreachCode(Int64 AConferenceKey)
        {
            TDBTransaction              Transaction  = new TDBTransaction();
            bool                        SubmissionOK = true;
            PcConferenceTable           ConferenceTable;
            PUnitTable                  UnitTable;
            PmShortTermApplicationTable ShortTermAppTable;
            ConferenceApplicationTDS    MainDS;

            DBAccess.WriteTransaction(
                ref Transaction,
                ref SubmissionOK,
                delegate
            {
                ConferenceTable   = new PcConferenceTable();
                UnitTable         = new PUnitTable();
                ShortTermAppTable = new PmShortTermApplicationTable();
                MainDS            = new ConferenceApplicationTDS();

                // get the conference in order to update the OutreachPrefix
                ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, Transaction);

                if (ConferenceTable.Count == 0)
                {
                    throw new Exception("Cannot find conference " + AConferenceKey.ToString("0000000000"));
                }

                // update OutreachPrefix in conference record in case it was changed in Unit record for event
                UnitTable = PUnitAccess.LoadByPrimaryKey(AConferenceKey, Transaction);

                if (UnitTable[0].OutreachCode.Length >= 5)
                {
                    ConferenceTable[0].OutreachPrefix = UnitTable[0].OutreachCode.Substring(0, 5);
                }
                else
                {
                    ConferenceTable[0].OutreachPrefix = UnitTable[0].OutreachCode;
                }

                MainDS.Merge(ConferenceTable);

                // update event code
                ShortTermAppTable = PmShortTermApplicationAccess.LoadViaPUnitStConfirmedOption(AConferenceKey, Transaction);

                foreach (PmShortTermApplicationRow ShortTermAppRow in ShortTermAppTable.Rows)
                {
                    ShortTermAppRow.ConfirmedOptionCode = UnitTable[0].OutreachCode;
                }

                MainDS.Merge(ShortTermAppTable);

                MainDS.ThrowAwayAfterSubmitChanges = true;

                ConferenceApplicationTDSAccess.SubmitChanges(MainDS);
            });
        }
コード例 #5
0
        public static Boolean GetCurrency(Int64 APartnerKey, out string ACurrencyCode, out string ACurrencyName)
        {
            ACurrencyCode = "";
            ACurrencyName = "";

            TDBTransaction    ReadTransaction;
            Boolean           NewTransaction;
            PcConferenceTable ConferenceTable;
            ACurrencyTable    CurrencyTable;
            Boolean           ReturnValue = false;

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

            try
            {
                ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);

                if (ConferenceTable.Rows.Count == 0)
                {
                    ReturnValue = false;
                }
                else
                {
                    ACurrencyCode = ((PcConferenceRow)ConferenceTable.Rows[0]).CurrencyCode;

                    // use the obtained currency code to retrieve the currency name
                    CurrencyTable = ACurrencyAccess.LoadByPrimaryKey(ACurrencyCode, ReadTransaction);
                    ACurrencyName = CurrencyTable[0].CurrencyName;

                    ReturnValue = true;
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.RollbackTransaction();
                    TLogging.LogAtLevel(7, "TConferenceDataReaderWebConnector.GetCurrency: rollback own transaction.");
                }
            }

            return(ReturnValue);
        }
コード例 #6
0
        public static Boolean GetConferenceApplications(ref ConferenceApplicationTDS AMainDS, Int64 AConferenceKey)
        {
            Boolean NewTransaction;

            // make sure outreach codes are up to date in case it has changed in Unit record
            TAttendeeManagement.RefreshOutreachCode(AConferenceKey);

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

            try
            {
                PcConferenceTable ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, ReadTransaction);

                if (ConferenceTable.Count == 0)
                {
                    throw new Exception("Cannot find conference " + AConferenceKey.ToString());
                }

                string OutreachPrefix = ConferenceTable[0].OutreachPrefix;

                // load application data for all conference attendees from db
                TApplicationManagement.GetApplications(ref AMainDS, AConferenceKey, OutreachPrefix, "all", -1, true, null, false);

                // obtain PPartner records for all the home offices
                foreach (PcAttendeeRow AttendeeRow in AMainDS.PcAttendee.Rows)
                {
                    if (AMainDS.PPartner.Rows.Find(new object[] { AttendeeRow.HomeOfficeKey }) == null)
                    {
                        PPartnerAccess.LoadByPrimaryKey(AMainDS, AttendeeRow.HomeOfficeKey, ReadTransaction);
                    }
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TConferenceDataReaderWebConnector.GetConferenceApplications: commit own transaction.");
                }
            }

            return(true);
        }
コード例 #7
0
        public static DateTime GetEndDate(Int64 APartnerKey)
        {
            TDBTransaction ReadTransaction = new TDBTransaction();

            PcConferenceTable ConferenceTable;
            DateTime          ConferenceEndDate = new DateTime();

            DBAccess.ReadTransaction(ref ReadTransaction,
                                     delegate
            {
                ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);

                if (((PcConferenceRow)ConferenceTable.Rows[0]).End != null)
                {
                    ConferenceEndDate = (DateTime)((PcConferenceRow)ConferenceTable.Rows[0]).End;
                }
            });

            return(ConferenceEndDate);
        }
コード例 #8
0
        public static ConferenceSetupTDS LoadConferenceSettings(long AConferenceKey, out string AConferenceName)
        {
            Boolean NewTransaction;

            ConferenceSetupTDS MainDS = new ConferenceSetupTDS();

            TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted,
                                                                                           TEnforceIsolationLevel.eilMinimum,
                                                                                           out NewTransaction);

            PPartnerLocationAccess.LoadViaPPartner(MainDS, AConferenceKey, Transaction);
            PcConferenceAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction);
            PcConferenceOptionAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction);
            PcDiscountAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction);
            PcConferenceVenueAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction);
            PUnitAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction);
            AConferenceName = PPartnerAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction).PartnerShortName;

            foreach (ConferenceSetupTDSPcConferenceVenueRow VenueRow in MainDS.PcConferenceVenue.Rows)
            {
                string        VenueName;
                TPartnerClass PartnerClass;
                MPartner.Partner.ServerLookups.WebConnectors.TPartnerServerLookups.GetPartnerShortName(VenueRow.VenueKey,
                                                                                                       out VenueName,
                                                                                                       out PartnerClass);
                VenueRow.VenueName = VenueName;
            }

            // Accept row changes here so that the Client gets 'unmodified' rows
            MainDS.AcceptChanges();

            // Remove all Tables that were not filled with data before remoting them.
            MainDS.RemoveEmptyTables();

            if (NewTransaction)
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
            }

            return(MainDS);
        }
コード例 #9
0
        public static DateTime GetEndDate(Int64 APartnerKey)
        {
            TDBTransaction ReadTransaction = null;

            PcConferenceTable ConferenceTable;
            DateTime          ConferenceEndDate = new DateTime();

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                      TEnforceIsolationLevel.eilMinimum, ref ReadTransaction,
                                                                      delegate
            {
                ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);

                if (((PcConferenceRow)ConferenceTable.Rows[0]).End != null)
                {
                    ConferenceEndDate = (DateTime)((PcConferenceRow)ConferenceTable.Rows[0]).End;
                }
            });

            return(ConferenceEndDate);
        }
コード例 #10
0
        public static DataTable GetOutreachTypes(long APartnerKey)
        {
            TDBTransaction ReadTransaction;

            ReadTransaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            DataTable Table = new PUnitTable();

            try
            {
                string OutreachPrefixCode =
                    ((PcConferenceRow)PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction).Rows[0]).OutreachPrefix;

                PUnitTable UnitTable = PUnitAccess.LoadAll(ReadTransaction);

                // add PUnit rows with matching OutreachPrefixCode to the new DataTable
                foreach (PUnitRow Row in UnitTable.Rows)
                {
                    if ((Row.OutreachCode.Length == 13) && (Row.OutreachCode.Substring(0, 5) == OutreachPrefixCode))
                    {
                        DataRow CopyRow = Table.NewRow();
                        ((PUnitRow)CopyRow).PartnerKey   = Row.PartnerKey;
                        ((PUnitRow)CopyRow).OutreachCode = Row.OutreachCode.Substring(5, 6);
                        ((PUnitRow)CopyRow).UnitName     = Row.UnitName;
                        Table.Rows.Add(CopyRow);
                    }
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
            }
            finally
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
                TLogging.LogAtLevel(7, "TConferenceDataReaderWebConnector.GetOutreachTypes: commit own transaction.");
            }

            return(Table);
        }
コード例 #11
0
        public static ConferenceSetupTDS LoadConferenceSettings(long AConferenceKey, out string AConferenceName)
        {
            ConferenceSetupTDS MainDS         = new ConferenceSetupTDS();
            string             ConferenceName = null;

            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(
                ref Transaction,
                delegate
            {
                PPartnerLocationAccess.LoadViaPPartner(MainDS, AConferenceKey, Transaction);
                PcConferenceAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction);
                PcConferenceOptionAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction);
                PcDiscountAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction);
                PcConferenceVenueAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction);
                PUnitAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction);
                ConferenceName = PPartnerAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction).PartnerShortName;
            });

            foreach (ConferenceSetupTDSPcConferenceVenueRow VenueRow in MainDS.PcConferenceVenue.Rows)
            {
                string        VenueName;
                TPartnerClass PartnerClass;
                MPartner.Partner.ServerLookups.WebConnectors.TPartnerServerLookups.GetPartnerShortName(VenueRow.VenueKey,
                                                                                                       out VenueName,
                                                                                                       out PartnerClass);
                VenueRow.VenueName = VenueName;
            }

            // Accept row changes here so that the Client gets 'unmodified' rows
            MainDS.AcceptChanges();

            // Remove all Tables that were not filled with data before remoting them.
            MainDS.RemoveEmptyTables();

            AConferenceName = ConferenceName;

            return(MainDS);
        }
コード例 #12
0
        public static Boolean IsPUnitAConference(Int64 APartnerKey)
        {
            Boolean        ReturnValue = false;
            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                           ref Transaction,
                                                           delegate
            {
                PcConferenceTable ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(APartnerKey, Transaction);

                if (ConferenceTable.Count == 0)
                {
                    ReturnValue = false;
                }
                else
                {
                    ReturnValue = true;
                }
            });

            return(ReturnValue);
        }
コード例 #13
0
        public static Boolean IsPUnitAConference(Int64 APartnerKey)
        {
            Boolean        ReturnValue = false;
            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(
                ref Transaction,
                delegate
            {
                PcConferenceTable ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(APartnerKey, Transaction);

                if (ConferenceTable.Count == 0)
                {
                    ReturnValue = false;
                }
                else
                {
                    ReturnValue = true;
                }
            });

            return(ReturnValue);
        }
コード例 #14
0
        public static Boolean GetCurrency(Int64 APartnerKey, out string ACurrencyCode, out string ACurrencyName)
        {
            TDBTransaction ReadTransaction = null;

            PcConferenceTable ConferenceTable;
            ACurrencyTable    CurrencyTable;
            Boolean           ReturnValue  = false;
            string            CurrencyCode = string.Empty;
            string            CurrencyName = string.Empty;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                      TEnforceIsolationLevel.eilMinimum, ref ReadTransaction,
                                                                      delegate
            {
                ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);

                if (ConferenceTable.Rows.Count == 0)
                {
                    ReturnValue = false;
                }
                else
                {
                    CurrencyCode = ((PcConferenceRow)ConferenceTable.Rows[0]).CurrencyCode;

                    // use the obtained currency code to retrieve the currency name
                    CurrencyTable = ACurrencyAccess.LoadByPrimaryKey(CurrencyCode, ReadTransaction);
                    CurrencyName  = CurrencyTable[0].CurrencyName;

                    ReturnValue = true;
                }
            });

            ACurrencyCode = CurrencyCode;
            ACurrencyName = CurrencyName;

            return(ReturnValue);
        }
コード例 #15
0
        public static Boolean GetCurrency(Int64 APartnerKey, out string ACurrencyCode, out string ACurrencyName)
        {
            TDBTransaction ReadTransaction = new TDBTransaction();

            PcConferenceTable ConferenceTable;
            ACurrencyTable    CurrencyTable;
            Boolean           ReturnValue  = false;
            string            CurrencyCode = string.Empty;
            string            CurrencyName = string.Empty;

            DBAccess.ReadTransaction(ref ReadTransaction,
                                     delegate
            {
                ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);

                if (ConferenceTable.Rows.Count == 0)
                {
                    ReturnValue = false;
                }
                else
                {
                    CurrencyCode = ((PcConferenceRow)ConferenceTable.Rows[0]).CurrencyCode;

                    // use the obtained currency code to retrieve the currency name
                    CurrencyTable = ACurrencyAccess.LoadByPrimaryKey(CurrencyCode, ReadTransaction);
                    CurrencyName  = CurrencyTable[0].CurrencyName;

                    ReturnValue = true;
                }
            });

            ACurrencyCode = CurrencyCode;
            ACurrencyName = CurrencyName;

            return(ReturnValue);
        }
コード例 #16
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);
        }
コード例 #17
0
        /// <summary>
        /// Load/Refresh all Attendees for a conference
        /// </summary>
        public static void RefreshAttendees(Int64 AConferenceKey)
        {
            TDBTransaction           Transaction  = new TDBTransaction();
            bool                     SubmissionOK = true;
            PcConferenceTable        ConferenceTable;
            PUnitTable               UnitTable;
            string                   OutreachPrefix = String.Empty;
            ConferenceApplicationTDS MainDS;

            // make sure outreach codes are up to date in case it has changed in Unit record
            RefreshOutreachCode(AConferenceKey);

            DBAccess.WriteTransaction(
                ref Transaction,
                ref SubmissionOK,
                delegate
            {
                ConferenceTable = new PcConferenceTable();
                UnitTable       = new PUnitTable();
                MainDS          = new ConferenceApplicationTDS();

                // get the conference prefix which links all outreaches associated with a conference
                ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, Transaction);

                if (ConferenceTable.Count == 0)
                {
                    throw new Exception("Cannot find conference " + AConferenceKey.ToString("0000000000"));
                }

                OutreachPrefix = ConferenceTable[0].OutreachPrefix;

                // load application data for all conference attendees from db
                TApplicationManagement.GetApplications(ref MainDS, AConferenceKey, OutreachPrefix, "all", -1, true, null, false);

                // check a valid pcattendee record exists for each short term application
                foreach (PmShortTermApplicationRow ShortTermAppRow in MainDS.PmShortTermApplication.Rows)
                {
                    if (!IsAttendeeValid(MainDS, OutreachPrefix, ShortTermAppRow.PartnerKey))
                    {
                        // ignore deleted applications, or cancelled applications
                        continue;
                    }

                    // update outreach code in application (it may have changed)
                    UnitTable = PUnitAccess.LoadByPrimaryKey(ShortTermAppRow.StConfirmedOption, Transaction);
                    ShortTermAppRow.ConfirmedOptionCode = ((PUnitRow)UnitTable.Rows[0]).OutreachCode;

                    // Do we have a record for this attendee yet?
                    bool AttendeeRecordExists = false;

                    if (MainDS.PcAttendee.Rows.Contains(new object[] { AConferenceKey, ShortTermAppRow.PartnerKey }))
                    {
                        AttendeeRecordExists = true;
                    }

                    // create a new PcAttendee record if one does not already exist for this attendee
                    if (!AttendeeRecordExists)
                    {
                        PcAttendeeRow AttendeeRow = MainDS.PcAttendee.NewRowTyped();

                        AttendeeRow.ConferenceKey = AConferenceKey;
                        AttendeeRow.PartnerKey    = ShortTermAppRow.PartnerKey;

                        if (ShortTermAppRow.ConfirmedOptionCode.Length >= 11)
                        {
                            AttendeeRow.OutreachType = ShortTermAppRow.ConfirmedOptionCode.Substring(5, 6);
                        }

                        PmGeneralApplicationRow GeneralAppRow = (PmGeneralApplicationRow)MainDS.PmGeneralApplication.Rows.Find(
                            new object[] { ShortTermAppRow.PartnerKey, ShortTermAppRow.ApplicationKey, ShortTermAppRow.RegistrationOffice });

                        DateTime DateAccepted = GeneralAppRow.GenAppDate;

                        if (!GeneralAppRow.IsGenAppSendFldAcceptDateNull())
                        {
                            DateAccepted = GeneralAppRow.GenAppSendFldAcceptDate.Value;
                        }
                        else if (!GeneralAppRow.IsGenAppRecvgFldAcceptNull())
                        {
                            DateAccepted = GeneralAppRow.GenAppRecvgFldAccept.Value;
                        }

                        AttendeeRow.Registered = DateAccepted;

                        // TODO: in Petra 2.x, this was calculated from pm_staff_data
                        AttendeeRow.HomeOfficeKey = ShortTermAppRow.RegistrationOffice;

                        if (AttendeeRow.HomeOfficeKey == 0)
                        {
                            AttendeeRow.HomeOfficeKey = ((int)AttendeeRow.PartnerKey / 1000000) * 1000000;
                        }

                        MainDS.PcAttendee.Rows.Add(AttendeeRow);
                    }
                }

                PcRoomAllocTable RoomAllocTable = null;
                PcExtraCostTable ExtraCostTable = null;

                // now check the other way: all attendees of this conference, are they still valid?
                foreach (PcAttendeeRow AttendeeRow in MainDS.PcAttendee.Rows)
                {
                    if ((AttendeeRow.RowState != DataRowState.Added) &&
                        !IsAttendeeValid(MainDS, OutreachPrefix, AttendeeRow.PartnerKey))
                    {
                        // remove their accommodation
                        RoomAllocTable = PcRoomAllocAccess.LoadViaPcAttendee(AttendeeRow.ConferenceKey, AttendeeRow.PartnerKey, Transaction);

                        foreach (DataRow Row in RoomAllocTable.Rows)
                        {
                            Row.Delete();
                        }

                        if (RoomAllocTable != null)
                        {
                            PcRoomAllocAccess.SubmitChanges(RoomAllocTable, Transaction);
                        }

                        // remove any extra costs
                        ExtraCostTable = PcExtraCostAccess.LoadViaPcAttendee(AttendeeRow.ConferenceKey, AttendeeRow.PartnerKey, Transaction);

                        foreach (DataRow Row in ExtraCostTable.Rows)
                        {
                            Row.Delete();
                        }

                        if (ExtraCostTable != null)
                        {
                            PcExtraCostAccess.SubmitChanges(ExtraCostTable, Transaction);
                        }

                        // remove attendee
                        AttendeeRow.Delete();
                    }
                }

                int shorttermApplicationsCount = MainDS.PmShortTermApplication.Count;
                int attendeeCount = MainDS.PcAttendee.Count;

                MainDS.ThrowAwayAfterSubmitChanges = true;

                ConferenceApplicationTDSAccess.SubmitChanges(MainDS);
            });
        }
コード例 #18
0
        /// <summary>
        /// generate the applications
        /// </summary>
        public static void GenerateApplications(string AApplicationCSVFile)
        {
            XmlDocument doc = TCsv2Xml.ParseCSV2Xml(AApplicationCSVFile, ",", Encoding.UTF8);

            XmlNode RecordNode = doc.FirstChild.NextSibling.FirstChild;

            // create registration offices
            GenerateRegistrationOffices("United Kingdom", 21000000, "GB");
            GenerateRegistrationOffices("France", 22000000, "FR");
            GenerateRegistrationOffices("Norway", 23000000, "NO");
            GenerateRegistrationOffices("USA", 24000000, "US");
            GenerateRegistrationOffices("Germany", 43000000, "DE");

            PUnitTable unitTable = new PUnitTable();
            // get a list of fields (all class UNIT, with unit type F)
            string sqlGetFieldPartnerKeys = "SELECT * FROM PUB_p_unit WHERE u_unit_type_code_c = 'F'";

            DBAccess.GDBAccessObj.SelectDT(unitTable, sqlGetFieldPartnerKeys, null, new OdbcParameter[0], 0, 0);

            PcConferenceTable conferenceTable   = PcConferenceAccess.LoadByPrimaryKey(1110198, null);
            DateTime          StartOfConference = conferenceTable[0].Start.Value;

            int counterApplicants = 0;

            while (RecordNode != null)
            {
                string JSONFormData = "{'RegistrationOffice':'#REGISTRATIONOFFICE_VALUE'," +
                                      "'EventIdentifier':'#EVENTCODE','EventPartnerKey':'#EVENTPARTNERKEY'," +
                                      "'RegistrationCountryCode':'#CULTURECODE','EventPartnerKey':'#EVENTPARTNERKEY'," +
                                      "'Role':'#ROLE','FirstName':'#FIRSTNAME','LastName':'#LASTNAME'," +
                                      "'Street':'#STREET','Postcode':'#POSTCODE','City':'#CITY','Country':'#COUNTRY_VALUE'," +
                                      "'Phone':'#PHONE','Email':'#EMAIL','DateOfBirth':'#DATEOFBIRTH','ImageID':'#IMAGEID'," +
                                      "'DateOfArrival':'#DATEOFARRIVAL','DateOfDeparture':'#DATEOFDEPARTURE'," +
                                      "'Gender':'#GENDER','Vegetarian':'#VEGETARIAN','MedicalNeeds':'#MEDICALNEEDS','PaymentInfo':'#PAYMENTINFO'}";

                StringBuilder json = new StringBuilder(JSONFormData);

                Dictionary <string, string> values = new Dictionary <string, string>();

                values.Add("EventCode", "SC001CNGRSS08");
                values.Add("EventPartnerKey", conferenceTable[0].ConferenceKey.ToString());

                string cultureCode = TXMLParser.GetAttribute(RecordNode, "RegistrationCountryCode");
                cultureCode = cultureCode.Substring(0, 2) + "-" + cultureCode.Substring(2, 2);
                values.Add("RegistrationCountryCode", cultureCode);

                Int64  RegistrationOffice = 43000000;
                string CountryIsoCode     = "DE";

                foreach (PUnitRow unitRow in unitTable.Rows)
                {
                    if (cultureCode.EndsWith(unitRow.CountryCode))
                    {
                        RegistrationOffice = unitRow.PartnerKey;
                        CountryIsoCode     = unitRow.CountryCode;
                    }
                }

                string role = TXMLParser.GetAttribute(RecordNode, "role");
                int    age  = Convert.ToInt32(TXMLParser.GetAttribute(RecordNode, "age"));

                if (role == "TEEN")
                {
                    // make the age fit
                    age = 12 + age % 6;
                }
                else if (role == "CHILD")
                {
                    age = age % 11;
                }
                else
                {
                    age = 18 + age % 40;
                }

                DateTime DateOfBirth = Convert.ToDateTime(
                    TXMLParser.GetAttribute(RecordNode, "DateOfBirth"));
                int CurrentAge = StartOfConference.Year - DateOfBirth.Year;

                if (DateOfBirth > StartOfConference.AddYears(-age))
                {
                    CurrentAge--;
                }

                DateOfBirth = DateOfBirth.AddYears(CurrentAge - age);

                if (age <= 11)
                {
                    role = "TS-CHILD";
                }
                else if (age <= 15)
                {
                    role = "TS-TEEN-A";
                }
                else if (age <= 17)
                {
                    role = "TS-TEEN-O";
                }
                else
                {
                    role = "TS-" + TXMLParser.GetAttribute(RecordNode, "role");
                }

                values.Add("RegistrationOffice_Value", RegistrationOffice.ToString());
                values.Add("Role", role);
                values.Add("FormsId", "\"");
                values.Add("culturecode", cultureCode);

                values.Add("FirstName", TXMLParser.GetAttribute(RecordNode, "FirstName"));
                values.Add("LastName", TXMLParser.GetAttribute(RecordNode, "FamilyName"));
                values.Add("Gender",
                           (TXMLParser.GetAttribute(RecordNode, "Gender") == "MALE" ? "Male" : "Female"));
                values.Add("Vegetarian", "No");

                string EmailAddress = TXMLParser.GetAttribute(RecordNode, "Email");
                EmailAddress = EmailAddress.Substring(0, EmailAddress.IndexOf("@")) + "@sample.openpetra.org";

                values.Add("Email", EmailAddress);
                values.Add("Street", TXMLParser.GetAttribute(RecordNode, "Street"));
                values.Add("Postcode", TXMLParser.GetAttribute(RecordNode, "PostCode"));
                values.Add("City", TXMLParser.GetAttribute(RecordNode, "City"));
                values.Add("Country_VALUE", CountryIsoCode);
                values.Add("MedicalNeeds", "test with \"quote\" in text");
                values.Add("PaymentInfo", "NONE");

                Catalog.Init("en-GB", cultureCode);
                values.Add("DateOfBirth", DateOfBirth.ToShortDateString()); // in the culture of the country code
                values.Add("DateOfArrival", StartOfConference.ToShortDateString());
                values.Add("DateOfDeparture", StartOfConference.AddDays(5).ToShortDateString());

                values.Add("IMAGEID", "temp.jpg");

                // copy photo to the data/photos directory
                string photo = "469px-Ernest_Hemingway_1923_passport_photo.TIF.jpg";

                if (TXMLParser.GetAttribute(RecordNode, "Gender") == "FEMALE")
                {
                    photo = "388px-Droste-Hülshoff_2.jpg";
                }

                File.Copy(TAppSettingsManager.GetValue("Server.PathTemp") + "/../webserver/Samples/UploadDemo/" + photo,
                          TAppSettingsManager.GetValue("Server.PathTemp") + Path.DirectorySeparatorChar +
                          "temp.jpg", true);

                foreach (string key in values.Keys)
                {
                    string value = values[key].ToString().Trim();

                    json.Replace("#" + key.ToUpper(), value);
                }

                string result = TImportPartnerForm.DataImportFromForm("RegisterPerson", json.ToString(), false);

                if (TLogging.DebugLevel >= 10)
                {
                    TLogging.Log(result);
                }

                counterApplicants++;

                if (counterApplicants % 100 == 0)
                {
                    TLogging.Log("created " + counterApplicants.ToString() + " applicants");
                }

                RecordNode = RecordNode.NextSibling;
            }

            // TODO accept applications

            // TODO give permissions to Demo user. create one user for each registration office
        }