} // update() private void _fixBadScheudlesAndTasks() { ICswNbtTree BadSchedulesTree = _CswNbtSchemaModTrnsctn.getTreeFromView( _getBadSchedulesAndTasksView(), false ); BadSchedulesTree.goToRoot(); for( int i = 0; i < BadSchedulesTree.getChildNodeCount(); i++ ) { BadSchedulesTree.goToNthChild( i ); CswNbtObjClassGenerator ScheduleNode = BadSchedulesTree.getNodeForCurrentPosition(); int TargetTypeId = ScheduleNode.NodeTypeId == AssemblyScheduleNT.NodeTypeId ? AssemblyTaskNT.NodeTypeId : EquipmentTaskNT.NodeTypeId; ScheduleNode.TargetType.SelectedNodeTypeIds.Clear(); ScheduleNode.TargetType.SelectedNodeTypeIds.Add( CswConvert.ToString( TargetTypeId ) ); ScheduleNode.postChanges( false ); for( int j = 0; j < BadSchedulesTree.getChildNodeCount(); j++ ) { BadSchedulesTree.goToNthChild( j ); CswNbtNode OldTaskNode = BadSchedulesTree.getNodeForCurrentPosition(); CswNbtObjClassTask NewTaskNode = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( TargetTypeId, CswEnumNbtMakeNodeOperation.WriteNode ); NewTaskNode.Node.copyPropertyValues( OldTaskNode ); NewTaskNode.Owner.RelatedNodeId = ScheduleNode.Owner.RelatedNodeId; OldTaskNode.delete(); NewTaskNode.postChanges( false ); BadSchedulesTree.goToParentNode(); } BadSchedulesTree.goToParentNode(); } }
public void updateNextDueDateTest_ExplicitSet() { CswNbtObjClassGenerator GeneratorNode = TestData.Nodes.createGeneratorNode(CswEnumRateIntervalType.WeeklyByDay); GeneratorNode.NextDueDate.DateTimeValue = DateTime.Today; GeneratorNode.postChanges(true); Assert.AreEqual(DateTime.Today, GeneratorNode.NextDueDate.DateTimeValue); }
public void updateNextDueDateTest_ForceUpdateRevert() { CswNbtObjClassGenerator GeneratorNode = TestData.Nodes.createGeneratorNode(CswEnumRateIntervalType.MonthlyByDate); CswNbtObjClassGenerator ExistingGen = TestData.CswNbtResources.Nodes[GeneratorNode.NodeId]; ExistingGen.updateNextDueDate(ForceUpdate: true, DeleteFutureNodes: false); ExistingGen.postChanges(true); Assert.AreEqual(getNextDate(15).AddMonths(1), ExistingGen.NextDueDate.DateTimeValue); DateTime LastDueDate = ExistingGen.DueDateInterval.getLastOccuranceBefore(ExistingGen.NextDueDate.DateTimeValue); if (LastDueDate > DateTime.Today) { ExistingGen.NextDueDate.DateTimeValue = DateTime.Now; ExistingGen.updateNextDueDate(ForceUpdate: true, DeleteFutureNodes: false); ExistingGen.postChanges(true); } Assert.AreEqual(getNextDate(15), ExistingGen.NextDueDate.DateTimeValue); }
public void updateNextDueDateTest_FinalDueDateBeforeNextDueDate() { DayOfWeek FiveDaysFromNow = DateTime.Today.AddDays(5).DayOfWeek; CswNbtObjClassGenerator GeneratorNode = TestData.Nodes.createGeneratorNode(CswEnumRateIntervalType.WeeklyByDay, Days: new SortedList { { FiveDaysFromNow, FiveDaysFromNow } }, WarningDays: 1); CswNbtObjClassGenerator ExistingGen = TestData.CswNbtResources.Nodes[GeneratorNode.NodeId]; ExistingGen.FinalDueDate.DateTimeValue = DateTime.Today; ExistingGen.postChanges(false); Assert.AreEqual(DateTime.MinValue, ExistingGen.NextDueDate.DateTimeValue); }
private void _processGenerator(CswNbtResources CswNbtResources, CswNbtObjClassGenerator CurrentGenerator) { try { // case 28069 // It should not be possible to make more than 24 nodes per parent in a single day, // since the fastest interval is 1 hour, and we're not creating things into the past anymore. // Therefore, disable anything that is erroneously spewing things. if (CurrentGenerator.GeneratedNodeCount(DateTime.Today) >= (24 * CurrentGenerator.TargetParents.Count)) { string Message = "Disabled due to error: Generated too many " + CurrentGenerator.TargetType.SelectedNodeTypeNames() + " targets in a single day"; _StatusMessage += Message + "; "; CurrentGenerator.Enabled.Checked = CswEnumTristate.False; CurrentGenerator.RunStatus.AddComment(Message); CurrentGenerator.postChanges(false); } else { CswNbtActGenerateNodes CswNbtActGenerateNodes = new CswNbtActGenerateNodes(CswNbtResources); bool Finished = CswNbtActGenerateNodes.makeNode(CurrentGenerator.Node); if (Finished) // case 26111 { string Message = "Created all " + CurrentGenerator.TargetType.SelectedNodeTypeNames() + " target(s) for " + CurrentGenerator.NextDueDate.DateTimeValue.Date.ToShortDateString(); CurrentGenerator.RunStatus.AddComment(Message); CurrentGenerator.updateNextDueDate(ForceUpdate: true, DeleteFutureNodes: false); CurrentGenerator.postChanges(false); } _StatusMessage += CurrentGenerator.Description.Text + "; "; } // if-else( CurrentGenerator.GeneratedNodeCount( DateTime.Today ) >= 24 ) } //try catch (Exception Exception) { string Message = "Unable to process generator " + CurrentGenerator.Description.Text + ", which will now be disabled, due to the following exception: " + Exception.Message; _StatusMessage += Message + "; "; CurrentGenerator.Enabled.Checked = CswEnumTristate.False; CurrentGenerator.RunStatus.AddComment("Disabled due to exception: " + Exception.Message); CurrentGenerator.postChanges(false); CswNbtResources.logError(new CswDniException(Message)); } }
public void updateNextDueDateTest_NextDueDateStillInPast() { DayOfWeek ThreeDaysFromNow = DateTime.Today.AddDays(3).DayOfWeek; CswNbtObjClassGenerator GeneratorNode = TestData.Nodes.createGeneratorNode(CswEnumRateIntervalType.WeeklyByDay, Days: new SortedList { { ThreeDaysFromNow, ThreeDaysFromNow } }, StartDate: DateTime.Today.AddDays(3 - 21), WarningDays: 5); GeneratorNode.postChanges(true); CswNbtObjClassGenerator ExistingGen = TestData.CswNbtResources.Nodes[GeneratorNode.NodeId]; ExistingGen.NextDueDate.DateTimeValue = DateTime.Today.AddDays(3 - 14); Assert.AreEqual(DateTime.Today.AddDays(3 - 14), ExistingGen.NextDueDate.DateTimeValue); ExistingGen.updateNextDueDate(ForceUpdate: true, DeleteFutureNodes: false); Assert.AreEqual(DateTime.Today.AddDays(3 - 7), ExistingGen.NextDueDate.DateTimeValue); }