}//afterPopulateProps() public override CswNbtNode CopyNode( bool IsNodeTemp = false, Action<CswNbtNode> OnCopy = null ) { CswNbtNode CopiedNode = _CswNbtResources.Nodes.makeNodeFromNodeTypeId( NodeTypeId, IsTemp : IsNodeTemp, OnAfterMakeNode : delegate( CswNbtNode NewNode ) { //copy each property from the old node NewNode.copyPropertyValues( Node ); //get the landing page items from the original role's welcome page and loop through them, copying each to new page //NOTE: if we ever implement non-welcome page role specific LPIs, this will need to be updated CswNbtLandingPage LandingPageBuilder = new CswNbtLandingPage( _CswNbtResources ); LandingPageData NewNodeLandingPageData = LandingPageBuilder.getWelcomePageItems( this.NodeId ); foreach(LandingPageData.LandingPageItem Item in NewNodeLandingPageData.LandingPageItems) { LandingPageBuilder.copyLandingPageItem( NewNode.NodeId.ToString(), Item ); } //copy the views to the new role _CswNbtResources.ViewSelect.copyViewsByRoleId( NodeId, NewNode.NodeId ); //if the thing that requested this copy had a callback, fire it if( null != OnCopy ) { OnCopy( NewNode ); } }, IsCopy : true ); return CopiedNode; }
protected CswNbtNode CopyNodeImpl(bool IsNodeTemp = false, Action <CswNbtNode> OnCopy = null) { CswNbtNode CopiedNode = _CswNbtResources.Nodes.makeNodeFromNodeTypeId(NodeTypeId, IsTemp : IsNodeTemp, OnAfterMakeNode : delegate(CswNbtNode NewNode) { NewNode.copyPropertyValues(Node); if (null != OnCopy) { OnCopy(NewNode); } }, IsCopy: true); return(CopiedNode); }
public override CswNbtNode CopyNode(bool IsNodeTemp = false, Action <CswNbtNode> OnCopy = null) { CswNbtObjClassInspectionDesign CopiedIDNode = base.CopyNodeImpl(IsNodeTemp, delegate(CswNbtNode NewNode) { NewNode.copyPropertyValues(Node); ((CswNbtObjClassInspectionDesign)NewNode).Generator.RelatedNodeId = null; ((CswNbtObjClassInspectionDesign)NewNode).Generator.RefreshNodeName(); if (null != OnCopy) { OnCopy(NewNode); } }); return(CopiedIDNode.Node); }
/// <summary> /// Copy the Request Item /// </summary> public CswNbtPropertySetRequestItem copyNode(bool ClearRequest = true) { CswNbtPropertySetRequestItem RetCopy = _CswNbtResources.Nodes.makeNodeFromNodeTypeId(NodeTypeId, delegate(CswNbtNode NewNode) { NewNode.copyPropertyValues(Node); ((CswNbtPropertySetRequestItem)NewNode).Status.Value = Statuses.Pending; if (ClearRequest) { ((CswNbtPropertySetRequestItem)NewNode).Request.RelatedNodeId = null; } _toggleReadOnlyProps(false, NewNode); //if( PostChanges ) //{ // RetCopy.postChanges( true ); //} }); return(RetCopy); }
/// <summary> /// Record a container dispense transaction /// </summary> /// <param name="DispenseType"></param> /// <param name="Quantity">Quantity adjustment (negative for dispenses, disposes, and wastes, positive for receiving and add)</param> /// <param name="UnitId"></param> /// <param name="RequestItemId"></param> /// <param name="SourceContainer"></param> /// <param name="DestinationContainer"></param> public void create(CswEnumNbtContainerDispenseType DispenseType, double Amount, CswPrimaryKey UnitId, CswPrimaryKey RequestItemId = null, CswNbtObjClassContainer SrcContainer = null, CswNbtObjClassContainer DestinationContainer = null, bool IsImport = false) { CswNbtMetaDataObjectClass ContDispTransOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ContainerDispenseTransactionClass); CswNbtMetaDataNodeType ContDispTransNT = ContDispTransOC.FirstNodeType; if (ContDispTransNT != null) { _CswNbtResources.Nodes.makeNodeFromNodeTypeId(ContDispTransNT.NodeTypeId, delegate(CswNbtNode NewNode) { if (null != _TempDispenseTransaction) { NewNode.copyPropertyValues(_TempDispenseTransaction.Node); } CswNbtObjClassContainerDispenseTransaction ContDispTransNode = NewNode; if (SrcContainer != null) { ContDispTransNode.SourceContainer.RelatedNodeId = SrcContainer.NodeId; ContDispTransNode.RemainingSourceContainerQuantity.Quantity = SrcContainer.Quantity.Quantity; if (DispenseType == CswEnumNbtContainerDispenseType.Dispose) { ContDispTransNode.RemainingSourceContainerQuantity.Quantity = 0; } ContDispTransNode.RemainingSourceContainerQuantity.UnitId = SrcContainer.Quantity.UnitId; } if (DestinationContainer != null) { ContDispTransNode.DestinationContainer.RelatedNodeId = DestinationContainer.NodeId; } ContDispTransNode.Dispenser.RelatedNodeId = _CswNbtResources.CurrentNbtUser.UserId; ContDispTransNode.QuantityDispensed.Quantity = Amount; ContDispTransNode.QuantityDispensed.UnitId = UnitId; ContDispTransNode.Type.Value = DispenseType.ToString(); ContDispTransNode.DispensedDate.DateTimeValue = DateTime.Now; if (null != RequestItemId && Int32.MinValue != RequestItemId.PrimaryKey) { ContDispTransNode.RequestItem.RelatedNodeId = RequestItemId; } }, OverrideUniqueValidation: IsImport, OverrideMailReportEvents: IsImport); } // if( ContDispTransNT != null ) }
public override CswNbtNode CopyNode(bool IsNodeTemp = false, Action <CswNbtNode> OnCopy = null) { CswNbtNode CopiedFireClassExemptAmountSetNode = base.CopyNodeImpl(IsNodeTemp, OnCopy); // Copy all Related FireClassExemptAmount Nodes CswNbtMetaDataObjectClass FireClassExemptAmountObjectClass = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.FireClassExemptAmountClass); CswNbtView FCEAView = new CswNbtView(_CswNbtResources); CswNbtViewRelationship FCEARelationship = FCEAView.AddViewRelationship(FireClassExemptAmountObjectClass, false); CswNbtViewProperty SetNameProperty = FCEAView.AddViewProperty(FCEARelationship, FireClassExemptAmountObjectClass.getObjectClassProp(CswNbtObjClassFireClassExemptAmount.PropertyName.SetName)); FCEAView.AddViewPropertyFilter( SetNameProperty, CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID, CswEnumNbtFilterMode.Equals, NodeId.PrimaryKey.ToString()); ICswNbtTree FCEATree = _CswNbtResources.Trees.getTreeFromView(_CswNbtResources.CurrentNbtUser, FCEAView, true, false, false); FCEATree.goToRoot(); Int32 ChildrenCopied = 0; while (ChildrenCopied < FCEATree.getChildNodeCount()) { FCEATree.goToNthChild(ChildrenCopied); CswNbtObjClassFireClassExemptAmount OriginalFCEANode = FCEATree.getNodeForCurrentPosition(); _CswNbtResources.Nodes.makeNodeFromNodeTypeId(OriginalFCEANode.NodeTypeId, delegate(CswNbtNode NewNode) { NewNode.copyPropertyValues(OriginalFCEANode.Node); ((CswNbtObjClassFireClassExemptAmount)NewNode).SetName.RelatedNodeId = CopiedFireClassExemptAmountSetNode.NodeId; }); FCEATree.goToParentNode(); ChildrenCopied++; } return(CopiedFireClassExemptAmountSetNode); }
/// <summary> /// Generates a future IGeneratorTarget node. If an existing node has the same due date, no node is generated. /// </summary> /// <returns>True if a future node was generated</returns> public bool makeNode(CswNbtNode CswNbtNodeGenerator, DateTime DueDate) { Int32 NodesCreated = 0; CswNbtObjClassGenerator GeneratorNodeAsGenerator = (CswNbtObjClassGenerator)CswNbtNodeGenerator; string SelectedNodeTypeIdStr = string.Empty; Int32 SelectedNodeTypeId = Int32.MinValue; if (0 < GeneratorNodeAsGenerator.TargetType.SelectedNodeTypeIds.Count) { SelectedNodeTypeIdStr = GeneratorNodeAsGenerator.TargetType.SelectedNodeTypeIds[0]; SelectedNodeTypeId = CswConvert.ToInt32(SelectedNodeTypeIdStr); } if (string.IsNullOrEmpty(SelectedNodeTypeIdStr) || "0" == SelectedNodeTypeIdStr || Int32.MinValue == SelectedNodeTypeId || null == _CswNbtResources.MetaData.getNodeType(SelectedNodeTypeId)) { throw (new CswDniException("Generator node " + CswNbtNodeGenerator.NodeName + " (" + CswNbtNodeGenerator.NodeId.ToString() + ") does not have a valid nodetypeid")); } if (DueDate == DateTime.MinValue) { DueDate = GeneratorNodeAsGenerator.NextDueDate.DateTimeValue.Date; } if (DueDate == DateTime.MinValue) { DueDate = GeneratorNodeAsGenerator.DueDateInterval.getStartDate().Date; } string DateFilter = DueDate.ToShortDateString(); bool GeneratorBaseIsProperlyConfigured = (null != GeneratorNodeAsGenerator.Owner && null != GeneratorNodeAsGenerator.Owner.RelatedNodeId && null != _CswNbtResources.Nodes.GetNode(GeneratorNodeAsGenerator.Owner.RelatedNodeId) && GeneratorNodeAsGenerator.TargetType.SelectedNodeTypeIds.Count > 0); if (false == GeneratorBaseIsProperlyConfigured) { throw new CswDniException(CswEnumErrorType.Error, "Cannot execute generator task if the generator does not have an owner and a target type.", "Generator node did not define both an Owner and a Target Type."); } // case 26111 - only generate a few at a time, and only increment NextDueDate when we're completely done Int32 GeneratorTargetLimit = CswConvert.ToInt32(_CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumNbtConfigurationVariables.generatortargetlimit.ToString())); if (Int32.MinValue == GeneratorTargetLimit) { GeneratorTargetLimit = 5; } foreach (CswPrimaryKey NewParentPk in GeneratorNodeAsGenerator.TargetParents) { if (null != NewParentPk && NodesCreated < GeneratorTargetLimit) { CswNbtPropertySetGeneratorTarget ExistingNode = null; if (GeneratorNodeAsGenerator.DueDateInterval.RateInterval.RateType != CswEnumRateIntervalType.Hourly) { ExistingNode = _getTargetNodeForGenerator(CswNbtNodeGenerator, NewParentPk, DateFilter); } if (null == ExistingNode) { Collection <Int32> SelectedNodeTypeIds = GeneratorNodeAsGenerator.TargetType.SelectedNodeTypeIds.ToIntCollection(); foreach (Int32 refNodeTypeId in SelectedNodeTypeIds) { CswNbtMetaDataNodeType LatestVersionNT = _CswNbtResources.MetaData.getNodeType(refNodeTypeId).getNodeTypeLatestVersion(); //CswNbtPropertySetGeneratorTarget NewNode = _CswNbtResources.Nodes.makeNodeFromNodeTypeId( LatestVersionNT.NodeTypeId, CswEnumNbtMakeNodeOperation.DoNothing ); //NewNode.Node.copyPropertyValues( CswNbtNodeGenerator ); _CswNbtResources.Nodes.makeNodeFromNodeTypeId(LatestVersionNT.NodeTypeId, delegate(CswNbtNode NewNode) { NewNode.copyPropertyValues(CswNbtNodeGenerator); CswNbtPropertySetGeneratorTarget NewTarget = NewNode; NewTarget.DueDate.DateTimeValue = DueDate; NewTarget.DueDate.setReadOnly(value: true, SaveToDb: true); //bz # 5349 NewTarget.Generator.RelatedNodeId = CswNbtNodeGenerator.NodeId; NewTarget.Generator.CachedNodeName = CswNbtNodeGenerator.NodeName; NewTarget.Parent.RelatedNodeId = NewParentPk; //NewTaskNodeAsTask.Completed.Checked = Tristate.False; if (MarkFuture) { NewTarget.IsFuture.Checked = CswEnumTristate.True; } else { NewTarget.IsFuture.Checked = CswEnumTristate.False; } if (null != onBeforeInsertNode) { onBeforeInsertNode(NewNode); } NodesCreated += 1; NewNode.PendingUpdate = true; //NewNode.postChanges( true ); }); } // foreach( Int32 refNodeTypeId in SelectedNodeTypeIds ) } //if ( null == ExistingNode ) else { if (false == MarkFuture) { if (ExistingNode.IsFuture.Checked == CswEnumTristate.True) { ExistingNode.IsFuture.Checked = CswEnumTristate.False; } } else { if (DateTime.Now.Date >= ExistingNode.DueDate.DateTimeValue.Date) { ExistingNode.IsFuture.Checked = CswEnumTristate.False; } } ExistingNode.postChanges(false); //BZ # 6961 } //if-else ( null == ExistingNode ) } // if( null != NewParentPk ) } // foreach( CswPrimaryKey NewParentPk in Parents ) // case 26111 - we're finished if we ran out of nodes to generate return(NodesCreated < GeneratorTargetLimit); } //makeNode()