public static PPartnerTable SharedBankAccountPartners(int ABankingDetailsKey, long APartnerKey) { PPartnerTable PartnerTable = new PPartnerTable(); TDBTransaction Transaction = null; DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, ref Transaction, delegate { PPartnerBankingDetailsTable PartnerBankingDetailsTable = PPartnerBankingDetailsAccess.LoadViaPBankingDetails(ABankingDetailsKey, Transaction); foreach (PPartnerBankingDetailsRow Row in PartnerBankingDetailsTable.Rows) { // if record exists with a different partner key then the Bank Account is shared if (Row.PartnerKey != APartnerKey) { PPartnerRow PartnerRow = (PPartnerRow)PPartnerAccess.LoadByPrimaryKey(Row.PartnerKey, Transaction).Rows[0]; PPartnerRow NewRow = PartnerTable.NewRowTyped(false); NewRow.PartnerKey = Row.PartnerKey; NewRow.PartnerShortName = PartnerRow.PartnerShortName; PartnerTable.Rows.Add(NewRow); } } }); return(PartnerTable); }
public static PPartnerTable SharedBankAccountPartners(int ABankingDetailsKey, long APartnerKey) { TDBTransaction ReadTransaction; Boolean NewTransaction; PPartnerTable PartnerTable = new PPartnerTable(); ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, out NewTransaction); try { PPartnerBankingDetailsTable PartnerBankingDetailsTable = PPartnerBankingDetailsAccess.LoadViaPBankingDetails(ABankingDetailsKey, ReadTransaction); foreach (PPartnerBankingDetailsRow Row in PartnerBankingDetailsTable.Rows) { // if record exists with a different partner key then the Bank Account is shared if (Row.PartnerKey != APartnerKey) { PPartnerRow PartnerRow = (PPartnerRow)PPartnerAccess.LoadByPrimaryKey(Row.PartnerKey, ReadTransaction).Rows[0]; PPartnerRow NewRow = PartnerTable.NewRowTyped(false); NewRow.PartnerKey = Row.PartnerKey; NewRow.PartnerShortName = PartnerRow.PartnerShortName; PartnerTable.Rows.Add(NewRow); } } } finally { if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); TLogging.LogAtLevel(7, "TPartnerDataReaderWebConnector.IsBankingDetailsRowShared: committed own transaction."); } } return(PartnerTable); }
/// <summary> /// Performs Partner Status change promotion to Family Members. /// /// </summary> /// <param name="AInspectDS">the dataset that will be saved later to the database</param> /// <param name="ANewPartnerStatusCode">The new Partner StatusCode</param> /// <param name="APartnerTypeChangeFamilyMembersDT">DataTable holding the PartnerKeys of /// Family Members (Note: These could be retrieved from the DB on-the-fly, but /// we really want to be sure that the promotion is done to those Family /// Members that we presented on the UI)</param> /// <param name="ASubmitChangesTransaction">Running transaction in which the DB commands /// will be enlisted</param> /// <returns>true if processing was successful, otherwise false /// </returns> private Boolean SpecialSubmitProcessingPartnerStatusChange( PartnerEditTDS AInspectDS, String ANewPartnerStatusCode, PartnerEditTDSFamilyMembersInfoForStatusChangeTable APartnerTypeChangeFamilyMembersDT, TDBTransaction ASubmitChangesTransaction) { PPartnerTable PartnerSaveDT = new PPartnerTable(); // TLogging.LogAtLevel(7, "TPartnerEditUIConnector.SpecialSubmitProcessingPartnerStatusChange: processing " + APartnerTypeChangeFamilyMembersDT.Rows.Count.ToString() + " Partners..."); // Loop over all Family Members that were presented to the user for (Int16 Counter = 0; Counter <= APartnerTypeChangeFamilyMembersDT.Rows.Count - 1; Counter += 1) { PartnerEditTDSFamilyMembersInfoForStatusChangeRow PartnerDR = APartnerTypeChangeFamilyMembersDT[Counter]; // Load Family Member's Partner record PPartnerTable PartnerDT = PPartnerAccess.LoadByPrimaryKey(PartnerDR.PartnerKey, ASubmitChangesTransaction); if (PartnerDT[0].StatusCode != ANewPartnerStatusCode) { // StatusCode of the Partner is different to the new StatusCode > change it PPartnerRow PartnerSaveDR = PartnerSaveDT.NewRowTyped(false); PartnerSaveDR.ItemArray = PartnerDT[0].ItemArray; // Add Partner DataRow to DataTable that contains the Partners that will be saved PartnerSaveDT.Rows.Add(PartnerSaveDR); // Change just added PartnerSaveDR's DataRowState from 'Added' to 'Unchanged' PartnerSaveDR.AcceptChanges(); // Apply new StatusCode (DataRowState changes to 'Modified') PartnerSaveDR.StatusCode = ANewPartnerStatusCode; PartnerSaveDR.StatusChange = DateTime.Now.Date; } } AInspectDS.PPartner.Merge(PartnerSaveDT); return true; }
public static void ChangeSubscription(int AExtractId, ref PSubscriptionTable ATable, List <String>AFieldsToChange, out PPartnerTable APartnersWithoutSubscription, out int ASubscriptionsChanged) { PSubscriptionTable SubscriptionTable = new PSubscriptionTable(); PSubscriptionRow SubscriptionRowTemplate; PSubscriptionRow SubscriptionRow; MExtractTable ExtractTable; PPartnerTable PartnerTable; PPartnerRow PartnerRow; int SubscriptionsChanged; PPartnerTable PartnersWithoutSubscription; // only use first row in table (as rows can't be serialized as parameters) SubscriptionRowTemplate = (PSubscriptionRow)ATable.Rows[0]; PartnersWithoutSubscription = new PPartnerTable(); SubscriptionsChanged = 0; TDBTransaction Transaction = null; bool SubmissionOK = false; DBAccess.GDBAccessObj.BeginAutoTransaction(IsolationLevel.Serializable, ref Transaction, ref SubmissionOK, delegate { ExtractTable = MExtractAccess.LoadViaMExtractMaster(AExtractId, Transaction); // query all rows of given extract foreach (MExtractRow ExtractRow in ExtractTable.Rows) { // for each extract row either change subscription or add to list of partners that don't have one if (PSubscriptionAccess.Exists(SubscriptionRowTemplate.PublicationCode, ExtractRow.PartnerKey, Transaction)) { SubscriptionTable = PSubscriptionAccess.LoadByPrimaryKey(SubscriptionRowTemplate.PublicationCode, ExtractRow.PartnerKey, Transaction); SubscriptionRow = (PSubscriptionRow)SubscriptionTable.Rows[0]; // change field contents if (AFieldsToChange.Contains(PSubscriptionTable.GetSubscriptionStatusDBName())) { SubscriptionRow.SubscriptionStatus = SubscriptionRowTemplate.SubscriptionStatus; } if (AFieldsToChange.Contains(PSubscriptionTable.GetGratisSubscriptionDBName())) { SubscriptionRow.GratisSubscription = SubscriptionRowTemplate.GratisSubscription; } if (AFieldsToChange.Contains(PSubscriptionTable.GetNumberComplimentaryDBName())) { SubscriptionRow.NumberComplimentary = SubscriptionRowTemplate.NumberComplimentary; } if (AFieldsToChange.Contains(PSubscriptionTable.GetPublicationCopiesDBName())) { SubscriptionRow.PublicationCopies = SubscriptionRowTemplate.PublicationCopies; } if (AFieldsToChange.Contains(PSubscriptionTable.GetReasonSubsGivenCodeDBName())) { SubscriptionRow.ReasonSubsGivenCode = SubscriptionRowTemplate.ReasonSubsGivenCode; } if (AFieldsToChange.Contains(PSubscriptionTable.GetReasonSubsCancelledCodeDBName())) { SubscriptionRow.ReasonSubsCancelledCode = SubscriptionRowTemplate.ReasonSubsCancelledCode; } if (AFieldsToChange.Contains(PSubscriptionTable.GetGiftFromKeyDBName())) { SubscriptionRow.GiftFromKey = SubscriptionRowTemplate.GiftFromKey; } if (AFieldsToChange.Contains(PSubscriptionTable.GetStartDateDBName())) { SubscriptionRow.StartDate = SubscriptionRowTemplate.StartDate; } if (AFieldsToChange.Contains(PSubscriptionTable.GetExpiryDateDBName())) { SubscriptionRow.ExpiryDate = SubscriptionRowTemplate.ExpiryDate; } if (AFieldsToChange.Contains(PSubscriptionTable.GetSubscriptionRenewalDateDBName())) { SubscriptionRow.SubscriptionRenewalDate = SubscriptionRowTemplate.SubscriptionRenewalDate; } if (AFieldsToChange.Contains(PSubscriptionTable.GetDateNoticeSentDBName())) { SubscriptionRow.DateNoticeSent = SubscriptionRowTemplate.DateNoticeSent; } if (AFieldsToChange.Contains(PSubscriptionTable.GetDateCancelledDBName())) { SubscriptionRow.DateCancelled = SubscriptionRowTemplate.DateCancelled; } if (AFieldsToChange.Contains(PSubscriptionTable.GetNumberIssuesReceivedDBName())) { SubscriptionRow.NumberIssuesReceived = SubscriptionRowTemplate.NumberIssuesReceived; } if (AFieldsToChange.Contains(PSubscriptionTable.GetFirstIssueDBName())) { SubscriptionRow.FirstIssue = SubscriptionRowTemplate.FirstIssue; } if (AFieldsToChange.Contains(PSubscriptionTable.GetLastIssueDBName())) { SubscriptionRow.LastIssue = SubscriptionRowTemplate.LastIssue; } // submit changes to the database after each row PSubscriptionAccess.SubmitChanges(SubscriptionTable, Transaction); //SubscriptionTable.Rows.Add(SubscriptionRow); SubscriptionsChanged++; } else { // this partner does not have given subscription, therefore it cannot be changed PartnerRow = PartnersWithoutSubscription.NewRowTyped(); PartnerTable = PPartnerAccess.LoadByPrimaryKey(ExtractRow.PartnerKey, Transaction); DataUtilities.CopyAllColumnValues(PartnerTable.Rows[0], PartnerRow); PartnersWithoutSubscription.Rows.Add(PartnerRow); } } SubmissionOK = true; }); APartnersWithoutSubscription = PartnersWithoutSubscription; ASubscriptionsChanged = SubscriptionsChanged; }
public static void AddSubscription(int AExtractId, ref PSubscriptionTable ATable, out PPartnerTable AExistingSubscriptionPartners, out int ASubscriptionsAdded) { PSubscriptionTable SubscriptionTable = new PSubscriptionTable(); PSubscriptionRow SubscriptionRowTemplate; PSubscriptionRow SubscriptionRow; MExtractTable ExtractTable; PPartnerTable PartnerTable; PPartnerRow PartnerRow; PPartnerTable ExistingSubscriptionPartners; int SubscriptionsAdded = 0; // only use first row in table (as rows can't be serialized as parameters) SubscriptionRowTemplate = (PSubscriptionRow)ATable.Rows[0]; ExistingSubscriptionPartners = new PPartnerTable(); TDBTransaction Transaction = null; bool SubmissionOK = false; DBAccess.GDBAccessObj.BeginAutoTransaction(IsolationLevel.Serializable, ref Transaction, ref SubmissionOK, delegate { ExtractTable = MExtractAccess.LoadViaMExtractMaster(AExtractId, Transaction); // query all rows of given extract foreach (MExtractRow ExtractRow in ExtractTable.Rows) { // for each extract row either add subscription or add to list of partners already having one if (PSubscriptionAccess.Exists(SubscriptionRowTemplate.PublicationCode, ExtractRow.PartnerKey, Transaction)) { PartnerRow = ExistingSubscriptionPartners.NewRowTyped(); PartnerTable = PPartnerAccess.LoadByPrimaryKey(ExtractRow.PartnerKey, Transaction); DataUtilities.CopyAllColumnValues(PartnerTable.Rows[0], PartnerRow); ExistingSubscriptionPartners.Rows.Add(PartnerRow); } else { SubscriptionRow = SubscriptionTable.NewRowTyped(); DataUtilities.CopyAllColumnValues(SubscriptionRowTemplate, SubscriptionRow); SubscriptionRow.PartnerKey = ExtractRow.PartnerKey; SubscriptionTable.Rows.Add(SubscriptionRow); SubscriptionsAdded++; } } // now submit changes to the database PSubscriptionAccess.SubmitChanges(SubscriptionTable, Transaction); SubmissionOK = true; }); AExistingSubscriptionPartners = ExistingSubscriptionPartners; ASubscriptionsAdded = SubscriptionsAdded; }
public static void AddSubscription(int AExtractId, ref PSubscriptionTable ATable, out PPartnerTable AExistingSubscriptionPartners, out int ASubscriptionsAdded) { PSubscriptionTable SubscriptionTable = new PSubscriptionTable(); PSubscriptionRow SubscriptionRowTemplate; PSubscriptionRow SubscriptionRow; MExtractTable ExtractTable; PPartnerTable PartnerTable; PPartnerRow PartnerRow; // only use first row in table (as rows can't be serialized as parameters) SubscriptionRowTemplate = (PSubscriptionRow)ATable.Rows[0]; AExistingSubscriptionPartners = new PPartnerTable(); ASubscriptionsAdded = 0; TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable); try { ExtractTable = MExtractAccess.LoadViaMExtractMaster(AExtractId, Transaction); // query all rows of given extract foreach (MExtractRow ExtractRow in ExtractTable.Rows) { // for each extract row either add subscription or add to list of partners already having one if (PSubscriptionAccess.Exists(SubscriptionRowTemplate.PublicationCode, ExtractRow.PartnerKey, Transaction)) { PartnerRow = AExistingSubscriptionPartners.NewRowTyped(); PartnerTable = PPartnerAccess.LoadByPrimaryKey(ExtractRow.PartnerKey, Transaction); DataUtilities.CopyAllColumnValues(PartnerTable.Rows[0], PartnerRow); AExistingSubscriptionPartners.Rows.Add(PartnerRow); } else { SubscriptionRow = SubscriptionTable.NewRowTyped(); DataUtilities.CopyAllColumnValues(SubscriptionRowTemplate, SubscriptionRow); SubscriptionRow.PartnerKey = ExtractRow.PartnerKey; SubscriptionTable.Rows.Add(SubscriptionRow); ASubscriptionsAdded++; } } // now submit changes to the database PSubscriptionAccess.SubmitChanges(SubscriptionTable, Transaction); DBAccess.GDBAccessObj.CommitTransaction(); } catch (Exception Exc) { TLogging.Log( "An Exception occured during the adding of subscriptions for all Partners in an Extract:" + Environment.NewLine + Exc.ToString()); DBAccess.GDBAccessObj.RollbackTransaction(); throw; } }
public static PPartnerTable SharedBankAccountPartners(int ABankingDetailsKey, long APartnerKey) { PPartnerTable PartnerTable = new PPartnerTable(); TDBTransaction Transaction = null; DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, ref Transaction, delegate { PPartnerBankingDetailsTable PartnerBankingDetailsTable = PPartnerBankingDetailsAccess.LoadViaPBankingDetails(ABankingDetailsKey, Transaction); foreach (PPartnerBankingDetailsRow Row in PartnerBankingDetailsTable.Rows) { // if record exists with a different partner key then the Bank Account is shared if (Row.PartnerKey != APartnerKey) { PPartnerRow PartnerRow = (PPartnerRow)PPartnerAccess.LoadByPrimaryKey(Row.PartnerKey, Transaction).Rows[0]; PPartnerRow NewRow = PartnerTable.NewRowTyped(false); NewRow.PartnerKey = Row.PartnerKey; NewRow.PartnerShortName = PartnerRow.PartnerShortName; PartnerTable.Rows.Add(NewRow); } } }); return PartnerTable; }
public static PPartnerTable SharedBankAccountPartners(int ABankingDetailsKey, long APartnerKey) { TDBTransaction ReadTransaction; Boolean NewTransaction; PPartnerTable PartnerTable = new PPartnerTable(); ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, out NewTransaction); try { PPartnerBankingDetailsTable PartnerBankingDetailsTable = PPartnerBankingDetailsAccess.LoadViaPBankingDetails(ABankingDetailsKey, ReadTransaction); foreach (PPartnerBankingDetailsRow Row in PartnerBankingDetailsTable.Rows) { // if record exists with a different partner key then the Bank Account is shared if (Row.PartnerKey != APartnerKey) { PPartnerRow PartnerRow = (PPartnerRow)PPartnerAccess.LoadByPrimaryKey(Row.PartnerKey, ReadTransaction).Rows[0]; PPartnerRow NewRow = PartnerTable.NewRowTyped(false); NewRow.PartnerKey = Row.PartnerKey; NewRow.PartnerShortName = PartnerRow.PartnerShortName; PartnerTable.Rows.Add(NewRow); } } } finally { if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); TLogging.LogAtLevel(7, "TPartnerDataReaderWebConnector.IsBankingDetailsRowShared: committed own transaction."); } } return PartnerTable; }