public static PersonnelTDS LoadPersonellStaffData(Int64 APartnerKey) { PersonnelTDS MainDS = new PersonnelTDS(); TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted); PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction); PmCommitmentStatusAccess.LoadAll(MainDS, Transaction); PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction); DBAccess.GDBAccessObj.RollbackTransaction(); return(MainDS); }
public static PersonnelTDS LoadPersonellStaffData(Int64 APartnerKey) { PersonnelTDS MainDS = new PersonnelTDS(); TDBTransaction Transaction = null; DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, ref Transaction, delegate { PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction); PmCommitmentStatusAccess.LoadAll(MainDS, Transaction); PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction); }); return(MainDS); }
public static PersonnelTDS LoadPersonellStaffData(Int64 APartnerKey) { PersonnelTDS MainDS = new PersonnelTDS(); TDBTransaction Transaction = new TDBTransaction(); DBAccess.ReadTransaction(ref Transaction, delegate { PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction); PmCommitmentStatusAccess.LoadAll(MainDS, Transaction); PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction); }); return(MainDS); }
public static TSubmitChangesResult SavePersonnelTDS(ref PersonnelTDS AInspectDS, out TVerificationResultCollection AVerificationResult) { TSubmitChangesResult SubmissionResult = TSubmitChangesResult.scrError; bool AllDataValidationsOK = true; AVerificationResult = new TVerificationResultCollection(); // TODO: calculate debit and credit sums for journal and batch? if (AInspectDS.Tables.Contains(PmStaffDataTable.GetTableName())) { if (AInspectDS.PmStaffData.Rows.Count > 0) { ValidatePersonnelStaff(ref AVerificationResult, AInspectDS.PmStaffData); ValidatePersonnelStaffManual(ref AVerificationResult, AInspectDS.PmStaffData); if (!TVerificationHelper.IsNullOrOnlyNonCritical(AVerificationResult)) { AllDataValidationsOK = false; } } } if (AllDataValidationsOK) { PersonnelTDSAccess.SubmitChanges(AInspectDS); SubmissionResult = TSubmitChangesResult.scrOK; } else if (AVerificationResult.Count > 0) { // Downgrade TScreenVerificationResults to TVerificationResults in order to allow // Serialisation (needed for .NET Remoting). TVerificationResultCollection.DowngradeScreenVerificationResults(AVerificationResult); } return(SubmissionResult); }
public static TSubmitChangesResult SavePersonnelTDS(ref PersonnelTDS AInspectDS, out TVerificationResultCollection AVerificationResult) { TSubmitChangesResult SubmissionResult = TSubmitChangesResult.scrError; bool AllDataValidationsOK = true; AVerificationResult = new TVerificationResultCollection(); // TODO: calculate debit and credit sums for journal and batch? if (AInspectDS.Tables.Contains(PmStaffDataTable.GetTableName())) { if (AInspectDS.PmStaffData.Rows.Count > 0) { ValidatePersonnelStaff(ref AVerificationResult, AInspectDS.PmStaffData); ValidatePersonnelStaffManual(ref AVerificationResult, AInspectDS.PmStaffData); if (!TVerificationHelper.IsNullOrOnlyNonCritical(AVerificationResult)) { AllDataValidationsOK = false; } } } if (AllDataValidationsOK) { PersonnelTDSAccess.SubmitChanges(AInspectDS); SubmissionResult = TSubmitChangesResult.scrOK; } else if (AVerificationResult.Count > 0) { // Downgrade TScreenVerificationResults to TVerificationResults in order to allow // Serialisation (needed for .NET Remoting). TVerificationResultCollection.DowngradeScreenVerificationResults(AVerificationResult); } return SubmissionResult; }
/// <summary> /// generate the partners from a text file that was generated with Benerator /// </summary> /// <param name="AInputBeneratorFile"></param> public static void GenerateWorkers(string AInputBeneratorFile) { PartnerEditTDS MainDS = new PartnerEditTDS(); PersonnelTDS PersonnelDS = new PersonnelTDS(); // get a list of fields (all class UNIT, with unit type F) string sqlGetFieldPartnerKeys = "SELECT p_partner_key_n, p_unit_name_c FROM PUB_p_unit WHERE u_unit_type_code_c = 'F'"; DataTable FieldKeys = DBAccess.GDBAccessObj.SelectDT(sqlGetFieldPartnerKeys, "keys", null); // get a list of banks (all class BANK) string sqlGetBankPartnerKeys = "SELECT p_partner_key_n FROM PUB_p_bank"; DataTable BankKeys = DBAccess.GDBAccessObj.SelectDT(sqlGetBankPartnerKeys, "keys", null); XmlDocument doc = TCsv2Xml.ParseCSV2Xml(AInputBeneratorFile, ",", Encoding.UTF8); XmlNode RecordNode = doc.FirstChild.NextSibling.FirstChild; while (RecordNode != null) { string familySituation = TXMLParser.GetAttribute(RecordNode, "familySituation"); PFamilyRow familyRecord = null; if (familySituation == "singleMan") { familyRecord = GenerateFamilyRecord(RecordNode, "Male", MainDS); GeneratePersonRecord(RecordNode, familyRecord, "Male", MainDS); } else if (familySituation == "singleWoman") { familyRecord = GenerateFamilyRecord(RecordNode, "Female", MainDS); GeneratePersonRecord(RecordNode, familyRecord, "Female", MainDS); } else if (familySituation == "family") { familyRecord = GenerateFamilyRecord(RecordNode, "Male", MainDS); GeneratePersonRecord(RecordNode, familyRecord, "Male", MainDS); GeneratePersonRecord(RecordNode, familyRecord, "Female", MainDS); int AgeDifferenceSpouse = Convert.ToInt32(TXMLParser.GetAttribute(RecordNode, "AgeDifferenceSpouse")); DataView FamilyView = new DataView(MainDS.PPerson); FamilyView.RowFilter = PPersonTable.GetFamilyKeyDBName() + " = " + familyRecord.PartnerKey.ToString(); FamilyView.Sort = PPersonTable.GetFamilyIdDBName(); PPersonRow HusbandPersonRow = (PPersonRow)FamilyView[0].Row; PPersonRow WifePersonRow = (PPersonRow)FamilyView[1].Row; WifePersonRow.DateOfBirth = WifePersonRow.DateOfBirth.Value.AddYears( AgeDifferenceSpouse - (WifePersonRow.DateOfBirth.Value.Year - HusbandPersonRow.DateOfBirth.Value.Year)); if (DateTime.Today.Year - WifePersonRow.DateOfBirth.Value.Year < 19) { WifePersonRow.DateOfBirth.Value.AddYears( 19 - (DateTime.Today.Year - WifePersonRow.DateOfBirth.Value.Year)); } int NumberOfChildren = Convert.ToInt32(TXMLParser.GetAttribute(RecordNode, "numberOfChildren")); for (int countChild = 0; countChild < NumberOfChildren; countChild++) { DateTime DateOfBirthChild = Convert.ToDateTime( TXMLParser.GetAttribute(RecordNode, "Child" + (countChild + 1).ToString() + "DateOfBirth")); // mother must have been 19 when the child was born if (DateOfBirthChild.Year < WifePersonRow.DateOfBirth.Value.Year + 19) { continue; } GeneratePersonRecord(RecordNode, familyRecord, "Child" + (countChild + 1).ToString(), MainDS); } } GenerateAddressForFamily(RecordNode, familyRecord, MainDS); GenerateCommitmentRecord(RecordNode, familyRecord, MainDS, PersonnelDS, FieldKeys); GenerateBankDetails(RecordNode, familyRecord, MainDS, BankKeys); if (MainDS.PFamily.Rows.Count % 100 == 0) { TLogging.Log("created worker " + MainDS.PFamily.Rows.Count.ToString() + " " + familyRecord.FamilyName); } RecordNode = RecordNode.NextSibling; } MainDS.ThrowAwayAfterSubmitChanges = true; PartnerEditTDSAccess.SubmitChanges(MainDS); PersonnelDS.ThrowAwayAfterSubmitChanges = true; PersonnelTDSAccess.SubmitChanges(PersonnelDS); TLogging.Log("after saving workers"); }
private static void GenerateCommitmentRecord( XmlNode ACurrentNode, PFamilyRow AFamilyRow, PartnerEditTDS AMainDS, PersonnelTDS APersonnelDS, DataTable AFieldKeys) { DataView FamilyView = new DataView(AMainDS.PPerson); FamilyView.RowFilter = PPersonTable.GetFamilyKeyDBName() + " = " + AFamilyRow.PartnerKey.ToString(); FamilyView.Sort = PPersonTable.GetFamilyIdDBName(); PPersonRow firstPerson = (PPersonRow)FamilyView[0].Row; int FieldID = Convert.ToInt32(TXMLParser.GetAttribute(ACurrentNode, "fieldCommitment")) % AFieldKeys.Rows.Count; long FieldPartnerKey = Convert.ToInt64(AFieldKeys.Rows[FieldID].ItemArray[0]); PPartnerGiftDestinationRow giftDestination = AMainDS.PPartnerGiftDestination.NewRowTyped(); if (NextKeyForGiftDestination == -1) { NextKeyForGiftDestination = TPartnerDataReaderWebConnector.GetNewKeyForPartnerGiftDestination(); } else { NextKeyForGiftDestination++; } giftDestination.Key = NextKeyForGiftDestination; giftDestination.FieldKey = FieldPartnerKey; giftDestination.PartnerKey = AFamilyRow.PartnerKey; giftDestination.PartnerClass = MPartnerConstants.PARTNERCLASS_FAMILY; giftDestination.DateEffective = Convert.ToDateTime(TXMLParser.GetAttribute(ACurrentNode, "startDateCommitment")); PmStaffDataRow staffData = APersonnelDS.PmStaffData.NewRowTyped(); staffData.SiteKey = DomainManager.GSiteKey; staffData.Key = (APersonnelDS.PmStaffData.Count + 1) * -1; staffData.PartnerKey = firstPerson.PartnerKey; staffData.ReceivingField = FieldPartnerKey; // TODO: could add foreign nationals staffData.HomeOffice = DomainManager.GSiteKey; staffData.OfficeRecruitedBy = DomainManager.GSiteKey; staffData.StartOfCommitment = Convert.ToDateTime(TXMLParser.GetAttribute(ACurrentNode, "startDateCommitment")); int LengthCommitment = Convert.ToInt32(TXMLParser.GetAttribute(ACurrentNode, "lengthCommitment")); staffData.StatusCode = "LONG-TERMER"; if (LengthCommitment > 0) { string LengthCommitmentUnit = TXMLParser.GetAttribute(ACurrentNode, "lengthCommitmentUnit"); if (LengthCommitmentUnit == "week") { staffData.StatusCode = "SHORT-TERMER"; staffData.EndOfCommitment = staffData.StartOfCommitment.AddDays(7 * LengthCommitment); } else if (LengthCommitmentUnit == "month") { staffData.StatusCode = "SHORT-TERMER"; staffData.EndOfCommitment = staffData.StartOfCommitment.AddMonths(LengthCommitment); } else if (LengthCommitmentUnit == "year") { if (LengthCommitment < 3) { staffData.StatusCode = "WORKER"; } staffData.EndOfCommitment = staffData.StartOfCommitment.AddYears(LengthCommitment); } } APersonnelDS.PmStaffData.Rows.Add(staffData); giftDestination.DateExpires = staffData.EndOfCommitment; if (AMainDS.PPartnerGiftDestination == null) { AMainDS.PPartnerGiftDestination.Merge(new PPartnerGiftDestinationTable()); } AMainDS.PPartnerGiftDestination.Rows.Add(giftDestination); // TODO depending on start and end date of commitment, set EX-WORKER or no special type yet at all string SpecialType = MPartnerConstants.PARTNERTYPE_WORKER; if (!staffData.IsEndOfCommitmentNull() && (staffData.EndOfCommitment < DateTime.Today)) { SpecialType = MPartnerConstants.PARTNERTYPE_EX_WORKER; } if (SpecialType != string.Empty) { // create special type for family partner PPartnerTypeRow PartnerTypeRow = AMainDS.PPartnerType.NewRowTyped(); PartnerTypeRow.PartnerKey = AFamilyRow.PartnerKey; PartnerTypeRow.TypeCode = SpecialType; AMainDS.PPartnerType.Rows.Add(PartnerTypeRow); // set special type WORKER for the parents for (int countPerson = 0; countPerson < FamilyView.Count && countPerson < 2; countPerson++) { PPersonRow personRow = (PPersonRow)FamilyView[countPerson].Row; // create special type for the person partners PartnerTypeRow = AMainDS.PPartnerType.NewRowTyped(); PartnerTypeRow.PartnerKey = personRow.PartnerKey; PartnerTypeRow.TypeCode = SpecialType; AMainDS.PPartnerType.Rows.Add(PartnerTypeRow); } } }
/// <summary> /// generate the partners from a text file that was generated with Benerator /// </summary> /// <param name="AInputBeneratorFile"></param> public static void GenerateWorkers(string AInputBeneratorFile) { PartnerEditTDS MainDS = new PartnerEditTDS(); PersonnelTDS PersonnelDS = new PersonnelTDS(); // get a list of fields (all class UNIT, with unit type F) string sqlGetFieldPartnerKeys = "SELECT p_partner_key_n, p_unit_name_c FROM PUB_p_unit WHERE u_unit_type_code_c = 'F'"; DataTable FieldKeys = DBAccess.GDBAccessObj.SelectDT(sqlGetFieldPartnerKeys, "keys", null); // get a list of banks (all class BANK) string sqlGetBankPartnerKeys = "SELECT p_partner_key_n FROM PUB_p_bank"; DataTable BankKeys = DBAccess.GDBAccessObj.SelectDT(sqlGetBankPartnerKeys, "keys", null); // AlanP: May 2016 - We may no longer need the UTF8 because the method now automatically discovers the encoding even with no BOM XmlDocument doc = TCsv2Xml.ParseCSVFile2Xml(AInputBeneratorFile, ",", Encoding.UTF8); XmlNode RecordNode = doc.FirstChild.NextSibling.FirstChild; while (RecordNode != null) { string familySituation = TXMLParser.GetAttribute(RecordNode, "familySituation"); PFamilyRow familyRecord = null; if (familySituation == "singleMan") { familyRecord = GenerateFamilyRecord(RecordNode, "Male", MainDS); GeneratePersonRecord(RecordNode, familyRecord, "Male", MainDS); } else if (familySituation == "singleWoman") { familyRecord = GenerateFamilyRecord(RecordNode, "Female", MainDS); GeneratePersonRecord(RecordNode, familyRecord, "Female", MainDS); } else if (familySituation == "family") { familyRecord = GenerateFamilyRecord(RecordNode, "Male", MainDS); GeneratePersonRecord(RecordNode, familyRecord, "Male", MainDS); GeneratePersonRecord(RecordNode, familyRecord, "Female", MainDS); int AgeDifferenceSpouse = Convert.ToInt32(TXMLParser.GetAttribute(RecordNode, "AgeDifferenceSpouse")); DataView FamilyView = new DataView(MainDS.PPerson); FamilyView.RowFilter = PPersonTable.GetFamilyKeyDBName() + " = " + familyRecord.PartnerKey.ToString(); FamilyView.Sort = PPersonTable.GetFamilyIdDBName(); PPersonRow HusbandPersonRow = (PPersonRow)FamilyView[0].Row; PPersonRow WifePersonRow = (PPersonRow)FamilyView[1].Row; WifePersonRow.DateOfBirth = WifePersonRow.DateOfBirth.Value.AddYears( AgeDifferenceSpouse - (WifePersonRow.DateOfBirth.Value.Year - HusbandPersonRow.DateOfBirth.Value.Year)); if (DateTime.Today.Year - WifePersonRow.DateOfBirth.Value.Year < 19) { WifePersonRow.DateOfBirth.Value.AddYears( 19 - (DateTime.Today.Year - WifePersonRow.DateOfBirth.Value.Year)); } int NumberOfChildren = Convert.ToInt32(TXMLParser.GetAttribute(RecordNode, "numberOfChildren")); for (int countChild = 0; countChild < NumberOfChildren; countChild++) { DateTime DateOfBirthChild = Convert.ToDateTime( TXMLParser.GetAttribute(RecordNode, "Child" + (countChild + 1).ToString() + "DateOfBirth")); // mother must have been 19 when the child was born if (DateOfBirthChild.Year < WifePersonRow.DateOfBirth.Value.Year + 19) { continue; } GeneratePersonRecord(RecordNode, familyRecord, "Child" + (countChild + 1).ToString(), MainDS); } } GenerateAddressForFamily(RecordNode, familyRecord, MainDS); GenerateCommitmentRecord(RecordNode, familyRecord, MainDS, PersonnelDS, FieldKeys); GenerateBankDetails(RecordNode, familyRecord, MainDS, BankKeys); if (MainDS.PFamily.Rows.Count % 100 == 0) { TLogging.Log("created worker " + MainDS.PFamily.Rows.Count.ToString() + " " + familyRecord.FamilyName); } RecordNode = RecordNode.NextSibling; } MainDS.ThrowAwayAfterSubmitChanges = true; PartnerEditTDSAccess.SubmitChanges(MainDS); PersonnelDS.ThrowAwayAfterSubmitChanges = true; PersonnelTDSAccess.SubmitChanges(PersonnelDS); TLogging.Log("after saving workers"); }
public static PersonnelTDS LoadPersonellStaffData(Int64 APartnerKey) { PersonnelTDS MainDS = new PersonnelTDS(); TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted); PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction); PmCommitmentStatusAccess.LoadAll(MainDS, Transaction); PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction); DBAccess.GDBAccessObj.RollbackTransaction(); return MainDS; }
public static PersonnelTDS LoadPersonellStaffData(Int64 APartnerKey) { PersonnelTDS MainDS = new PersonnelTDS(); TDBTransaction Transaction = null; DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, ref Transaction, delegate { PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction); PmCommitmentStatusAccess.LoadAll(MainDS, Transaction); PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction); }); return MainDS; }