Exemple #1
0
        /// <summary>
        /// Initialize the static variables.
        /// Set up Error Codes and Data Validation Delegates for a Web Request.
        /// This setting-up makes use of the fact that this Method is called only once,
        /// at the start of each Web Request in TOpenPetraOrgSessionManager.Init()
        /// </summary>
        public static void Init()
        {
            TSharedValidationHelper.SharedGetDataDelegate                           = @TCommonDataReader.GetData;
            TSharedPartnerValidationHelper.VerifyPartnerDelegate                    = @TPartnerServerLookups.VerifyPartner;
            TSharedPartnerValidationHelper.PartnerHasActiveStatusDelegate           = @TPartnerServerLookups.PartnerHasActiveStatus;
            TSharedPartnerValidationHelper.PartnerIsLinkedToCCDelegate              = @TPartnerServerLookups.PartnerIsLinkedToCC;
            TSharedPartnerValidationHelper.PartnerOfTypeCCIsLinkedDelegate          = @TPartnerServerLookups.PartnerOfTypeCCIsLinked;
            TSharedPartnerValidationHelper.PartnerHasCurrentGiftDestinationDelegate = @TPartnerServerLookups.PartnerHasCurrentGiftDestination;
            TSharedFinanceValidationHelper.GetValidPostingDateRangeDelegate         = @TFinanceServerLookupWebConnector.GetCurrentPostingRangeDates;
            TSharedFinanceValidationHelper.GetValidPeriodDatesDelegate              = @TAccountingPeriodsWebConnector.GetPeriodDates;
            TSharedFinanceValidationHelper.GetFirstDayOfAccountingPeriodDelegate    = @TAccountingPeriodsWebConnector.GetFirstDayOfAccountingPeriod;
            TMonthEnd.StewardshipCalculationDelegate = @TStewardshipCalculationWebConnector.PerformStewardshipCalculation;

            // Set up Delegates for retrieval of cacheable tables when called from Shared directories on server side
            CachePopulatorCommon        = new Ict.Petra.Server.MCommon.Cacheable.TCacheable();
            CachePopulatorConference    = new Ict.Petra.Server.MConference.Cacheable.TCacheable();
            CachePopulatorFinance       = new Ict.Petra.Server.MFinance.Cacheable.TCacheable();
            CachePopulatorMailing       = new Ict.Petra.Server.MPartner.Mailing.Cacheable.TPartnerCacheable();
            CachePopulatorPartner       = new Ict.Petra.Server.MPartner.Partner.Cacheable.TPartnerCacheable();
            CachePopulatorSubscriptions = new Ict.Petra.Server.MPartner.Subscriptions.Cacheable.TPartnerCacheable();
            CachePopulatorPersonnel     = new Ict.Petra.Server.MPersonnel.Person.Cacheable.TPersonnelCacheable();
            CachePopulatorUnits         = new Ict.Petra.Server.MPersonnel.Unit.Cacheable.TPersonnelCacheable();
            CachePopulatorSysMan        = new Ict.Petra.Server.MSysMan.Cacheable.TCacheable();

            Ict.Petra.Server.MCommon.Cacheable.WebConnectors.TCommonCacheableWebConnector.Init();
            Ict.Petra.Server.MConference.Cacheable.WebConnectors.TConferenceCacheableWebConnector.Init();
            Ict.Petra.Server.MFinance.Cacheable.WebConnectors.TFinanceCacheableWebConnector.Init();
            Ict.Petra.Server.MPartner.Mailing.Cacheable.WebConnectors.TMailingCacheableWebConnector.Init();
            Ict.Petra.Server.MPartner.Partner.Cacheable.WebConnectors.TPartnerCacheableWebConnector.Init();
            Ict.Petra.Server.MPartner.Subscriptions.Cacheable.WebConnectors.TSubscriptionsCacheableWebConnector.Init();
            Ict.Petra.Server.MPersonnel.Person.Cacheable.WebConnectors.TPersonCacheableWebConnector.Init();
            Ict.Petra.Server.MPersonnel.Unit.Cacheable.WebConnectors.TUnitCacheableWebConnector.Init();
            Ict.Petra.Server.MSysMan.Cacheable.WebConnectors.TSysManCacheableWebConnector.Init();

            TSharedDataCache.TMCommon.GetCacheableCommonTableDelegate         = @CachePopulatorCommon.GetCacheableTable;
            TSharedDataCache.TMFinance.GetCacheableFinanceTableDelegate       = @CachePopulatorFinance.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheablePartnerTableDelegate       = @CachePopulatorPartner.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableMailingTableDelegate       = @CachePopulatorMailing.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableSubscriptionsTableDelegate = @CachePopulatorSubscriptions.GetCacheableTable;
            TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate   = @CachePopulatorPersonnel.GetCacheableTable;
            TSharedDataCache.TMPersonnel.GetCacheableUnitsTableDelegate       = @CachePopulatorUnits.GetCacheableTable;
            TSharedDataCache.TMConference.GetCacheableConferenceTableDelegate = @CachePopulatorConference.GetCacheableTable;
            TSharedDataCache.TMSysMan.GetCacheableSysManTableDelegate         = @CachePopulatorSysMan.GetCacheableTable;

            TSharedDataCache.TMPartner.GetPartnerCalculationsSystemCategoryAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DetermineSystemCategoryAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsPartnerContactDetailAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DeterminePartnerContactDetailAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsEmailPartnerAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DetermineEmailPartnerAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsPhonePartnerAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DeterminePhonePartnerAttributeTypes;

            TCacheableTablesManager.Init();
            TCacheableTablesManager.GCacheableTablesManager = new TCacheableTablesManager(new TDelegateSendClientTask(TClientManager.QueueClientTask));

            TSmtpSender.GetSmtpSettings = @TSmtpSender.GetSmtpSettingsFromAppSettings;
        }
