private void onQuantityPropChange(CswNbtNodeProp Prop)
 {
     if (CswTools.IsPrimaryKey(Quantity.UnitId) && TotalDispensed.UnitId != Quantity.UnitId)
     {
         TotalDispensed.UnitId = Quantity.UnitId;
     }
 }
Beispiel #2
0
        public void OnCurrentWorkUnitPropertyChange(CswNbtNodeProp Prop, bool Creating)
        {
            CswPrimaryKey UsersCurrentWorkUnitId = CurrentWorkUnitId;

            //Case 30817
            //if( null != UsersWorkUnitId )
            if (false == CswTools.IsPrimaryKey(UsersCurrentWorkUnitId))
            {
                UsersCurrentWorkUnitId = GetFirstAvailableWorkUnitNodeId();
            }

            if (false == AvailableWorkUnits.CheckValue(UsersCurrentWorkUnitId.ToString()))
            {
                if (false == _CswNbtResources.CurrentNbtUser is CswNbtSystemUser &&
                    _CswNbtResources.CurrentNbtUser.Username != ChemSWAdminUsername)
                {
                    throw new CswDniException(CswEnumErrorType.Warning,
                                              CurrentWorkUnitProperty.CachedNodeName +
                                              " is not an available Work Unit for user " + Username,
                                              _CswNbtResources.CurrentNbtUser.Username + " attempted to assign User: "******" to Work Unit: " + UsersCurrentWorkUnitId +
                                              " when Users available Work Units are: " + AvailableWorkUnits.Value);
                }
                // We add the work unit to the list and then check it!
                AvailableWorkUnits.AddValue(UsersCurrentWorkUnitId.ToString());
                CurrentWorkUnitProperty.RelatedNodeId = UsersCurrentWorkUnitId;
                CurrentWorkUnitProperty.SyncGestalt();

                _updateAvailableWorkUnits();
            }
        }
        /// <summary>
        /// Finalize the new Material
        /// </summary>
        public JObject commitMaterial(string MaterialDefinition)
        {
            JObject RetObj = new JObject();

            JObject MaterialObj = CswConvert.ToJObject(MaterialDefinition);

            if (MaterialObj.HasValues)
            {
                JArray        SizesArray = CswConvert.ToJArray(MaterialObj["sizeNodes"]);
                CswPrimaryKey MaterialId = new CswPrimaryKey();
                MaterialId.FromString(CswConvert.ToString(MaterialObj["materialId"]));
                if (CswTools.IsPrimaryKey(MaterialId))
                {
                    CswNbtNode MaterialNode = _CswNbtResources.Nodes[MaterialId];
                    if (null != MaterialNode)
                    {
                        /* 1. Validate the new material and get its properties */
                        MaterialNode = _commitMaterialNode(MaterialObj);
                        RetObj["createdmaterial"] = true;

                        /* 2. Add the sizes */
                        if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.Containers))
                        {
                            SizesArray = _removeDuplicateSizes(SizesArray);
                            _addMaterialSizes(SizesArray, MaterialNode);
                            RetObj["sizescount"] = SizesArray.Count;
                        }

                        /* 3. Add landingpage data */
                        RetObj["landingpagedata"] = _getLandingPageData(MaterialNode);
                    }
                }
            }
            return(RetObj);
        }
        //mark any property references to this property on other nodes as pending update
        private void _markExternalPropRefsDirty(CswNbtNodePropWrapper CurrentProp)
        {
            if (CswTools.IsPrimaryKey(CurrentProp.NodeId))
            {
                CswNbtFieldTypeRulePropertyReference PropRefFTR = (CswNbtFieldTypeRulePropertyReference)_CswNbtResources.MetaData.getFieldTypeRule(CswEnumNbtFieldType.PropertyReference);
                CswEnumNbtPropColumn PropRefColumn = PropRefFTR.CachedValueSubField.Column;

                string SQL = @"update jct_nodes_props 
                            set pendingupdate = '" + CswConvert.ToDbVal(true) + @"',
                                " + PropRefColumn.ToString() + @" = ''
                        where jctnodepropid in (select j.jctnodepropid
                                                    from jct_nodes_props j
                                                    join nodes n on n.nodeid = j.nodeid
                                                    join nodetype_props p on p.nodetypepropid = j.nodetypepropid
                                                    join field_types f on p.fieldtypeid = f.fieldtypeid
                                                    left outer join jct_nodes_props jntp on (jntp.nodetypepropid = p.fkvalue
                                                                                        and jntp.nodeid = n.nodeid
                                                                                        and jntp.field1_fk = " + CurrentProp.NodeId.PrimaryKey.ToString() + @")
                                                    left outer join (select jx.jctnodepropid, ox.objectclasspropid, jx.nodeid
                                                                        from jct_nodes_props jx
                                                                        join nodetype_props px on jx.nodetypepropid = px.nodetypepropid
                                                                        join object_class_props ox on px.objectclasspropid = ox.objectclasspropid
                                                                    where jx.field1_fk = " + CurrentProp.NodeId.PrimaryKey.ToString() + @") jocp 
                                                                                        on (jocp.objectclasspropid = p.fkvalue 
                                                                                        and jocp.nodeid = n.nodeid)
                                                    where f.fieldtype = 'PropertyReference'
                                                    and ((lower(p.fktype) = 'nodetypepropid' and jntp.jctnodepropid is not null)
                                                        or (lower(p.fktype) = 'objectclasspropid' and jocp.jctnodepropid is not null))
                                                    and ((lower(p.valueproptype) = 'nodetypepropid' and p.valuepropid = " + CurrentProp.NodeTypePropId.ToString() + @") 
                                                        or (lower(p.valueproptype) = 'objectclasspropid' and p.valuepropid = " + CurrentProp.ObjectClassPropId + @")))";
                // We're not doing this in a CswTableUpdate because it might be a large operation,
                // and we don't care about auditing for this change.
                _CswNbtResources.execArbitraryPlatformNeutralSql(SQL);
            }
        }
