private DataTable GetDataLabelsForPartnerClassesListTable(TDBTransaction AReadTransaction, string ATableName)
        {
            const string PARTNERCLASSCOL = "PartnerClass";
            const string DLAVAILCOL      = "DataLabelsAvailable";

            DataTable TmpTable;
            DataRow   NewDR;
            TOfficeSpecificDataLabelsUIConnector OfficeSpecificDataLabelsUIConnector;

            // Create our custom Cacheable DataTable on-the-fly
            TmpTable = new DataTable(ATableName);
            DataColumn PKColumn = new DataColumn(PARTNERCLASSCOL, System.Type.GetType("System.String"));

            TmpTable.Columns.Add(PKColumn);
            TmpTable.Columns.Add(new DataColumn(DLAVAILCOL, System.Type.GetType("System.Boolean")));
            TmpTable.PrimaryKey = new DataColumn[] {
                PKColumn
            };

            /*
             * Create an Instance of TOfficeSpecificDataLabelsUIConnector - PartnerKey and DataLabelUse are not important here
             * because we only call Method 'CountLabelUse', which doesn't rely on any of them.
             */
            OfficeSpecificDataLabelsUIConnector = new TOfficeSpecificDataLabelsUIConnector(0,
                                                                                           TOfficeSpecificDataLabelUseEnum.Family);

            // DataLabels available for PERSONs?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.PERSON);
            NewDR[DLAVAILCOL]      =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            // DataLabels available for FAMILYs?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.FAMILY);
            NewDR[DLAVAILCOL]      =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            // DataLabels available for CHURCHes?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.CHURCH);
            NewDR[DLAVAILCOL]      =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            // DataLabels available for ORGANISATIONs?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.ORGANISATION);
            NewDR[DLAVAILCOL]      =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            // DataLabels available for UNITs?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.UNIT);
            NewDR[DLAVAILCOL]      =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            // DataLabels available for BANKs?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.BANK);
            NewDR[DLAVAILCOL]      =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            // DataLabels available for VENUEs?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.VENUE);
            NewDR[DLAVAILCOL]      =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            return(TmpTable);
        }
