/// <summary> /// Create a ContractGenerationHistory. /// </summary> protected void CreateContractGenerationHistory(int nextGenerationID, int scheduleID, DateTime lastProcessDate, DateTime?lastGeneratedElementDate, string recordType) { var graphContractGenerationHistory = PXGraph.CreateInstance <ContractGenerationHistoryMaint>(); FSContractGenerationHistory fsContractGenerationHistoryRow = new FSContractGenerationHistory(); fsContractGenerationHistoryRow.GenerationID = nextGenerationID; fsContractGenerationHistoryRow.ScheduleID = scheduleID; fsContractGenerationHistoryRow.LastProcessedDate = lastProcessDate; fsContractGenerationHistoryRow.LastGeneratedElementDate = lastGeneratedElementDate; fsContractGenerationHistoryRow.EntityType = ID.Schedule_EntityType.CONTRACT; fsContractGenerationHistoryRow.RecordType = recordType; FSContractGenerationHistory fsContractGenerationHistoryRowPrevious = GetLastGenerationHistoryRowBySchedule(scheduleID); if (fsContractGenerationHistoryRowPrevious != null && fsContractGenerationHistoryRowPrevious.ContractGenerationHistoryID != null) { fsContractGenerationHistoryRow.PreviousGeneratedElementDate = fsContractGenerationHistoryRowPrevious.LastGeneratedElementDate; fsContractGenerationHistoryRow.PreviousProcessedDate = fsContractGenerationHistoryRowPrevious.LastProcessedDate; if (lastGeneratedElementDate == null) { fsContractGenerationHistoryRow.LastGeneratedElementDate = fsContractGenerationHistoryRow.PreviousGeneratedElementDate; } } graphContractGenerationHistory.ContractGenerationHistoryRecords.Insert(fsContractGenerationHistoryRow); graphContractGenerationHistory.Save.Press(); }
/// <summary> /// Create a ContractGenerationHistory. /// </summary> protected void createContractGenerationHistory(int nextProcessID, int scheduleID, DateTime lastProcessDate, DateTime?lastGeneratedTimeSlotDate, string recordType) { var graphContractGenerationHistory = PXGraph.CreateInstance <ContractGenerationHistoryMaint>(); FSContractGenerationHistory fsContractGenerationHistoryRow = new FSContractGenerationHistory() { GenerationID = nextProcessID, ScheduleID = scheduleID, LastProcessedDate = lastProcessDate, LastGeneratedElementDate = lastGeneratedTimeSlotDate, EntityType = ID.Schedule_EntityType.EMPLOYEE, RecordType = recordType }; FSContractGenerationHistory fsContractGenerationHistoryRow_Previous = getLastGenerationHistoryRowBySchedule(scheduleID); if (fsContractGenerationHistoryRow_Previous != null && fsContractGenerationHistoryRow_Previous.ContractGenerationHistoryID != null) { if (fsContractGenerationHistoryRow_Previous != null) { fsContractGenerationHistoryRow.PreviousGeneratedElementDate = fsContractGenerationHistoryRow_Previous.LastGeneratedElementDate; fsContractGenerationHistoryRow.PreviousProcessedDate = fsContractGenerationHistoryRow_Previous.LastProcessedDate; if (lastGeneratedTimeSlotDate == null) { fsContractGenerationHistoryRow.LastGeneratedElementDate = fsContractGenerationHistoryRow.PreviousGeneratedElementDate; } } } graphContractGenerationHistory.ContractGenerationHistoryRecords.Insert(fsContractGenerationHistoryRow); graphContractGenerationHistory.Save.Press(); }
/// <summary> /// Return the last FSContractGenerationHistory by Schedule. /// </summary> public FSContractGenerationHistory GetLastGenerationHistoryRowBySchedule(int scheduleID) { FSContractGenerationHistory fsContractGenerationHistoryRow = PXSelectGroupBy <FSContractGenerationHistory, Where < FSContractGenerationHistory.scheduleID, Equal <Required <FSContractGenerationHistory.scheduleID> > >, Aggregate < Max <FSContractGenerationHistory.generationID> > > .Select(this, scheduleID); if (fsContractGenerationHistoryRow != null && fsContractGenerationHistoryRow.GenerationID != null) { return(fsContractGenerationHistoryRow); } else { return(null); } }
/// <summary> /// Return the last FSContractGenerationHistory. /// </summary> protected FSContractGenerationHistory getLastGenerationHistoryRow(string recordType) { FSContractGenerationHistory fsContractGenerationHistoryRow = PXSelectGroupBy <FSContractGenerationHistory, Where < FSContractGenerationHistory.recordType, Equal <Required <FSContractGenerationHistory.recordType> > >, Aggregate < Max <FSContractGenerationHistory.generationID> > > .Select(this, recordType); if (fsContractGenerationHistoryRow != null && fsContractGenerationHistoryRow.GenerationID != null) { return(fsContractGenerationHistoryRow); } else { return(null); } }