Beispiel #5
0
        private void _updateAvailableWorkUnits()
        {
            //Case 30817 (Case 30843: moved to here from onBeforeCreate)
            if (CswTools.IsPrimaryKey(CurrentWorkUnitId) &&
                false == AvailableWorkUnits.CheckValue(CurrentWorkUnitId.ToString()))
            {
                AvailableWorkUnits.AddValue(CurrentWorkUnitId.ToString());
                CurrentWorkUnitProperty.RelatedNodeId = CurrentWorkUnitId;
                CurrentWorkUnitProperty.SyncGestalt();
            }

            CswNbtView View = _CswNbtResources.ViewSelect.restoreView(CurrentWorkUnitProperty.NodeTypeProp.ViewId);

            View.Clear();
            View.SetVisibility(CswEnumNbtViewVisibility.Property, null, null);

            CswNbtMetaDataObjectClass WorkUnitOC     = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.WorkUnitClass);
            CswNbtViewRelationship    WorkUnitParent = View.AddViewRelationship(WorkUnitOC, false);

            foreach (string WorkUnitNodeId in AvailableWorkUnits.Value)
            {
                CswPrimaryKey pk = CswConvert.ToPrimaryKey(WorkUnitNodeId);
                WorkUnitParent.NodeIdsToFilterIn.Add(pk);
            }

            CurrentWorkUnitProperty.OverrideView(View);
        }