Exemple #2
0
        /// <summary>
        /// init the static variables
        /// </summary>
        public static void Init()
        {
            // Set up Error Codes and Data Validation Delegates for a Client's AppDomain.
            // This setting-up makes use of the fact that this Method is called only once,
            // namely directly after the Client logged in successfully.
            ErrorCodeInventory.RegisteredTypes.Add(new Ict.Petra.Shared.PetraErrorCodes().GetType());

            TSharedValidationHelper.SharedGetDataDelegate                           = @TCommonDataReader.GetData;
            TSharedPartnerValidationHelper.VerifyPartnerDelegate                    = @TPartnerServerLookups.VerifyPartner;
            TSharedPartnerValidationHelper.PartnerHasActiveStatusDelegate           = @TPartnerServerLookups.PartnerHasActiveStatus;
            TSharedPartnerValidationHelper.PartnerIsLinkedToCCDelegate              = @TPartnerServerLookups.PartnerIsLinkedToCC;
            TSharedPartnerValidationHelper.PartnerOfTypeCCIsLinkedDelegate          = @TPartnerServerLookups.PartnerOfTypeCCIsLinked;
            TSharedPartnerValidationHelper.PartnerHasCurrentGiftDestinationDelegate = @TPartnerServerLookups.PartnerHasCurrentGiftDestination;
            TSharedFinanceValidationHelper.GetValidPostingDateRangeDelegate         = @TFinanceServerLookupWebConnector.GetCurrentPostingRangeDates;
            TSharedFinanceValidationHelper.GetFirstDayOfAccountingPeriodDelegate    = @TAccountingPeriodsWebConnector.GetFirstDayOfAccountingPeriod;
            TMonthEnd.StewardshipCalculationDelegate = @TStewardshipCalculationWebConnector.PerformStewardshipCalculation;
            TGLPosting.PrintReportOnClientDelegate   = @TReportingWebConnector.GenerateReportOnClient;

            // Set up Delegates for retrieval of cacheable tables when called from Shared directories on server side
            CachePopulatorCommon        = new Ict.Petra.Server.MCommon.Cacheable.TCacheable();
            CachePopulatorConference    = new Ict.Petra.Server.MConference.Cacheable.TCacheable();
            CachePopulatorFinance       = new Ict.Petra.Server.MFinance.Cacheable.TCacheable();
            CachePopulatorMailing       = new Ict.Petra.Server.MPartner.Mailing.Cacheable.TPartnerCacheable();
            CachePopulatorPartner       = new Ict.Petra.Server.MPartner.Partner.Cacheable.TPartnerCacheable();
            CachePopulatorSubscriptions = new Ict.Petra.Server.MPartner.Subscriptions.Cacheable.TPartnerCacheable();
            CachePopulatorPersonnel     = new Ict.Petra.Server.MPersonnel.Person.Cacheable.TPersonnelCacheable();
            CachePopulatorUnits         = new Ict.Petra.Server.MPersonnel.Unit.Cacheable.TPersonnelCacheable();
            CachePopulatorSysMan        = new Ict.Petra.Server.MSysMan.Cacheable.TCacheable();

            TSharedDataCache.TMCommon.GetCacheableCommonTableDelegate = @CachePopulatorCommon.GetCacheableTable;

            TSharedDataCache.TMFinance.GetCacheableFinanceTableDelegate = @CachePopulatorFinance.GetCacheableTable;

            TSharedDataCache.TMPartner.GetCacheablePartnerTableDelegate       = @CachePopulatorPartner.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableMailingTableDelegate       = @CachePopulatorMailing.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableSubscriptionsTableDelegate = @CachePopulatorSubscriptions.GetCacheableTable;
            TSharedDataCache.TMPartner.GetPartnerCalculationsSystemCategoryAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DetermineSystemCategoryAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsPartnerContactDetailAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DeterminePartnerContactDetailAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsEmailPartnerAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DetermineEmailPartnerAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsPhonePartnerAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DeterminePhonePartnerAttributeTypes;

            TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate = @CachePopulatorPersonnel.GetCacheableTable;
            TSharedDataCache.TMPersonnel.GetCacheableUnitsTableDelegate     = @CachePopulatorUnits.GetCacheableTable;

            TSharedDataCache.TMConference.GetCacheableConferenceTableDelegate = @CachePopulatorConference.GetCacheableTable;

            TSharedDataCache.TMSysMan.GetCacheableSysManTableDelegate = @CachePopulatorSysMan.GetCacheableTable;

            TSmtpSender.GetSmtpSettings = @TSmtpSender.GetSmtpSettingsFromAppSettings;
        }