Beispiel #2
0
        /// <summary>
        /// Passes data as a Typed DataSet to the caller, containing a DataTable that corresponds with <paramref name="AIndivDataItem"></paramref>.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of the Person to load data for.</param>
        /// <param name="AIndivDataItem">The Individual Data Item for which data should be returned.</param>
        /// <param name="AReadTransaction">Open Database transaction.</param>
        /// <returns>A Typed DataSet containing a DataTable that corresponds with <paramref name="AIndivDataItem"></paramref>.</returns>
        private static IndividualDataTDS GetData(Int64 APartnerKey, TIndividualDataItemEnum AIndivDataItem, TDBTransaction AReadTransaction)
        {
            IndividualDataTDS IndividualDataDS = new IndividualDataTDS("IndividualData");   // create the IndividualDataTDS DataSet that will later be passed to the Client
            IndividualDataTDSMiscellaneousDataTable MiscellaneousDataDT;
            IndividualDataTDSMiscellaneousDataRow   MiscellaneousDataDR;

            #region Create 'Miscellaneous' DataRow

            MiscellaneousDataDT            = IndividualDataDS.MiscellaneousData;
            MiscellaneousDataDR            = MiscellaneousDataDT.NewRowTyped(false);
            MiscellaneousDataDR.PartnerKey = APartnerKey;

            MiscellaneousDataDT.Rows.Add(MiscellaneousDataDR);

            #endregion

            switch (AIndivDataItem)
            {
            case TIndividualDataItemEnum.idiSummary:
                BuildSummaryData(APartnerKey, ref IndividualDataDS, AReadTransaction);

                DetermineItemCounts(MiscellaneousDataDR, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiPersonalLanguages:
                PmPersonLanguageAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);

                PLanguageTable LanguageTable = (PLanguageTable)TSharedDataCache.TMCommon.GetCacheableCommonTable(
                    TCacheableCommonTablesEnum.LanguageCodeList);
                PLanguageRow LanguageRow;

                foreach (IndividualDataTDSPmPersonLanguageRow PersonLanguageRow in IndividualDataDS.PmPersonLanguage.Rows)
                {
                    LanguageRow = (PLanguageRow)LanguageTable.Rows.Find(new object[] { PersonLanguageRow.LanguageCode });

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

                break;

            case TIndividualDataItemEnum.idiSpecialNeeds:
                PmSpecialNeedAccess.LoadByPrimaryKey(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiPreviousExperiences:
                PmPastExperienceAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);

                PUnitTable UnitTable;
                PUnitRow   UnitRow;

                // For outreaches the event code is currently stored in the location field. Try to retrieve the correct
                // outreach event and return it's actual name (as the event does not mean much to anybody).
                foreach (IndividualDataTDSPmPastExperienceRow PastExpRow in IndividualDataDS.PmPastExperience.Rows)
                {
                    PUnitRow template = new PUnitTable().NewRowTyped(false);

                    template.OutreachCode = PastExpRow.PrevLocation;

                    UnitTable = PUnitAccess.LoadUsingTemplate(template, AReadTransaction);

                    if (UnitTable.Rows.Count > 0)
                    {
                        UnitRow = (PUnitRow)UnitTable.Rows[0];
                        PastExpRow.EventName = UnitRow.UnitName;
                    }
                }

                break;

            case TIndividualDataItemEnum.idiPersonalDocuments:
                PmDocumentAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiJobAssignments:
                PmJobAssignmentAccess.LoadViaPPartner(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiLocalPersonnelData:
                // TODO: Fix this so LocalPersonnelData can actually load some data
                bool labelsAvailable;
                TOfficeSpecificDataLabelsUIConnector OfficeSpecificDataLabelsUIConnector;
                OfficeSpecificDataLabelsUIConnector = new TOfficeSpecificDataLabelsUIConnector(APartnerKey,
                                                                                               TOfficeSpecificDataLabelUseEnum.Personnel);
                IndividualDataDS.Merge(OfficeSpecificDataLabelsUIConnector.GetDataLocalPartnerDataValues(APartnerKey, out labelsAvailable, false,
                                                                                                         AReadTransaction));
                break;

            case TIndividualDataItemEnum.idiProgressReports:
                PmPersonEvaluationAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiCommitmentPeriods:
                PmStaffDataAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiPersonSkills:
                PmPersonSkillAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiPersonalAbilities:
                PmPersonAbilityAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiPassportDetails:
                PmPassportDetailsAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);

                PCountryTable CountryTable = (PCountryTable)TSharedDataCache.TMCommon.GetCacheableCommonTable(
                    TCacheableCommonTablesEnum.CountryList);
                PCountryRow CountryRow;

                foreach (IndividualDataTDSPmPassportDetailsRow PassportRow in IndividualDataDS.PmPassportDetails.Rows)
                {
                    CountryRow = (PCountryRow)CountryTable.Rows.Find(new object[] { PassportRow.PassportNationalityCode });

                    if (CountryRow != null)
                    {
                        PassportRow.PassportNationalityName = CountryRow.CountryName;
                    }
                }

                break;

            case TIndividualDataItemEnum.idiPersonalData:
                PmPersonalDataAccess.LoadByPrimaryKey(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiEmergencyData:
                PmPersonalDataAccess.LoadByPrimaryKey(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiApplications:
                PmGeneralApplicationAccess.LoadViaPPersonPartnerKey(IndividualDataDS, APartnerKey, AReadTransaction);
                PmShortTermApplicationAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);
                PmYearProgramApplicationAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);

                IndividualDataTDSPmGeneralApplicationRow GenAppRow;
                TPartnerClass         PartnerClass;
                TStdPartnerStatusCode PartnerStatus;
                String EventOrFieldName;

                //TODO: now go through all short and long term apps and set the
                // two fields in general app for EventOrFieldName and ApplicationForEventOrField
                foreach (PmShortTermApplicationRow ShortTermRow in IndividualDataDS.PmShortTermApplication.Rows)
                {
                    GenAppRow = (IndividualDataTDSPmGeneralApplicationRow)IndividualDataDS.PmGeneralApplication.Rows.Find
                                    (new object[] { ShortTermRow.PartnerKey,
                                                    ShortTermRow.ApplicationKey, ShortTermRow.RegistrationOffice });
                    GenAppRow.ApplicationForEventOrField = Catalog.GetString("Event");

                    if (!ShortTermRow.IsStConfirmedOptionNull())
                    {
                        Ict.Petra.Server.MCommon.MCommonMain.RetrievePartnerShortName
                            (ShortTermRow.StConfirmedOption, out EventOrFieldName, out PartnerClass, out PartnerStatus);
                        GenAppRow.EventOrFieldName = EventOrFieldName;
                    }
                }

                foreach (PmYearProgramApplicationRow LongTermRow in IndividualDataDS.PmYearProgramApplication.Rows)
                {
                    GenAppRow = (IndividualDataTDSPmGeneralApplicationRow)IndividualDataDS.PmGeneralApplication.Rows.Find
                                    (new object[] { LongTermRow.PartnerKey,
                                                    LongTermRow.ApplicationKey, LongTermRow.RegistrationOffice });
                    GenAppRow.ApplicationForEventOrField = Catalog.GetString("Field");

                    if (!GenAppRow.IsGenAppPossSrvUnitKeyNull())
                    {
                        Ict.Petra.Server.MCommon.MCommonMain.RetrievePartnerShortName
                            (GenAppRow.GenAppPossSrvUnitKey, out EventOrFieldName, out PartnerClass, out PartnerStatus);
                        GenAppRow.EventOrFieldName = EventOrFieldName;
                    }
                }

                break;

                // TODO: work on all cases/load data for all Individual Data items
            }

            return(IndividualDataDS);
        }