Ejemplo n.º 1
0
 /// <summary>
 /// Retrieves PartnerAttribute information.
 /// </summary>
 /// <param name="APartnerKey">PartnerKey of Partner to find the short name for</param>
 /// <param name="APartnerInfoDS">Typed DataSet that contains the requested data.</param>
 /// <param name="AReadTransaction">Open Database Transaction.</param>
 private static void PartnerAttributesInternal(Int64 APartnerKey, ref PartnerInfoTDS APartnerInfoDS,
                                               TDBTransaction AReadTransaction)
 {
     /*
      * Load PartnerAttribute Information; this gets merged into the already retrieved
      * information in APartnerInfoDS (eg. 'Head' data)
      */
     APartnerInfoDS.Merge(PPartnerAttributeAccess.LoadViaPPartner(APartnerKey, AReadTransaction));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the Contact Detail Attributes for a Partner.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of the Partner.</param>
        /// <returns>An instance of <see cref="PPartnerAttributeTable"/> that holds the
        /// p_partner_attribute records for the Partner. Every Partner Attribute that *is* a Partner Contact Attribute
        /// is marked with 'true' in the special Column
        /// <see cref="Ict.Petra.Shared.MPartner.Calculations.PARTNERATTRIBUTE_PARTNERCONTACTDETAIL_COLUMN"/>!
        /// </returns>
        public static PPartnerAttributeTable GetPartnersContactDetailAttributes(Int64 APartnerKey)
        {
            PPartnerAttributeTable ReturnValue     = null;
            TDBTransaction         ReadTransaction = new TDBTransaction();

            DBAccess.ReadTransaction(
                ref ReadTransaction,
                delegate
            {
                // Load all PPartnerAttribute records of the Partner and put them into a DataTable
                ReturnValue = PPartnerAttributeAccess.LoadViaPPartner(APartnerKey, ReadTransaction);
                Calculations.DeterminePartnerContactDetailAttributes(ReturnValue);
            });

            return(ReturnValue);
        }
        /// <summary>
        /// Gets the Contact Detail Attributes for a Partner.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of the Partner.</param>
        /// <returns>An instance of <see cref="PPartnerAttributeTable"/> that holds the
        /// p_partner_attribute records for the Partner. Every Partner Attribute that *is* a Partner Contact Attribute
        /// is marked with 'true' in the special Column
        /// <see cref="Ict.Petra.Shared.MPartner.Calculations.PARTNERATTRIBUTE_PARTNERCONTACTDETAIL_COLUMN"/>!
        /// </returns>
        public static PPartnerAttributeTable GetPartnersContactDetailAttributes(Int64 APartnerKey)
        {
            PPartnerAttributeTable ReturnValue     = null;
            TDBTransaction         ReadTransaction = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                      TEnforceIsolationLevel.eilMinimum,
                                                                      ref ReadTransaction,
                                                                      delegate
            {
                // Load all PPartnerAttribute records of the Partner and put them into a DataTable
                ReturnValue = PPartnerAttributeAccess.LoadViaPPartner(APartnerKey, ReadTransaction);
                Calculations.DeterminePartnerContactDetailAttributes(ReturnValue);
            });

            return(ReturnValue);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Determines the 'Primary' and/or 'Within Organisation' setting(s) for a Partner.
        /// </summary>
        /// <param name="AReadTransaction"></param>
        /// <param name="APartnerKey">PartnerKey of the Partner.</param>
        /// <param name="AOverallContSettingKind">Specify the kind of Overall Contact Setting(s) that you want returned.
        /// Combine multiple ones with the binary OR operator ( | ).</param>
        /// <param name="APartnerAttributeDT">Contains the Partners' p_partner_attribute records. The ones that are
        /// 'Contact Details' have 'true' in the Column
        /// <see cref="Calculations.PARTNERATTRIBUTE_PARTNERCONTACTDETAIL_COLUMN"/>!</param>
        /// <returns>An instance of <see cref="Calculations.TPartnersOverallContactSettings"/> that holds the
        /// <see cref="Calculations.TPartnersOverallContactSettings"/> for the Partner. However, it returns null
        /// in case the Partner hasn't got any p_partner_attribute records, or when the Partner has no p_partner_attribute
        /// records that constitute Contact Detail records, or when the Partner has got only one p_partner_attribute record
        /// but this records' Current flag is false. It also returns null if no record was found that met what was asked for
        /// with <paramref name="AOverallContSettingKind"/>!</returns>
        public static Calculations.TPartnersOverallContactSettings GetPartnersOverallCS(
            TDBTransaction AReadTransaction,
            Int64 APartnerKey,
            Calculations.TOverallContSettingKind AOverallContSettingKind, out PPartnerAttributeTable APartnerAttributeDT)
        {
            Calculations.TPartnersOverallContactSettings PrimaryContactAttributes = null;
            TDBTransaction         ReadTransaction    = new TDBTransaction();
            PPartnerAttributeTable PartnerAttributeDT = null;

            DBAccess.ReadTransaction(
                ref ReadTransaction,
                delegate
            {
                // Load all PPartnerAttribute records of the Partner and put them into a DataTable
                PartnerAttributeDT = PPartnerAttributeAccess.LoadViaPPartner(APartnerKey, ReadTransaction);

                if (PartnerAttributeDT.Rows.Count > 0)
                {
                    Calculations.DeterminePartnerContactDetailAttributes(ReadTransaction, PartnerAttributeDT);

                    PrimaryContactAttributes = Calculations.DeterminePrimaryOrWithinOrgSettingsForPartner(
                        AReadTransaction,
                        PartnerAttributeDT, AOverallContSettingKind);

                    if (((AOverallContSettingKind & Calculations.TOverallContSettingKind.ocskPrimaryContactMethod) ==
                         Calculations.TOverallContSettingKind.ocskPrimaryContactMethod) ||
                        ((AOverallContSettingKind & Calculations.TOverallContSettingKind.ocskSecondaryEmailAddress) ==
                         Calculations.TOverallContSettingKind.ocskSecondaryEmailAddress))
                    {
                        if (PrimaryContactAttributes == null)
                        {
                            PrimaryContactAttributes = new Calculations.TPartnersOverallContactSettings();
                        }

                        Calculations.DeterminePartnerSystemCategorySettings(
                            AReadTransaction,
                            PartnerAttributeDT, ref PrimaryContactAttributes, AOverallContSettingKind);
                    }
                }
            });

            APartnerAttributeDT = PartnerAttributeDT;

            return(PrimaryContactAttributes);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Load all the data of a partner into a TDS
        /// </summary>
        public static PartnerImportExportTDS ExportPartner(Int64 APartnerKey, TPartnerClass?APartnerClass = null)
        {
            PartnerImportExportTDS MainDS = new PartnerImportExportTDS();

            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(
                ref Transaction,
                delegate
            {
                PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                // APartnerClass is optional but if it was not provided we need to assign to it now
                if (APartnerClass == null)
                {
                    APartnerClass = SharedTypes.PartnerClassStringToEnum(MainDS.PPartner[0].PartnerClass);
                }

                if (APartnerClass == TPartnerClass.CHURCH)
                {
                    PChurchAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                }
                else if (APartnerClass == TPartnerClass.FAMILY)
                {
                    PFamilyAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                    PPartnerGiftDestinationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                }
                else if (APartnerClass == TPartnerClass.PERSON)
                {
                    PPersonAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                    PmPersonalDataAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                    PmPassportDetailsAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmDocumentAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                    PmDocumentTypeAccess.LoadAll(MainDS, Transaction);
                    PmPersonQualificationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmSpecialNeedAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmPastExperienceAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmPersonLanguageAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmPersonAbilityAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmJobAssignmentAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                    PmPersonEvaluationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmPersonSkillAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);

                    PmGeneralApplicationAccess.LoadViaPPersonPartnerKey(MainDS, APartnerKey, Transaction);
                    PtApplicationTypeAccess.LoadAll(MainDS, Transaction);
                    PmShortTermApplicationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmYearProgramApplicationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                }
                else if (APartnerClass == TPartnerClass.ORGANISATION)
                {
                    POrganisationAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                }
                else if (APartnerClass == TPartnerClass.UNIT)
                {
                    PUnitAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                    UmUnitStructureAccess.LoadViaPUnitChildUnitKey(MainDS, APartnerKey, Transaction);
                    UmUnitAbilityAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                    UmUnitLanguageAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                    UmUnitCostAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                    UmJobAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                    UmJobRequirementAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                    UmJobLanguageAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                    UmJobQualificationAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                }
                else if (APartnerClass == TPartnerClass.VENUE)
                {
                    PVenueAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                    PcBuildingAccess.LoadViaPVenue(MainDS, APartnerKey, Transaction);
                    PcRoomAccess.LoadViaPVenue(MainDS, APartnerKey, Transaction);
                }

                PPartnerAttributeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                PLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                PPartnerLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                PPartnerCommentAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                PPartnerTypeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                PPartnerInterestAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                PInterestAccess.LoadAll(MainDS, Transaction);
            });

            return(MainDS);
        }
Ejemplo n.º 6
0
        public static PartnerEditTDS GetPartnerDetails(Int64 APartnerKey,
                                                       out List <string> ASubscriptions,
                                                       out List <string> APartnerTypes,
                                                       out string ADefaultEmailAddress,
                                                       out string ADefaultPhoneMobile,
                                                       out string ADefaultPhoneLandline)
        {
            PartnerEditTDS MainDS               = new PartnerEditTDS();
            List <string>  Subscriptions        = new List <string>();
            List <string>  PartnerTypes         = new List <string>();
            string         DefaultEmailAddress  = String.Empty;
            string         DefaultPhoneMobile   = String.Empty;
            string         DefaultPhoneLandline = String.Empty;

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, ref Transaction,
                                                           delegate
            {
                PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                if (MainDS.PPartner.Rows.Count > 0)
                {
                    switch (MainDS.PPartner[0].PartnerClass)
                    {
                    case MPartnerConstants.PARTNERCLASS_FAMILY:
                        PFamilyAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_PERSON:
                        PPersonAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_CHURCH:
                        PChurchAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_ORGANISATION:
                        POrganisationAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_BANK:
                        PBankAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_UNIT:
                        PUnitAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;
                    }

                    if (true)
                    {
                        PPartnerLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                        PLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                    }

                    if (true)
                    {
                        PPartnerRelationshipAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);
                    }

                    if (true)
                    {
                        PPublicationAccess.LoadAll(MainDS, Transaction);
                        PSubscriptionAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);

                        foreach (PSubscriptionRow subscription in MainDS.PSubscription.Rows)
                        {
                            Subscriptions.Add(subscription.PublicationCode);
                        }
                    }

                    PPartnerStatusAccess.LoadAll(MainDS, Transaction);
                    PTypeAccess.LoadAll(MainDS, Transaction);
                    PPartnerTypeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                    foreach (PPartnerTypeRow partnertype in MainDS.PPartnerType.Rows)
                    {
                        PartnerTypes.Add(partnertype.TypeCode);
                    }

                    PPartnerAttributeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                    foreach (PPartnerAttributeRow partnerattr in MainDS.PPartnerAttribute.Rows)
                    {
                        if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_EMAIL)
                        {
                            DefaultEmailAddress = partnerattr.Value;
                        }
                        else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_PHONE)
                        {
                            DefaultPhoneLandline = partnerattr.Value;
                        }
                        else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_MOBILE_PHONE)
                        {
                            DefaultPhoneMobile = partnerattr.Value;
                        }
                    }
                }
            });

            APartnerTypes         = PartnerTypes;
            ASubscriptions        = Subscriptions;
            ADefaultEmailAddress  = DefaultEmailAddress;
            ADefaultPhoneMobile   = DefaultPhoneMobile;
            ADefaultPhoneLandline = DefaultPhoneLandline;

            return(MainDS);
        }