Beispiel #6
0
        } // set( CswNbtActionName ActionName, ICswNbtUser User, bool value )

        #endregion Actions

        #region Specialty

        /// <summary>
        /// Determines if the user has permission to View or Edit a node belonging to the Permission Group defined by the given GroupId
        /// </summary>
        /// <param name="Permission">Permission Type (either View or Edit)</param>
        /// <param name="PermissionGroupId">The nodeid of the PermissionGroup with which to check permissions</param>
        /// <param name="User">User for which to check permissions</param>
        public bool canNode(CswEnumNbtNodeTypePermission Permission, CswPrimaryKey PermissionGroupId, ICswNbtUser User = null, CswNbtMetaDataNodeType NodeType = null)
        {
            bool hasPermission = true;

            if (null == User)
            {
                User = _CswNbtResources.CurrentNbtUser;
            }
            if (false == (User is CswNbtSystemUser || User.Username == CswNbtObjClassUser.ChemSWAdminUsername))
            {
                if (null != User && CswTools.IsPrimaryKey(PermissionGroupId))
                {
                    CswNbtPropertySetPermission PermNode = User.getPermissionForGroup(PermissionGroupId);
                    if (null != PermNode)
                    {
                        //Case 30480: Only use InventoryGroupPermission if checking against Containers
                        if (null == NodeType ||
                            PermNode.ObjectClass.ObjectClass != CswEnumNbtObjectClass.InventoryGroupPermissionClass ||
                            NodeType.getObjectClass().ObjectClass == CswEnumNbtObjectClass.ContainerClass)
                        {
                            hasPermission = ((Permission == CswEnumNbtNodeTypePermission.View && PermNode.View.Checked == CswEnumTristate.True) ||
                                             PermNode.Edit.Checked == CswEnumTristate.True);   //edit implies edit, create, and delete
                        }
                    }
                    else if (null != _CswNbtResources.Nodes[PermissionGroupId])
                    {
                        // case 30477 - Only revoke permissions if the group's nodetype is enabled and the node is valid
                        hasPermission = false;
                    }
                }
            }
            return(hasPermission);
        }
        public static void getUserDefaults(ICswResources CswResources, CswNbtAuthReturn Ret, object Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            if (CswTools.IsPrimaryKey(NbtResources.CurrentNbtUser.DefaultLocationId))
            {
                Ret.Data.DefaultLocationId = NbtResources.CurrentNbtUser.DefaultLocationId.ToString();
            }
            if (CswTools.IsPrimaryKey(NbtResources.CurrentNbtUser.DefaultPrinterId))
            {
                Ret.Data.DefaultPrinterId = NbtResources.CurrentNbtUser.DefaultPrinterId.ToString();
            }
            if (CswTools.IsPrimaryKey(NbtResources.CurrentNbtUser.DefaultBalanceId))
            {
                Ret.Data.DefaultBalanceId = NbtResources.CurrentNbtUser.DefaultBalanceId.ToString();
            }
            if (CswTools.IsPrimaryKey(NbtResources.CurrentNbtUser.JurisdictionId))
            {
                Ret.Data.JurisdictionId = NbtResources.CurrentNbtUser.JurisdictionId.ToString();
            }
            if (CswTools.IsPrimaryKey(NbtResources.CurrentNbtUser.CurrentWorkUnitId))
            {
                Ret.Data.WorkUnitId = NbtResources.CurrentNbtUser.CurrentWorkUnitId.ToString();
            }
            Ret.Data.DateFormatDn = NbtResources.CurrentNbtUser.DateFormat;
            Ret.Data.TimeFormatDn = NbtResources.CurrentNbtUser.TimeFormat;
            Ret.Data.DateFormatJs = CswTools.ConvertNetToPHP(NbtResources.CurrentNbtUser.DateFormat);
            Ret.Data.TimeFormatJs = CswTools.ConvertNetToPHP(NbtResources.CurrentNbtUser.TimeFormat);
        }
        /// <summary>
        /// Makes a temporary node of the Chemical nodetype. The reason we can't use createMaterial()
        /// is because we don't have the any properties to provide to the method and tradename,
        /// material type, and supplier are required.
        /// </summary>
        /// <param name="NodeId"></param>
        /// <returns></returns>
        public CswPrimaryKey makeTemp(string NodeId)
        {
            CswPrimaryKey Ret = new CswPrimaryKey();

            CswPrimaryKey NodePk = CswConvert.ToPrimaryKey(NodeId);

            if (false == CswTools.IsPrimaryKey(NodePk))    //node doesn't exist
            {
                CswNbtMetaDataObjectClass ChemicalOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ChemicalClass);
                CswNbtMetaDataNodeType    ChemicalNT = ChemicalOC.FirstNodeType;
                if (null != ChemicalNT)
                {
                    CswNbtPropertySetMaterial NewMaterialTempNode = _CswNbtResources.Nodes.makeNodeFromNodeTypeId(ChemicalNT.NodeTypeId, IsTemp: true);
                    if (null != NewMaterialTempNode)
                    {
                        Ret = NewMaterialTempNode.Node.NodeId;
                    }
                }
            }
            else //node exists
            {
                Ret = NodePk;
            }

            return(Ret);
        }
 private void OnOwnerPropChange( CswNbtNodeProp NodeProp, bool Creating )
 {
     if( CswTools.IsPrimaryKey( Owner.RelatedNodeId ) )
     {
         archiveMatchingDocs();
     }
 }
        /// <summary>
        /// Updates the default Expiration Date on containers to receive based on Receipt Lot's Manufactured Date
        /// </summary>
        public ContainerData.ReceivingData updateExpirationDate(ContainerData.ReceiptLotRequest Request)
        {
            ContainerData.ReceivingData ReceiveData = new ContainerData.ReceivingData();
            JObject ReceiptLotPropsObj = CswConvert.ToJObject(Request.ReceiptLotProps);

            if (ReceiptLotPropsObj.HasValues)
            {
                CswPrimaryKey ReceiptLotId = CswConvert.ToPrimaryKey(Request.ReceiptLotId);
                if (CswTools.IsPrimaryKey(ReceiptLotId))
                {
                    CswNbtObjClassReceiptLot ReceiptLot = _CswNbtResources.Nodes.GetNode(ReceiptLotId);
                    _CswNbtSdTabsAndProps.saveNodeProps(ReceiptLot.Node, ReceiptLotPropsObj);
                    CswPrimaryKey ContainerId = CswConvert.ToPrimaryKey(Request.ContainerId);
                    if (CswTools.IsPrimaryKey(ContainerId) &&
                        ReceiptLot.ManufacturedDate.DateTimeValue != DateTime.MinValue)
                    {
                        CswNbtObjClassContainer   Container = _CswNbtResources.Nodes.GetNode(ContainerId);
                        CswNbtPropertySetMaterial Material  = _CswNbtResources.Nodes.GetNode(Container.Material.RelatedNodeId);
                        Container.ExpirationDate.DateTimeValue = Material.getDefaultExpirationDate(ReceiptLot.ManufacturedDate.DateTimeValue);
                        Container.postChanges(false);
                        JObject ContainerProps = getContainerAddProps(Container);
                        ReceiveData.ContainerProps = ContainerProps.ToString();
                    }
                }
            }
            return(ReceiveData);
        }
        private static void _recurseForRelatingNodes(CswNbtResources NbtResources, CswNbtExplorerReturn Return, CswNbtNode Node, int Level, string OwnerIdStr)
        {
            CswNbtMetaDataNodeType TargetNodeType = Node.getNodeType();

            foreach (CswNbtMetaDataNodeTypeProp RelNTP in TargetNodeType.getNodeTypeProps(CswEnumNbtFieldType.Relationship))    //TODO: Locations are just like relationships, we should be able to handle them
            {
                CswNbtNodePropRelationship RelProp = Node.Properties[RelNTP];
                string Icon = _getIconFromRelationshipProp(NbtResources, RelNTP);
                if (CswTools.IsPrimaryKey(RelProp.RelatedNodeId))
                {
                    CswNbtNode             TargetNode = NbtResources.Nodes[RelProp.RelatedNodeId];
                    CswNbtMetaDataNodeType TargetNT   = TargetNode.getNodeType();

                    if (FilterVal.Contains("NT_" + TargetNode.NodeTypeId) || FilterVal.Contains("OC_" + TargetNode.getObjectClassId()))
                    {
                        string targetIdStr = OwnerIdStr + "_" + RelProp.RelatedNodeId.ToString();
                        _addToGraph(Return, RelProp.PropName + ": " + RelProp.CachedNodeName, Node.NodeId.ToString(), RelProp.RelatedNodeId.ToString(), Icon, Level, "Instance", RelProp.RelatedNodeId.ToString(), TargetNT.NodeTypeName, RelNTP.PropId);

                        if (Level + 1 <= MAX_DEPTH)
                        {
                            _recurseForRelatedNTs(NbtResources, Return, TargetNode.NodeTypeId, 1, RelProp.RelatedNodeId.ToString());
                        }

                        if (Level + 1 <= MAX_DEPTH)
                        {
                            _recurseForRelatingNodes(NbtResources, Return, TargetNode, Level + 1, targetIdStr);
                        }
                    }
                }
            }
        }
