public static string GetOutreachCode(Int64 APartnerKey) { string ReturnValue; TDBTransaction ReadTransaction; Boolean NewTransaction; ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead, TEnforceIsolationLevel.eilMinimum, out NewTransaction); PUnitTable UnitTable = PUnitAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction); if (UnitTable.Count > 0) { ReturnValue = ((PUnitRow)UnitTable.Rows[0]).OutreachCode; } else { ReturnValue = ""; } if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); TLogging.LogAtLevel(7, "TIndividualDataWebConnector.GetOutreachCode: rollback own transaction."); } return(ReturnValue); }
/// <summary> /// Refresh Outreach Code for applications and conference /// </summary> public static void RefreshOutreachCode(Int64 AConferenceKey) { TDBTransaction Transaction = new TDBTransaction(); bool SubmissionOK = true; PcConferenceTable ConferenceTable; PUnitTable UnitTable; PmShortTermApplicationTable ShortTermAppTable; ConferenceApplicationTDS MainDS; DBAccess.WriteTransaction( ref Transaction, ref SubmissionOK, delegate { ConferenceTable = new PcConferenceTable(); UnitTable = new PUnitTable(); ShortTermAppTable = new PmShortTermApplicationTable(); MainDS = new ConferenceApplicationTDS(); // get the conference in order to update the OutreachPrefix ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, Transaction); if (ConferenceTable.Count == 0) { throw new Exception("Cannot find conference " + AConferenceKey.ToString("0000000000")); } // update OutreachPrefix in conference record in case it was changed in Unit record for event UnitTable = PUnitAccess.LoadByPrimaryKey(AConferenceKey, Transaction); if (UnitTable[0].OutreachCode.Length >= 5) { ConferenceTable[0].OutreachPrefix = UnitTable[0].OutreachCode.Substring(0, 5); } else { ConferenceTable[0].OutreachPrefix = UnitTable[0].OutreachCode; } MainDS.Merge(ConferenceTable); // update event code ShortTermAppTable = PmShortTermApplicationAccess.LoadViaPUnitStConfirmedOption(AConferenceKey, Transaction); foreach (PmShortTermApplicationRow ShortTermAppRow in ShortTermAppTable.Rows) { ShortTermAppRow.ConfirmedOptionCode = UnitTable[0].OutreachCode; } MainDS.Merge(ShortTermAppTable); MainDS.ThrowAwayAfterSubmitChanges = true; ConferenceApplicationTDSAccess.SubmitChanges(MainDS); }); }
/// <summary> /// Load all the data of a partner into a TDS /// </summary> public static PartnerImportExportTDS ExportPartner(Int64 APartnerKey) { PartnerImportExportTDS MainDS = new PartnerImportExportTDS(); TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted); PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction); PChurchAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction); PFamilyAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction); PPersonAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction); POrganisationAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction); PUnitAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction); PVenueAccess.LoadByPrimaryKey(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); PPartnerGiftDestinationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction); PInterestAccess.LoadAll(MainDS, 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); PmGeneralApplicationAccess.LoadViaPPersonPartnerKey(MainDS, APartnerKey, Transaction); PtApplicationTypeAccess.LoadAll(MainDS, Transaction); PmShortTermApplicationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction); PmYearProgramApplicationAccess.LoadViaPPerson(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); PcBuildingAccess.LoadViaPVenue(MainDS, APartnerKey, Transaction); PcRoomAccess.LoadViaPVenue(MainDS, APartnerKey, Transaction); DBAccess.GDBAccessObj.RollbackTransaction(); return(MainDS); }
private static bool AddFieldToTable(long AFieldKey, ref DataTable AFieldsTable, ref TDBTransaction ATransaction) { // First check if the unit is already in the table foreach (DataRow Row in AFieldsTable.Rows) { if ((long)Row[UNIT_KEY] == AFieldKey) { return(true); } } bool IsLedger = false; PUnitTable UnitTable; PPartnerTypeTable PartnerTypeTable; StringCollection FieldList = new StringCollection(); FieldList.Add(PUnitTable.GetUnitNameDBName()); UnitTable = PUnitAccess.LoadByPrimaryKey(AFieldKey, FieldList, ATransaction); PartnerTypeTable = PPartnerTypeAccess.LoadViaPPartner(AFieldKey, ATransaction); foreach (PPartnerTypeRow PartnerTypeRow in PartnerTypeTable.Rows) { if (PartnerTypeRow.TypeCode == "LEDGER") { IsLedger = true; break; } } if (!IsLedger) { return(false); } if (UnitTable.Rows.Count > 0) { DataRow NewRow = AFieldsTable.NewRow(); NewRow[SELECTION] = false; NewRow[UNIT_KEY] = AFieldKey; NewRow[UNIT_NAME] = UnitTable.Rows[0][PUnitTable.GetUnitNameDBName()]; NewRow[USED_IN_CONFERENCE] = true; AFieldsTable.Rows.Add(NewRow); } return(true); }
/// <summary> /// Get the units which start with the same outreach code as given with the prefix. /// </summary> /// <param name="AUnitKey">Partner Key of the unit from which the outreach options are retrieved</param> /// <param name="AConferenceTable">A table with all the units</param> /// <returns></returns> private static System.Boolean GetOutreachOptions(long AUnitKey, out System.Data.DataTable AConferenceTable) { AConferenceTable = new DataTable(); AConferenceTable.Columns.Add("Partner Key", Type.GetType("System.Int64")); AConferenceTable.Columns.Add("Outreach Code"); AConferenceTable.Columns.Add("Unit Name"); String ConferenceCodePrefix = ""; PUnitTable UnitTable = new PUnitTable(); PUnitRow TemplateRow = UnitTable.NewRowTyped(false); TLogging.LogAtLevel(9, "TConferenceOptions.GetOutreachOptions called!"); TDBTransaction Transaction = new TDBTransaction(); DBAccess.ReadTransaction(ref Transaction, delegate { /* Load data */ UnitTable = PUnitAccess.LoadByPrimaryKey(AUnitKey, Transaction); if (UnitTable.Rows.Count > 0) { ConferenceCodePrefix = ((PUnitRow)UnitTable.Rows[0]).OutreachCode.Substring(0, 5); UnitTable = PUnitAccess.LoadUsingTemplate(TemplateRow, null, null, Transaction); } }); foreach (PUnitRow UnitRow in UnitTable.Rows) { if (!UnitRow.OutreachCode.StartsWith(ConferenceCodePrefix, true, null)) { continue; } DataRow NewRow = AConferenceTable.NewRow(); NewRow["Partner Key"] = UnitRow.PartnerKey; NewRow["Outreach Code"] = UnitRow.OutreachCode; NewRow["Unit Name"] = UnitRow.UnitName; AConferenceTable.Rows.Add(NewRow); } return(true); }
/// <summary> /// Load data from db. /// Data is held in variable MainDS.PPartner and then MainDS.PLocation, PFamilyAccess etc... /// The latter is to get the additional information not present in PPartner but in dependent tables. /// </summary> /// <param name="MainDS"> /// The Datastructure which is filled with the data from the DB. /// It should be empty initially. /// </param> private static void LoadDataFromDB(ref PartnerEditTDS MainDS) { TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable); try { PPartnerAccess.LoadAll(MainDS, Transaction); TLogging.LogAtLevel(TLogging.DEBUGLEVEL_TRACE, "Read Partners from Database : " + MainDS.PPartner.Rows.Count.ToString()); TLogging.LogAtLevel(TLogging.DEBUGLEVEL_TRACE, "Now reading additional data for each Partner:"); foreach (PPartnerRow partnerRow in MainDS.PPartner.Rows) { long partnerKey = partnerRow.PartnerKey; PLocationAccess.LoadViaPPartner(MainDS, partnerKey, Transaction); PPartnerLocationAccess.LoadViaPPartner(MainDS, partnerKey, Transaction); PPartnerTypeAccess.LoadViaPPartner(MainDS, partnerKey, Transaction); PPersonAccess.LoadViaPPartner(MainDS, partnerKey, Transaction); PFamilyAccess.LoadViaPPartner(MainDS, partnerKey, Transaction); POrganisationAccess.LoadViaPPartnerPartnerKey(MainDS, partnerKey, Transaction); PUnitAccess.LoadViaPPartnerPartnerKey(MainDS, partnerKey, Transaction); UmUnitStructureAccess.LoadViaPUnitChildUnitKey(MainDS, partnerKey, Transaction); PBankAccess.LoadViaPPartnerPartnerKey(MainDS, partnerKey, Transaction); } if (TLogging.DebugLevel >= TLogging.DEBUGLEVEL_TRACE) { TLogging.Log("All in all:"); SortedList <string, int> sortedtables = new SortedList <string, int>(); sortedtables.Add("PLocation", MainDS.PLocation.Count); sortedtables.Add("PPartnerLocation", MainDS.PPartnerLocation.Count); sortedtables.Add("PPartnerType", MainDS.PPartnerType.Count); sortedtables.Add("PPerson", MainDS.PPerson.Count); sortedtables.Add("PFamily", MainDS.PFamily.Count); sortedtables.Add("POrganisation", MainDS.POrganisation.Count); foreach (KeyValuePair <string, int /*TTypedDataTable*/> pair in sortedtables) { TLogging.Log(pair.Key + " : " + pair.Value.ToString()); } } } catch (Exception e) { TLogging.Log("ExportPartners: " + e.Message); } DBAccess.GDBAccessObj.RollbackTransaction(); }
public static PUnitTable GetOutreachOptions(Int64 AUnitKey) { String ConferenceCodePrefix = ""; PUnitTable UnitTable = new PUnitTable(); PUnitRow TemplateRow = UnitTable.NewRowTyped(false); TDBTransaction ReadTransaction; Boolean NewTransaction = false; TLogging.LogAtLevel(9, "TConferenceOptions.GetOutreachOptions called!"); TDataBase db = DBAccess.Connect("GetOutreachOptions"); ReadTransaction = db.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead, out NewTransaction); try { /* Load data */ UnitTable = PUnitAccess.LoadByPrimaryKey(AUnitKey, ReadTransaction); if (UnitTable.Rows.Count > 0) { String ConferenceCode = ((PUnitRow)UnitTable.Rows[0]).OutreachCode; if (ConferenceCode.Length >= 5) { ConferenceCodePrefix = ConferenceCode.Substring(0, 5) + "%"; } StringCollection operators = new StringCollection(); operators.Add("LIKE"); TemplateRow.OutreachCode = ConferenceCodePrefix; UnitTable = PUnitAccess.LoadUsingTemplate(TemplateRow, operators, null, ReadTransaction); } } finally { if (NewTransaction) { ReadTransaction.Commit(); TLogging.LogAtLevel(7, "TConferenceOptions.GetOutreachOptions: committed own transaction."); } } return(UnitTable); }
public static string GetOutreachCode(Int64 APartnerKey) { string ReturnValue = ""; TDBTransaction Transaction = new TDBTransaction(); DBAccess.ReadTransaction( ref Transaction, delegate { PUnitTable UnitTable = PUnitAccess.LoadByPrimaryKey(APartnerKey, Transaction); if (UnitTable.Count > 0) { ReturnValue = ((PUnitRow)UnitTable.Rows[0]).OutreachCode; } }); return(ReturnValue); }
public static string GetOutreachCode(Int64 APartnerKey) { string ReturnValue = ""; TDBTransaction Transaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { PUnitTable UnitTable = PUnitAccess.LoadByPrimaryKey(APartnerKey, Transaction); if (UnitTable.Count > 0) { ReturnValue = ((PUnitRow)UnitTable.Rows[0]).OutreachCode; } }); return(ReturnValue); }
private static String GetConferencePrefix(long AConferenceKey) { TDBTransaction ReadTransaction; Boolean NewTransaction = false; String ConferencePrefix = "-----"; PUnitTable UnitTable; TLogging.LogAtLevel(9, "TConferenceOptions.GetOutreachPrefix: called."); TDataBase db = DBAccess.Connect("GetConferencePrefix"); ReadTransaction = db.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead, out NewTransaction); try { UnitTable = PUnitAccess.LoadByPrimaryKey(AConferenceKey, ReadTransaction); if (UnitTable.Rows.Count > 0) { if (UnitTable.Rows[0][PUnitTable.GetOutreachCodeDBName()] != System.DBNull.Value) { ConferencePrefix = (string)UnitTable.Rows[0][PUnitTable.GetOutreachCodeDBName()]; if (ConferencePrefix.Length > 5) { ConferencePrefix = ConferencePrefix.Substring(0, 5); } } } } finally { if (NewTransaction) { ReadTransaction.Commit(); TLogging.LogAtLevel(7, "TConferenceOptions.GetOutreachPrefix: committed own transaction."); } } return(ConferencePrefix); }
public static ConferenceSetupTDS LoadConferenceSettings(long AConferenceKey, out string AConferenceName) { Boolean NewTransaction; ConferenceSetupTDS MainDS = new ConferenceSetupTDS(); TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, out NewTransaction); PPartnerLocationAccess.LoadViaPPartner(MainDS, AConferenceKey, Transaction); PcConferenceAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction); PcConferenceOptionAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction); PcDiscountAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction); PcConferenceVenueAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction); PUnitAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction); AConferenceName = PPartnerAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction).PartnerShortName; foreach (ConferenceSetupTDSPcConferenceVenueRow VenueRow in MainDS.PcConferenceVenue.Rows) { string VenueName; TPartnerClass PartnerClass; MPartner.Partner.ServerLookups.WebConnectors.TPartnerServerLookups.GetPartnerShortName(VenueRow.VenueKey, out VenueName, out PartnerClass); VenueRow.VenueName = VenueName; } // Accept row changes here so that the Client gets 'unmodified' rows MainDS.AcceptChanges(); // Remove all Tables that were not filled with data before remoting them. MainDS.RemoveEmptyTables(); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } return(MainDS); }
public static DataTable GetOutreachTypes(long APartnerKey) { TDBTransaction ReadTransaction; ReadTransaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted); DataTable Table = new PUnitTable(); try { string OutreachPrefixCode = ((PcConferenceRow)PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction).Rows[0]).OutreachPrefix; PUnitTable UnitTable = PUnitAccess.LoadAll(ReadTransaction); // add PUnit rows with matching OutreachPrefixCode to the new DataTable foreach (PUnitRow Row in UnitTable.Rows) { if ((Row.OutreachCode.Length == 13) && (Row.OutreachCode.Substring(0, 5) == OutreachPrefixCode)) { DataRow CopyRow = Table.NewRow(); ((PUnitRow)CopyRow).PartnerKey = Row.PartnerKey; ((PUnitRow)CopyRow).OutreachCode = Row.OutreachCode.Substring(5, 6); ((PUnitRow)CopyRow).UnitName = Row.UnitName; Table.Rows.Add(CopyRow); } } } catch (Exception e) { TLogging.Log(e.ToString()); } finally { DBAccess.GDBAccessObj.RollbackTransaction(); TLogging.LogAtLevel(7, "TConferenceDataReaderWebConnector.GetOutreachTypes: commit own transaction."); } return(Table); }
public static ConferenceSetupTDS LoadConferenceSettings(long AConferenceKey, out string AConferenceName) { ConferenceSetupTDS MainDS = new ConferenceSetupTDS(); string ConferenceName = null; TDBTransaction Transaction = new TDBTransaction(); DBAccess.ReadTransaction( ref Transaction, delegate { PPartnerLocationAccess.LoadViaPPartner(MainDS, AConferenceKey, Transaction); PcConferenceAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction); PcConferenceOptionAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction); PcDiscountAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction); PcConferenceVenueAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction); PUnitAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction); ConferenceName = PPartnerAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction).PartnerShortName; }); foreach (ConferenceSetupTDSPcConferenceVenueRow VenueRow in MainDS.PcConferenceVenue.Rows) { string VenueName; TPartnerClass PartnerClass; MPartner.Partner.ServerLookups.WebConnectors.TPartnerServerLookups.GetPartnerShortName(VenueRow.VenueKey, out VenueName, out PartnerClass); VenueRow.VenueName = VenueName; } // Accept row changes here so that the Client gets 'unmodified' rows MainDS.AcceptChanges(); // Remove all Tables that were not filled with data before remoting them. MainDS.RemoveEmptyTables(); AConferenceName = ConferenceName; return(MainDS); }
/// <summary> /// Returns the Unit Structure Info for a Partner of Partner Class UNIT. /// </summary> /// <param name="APartnerKey">PartnerKey of the UNIT.</param> /// <param name="AReadTransaction">Open DB Transaction.</param> /// <returns>An Instance of <see cref="PartnerInfoTDSUnitInfoTable" />. /// Contains one DataRow if Unit Structure information could be retrieved, otherwise no DataRow.</returns> private static PartnerInfoTDSUnitInfoTable GetUnitStructure(Int64 APartnerKey, TDBTransaction AReadTransaction) { PartnerInfoTDSUnitInfoTable UnitInfoDT = new PartnerInfoTDSUnitInfoTable(); UmUnitStructureTable UnitStructureDT = UmUnitStructureAccess.LoadViaPUnitChildUnitKey(APartnerKey, AReadTransaction); if (UnitStructureDT.Rows.Count > 0) { PUnitTable UnitDT = PUnitAccess.LoadByPrimaryKey(UnitStructureDT[0].ParentUnitKey, AReadTransaction); if (UnitDT != null) { PartnerInfoTDSUnitInfoRow UnitInfoDR = UnitInfoDT.NewRowTyped(false); UnitInfoDR.ParentUnitKey = UnitDT[0].PartnerKey; UnitInfoDR.ParentUnitName = UnitDT[0].UnitName; UnitInfoDT.Rows.Add(UnitInfoDR); } } return(UnitInfoDT); }
public static void CreateNewConference(long APartnerKey) { TDBTransaction Transaction; PcConferenceTable ConferenceTable; PUnitTable UnitTable; PPartnerLocationTable PartnerLocationTable; Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable); try { ConferenceTable = PcConferenceAccess.LoadAll(Transaction); UnitTable = PUnitAccess.LoadByPrimaryKey(APartnerKey, Transaction); PartnerLocationTable = PPartnerLocationAccess.LoadViaPPartner(APartnerKey, Transaction); DateTime Start = new DateTime(); DateTime End = new DateTime(); foreach (PPartnerLocationRow PartnerLocationRow in PartnerLocationTable.Rows) { if ((PartnerLocationRow.DateEffective != null) || (PartnerLocationRow.DateGoodUntil != null)) { if (PartnerLocationRow.DateEffective != null) { Start = (DateTime)PartnerLocationRow.DateEffective; } if (PartnerLocationRow.DateGoodUntil != null) { End = (DateTime)PartnerLocationRow.DateGoodUntil; } break; } } // set column values PcConferenceRow AddRow = ConferenceTable.NewRowTyped(); AddRow.ConferenceKey = APartnerKey; string OutreachPrefix = ((PUnitRow)UnitTable.Rows[0]).OutreachCode; if (OutreachPrefix.Length > 4) { AddRow.OutreachPrefix = OutreachPrefix.Substring(0, 5); } else { AddRow.OutreachPrefix = OutreachPrefix; } if (Start != DateTime.MinValue) { AddRow.Start = Start; } if (End != DateTime.MinValue) { AddRow.End = End; } string CurrencyCode = ((PUnitRow)UnitTable.Rows[0]).OutreachCostCurrencyCode; if (!string.IsNullOrEmpty(CurrencyCode)) { AddRow.CurrencyCode = CurrencyCode; } else { AddRow.CurrencyCode = "USD"; } // add new row to database table ConferenceTable.Rows.Add(AddRow); PcConferenceAccess.SubmitChanges(ConferenceTable, Transaction); DBAccess.GDBAccessObj.CommitTransaction(); TLogging.LogAtLevel(7, "TConferenceDataReaderWebConnector.CreateNewConference: commit own transaction."); } catch (Exception Exc) { TLogging.Log("An Exception occured during the creation of a new Conference:" + Environment.NewLine + Exc.ToString()); DBAccess.GDBAccessObj.RollbackTransaction(); throw; } }
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); }
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); }
public static void FillFormDataFromPersonnel(Int64 APartnerKey, TFormDataPerson AFormDataPerson, TFormLetterInfo AFormLetterInfo, TDBTransaction AReadTransaction, Int64 ASiteKey = 0, Int32 ALocationKey = 0) { TPartnerClass PartnerClass; String ShortName; TStdPartnerStatusCode PartnerStatusCode; if (AFormDataPerson == null) { return; } if (MCommonMain.RetrievePartnerShortName(APartnerKey, out ShortName, out PartnerClass, out PartnerStatusCode, AReadTransaction)) { // first retrieve all partner information // we cannot reference MPartner connect because of SimplePartnerEdit, cyclic dependencies #if DISABLED_TP_20180623 TFormLettersWebConnector.FillFormDataFromPerson(APartnerKey, AFormDataPerson, AFormLetterInfo, AReadTransaction, ASiteKey, ALocationKey); #endif // retrieve Special Needs information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eSpecialNeeds)) { PmSpecialNeedTable SpecialNeedTable; PmSpecialNeedRow SpecialNeedRow; SpecialNeedTable = PmSpecialNeedAccess.LoadViaPPerson(APartnerKey, AReadTransaction); if (SpecialNeedTable.Count > 0) { SpecialNeedRow = (PmSpecialNeedRow)SpecialNeedTable.Rows[0]; AFormDataPerson.DietaryNeeds = SpecialNeedRow.DietaryComment; AFormDataPerson.MedicalNeeds = SpecialNeedRow.MedicalComment; AFormDataPerson.OtherNeeds = SpecialNeedRow.OtherSpecialNeed; AFormDataPerson.Vegetarian = SpecialNeedRow.VegetarianFlag; } } // retrieve Personal Data information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.ePersonalData)) { PmPersonalDataTable PersonalDataTable; PmPersonalDataRow PersonalDataRow; PersonalDataTable = PmPersonalDataAccess.LoadViaPPerson(APartnerKey, AReadTransaction); if (PersonalDataTable.Count > 0) { PersonalDataRow = (PmPersonalDataRow)PersonalDataTable.Rows[0]; if (!PersonalDataRow.IsBelieverSinceYearNull() && (PersonalDataRow.BelieverSinceYear != 0)) { AFormDataPerson.YearsBeliever = (DateTime.Today.Year - PersonalDataRow.BelieverSinceYear).ToString(); } AFormDataPerson.CommentBeliever = PersonalDataRow.BelieverSinceComment; } } // retrieve Passport information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.ePassport)) { PmPassportDetailsTable PassportTable; TFormDataPassport PassportRecord; PassportTable = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey, AReadTransaction); Boolean MainPassportFound = false; foreach (PmPassportDetailsRow PassportRow in PassportTable.Rows) { // only list "full" passports that have not expired yet if ((PassportRow.IsDateOfExpirationNull() || (PassportRow.DateOfExpiration >= DateTime.Today)) && (PassportRow.PassportDetailsType == "P")) { PassportRecord = new TFormDataPassport(); PassportRecord.IsMainPassport = PassportRow.MainPassport; PassportRecord.Number = PassportRow.PassportNumber; PassportRecord.PassportName = PassportRow.FullPassportName; PassportRecord.NationalityCode = PassportRow.PassportNationalityCode; // retrieve country name from country table TCacheable CachePopulator = new TCacheable(); PCountryTable CountryTable = (PCountryTable)CachePopulator.GetCacheableTable(TCacheableCommonTablesEnum.CountryList); PCountryRow CountryRow = (PCountryRow)CountryTable.Rows.Find(new object[] { PassportRow.PassportNationalityCode }); if (CountryRow != null) { PassportRecord.NationalityName = CountryRow.CountryName; } PassportRecord.TypeCode = PassportRow.PassportDetailsType; // retrieve passport type name from type table TPersonnelCacheable PersonnelCachePopulator = new TPersonnelCacheable(); PtPassportTypeTable TypeTable = (PtPassportTypeTable)PersonnelCachePopulator.GetCacheableTable(TCacheablePersonTablesEnum. PassportTypeList); PtPassportTypeRow TypeRow = (PtPassportTypeRow)TypeTable.Rows.Find(new object[] { PassportRow.PassportDetailsType }); if (TypeRow != null) { PassportRecord.TypeDescription = TypeRow.Description; } PassportRecord.DateOfIssue = PassportRow.DateOfIssue; PassportRecord.PlaceOfIssue = PassportRow.PlaceOfIssue; PassportRecord.DateOfExpiry = PassportRow.DateOfExpiration; PassportRecord.PlaceOfBirth = PassportRow.PlaceOfBirth; // set number and nationality in main record (only for main passport or if there is just one) if (PassportRow.MainPassport || (PassportTable.Count == 1)) { AFormDataPerson.PassportNumber = PassportRecord.Number; AFormDataPerson.PassportNationality = PassportRecord.NationalityName; AFormDataPerson.PassportNationalityCode = PassportRecord.NationalityCode; AFormDataPerson.PassportName = PassportRecord.PassportName; AFormDataPerson.PassportDateOfIssue = PassportRecord.DateOfIssue; AFormDataPerson.PassportPlaceOfIssue = PassportRecord.PlaceOfIssue; AFormDataPerson.PassportDateOfExpiry = PassportRecord.DateOfExpiry; AFormDataPerson.PassportPlaceOfBirth = PassportRecord.PlaceOfBirth; MainPassportFound = true; } // If the PassportName has not been set yet then make sure it is set on Person level from at least one passport // (this will not be necessary any longer once the tick box for "Main Passport" is implemented) if (!MainPassportFound) { AFormDataPerson.PassportName = PassportRecord.PassportName; } AFormDataPerson.AddPassport(PassportRecord); } } } // retrieve Language information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eLanguage)) { PmPersonLanguageTable PersonLanguageTable; TFormDataLanguage PersonLanguageRecord; PersonLanguageTable = PmPersonLanguageAccess.LoadViaPPerson(APartnerKey, AReadTransaction); foreach (PmPersonLanguageRow PersonLanguageRow in PersonLanguageTable.Rows) { PersonLanguageRecord = new TFormDataLanguage(); PersonLanguageRecord.Code = PersonLanguageRow.LanguageCode; // retrieve language name from language table TCacheable CachePopulator = new TCacheable(); PLanguageTable LanguageTable = (PLanguageTable)CachePopulator.GetCacheableTable(TCacheableCommonTablesEnum.LanguageCodeList); PLanguageRow LanguageRow = (PLanguageRow)LanguageTable.Rows.Find(new object[] { PersonLanguageRow.LanguageCode }); if (LanguageRow != null) { PersonLanguageRecord.Name = LanguageRow.LanguageDescription; } PersonLanguageRecord.Level = PersonLanguageRow.LanguageLevel.ToString(); // retrieve language level name from language level table TPersonnelCacheable CachePopulatorPersonnel = new TPersonnelCacheable(); PtLanguageLevelTable LanguageLevelTable = (PtLanguageLevelTable)CachePopulatorPersonnel.GetCacheableTable(TCacheablePersonTablesEnum.LanguageLevelList); PtLanguageLevelRow LanguageLevelRow = (PtLanguageLevelRow)LanguageLevelTable.Rows.Find(new object[] { PersonLanguageRow.LanguageLevel }); if (LanguageLevelRow != null) { PersonLanguageRecord.LevelDesc = LanguageLevelRow.LanguageLevelDescr; } PersonLanguageRecord.Comment = PersonLanguageRow.Comment; AFormDataPerson.AddLanguage(PersonLanguageRecord); } } // retrieve Skill information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eSkill)) { PmPersonSkillTable PersonSkillTable; TFormDataSkill PersonSkillRecord; TFormDataDegree PersonDegreeRecord; PersonSkillTable = PmPersonSkillAccess.LoadViaPPerson(APartnerKey, AReadTransaction); foreach (PmPersonSkillRow PersonSkillRow in PersonSkillTable.Rows) { PersonSkillRecord = new TFormDataSkill(); PersonSkillRecord.Category = PersonSkillRow.SkillCategoryCode; PersonSkillRecord.Description = PersonSkillRow.DescriptionEnglish; // if no description in local language then use english PersonSkillRecord.DescriptionLocalOrDefault = PersonSkillRow.DescriptionLocal; if (PersonSkillRow.DescriptionLocal != "") { PersonSkillRecord.DescriptionLocalOrDefault = PersonSkillRow.DescriptionEnglish; } PersonSkillRecord.Level = PersonSkillRow.SkillLevel; // retrieve skill level name from skill level table TPersonnelCacheable CachePopulatorPersonnel = new TPersonnelCacheable(); PtSkillLevelTable SkillLevelTable = (PtSkillLevelTable)CachePopulatorPersonnel.GetCacheableTable(TCacheablePersonTablesEnum.SkillLevelList); PtSkillLevelRow SkillLevelRow = (PtSkillLevelRow)SkillLevelTable.Rows.Find(new object[] { PersonSkillRow.SkillLevel }); if (SkillLevelRow != null) { PersonSkillRecord.LevelDesc = SkillLevelRow.Description; } PersonSkillRecord.YearsExp = PersonSkillRow.YearsOfExperience; PersonSkillRecord.Professional = PersonSkillRow.ProfessionalSkill; PersonSkillRecord.Degree = PersonSkillRow.Degree; PersonSkillRecord.Comment = PersonSkillRow.Comment; AFormDataPerson.AddSkill(PersonSkillRecord); // now add a degree record if a degree is mentioned if (!PersonSkillRow.IsDegreeNull() && (PersonSkillRow.Degree.Length > 0)) { PersonDegreeRecord = new TFormDataDegree(); PersonDegreeRecord.Name = PersonSkillRow.Degree; PersonDegreeRecord.Year = PersonSkillRow.YearOfDegree.ToString(); AFormDataPerson.AddDegree(PersonDegreeRecord); } } } // retrieve past work experience information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eWorkExperience)) { TFormDataWorkExperience PersonExpRecord; /* * currently we don't include application records in the work experience data * * String UnitShortName; * TPartnerClass UnitClass; * * // retrieve applications for short term events * String SqlStmt = TDataBase.ReadSqlFile("Personnel.FormLetters.GetAppTravelDates.sql"); * * OdbcParameter[] parameters = new OdbcParameter[1]; * parameters[0] = new OdbcParameter("PartnerKey", OdbcType.BigInt); * parameters[0].Value = APartnerKey; * * DataTable travelData = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "TravelDates", ReadTransaction, parameters); * * for (int i = 0; i < travelData.Rows.Count; i++) * { * PersonExpRecord = new TFormDataWorkExperience(); * * if ((travelData.Rows[i][0]).GetType() == typeof(DateTime)) * { * PersonExpRecord.StartDate = (DateTime?)travelData.Rows[i][0]; * } * * if ((travelData.Rows[i][1]).GetType() == typeof(DateTime)) * { * PersonExpRecord.EndDate = (DateTime?)travelData.Rows[i][1]; * } * * PersonExpRecord.Organisation = ""; * PersonExpRecord.Role = ""; * PersonExpRecord.Category = ""; * PersonExpRecord.SameOrg = true; * PersonExpRecord.SimilarOrg = true; * PersonExpRecord.Comment = ""; * * // check if unit exists and use unit name as location * if (TPartnerServerLookups.GetPartnerShortName((Int64)travelData.Rows[i][2], out UnitShortName, out UnitClass)) * { * PersonExpRecord.Location = UnitShortName; * } * else * { * PersonExpRecord.Location = travelData.Rows[i][3].ToString(); * } * * AFormDataPerson.AddWorkExperience(PersonExpRecord); * } */ // retrieve actual past experience records PmPastExperienceTable PersonExpTable; PersonExpTable = PmPastExperienceAccess.LoadViaPPerson(APartnerKey, AReadTransaction); PUnitTable UnitTable; PUnitRow UnitRow; foreach (PmPastExperienceRow PersonExpRow in PersonExpTable.Rows) { PersonExpRecord = new TFormDataWorkExperience(); PersonExpRecord.StartDate = PersonExpRow.StartDate; PersonExpRecord.EndDate = PersonExpRow.EndDate; PersonExpRecord.Location = PersonExpRow.PrevLocation; PersonExpRecord.Organisation = PersonExpRow.OtherOrganisation; PersonExpRecord.Role = PersonExpRow.PrevRole; PersonExpRecord.Category = PersonExpRow.Category; PersonExpRecord.SameOrg = PersonExpRow.PrevWorkHere; PersonExpRecord.SimilarOrg = PersonExpRow.PrevWork; PersonExpRecord.Comment = PersonExpRow.PastExpComments; // check if previous experience came from an event with location set to event code // -> in this case don't set event code as location but rather the event name PUnitRow template = new PUnitTable().NewRowTyped(false); template.OutreachCode = PersonExpRow.PrevLocation; UnitTable = PUnitAccess.LoadUsingTemplate(template, AReadTransaction); if (UnitTable.Rows.Count > 0) { UnitRow = (PUnitRow)UnitTable.Rows[0]; PersonExpRecord.Location = UnitRow.UnitName; } AFormDataPerson.AddWorkExperience(PersonExpRecord); } } // retrieve Commitment information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eCommitment) || AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eFutureCommitment)) { String FieldName; TPartnerClass FieldPartnerClass; PmStaffDataTable PersonCommitmentTable; PmStaffDataRow PersonCommitmentRow; TFormDataCommitment PersonCommitmentRecord; PersonCommitmentTable = PmStaffDataAccess.LoadViaPPerson(APartnerKey, AReadTransaction); PersonCommitmentTable.DefaultView.Sort = PmStaffDataTable.GetStartOfCommitmentDBName() + " DESC"; if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eCommitment)) { foreach (DataRowView rv in PersonCommitmentTable.DefaultView) { PersonCommitmentRow = (PmStaffDataRow)rv.Row; PersonCommitmentRecord = new TFormDataCommitment(); PersonCommitmentRecord.StartDate = PersonCommitmentRow.StartOfCommitment; PersonCommitmentRecord.EndDate = PersonCommitmentRow.EndOfCommitment; PersonCommitmentRecord.Status = PersonCommitmentRow.StatusCode; PersonCommitmentRecord.ReceivingFieldKey = PersonCommitmentRow.ReceivingField.ToString("0000000000"); TPartnerServerLookups.GetPartnerShortName(PersonCommitmentRow.ReceivingField, out FieldName, out FieldPartnerClass); PersonCommitmentRecord.ReceivingFieldName = FieldName; PersonCommitmentRecord.SendingFieldKey = PersonCommitmentRow.HomeOffice.ToString("0000000000"); TPartnerServerLookups.GetPartnerShortName(PersonCommitmentRow.HomeOffice, out FieldName, out FieldPartnerClass); PersonCommitmentRecord.SendingFieldName = FieldName; PersonCommitmentRecord.RecruitingFieldKey = PersonCommitmentRow.OfficeRecruitedBy.ToString("0000000000"); TPartnerServerLookups.GetPartnerShortName(PersonCommitmentRow.OfficeRecruitedBy, out FieldName, out FieldPartnerClass); PersonCommitmentRecord.RecruitingFieldName = FieldName; PersonCommitmentRecord.Comment = PersonCommitmentRow.StaffDataComments; AFormDataPerson.AddCommitment(PersonCommitmentRecord); } } if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eFutureCommitment)) { foreach (DataRowView rv in PersonCommitmentTable.DefaultView) { PersonCommitmentRow = (PmStaffDataRow)rv.Row; if (PersonCommitmentRow.StartOfCommitment >= DateTime.Today) { TPartnerServerLookups.GetPartnerShortName(PersonCommitmentRow.ReceivingField, out FieldName, out FieldPartnerClass); AFormDataPerson.FutureFieldName = FieldName; AFormDataPerson.FutureCommitStartDate = PersonCommitmentRow.StartOfCommitment; AFormDataPerson.FutureCommitEndDate = PersonCommitmentRow.EndOfCommitment; // only use the first commitment (list is sorted by start date) break; } } } } } }
/// <summary> /// Get recursively all the child units of a unit and puts them into the /// results list. /// </summary> /// <param name="AUnitKey">Parent unit to get the child unit from</param> /// <param name="AChildLevel">Indicates how deep we are in the recursion</param> /// <param name="AWithOutreaches">Indicates if outreaches and conferences should /// be included in the result</param> /// <param name="AChildRow">the number of the row</param> /// <returns>False if the parent unit is not active. /// Otherwise true</returns> private bool GetChildUnits(long AUnitKey, int AChildLevel, bool AWithOutreaches, ref int AChildRow) { UmUnitStructureTable UnitStructure; PUnitTable UnitTable; PPartnerTable PartnerTable; UUnitTypeTable UnitType; PartnerTable = PPartnerAccess.LoadByPrimaryKey(AUnitKey, situation.GetDatabaseConnection().Transaction); if ((PartnerTable.Rows.Count > 0) && (((PPartnerRow)PartnerTable.Rows[0]).StatusCode != "ACTIVE")) { return(false); } string PreceedingWhiteSpaces = new string(' ', AChildLevel * 2); UnitStructure = UmUnitStructureAccess.LoadViaPUnitParentUnitKey(AUnitKey, situation.GetDatabaseConnection().Transaction); // Add this unit to the results UnitTable = PUnitAccess.LoadByPrimaryKey(AUnitKey, situation.GetDatabaseConnection().Transaction); if (UnitTable.Rows.Count > 0) { PUnitRow UnitRow = (PUnitRow)UnitTable.Rows[0]; string UnitTypeName = UnitRow.UnitTypeCode; UnitType = UUnitTypeAccess.LoadByPrimaryKey(UnitRow.UnitTypeCode, situation.GetDatabaseConnection().Transaction); if (UnitType.Rows.Count > 0) { UnitTypeName = ((UUnitTypeRow)UnitType.Rows[0]).UnitTypeName; } string UnitKeyString = FormatAsUnitKey(UnitRow.PartnerKey); TVariant[] Header = { new TVariant(), new TVariant(), new TVariant(), new TVariant() }; TVariant[] Description = { new TVariant(), new TVariant() }; TVariant[] Columns = { new TVariant(PreceedingWhiteSpaces + UnitKeyString), new TVariant(PreceedingWhiteSpaces + UnitTypeName), new TVariant(PreceedingWhiteSpaces + UnitRow.UnitName), new TVariant(UnitRow.PartnerKey) }; situation.GetResults().AddRow(0, AChildRow++, true, 1, "", "", false, Header, Description, Columns); } // // Add the children to the results // SortedList <string, long> ChildList = new SortedList <string, long>(); AChildLevel++; foreach (DataRow Row in UnitStructure.Rows) { // Add the name and the key into a sorted list // so we can sort the result alphabetically long ChildUnitKey = (long)Row[UmUnitStructureTable.GetChildUnitKeyDBName()]; if (ChildUnitKey == AUnitKey) { continue; } UnitTable = PUnitAccess.LoadByPrimaryKey(ChildUnitKey, situation.GetDatabaseConnection().Transaction); if (UnitTable.Rows.Count < 1) { continue; } PUnitRow UnitRow = (PUnitRow)UnitTable.Rows[0]; string UnitName = UnitRow.UnitName; string UnitTypeName = UnitRow.UnitTypeCode; if (!AWithOutreaches && ((UnitTypeName.StartsWith("GA")) || (UnitTypeName.StartsWith("GC")) || (UnitTypeName.StartsWith("TN")) || (UnitTypeName.StartsWith("TS")))) { continue; } // use as key UnitName (for sorting) plus UnitKey so that it is // unique. We might have two units with the same name ChildList.Add(UnitName + ChildUnitKey.ToString(), ChildUnitKey); } foreach (KeyValuePair <string, long> kvp in ChildList) { GetChildUnits(kvp.Value, AChildLevel, AWithOutreaches, ref AChildRow); } return(true); }
private static bool GetAllSendingFields(long AConferenceKey, ref DataTable AFieldsTable) { TDBTransaction ReadTransaction; Boolean NewTransaction = false; PUnitTable UnitTable; PcAttendeeTable AttendeeTable = new PcAttendeeTable(); TLogging.LogAtLevel(9, "TConferenceOptions.GetAllSendingFields called!"); TDataBase db = DBAccess.Connect("GetAllSendingFields"); ReadTransaction = db.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead, out NewTransaction); try { StringCollection FieldList = new StringCollection(); FieldList.Add(PcAttendeeTable.GetHomeOfficeKeyDBName()); AttendeeTable = PcAttendeeAccess.LoadAll(FieldList, ReadTransaction); long LastUnitKey = 0; long NewUnitKey = 0; String HomeOfficeColumnName = PcAttendeeTable.GetHomeOfficeKeyDBName(); foreach (DataRow AttendeeRow in AttendeeTable.Select("", HomeOfficeColumnName)) { if (AttendeeRow[HomeOfficeColumnName] != null) { NewUnitKey = (long)AttendeeRow[HomeOfficeColumnName]; } else { continue; } if (LastUnitKey == NewUnitKey) { continue; } UnitTable = PUnitAccess.LoadByPrimaryKey(NewUnitKey, ReadTransaction); if (UnitTable.Rows.Count > 0) { DataRow ResultRow = AFieldsTable.NewRow(); ResultRow[SELECTION] = false; ResultRow[UNIT_KEY] = NewUnitKey; ResultRow[UNIT_NAME] = UnitTable[0][PUnitTable.GetUnitNameDBName()]; ResultRow[USED_IN_CONFERENCE] = true; AFieldsTable.Rows.Add(ResultRow); LastUnitKey = NewUnitKey; } } } finally { if (NewTransaction) { ReadTransaction.Commit(); TLogging.LogAtLevel(7, "TConferenceOptions.GetAllSendingFields: committed own transaction."); } } return(true); }
/// <summary> /// Passes data as a Typed DataSet to the caller, containing a DataTable that corresponds with <paramref name="AIndivDataItem"></paramref>. /// </summary> /// <param name="APartnerKey">PartnerKey of the Person to load data for.</param> /// <param name="AIndivDataItem">The Individual Data Item for which data should be returned.</param> /// <param name="AReadTransaction">Open Database transaction.</param> /// <returns>A Typed DataSet containing a DataTable that corresponds with <paramref name="AIndivDataItem"></paramref>.</returns> private static IndividualDataTDS GetData(Int64 APartnerKey, TIndividualDataItemEnum AIndivDataItem, TDBTransaction AReadTransaction) { IndividualDataTDS IndividualDataDS = new IndividualDataTDS("IndividualData"); // create the IndividualDataTDS DataSet that will later be passed to the Client IndividualDataTDSMiscellaneousDataTable MiscellaneousDataDT; IndividualDataTDSMiscellaneousDataRow MiscellaneousDataDR; #region Create 'Miscellaneous' DataRow MiscellaneousDataDT = IndividualDataDS.MiscellaneousData; MiscellaneousDataDR = MiscellaneousDataDT.NewRowTyped(false); MiscellaneousDataDR.PartnerKey = APartnerKey; MiscellaneousDataDT.Rows.Add(MiscellaneousDataDR); #endregion switch (AIndivDataItem) { case TIndividualDataItemEnum.idiSummary: BuildSummaryData(APartnerKey, ref IndividualDataDS, AReadTransaction); DetermineItemCounts(MiscellaneousDataDR, AReadTransaction); break; case TIndividualDataItemEnum.idiPersonalLanguages: PmPersonLanguageAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); PLanguageTable LanguageTable = (PLanguageTable)TSharedDataCache.TMCommon.GetCacheableCommonTable( TCacheableCommonTablesEnum.LanguageCodeList); PLanguageRow LanguageRow; foreach (IndividualDataTDSPmPersonLanguageRow PersonLanguageRow in IndividualDataDS.PmPersonLanguage.Rows) { LanguageRow = (PLanguageRow)LanguageTable.Rows.Find(new object[] { PersonLanguageRow.LanguageCode }); if (LanguageRow != null) { PersonLanguageRow.LanguageDescription = LanguageRow.LanguageDescription; } } break; case TIndividualDataItemEnum.idiSpecialNeeds: PmSpecialNeedAccess.LoadByPrimaryKey(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiPreviousExperiences: PmPastExperienceAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); PUnitTable UnitTable; PUnitRow UnitRow; // For outreaches the event code is currently stored in the location field. Try to retrieve the correct // outreach event and return it's actual name (as the event does not mean much to anybody). foreach (IndividualDataTDSPmPastExperienceRow PastExpRow in IndividualDataDS.PmPastExperience.Rows) { PUnitRow template = new PUnitTable().NewRowTyped(false); template.OutreachCode = PastExpRow.PrevLocation; UnitTable = PUnitAccess.LoadUsingTemplate(template, AReadTransaction); if (UnitTable.Rows.Count > 0) { UnitRow = (PUnitRow)UnitTable.Rows[0]; PastExpRow.EventName = UnitRow.UnitName; } } break; case TIndividualDataItemEnum.idiPersonalDocuments: PmDocumentAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiJobAssignments: PmJobAssignmentAccess.LoadViaPPartner(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiLocalPersonnelData: // TODO: Fix this so LocalPersonnelData can actually load some data bool labelsAvailable; TOfficeSpecificDataLabelsUIConnector OfficeSpecificDataLabelsUIConnector; OfficeSpecificDataLabelsUIConnector = new TOfficeSpecificDataLabelsUIConnector(APartnerKey, TOfficeSpecificDataLabelUseEnum.Personnel); IndividualDataDS.Merge(OfficeSpecificDataLabelsUIConnector.GetDataLocalPartnerDataValues(APartnerKey, out labelsAvailable, false, AReadTransaction)); break; case TIndividualDataItemEnum.idiProgressReports: PmPersonEvaluationAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiCommitmentPeriods: PmStaffDataAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiPersonSkills: PmPersonSkillAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiPersonalAbilities: PmPersonAbilityAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiPassportDetails: PmPassportDetailsAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); PCountryTable CountryTable = (PCountryTable)TSharedDataCache.TMCommon.GetCacheableCommonTable( TCacheableCommonTablesEnum.CountryList); PCountryRow CountryRow; foreach (IndividualDataTDSPmPassportDetailsRow PassportRow in IndividualDataDS.PmPassportDetails.Rows) { CountryRow = (PCountryRow)CountryTable.Rows.Find(new object[] { PassportRow.PassportNationalityCode }); if (CountryRow != null) { PassportRow.PassportNationalityName = CountryRow.CountryName; } } break; case TIndividualDataItemEnum.idiPersonalData: PmPersonalDataAccess.LoadByPrimaryKey(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiEmergencyData: PmPersonalDataAccess.LoadByPrimaryKey(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiApplications: PmGeneralApplicationAccess.LoadViaPPersonPartnerKey(IndividualDataDS, APartnerKey, AReadTransaction); PmShortTermApplicationAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); PmYearProgramApplicationAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); IndividualDataTDSPmGeneralApplicationRow GenAppRow; TPartnerClass PartnerClass; TStdPartnerStatusCode PartnerStatus; String EventOrFieldName; //TODO: now go through all short and long term apps and set the // two fields in general app for EventOrFieldName and ApplicationForEventOrField foreach (PmShortTermApplicationRow ShortTermRow in IndividualDataDS.PmShortTermApplication.Rows) { GenAppRow = (IndividualDataTDSPmGeneralApplicationRow)IndividualDataDS.PmGeneralApplication.Rows.Find (new object[] { ShortTermRow.PartnerKey, ShortTermRow.ApplicationKey, ShortTermRow.RegistrationOffice }); GenAppRow.ApplicationForEventOrField = Catalog.GetString("Event"); if (!ShortTermRow.IsStConfirmedOptionNull()) { Ict.Petra.Server.MCommon.MCommonMain.RetrievePartnerShortName (ShortTermRow.StConfirmedOption, out EventOrFieldName, out PartnerClass, out PartnerStatus); GenAppRow.EventOrFieldName = EventOrFieldName; } } foreach (PmYearProgramApplicationRow LongTermRow in IndividualDataDS.PmYearProgramApplication.Rows) { GenAppRow = (IndividualDataTDSPmGeneralApplicationRow)IndividualDataDS.PmGeneralApplication.Rows.Find (new object[] { LongTermRow.PartnerKey, LongTermRow.ApplicationKey, LongTermRow.RegistrationOffice }); GenAppRow.ApplicationForEventOrField = Catalog.GetString("Field"); if (!GenAppRow.IsGenAppPossSrvUnitKeyNull()) { Ict.Petra.Server.MCommon.MCommonMain.RetrievePartnerShortName (GenAppRow.GenAppPossSrvUnitKey, out EventOrFieldName, out PartnerClass, out PartnerStatus); GenAppRow.EventOrFieldName = EventOrFieldName; } } break; // TODO: work on all cases/load data for all Individual Data items } return(IndividualDataDS); }
/// <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); }
/// <summary> /// Load/Refresh all Attendees for a conference /// </summary> public static void RefreshAttendees(Int64 AConferenceKey) { TDBTransaction Transaction = new TDBTransaction(); bool SubmissionOK = true; PcConferenceTable ConferenceTable; PUnitTable UnitTable; string OutreachPrefix = String.Empty; ConferenceApplicationTDS MainDS; // make sure outreach codes are up to date in case it has changed in Unit record RefreshOutreachCode(AConferenceKey); DBAccess.WriteTransaction( ref Transaction, ref SubmissionOK, delegate { ConferenceTable = new PcConferenceTable(); UnitTable = new PUnitTable(); MainDS = new ConferenceApplicationTDS(); // get the conference prefix which links all outreaches associated with a conference ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, Transaction); if (ConferenceTable.Count == 0) { throw new Exception("Cannot find conference " + AConferenceKey.ToString("0000000000")); } OutreachPrefix = ConferenceTable[0].OutreachPrefix; // load application data for all conference attendees from db TApplicationManagement.GetApplications(ref MainDS, AConferenceKey, OutreachPrefix, "all", -1, true, null, false); // check a valid pcattendee record exists for each short term application foreach (PmShortTermApplicationRow ShortTermAppRow in MainDS.PmShortTermApplication.Rows) { if (!IsAttendeeValid(MainDS, OutreachPrefix, ShortTermAppRow.PartnerKey)) { // ignore deleted applications, or cancelled applications continue; } // update outreach code in application (it may have changed) UnitTable = PUnitAccess.LoadByPrimaryKey(ShortTermAppRow.StConfirmedOption, Transaction); ShortTermAppRow.ConfirmedOptionCode = ((PUnitRow)UnitTable.Rows[0]).OutreachCode; // Do we have a record for this attendee yet? bool AttendeeRecordExists = false; if (MainDS.PcAttendee.Rows.Contains(new object[] { AConferenceKey, ShortTermAppRow.PartnerKey })) { AttendeeRecordExists = true; } // create a new PcAttendee record if one does not already exist for this attendee if (!AttendeeRecordExists) { PcAttendeeRow AttendeeRow = MainDS.PcAttendee.NewRowTyped(); AttendeeRow.ConferenceKey = AConferenceKey; AttendeeRow.PartnerKey = ShortTermAppRow.PartnerKey; if (ShortTermAppRow.ConfirmedOptionCode.Length >= 11) { AttendeeRow.OutreachType = ShortTermAppRow.ConfirmedOptionCode.Substring(5, 6); } PmGeneralApplicationRow GeneralAppRow = (PmGeneralApplicationRow)MainDS.PmGeneralApplication.Rows.Find( new object[] { ShortTermAppRow.PartnerKey, ShortTermAppRow.ApplicationKey, ShortTermAppRow.RegistrationOffice }); DateTime DateAccepted = GeneralAppRow.GenAppDate; if (!GeneralAppRow.IsGenAppSendFldAcceptDateNull()) { DateAccepted = GeneralAppRow.GenAppSendFldAcceptDate.Value; } else if (!GeneralAppRow.IsGenAppRecvgFldAcceptNull()) { DateAccepted = GeneralAppRow.GenAppRecvgFldAccept.Value; } AttendeeRow.Registered = DateAccepted; // TODO: in Petra 2.x, this was calculated from pm_staff_data AttendeeRow.HomeOfficeKey = ShortTermAppRow.RegistrationOffice; if (AttendeeRow.HomeOfficeKey == 0) { AttendeeRow.HomeOfficeKey = ((int)AttendeeRow.PartnerKey / 1000000) * 1000000; } MainDS.PcAttendee.Rows.Add(AttendeeRow); } } PcRoomAllocTable RoomAllocTable = null; PcExtraCostTable ExtraCostTable = null; // now check the other way: all attendees of this conference, are they still valid? foreach (PcAttendeeRow AttendeeRow in MainDS.PcAttendee.Rows) { if ((AttendeeRow.RowState != DataRowState.Added) && !IsAttendeeValid(MainDS, OutreachPrefix, AttendeeRow.PartnerKey)) { // remove their accommodation RoomAllocTable = PcRoomAllocAccess.LoadViaPcAttendee(AttendeeRow.ConferenceKey, AttendeeRow.PartnerKey, Transaction); foreach (DataRow Row in RoomAllocTable.Rows) { Row.Delete(); } if (RoomAllocTable != null) { PcRoomAllocAccess.SubmitChanges(RoomAllocTable, Transaction); } // remove any extra costs ExtraCostTable = PcExtraCostAccess.LoadViaPcAttendee(AttendeeRow.ConferenceKey, AttendeeRow.PartnerKey, Transaction); foreach (DataRow Row in ExtraCostTable.Rows) { Row.Delete(); } if (ExtraCostTable != null) { PcExtraCostAccess.SubmitChanges(ExtraCostTable, Transaction); } // remove attendee AttendeeRow.Delete(); } } int shorttermApplicationsCount = MainDS.PmShortTermApplication.Count; int attendeeCount = MainDS.PcAttendee.Count; MainDS.ThrowAwayAfterSubmitChanges = true; ConferenceApplicationTDSAccess.SubmitChanges(MainDS); }); }
public static ArrayList GetUnitHeirarchy() { const Int64 THE_ORGANISATION = 1000000; ArrayList Ret = new ArrayList(); try { TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted); PUnitTable UnitTbl = PUnitAccess.LoadAll(Transaction); UUnitTypeTable UnitTypeTbl = UUnitTypeAccess.LoadAll(Transaction); UnitTypeTbl.DefaultView.Sort = UUnitTypeTable.GetUnitTypeCodeDBName(); UmUnitStructureTable HierarchyTbl = UmUnitStructureAccess.LoadAll(Transaction); HierarchyTbl.DefaultView.Sort = UmUnitStructureTable.GetChildUnitKeyDBName(); UnitTbl.DefaultView.Sort = PUnitTable.GetPartnerKeyDBName(); UnitHierarchyNode RootNode = new UnitHierarchyNode(); RootNode.MyUnitKey = THE_ORGANISATION; RootNode.ParentUnitKey = THE_ORGANISATION; RootNode.Description = "The Organisation"; RootNode.TypeCode = "Root"; Int32 RootUnitIdx = UnitTbl.DefaultView.Find(THE_ORGANISATION); if (RootUnitIdx >= 0) { RootNode.Description = ((PUnitRow)UnitTbl.DefaultView[RootUnitIdx].Row).UnitName; UnitTbl.DefaultView.Delete(RootUnitIdx); } Ret.Add(RootNode); foreach (DataRowView rv in UnitTbl.DefaultView) { PUnitRow UnitRow = (PUnitRow)rv.Row; UnitHierarchyNode Node = new UnitHierarchyNode(); Node.Description = UnitRow.UnitName + " " + UnitRow.Description; if (Node.Description == "") { Node.Description = "[" + UnitRow.PartnerKey.ToString("D10") + "]"; } Node.MyUnitKey = UnitRow.PartnerKey; // // Retrieve parent.. Int32 HierarchyTblIdx = HierarchyTbl.DefaultView.Find(Node.MyUnitKey); if (HierarchyTblIdx >= 0) { Node.ParentUnitKey = ((UmUnitStructureRow)HierarchyTbl.DefaultView[HierarchyTblIdx].Row).ParentUnitKey; } else { Node.ParentUnitKey = THE_ORGANISATION; } // // Retrieve TypeCode.. Int32 TypeTblIndex = UnitTypeTbl.DefaultView.Find(UnitRow.UnitTypeCode); if (TypeTblIndex >= 0) { Node.TypeCode = ((UUnitTypeRow)UnitTypeTbl.DefaultView[TypeTblIndex].Row).UnitTypeName; } else { Node.TypeCode = "Type: " + UnitRow.UnitTypeCode; } Ret.Add(Node); } } finally { DBAccess.GDBAccessObj.RollbackTransaction(); } return(Ret); }
private static void GenerateRegistrationOffices(string ACountryName, Int64 APartnerKey, string ACountryCode) { if (PUnitAccess.Exists(APartnerKey, null)) { TLogging.Log("Office with key " + APartnerKey.ToString() + " already exists."); return; } PartnerEditTDS MainDS = new PartnerEditTDS(); PPartnerRow partnerRow = MainDS.PPartner.NewRowTyped(true); partnerRow.PartnerKey = APartnerKey; partnerRow.PartnerShortName = ACountryName; partnerRow.PartnerClass = MPartnerConstants.PARTNERCLASS_UNIT; partnerRow.StatusCode = MPartnerConstants.PARTNERSTATUS_ACTIVE; partnerRow.AddresseeTypeCode = MPartnerConstants.ADDRESSEETYPE_ORGANISATION; MainDS.PPartner.Rows.Add(partnerRow); PUnitRow unitRow = MainDS.PUnit.NewRowTyped(true); unitRow.PartnerKey = partnerRow.PartnerKey; unitRow.UnitName = partnerRow.PartnerShortName; unitRow.CountryCode = ACountryCode; unitRow.UnitTypeCode = MPartnerConstants.UNIT_TYPE_FIELD; MainDS.PUnit.Rows.Add(unitRow); PLocationRow locationRow = MainDS.PLocation.NewRowTyped(); locationRow.SiteKey = partnerRow.PartnerKey; locationRow.LocationKey = 0; locationRow.StreetName = "No valid address on file"; locationRow.CountryCode = ACountryCode; MainDS.PLocation.Rows.Add(locationRow); PPartnerLocationRow partnerlocationRow = MainDS.PPartnerLocation.NewRowTyped(); partnerlocationRow.PartnerKey = partnerRow.PartnerKey; partnerlocationRow.SiteKey = locationRow.SiteKey; partnerlocationRow.LocationKey = locationRow.LocationKey; MainDS.PPartnerLocation.Rows.Add(partnerlocationRow); PPartnerTypeRow partnertypeRow = MainDS.PPartnerType.NewRowTyped(); partnertypeRow.PartnerKey = partnerRow.PartnerKey; partnertypeRow.TypeCode = MPartnerConstants.PARTNERTYPE_LEDGER; MainDS.PPartnerType.Rows.Add(partnertypeRow); UmUnitStructureRow unitStructureRow = MainDS.UmUnitStructure.NewRowTyped(); unitStructureRow.ParentUnitKey = 1000000; unitStructureRow.ChildUnitKey = partnerRow.PartnerKey; MainDS.UmUnitStructure.Rows.Add(unitStructureRow); PartnerEditTDSAccess.SubmitChanges(MainDS); string sqlInsertModule = String.Format("INSERT INTO PUB_{0}({1}, {2}) VALUES ('REG-{3:0000000000}','Registration {4}')", SModuleTable.GetTableDBName(), SModuleTable.GetModuleIdDBName(), SModuleTable.GetModuleNameDBName(), APartnerKey, ACountryName); string sqlInsertModulePermissions = String.Format("INSERT INTO PUB_{0}({1}, {2}, {3}) VALUES ('DEMO', 'REG-{4:0000000000}',true)", SUserModuleAccessPermissionTable.GetTableDBName(), SUserModuleAccessPermissionTable.GetUserIdDBName(), SUserModuleAccessPermissionTable.GetModuleIdDBName(), SUserModuleAccessPermissionTable.GetCanAccessDBName(), APartnerKey); TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable); try { DBAccess.GDBAccessObj.ExecuteNonQuery(sqlInsertModule, Transaction); DBAccess.GDBAccessObj.ExecuteNonQuery(sqlInsertModulePermissions, Transaction); DBAccess.GDBAccessObj.CommitTransaction(); } catch (Exception e) { TLogging.Log(e.ToString()); DBAccess.GDBAccessObj.RollbackTransaction(); } }
public static Boolean GetMotivationGroupAndDetail(Int64 APartnerKey, ref String AMotivationGroup, ref String AMotivationDetail) { Boolean PartnerKeyIsValid = false; if (APartnerKey != 0) { string MotivationGroup = MFinanceConstants.MOTIVATION_GROUP_GIFT; string MotivationDetail = AMotivationDetail; TDBTransaction readTransaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref readTransaction, delegate { PPartnerTable myPPartnerTable = null; myPPartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, readTransaction); if (myPPartnerTable.Rows.Count == 1) { // Entry for partnerKey is valid PartnerKeyIsValid = true; PPartnerRow partnerRow = null; partnerRow = (PPartnerRow)myPPartnerTable.Rows[0]; // Change motivationDetail if ColumnPartnerClass is UNIT if (partnerRow.PartnerClass.Equals(MPartnerConstants.PARTNERCLASS_UNIT)) { // AND KEY-MIN bool KeyMinFound = false; // first check if a motivation detail is linked to this potential key min AMotivationDetailTable MotivationDetailTable = null; MotivationDetailTable = AMotivationDetailAccess.LoadViaPPartner(APartnerKey, readTransaction); if ((MotivationDetailTable != null) && (MotivationDetailTable.Rows.Count > 0)) { foreach (AMotivationDetailRow Row in MotivationDetailTable.Rows) { if (Row.MotivationStatus) { MotivationGroup = MotivationDetailTable[0].MotivationGroupCode; MotivationDetail = MotivationDetailTable[0].MotivationDetailCode; KeyMinFound = true; break; } } } // second check to see if this is a key min if (!KeyMinFound) { PUnitTable pUnitTable = null; pUnitTable = PUnitAccess.LoadByPrimaryKey(APartnerKey, readTransaction); if (pUnitTable.Rows.Count == 1) { PUnitRow unitRow = null; unitRow = (PUnitRow)pUnitTable.Rows[0]; if (unitRow.UnitTypeCode.Equals(MPartnerConstants.UNIT_TYPE_KEYMIN)) { MotivationDetail = MFinanceConstants.GROUP_DETAIL_KEY_MIN; } else { MotivationDetail = TSystemDefaults.GetStringDefault(SharedConstants.SYSDEFAULT_DEFAULTFIELDMOTIVATION, MFinanceConstants.GROUP_DETAIL_FIELD); // if system default is empty then set to FIELD if (string.IsNullOrEmpty(MotivationDetail)) { MotivationDetail = MFinanceConstants.GROUP_DETAIL_FIELD; } } } } } else { MotivationDetail = MFinanceConstants.GROUP_DETAIL_SUPPORT; } } }); AMotivationGroup = MotivationGroup; AMotivationDetail = MotivationDetail; } return(PartnerKeyIsValid); }
private static void CreateShortTermApplication(XmlNode ANode, Int64 APartnerKey, ref PartnerImportExportTDS AMainDS, TDBTransaction ATransaction) { String strEventKey = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_EVENTKEY); long EventKey = -1; if (strEventKey.Length > 0) { try { EventKey = long.Parse(strEventKey); } catch (System.FormatException) { AddVerificationResult("Bad number format in EventKey: " + strEventKey); } if (!PUnitAccess.Exists(EventKey, ATransaction)) { AddVerificationResult("EventKey not known - application cannot be imported: " + EventKey); return; } PmGeneralApplicationRow GenAppRow = AMainDS.PmGeneralApplication.NewRowTyped(); GenAppRow.PartnerKey = APartnerKey; GenAppRow.ApplicationKey = (int)DBAccess.GDBAccessObj.GetNextSequenceValue("seq_application", ATransaction); GenAppRow.OldLink = TSystemDefaults.GetSystemDefault(SharedConstants.SYSDEFAULT_SITEKEY, "") + ";" + GenAppRow.ApplicationKey.ToString(); GenAppRow.RegistrationOffice = DomainManager.GSiteKey; // When this is imported, RegistrationOffice can't be null. GenAppRow.GenAppDate = DateTime.Now; GenAppRow.AppTypeName = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_APPTYPE); GenAppRow.GenApplicationStatus = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_APPSTATUS); GenAppRow.Comment = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_APPCOMMENTS); PmShortTermApplicationRow ShortTermRow = AMainDS.PmShortTermApplication.NewRowTyped(); ShortTermRow.PartnerKey = APartnerKey; ShortTermRow.ApplicationKey = GenAppRow.ApplicationKey; ShortTermRow.RegistrationOffice = GenAppRow.RegistrationOffice; // When this is imported, RegistrationOffice can't be null. ShortTermRow.StBasicOutreachId = "Unused field"; // This field is scheduled for deletion, but NOT NULL now. ShortTermRow.StAppDate = DateTime.Now; ShortTermRow.StApplicationType = GenAppRow.AppTypeName; ShortTermRow.StConfirmedOption = EventKey; String TimeString = ""; try { TimeString = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_ARRIVALDATE); if (TimeString.Length > 0) { ShortTermRow.Arrival = DateTime.Parse(TimeString); } TimeString = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_DEPARTUREDATE); if (TimeString.Length > 0) { ShortTermRow.Departure = DateTime.Parse(TimeString); } } catch (System.FormatException) { AddVerificationResult("Bad date format in Application: " + TimeString); } DateTime TempTime; TimeString = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_ARRIVALTIME); if (TimeString.Length > 0) { try { TempTime = DateTime.Parse(TimeString); ShortTermRow.ArrivalHour = TempTime.Hour; ShortTermRow.ArrivalMinute = TempTime.Minute; } catch (System.FormatException) { AddVerificationResult("Bad time format in Application: " + TimeString); } } TimeString = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_DEPARTURETIME); if (TimeString.Length > 0) { try { TempTime = DateTime.Parse(TimeString); ShortTermRow.DepartureHour = TempTime.Hour; ShortTermRow.DepartureMinute = TempTime.Minute; } catch (System.FormatException) { AddVerificationResult("Bad time format in Application: " + TimeString); } } ShortTermRow.OutreachRole = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_EVENTROLE); String ChargedField = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_CHARGEDFIELD); if (ChargedField.Length > 0) { try { ShortTermRow.StFieldCharged = long.Parse(ChargedField); } catch { AddVerificationResult("Bad number format in ChargedField: " + ChargedField); } } AMainDS.PmGeneralApplication.Rows.Add(GenAppRow); AMainDS.PmShortTermApplication.Rows.Add(ShortTermRow); AddVerificationResult("Application Record Created.", TResultSeverity.Resv_Status); } }
/// <summary> /// Retrieves data that will be shown on the 'Overview' UserControl and adds it to <paramref name="AIndividualDataDS" />. /// </summary> /// <param name="APartnerKey">PartnerKey of the Person to load data for.</param> /// <param name="AIndividualDataDS">Typed DataSet of Type <see cref="IndividualDataTDS" />. Needs to be instantiated already!</param> /// <param name="AReadTransaction">Open Database transaction.</param> /// <returns>void</returns> private static void BuildSummaryData(Int64 APartnerKey, ref IndividualDataTDS AIndividualDataDS, TDBTransaction AReadTransaction) { string StrNotAvailable = Catalog.GetString("Not Available"); IndividualDataTDSSummaryDataTable SummaryDT; IndividualDataTDSSummaryDataRow SummaryDR; IndividualDataTDSMiscellaneousDataRow MiscellaneousDataDR = AIndividualDataDS.MiscellaneousData[0]; PPersonTable PPersonDT; PPersonRow PersonDR = null; PmPassportDetailsTable PassportDetailsDT; PmStaffDataTable PmStaffDataDT; PmStaffDataRow PmStaffDataDR = null; PmJobAssignmentTable PmJobAssignmentDT = null; PUnitTable PUnitDT = null; PmJobAssignmentRow PmJobAssignmentDR; IndividualDataTDSJobAssignmentStaffDataCombinedRow JobAssiStaffDataCombDR; int JobAssiStaffDataCombKey = 0; TCacheable CommonCacheable = new TCacheable(); TPartnerCacheable PartnerCacheable = new TPartnerCacheable(); string MaritalStatusDescr; StringCollection PassportColumns; string Nationalities; PPartnerRelationshipTable PartnerRelationshipDT; PPartnerTable PartnerDT; PPartnerRow PartnerDR = null; PLocationRow LocationDR; PPartnerLocationRow PartnerLocationDR; string PhoneNumber; string EmailAddress; Int64 ChurchPartnerKey; SummaryDT = new IndividualDataTDSSummaryDataTable(); SummaryDR = SummaryDT.NewRowTyped(false); SummaryDR.PartnerKey = APartnerKey; #region Person Info PPersonDT = PPersonAccess.LoadByPrimaryKey(APartnerKey, AReadTransaction); if (PPersonDT.Rows.Count == 1) { PersonDR = (PPersonRow)PPersonDT.Rows[0]; } if (PersonDR != null) { SummaryDR.DateOfBirth = PersonDR.DateOfBirth; SummaryDR.Gender = PersonDR.Gender; MaritalStatusDescr = PartnerCodeHelper.GetMaritalStatusDescription( @PartnerCacheable.GetCacheableTable, PersonDR.MaritalStatus); if (MaritalStatusDescr != String.Empty) { MaritalStatusDescr = " - " + MaritalStatusDescr; } SummaryDR.MaritalStatus = PersonDR.MaritalStatus + MaritalStatusDescr; } else { SummaryDR.SetDateOfBirthNull(); SummaryDR.Gender = StrNotAvailable; SummaryDR.MaritalStatus = StrNotAvailable; } #region Nationalities PassportColumns = StringHelper.StrSplit( PmPassportDetailsTable.GetDateOfIssueDBName() + "," + PmPassportDetailsTable.GetDateOfExpirationDBName() + "," + PmPassportDetailsTable.GetPassportNationalityCodeDBName() + "," + PmPassportDetailsTable.GetMainPassportDBName(), ","); PassportDetailsDT = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey, PassportColumns, AReadTransaction, null, 0, 0); Nationalities = Ict.Petra.Shared.MPersonnel.Calculations.DeterminePersonsNationalities( @CommonCacheable.GetCacheableTable, PassportDetailsDT); if (Nationalities != String.Empty) { SummaryDR.Nationalities = Nationalities; } else { SummaryDR.Nationalities = StrNotAvailable; } #endregion #region Phone and Email (from 'Best Address') if (TContactDetailsAggregate.GetPrimaryEmailAndPrimaryPhone(APartnerKey, out PhoneNumber, out EmailAddress)) { SummaryDR.PrimaryPhoneNumber = PhoneNumber ?? StrNotAvailable; SummaryDR.PrimaryEmailAddress = EmailAddress ?? StrNotAvailable; } else { SummaryDR.PrimaryPhoneNumber = StrNotAvailable; SummaryDR.PrimaryEmailAddress = StrNotAvailable; } #endregion #endregion #region Commitments/Jobs PmStaffDataDT = PmStaffDataAccess.LoadViaPPerson(APartnerKey, AReadTransaction); MiscellaneousDataDR.ItemsCountCommitmentPeriods = PmStaffDataDT.Rows.Count; // First check if the PERSON has got any Commitments if (PmStaffDataDT.Rows.Count > 0) { foreach (DataRow DR in PmStaffDataDT.Rows) { JobAssiStaffDataCombDR = AIndividualDataDS.JobAssignmentStaffDataCombined.NewRowTyped(false); JobAssiStaffDataCombDR.Key = JobAssiStaffDataCombKey++; JobAssiStaffDataCombDR.PartnerKey = APartnerKey; PmStaffDataDR = (PmStaffDataRow)DR; if (!(PmStaffDataDR.IsReceivingFieldNull()) && (PmStaffDataDR.ReceivingField != 0)) { PUnitDT = PUnitAccess.LoadByPrimaryKey(PmStaffDataDR.ReceivingField, AReadTransaction); JobAssiStaffDataCombDR.FieldKey = PmStaffDataDR.ReceivingField; JobAssiStaffDataCombDR.FieldName = PUnitDT[0].UnitName; } else { JobAssiStaffDataCombDR.FieldKey = 0; JobAssiStaffDataCombDR.FieldName = "[None]"; } JobAssiStaffDataCombDR.Position = PmStaffDataDR.JobTitle; JobAssiStaffDataCombDR.FromDate = PmStaffDataDR.StartOfCommitment; JobAssiStaffDataCombDR.ToDate = PmStaffDataDR.EndOfCommitment; AIndividualDataDS.JobAssignmentStaffDataCombined.Rows.Add(JobAssiStaffDataCombDR); } } else { // The PERSON hasn't got any Commitments, therefore check if the PERSON has any Job Assignments PmJobAssignmentDT = PmJobAssignmentAccess.LoadViaPPartner(APartnerKey, AReadTransaction); if (PmJobAssignmentDT.Rows.Count > 0) { foreach (DataRow DR in PmJobAssignmentDT.Rows) { JobAssiStaffDataCombDR = AIndividualDataDS.JobAssignmentStaffDataCombined.NewRowTyped(false); JobAssiStaffDataCombDR.Key = JobAssiStaffDataCombKey++; JobAssiStaffDataCombDR.PartnerKey = APartnerKey; PmJobAssignmentDR = (PmJobAssignmentRow)DR; if (PmJobAssignmentDR.UnitKey != 0) { PUnitDT = PUnitAccess.LoadByPrimaryKey(PmJobAssignmentDR.UnitKey, AReadTransaction); JobAssiStaffDataCombDR.FieldKey = PmJobAssignmentDR.UnitKey; JobAssiStaffDataCombDR.FieldName = PUnitDT[0].UnitName; } else { JobAssiStaffDataCombDR.FieldKey = 0; JobAssiStaffDataCombDR.FieldName = "[None]"; } JobAssiStaffDataCombDR.Position = PmJobAssignmentDR.PositionName; JobAssiStaffDataCombDR.FromDate = PmJobAssignmentDR.FromDate; JobAssiStaffDataCombDR.ToDate = PmJobAssignmentDR.ToDate; AIndividualDataDS.JobAssignmentStaffDataCombined.Rows.Add(JobAssiStaffDataCombDR); } } } #endregion #region Church Info SummaryDR.ChurchName = StrNotAvailable; SummaryDR.ChurchAddress = StrNotAvailable; SummaryDR.ChurchPrimaryPhoneNumber = StrNotAvailable; SummaryDR.ChurchPastor = StrNotAvailable; SummaryDR.ChurchPastorsPrimaryPhoneNumber = StrNotAvailable; SummaryDR.NumberOfShownSupportingChurchPastors = 0; // Find SUPPCHURCH Relationship PartnerRelationshipDT = PPartnerRelationshipAccess.LoadUsingTemplate(new TSearchCriteria[] { new TSearchCriteria(PPartnerRelationshipTable.GetRelationKeyDBName(), APartnerKey), new TSearchCriteria(PPartnerRelationshipTable.GetRelationNameDBName(), "SUPPCHURCH") }, AReadTransaction); SummaryDR.NumberOfShownSupportingChurches = PartnerRelationshipDT.Rows.Count; if (PartnerRelationshipDT.Rows.Count > 0) { ChurchPartnerKey = PartnerRelationshipDT[0].PartnerKey; // Load Church Partner PartnerDT = PPartnerAccess.LoadByPrimaryKey(ChurchPartnerKey, AReadTransaction); if (PartnerDT.Rows.Count > 0) { PartnerDR = PartnerDT[0]; // Church Name if (PartnerDR.PartnerShortName != String.Empty) { SummaryDR.ChurchName = PartnerDR.PartnerShortName; } #region Church Address and Phone ServerCalculations.DetermineBestAddress(PartnerRelationshipDT[0].PartnerKey, out PartnerLocationDR, out LocationDR); if (LocationDR != null) { SummaryDR.ChurchAddress = Calculations.DetermineLocationString(LocationDR, Calculations.TPartnerLocationFormatEnum.plfCommaSeparated); } if (TContactDetailsAggregate.GetPrimaryPhoneNumber(PartnerRelationshipDT[0].PartnerKey, out PhoneNumber)) { SummaryDR.ChurchPrimaryPhoneNumber = PhoneNumber ?? StrNotAvailable; } else { SummaryDR.ChurchPrimaryPhoneNumber = StrNotAvailable; } #endregion #region Pastor // Find PASTOR Relationship PartnerRelationshipDT.Rows.Clear(); PartnerRelationshipDT = PPartnerRelationshipAccess.LoadUsingTemplate(new TSearchCriteria[] { new TSearchCriteria(PPartnerRelationshipTable.GetPartnerKeyDBName(), ChurchPartnerKey), new TSearchCriteria(PPartnerRelationshipTable.GetRelationNameDBName(), "PASTOR") }, AReadTransaction); SummaryDR.NumberOfShownSupportingChurchPastors = PartnerRelationshipDT.Rows.Count; if (PartnerRelationshipDT.Rows.Count > 0) { // Load PASTOR Partner PartnerDT = PPartnerAccess.LoadByPrimaryKey(PartnerRelationshipDT[0].RelationKey, AReadTransaction); if (PartnerDT.Rows.Count > 0) { PartnerDR = PartnerDT[0]; // Pastor's Name if (PartnerDR.PartnerShortName != String.Empty) { SummaryDR.ChurchPastor = PartnerDR.PartnerShortName; } #region Pastor's Phone if (TContactDetailsAggregate.GetPrimaryPhoneNumber(PartnerRelationshipDT[0].RelationKey, out PhoneNumber)) { SummaryDR.ChurchPastorsPrimaryPhoneNumber = PhoneNumber ?? StrNotAvailable; } else { SummaryDR.ChurchPastorsPrimaryPhoneNumber = StrNotAvailable; } #endregion } } #endregion } } #endregion // Add Summary DataRow to Summary DataTable SummaryDT.Rows.Add(SummaryDR); // Add Row to 'SummaryData' DataTable in Typed DataSet 'IndividualDataTDS' AIndividualDataDS.Merge(SummaryDT); }
public static Boolean GetMotivationGroupAndDetailForPartner(Int64 APartnerKey, ref String AMotivationGroup, ref String AMotivationDetail) { Boolean PartnerKeyIsValid = false; if (APartnerKey != 0) { string motivationGroup = MFinanceConstants.MOTIVATION_GROUP_GIFT; string motivationDetail = AMotivationDetail; TDBTransaction readTransaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref readTransaction, delegate { PPartnerTable myPPartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, readTransaction); if (myPPartnerTable.Rows.Count == 1) { // partnerKey is valid PartnerKeyIsValid = true; PPartnerRow partnerRow = myPPartnerTable[0]; // Change motivationDetail if PartnerClass is UNIT if (partnerRow.PartnerClass.Equals(MPartnerConstants.PARTNERCLASS_UNIT)) { // AND KEY-MIN bool KeyMinFound = false; // first check if a specific motivation detail is linked to this partner AMotivationDetailTable MotivationDetailTable = AMotivationDetailAccess.LoadViaPPartner(APartnerKey, readTransaction); if ((MotivationDetailTable != null) && (MotivationDetailTable.Rows.Count > 0)) { foreach (AMotivationDetailRow Row in MotivationDetailTable.Rows) { if (Row.MotivationStatus) { motivationGroup = MotivationDetailTable[0].MotivationGroupCode; motivationDetail = MotivationDetailTable[0].MotivationDetailCode; KeyMinFound = true; break; // Go with the first entry found. } } } if (!KeyMinFound) { // Is this is a key min, or a field? PUnitTable pUnitTable = PUnitAccess.LoadByPrimaryKey(APartnerKey, readTransaction); if (pUnitTable.Rows.Count == 1) { PUnitRow unitRow = pUnitTable[0]; switch (unitRow.UnitTypeCode) { case MPartnerConstants.UNIT_TYPE_AREA: case MPartnerConstants.UNIT_TYPE_FUND: case MPartnerConstants.UNIT_TYPE_FIELD: motivationDetail = MFinanceConstants.GROUP_DETAIL_FIELD; break; case MPartnerConstants.UNIT_TYPE_KEYMIN: motivationDetail = MFinanceConstants.GROUP_DETAIL_KEY_MIN; break; case MPartnerConstants.UNIT_TYPE_COUNTRY: case MPartnerConstants.UNIT_TYPE_CONFERENCE: case MPartnerConstants.UNIT_TYPE_OTHER: case MPartnerConstants.UNIT_TYPE_ROOT: case MPartnerConstants.UNIT_TYPE_TEAM: case MPartnerConstants.UNIT_TYPE_WORKING_GROUP: default: motivationDetail = MFinanceConstants.GROUP_DETAIL_SUPPORT; break; } } } } else { motivationDetail = MFinanceConstants.GROUP_DETAIL_SUPPORT; } } }); AMotivationGroup = motivationGroup; AMotivationDetail = motivationDetail; } return(PartnerKeyIsValid); }
public static bool GetFieldUnits(Int64 AConferenceKey, TUnitTypeEnum AFieldTypes, out DataTable AFieldsTable, out String AConferencePrefix) { TDBTransaction ReadTransaction; Boolean NewTransaction = false; AFieldsTable = new DataTable("Field Units"); AConferencePrefix = ""; PUnitTable UnitTable; DataTable TmpTable; PmShortTermApplicationTable ShortTermerTable = new PmShortTermApplicationTable(); AFieldsTable.Columns.Add("Selection", System.Type.GetType("System.Boolean")); AFieldsTable.Columns.Add("Unit_Key", System.Type.GetType("System.Int64")); AFieldsTable.Columns.Add("Unit_Name", System.Type.GetType("System.String")); AFieldsTable.Columns.Add("Outreach_Code", System.Type.GetType("System.String")); AFieldsTable.Columns.Add("Used_in_Conference", System.Type.GetType("System.Boolean")); AConferencePrefix = TConferenceOptions.GetConferencePrefix(AConferenceKey); switch (AFieldTypes) { case TUnitTypeEnum.utSendingFields: return(TConferenceOptions.GetSendingFields(AConferenceKey, ref AFieldsTable)); case TUnitTypeEnum.utReceivingFields: return(TConferenceOptions.GetReceivingFields(AConferenceKey, ref AFieldsTable)); case TUnitTypeEnum.utOutreachOptions: if (TConferenceOptions.GetOutreachOptions(AConferenceKey, out TmpTable)) { foreach (DataRow Row in TmpTable.Rows) { DataRow NewRow = AFieldsTable.NewRow(); NewRow[SELECTION] = false; NewRow[UNIT_KEY] = Row["Partner Key"]; NewRow[UNIT_NAME] = Row["Unit Name"]; NewRow[CAMPAIGN_CODE] = Row["Outreach Code"]; NewRow[USED_IN_CONFERENCE] = true; AFieldsTable.Rows.Add(NewRow); } return(true); } return(false); default: break; } TLogging.LogAtLevel(9, "TConferenceOptions.GetFieldUnits called!"); TDataBase db = DBAccess.Connect("GetFieldUnits"); ReadTransaction = db.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead, out NewTransaction); try { StringCollection FieldList = new StringCollection(); FieldList.Add(PmShortTermApplicationTable.GetStFieldChargedDBName()); FieldList.Add(PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()); FieldList.Add(PmShortTermApplicationTable.GetRegistrationOfficeDBName()); ShortTermerTable = PmShortTermApplicationAccess.LoadAll(FieldList, ReadTransaction); long LastUnitKey = 0; long NewUnitKey = 0; bool IsUsedInOneConference = false; String ConfirmedOptionCode = ""; System.Type StringType = System.Type.GetType("System.String"); String SearchedColumnName = ""; switch (AFieldTypes) { case TUnitTypeEnum.utChargedFields: SearchedColumnName = PmShortTermApplicationTable.GetStFieldChargedDBName(); break; case TUnitTypeEnum.utRegisteringFields: SearchedColumnName = PmShortTermApplicationTable.GetRegistrationOfficeDBName(); break; default: break; } foreach (DataRow ShortTermerRow in ShortTermerTable.Select("", SearchedColumnName)) { if ((ShortTermerRow[SearchedColumnName] != null) && (ShortTermerRow[SearchedColumnName].ToString().Length > 0)) { NewUnitKey = (long)ShortTermerRow[SearchedColumnName]; } else { continue; } if (LastUnitKey != NewUnitKey) { if ((AFieldsTable.Rows.Count > 0) && (IsUsedInOneConference)) { AFieldsTable.Rows[AFieldsTable.Rows.Count - 1][USED_IN_CONFERENCE] = true; } IsUsedInOneConference = false; } // We have to check from every shorttermer if the charged field is used // in this conference if (IsUsedInOneConference) { continue; } if (ShortTermerRow[PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()].GetType() == StringType) { ConfirmedOptionCode = (string)ShortTermerRow[PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()]; } else { ConfirmedOptionCode = ""; } if (ConfirmedOptionCode.StartsWith(AConferencePrefix)) { IsUsedInOneConference = true; } if (LastUnitKey == NewUnitKey) { continue; } UnitTable = PUnitAccess.LoadByPrimaryKey(NewUnitKey, ReadTransaction); if (UnitTable.Rows.Count > 0) { DataRow ResultRow = AFieldsTable.NewRow(); ResultRow[SELECTION] = false; ResultRow[UNIT_KEY] = NewUnitKey; ResultRow[UNIT_NAME] = UnitTable[0][PUnitTable.GetUnitNameDBName()]; ResultRow[CAMPAIGN_CODE] = ConfirmedOptionCode; ResultRow[USED_IN_CONFERENCE] = IsUsedInOneConference; AFieldsTable.Rows.Add(ResultRow); LastUnitKey = NewUnitKey; } } // Check for the previous entry the "IsUsedInConference" field if ((AFieldsTable.Rows.Count > 0) && (IsUsedInOneConference)) { AFieldsTable.Rows[AFieldsTable.Rows.Count - 1][USED_IN_CONFERENCE] = true; } } finally { if (NewTransaction) { ReadTransaction.Commit(); TLogging.LogAtLevel(7, "TConferenceOptions.GetFieldUnits: committed own transaction."); } } return(true); }