public static PartnerEditTDS GetPartnerDetails(Int64 APartnerKey, bool AWithSubscriptions, bool AWithRelationships,
                                                       out string APrimaryPhoneNumber, out string APrimaryEmailAddress)
        {
            // Call the standard method including address details
            List <string>  Dummy1, Dummy2;
            string         Dummy3, Dummy4, Dummy5;
            PartnerEditTDS MainDS = GetPartnerDetails(APartnerKey, out Dummy1, out Dummy2, out Dummy3, out Dummy4, out Dummy5);

            // Now get the primary email and phone
            PPartnerAttributeTable attributeTable = TContactDetailsAggregate.GetPartnersContactDetailAttributes(APartnerKey);

            Calculations.GetPrimaryEmailAndPrimaryPhone(attributeTable, out APrimaryPhoneNumber, out APrimaryEmailAddress);

            return(MainDS);
        }
Exemple #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>
        /// Returns the attribute types and sequences for all the contact details selected in the grid.
        /// </summary>
        public List <string[]> GetContactDetails()
        {
            List <string[]> ContactDetails = new List <string[]>();
            int             i = 0;

            foreach (DataRow Row in FDataTable.Rows)
            {
                if (Convert.ToBoolean(Row["Checked"]) == true)
                {
                    ContactDetails.Add(new string[] { Row[PPartnerAttributeTable.GetAttributeTypeDBName()].ToString(),
                                                      Row[PPartnerAttributeTable.GetSequenceDBName()].ToString() });
                    i++;
                }
            }

            return(ContactDetails);
        }
        /// <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);
        }
Exemple #5
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);
        }