Beispiel #12
0
        public void _RegulatoryList_OnChange(CswNbtNodeProp Prop, bool Creating)
        {
            if (null != RegulatoryList.RelatedNodeId &&
                RegulatoryList.RelatedNodeId.PrimaryKey != CswConvert.ToInt32(RegulatoryList.GetOriginalPropRowValue(CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID)))
            {
                // case 28303 - set ByUser to current user when regulatory list is modified
                if (false == SetByChemical && false == _CswNbtResources.CurrentNbtUser is CswNbtSystemUser)
                {
                    ByUser.RelatedNodeId = _CswNbtResources.CurrentNbtUser.UserId;

                    // case 28303 - remove list from Chemical's Suppressed list
                    if (CswTools.IsPrimaryKey(Chemical.RelatedNodeId))
                    {
                        CswNbtObjClassChemical ChemicalNode = _CswNbtResources.Nodes[Chemical.RelatedNodeId];
                        if (null != ChemicalNode)
                        {
                            if (ChemicalNode.isRegulatoryListSuppressed(RegulatoryList.RelatedNodeId))    // important to prevent an infinite loop
                            {
                                ChemicalNode.removeSuppressedRegulatoryList(RegulatoryList.RelatedNodeId);
                                ChemicalNode.postChanges(false);
                            }
                        }
                    }
                }
            }
        } // _RegulatoryList_OnChange()
        public static void getReportInfo( ICswResources CswResources, CswNbtWebServiceReport.ReportReturn Return, CswNbtWebServiceReport.ReportData reportParams )
        {
            CswNbtResources NBTResources = (CswNbtResources) CswResources;
            reportParams.ReportNode = NBTResources.Nodes[reportParams.NodeId];
            if( null != reportParams.ReportNode )
            {
                reportParams.doesSupportCrystal = ( false == reportParams.ReportNode.RPTFile.Empty );

                CswNbtNode SourceNode = null;
                if( CswTools.IsPrimaryKey( reportParams.SourceId ) )
                {
                    SourceNode = NBTResources.Nodes[reportParams.SourceId];
                }

                reportParams.reportParams = new Collection<ReportData.ReportParam>();
                foreach( var paramPair in reportParams.ReportNode.ExtractReportParams( NBTResources.Nodes[NBTResources.CurrentNbtUser.UserId], SourceNode ) )
                {
                    ReportData.ReportParam paramObj = new ReportData.ReportParam();
                    paramObj.name = paramPair.Key;
                    paramObj.value = paramPair.Value;
                    reportParams.reportParams.Add( paramObj );
                }
            }
            Return.Data = reportParams;
        }
Beispiel #14
0
        protected override void afterPromoteNodeLogic()
        {
            // ------------------------------------------------------------
            // This logic from makeNewTab in CswNbtMetaData.cs
            // ------------------------------------------------------------
            if (CswTools.IsPrimaryKey(RelationalId))
            {
                Int32 TabId = RelationalId.PrimaryKey;

                //CswTableUpdate TabsUpdate = _CswNbtResources.makeCswTableUpdate( "DesignNodeTypeTab_afterCreateNode_TabsUpdate", "nodetype_tabset" );
                //DataTable TabsTable = TabsUpdate.getTable( "nodetypetabsetid", TabId );
                //if( TabsTable.Rows.Count > 0 )
                //{

                // Version, if necessary
                //NodeType = CheckVersioning( NodeType );

                //DataRow Row = TabsTable.Rows[0];
                DataRow Row = RelationalNodeTypeTab._DataRow;
                if (null != Row)
                {
                    Row["firsttabversionid"] = CswConvert.ToDbVal(TabId);
                    //TabsUpdate.update( TabsTable );
                }

                CswNbtMetaDataNodeTypeProp SaveNtp = NodeType.getNodeTypeProp(CswNbtObjClass.PropertyName.Save);
                if (null != SaveNtp)  //Case 29181 - Save prop on new tabs
                {
                    //Note - when first creating a new NodeType and creating its first tab this will be null, which is expected
                    SaveNtp.updateLayout(CswEnumNbtLayoutType.Edit, false, TabId: TabId, DisplayColumn: 1, DisplayRow: Int32.MaxValue);
                }
                //} // if( TabsTable.Rows.Count > 0 )
            } // if( CswTools.IsPrimaryKey( RelationalId ) )
        }     // afterPromoteNode()