Exemple #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        static TCallForwarding()
        {
            // Set up Error Codes and Data Validation Delegates for a Client's AppDomain.
            // This setting-up makes use of the fact that this Method is called only once,
            // namely directly after the Client logged in successfully.
            ErrorCodeInventory.RegisteredTypes.Add(new Ict.Petra.Shared.PetraErrorCodes().GetType());

            TSharedValidationHelper.SharedGetDataDelegate                   = @TCommonDataReader.GetData;
            TSharedPartnerValidationHelper.VerifyPartnerDelegate            = @TPartnerServerLookups.VerifyPartner;
            TSharedFinanceValidationHelper.GetValidPostingDateRangeDelegate = @TFinanceServerLookups.GetCurrentPostingRangeDates;
            TMonthEnd.StewardshipCalculationDelegate = @TStewardshipCalculationWebConnector.PerformStewardshipCalculation;
            TGLPosting.PrintReportOnClientDelegate   = @TReportingWebConnector.GenerateReportOnClient;

            // Set up Delegates for retrieval of cacheable tables when called from Shared directories on server side
            CachePopulatorCommon        = new Ict.Petra.Server.MCommon.Cacheable.TCacheable();
            CachePopulatorConference    = new Ict.Petra.Server.MConference.Cacheable.TCacheable();
            CachePopulatorFinance       = new Ict.Petra.Server.MFinance.Cacheable.TCacheable();
            CachePopulatorMailing       = new Ict.Petra.Server.MPartner.Mailing.Cacheable.TPartnerCacheable();
            CachePopulatorPartner       = new Ict.Petra.Server.MPartner.Partner.Cacheable.TPartnerCacheable();
            CachePopulatorSubscriptions = new Ict.Petra.Server.MPartner.Subscriptions.Cacheable.TPartnerCacheable();
            CachePopulatorPersonnel     = new Ict.Petra.Server.MPersonnel.Person.Cacheable.TPersonnelCacheable();
            CachePopulatorUnits         = new Ict.Petra.Server.MPersonnel.Unit.Cacheable.TPersonnelCacheable();
            CachePopulatorSysMan        = new Ict.Petra.Server.MSysMan.Cacheable.TCacheable();

            TSharedDataCache.TMCommon.GetCacheableCommonTableDelegate = @CachePopulatorCommon.GetCacheableTable;

            TSharedDataCache.TMFinance.GetCacheableFinanceTableDelegate = @CachePopulatorFinance.GetCacheableTable;

            TSharedDataCache.TMPartner.GetCacheablePartnerTableDelegate       = @CachePopulatorPartner.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableMailingTableDelegate       = @CachePopulatorMailing.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableSubscriptionsTableDelegate = @CachePopulatorSubscriptions.GetCacheableTable;

            TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate = @CachePopulatorPersonnel.GetCacheableTable;
            TSharedDataCache.TMPersonnel.GetCacheableUnitsTableDelegate     = @CachePopulatorUnits.GetCacheableTable;

            TSharedDataCache.TMConference.GetCacheableConferenceTableDelegate = @CachePopulatorConference.GetCacheableTable;

            TSharedDataCache.TMSysMan.GetCacheableSysManTableDelegate = @CachePopulatorSysMan.GetCacheableTable;
        }
        /// <summary>
        /// Retrieves data that will be shown on the 'Overview' UserControl and adds it to <paramref name="AIndividualDataDS" />.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of the Person to load data for.</param>
        /// <param name="AIndividualDataDS">Typed DataSet of Type <see cref="IndividualDataTDS" />. Needs to be instantiated already!</param>
        /// <param name="AReadTransaction">Open Database transaction.</param>
        /// <returns>void</returns>
        private static void BuildSummaryData(Int64 APartnerKey, ref IndividualDataTDS AIndividualDataDS, TDBTransaction AReadTransaction)
        {
            string StrNotAvailable = Catalog.GetString("Not Available");
            IndividualDataTDSSummaryDataTable SummaryDT;
            IndividualDataTDSSummaryDataRow SummaryDR;
            IndividualDataTDSMiscellaneousDataRow MiscellaneousDataDR = AIndividualDataDS.MiscellaneousData[0];
            PPersonTable PPersonDT;
            PPersonRow PersonDR = null;
            PmPassportDetailsTable PassportDetailsDT;
            PmStaffDataTable PmStaffDataDT;
            PmStaffDataRow PmStaffDataDR = null;
            PmJobAssignmentTable PmJobAssignmentDT = null;
            PUnitTable PUnitDT = null;
            PmJobAssignmentRow PmJobAssignmentDR;
            IndividualDataTDSJobAssignmentStaffDataCombinedRow JobAssiStaffDataCombDR;
            int JobAssiStaffDataCombKey = 0;
            TCacheable CommonCacheable = new TCacheable();
            TPartnerCacheable PartnerCacheable = new TPartnerCacheable();
            string MaritalStatusDescr;
            StringCollection PassportColumns;
            string Nationalities;
            PPartnerRelationshipTable PartnerRelationshipDT;
            PPartnerTable PartnerDT;
            PPartnerRow PartnerDR = null;
            PLocationRow LocationDR;
            PPartnerLocationRow PartnerLocationDR;
            string PhoneNumber;
            string PhoneExtension = String.Empty;
            Int64 ChurchPartnerKey;

            SummaryDT = new IndividualDataTDSSummaryDataTable();
            SummaryDR = SummaryDT.NewRowTyped(false);

            SummaryDR.PartnerKey = APartnerKey;

            #region Person Info

            PPersonDT = PPersonAccess.LoadByPrimaryKey(APartnerKey, AReadTransaction);

            if (PPersonDT.Rows.Count == 1)
            {
                PersonDR = (PPersonRow)PPersonDT.Rows[0];
            }

            if (PersonDR != null)
            {
                SummaryDR.DateOfBirth = PersonDR.DateOfBirth;
                SummaryDR.Gender = PersonDR.Gender;

                MaritalStatusDescr = PartnerCodeHelper.GetMaritalStatusDescription(
                    @PartnerCacheable.GetCacheableTable, PersonDR.MaritalStatus);

                if (MaritalStatusDescr != String.Empty)
                {
                    MaritalStatusDescr = " - " + MaritalStatusDescr;
                }

                SummaryDR.MaritalStatus = PersonDR.MaritalStatus + MaritalStatusDescr;
            }
            else
            {
                SummaryDR.SetDateOfBirthNull();
                SummaryDR.Gender = StrNotAvailable;
                SummaryDR.MaritalStatus = StrNotAvailable;
            }

            #region Nationalities

            PassportColumns = StringHelper.StrSplit(
                PmPassportDetailsTable.GetDateOfIssueDBName() + "," +
                PmPassportDetailsTable.GetDateOfExpirationDBName() + "," +
                PmPassportDetailsTable.GetPassportNationalityCodeDBName() + "," +
                PmPassportDetailsTable.GetMainPassportDBName(), ",");

            PassportDetailsDT = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey,
                PassportColumns, AReadTransaction, null, 0, 0);

            Nationalities = Ict.Petra.Shared.MPersonnel.Calculations.DeterminePersonsNationalities(
                @CommonCacheable.GetCacheableTable, PassportDetailsDT);

            if (Nationalities != String.Empty)
            {
                SummaryDR.Nationalities = Nationalities;
            }
            else
            {
                SummaryDR.Nationalities = StrNotAvailable;
            }

            #endregion

            #region Phone and Email (from 'Best Address')

            ServerCalculations.DetermineBestAddress(APartnerKey, out PartnerLocationDR, out LocationDR);

            if (LocationDR != null)
            {
                SummaryDR.EmailAddress = PartnerLocationDR.EmailAddress;

                if (PartnerLocationDR.TelephoneNumber != String.Empty)
                {
                    PhoneNumber = PartnerLocationDR.TelephoneNumber;

                    if (!PartnerLocationDR.IsExtensionNull())
                    {
                        PhoneExtension = PartnerLocationDR.Extension.ToString();
                    }

                    SummaryDR.TelephoneNumber = Calculations.FormatIntlPhoneNumber(PhoneNumber, PhoneExtension, LocationDR.CountryCode,
                        @CommonCacheable.GetCacheableTable);
                }
                else if (PartnerLocationDR.MobileNumber != String.Empty)
                {
                    SummaryDR.TelephoneNumber = Calculations.FormatIntlPhoneNumber(PartnerLocationDR.MobileNumber,
                        String.Empty, LocationDR.CountryCode, @CommonCacheable.GetCacheableTable) + " " +
                                                Catalog.GetString("(Mobile)");
                }
                else
                {
                    SummaryDR.TelephoneNumber = StrNotAvailable;
                }
            }
            else
            {
                SummaryDR.TelephoneNumber = StrNotAvailable;
                SummaryDR.EmailAddress = StrNotAvailable;
            }

            #endregion

            #endregion

            #region Commitments/Jobs

            PmStaffDataDT = PmStaffDataAccess.LoadViaPPerson(APartnerKey, AReadTransaction);
            MiscellaneousDataDR.ItemsCountCommitmentPeriods = PmStaffDataDT.Rows.Count;

            // First check if the PERSON has got any Commitments
            if (PmStaffDataDT.Rows.Count > 0)
            {
                foreach (DataRow DR in PmStaffDataDT.Rows)
                {
                    JobAssiStaffDataCombDR = AIndividualDataDS.JobAssignmentStaffDataCombined.NewRowTyped(false);
                    JobAssiStaffDataCombDR.Key = JobAssiStaffDataCombKey++;
                    JobAssiStaffDataCombDR.PartnerKey = APartnerKey;

                    PmStaffDataDR = (PmStaffDataRow)DR;

                    if (!(PmStaffDataDR.IsReceivingFieldNull())
                        && (PmStaffDataDR.ReceivingField != 0))
                    {
                        PUnitDT = PUnitAccess.LoadByPrimaryKey(PmStaffDataDR.ReceivingField, AReadTransaction);

                        JobAssiStaffDataCombDR.FieldKey = PmStaffDataDR.ReceivingField;
                        JobAssiStaffDataCombDR.FieldName = PUnitDT[0].UnitName;
                    }
                    else
                    {
                        JobAssiStaffDataCombDR.FieldKey = 0;
                        JobAssiStaffDataCombDR.FieldName = "[None]";
                    }

                    JobAssiStaffDataCombDR.Position = PmStaffDataDR.JobTitle;
                    JobAssiStaffDataCombDR.FromDate = PmStaffDataDR.StartOfCommitment;
                    JobAssiStaffDataCombDR.ToDate = PmStaffDataDR.EndOfCommitment;

                    AIndividualDataDS.JobAssignmentStaffDataCombined.Rows.Add(JobAssiStaffDataCombDR);
                }
            }
            else
            {
                // The PERSON hasn't got any Commitments, therefore check if the PERSON has any Job Assignments

                PmJobAssignmentDT = PmJobAssignmentAccess.LoadViaPPartner(APartnerKey, AReadTransaction);

                if (PmJobAssignmentDT.Rows.Count > 0)
                {
                    foreach (DataRow DR in PmJobAssignmentDT.Rows)
                    {
                        JobAssiStaffDataCombDR = AIndividualDataDS.JobAssignmentStaffDataCombined.NewRowTyped(false);
                        JobAssiStaffDataCombDR.Key = JobAssiStaffDataCombKey++;
                        JobAssiStaffDataCombDR.PartnerKey = APartnerKey;

                        PmJobAssignmentDR = (PmJobAssignmentRow)DR;

                        if (PmJobAssignmentDR.UnitKey != 0)
                        {
                            PUnitDT = PUnitAccess.LoadByPrimaryKey(PmJobAssignmentDR.UnitKey, AReadTransaction);

                            JobAssiStaffDataCombDR.FieldKey = PmJobAssignmentDR.UnitKey;
                            JobAssiStaffDataCombDR.FieldName = PUnitDT[0].UnitName;
                        }
                        else
                        {
                            JobAssiStaffDataCombDR.FieldKey = 0;
                            JobAssiStaffDataCombDR.FieldName = "[None]";
                        }

                        JobAssiStaffDataCombDR.Position = PmJobAssignmentDR.PositionName;
                        JobAssiStaffDataCombDR.FromDate = PmJobAssignmentDR.FromDate;
                        JobAssiStaffDataCombDR.ToDate = PmJobAssignmentDR.ToDate;

                        AIndividualDataDS.JobAssignmentStaffDataCombined.Rows.Add(JobAssiStaffDataCombDR);
                    }
                }
            }

            #endregion

            #region Church Info

            SummaryDR.ChurchName = StrNotAvailable;
            SummaryDR.ChurchAddress = StrNotAvailable;
            SummaryDR.ChurchPhone = StrNotAvailable;
            SummaryDR.ChurchPastor = StrNotAvailable;
            SummaryDR.ChurchPastorsPhone = StrNotAvailable;
            SummaryDR.NumberOfShownSupportingChurchPastors = 0;

            // Find SUPPCHURCH Relationship
            PartnerRelationshipDT = PPartnerRelationshipAccess.LoadUsingTemplate(new TSearchCriteria[] {
                    new TSearchCriteria(PPartnerRelationshipTable.GetRelationKeyDBName(), APartnerKey),
                    new TSearchCriteria(PPartnerRelationshipTable.GetRelationNameDBName(), "SUPPCHURCH")
                },
                AReadTransaction);

            SummaryDR.NumberOfShownSupportingChurches = PartnerRelationshipDT.Rows.Count;

            if (PartnerRelationshipDT.Rows.Count > 0)
            {
                ChurchPartnerKey = PartnerRelationshipDT[0].PartnerKey;

                // Load Church Partner
                PartnerDT = PPartnerAccess.LoadByPrimaryKey(ChurchPartnerKey, AReadTransaction);

                if (PartnerDT.Rows.Count > 0)
                {
                    PartnerDR = PartnerDT[0];

                    // Church Name
                    if (PartnerDR.PartnerShortName != String.Empty)
                    {
                        SummaryDR.ChurchName = PartnerDR.PartnerShortName;
                    }

                    #region Church Address and Phone

                    ServerCalculations.DetermineBestAddress(PartnerRelationshipDT[0].PartnerKey, out PartnerLocationDR, out LocationDR);

                    if (LocationDR != null)
                    {
                        SummaryDR.ChurchAddress = Calculations.DetermineLocationString(LocationDR,
                            Calculations.TPartnerLocationFormatEnum.plfCommaSeparated);

                        // Church Phone
                        if (PartnerLocationDR.TelephoneNumber != String.Empty)
                        {
                            PhoneNumber = PartnerLocationDR.TelephoneNumber;

                            if (!PartnerLocationDR.IsExtensionNull())
                            {
                                PhoneExtension = PartnerLocationDR.Extension.ToString();
                            }

                            SummaryDR.ChurchPhone = Calculations.FormatIntlPhoneNumber(PhoneNumber, PhoneExtension, LocationDR.CountryCode,
                                @CommonCacheable.GetCacheableTable);
                        }
                        else if (PartnerLocationDR.MobileNumber != String.Empty)
                        {
                            SummaryDR.ChurchPhone = Calculations.FormatIntlPhoneNumber(PartnerLocationDR.MobileNumber,
                                String.Empty, LocationDR.CountryCode, @CommonCacheable.GetCacheableTable) + " " +
                                                    Catalog.GetString("(Mobile)");
                        }
                    }

                    #endregion

                    #region Pastor

                    // Find PASTOR Relationship
                    PartnerRelationshipDT.Rows.Clear();
                    PartnerRelationshipDT = PPartnerRelationshipAccess.LoadUsingTemplate(new TSearchCriteria[] {
                            new TSearchCriteria(PPartnerRelationshipTable.GetPartnerKeyDBName(), ChurchPartnerKey),
                            new TSearchCriteria(PPartnerRelationshipTable.GetRelationNameDBName(), "PASTOR")
                        },
                        AReadTransaction);

                    SummaryDR.NumberOfShownSupportingChurchPastors = PartnerRelationshipDT.Rows.Count;

                    if (PartnerRelationshipDT.Rows.Count > 0)
                    {
                        // Load PASTOR Partner
                        PartnerDT = PPartnerAccess.LoadByPrimaryKey(PartnerRelationshipDT[0].RelationKey, AReadTransaction);

                        if (PartnerDT.Rows.Count > 0)
                        {
                            PartnerDR = PartnerDT[0];

                            // Pastor's Name
                            if (PartnerDR.PartnerShortName != String.Empty)
                            {
                                SummaryDR.ChurchPastor = PartnerDR.PartnerShortName;
                            }

                            #region Pastor's Phone

                            ServerCalculations.DetermineBestAddress(PartnerRelationshipDT[0].RelationKey,
                                out PartnerLocationDR, out LocationDR);

                            if (LocationDR != null)
                            {
                                // Pastor's Phone
                                if (PartnerLocationDR.TelephoneNumber != String.Empty)
                                {
                                    PhoneNumber = PartnerLocationDR.TelephoneNumber;

                                    if (!PartnerLocationDR.IsExtensionNull())
                                    {
                                        PhoneExtension = PartnerLocationDR.Extension.ToString();
                                    }

                                    SummaryDR.ChurchPastorsPhone = Calculations.FormatIntlPhoneNumber(PhoneNumber,
                                        PhoneExtension, LocationDR.CountryCode, @CommonCacheable.GetCacheableTable);
                                }
                                else if (PartnerLocationDR.MobileNumber != String.Empty)
                                {
                                    SummaryDR.ChurchPastorsPhone = Calculations.FormatIntlPhoneNumber(PartnerLocationDR.MobileNumber,
                                        String.Empty, LocationDR.CountryCode, @CommonCacheable.GetCacheableTable) + " " +
                                                                   Catalog.GetString("(Mobile)");
                                }
                            }

                            #endregion
                        }
                    }

                    #endregion
                }
            }

            #endregion

            // Add Summary DataRow to Summary DataTable
            SummaryDT.Rows.Add(SummaryDR);

            // Add Row to 'SummaryData' DataTable in Typed DataSet 'IndividualDataTDS'
            AIndividualDataDS.Merge(SummaryDT);
        }