Exemple #6
0
        /// <summary>
        /// Gets additional mobile or landline numbers that are not the primary phone number.
        /// </summary>
        /// <param name="AReadTransaction"></param>
        /// <param name="APartnerKey">A partner key for which we are finding the additional information.</param>
        /// <param name="AMobileNumbers">Additional mobile numbers for the specified partner.  Empty string if none.</param>
        /// <param name="AAlternatePhoneNumbers">Additional landline numbers for the specified partner.  Empty string if none.</param>
        public static void GetPartnersAdditionalPhoneNumbers(
            TDBTransaction AReadTransaction,
            Int64 APartnerKey, out string AMobileNumbers, out string AAlternatePhoneNumbers)
        {
            AMobileNumbers         = string.Empty;
            AAlternatePhoneNumbers = string.Empty;

            // Get all the contact details for the specified partner and then find the ones that relate to phones
            PPartnerAttributeTable partnerAttributeDT = GetPartnersContactDetailAttributes(APartnerKey);
            DataView allPhoneNumbers = Calculations.DeterminePartnerPhoneNumbers(AReadTransaction, partnerAttributeDT, true, false);

            foreach (DataRowView rv in allPhoneNumbers)
            {
                // Evaluate each row in turn
                PPartnerAttributeRow row = (PPartnerAttributeRow)rv.Row;

                if (row.NoLongerCurrentFrom != null)
                {
                    if (row.NoLongerCurrentFrom < DateTime.Today)
                    {
                        continue;
                    }
                }

                if (row.AttributeType == MPartnerConstants.ATTR_TYPE_MOBILE_PHONE)
                {
                    if (row.Primary == false)
                    {
                        string number = Calculations.ConcatenatePhoneOrFaxNumberWithIntlCountryPrefix(row);
                        AMobileNumbers += (AMobileNumbers.Length > 0) ? "; " : string.Empty;
                        AMobileNumbers += number;
                    }
                }
                else if (row.AttributeType == MPartnerConstants.ATTR_TYPE_PHONE)
                {
                    if (row.Primary == false)
                    {
                        string number = Calculations.ConcatenatePhoneOrFaxNumberWithIntlCountryPrefix(row);
                        AAlternatePhoneNumbers += (AAlternatePhoneNumbers.Length > 0) ? "; " : string.Empty;
                        AAlternatePhoneNumbers += number;
                    }
                }
            }
        }
        /// <summary>
        /// Populates the grid for the dialog for selecting Addresses to be merged.
        /// </summary>
        public void InitializeContactDetailGrid(long AFromPartnerKey, long AToPartnerKey)
        {
            // set text for label
            lblInfo.Text = Catalog.GetString(
                "The following contact details exist for the Partner being merged. Select the contact details to be transferred.") +
                           "\n\n" + Catalog.GetString("Any contact details which are not selected will be deleted!");

            string CheckedMember       = "CHECKED";
            string ContactCategory     = PartnerEditTDSPPartnerAttributeTable.GetCategoryCodeDBName();
            string ContactType         = PPartnerAttributeTable.GetAttributeTypeDBName();
            string Sequence            = PPartnerAttributeTable.GetSequenceDBName();
            string Value               = PPartnerAttributeTable.GetValueDBName();
            string Primary             = PPartnerAttributeTable.GetPrimaryDBName();
            string Business            = PPartnerAttributeTable.GetSpecialisedDBName();
            string Current             = PPartnerAttributeTable.GetCurrentDBName();
            string NoLongerCurrentFrom = PPartnerAttributeTable.GetNoLongerCurrentFromDBName();
            string Comment             = PPartnerAttributeTable.GetCommentDBName();


            PartnerEditTDSPPartnerAttributeTable ContactDetails =
                TRemote.MPartner.Partner.WebConnectors.GetPartnerContactDetails(AFromPartnerKey, AToPartnerKey);
            DataView MyDataView = ContactDetails.DefaultView;

            FDataTable = MyDataView.ToTable(true, new string[]
                                            { ContactCategory, ContactType, Sequence, Value, Primary, Business, Current, NoLongerCurrentFrom, Comment });
            FDataTable.Columns.Add(new DataColumn(CheckedMember, typeof(bool)));

            clbRecords.Columns.Clear();
            clbRecords.AddCheckBoxColumn("", FDataTable.Columns[CheckedMember], 17, false);
            clbRecords.AddTextColumn("Category", FDataTable.Columns[ContactCategory]);
            clbRecords.AddTextColumn("Type", FDataTable.Columns[ContactType]);
            clbRecords.AddTextColumn("Value", FDataTable.Columns[Value]);
            clbRecords.AddCheckBoxColumn("Primary", FDataTable.Columns[Primary], true);
            clbRecords.AddCheckBoxColumn("Business", FDataTable.Columns[Business], true);
            clbRecords.AddCheckBoxColumn("Current", FDataTable.Columns[Current], true);
            clbRecords.AddDateColumn("No Longer Current From", FDataTable.Columns[NoLongerCurrentFrom]);
            clbRecords.AddTextColumn("Comment", FDataTable.Columns[Comment]);
            clbRecords.ValueChanged += new EventHandler(OnCheckboxChange);

            clbRecords.DataBindGrid(FDataTable, ContactCategory + ", " + ContactType + ", " + Value, CheckedMember, Value, false, true, false);
            clbRecords.SetCheckedStringList("");

            clbRecords.AutoResizeGrid();
        }
        private void GetDataAccordingToContactComboType(TOverallContactComboType AContactComboType,
            out TCmbAutoComplete AComboBoxForContactComboType, out DataColumn ADataColumn)
        {
            string PhoneComboTypeStr;  // Ignored, but needed as this is an out Argument of GetDataAccordingToContactComboType...

            GetDataAccordingToContactComboType(AContactComboType, out AComboBoxForContactComboType, out PhoneComboTypeStr);

            switch (AContactComboType)
            {
                case TOverallContactComboType.occtPrimaryPhone:
                    ADataColumn = new PPartnerAttributeTable().Columns[PPartnerAttributeTable.ColumnPrimaryId];

                    break;

                case TOverallContactComboType.occtPhoneWithinOrganisation:
                    ADataColumn = new PPartnerAttributeTable().Columns[PPartnerAttributeTable.ColumnWithinOrganisationId];

                    break;

                case TOverallContactComboType.occtPrimaryEmail:
                    ADataColumn = new PPartnerAttributeTable().Columns[PPartnerAttributeTable.ColumnPrimaryId];

                    break;

                case TOverallContactComboType.occtEmailWithinOrganisation:
                    ADataColumn = new PPartnerAttributeTable().Columns[PPartnerAttributeTable.ColumnWithinOrganisationId];

                    break;

                default:
                    ADataColumn = null;

                    break;
            }
        }
        /// <summary>
        /// Called when data got saved in the screen. Performs a check whether reloading
        /// of the 'SummaryData' is necessary to reflect changes that were done elsewhere
        /// in the Partner Edit screen and which just got saved.
        /// </summary>
        /// <returns>void</returns>
        public void CheckForRefreshOfDisplayedData(bool AJobAndStaffDataGridNeedsRefresh)
        {
            bool   RefreshNecessary = false;
            string PhoneOfPerson;
            string EmailOfPerson;

            if (!AJobAndStaffDataGridNeedsRefresh)
            {
                Int64[] SupportingChurchesPartnerKeys = new long[0];

                if (FMainDS.Tables[PPartnerAttributeTable.GetTableName()] != null)
                {
                    // Check for change of the 'Primary Phone Number' and the 'Primary E-mail Address' of the PERSON
                    DeterminePrimaryEmailAndPrimaryPhone(out PhoneOfPerson, out EmailOfPerson);

                    if ((PhoneOfPerson != FPhoneOfPerson) ||
                        (EmailOfPerson != FEmailOfPerson))
                    {
                        RefreshNecessary = true;
                    }
                }

                if (FMainDS.Tables[PPartnerRelationshipTable.GetTableName()] != null)
                {
                    // Check for change in supporting Church/es relationship(s)
                    DetermineChurchRelationships(out SupportingChurchesPartnerKeys);

                    if ((FSupportingChurchesPartnerKeys == null) ||
                        (FSupportingChurchesPartnerKeys.Length != SupportingChurchesPartnerKeys.Length))
                    {
                        RefreshNecessary = true;
                    }
                    else
                    {
                        for (int Counter = 0; Counter < SupportingChurchesPartnerKeys.Length; Counter++)
                        {
                            if (SupportingChurchesPartnerKeys[Counter] != FSupportingChurchesPartnerKeys[Counter])
                            {
                                RefreshNecessary = true;
                            }
                        }
                    }
                }
            }
            else
            {
                RefreshNecessary = true;
            }

            if (RefreshNecessary)
            {
                // Call WebConnector to retrieve SummaryData afresh!
                IndividualDataTDS FillDS = new IndividualDataTDS();
                FillDS.Merge(FMainDS.MiscellaneousData);

                TRemote.MPersonnel.Person.DataElements.WebConnectors.GetSummaryData(FMainDS.PPerson[0].PartnerKey, ref FillDS);

                FMainDS.SummaryData.Rows.Clear();
                FMainDS.Merge(FillDS.SummaryData);
                FMainDS.JobAssignmentStaffDataCombined.Rows.Clear();
                FMainDS.Merge(FillDS.JobAssignmentStaffDataCombined);

                // Refresh the displayed data
                SpecialShowData();
            }
        }