Beispiel #15
0
        public override void update()
        {
            // Adapted from CswNbtSessionDataMgr.removeAllSessionData()

            CswTableSelect NodesSelect = _CswNbtSchemaModTrnsctn.makeCswTableSelect( "30983_nodes_select", "nodes" );
            DataTable NodesTable = NodesSelect.getTable( new CswCommaDelimitedString { "nodeid" }, "where istemp = '1'" );
            if( NodesTable.Rows.Count > 0 )
            {
                Collection<CswNbtNode> DoomedNodes = new Collection<CswNbtNode>();
                foreach( DataRow Row in NodesTable.Rows )
                {
                    CswPrimaryKey NodeId = new CswPrimaryKey( "nodes", CswConvert.ToInt32( Row["nodeid"] ) );
                    if( CswTools.IsPrimaryKey( NodeId ) )
                    {
                        CswNbtNode TempNode = _CswNbtSchemaModTrnsctn.Nodes[NodeId];
                        if( null != TempNode )
                        {
                            DoomedNodes.Add( TempNode );
                        }
                    }
                }

                foreach( CswNbtNode DoomedNode in DoomedNodes )
                {
                    DoomedNode.delete( DeleteAllRequiredRelatedNodes: true, OverridePermissions: true );
                }

            } //there are nodes rows

        } // update()
Beispiel #16
0
 private void onRolePropChange(CswNbtNodeProp NodeProp, bool Creating)
 {
     if (null != _CswNbtResources.CurrentNbtUser &&
         CswTools.IsPrimaryKey(Role.RelatedNodeId) &&
         Role.RelatedNodeId.PrimaryKey != CswConvert.ToInt32(Role.GetOriginalPropRowValue(CswEnumNbtPropColumn.Field1_FK)))
     {
         if (false == _CswNbtResources.CurrentNbtUser.IsAdministrator())
         {
             throw new CswDniException(CswEnumErrorType.Warning, "Only Administrators can change user roles",
                                       "Current user (" + _CswNbtResources.CurrentUser.Username +
                                       ") attempted to edit a user role.");
         }
         if (this.Username != ChemSWAdminUsername &&
             ((CswNbtObjClassRole)_CswNbtResources.Nodes[Role.RelatedNodeId]).Name.Text ==
             CswNbtObjClassRole.ChemSWAdminRoleName)
         {
             throw new CswDniException(CswEnumErrorType.Warning,
                                       "New users may not be assigned to the '" +
                                       CswNbtObjClassRole.ChemSWAdminRoleName + "' role",
                                       "Current user (" + _CswNbtResources.CurrentUser.Username +
                                       ") attempted to assign a new user to the '" +
                                       CswNbtObjClassRole.ChemSWAdminRoleName + "' role.");
         }
     }
 }
Beispiel #17
0
        public static bool IsUserNameUnique(CswNbtResources Resources, string UserName)
        {
            CswNbtObjClassUser ExistingUserNode = Resources.Nodes.makeUserNodeFromUsername(UserName);

            return(null == ExistingUserNode ||
                   false == CswTools.IsPrimaryKey(ExistingUserNode.NodeId));
        }
Beispiel #18
0
 public void saveContainerActions(ContainerData.ReconciliationRequest Request)
 {
     if (null != Request.ContainerActions)
     {
         foreach (ContainerData.ReconciliationActions Action in Request.ContainerActions)
         {
             if (Action.Action == CswEnumNbtContainerLocationActionOptions.MarkMissing.ToString())
             {
                 _createNotScannedContainerLocation(Action, CswEnumNbtContainerLocationTypeOptions.Missing);
             }
             else
             {
                 CswPrimaryKey ContLocNodeId = CswConvert.ToPrimaryKey(Action.ContainerLocationId);
                 if (CswTools.IsPrimaryKey(ContLocNodeId))
                 {
                     CswNbtObjClassContainerLocation ContLocNode = _CswNbtResources.Nodes.GetNode(ContLocNodeId);
                     ContLocNode.Action.Value = Action.Action;
                     ContLocNode.ActionByUser.RelatedNodeId = _CswNbtResources.CurrentNbtUser.UserId;
                     ContLocNode.postChanges(false);
                 }
                 else if (Action.Action == CswEnumNbtContainerLocationActionOptions.Ignore.ToString())
                 {
                     _createNotScannedContainerLocation(Action, CswEnumNbtContainerLocationTypeOptions.Ignore);
                 }
             }
         }
     }
 }