Exemple #5
0
        /// <summary>
        /// Gets nationalities from all of a Partner's recorded passports
        /// </summary>
        /// <param name="APartnerKey">Partner key</param>
        /// <returns>returns nationalities in a comma seperated string</returns>
        private string GetNationalities(Int64 APartnerKey)
        {
            TCacheable CommonCacheable = new TCacheable();

            StringCollection PassportColumns = StringHelper.StrSplit(
                PmPassportDetailsTable.GetDateOfIssueDBName() + "," +
                PmPassportDetailsTable.GetDateOfExpirationDBName() + "," +
                PmPassportDetailsTable.GetPassportNationalityCodeDBName() + "," +
                PmPassportDetailsTable.GetMainPassportDBName(), ",");

            PmPassportDetailsTable PassportDetailsDT = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey,
                PassportColumns, situation.GetDatabaseConnection().Transaction, null, 0, 0);

            return Ict.Petra.Shared.MPersonnel.Calculations.DeterminePersonsNationalities(
                @CommonCacheable.GetCacheableTable, PassportDetailsDT);
        }
Exemple #6
0
        public static void FillFormDataFromPartner(Int64 APartnerKey,
            ref TFormDataPartner AFormDataPartner,
            TFormLetterInfo AFormLetterInfo,
            Int64 ASiteKey = 0,
            Int32 ALocationKey = 0)
        {
            TPartnerClass PartnerClass;
            String ShortName;
            TStdPartnerStatusCode PartnerStatusCode;
            Int64 FamilyKey = 0;

            TFormDataPartner formData = null;

            TDBTransaction ReadTransaction = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum,
                ref ReadTransaction,
                delegate
                {
                    if (MCommonMain.RetrievePartnerShortName(APartnerKey, out ShortName, out PartnerClass, out PartnerStatusCode, ReadTransaction))
                    {
                        switch (PartnerClass)
                        {
                            case TPartnerClass.PERSON:
                                formData = new TFormDataPerson();
                                formData.IsPersonRecord = true;
                                break;

                            default:
                                formData = new TFormDataPartner();
                                formData.IsPersonRecord = false;
                                break;
                        }

                        // set current date
                        formData.CurrentDate = DateTime.Today;

                        // retrieve general Partner information
                        if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eGeneral))
                        {
                            String SiteName;
                            TPartnerClass SiteClass;

                            if (TPartnerServerLookups.GetPartnerShortName(DomainManager.GSiteKey, out SiteName, out SiteClass))
                            {
                                formData.RecordingField = SiteName;
                            }
                        }

                        // retrieve general Partner information
                        if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.ePartner))
                        {
                            PPartnerTable PartnerTable;
                            PPartnerRow PartnerRow;
                            PartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);

                            if (PartnerTable.Count > 0)
                            {
                                PartnerRow = (PPartnerRow)PartnerTable.Rows[0];

                                formData.PartnerKey = PartnerRow.PartnerKey.ToString("0000000000");
                                formData.Name = Calculations.FormatShortName(PartnerRow.PartnerShortName, eShortNameFormat.eReverseWithoutTitle);
                                formData.ShortName = PartnerRow.PartnerShortName;
                                formData.LocalName = PartnerRow.PartnerShortNameLoc;
                                formData.AddresseeType = PartnerRow.AddresseeTypeCode;
                                formData.LanguageCode = PartnerRow.LanguageCode;
                                formData.Notes = PartnerRow.Comment;
                                formData.ReceiptLetterFrequency = PartnerRow.ReceiptLetterFrequency;

                                if (PartnerRow.PartnerShortName.Contains(","))
                                {
                                    formData.Title = Calculations.FormatShortName(PartnerRow.PartnerShortName, eShortNameFormat.eOnlyTitle);
                                }
                                else
                                {
                                    formData.Title = "";
                                }
                            }

                            if (PartnerClass == TPartnerClass.PERSON)
                            {
                                PPersonTable PersonTable;
                                PPersonRow PersonRow;
                                PersonTable = PPersonAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);

                                if (PersonTable.Count > 0)
                                {
                                    PersonRow = (PPersonRow)PersonTable.Rows[0];

                                    formData.FirstName = PersonRow.FirstName;
                                    formData.LastName = PersonRow.FamilyName;
                                }
                            }
                            else if (PartnerClass == TPartnerClass.FAMILY)
                            {
                                PFamilyTable FamilyTable;
                                PFamilyRow FamilyRow;
                                FamilyTable = PFamilyAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);

                                if (FamilyTable.Count > 0)
                                {
                                    FamilyRow = (PFamilyRow)FamilyTable.Rows[0];

                                    formData.FirstName = FamilyRow.FirstName;
                                    formData.LastName = FamilyRow.FamilyName;
                                }
                            }
                        }

                        // retrieve Person information
                        if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.ePerson)
                            && (PartnerClass == TPartnerClass.PERSON)
                            && (formData.GetType() == typeof(TFormDataPerson)))
                        {
                            PPersonTable PersonTable;
                            PPersonRow PersonRow;
                            TFormDataPerson PersonFormData = (TFormDataPerson)formData;
                            PersonTable = PPersonAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);

                            if (PersonTable.Count > 0)
                            {
                                PersonRow = (PPersonRow)PersonTable.Rows[0];
                                PersonFormData.Title = PersonRow.Title;
                                PersonFormData.Decorations = PersonRow.Decorations;
                                PersonFormData.MiddleName = PersonRow.MiddleName1;
                                PersonFormData.PreferedName = PersonRow.PreferedName;
                                PersonFormData.DateOfBirth = PersonRow.DateOfBirth;
                                PersonFormData.Gender = PersonRow.Gender;
                                PersonFormData.MaritalStatus = PersonRow.MaritalStatus;
                                PersonFormData.OccupationCode = PersonRow.OccupationCode;

                                if (!PersonRow.IsOccupationCodeNull()
                                    && (PersonRow.OccupationCode != ""))
                                {
                                    // retrieve occupation description from occupation table
                                    TPartnerCacheable CachePopulator = new TPartnerCacheable();
                                    POccupationTable OccupationTable =
                                        (POccupationTable)CachePopulator.GetCacheableTable(TCacheablePartnerTablesEnum.OccupationList);
                                    POccupationRow OccupationRow = (POccupationRow)OccupationTable.Rows.Find(new object[] { PersonRow.OccupationCode });

                                    if (OccupationRow != null)
                                    {
                                        PersonFormData.Occupation = OccupationRow.OccupationDescription;
                                    }
                                }

                                // Get supporting church, if there is one.  (Actually there may be more than one!)
                                // The RelationKey should hold the PERSON key and PartnerKey should hold supporter key
                                PPartnerRelationshipTable tmpTable = new PPartnerRelationshipTable();
                                PPartnerRelationshipRow templateRow = tmpTable.NewRowTyped(false);
                                templateRow.RelationName = "SUPPCHURCH";
                                templateRow.RelationKey = APartnerKey;

                                PPartnerRelationshipTable supportingChurchTable =
                                    PPartnerRelationshipAccess.LoadUsingTemplate(templateRow, ReadTransaction);
                                int supportingChurchCount = supportingChurchTable.Rows.Count;

                                // If the user has got RelationKey and PartnerKey back to front we will get no results
                                PersonFormData.SendingChurchName = String.Empty;

                                for (int i = 0; i < supportingChurchCount; i++)
                                {
                                    // Go round each supporting church
                                    // Get the short name for the sending church
                                    // Foreign key constraint means that this row is bound to exist
                                    string churchName;
                                    TPartnerClass churchClass;
                                    TStdPartnerStatusCode churchStatus;
                                    long supportingChurchKey = ((PPartnerRelationshipRow)supportingChurchTable.Rows[i]).PartnerKey;

                                    if (MCommonMain.RetrievePartnerShortName(supportingChurchKey, out churchName, out churchClass, out churchStatus,
                                            ReadTransaction))
                                    {
                                        // The church name can be empty but that would be unusual
                                        // churchClass should be CHURCH or ORGANISATION if everything is the right way round
                                        // but we do not check this - nor churchStatus
                                        if (churchName.Length == 0)
                                        {
                                            churchName = Catalog.GetString("Not available");
                                        }

                                        if (supportingChurchCount > 1)
                                        {
                                            if (i > 0)
                                            {
                                                PersonFormData.SendingChurchName += Catalog.GetString(" AND ");
                                            }

                                            PersonFormData.SendingChurchName += String.Format("{0}: '{1}'", i + 1, churchName);
                                        }
                                        else
                                        {
                                            PersonFormData.SendingChurchName += String.Format("'{0}'", churchName);
                                        }
                                    }
                                }

                                // we need this for later in case we retrieve family members
                                FamilyKey = PersonRow.FamilyKey;

                                // retrieve Special Needs information
                                if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eSpecialNeeds))
                                {
                                    PmSpecialNeedTable SpecialNeedTable;
                                    PmSpecialNeedRow SpecialNeedRow;
                                    SpecialNeedTable = PmSpecialNeedAccess.LoadViaPPerson(APartnerKey, ReadTransaction);

                                    if (SpecialNeedTable.Count > 0)
                                    {
                                        SpecialNeedRow = (PmSpecialNeedRow)SpecialNeedTable.Rows[0];
                                        PersonFormData.DietaryNeeds = SpecialNeedRow.DietaryComment;
                                        PersonFormData.MedicalNeeds = SpecialNeedRow.MedicalComment;
                                        PersonFormData.OtherNeeds = SpecialNeedRow.OtherSpecialNeed;
                                        PersonFormData.Vegetarian = SpecialNeedRow.VegetarianFlag;
                                    }
                                }

                                // retrieve Personal Data information
                                if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.ePersonalData))
                                {
                                    PmPersonalDataTable PersonalDataTable;
                                    PmPersonalDataRow PersonalDataRow;
                                    PersonalDataTable = PmPersonalDataAccess.LoadViaPPerson(APartnerKey, ReadTransaction);

                                    if (PersonalDataTable.Count > 0)
                                    {
                                        PersonalDataRow = (PmPersonalDataRow)PersonalDataTable.Rows[0];

                                        if (!PersonalDataRow.IsBelieverSinceYearNull()
                                            && (PersonalDataRow.BelieverSinceYear != 0))
                                        {
                                            PersonFormData.YearsBeliever = (DateTime.Today.Year - PersonalDataRow.BelieverSinceYear).ToString();
                                        }

                                        PersonFormData.CommentBeliever = PersonalDataRow.BelieverSinceComment;
                                    }
                                }
                            }
                        }

                        // retrieve Family member information
                        if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eFamilyMember))
                        {
                            // Retrieve family key for FAMILY class. In case of PERSON this has already been done earlier.
                            if (PartnerClass == TPartnerClass.FAMILY)
                            {
                                FamilyKey = APartnerKey;
                            }

                            if (FamilyKey != 0)
                            {
                                PPersonTable FamilyMembersTable;
                                TFormDataFamilyMember FamilyMemberRecord;
                                String PersonShortName;
                                TPartnerClass PersonClass;
                                FamilyMembersTable = PPersonAccess.LoadViaPFamily(FamilyKey, ReadTransaction);

                                foreach (PPersonRow PersonRow in FamilyMembersTable.Rows)
                                {
                                    // only add this person if it is not the main record
                                    if (PersonRow.PartnerKey != APartnerKey)
                                    {
                                        FamilyMemberRecord = new TFormDataFamilyMember();

                                        TPartnerServerLookups.GetPartnerShortName(PersonRow.PartnerKey, out PersonShortName, out PersonClass);
                                        FamilyMemberRecord.Name = PersonShortName;
                                        FamilyMemberRecord.DateOfBirth = PersonRow.DateOfBirth;

                                        formData.AddFamilyMember(FamilyMemberRecord);
                                    }
                                }
                            }
                        }

                        // retrieve Contact information
                        if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eContact))
                        {
                            string Phone;
                            string Email;

                            // retrieve primary phone and primary email
                            TContactDetailsAggregate.GetPrimaryEmailAndPrimaryPhone(APartnerKey, out Phone, out Email);

                            formData.PrimaryPhone = Phone;
                            formData.PrimaryEmail = Email;

                            // check for skype as it may not often be used
                            // if there is more than one skype id then at the moment the first one found is used
                            if (AFormLetterInfo.ContainsTag("Skype"))
                            {
                                PPartnerAttributeTable AttributeTable = PPartnerAttributeAccess.LoadViaPPartner(APartnerKey, ReadTransaction);

                                foreach (PPartnerAttributeRow AttributeRow in AttributeTable.Rows)
                                {
                                    if (AttributeRow.AttributeType == "Skype") // check if we can maybe use constant value instead of string
                                    {
                                        formData.Skype = AttributeRow.Value;
                                        break;
                                    }
                                }
                            }
                        }

                        // retrieve Location and formality information
                        if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eLocation)
                            || AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eLocationBlock)
                            || AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eFormalGreetings))
                        {
                            PLocationTable LocationTable;
                            PLocationRow LocationRow;
                            String CountryName = "";

                            if (ALocationKey == 0)
                            {
                                // no address set -> retrieve best address
                                TAddressTools.GetBestAddress(APartnerKey, out LocationTable, out CountryName, ReadTransaction);
                            }
                            else
                            {
                                LocationTable = PLocationAccess.LoadByPrimaryKey(ASiteKey, ALocationKey, ReadTransaction);
                            }

                            if (LocationTable.Count > 0)
                            {
                                LocationRow = (PLocationRow)LocationTable.Rows[0];
                                formData.LocationKey = LocationRow.LocationKey;
                                formData.Address1 = LocationRow.Locality;
                                formData.AddressStreet2 = LocationRow.StreetName;
                                formData.Address3 = LocationRow.Address3;
                                formData.PostalCode = LocationRow.PostalCode;
                                formData.County = LocationRow.County;
                                formData.CountryName = CountryName;
                                formData.City = LocationRow.City;
                                formData.CountryCode = LocationRow.CountryCode;

                                // retrieve country name from country table
                                TCacheable CachePopulator = new TCacheable();
                                PCountryTable CountryTable = (PCountryTable)CachePopulator.GetCacheableTable(TCacheableCommonTablesEnum.CountryList);
                                PCountryRow CountryRow = (PCountryRow)CountryTable.Rows.Find(new object[] { LocationRow.CountryCode });

                                if (CountryRow != null)
                                {
                                    formData.CountryName = CountryRow.CountryName;
                                    formData.CountryInLocalLanguage = CountryRow.CountryNameLocal;
                                }
                            }

                            // build address block (need to have retrieved location data beforehand)
                            if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eLocationBlock))
                            {
                                formData.AddressBlock = BuildAddressBlock(formData, AFormLetterInfo.AddressLayoutCode, PartnerClass, ReadTransaction);
                            }

                            // retrieve formality information (need to have retrieved country, language and addressee type beforehand)
                            if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eFormalGreetings))
                            {
                                String SalutationText;
                                String ClosingText;

                                InitializeFormality(AFormLetterInfo, ReadTransaction);
                                AFormLetterInfo.RetrieveFormalityGreeting(formData, out SalutationText, out ClosingText);
                                ResolveGreetingPlaceholders(formData, AFormLetterInfo, APartnerKey, ShortName, PartnerClass, ref SalutationText,
                                    ref ClosingText, ReadTransaction);

                                formData.FormalSalutation = SalutationText;
                                formData.FormalClosing = ClosingText;
                            }
                        }

                        // retrieve Contact Log information
                        if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eContactLog))
                        {
                            PContactLogTable ContactLogTable;
                            TFormDataContactLog ContactLogRecord;
                            ContactLogTable = PContactLogAccess.LoadViaPPartnerPPartnerContact(APartnerKey, ReadTransaction);

                            foreach (PContactLogRow ContactLogRow in ContactLogTable.Rows)
                            {
                                ContactLogRecord = new TFormDataContactLog();

                                ContactLogRecord.Contactor = ContactLogRow.Contactor;
                                ContactLogRecord.Notes = ContactLogRow.ContactComment;

                                formData.AddContactLog(ContactLogRecord);
                            }
                        }

                        // retrieve Subscription information
                        if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eSubscription))
                        {
                            PSubscriptionTable SubscriptionTable;
                            TFormDataSubscription SubscriptionRecord;

                            SubscriptionTable = PSubscriptionAccess.LoadViaPPartnerPartnerKey(APartnerKey, ReadTransaction);

                            foreach (PSubscriptionRow SubscriptionRow in SubscriptionTable.Rows)
                            {
                                SubscriptionRecord = new TFormDataSubscription();

                                SubscriptionRecord.PublicationCode = SubscriptionRow.PublicationCode;
                                SubscriptionRecord.Status = SubscriptionRow.SubscriptionStatus;

                                formData.AddSubscription(SubscriptionRecord);
                            }
                        }

                        // retrieve banking information
                        if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eBanking))
                        {
                            PBankingDetailsUsageTable BankingDetailsUsageTable = new PBankingDetailsUsageTable();
                            PBankingDetailsUsageRow BankingDetailsUsageTemplateRow = BankingDetailsUsageTable.NewRowTyped(false);
                            BankingDetailsUsageTemplateRow.PartnerKey = APartnerKey;
                            BankingDetailsUsageTemplateRow.Type = MPartnerConstants.BANKINGUSAGETYPE_MAIN;

                            BankingDetailsUsageTable = PBankingDetailsUsageAccess.LoadUsingTemplate(BankingDetailsUsageTemplateRow, ReadTransaction);

                            if (BankingDetailsUsageTable.Count > 0)
                            {
                                // in this case there is a main bank account for this partner
                                PBankingDetailsTable BankingDetailsTable;
                                PBankingDetailsRow BankingDetailsRow;

                                BankingDetailsTable =
                                    (PBankingDetailsTable)(PBankingDetailsAccess.LoadByPrimaryKey(((PBankingDetailsUsageRow)BankingDetailsUsageTable.
                                                                                                   Rows[0]).
                                                               BankingDetailsKey, ReadTransaction));

                                if (BankingDetailsTable.Count > 0)
                                {
                                    BankingDetailsRow = (PBankingDetailsRow)BankingDetailsTable.Rows[0];
                                    formData.BankAccountName = BankingDetailsRow.AccountName;
                                    formData.BankAccountNumber = BankingDetailsRow.BankAccountNumber;
                                    formData.IBANUnformatted = BankingDetailsRow.Iban;
                                    //formData.IBANFormatted = ...;

                                    // now retrieve bank information
                                    PBankTable BankTable;
                                    PBankRow BankRow;

                                    BankTable = (PBankTable)(PBankAccess.LoadByPrimaryKey(BankingDetailsRow.BankKey, ReadTransaction));

                                    if (BankTable.Count > 0)
                                    {
                                        BankRow = (PBankRow)BankTable.Rows[0];
                                        formData.BankName = BankRow.BranchName;
                                        formData.BankBranchCode = BankRow.BranchCode;
                                        formData.BICSwiftCode = BankRow.Bic;
                                    }
                                }
                            }
                        }

                        if ((PartnerClass == TPartnerClass.PERSON)
                            && (formData.GetType() == typeof(TFormDataPerson)))
                        {
                            // retrieve Passport information
                            if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.ePassport))
                            {
                                PmPassportDetailsTable PassportTable;
                                TFormDataPassport PassportRecord;
                                PassportTable = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey, ReadTransaction);

                                foreach (PmPassportDetailsRow PassportRow in PassportTable.Rows)
                                {
                                    PassportRecord = new TFormDataPassport();

                                    PassportRecord.PassportName = PassportRow.FullPassportName;
                                    PassportRecord.NationalityCode = PassportRow.PassportNationalityCode;

                                    // retrieve country name from country table
                                    TCacheable CachePopulator = new TCacheable();
                                    PCountryTable CountryTable =
                                        (PCountryTable)CachePopulator.GetCacheableTable(TCacheableCommonTablesEnum.CountryList);
                                    PCountryRow CountryRow = (PCountryRow)CountryTable.Rows.Find(new object[] { PassportRow.PassportNationalityCode });

                                    if (CountryRow != null)
                                    {
                                        PassportRecord.NationalityName = CountryRow.CountryName;
                                    }

                                    PassportRecord.TypeCode = PassportRow.PassportDetailsType;
                                    // retrieve passport type name from type table
                                    TPersonnelCacheable PersonnelCachePopulator = new TPersonnelCacheable();
                                    PtPassportTypeTable TypeTable =
                                        (PtPassportTypeTable)PersonnelCachePopulator.GetCacheableTable(TCacheablePersonTablesEnum.PassportTypeList);
                                    PtPassportTypeRow TypeRow = (PtPassportTypeRow)TypeTable.Rows.Find(new object[] { PassportRow.PassportDetailsType });

                                    if (TypeRow != null)
                                    {
                                        PassportRecord.TypeDescription = TypeRow.Description;
                                    }

                                    // set number and nationality in main record (only for main passport or if there is just one)
                                    if (PassportRow.MainPassport || (PassportTable.Count == 1))
                                    {
                                        ((TFormDataPerson)formData).PassportNumber = PassportRow.PassportNumber;
                                        ((TFormDataPerson)formData).PassportNationality = PassportRow.PassportNationalityCode;
                                        ((TFormDataPerson)formData).PassportName = PassportRow.FullPassportName;
                                    }

                                    PassportRecord.DateOfIssue = PassportRow.DateOfIssue;
                                    PassportRecord.PlaceOfIssue = PassportRow.PlaceOfIssue;
                                    PassportRecord.DateOfExpiry = PassportRow.DateOfExpiration;
                                    PassportRecord.PlaceOfBirth = PassportRow.PlaceOfBirth;

                                    ((TFormDataPerson)formData).AddPassport(PassportRecord);
                                }
                            }

                            // retrieve Language information
                            if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eLanguage))
                            {
                                PmPersonLanguageTable PersonLanguageTable;
                                TFormDataLanguage PersonLanguageRecord;
                                PersonLanguageTable = PmPersonLanguageAccess.LoadViaPPerson(APartnerKey, ReadTransaction);

                                foreach (PmPersonLanguageRow PersonLanguageRow in PersonLanguageTable.Rows)
                                {
                                    PersonLanguageRecord = new TFormDataLanguage();

                                    PersonLanguageRecord.Code = PersonLanguageRow.LanguageCode;

                                    // retrieve language name from language table
                                    TCacheable CachePopulator = new TCacheable();
                                    PLanguageTable LanguageTable =
                                        (PLanguageTable)CachePopulator.GetCacheableTable(TCacheableCommonTablesEnum.LanguageCodeList);
                                    PLanguageRow LanguageRow = (PLanguageRow)LanguageTable.Rows.Find(new object[] { PersonLanguageRow.LanguageCode });

                                    if (LanguageRow != null)
                                    {
                                        PersonLanguageRecord.Name = LanguageRow.LanguageDescription;
                                    }

                                    PersonLanguageRecord.Level = PersonLanguageRow.LanguageLevel.ToString();

                                    // retrieve language level name from language level table
                                    TPersonnelCacheable CachePopulatorPersonnel = new TPersonnelCacheable();
                                    PtLanguageLevelTable LanguageLevelTable =
                                        (PtLanguageLevelTable)CachePopulatorPersonnel.GetCacheableTable(TCacheablePersonTablesEnum.LanguageLevelList);
                                    PtLanguageLevelRow LanguageLevelRow =
                                        (PtLanguageLevelRow)LanguageLevelTable.Rows.Find(new object[] { PersonLanguageRow.LanguageLevel });

                                    if (LanguageLevelRow != null)
                                    {
                                        PersonLanguageRecord.LevelDesc = LanguageLevelRow.LanguageLevelDescr;
                                    }

                                    PersonLanguageRecord.Comment = PersonLanguageRow.Comment;

                                    ((TFormDataPerson)formData).AddLanguage(PersonLanguageRecord);
                                }
                            }

                            // retrieve Skill information
                            if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eSkill))
                            {
                                PmPersonSkillTable PersonSkillTable;
                                TFormDataSkill PersonSkillRecord;
                                PersonSkillTable = PmPersonSkillAccess.LoadViaPPerson(APartnerKey, ReadTransaction);

                                foreach (PmPersonSkillRow PersonSkillRow in PersonSkillTable.Rows)
                                {
                                    PersonSkillRecord = new TFormDataSkill();

                                    PersonSkillRecord.Category = PersonSkillRow.SkillCategoryCode;
                                    PersonSkillRecord.Description = PersonSkillRow.DescriptionEnglish;

                                    // if no description in local language then use english
                                    PersonSkillRecord.DescriptionLocalOrDefault = PersonSkillRow.DescriptionLocal;

                                    if (PersonSkillRow.DescriptionLocal != "")
                                    {
                                        PersonSkillRecord.DescriptionLocalOrDefault = PersonSkillRow.DescriptionEnglish;
                                    }

                                    PersonSkillRecord.Level = PersonSkillRow.SkillLevel;

                                    // retrieve skill level name from skill level table
                                    TPersonnelCacheable CachePopulatorPersonnel = new TPersonnelCacheable();
                                    PtSkillLevelTable SkillLevelTable =
                                        (PtSkillLevelTable)CachePopulatorPersonnel.GetCacheableTable(TCacheablePersonTablesEnum.SkillLevelList);
                                    PtSkillLevelRow SkillLevelRow =
                                        (PtSkillLevelRow)SkillLevelTable.Rows.Find(new object[] { PersonSkillRow.SkillLevel });

                                    if (SkillLevelRow != null)
                                    {
                                        PersonSkillRecord.LevelDesc = SkillLevelRow.Description;
                                    }

                                    PersonSkillRecord.YearsExp = PersonSkillRow.YearsOfExperience;
                                    PersonSkillRecord.Professional = PersonSkillRow.ProfessionalSkill;
                                    PersonSkillRecord.Degree = PersonSkillRow.Degree;
                                    PersonSkillRecord.Comment = PersonSkillRow.Comment;

                                    ((TFormDataPerson)formData).AddSkill(PersonSkillRecord);
                                }
                            }

                            // retrieve past work experience information
                            if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eWorkExperience))
                            {
                                TFormDataWorkExperience PersonExpRecord;
                                String UnitShortName;
                                TPartnerClass UnitClass;

                                // retrieve applications for short term events
                                String SqlStmt = TDataBase.ReadSqlFile("Personnel.FormLetters.GetAppTravelDates.sql");

                                OdbcParameter[] parameters = new OdbcParameter[1];
                                parameters[0] = new OdbcParameter("PartnerKey", OdbcType.BigInt);
                                parameters[0].Value = APartnerKey;

                                DataTable travelData = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "TravelDates", ReadTransaction, parameters);

                                for (int i = 0; i < travelData.Rows.Count; i++)
                                {
                                    PersonExpRecord = new TFormDataWorkExperience();

                                    if ((travelData.Rows[i][0]).GetType() == typeof(DateTime))
                                    {
                                        PersonExpRecord.StartDate = (DateTime?)travelData.Rows[i][0];
                                    }

                                    if ((travelData.Rows[i][1]).GetType() == typeof(DateTime))
                                    {
                                        PersonExpRecord.EndDate = (DateTime?)travelData.Rows[i][1];
                                    }

                                    PersonExpRecord.Organisation = "";
                                    PersonExpRecord.Role = "";
                                    PersonExpRecord.Category = "";
                                    PersonExpRecord.SameOrg = true;
                                    PersonExpRecord.SimilarOrg = true;
                                    PersonExpRecord.Comment = "";

                                    // check if unit exists and use unit name as location
                                    if (TPartnerServerLookups.GetPartnerShortName((Int64)travelData.Rows[i][2], out UnitShortName, out UnitClass))
                                    {
                                        PersonExpRecord.Location = UnitShortName;
                                    }
                                    else
                                    {
                                        PersonExpRecord.Location = travelData.Rows[i][3].ToString();
                                    }

                                    ((TFormDataPerson)formData).AddWorkExperience(PersonExpRecord);
                                }

                                // retrieve actual past experience records
                                PmPastExperienceTable PersonExpTable;
                                PersonExpTable = PmPastExperienceAccess.LoadViaPPerson(APartnerKey, ReadTransaction);

                                foreach (PmPastExperienceRow PersonExpRow in PersonExpTable.Rows)
                                {
                                    PersonExpRecord = new TFormDataWorkExperience();

                                    PersonExpRecord.StartDate = PersonExpRow.StartDate;
                                    PersonExpRecord.EndDate = PersonExpRow.EndDate;
                                    PersonExpRecord.Location = PersonExpRow.PrevLocation;
                                    PersonExpRecord.Organisation = PersonExpRow.OtherOrganisation;
                                    PersonExpRecord.Role = PersonExpRow.PrevRole;
                                    PersonExpRecord.Category = PersonExpRow.Category;
                                    PersonExpRecord.SameOrg = PersonExpRow.PrevWorkHere;
                                    PersonExpRecord.SimilarOrg = PersonExpRow.PrevWork;
                                    PersonExpRecord.Comment = PersonExpRow.PastExpComments;

                                    ((TFormDataPerson)formData).AddWorkExperience(PersonExpRecord);
                                }
                            }
                        }
                    }
                });

            AFormDataPartner = formData;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        static TCallForwarding()
        {
            // Set up Error Codes and Data Validation Delegates for a Client's AppDomain.
            // This setting-up makes use of the fact that this Method is called only once,
            // namely directly after the Client logged in successfully.
            ErrorCodeInventory.RegisteredTypes.Add(new Ict.Petra.Shared.PetraErrorCodes().GetType());

            TSharedValidationHelper.SharedGetDataDelegate = @TCommonDataReader.GetData;
            TSharedPartnerValidationHelper.VerifyPartnerDelegate = @TPartnerServerLookups.VerifyPartner;
            TSharedFinanceValidationHelper.GetValidPostingDateRangeDelegate = @TFinanceServerLookups.GetCurrentPostingRangeDates;
            TMonthEnd.StewardshipCalculationDelegate = @TStewardshipCalculationWebConnector.PerformStewardshipCalculation;
            TGLPosting.PrintReportOnClientDelegate = @TReportingWebConnector.GenerateReportOnClient;

            // Set up Delegates for retrieval of cacheable tables when called from Shared directories on server side
            CachePopulatorCommon = new Ict.Petra.Server.MCommon.Cacheable.TCacheable();
            CachePopulatorConference = new Ict.Petra.Server.MConference.Cacheable.TCacheable();
            CachePopulatorFinance = new Ict.Petra.Server.MFinance.Cacheable.TCacheable();
            CachePopulatorMailing = new Ict.Petra.Server.MPartner.Mailing.Cacheable.TPartnerCacheable();
            CachePopulatorPartner = new Ict.Petra.Server.MPartner.Partner.Cacheable.TPartnerCacheable();
            CachePopulatorSubscriptions = new Ict.Petra.Server.MPartner.Subscriptions.Cacheable.TPartnerCacheable();
            CachePopulatorPersonnel = new Ict.Petra.Server.MPersonnel.Person.Cacheable.TPersonnelCacheable();
            CachePopulatorUnits = new Ict.Petra.Server.MPersonnel.Unit.Cacheable.TPersonnelCacheable();
            CachePopulatorSysMan = new Ict.Petra.Server.MSysMan.Cacheable.TCacheable();

            TSharedDataCache.TMCommon.GetCacheableCommonTableDelegate = @CachePopulatorCommon.GetCacheableTable;

            TSharedDataCache.TMFinance.GetCacheableFinanceTableDelegate = @CachePopulatorFinance.GetCacheableTable;

            TSharedDataCache.TMPartner.GetCacheablePartnerTableDelegate = @CachePopulatorPartner.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableMailingTableDelegate = @CachePopulatorMailing.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableSubscriptionsTableDelegate = @CachePopulatorSubscriptions.GetCacheableTable;

            TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate = @CachePopulatorPersonnel.GetCacheableTable;
            TSharedDataCache.TMPersonnel.GetCacheableUnitsTableDelegate = @CachePopulatorUnits.GetCacheableTable;

            TSharedDataCache.TMConference.GetCacheableConferenceTableDelegate = @CachePopulatorConference.GetCacheableTable;

            TSharedDataCache.TMSysMan.GetCacheableSysManTableDelegate = @CachePopulatorSysMan.GetCacheableTable;
        }
        /// <summary>
        /// Adds one partner to the report table
        /// </summary>
        /// <param name="APartnerKey">The partner key of the current partner</param>
        /// <param name="AGender">Gender of the current partner</param>
        /// <param name="ALanguageCode">The mother language of the current partner</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns></returns>
        public bool CalculateNationalities(long APartnerKey, String AGender, String ALanguageCode, ref TRptSituation ASituation)
        {
            TCacheable CommonCacheable = new TCacheable();

            StringCollection PassportColumns = StringHelper.StrSplit(
                PmPassportDetailsTable.GetDateOfIssueDBName() + "," +
                PmPassportDetailsTable.GetDateOfExpirationDBName() + "," +
                PmPassportDetailsTable.GetPassportNationalityCodeDBName() + "," +
                PmPassportDetailsTable.GetMainPassportDBName(), ",");

            PmPassportDetailsTable PassportDetailsDT = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey,
                PassportColumns, ASituation.GetDatabaseConnection().Transaction, null, 0, 0);

            string Nationalities = Ict.Petra.Shared.MPersonnel.Calculations.DeterminePersonsNationalities(
                @CommonCacheable.GetCacheableTable, PassportDetailsDT);

            string[] NationalitiesArray = Nationalities.Split(',');

            bool FoundNationality = false;
            List <string>PreviousNationalities = new List <string>();

            foreach (string Nationality in NationalitiesArray)
            {
                string SingleNationality = Nationality;

                // remove all characters other than the country name
                SingleNationality = Nationality.TrimStart(' ');

                if (SingleNationality.EndsWith(Ict.Petra.Shared.MPersonnel.Calculations.PASSPORT_EXPIRED))
                {
                    SingleNationality = SingleNationality.Remove(SingleNationality.Length -
                        Ict.Petra.Shared.MPersonnel.Calculations.PASSPORT_EXPIRED.Length);
                }
                else if (SingleNationality.EndsWith(Ict.Petra.Shared.MPersonnel.Calculations.PASSPORTMAIN_EXPIRED))
                {
                    SingleNationality = SingleNationality.Remove(SingleNationality.Length -
                        Ict.Petra.Shared.MPersonnel.Calculations.PASSPORTMAIN_EXPIRED.Length);
                }

                if (SingleNationality == "")
                {
                    SingleNationality = Catalog.GetString("UNKNOWN");
                }

                // make sure that this nationality has not already been processed for this partner
                if (!PreviousNationalities.Contains(SingleNationality))
                {
                    for (int Counter = 0; Counter < FNationalityTable.Rows.Count; ++Counter)
                    {
                        if (((String)FNationalityTable.Rows[Counter][COLUMNNATIONALITYCODE] == SingleNationality))
                        {
                            FoundNationality = true;
                            AddAttendeeToTable(Counter, AGender, SingleNationality, ALanguageCode);
                        }
                    }

                    if (!FoundNationality)
                    {
                        AddAttendeeToTable(-1, AGender, SingleNationality, ALanguageCode);
                    }

                    PreviousNationalities.Add(SingleNationality);
                }
            }

            return true;
        }