private void WriteLocation(PLocationRow ALocationRow, PPartnerLocationRow APartnerLocationRow, TLocationPK ABestAddressPK) { string PhoneNumber; string EmailAddress; string FaxNumber; Write(ALocationRow.IsSiteKeyNull() ? 0 : ALocationRow.SiteKey); Write(ALocationRow.IsLocalityNull() ? "" : ALocationRow.Locality); Write(ALocationRow.IsStreetNameNull() ? "" : ALocationRow.StreetName); Write(ALocationRow.IsAddress3Null() ? "" : ALocationRow.Address3); WriteLine(); Write(ALocationRow.IsCityNull() ? "" : ALocationRow.City); Write(ALocationRow.IsCountyNull() ? "" : ALocationRow.County); Write(ALocationRow.IsPostalCodeNull() ? "" : ALocationRow.PostalCode); Write(ALocationRow.IsCountryCodeNull() ? "" : ALocationRow.CountryCode); WriteLine(); Write(APartnerLocationRow.IsDateEffectiveNull() ? "?" : APartnerLocationRow.DateEffective.Value.ToString(DATEFORMAT)); Write(APartnerLocationRow.IsDateGoodUntilNull() ? "?" : APartnerLocationRow.DateGoodUntil.Value.ToString(DATEFORMAT)); Write(APartnerLocationRow.IsLocationTypeNull() ? "" : APartnerLocationRow.LocationType); Write(APartnerLocationRow.IsSendMailNull() ? false : APartnerLocationRow.SendMail); if ((APartnerLocationRow.LocationKey == ABestAddressPK.LocationKey) && (APartnerLocationRow.SiteKey == ABestAddressPK.SiteKey)) { // For the Location that is the 'Best Address' of the Partner we export 'Primary Phone Number', // 'Primary E-mail Address' and the 'Fax Number'. // They are exported for backwards compatibility as part of the 'Location' information as that is the only // place where the data was/is stored (and was/is seen and was/is maintained by the user) in Petra 2.x! TContactDetailsAggregate.GetPrimaryEmailAndPrimaryPhoneAndFax(APartnerLocationRow.PartnerKey, out PhoneNumber, out EmailAddress, out FaxNumber); Write(EmailAddress ?? String.Empty); Write(PhoneNumber ?? String.Empty); Write(0); // Phone Extensions are no longer kept in the Contact Details scheme so we can't export them... Write(FaxNumber ?? String.Empty); Write(0); // Fax Extensions are no longer kept in the Contact Details scheme so we can't export them... } else { // For any Location that isn't the 'Best Address' of the Partner: Export empty data for EmailAddress, // PhoneNumber, (Phone) Extension, Fax and Fax Extension. Write(String.Empty); Write(String.Empty); Write(0); Write(String.Empty); Write(0); } WriteLine(); }
/// <summary> /// For all members of the Family: if they have a PartnerLocation mapped to the /// same Location as the Family then update the DateGoodUntil column. /// /// @comment Must only be called for Partners of Partner Class FAMILY - the /// function does no checks on that and will fail for other Partner Classes! /// /// </summary> /// <param name="AFamilyPartnerKey">PartnerKey of the Family</param> /// <param name="APartnerLocationDR">PartnerLocation DataRow of the Family</param> /// <param name="ASubmitChangesTransaction">Running transaction in which the DB commands /// will be enlisted</param> private static void PromoteToFamilyMembersDateGoodUntilChange(Int64 AFamilyPartnerKey, PPartnerLocationRow APartnerLocationDR, TDBTransaction ASubmitChangesTransaction) { StringCollection RequiredColumns; PPersonTable FamilyPersonsDT; PPartnerLocationTable PartnerLocationDT; PPartnerLocationTable PartnerLocationSubmitDT; PPartnerLocationRow PartnerLocationSubmitDR; Int16 Counter; FamilyPersonsDT = GetFamilyMemberPartnerKeys(AFamilyPartnerKey, ASubmitChangesTransaction); PartnerLocationSubmitDT = new PPartnerLocationTable(); RequiredColumns = new StringCollection(); RequiredColumns.Add(PPartnerLocationTable.GetModificationIdDBName()); /* * For all members of the Family: if they have a PartnerLocation mapped to the * same Location as the Family then update the DateGoodUntil column */ // TLogging.LogAtLevel(9, "PromoteToFamilyMembersDateGoodUntilChange for Location " + APartnerLocationDR.LocationKey.ToString() + ": Family has " + FamilyPersonsDT.Rows.Count.ToString() + " members."); for (Counter = 0; Counter <= FamilyPersonsDT.Rows.Count - 1; Counter += 1) { // Load ModificationId for the PartnerLocation of each Person (otherwise we // will run into optimistic locking problems!) PartnerLocationDT = PPartnerLocationAccess.LoadByPrimaryKey( FamilyPersonsDT[Counter].PartnerKey, APartnerLocationDR.SiteKey, APartnerLocationDR.LocationKey, RequiredColumns, ASubmitChangesTransaction); /* * Check that found Person has PartnerLocation that is mapped to the same * Location than the one that the PartnerLocation of the Family that we are * processing is mapped to */ if (PartnerLocationDT.Rows.Count != 0) { // Build row to be able to update that PartnerLocation PartnerLocationSubmitDR = PartnerLocationSubmitDT.NewRowTyped(false); PartnerLocationSubmitDR.PartnerKey = FamilyPersonsDT[Counter].PartnerKey; PartnerLocationSubmitDR.SiteKey = APartnerLocationDR.SiteKey; PartnerLocationSubmitDR.LocationKey = APartnerLocationDR.LocationKey; PartnerLocationSubmitDR.ModificationId = PartnerLocationDT[0].ModificationId; PartnerLocationSubmitDT.Rows.Add(PartnerLocationSubmitDR); // Change its DateGoodUntil column to match the Family's PartnerLocation DateGoodUntil column if (!APartnerLocationDR.IsDateGoodUntilNull()) { // Make this row unchanged so that SubmitChanges later picks up a changed // DataRow, and not a new DataRow. PartnerLocationSubmitDR.AcceptChanges(); // Now change DateGoodUntil PartnerLocationSubmitDR.DateGoodUntil = APartnerLocationDR.DateGoodUntil; } else { // Change DataRow to a dummy value to make Null different to what was // there before PartnerLocationSubmitDR.DateGoodUntil = DateTime.MinValue; PartnerLocationSubmitDR.AcceptChanges(); // Now change DateGoodUntil PartnerLocationSubmitDR.SetDateGoodUntilNull(); } // Get PartnerLocation data of just processed Person out of memory! PartnerLocationDT.Rows.Clear(); } } /* * Save changes to DateGoodUntil columns if PartnerLocation of any FamilyMember got changed. */ if (PartnerLocationSubmitDT.Rows.Count > 0) { // Submit the changes to the DB PPartnerLocationAccess.SubmitChanges(PartnerLocationSubmitDT, ASubmitChangesTransaction); } }
private void WriteLocation(PLocationRow ALocationRow, PPartnerLocationRow APartnerLocationRow) { Write(ALocationRow.IsSiteKeyNull() ? 0 : ALocationRow.SiteKey); Write(ALocationRow.IsLocalityNull() ? "" : ALocationRow.Locality); Write(ALocationRow.IsStreetNameNull() ? "" : ALocationRow.StreetName); Write(ALocationRow.IsAddress3Null() ? "" : ALocationRow.Address3); WriteLine(); Write(ALocationRow.IsCityNull() ? "" : ALocationRow.City); Write(ALocationRow.IsCountyNull() ? "" : ALocationRow.County); Write(ALocationRow.IsPostalCodeNull() ? "" : ALocationRow.PostalCode); Write(ALocationRow.IsCountryCodeNull() ? "" : ALocationRow.CountryCode); WriteLine(); Write(APartnerLocationRow.IsDateEffectiveNull() ? "?" : APartnerLocationRow.DateEffective.Value.ToString(DATEFORMAT)); Write(APartnerLocationRow.IsDateGoodUntilNull() ? "?" : APartnerLocationRow.DateGoodUntil.Value.ToString(DATEFORMAT)); Write(APartnerLocationRow.IsLocationTypeNull() ? "" : APartnerLocationRow.LocationType); Write(APartnerLocationRow.IsSendMailNull() ? false : APartnerLocationRow.SendMail); Write(APartnerLocationRow.IsEmailAddressNull() ? "" : APartnerLocationRow.EmailAddress); Write(APartnerLocationRow.IsTelephoneNumberNull() ? "" : APartnerLocationRow.TelephoneNumber); Write(APartnerLocationRow.IsExtensionNull() ? 0 : APartnerLocationRow.Extension); Write(APartnerLocationRow.IsFaxNumberNull() ? "" : APartnerLocationRow.FaxNumber); Write(APartnerLocationRow.IsFaxExtensionNull() ? 0 : APartnerLocationRow.FaxExtension); WriteLine(); }