Beispiel #19
0
        public void onBeforeWriteDesignNode(CswNbtObjClassDesignNodeTypeProp DesignNTPNode)
        {
            // Copy value of 'Add To Template' to the Template
            CswNbtNodePropText         TemplateProp      = DesignNTPNode.AttributeProperty[AttributeName.Template].AsText;
            CswNbtNodePropRelationship AddToTemplateProp = DesignNTPNode.AttributeProperty[AttributeName.AddToTemplate].AsRelationship;

            if (CswTools.IsPrimaryKey(AddToTemplateProp.RelatedNodeId))
            {
                CswNbtObjClassDesignNodeTypeProp SelectedProp = _CswNbtFieldResources.CswNbtResources.Nodes[AddToTemplateProp.RelatedNodeId];
                if (null != SelectedProp)
                {
                    string newTemplate = TemplateProp.Text;
                    if (false == string.IsNullOrEmpty(newTemplate))
                    {
                        newTemplate += " ";
                    }
                    newTemplate      += CswNbtMetaData.MakeTemplateEntry(SelectedProp.RelationalNodeTypeProp.FirstPropVersionId.ToString());
                    TemplateProp.Text = newTemplate;

                    // Clear the selected value
                    AddToTemplateProp.RelatedNodeId  = null;
                    AddToTemplateProp.CachedNodeName = string.Empty;
                    AddToTemplateProp.PendingUpdate  = false;
                } // if( null != SelectedProp )
            }     // if( CswTools.IsPrimaryKey( AddToTemplateProp.RelatedNodeId ) )
        }
Beispiel #20
0
        public JObject DeleteNodes(string[] NodePks, string[] NodeKeys)
        {
            JObject ret = new JObject();
            Collection <CswPrimaryKey> NodePrimaryKeys = new Collection <CswPrimaryKey>();

            if (NodeKeys.Length > 0)
            {
                foreach (string NodeKey in NodeKeys)
                {
                    CswNbtNodeKey NbtNodeKey = new CswNbtNodeKey(NodeKey);
                    if (null != NbtNodeKey &&
                        null != NbtNodeKey.NodeId &&
                        CswTools.IsPrimaryKey(NbtNodeKey.NodeId) &&
                        false == NodePrimaryKeys.Contains(NbtNodeKey.NodeId))
                    {
                        NodePrimaryKeys.Add(NbtNodeKey.NodeId);
                    }
                }
            }
            if (NodePks.Length > 0)
            {
                foreach (string NodePk in NodePks)
                {
                    CswPrimaryKey PrimaryKey = CswConvert.ToPrimaryKey(NodePk);
                    if (CswTools.IsPrimaryKey(PrimaryKey) &&
                        false == NodePrimaryKeys.Contains(PrimaryKey))
                    {
                        NodePrimaryKeys.Add(PrimaryKey);
                    }
                }
            }
            if (NodePrimaryKeys.Count > 0)
            {
                if (NodePrimaryKeys.Count < CswNbtBatchManager.getBatchThreshold(_CswNbtResources))
                {
                    bool   success      = true;
                    string DeletedNodes = "";
                    foreach (CswPrimaryKey Npk in NodePrimaryKeys)
                    {
                        string DeletedNode = "";
                        success = DeleteNode(Npk, out DeletedNode) && success;
                        if (success)
                        {
                            DeletedNodes += DeletedNode;
                        }
                    }
                    ret["Succeeded"] = success.ToString();
                }
                else
                {
                    CswNbtBatchOpMultiDelete op        = new CswNbtBatchOpMultiDelete(_CswNbtResources);
                    CswNbtObjClassBatchOp    BatchNode = op.makeBatchOp(NodePrimaryKeys);
                    ret["batch"] = BatchNode.NodeId.ToString();
                }
            }

            return(ret);
        }
Beispiel #21
0
 protected override void afterPopulateProps()
 {
     if (CswTools.IsPrimaryKey(RelationalId))
     {
         NextValue.SetOnBeforeRender(delegate(CswNbtNodeProp prop)
         {
             NextValue.Text = getCurrent();
         });
     }
 } //afterPopulateProps()
Beispiel #22
0
 private void onMaterialPropChange(CswNbtNodeProp NodeProp)
 {
     if (CswTools.IsPrimaryKey(Material.RelatedNodeId))
     {
         NewMaterialType.setHidden(value: true, SaveToDb: true);
         NewMaterialTradename.setHidden(value: true, SaveToDb: true);
         NewMaterialSupplier.setHidden(value: true, SaveToDb: true);
         NewMaterialPartNo.setHidden(value: true, SaveToDb: true);
     }
 }