Exemple #10
0
        private static void MergeContactDetails(long AFromPartnerKey, long AToPartnerKey, TPartnerClass AFromPartnerClass,
            TPartnerClass AToPartnerClass, List <string[]>AContactDetails, TDBTransaction ATransaction)
        {
            PPartnerAttributeTable FromContactDetails = new PPartnerAttributeTable();
            PPartnerAttributeTable ToContactDetails = new PPartnerAttributeTable();

            string Query = "SELECT p_partner_attribute.*" +
                           " FROM p_partner_attribute, p_partner_attribute_category, p_partner_attribute_type" +
                           " WHERE p_partner_attribute.p_partner_key_n = ?" +
                           " AND p_partner_attribute.p_attribute_type_c = p_partner_attribute_type.p_attribute_type_c" +
                           " AND p_partner_attribute_category.p_category_code_c = p_partner_attribute_type.p_category_code_c" +
                           " AND (p_partner_attribute_category.p_partner_contact_category_l = 'true'" +
                           " OR p_partner_attribute.p_attribute_type_c = 'PARTNERS_PRIMARY_CONTACT_METHOD'" +
                           " OR p_partner_attribute.p_attribute_type_c = 'PARTNERS_SECONDARY_EMAIL_ADDRESS')";

            OdbcParameter[] Parameters = new OdbcParameter[1];
            Parameters[0] = new OdbcParameter("PartnerKey", OdbcType.Int);
            Parameters[0].Value = AFromPartnerKey;

            DBAccess.GDBAccessObj.SelectDT(FromContactDetails, Query, ATransaction, Parameters);

            Parameters[0].Value = AToPartnerKey;

            DBAccess.GDBAccessObj.SelectDT(ToContactDetails, Query, ATransaction, Parameters);

            // get max sequence numbers for each attribute
            List <string[]>MaxSequenceNumbers = new List <string[]>();

            foreach (PPartnerAttributeRow ToRow in ToContactDetails.Rows)
            {
                int Index = MaxSequenceNumbers.FindIndex(x => x[0] == ToRow.AttributeType);

                if (Index != -1)
                {
                    if (Convert.ToInt32(MaxSequenceNumbers[Index][1]) < ToRow.Sequence)
                    {
                        MaxSequenceNumbers[Index][1] = ToRow.Sequence.ToString();
                    }
                }
                else
                {
                    MaxSequenceNumbers.Add(new string[] { ToRow.AttributeType, ToRow.Sequence.ToString() });
                }
            }

            foreach (PPartnerAttributeRow FromRow in FromContactDetails.Rows)
            {
                // if this is a detail that is to be merged (we already know that To partner does not contain the exact same contact detail)
                // or a contact details setting
                if ((FromRow.AttributeType == "PARTNERS_PRIMARY_CONTACT_METHOD") || (FromRow.AttributeType == "PARTNERS_SECONDARY_EMAIL_ADDRESS")
                    || AContactDetails.Exists(x => (x[0] == FromRow.AttributeType) && (x[1] == FromRow.Sequence.ToString())))
                {
                    bool TwoPrimary = false;
                    bool TwoOffice = false;
                    bool DeleteRow = false;

                    // fix fields that there can only be one of
                    foreach (PPartnerAttributeRow ToRow in ToContactDetails.Rows)
                    {
                        if (FromRow.Primary && (ToRow.AttributeType == FromRow.AttributeType) && ToRow.Primary)
                        {
                            // if this is a primary contact detail for this attribute type and
                            // the To Partner already contains a primary contact detail for this attribute type
                            TwoPrimary = true;
                        }

                        if ((AFromPartnerClass == TPartnerClass.PERSON) && FromRow.WithinOrganisation
                            && (ToRow.AttributeType == FromRow.AttributeType) && ToRow.WithinOrganisation)
                        {
                            // if this is an office contact detail (person only) for this attribute type and
                            // the To Partner already contains an office contact detail for this attribute type
                            TwoOffice = true;
                        }
                        else if ((AFromPartnerClass == TPartnerClass.FAMILY) && (FromRow.AttributeType == "PARTNERS_SECONDARY_EMAIL_ADDRESS")
                                 && ((AToPartnerClass != TPartnerClass.FAMILY) || (ToRow.AttributeType == FromRow.AttributeType)))
                        {
                            // if this is a secondary email (family only) and
                            // the To Partner is not a family partner or already contains a secondary email
                            DeleteRow = true;
                            break;
                        }

                        if ((FromRow.AttributeType == "PARTNERS_PRIMARY_CONTACT_METHOD") && (ToRow.AttributeType == FromRow.AttributeType))
                        {
                            // if this is a primary contact method and the To Partner already contains a primary contact method
                            DeleteRow = true;
                            break;
                        }
                    }

                    if (DeleteRow)
                    {
                        FromRow.Delete();
                        continue;
                    }
                    else if (TwoPrimary)
                    {
                        FromRow.Primary = false;
                    }
                    else if (TwoOffice)
                    {
                        FromRow.WithinOrganisation = false;
                    }

                    FromRow.PartnerKey = AToPartnerKey;

                    // fix sequence number
                    int Index = MaxSequenceNumbers.FindIndex(x => x[0] == FromRow.AttributeType);

                    // if attribute type already exists for ToPartner
                    if (Index != -1)
                    {
                        // use the next sequence number
                        FromRow.Sequence = Convert.ToInt32(MaxSequenceNumbers[Index][1]) + 1;
                        MaxSequenceNumbers[Index][1] = (FromRow.Sequence).ToString();
                    }
                    else
                    {
                        // use 0
                        FromRow.Sequence = 0;
                        MaxSequenceNumbers.Add(new string[] { FromRow.AttributeType, "0" });
                    }
                }
                else
                {
                    FromRow.Delete();
                }
            }

            FromContactDetails.ThrowAwayAfterSubmitChanges = true;
            PPartnerAttributeAccess.SubmitChanges(FromContactDetails, ATransaction);
        }
        /// <summary>
        /// Determines the 'Primary' and/or 'Within Organisation' setting(s) for a Partner.
        /// </summary>
        /// <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(Int64 APartnerKey,
            Calculations.TOverallContSettingKind AOverallContSettingKind, out PPartnerAttributeTable APartnerAttributeDT)
        {
            Calculations.TPartnersOverallContactSettings PrimaryContactAttributes = null;
            TDBTransaction ReadTransaction = null;
            PPartnerAttributeTable PartnerAttributeDT = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                TEnforceIsolationLevel.eilMinimum,
                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(PartnerAttributeDT);

                        PrimaryContactAttributes = Calculations.DeterminePrimaryOrWithinOrgSettingsForPartner(
                            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(
                                PartnerAttributeDT, ref PrimaryContactAttributes, AOverallContSettingKind);
                        }
                    }
                });

            APartnerAttributeDT = PartnerAttributeDT;

            return PrimaryContactAttributes;
        }
        /// <summary>
        /// Checks whether Partner Attributes of the same Attribute Type exist in the database.
        /// </summary>
        /// <param name="AImportedPartnerAttribRow"><see cref="PPartnerAttributeRow" /> that holds the imported data.</param>
        /// <param name="AFoundPartnerAttribDR"><see cref="PPartnerAttributeRow" /> that holds the record that was found -
        /// if one was found, otherwise this is null.</param>
        /// <param name="ATransaction">Instantiated DB Transaction.</param>
        /// <returns>False if the row should be imported as found in the import file, otherwise true.</returns>
        public static bool ExistingPartnerAttributes(PPartnerAttributeRow AImportedPartnerAttribRow,
            out PPartnerAttributeRow AFoundPartnerAttribDR, TDBTransaction ATransaction)
        {
            PPartnerAttributeTable ExistingPartnerAttributeDT;

            AFoundPartnerAttribDR = null;

            // Find existing Partner Attribute(s) of the same AttributeType (ignoring sequence!)
            PPartnerAttributeRow TmpPartnerAttributeRow = new PPartnerAttributeTable().NewRowTyped(false);
            TmpPartnerAttributeRow.PartnerKey = AImportedPartnerAttribRow.PartnerKey;
            TmpPartnerAttributeRow.AttributeType = AImportedPartnerAttribRow.AttributeType;

            ExistingPartnerAttributeDT = PartnerAttributeLoadUsingTemplate(TmpPartnerAttributeRow, null, ATransaction);

            if (ExistingPartnerAttributeDT.Count == 0)
            {
                // No existing Partner Attribute(s) of the same AttributeType -->
                // we want to import the row as found in the import file!
                return false;
            }

            // Existing Partner Attribute(s) of the same AttributeType --> Check to see whether we want to import
            // that Row, or whether we want to overwrite an existing Row with some imported data!
            for (int Counter = 0; Counter < ExistingPartnerAttributeDT.Rows.Count; Counter++)
            {
                if (ExistingPartnerAttributeDT[Counter].Value == AImportedPartnerAttribRow.Value)
                {
                    // This *is* the same Partner Attribute!
                    AFoundPartnerAttribDR = ExistingPartnerAttributeDT[Counter];

                    break;
                }
                else if (AImportedPartnerAttribRow.AttributeType == Ict.Petra.Shared.MPartner.Calculations.ATTR_TYPE_PARTNERS_PRIMARY_CONTACT_METHOD)
                {
                    // This *is* the same Partner Attribute!
                    AFoundPartnerAttribDR = ExistingPartnerAttributeDT[Counter];

                    break;
                }
            }

            if (AFoundPartnerAttribDR != null)
            {
                // Same Partner Attribute --> overwrite the Row that is existing in the DB with some imported data!
                return true;
            }

            // No existing Partner Attribute(s) of the same AttributeType with the same Value -->
            // we want to import the row as found in the import file!
            return false;
        }
        /// Upgrade to version 2015-01
        public static bool UpgradeDatabase201412_201501()
        {
            // There are no new tables and fields

            TDBTransaction       SubmitChangesTransaction = null;
            TSubmitChangesResult SubmissionResult         = TSubmitChangesResult.scrError;

            DBAccess.GDBAccessObj.BeginAutoTransaction(IsolationLevel.Serializable, ref SubmitChangesTransaction,
                                                       ref SubmissionResult,
                                                       delegate
            {
                PPartnerAttributeTable partnerattributes = new PPartnerAttributeTable();
                PPartnerLocationTable partnerlocations   = PPartnerLocationAccess.LoadAll(SubmitChangesTransaction);

                // this update only works for very simple databases, only one partner location record per partner...
                if (partnerlocations.Count > 1000)
                {
                    throw new Exception("the upgrade has not been optimized for huge databases");
                }

                List <Int64> PartnerKeys = new List <Int64>();

                foreach (PPartnerLocationRow partnerlocation in partnerlocations.Rows)
                {
                    if (!PartnerKeys.Contains(partnerlocation.PartnerKey))
                    {
                        PartnerKeys.Add(partnerlocation.PartnerKey);
                    }
                    else
                    {
                        TLogging.Log("several locations for partner " + partnerlocation.PartnerKey.ToString());
                    }
                }

                // Number for the p_sequence_i Column. Gets increased with every p_partner_attribute record that gets produced!
                int SequenceNumber = 0;

                foreach (Int64 partnerkey in PartnerKeys)
                {
                    // Get that Partner's p_partner_location records from PPartnerLocationRecords
                    DataRow[] CurrentRows = partnerlocations.Select(PPartnerLocationTable.GetPartnerKeyDBName() + " = " + partnerkey.ToString());

                    if (CurrentRows.Length == 0)
                    {
                        continue;
                    }

                    DataTable PPartnersLocationsDT = GetNewPPartnerLocationTableInstance();

                    foreach (DataRow r in CurrentRows)
                    {
                        PPartnersLocationsDT.Rows.Add(r.ItemArray);
                    }

                    TLocationPK bestAddress = Calculations.DetermineBestAddress(PPartnersLocationsDT);

                    int IndexPhone  = 0;
                    int IndexEmail  = 0;
                    int IndexFax    = 0;
                    int IndexUrl    = 0;
                    int IndexMobile = 0;

                    List <string> AvoidDuplicates = new List <string>();
                    string AttributeConcatenated;

                    foreach (PPartnerLocationRow partnerlocation in PPartnersLocationsDT.Rows)
                    {
                        bool primaryAddress =
                            (bestAddress.LocationKey == partnerlocation.LocationKey && bestAddress.SiteKey == partnerlocation.SiteKey);
                        bool currentAddress  = (((int)partnerlocation[PARTNERLOCATION_ICON_COLUMN]) == 1);
                        bool businessAddress = (partnerlocation.LocationType == "BUSINESS" || partnerlocation.LocationType == "FIELD");
                        // TODO: avoid duplicate entries with the same type

                        if (!partnerlocation.IsEmailAddressNull())
                        {
                            PPartnerAttributeRow partnerattribute = partnerattributes.NewRowTyped();
                            partnerattribute.Sequence             = SequenceNumber++;
                            partnerattribute.PartnerKey           = partnerlocation.PartnerKey;
                            partnerattribute.Value               = partnerlocation.EmailAddress;
                            partnerattribute.AttributeType       = MPartnerConstants.ATTR_TYPE_EMAIL;
                            partnerattribute.Current             = currentAddress;
                            partnerattribute.Primary             = primaryAddress;
                            partnerattribute.Index               = IndexEmail++;
                            partnerattribute.Specialised         = businessAddress;
                            partnerattribute.NoLongerCurrentFrom = partnerlocation.DateGoodUntil;

                            AttributeConcatenated = ConcatPartnerAttributes(partnerattribute);

                            if (!AvoidDuplicates.Contains(AttributeConcatenated))
                            {
                                partnerattributes.Rows.Add(partnerattribute);
                                AvoidDuplicates.Add(AttributeConcatenated);
                            }
                            else
                            {
                                TLogging.Log("dropping duplicate " + AttributeConcatenated);
                            }

                            partnerlocation.SetEmailAddressNull();
                        }

                        if (!partnerlocation.IsTelephoneNumberNull())
                        {
                            if (!partnerlocation.IsExtensionNull())
                            {
                                partnerlocation.TelephoneNumber += "-" + partnerlocation.Extension;
                            }

                            PPartnerAttributeRow partnerattribute = partnerattributes.NewRowTyped();
                            partnerattribute.Sequence             = SequenceNumber++;
                            partnerattribute.PartnerKey           = partnerlocation.PartnerKey;
                            partnerattribute.Value               = partnerlocation.TelephoneNumber;
                            partnerattribute.AttributeType       = MPartnerConstants.ATTR_TYPE_PHONE;
                            partnerattribute.Current             = currentAddress;
                            partnerattribute.Primary             = primaryAddress;
                            partnerattribute.Index               = IndexPhone++;
                            partnerattribute.Specialised         = businessAddress;
                            partnerattribute.NoLongerCurrentFrom = partnerlocation.DateGoodUntil;

                            AttributeConcatenated = ConcatPartnerAttributes(partnerattribute);

                            if (!AvoidDuplicates.Contains(AttributeConcatenated))
                            {
                                partnerattributes.Rows.Add(partnerattribute);
                                AvoidDuplicates.Add(AttributeConcatenated);
                            }
                            else
                            {
                                TLogging.Log("dropping duplicate " + AttributeConcatenated);
                            }

                            partnerlocation.SetTelephoneNumberNull();
                        }

                        if (!partnerlocation.IsFaxNumberNull())
                        {
                            if (!partnerlocation.IsFaxExtensionNull())
                            {
                                partnerlocation.FaxNumber += "-" + partnerlocation.FaxExtension;
                            }

                            PPartnerAttributeRow partnerattribute = partnerattributes.NewRowTyped();
                            partnerattribute.Sequence             = SequenceNumber++;
                            partnerattribute.PartnerKey           = partnerlocation.PartnerKey;
                            partnerattribute.Value               = partnerlocation.FaxNumber;
                            partnerattribute.AttributeType       = MPartnerConstants.ATTR_TYPE_FAX;
                            partnerattribute.Current             = currentAddress;
                            partnerattribute.Primary             = primaryAddress;
                            partnerattribute.Index               = IndexFax++;
                            partnerattribute.Specialised         = businessAddress;
                            partnerattribute.NoLongerCurrentFrom = partnerlocation.DateGoodUntil;

                            AttributeConcatenated = ConcatPartnerAttributes(partnerattribute);

                            if (!AvoidDuplicates.Contains(AttributeConcatenated))
                            {
                                partnerattributes.Rows.Add(partnerattribute);
                                AvoidDuplicates.Add(AttributeConcatenated);
                            }
                            else
                            {
                                TLogging.Log("dropping duplicate " + AttributeConcatenated);
                            }

                            partnerlocation.SetFaxNumberNull();
                        }

                        if (!partnerlocation.IsAlternateTelephoneNull())
                        {
                            PPartnerAttributeRow partnerattribute = partnerattributes.NewRowTyped();
                            partnerattribute.Sequence             = SequenceNumber++;
                            partnerattribute.PartnerKey           = partnerlocation.PartnerKey;
                            partnerattribute.Value               = partnerlocation.AlternateTelephone;
                            partnerattribute.AttributeType       = MPartnerConstants.ATTR_TYPE_PHONE;
                            partnerattribute.Current             = currentAddress;
                            partnerattribute.Primary             = primaryAddress;
                            partnerattribute.Index               = IndexPhone++;
                            partnerattribute.Specialised         = businessAddress;
                            partnerattribute.NoLongerCurrentFrom = partnerlocation.DateGoodUntil;

                            AttributeConcatenated = ConcatPartnerAttributes(partnerattribute);

                            if (!AvoidDuplicates.Contains(AttributeConcatenated))
                            {
                                partnerattributes.Rows.Add(partnerattribute);
                                AvoidDuplicates.Add(AttributeConcatenated);
                            }
                            else
                            {
                                TLogging.Log("dropping duplicate " + AttributeConcatenated);
                            }

                            partnerlocation.SetAlternateTelephoneNull();
                        }

                        if (!partnerlocation.IsMobileNumberNull())
                        {
                            PPartnerAttributeRow partnerattribute = partnerattributes.NewRowTyped();
                            partnerattribute.Sequence             = SequenceNumber++;
                            partnerattribute.PartnerKey           = partnerlocation.PartnerKey;
                            partnerattribute.Value               = partnerlocation.MobileNumber;
                            partnerattribute.AttributeType       = MPartnerConstants.ATTR_TYPE_MOBILE_PHONE;
                            partnerattribute.Current             = currentAddress;
                            partnerattribute.Primary             = primaryAddress;
                            partnerattribute.Index               = IndexMobile++;
                            partnerattribute.Specialised         = businessAddress;
                            partnerattribute.NoLongerCurrentFrom = partnerlocation.DateGoodUntil;

                            AttributeConcatenated = ConcatPartnerAttributes(partnerattribute);

                            if (!AvoidDuplicates.Contains(AttributeConcatenated))
                            {
                                partnerattributes.Rows.Add(partnerattribute);
                                AvoidDuplicates.Add(AttributeConcatenated);
                            }
                            else
                            {
                                TLogging.Log("dropping duplicate " + AttributeConcatenated);
                            }

                            partnerlocation.SetMobileNumberNull();
                        }

                        if (!partnerlocation.IsUrlNull())
                        {
                            PPartnerAttributeRow partnerattribute = partnerattributes.NewRowTyped();
                            partnerattribute.Sequence             = SequenceNumber++;
                            partnerattribute.PartnerKey           = partnerlocation.PartnerKey;
                            partnerattribute.Value               = partnerlocation.Url;
                            partnerattribute.AttributeType       = MPartnerConstants.ATTR_TYPE_WEBSITE;
                            partnerattribute.Current             = currentAddress;
                            partnerattribute.Primary             = primaryAddress;
                            partnerattribute.Index               = IndexUrl++;
                            partnerattribute.Specialised         = businessAddress;
                            partnerattribute.NoLongerCurrentFrom = partnerlocation.DateGoodUntil;

                            AttributeConcatenated = ConcatPartnerAttributes(partnerattribute);

                            if (!AvoidDuplicates.Contains(AttributeConcatenated))
                            {
                                partnerattributes.Rows.Add(partnerattribute);
                                AvoidDuplicates.Add(AttributeConcatenated);
                            }
                            else
                            {
                                TLogging.Log("dropping duplicate " + AttributeConcatenated);
                            }

                            partnerlocation.SetUrlNull();
                        }
                    }
                }

                PPartnerLocationAccess.SubmitChanges(partnerlocations, SubmitChangesTransaction);
                PPartnerAttributeAccess.SubmitChanges(partnerattributes, SubmitChangesTransaction);
                SubmissionResult = TSubmitChangesResult.scrOK;
            });
            return(true);
        }
        /// Upgrade to version 2015-01
        public static bool UpgradeDatabase201412_201501()
        {
            // There are no new tables and fields

            TDBTransaction SubmitChangesTransaction = null;
            TSubmitChangesResult SubmissionResult = TSubmitChangesResult.scrError;

            DBAccess.GDBAccessObj.BeginAutoTransaction(IsolationLevel.Serializable, ref SubmitChangesTransaction,
                ref SubmissionResult,
                delegate
                {
                    PPartnerAttributeTable partnerattributes = new PPartnerAttributeTable();
                    PPartnerLocationTable partnerlocations = PPartnerLocationAccess.LoadAll(SubmitChangesTransaction);

                    // this update only works for very simple databases, only one partner location record per partner...
                    if (partnerlocations.Count > 1000)
                    {
                        throw new Exception("the upgrade has not been optimized for huge databases");
                    }

                    List <Int64>PartnerKeys = new List <Int64>();

                    foreach (PPartnerLocationRow partnerlocation in partnerlocations.Rows)
                    {
                        if (!PartnerKeys.Contains(partnerlocation.PartnerKey))
                        {
                            PartnerKeys.Add(partnerlocation.PartnerKey);
                        }
                        else
                        {
                            TLogging.Log("several locations for partner " + partnerlocation.PartnerKey.ToString());
                        }
                    }

                    // Number for the p_sequence_i Column. Gets increased with every p_partner_attribute record that gets produced!
                    int SequenceNumber = 0;

                    foreach (Int64 partnerkey in PartnerKeys)
                    {
                        // Get that Partner's p_partner_location records from PPartnerLocationRecords
                        DataRow[] CurrentRows = partnerlocations.Select(PPartnerLocationTable.GetPartnerKeyDBName() + " = " + partnerkey.ToString());

                        if (CurrentRows.Length == 0)
                        {
                            continue;
                        }

                        DataTable PPartnersLocationsDT = GetNewPPartnerLocationTableInstance();

                        foreach (DataRow r in CurrentRows)
                        {
                            PPartnersLocationsDT.Rows.Add(r.ItemArray);
                        }

                        TLocationPK bestAddress = Calculations.DetermineBestAddress(PPartnersLocationsDT);

                        int IndexPhone = 0;
                        int IndexEmail = 0;
                        int IndexFax = 0;
                        int IndexUrl = 0;
                        int IndexMobile = 0;

                        List <string>AvoidDuplicates = new List <string>();
                        string AttributeConcatenated;

                        foreach (PPartnerLocationRow partnerlocation in PPartnersLocationsDT.Rows)
                        {
                            bool primaryAddress =
                                (bestAddress.LocationKey == partnerlocation.LocationKey && bestAddress.SiteKey == partnerlocation.SiteKey);
                            bool currentAddress = (((int)partnerlocation[PARTNERLOCATION_ICON_COLUMN]) == 1);
                            bool businessAddress = (partnerlocation.LocationType == "BUSINESS" || partnerlocation.LocationType == "FIELD");
                            // TODO: avoid duplicate entries with the same type

                            if (!partnerlocation.IsEmailAddressNull())
                            {
                                PPartnerAttributeRow partnerattribute = partnerattributes.NewRowTyped();
                                partnerattribute.Sequence = SequenceNumber++;
                                partnerattribute.PartnerKey = partnerlocation.PartnerKey;
                                partnerattribute.Value = partnerlocation.EmailAddress;
                                partnerattribute.AttributeType = MPartnerConstants.ATTR_TYPE_EMAIL;
                                partnerattribute.Current = currentAddress;
                                partnerattribute.Primary = primaryAddress;
                                partnerattribute.Index = IndexEmail++;
                                partnerattribute.Specialised = businessAddress;
                                partnerattribute.NoLongerCurrentFrom = partnerlocation.DateGoodUntil;

                                AttributeConcatenated = ConcatPartnerAttributes(partnerattribute);

                                if (!AvoidDuplicates.Contains(AttributeConcatenated))
                                {
                                    partnerattributes.Rows.Add(partnerattribute);
                                    AvoidDuplicates.Add(AttributeConcatenated);
                                }
                                else
                                {
                                    TLogging.Log("dropping duplicate " + AttributeConcatenated);
                                }

                                partnerlocation.SetEmailAddressNull();
                            }

                            if (!partnerlocation.IsTelephoneNumberNull())
                            {
                                if (!partnerlocation.IsExtensionNull())
                                {
                                    partnerlocation.TelephoneNumber += "-" + partnerlocation.Extension;
                                }

                                PPartnerAttributeRow partnerattribute = partnerattributes.NewRowTyped();
                                partnerattribute.Sequence = SequenceNumber++;
                                partnerattribute.PartnerKey = partnerlocation.PartnerKey;
                                partnerattribute.Value = partnerlocation.TelephoneNumber;
                                partnerattribute.AttributeType = MPartnerConstants.ATTR_TYPE_PHONE;
                                partnerattribute.Current = currentAddress;
                                partnerattribute.Primary = primaryAddress;
                                partnerattribute.Index = IndexPhone++;
                                partnerattribute.Specialised = businessAddress;
                                partnerattribute.NoLongerCurrentFrom = partnerlocation.DateGoodUntil;

                                AttributeConcatenated = ConcatPartnerAttributes(partnerattribute);

                                if (!AvoidDuplicates.Contains(AttributeConcatenated))
                                {
                                    partnerattributes.Rows.Add(partnerattribute);
                                    AvoidDuplicates.Add(AttributeConcatenated);
                                }
                                else
                                {
                                    TLogging.Log("dropping duplicate " + AttributeConcatenated);
                                }

                                partnerlocation.SetTelephoneNumberNull();
                            }

                            if (!partnerlocation.IsFaxNumberNull())
                            {
                                if (!partnerlocation.IsFaxExtensionNull())
                                {
                                    partnerlocation.FaxNumber += "-" + partnerlocation.FaxExtension;
                                }

                                PPartnerAttributeRow partnerattribute = partnerattributes.NewRowTyped();
                                partnerattribute.Sequence = SequenceNumber++;
                                partnerattribute.PartnerKey = partnerlocation.PartnerKey;
                                partnerattribute.Value = partnerlocation.FaxNumber;
                                partnerattribute.AttributeType = MPartnerConstants.ATTR_TYPE_FAX;
                                partnerattribute.Current = currentAddress;
                                partnerattribute.Primary = primaryAddress;
                                partnerattribute.Index = IndexFax++;
                                partnerattribute.Specialised = businessAddress;
                                partnerattribute.NoLongerCurrentFrom = partnerlocation.DateGoodUntil;

                                AttributeConcatenated = ConcatPartnerAttributes(partnerattribute);

                                if (!AvoidDuplicates.Contains(AttributeConcatenated))
                                {
                                    partnerattributes.Rows.Add(partnerattribute);
                                    AvoidDuplicates.Add(AttributeConcatenated);
                                }
                                else
                                {
                                    TLogging.Log("dropping duplicate " + AttributeConcatenated);
                                }

                                partnerlocation.SetFaxNumberNull();
                            }

                            if (!partnerlocation.IsAlternateTelephoneNull())
                            {
                                PPartnerAttributeRow partnerattribute = partnerattributes.NewRowTyped();
                                partnerattribute.Sequence = SequenceNumber++;
                                partnerattribute.PartnerKey = partnerlocation.PartnerKey;
                                partnerattribute.Value = partnerlocation.AlternateTelephone;
                                partnerattribute.AttributeType = MPartnerConstants.ATTR_TYPE_PHONE;
                                partnerattribute.Current = currentAddress;
                                partnerattribute.Primary = primaryAddress;
                                partnerattribute.Index = IndexPhone++;
                                partnerattribute.Specialised = businessAddress;
                                partnerattribute.NoLongerCurrentFrom = partnerlocation.DateGoodUntil;

                                AttributeConcatenated = ConcatPartnerAttributes(partnerattribute);

                                if (!AvoidDuplicates.Contains(AttributeConcatenated))
                                {
                                    partnerattributes.Rows.Add(partnerattribute);
                                    AvoidDuplicates.Add(AttributeConcatenated);
                                }
                                else
                                {
                                    TLogging.Log("dropping duplicate " + AttributeConcatenated);
                                }

                                partnerlocation.SetAlternateTelephoneNull();
                            }

                            if (!partnerlocation.IsMobileNumberNull())
                            {
                                PPartnerAttributeRow partnerattribute = partnerattributes.NewRowTyped();
                                partnerattribute.Sequence = SequenceNumber++;
                                partnerattribute.PartnerKey = partnerlocation.PartnerKey;
                                partnerattribute.Value = partnerlocation.MobileNumber;
                                partnerattribute.AttributeType = MPartnerConstants.ATTR_TYPE_MOBILE_PHONE;
                                partnerattribute.Current = currentAddress;
                                partnerattribute.Primary = primaryAddress;
                                partnerattribute.Index = IndexMobile++;
                                partnerattribute.Specialised = businessAddress;
                                partnerattribute.NoLongerCurrentFrom = partnerlocation.DateGoodUntil;

                                AttributeConcatenated = ConcatPartnerAttributes(partnerattribute);

                                if (!AvoidDuplicates.Contains(AttributeConcatenated))
                                {
                                    partnerattributes.Rows.Add(partnerattribute);
                                    AvoidDuplicates.Add(AttributeConcatenated);
                                }
                                else
                                {
                                    TLogging.Log("dropping duplicate " + AttributeConcatenated);
                                }

                                partnerlocation.SetMobileNumberNull();
                            }

                            if (!partnerlocation.IsUrlNull())
                            {
                                PPartnerAttributeRow partnerattribute = partnerattributes.NewRowTyped();
                                partnerattribute.Sequence = SequenceNumber++;
                                partnerattribute.PartnerKey = partnerlocation.PartnerKey;
                                partnerattribute.Value = partnerlocation.Url;
                                partnerattribute.AttributeType = MPartnerConstants.ATTR_TYPE_WEBSITE;
                                partnerattribute.Current = currentAddress;
                                partnerattribute.Primary = primaryAddress;
                                partnerattribute.Index = IndexUrl++;
                                partnerattribute.Specialised = businessAddress;
                                partnerattribute.NoLongerCurrentFrom = partnerlocation.DateGoodUntil;

                                AttributeConcatenated = ConcatPartnerAttributes(partnerattribute);

                                if (!AvoidDuplicates.Contains(AttributeConcatenated))
                                {
                                    partnerattributes.Rows.Add(partnerattribute);
                                    AvoidDuplicates.Add(AttributeConcatenated);
                                }
                                else
                                {
                                    TLogging.Log("dropping duplicate " + AttributeConcatenated);
                                }

                                partnerlocation.SetUrlNull();
                            }
                        }
                    }

                    PPartnerLocationAccess.SubmitChanges(partnerlocations, SubmitChangesTransaction);
                    PPartnerAttributeAccess.SubmitChanges(partnerattributes, SubmitChangesTransaction);
                    SubmissionResult = TSubmitChangesResult.scrOK;
                });
            return true;
        }