Ejemplo n.º 7
0
        public static PartnerEditTDS GetPartnerDetails(Int64 APartnerKey,
                                                       out List <string> ASubscriptions,
                                                       out List <string> APartnerTypes,
                                                       out string ADefaultEmailAddress,
                                                       out string ADefaultPhoneMobile,
                                                       out string ADefaultPhoneLandline)
        {
            PartnerEditTDS MainDS               = new PartnerEditTDS();
            List <string>  Subscriptions        = new List <string>();
            List <string>  PartnerTypes         = new List <string>();
            string         DefaultEmailAddress  = String.Empty;
            string         DefaultPhoneMobile   = String.Empty;
            string         DefaultPhoneLandline = String.Empty;

            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(ref Transaction,
                                     delegate
            {
                PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                if (MainDS.PPartner.Rows.Count > 0)
                {
                    switch (MainDS.PPartner[0].PartnerClass)
                    {
                    case MPartnerConstants.PARTNERCLASS_FAMILY:
                        PFamilyAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_PERSON:
                        PPersonAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_CHURCH:
                        PChurchAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_ORGANISATION:
                        POrganisationAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_BANK:
                        PBankAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_UNIT:
                        PUnitAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;
                    }

                    if (true)
                    {
                        PPartnerLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                        PLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                    }

                    if (true)
                    {
                        PPartnerRelationshipAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);
                    }

                    if (true)
                    {
                        PCountryAccess.LoadAll(MainDS, Transaction);
                    }

                    if (true)
                    {
                        PPublicationAccess.LoadAll(MainDS, Transaction);
                        PSubscriptionAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);

                        foreach (PSubscriptionRow subscription in MainDS.PSubscription.Rows)
                        {
                            Subscriptions.Add(subscription.PublicationCode);
                        }
                    }

                    if (true)
                    {
                        PBankingDetailsAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                        PPartnerBankingDetailsAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                        PBankingDetailsUsageAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                        foreach (PartnerEditTDSPBankingDetailsRow banking in MainDS.PBankingDetails.Rows)
                        {
                            PBankAccess.LoadByPrimaryKey(MainDS, banking.BankKey, Transaction);
                            banking.Bic        = MainDS.PBank[0].Bic;
                            banking.BranchName = MainDS.PBank[0].BranchName;
                            banking.Iban       = FormatIBAN(banking.Iban);
                            MainDS.PBank.Rows.Clear();
                        }

                        foreach (PartnerEditTDSPBankingDetailsRow bd in MainDS.PBankingDetails.Rows)
                        {
                            bd.MainAccount =
                                (MainDS.PBankingDetailsUsage.Rows.Find(
                                     new object[] { APartnerKey, bd.BankingDetailsKey, MPartnerConstants.BANKINGUSAGETYPE_MAIN }) != null);
                        }

                        MainDS.PBankingDetailsUsage.Rows.Clear();
                    }

                    PPartnerStatusAccess.LoadAll(MainDS, Transaction);
                    PTypeRow templateRow   = MainDS.PType.NewRowTyped();
                    templateRow.SystemType = false;
                    templateRow.SetTypeDeletableNull();
                    templateRow.SetDateCreatedNull();
                    PTypeAccess.LoadUsingTemplate(MainDS, templateRow, Transaction);
                    PPartnerTypeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                    foreach (PPartnerTypeRow partnertype in MainDS.PPartnerType.Rows)
                    {
                        PartnerTypes.Add(partnertype.TypeCode);
                    }

                    PPartnerAttributeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                    foreach (PPartnerAttributeRow partnerattr in MainDS.PPartnerAttribute.Rows)
                    {
                        if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_EMAIL)
                        {
                            DefaultEmailAddress = partnerattr.Value;
                        }
                        else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_PHONE)
                        {
                            DefaultPhoneLandline = partnerattr.Value;
                        }
                        else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_MOBILE_PHONE)
                        {
                            DefaultPhoneMobile = partnerattr.Value;
                        }
                    }
                }
            });

            APartnerTypes         = PartnerTypes;
            ASubscriptions        = Subscriptions;
            ADefaultEmailAddress  = DefaultEmailAddress;
            ADefaultPhoneMobile   = DefaultPhoneMobile;
            ADefaultPhoneLandline = DefaultPhoneLandline;

            return(MainDS);
        }