Beispiel #23
0
        public static string getNodeLink(CswPrimaryKey NodeId, string NodeName)
        {
            string Id = "none";

            if (CswTools.IsPrimaryKey(NodeId))
            {
                Id = NodeId.ToString();
            }
            return("[[" + Id + "][" + NodeName + "]]");
        }
        /// <summary>
        /// Returns a view used to show the containers available for dispense for the given Request Item
        /// </summary>
        /// <returns></returns>
        public CswNbtView getDispensibleContainersView(CswPrimaryKey RequestItemId)
        {
            CswNbtView Ret = new CswNbtView(_CswNbtResources);

            CswNbtObjClassRequestItem NodeAsRequestItem = _CswNbtResources.Nodes[RequestItemId];

            if (null != NodeAsRequestItem)
            {
                //TODO - if we're dispensing a specific container or EP, we don't care about the specific material
                CswNbtNode TargetNode = _CswNbtResources.Nodes[NodeAsRequestItem.Target.RelatedNodeId];
                if (null != TargetNode)
                {
                    Ret.ViewName = "Containers of " + TargetNode.NodeName;
                    Ret.ViewMode = CswEnumNbtViewRenderingMode.Grid;
                    Ret.Category = "Dispensing";

                    CswNbtMetaDataObjectClass ContainerOc  = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ContainerClass);
                    CswNbtViewRelationship    ContainerRel = Ret.AddViewRelationship(ContainerOc, true);
                    CswNbtViewProperty        BarcodeVp    = Ret.AddViewProperty(ContainerRel, ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Barcode));

                    //Filter Containers by Materials in Requested EP
                    if (NodeAsRequestItem.Type.Value == CswNbtObjClassRequestItem.Types.EnterprisePart)
                    {
                        CswCommaDelimitedString EPMaterialPks = _getMaterialPKsForEP(NodeAsRequestItem.EnterprisePart.RelatedNodeId);
                        Ret.AddViewPropertyAndFilter(ContainerRel, ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Material), SubFieldName: CswEnumNbtSubFieldName.NodeID, FilterMode: CswEnumNbtFilterMode.In, Value: EPMaterialPks.ToString(), ShowInGrid: false);
                    }
                    else//Filters Containers by Requested Material
                    {
                        Ret.AddViewPropertyAndFilter(ContainerRel, ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Material), SubFieldName: CswEnumNbtSubFieldName.NodeID, Value: TargetNode.NodeId.PrimaryKey.ToString(), ShowInGrid: false);
                    }
                    Ret.AddViewPropertyAndFilter(ContainerRel, ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Missing), FilterMode: CswEnumNbtFilterMode.NotEquals, Value: CswEnumTristate.True, ShowInGrid: false);
                    Ret.AddViewPropertyAndFilter(ContainerRel, ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Quantity), SubFieldName: CswEnumNbtSubFieldName.Value, FilterMode: CswEnumNbtFilterMode.GreaterThan, Value: "0");
                    Ret.AddViewPropertyAndFilter(ContainerRel, ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Status), FilterMode: CswEnumNbtFilterMode.NotEquals, Value: CswEnumNbtContainerStatuses.Expired, ShowInGrid: false);
                    Ret.AddViewProperty(ContainerRel, ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Location));

                    CswNbtMetaDataObjectClass     LocationOc        = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.LocationClass);
                    CswNbtMetaDataObjectClassProp InventoryGroupOcp = LocationOc.getObjectClassProp(CswNbtObjClassLocation.PropertyName.InventoryGroup);
                    CswNbtViewRelationship        LocationVr        = Ret.AddViewRelationship(ContainerRel, CswEnumNbtViewPropOwnerType.First, ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Location), IncludeDefaultFilters: true);
                    if (CswTools.IsPrimaryKey(NodeAsRequestItem.InventoryGroup.RelatedNodeId))   //Filter by Inventory Group
                    {
                        Ret.AddViewPropertyAndFilter(LocationVr, InventoryGroupOcp, SubFieldName: CswEnumNbtSubFieldName.NodeID, Value: NodeAsRequestItem.InventoryGroup.RelatedNodeId.PrimaryKey.ToString(), ShowInGrid: false);
                    }
                    else
                    {
                        Ret.AddViewPropertyAndFilter(LocationVr, InventoryGroupOcp, SubFieldName: CswEnumNbtSubFieldName.NodeID, FilterMode: CswEnumNbtFilterMode.Null, ShowInGrid: false);
                    }

                    if (NodeAsRequestItem.Type.Value == CswNbtObjClassRequestItem.Types.MaterialSize) //Filter By Size (if present)
                    {
                        Ret.AddViewPropertyAndFilter(ContainerRel, ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Size), SubFieldName: CswEnumNbtSubFieldName.NodeID, Value: NodeAsRequestItem.Size.RelatedNodeId.PrimaryKey.ToString(), ShowInGrid: false);
                    }
                }
            }
            return(Ret);
        }
