// usage examples. private static void Main(string[] args) { var donkeyInstance = new Donkey(); var lizardInstance = new Lizard(); var snakeInstance = new Snake(); var tableInstance = new Table(); var deskInstance = new Desk(); var conferenceTalbeInstance = new ConferenceTable(); var listOfThingsWithLegs = new ListOfIhasLegs { donkeyInstance, lizardInstance, tableInstance, deskInstance, conferenceTalbeInstance }; var listOfAnimals = new ListOfAnimals { donkeyInstance, lizardInstance, snakeInstance }; var cageOfAnimalsWithLegs = new ListOfAnimalsWithLegs { donkeyInstance, lizardInstance, }; }
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 void CreateNewConference(long APartnerKey) { TDBTransaction Transaction = new TDBTransaction(); TDataBase db = DBAccess.Connect("CreateNewConference"); bool SubmissionOK = false; PcConferenceTable ConferenceTable; PUnitTable UnitTable; PPartnerLocationTable PartnerLocationTable; db.WriteTransaction(ref Transaction, ref SubmissionOK, delegate { 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); SubmissionOK = true; } catch (Exception Exc) { TLogging.Log("An Exception occured during the creation of a new Conference:" + Environment.NewLine + Exc.ToString()); } }); }