Beispiel #25
0
        /// <summary>
        /// Instance a new Container Request Item based on the selected button option - the type will either be Dispense, Move, or Dispose.
        /// </summary>
        public CswNbtObjClassRequestItem makeContainerRequestItem(CswNbtObjClassContainer Container, CswNbtObjClass.NbtButtonData ButtonData)
        {
            checkForCentralInventoryGroups(_CswNbtResources);
            CswNbtObjClassRequestItem RequestItem;
            CswNbtMetaDataObjectClass RequestItemOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.RequestItemClass);
            CswNbtMetaDataNodeType    RequestItemNT = RequestItemOC.getNodeTypes().FirstOrDefault();
            CswNbtSdTabsAndProps      PropsAction   = new CswNbtSdTabsAndProps(_CswNbtResources);

            RequestItem = PropsAction.getAddNodeAndPostChanges(RequestItemNT, delegate(CswNbtNode NewNode)
            {
                CswNbtObjClassRequestItem RequestItemNode = NewNode;
                if (null != getCurrentRequestNodeId() && null != Container)
                {
                    RequestItemNode.Container.RelatedNodeId = Container.NodeId;
                    RequestItemNode.Material.RelatedNodeId  = Container.Material.RelatedNodeId;
                    CswPrimaryKey SelectedLocationId        = CswTools.IsPrimaryKey(_ThisUser.DefaultLocationId) ?
                                                              _ThisUser.DefaultLocationId :
                                                              Container.Location.SelectedNodeId;
                    ButtonData.Action = CswEnumNbtButtonAction.request;
                    switch (ButtonData.SelectedText)
                    {
                    case CswEnumNbtContainerRequestMenu.Dispense:
                        RequestItemNode.Type.Value              = CswNbtObjClassRequestItem.Types.ContainerDispense;
                        RequestItemNode.Quantity.UnitId         = Container.Quantity.UnitId;
                        RequestItemNode.Size.RelatedNodeId      = Container.Size.RelatedNodeId;
                        RequestItemNode.Location.SelectedNodeId = SelectedLocationId;
                        //Scope available units of measure on Quantity based on the Container's Material
                        CswNbtNode MaterialNode = _CswNbtResources.Nodes[Container.Material.RelatedNodeId];
                        if (null != MaterialNode)
                        {
                            CswNbtUnitViewBuilder Vb = new CswNbtUnitViewBuilder(_CswNbtResources);
                            Vb.setQuantityUnitOfMeasureView(MaterialNode, RequestItemNode.Quantity);
                        }
                        break;

                    case CswEnumNbtContainerRequestMenu.Dispose:
                        RequestItemNode.Type.Value = CswNbtObjClassRequestItem.Types.ContainerDispose;
                        RequestItemNode.Location.SelectedNodeId = Container.Location.SelectedNodeId;
                        break;

                    case CswEnumNbtContainerRequestMenu.Move:
                        RequestItemNode.Type.Value = CswNbtObjClassRequestItem.Types.ContainerMove;
                        RequestItemNode.Location.SelectedNodeId = SelectedLocationId;
                        break;
                    }
                    RequestItemNode.Location.RefreshNodeName();
                }
            });
            if (null == RequestItem)
            {
                throw new CswDniException(CswEnumErrorType.Error, "Could not generate a new request item.", "Failed to create a new Request Item node.");
            }
            return(RequestItem);
        }
Beispiel #26
0
 private void _setDefaultValues()
 {
     if (false == CswTools.IsPrimaryKey(Requestor.RelatedNodeId))
     {
         Requestor.RelatedNodeId = _CswNbtResources.CurrentNbtUser.UserId;
     }
     if (string.IsNullOrEmpty(Name.Text) && false == _IsFakeNode)
     {
         Name.Text = _CswNbtResources.CurrentNbtUser.Username;
     }
 }
 private void onMaterialPropChange(CswNbtNodeProp Prop)
 {
     if (CswTools.IsPrimaryKey(Material.RelatedNodeId))
     {
         Material.setReadOnly(value: true, SaveToDb: true);
         CswNbtNode            MaterialNode = _CswNbtResources.Nodes[Material.RelatedNodeId];
         CswNbtUnitViewBuilder Vb           = new CswNbtUnitViewBuilder(_CswNbtResources);
         Vb.setQuantityUnitOfMeasureView(MaterialNode, Quantity);
         Vb.setQuantityUnitOfMeasureView(MaterialNode, TotalDispensed);
         TotalDispensed.Quantity = 0;
     }
 }
Beispiel #28
0
        private JProperty _getNode(string NodePkStr, bool RunProps = true)
        {
            JProperty     Ret    = null;
            CswPrimaryKey NodePk = CswConvert.ToPrimaryKey(NodePkStr);

            if (CswTools.IsPrimaryKey(NodePk))
            {
                CswNbtNode ThisNode = _CswNbtResources.Nodes.GetNode(NodePk);
                Ret = _getNode(ThisNode, RunProps);
            }
            return(Ret);
        }
Beispiel #29
0
 protected override void afterDeleteNodeLogic()
 {
     // case 28303 - add list to Chemical's Suppressed list
     if (false == SetByChemical && CswTools.IsPrimaryKey(Chemical.RelatedNodeId))
     {
         CswNbtObjClassChemical ChemicalNode = _CswNbtResources.Nodes[Chemical.RelatedNodeId];
         if (null != ChemicalNode)
         {
             ChemicalNode.addSuppressedRegulatoryList(RegulatoryList.RelatedNodeId);
             ChemicalNode.postChanges(false);
         }
     }
 }//afterDeleteNode()
 private void OnMaterialPropChange( CswNbtNodeProp Prop, bool Creating )
 {
     if( CswTools.IsPrimaryKey( Material.RelatedNodeId ) )
     {
         CswNbtNode MaterialNode = _CswNbtResources.Nodes[Material.RelatedNodeId];
         if( null != MaterialNode )
         {
             CswNbtUnitViewBuilder Vb = new CswNbtUnitViewBuilder( _CswNbtResources );
             Vb.setQuantityUnitOfMeasureView( MaterialNode, CurrentQuantity );
             Vb.setQuantityUnitOfMeasureView( MaterialNode, Level );
         }
     }
 }