예제 #1
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();
            }
        }
        public static void Initialize(ICswResources CswResources, CswNbtExplorerReturn Return, CswNbtExplorerRequest Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;
            CswPrimaryKey   NodeId       = CswConvert.ToPrimaryKey(Request.NodeId);

            if (Request.Depth <= 4 || Request.Depth > 0)  //We never want a request higher than 4 and 0 doesn't make sense
            {
                MAX_DEPTH = Request.Depth;
            }

            FilterVal = new CswCommaDelimitedString();
            if (String.IsNullOrEmpty(Request.FilterVal))
            {
                FilterVal.FromString(CswNbtArborGraph._setDefaultFilterVal(NbtResources));
            }
            else
            {
                FilterVal.FromString(Request.FilterVal);
            }


            StartingNode = NbtResources.Nodes[NodeId];
            CswNbtMetaDataNodeType startingNT = StartingNode.getNodeType();

            //Add the initial node to the graph
            _addToGraph(Return, StartingNode.NodeName, string.Empty, NodeId.ToString(), startingNT.IconFileName, 0, "Instance", NodeId.ToString(), startingNT.NodeTypeName, Int32.MinValue);

            _recurseForRelatingNodes(NbtResources, Return, StartingNode, 1, NodeId.ToString());

            _recurseForRelatedNTs(NbtResources, Return, StartingNode.NodeTypeId, 1, NodeId.ToString());
        }
 public static void createDefaultWildcardPermission( CswNbtResources _CswNbtResources, CswEnumNbtObjectClass PermissionClass, CswPrimaryKey GroupId )
 {
     CswNbtMetaDataObjectClass PermissionOC = _CswNbtResources.MetaData.getObjectClass( PermissionClass );
     CswNbtView PermissionsView = new CswNbtView( _CswNbtResources );
     CswNbtViewRelationship PermissionVR = PermissionsView.AddViewRelationship( PermissionOC, IncludeDefaultFilters: false );
     CswNbtMetaDataObjectClassProp GroupOCP = PermissionOC.getObjectClassProp( PropertyName.PermissionGroup );
     PermissionsView.AddViewPropertyAndFilter( PermissionVR, GroupOCP, Value: GroupId.ToString(), SubFieldName: CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID );
     ICswNbtTree PermissionTree = _CswNbtResources.Trees.getTreeFromView( PermissionsView, false, false, false );
     if( PermissionTree.getChildNodeCount() == 0 )
     {
         CswNbtMetaDataNodeType PermissionNT = PermissionOC.FirstNodeType;
         if( null != PermissionNT )
         {
             _CswNbtResources.Nodes.makeNodeFromNodeTypeId( PermissionNT.NodeTypeId, delegate( CswNbtNode NewNode )
                 {
                     CswNbtPropertySetPermission WildCardPermission = NewNode;
                     WildCardPermission.ApplyToAllRoles.Checked = CswEnumTristate.True;
                     WildCardPermission.ApplyToAllWorkUnits.Checked = CswEnumTristate.True;
                     WildCardPermission.PermissionGroup.RelatedNodeId = GroupId;
                     WildCardPermission.View.Checked = CswEnumTristate.True;
                     WildCardPermission.Edit.Checked = CswEnumTristate.True;
                     WildCardPermission.setWildCardValues();
                 } );
         }
     }
 }
        public void getHMISDataTestTwoContainersDifferentMaterial()
        {
            CswPrimaryKey ControlZoneId = TestData.Nodes.createControlZoneNode().NodeId;
            CswPrimaryKey LocationId    = TestData.Nodes.createLocationNode(ControlZoneId: ControlZoneId).NodeId;
            CswNbtNode    ChemicalNode  = TestData.Nodes.createMaterialNode(Hazards: "Exp");
            CswNbtNode    ChemicalNode2 = TestData.Nodes.createMaterialNode(Hazards: "Exp");
            CswNbtNode    GallonsUnit   = TestData.Nodes.createUnitOfMeasureNode("Volume", "gal_Test", 3.78541178, 0, CswEnumTristate.True);

            TestData.Nodes.createContainerNode("Container", 1, GallonsUnit, ChemicalNode, LocationId);
            TestData.Nodes.createContainerNode("Container", 1, GallonsUnit, ChemicalNode2, LocationId);
            HMISData.HMISDataRequest Request = new HMISData.HMISDataRequest
            {
                ControlZoneId = ControlZoneId.ToString()
            };
            HMISData Data = HMISAction.getHMISData(Request);

            Assert.AreEqual(HazardClassCount, Data.Materials.Count);
            foreach (HMISData.HMISMaterial Material in Data.Materials)
            {
                if (false == String.IsNullOrEmpty(Material.Material))
                {
                    Assert.AreEqual("Exp", Material.HazardClass);
                    Assert.AreEqual(1, Material.Storage.Liquid.Qty);
                }
            }
        }
예제 #5
0
        } // getMenu()

        public static JObject makeAddMenuItem(CswNbtMetaDataNodeType NodeType, CswPrimaryKey RelatedNodeId, string RelatedNodeName)
        {
            JObject Ret = new JObject();

            Ret["text"]       = default(string);
            Ret["nodetypeid"] = default(string);
            if (null != NodeType)
            {
                Ret["text"]       = NodeType.NodeTypeName;
                Ret["nodetypeid"] = NodeType.NodeTypeId;
                Ret["icon"]       = CswNbtMetaDataObjectClass.IconPrefix16 + NodeType.IconFileName;
                Ret["action"]     = _getActionType(NodeType);
                if (String.IsNullOrEmpty(Ret["action"].ToString()))
                {
                    Ret["relatednodeid"] = default(string);
                    if (null != RelatedNodeId && Int32.MinValue != RelatedNodeId.PrimaryKey)
                    {
                        Ret["relatednodeid"] = RelatedNodeId.ToString();
                    }
                    Ret["relatednodename"] = RelatedNodeName;
                    Ret["action"]          = CswEnumNbtMainMenuActions.AddNode.ToString();
                }
            }
            return(Ret);
        } // makeAddMenuItem()
예제 #6
0
        public void TierII_1Day_OneOfTwoMaterialComponentsPresent()
        {
            CswPrimaryKey           LocationId   = TestData.Nodes.createLocationNode().NodeId;
            CswNbtNode              Constituent1 = TestData.Nodes.createConstituentNode(IsTierII: CswEnumTristate.True);
            CswNbtNode              Constituent2 = TestData.Nodes.createConstituentNode(IsTierII: CswEnumTristate.False, CASNo: "67-64-1");
            Collection <CswNbtNode> Constituents = new Collection <CswNbtNode> {
                Constituent1, Constituent2
            };
            CswNbtNode ChemicalNode = TestData.Nodes.createMaterialNode(CASNo: "50-00-0", IsTierII: CswEnumTristate.True, State: "Solid", Constituents: Constituents);
            CswNbtNode PoundsUnit   = TestData.Nodes.createUnitOfMeasureNode("Weight", "lb", 4.53592, -1, CswEnumTristate.True);

            TestData.Nodes.createContainerWithRecords("Container", 1, PoundsUnit, ChemicalNode, LocationId);
            TierIIData.TierIIDataRequest Request = new TierIIData.TierIIDataRequest
            {
                LocationId = LocationId.ToString(),
                StartDate  = DateTime.Today.AddDays(-1).ToString(),
                EndDate    = DateTime.Today.ToString()
            };
            TierIIData Data = TierIIAction.getTierIIData(Request);

            Assert.AreEqual(2, Data.Materials.Count);
            foreach (TierIIData.TierIIMaterial TierIIMat in Data.Materials)
            {
                Assert.AreEqual(TierIIMat.CASNo == "12-34-0" ? .1 : 1, TierIIMat.MaxQty);
            }
        }
예제 #7
0
 /// <summary>
 /// Grabs all WelcomePage Items for the given RoleId
 /// </summary>
 /// <param name="RoleId">RoleId to filter by</param>
 /// <returns>Collection of LandingPage Items</returns>
 public LandingPageData getWelcomePageItems(CswPrimaryKey RoleId)
 {
     LandingPageData.Request Request = new LandingPageData.Request
     {
         RoleId = RoleId.ToString()
     };
     return(_LandingPageTable.getLandingPageItems(Request));
 }
예제 #8
0
 /// <summary>
 /// Grabs all LandingPage Items for the given RoleId and/or ActionId
 /// </summary>
 /// <param name="ActionId">Action ID (for Action-specific Landing Pages)</param>
 /// <param name="RoleId">RoleId (for Welcome Page)</param>
 /// <returns></returns>
 public LandingPageData getLandingPageItems(Int32 ActionId, CswPrimaryKey RoleId)
 {
     LandingPageData.Request Request = new LandingPageData.Request
     {
         ActionId = ActionId.ToString(),
         RoleId   = RoleId.ToString()
     };
     return(_LandingPageTable.getLandingPageItems(Request));
 }
예제 #9
0
        public static string getNodeLink(CswPrimaryKey NodeId, string NodeName)
        {
            string Id = "none";

            if (CswTools.IsPrimaryKey(NodeId))
            {
                Id = NodeId.ToString();
            }
            return("[[" + Id + "][" + NodeName + "]]");
        }
        public void getHMISDataTestNoLocations()
        {
            CswPrimaryKey ControlZoneId = TestData.Nodes.createControlZoneNode().NodeId;

            HMISData.HMISDataRequest Request = new HMISData.HMISDataRequest
            {
                ControlZoneId = ControlZoneId.ToString()
            };
            HMISData Data = HMISAction.getHMISData(Request);

            Assert.AreEqual(HazardClassCount, Data.Materials.Count);
        }
예제 #11
0
 public CswNbtTreeNode(CswPrimaryKey NbtNodeId, string NbtNodeName, int NbtNodeTypeId, int NbtObjectClassId, CswPrimaryKey NbtRelationalId, CswNbtTreeNode ParentNode = null)
 {
     if (null != NbtNodeId)
     {
         NodePk = NbtNodeId.ToString();
     }
     NodeName        = NbtNodeName;
     NodeTypeId      = NbtNodeTypeId;
     ObjectClassId   = NbtObjectClassId;
     this.ParentNode = ParentNode;
     RelationalId    = NbtRelationalId;
 }
            public override string ToString()
            {
                JObject Obj = new JObject();

                if (null != FromLocation)
                {
                    Obj["FromLocation"] = FromLocation.ToString();
                }
                if (null != ToLocation)
                {
                    Obj["ToLocation"] = ToLocation.ToString();
                }
                return(Obj.ToString());
            }
예제 #13
0
        public void getTierIIDataTestNoData()
        {
            CswPrimaryKey LocationId = TestData.Nodes.createLocationNode().NodeId;

            TierIIData.TierIIDataRequest Request = new TierIIData.TierIIDataRequest
            {
                LocationId = LocationId.ToString(),
                StartDate  = DateTime.Today.ToString(),
                EndDate    = DateTime.Now.ToString()
            };
            TierIIData Data = TierIIAction.getTierIIData(Request);

            Assert.AreEqual(0, Data.Materials.Count);
        }
예제 #14
0
        private ContainerData.UnscannedLocation _makeUnscannedLocation(CswPrimaryKey LocationId)
        {
            ContainerData.UnscannedLocation UnscannedLocation = new ContainerData.UnscannedLocation();
            CswNbtObjClassLocation          LocationNode      = _CswNbtResources.Nodes[LocationId];

            if (null != LocationNode)
            {
                UnscannedLocation.LocationId     = LocationId.ToString();
                UnscannedLocation.Name           = LocationNode.Name.Text;
                UnscannedLocation.Path           = LocationNode.Location.CachedFullPath;
                UnscannedLocation.Link           = LocationNode.Node.NodeLink;
                UnscannedLocation.AllowInventory = CswConvert.ToBoolean(LocationNode.AllowInventory.Checked);
            }
            return(UnscannedLocation);
        }
예제 #15
0
        private JObject _tryCreateTempMaterial(Int32 MaterialNodeTypeId, CswPrimaryKey SupplierId, string TradeName, string PartNo, string NodeId, bool IsConstituent)
        {
            JObject Ret = new JObject();

            NewMaterial PotentialMaterial = new NewMaterial(_CswNbtResources, MaterialNodeTypeId, TradeName, SupplierId, IsConstituent, PartNo, NodeId);

            bool MaterialExists = PotentialMaterial.existsInDb();

            Ret["materialexists"] = MaterialExists;
            if (false == MaterialExists)
            {
                CswNbtPropertySetMaterial NodeAsMaterial = PotentialMaterial.Node;
                if (null == NodeAsMaterial)
                {
                    NodeAsMaterial = PotentialMaterial.commit();
                }
                if (null != NodeAsMaterial)
                {
                    Ret["materialid"] = NodeAsMaterial.NodeId.ToString();
                    Ret["tradename"]  = NodeAsMaterial.TradeName.Text;
                    Ret["partno"]     = NodeAsMaterial.PartNumber.Text;
                    Ret["supplier"]   = false == IsConstituent ? NodeAsMaterial.Supplier.CachedNodeName : "";
                    Ret["supplierid"] = false == IsConstituent?SupplierId.ToString() : "";

                    Ret["nodetypeid"] = NodeAsMaterial.NodeTypeId;
                    NodeAsMaterial.Save.setHidden(value: true, SaveToDb: true);
                    CswNbtSdTabsAndProps SdProps = new CswNbtSdTabsAndProps(_CswNbtResources);
                    Ret["properties"] = SdProps.getProps(NodeAsMaterial.Node, string.Empty, null, CswEnumNbtLayoutType.Add);
                    if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.SDS))
                    {
                        CswNbtMetaDataObjectClass SDSDocOC    = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.SDSDocumentClass);
                        CswNbtMetaDataNodeType    SDSNodeType = SDSDocOC.FirstNodeType;
                        if (null != SDSNodeType)
                        {
                            Ret["documenttypeid"] = SDSNodeType.NodeTypeId;
                        }
                    }
                    Ret["noderef"] = NodeAsMaterial.Node.NodeLink; //for the link
                }
            }
            else
            {
                CswNbtPropertySetMaterial ExisitingMaterial = PotentialMaterial.existingMaterial();
                Ret["noderef"] = ExisitingMaterial.Node.NodeLink;
            }

            return(Ret);
        }
예제 #16
0
            public JObject ToJson()
            {
                JObject NodeObj = new JObject();
                NodeObj["nodename"] = NodeName;
                if( null == NodeId )
                {
                    NodeObj["nodeid"] = "";
                }
                else
                {
                    NodeObj["nodeid"] = NodeId.ToString();
                }
                if( null == NodeKey )
                {
                    NodeObj["nodekey"] = "";
                }
                else
                {
                    NodeObj["nodekey"] = NodeKey.ToString();
                }
                NodeObj["nodelink"] = CswNbtNode.getNodeLink( NodeId, NodeName );
                NodeObj["c3productid"] = C3ProductId.ToString();
                NodeObj["acdcdbregno"] = ACDCdbregno.ToString();
                NodeObj["locked"] = Locked.ToString().ToLower();
                NodeObj["disabled"] = Disabled.ToString().ToLower();
                NodeObj["isFavorite"] = IsFavorite.ToString().ToLower();
                NodeObj["nodetypeid"] = NodeType.NodeTypeId;
                NodeObj["nodetypename"] = NodeType.NodeTypeName;
                NodeObj["thumbnailurl"] = ThumbnailUrl;
                NodeObj["thumbnailbase64str"] = ThumbnailBase64Str;
                NodeObj["allowview"] = AllowView;
                NodeObj["allowedit"] = AllowEdit;
                NodeObj["allowdelete"] = AllowDelete;

                NodeObj["allowimport"] = AllowImport;
                NodeObj["allowrequest"] = AllowRequest;

                // Props in the View
                JArray PropsArray = new JArray();
                NodeObj["props"] = PropsArray;
                foreach( TableProp thisProp in Props.Values )
                {
                    PropsArray.Add( thisProp.ToJson() );
                }
                return NodeObj;
            } // ToJson()
예제 #17
0
        public void TierII_1Day_MaterialNotPresentNotTierII()
        {
            CswPrimaryKey LocationId    = TestData.Nodes.createLocationNode().NodeId;
            CswNbtNode    ChemicalNode  = TestData.Nodes.createMaterialNode(IsTierII: CswEnumTristate.False);
            CswNbtNode    KilogramsUnit = TestData.Nodes.createUnitOfMeasureNode("Weight", "kg", 1, 0, CswEnumTristate.True);

            TestData.Nodes.createContainerWithRecords("Container", 1, KilogramsUnit, ChemicalNode, LocationId);
            TierIIData.TierIIDataRequest Request = new TierIIData.TierIIDataRequest
            {
                LocationId = LocationId.ToString(),
                StartDate  = DateTime.Today.AddDays(-1).ToString(),
                EndDate    = DateTime.Today.ToString()
            };
            TierIIData Data = TierIIAction.getTierIIData(Request);

            Assert.AreEqual(0, Data.Materials.Count);
        }
예제 #18
0
        /// <summary>
        /// Grabs a LandingPage Item with the given Name for the given RoleId and/or Action Id
        /// </summary>
        /// <param name="Name">Label Text of the LandingPage Item to grab</param>
        /// <param name="ActionId">Action ID (for Action-specific Landing Pages)</param>
        /// <param name="RoleId">RoleId (for Welcome Page)</param>
        /// <returns></returns>
        public LandingPageData.LandingPageItem getLandingPageItem(String Name, Int32 ActionId, CswPrimaryKey RoleId)
        {
            LandingPageData.LandingPageItem LandingPageItem = null;
            LandingPageData Items = _LandingPageTable.getLandingPageItems(new LandingPageData.Request
            {
                ActionId = ActionId.ToString(),
                RoleId   = RoleId.ToString()
            });

            foreach (LandingPageData.LandingPageItem Item in Items.LandingPageItems)
            {
                if (Item.Text == Name)
                {
                    LandingPageItem = Item;
                }
            }
            return(LandingPageItem);
        }
예제 #19
0
        public void executeNodeUpdateEvents(CswNbtResources CswNbtResources, CswPrimaryKey NodeId)
        {
            try
            {
                CswNbtNode Node = CswNbtResources.Nodes[NodeId];

                //TODO - put node event logic here
                //Node.postChanges( ForceUpdate: true );
            }
            catch (Exception ex)
            {
                if (false == _ErroneousNodes.Contains(NodeId.ToString()))
                {
                    _ErroneousNodeCount++;
                    _ErroneousNodes += NodeId + " - " + ex.Message + ex.StackTrace + "\n\n";
                }
            }
        }
        public void getHMISDataTestNotReportable()
        {
            CswPrimaryKey ControlZoneId = TestData.Nodes.createControlZoneNode().NodeId;
            CswPrimaryKey LocationId    = TestData.Nodes.createLocationNode(ControlZoneId: ControlZoneId).NodeId;
            CswNbtNode    ChemicalNode  = TestData.Nodes.createMaterialNode(Hazards: "Exp", SpecialFlags: "Not Reportable");

            TestData.Nodes.createContainerNode("Container", 1, null, ChemicalNode, LocationId);
            HMISData.HMISDataRequest Request = new HMISData.HMISDataRequest
            {
                ControlZoneId = ControlZoneId.ToString()
            };
            HMISData Data = HMISAction.getHMISData(Request);

            Assert.AreEqual(HazardClassCount, Data.Materials.Count);
            foreach (HMISData.HMISMaterial Material in Data.Materials)
            {
                Assert.AreEqual(String.Empty, Material.Material);
            }
        }
예제 #21
0
        public void TierII_1Day_MaterialPresentSpecificGravity()
        {
            CswPrimaryKey LocationId   = TestData.Nodes.createLocationNode().NodeId;
            CswNbtNode    ChemicalNode = TestData.Nodes.createMaterialNode(SpecificGravity: 0.5);//1 L = .5 kg = 1.102 lb
            CswNbtNode    LiterNode    = TestData.Nodes.createUnitOfMeasureNode("Volume", "Liters", 1.0, 0, CswEnumTristate.True);

            TestData.Nodes.createContainerWithRecords("Container", 1, LiterNode, ChemicalNode, LocationId);
            TierIIData.TierIIDataRequest Request = new TierIIData.TierIIDataRequest
            {
                LocationId = LocationId.ToString(),
                StartDate  = DateTime.Today.AddDays(-1).ToString(),
                EndDate    = DateTime.Today.ToString()
            };
            TierIIData Data = TierIIAction.getTierIIData(Request);

            Assert.AreEqual(1, Data.Materials.Count);
            Assert.AreEqual(1.102, Data.Materials[0].MaxQty);
            Assert.AreEqual(1.102, Data.Materials[0].AverageQty);
        }
예제 #22
0
        public void TierII_2Days_ContainerMoveToUnrelatedLocation()
        {
            CswPrimaryKey LocationIdA   = TestData.Nodes.createLocationNode().NodeId;
            CswPrimaryKey LocationIdB   = TestData.Nodes.createLocationNode().NodeId;
            CswNbtNode    ChemicalNode  = TestData.Nodes.createMaterialNode(State: "Solid");
            CswNbtNode    PoundsUnit    = TestData.Nodes.createUnitOfMeasureNode("Weight", "lb", 4.53592, -1, CswEnumTristate.True);
            CswNbtNode    ContainerNode = TestData.Nodes.createContainerWithRecords("Container", 1, PoundsUnit, ChemicalNode, LocationIdA, DateTime.Today.AddDays(-1), CswEnumNbtContainerUseTypes.Closed);

            TestData.Nodes.createContainerLocationNode(ContainerNode, Type: CswEnumNbtContainerLocationTypeOptions.Move.ToString(), LocationId: LocationIdB);
            TierIIData.TierIIDataRequest Request = new TierIIData.TierIIDataRequest
            {
                LocationId = LocationIdA.ToString(),
                StartDate  = DateTime.Today.AddDays(-1).ToString(),
                EndDate    = DateTime.Today.ToString()
            };
            TierIIData Data = TierIIAction.getTierIIData(Request);

            Assert.AreEqual(1, Data.Materials[0].Locations.Count);
            Assert.AreEqual(1, Data.Materials[0].DaysOnSite);
        }
예제 #23
0
        public void TierII_2Days_MaterialDispenseForUse()
        {
            CswPrimaryKey LocationId    = TestData.Nodes.createLocationNode().NodeId;
            CswNbtNode    ChemicalNode  = TestData.Nodes.createMaterialNode(State: "Solid");
            CswNbtNode    PoundsUnit    = TestData.Nodes.createUnitOfMeasureNode("Weight", "lb", 4.53592, -1, CswEnumTristate.True);
            CswNbtNode    ContainerNode = TestData.Nodes.createContainerWithRecords("Container", 1, PoundsUnit, ChemicalNode, LocationId, DateTime.Today.AddDays(-1), CswEnumNbtContainerUseTypes.Closed);

            TestData.Nodes.createContainerDispenseTransactionNode(ContainerNode, Quantity: .5, Type: CswEnumNbtContainerDispenseType.Dispense.ToString());
            TierIIData.TierIIDataRequest Request = new TierIIData.TierIIDataRequest
            {
                LocationId = LocationId.ToString(),
                StartDate  = DateTime.Today.AddDays(-1).ToString(),
                EndDate    = DateTime.Today.ToString()
            };
            TierIIData Data = TierIIAction.getTierIIData(Request);

            Assert.AreEqual(1, Data.Materials.Count);
            Assert.AreEqual(1, Data.Materials[0].MaxQty);
            Assert.AreEqual(.75, Data.Materials[0].AverageQty);
        }
예제 #24
0
        public void TierII_3Days_ContainerDispose()
        {
            CswPrimaryKey           LocationId    = TestData.Nodes.createLocationNode().NodeId;
            CswNbtNode              ChemicalNode  = TestData.Nodes.createMaterialNode(State: "Solid");
            CswNbtNode              PoundsUnit    = TestData.Nodes.createUnitOfMeasureNode("Weight", "lb", 4.53592, -1, CswEnumTristate.True);
            CswNbtObjClassContainer ContainerNode = TestData.Nodes.createContainerWithRecords("Container", 1, PoundsUnit, ChemicalNode, LocationId, DateTime.Today.AddDays(-1), CswEnumNbtContainerUseTypes.Closed);

            ContainerNode.DisposeContainer(true);
            ContainerNode.postChanges(false);
            TierIIData.TierIIDataRequest Request = new TierIIData.TierIIDataRequest
            {
                LocationId = LocationId.ToString(),
                StartDate  = DateTime.Today.AddDays(-1).ToString(),
                EndDate    = DateTime.Today.AddDays(1).ToString()
            };
            TierIIData Data = TierIIAction.getTierIIData(Request);

            Assert.AreEqual(1, Data.Materials[0].MaxQty);
            Assert.AreEqual(1, Data.Materials[0].AverageQty);
            Assert.AreEqual(2, Data.Materials[0].DaysOnSite);
        }
예제 #25
0
        public void TierII_1Day_MaterialPresentWithMultipleStorageTypes()
        {
            CswPrimaryKey LocationId   = TestData.Nodes.createLocationNode().NodeId;
            CswNbtNode    ChemicalNode = TestData.Nodes.createMaterialNode(State: "Solid");
            CswNbtNode    PoundsUnit   = TestData.Nodes.createUnitOfMeasureNode("Weight", "lb", 4.53592, -1, CswEnumTristate.True);

            TestData.Nodes.createContainerWithRecords("Container", 1, PoundsUnit, ChemicalNode, LocationId);
            TestData.Nodes.createContainerWithRecords("Container", 1, PoundsUnit, ChemicalNode, LocationId, UseType: CswEnumNbtContainerUseTypes.Closed);
            TierIIData.TierIIDataRequest Request = new TierIIData.TierIIDataRequest
            {
                LocationId = LocationId.ToString(),
                StartDate  = DateTime.Today.AddDays(-1).ToString(),
                EndDate    = DateTime.Today.ToString()
            };
            TierIIData Data = TierIIAction.getTierIIData(Request);

            Assert.AreEqual(1, Data.Materials.Count);
            Assert.AreEqual(2, Data.Materials[0].MaxQty);
            Assert.AreEqual(2, Data.Materials[0].AverageQty);
            Assert.AreEqual(2, Data.Materials[0].Storage.Count);
        }
예제 #26
0
        public void TierII_1Day_MaterialComponentPresent()
        {
            CswPrimaryKey LocationId   = TestData.Nodes.createLocationNode().NodeId;
            CswNbtNode    Constituent  = TestData.Nodes.createConstituentNode(IsTierII: CswEnumTristate.True);
            CswNbtNode    ChemicalNode = TestData.Nodes.createMaterialNode(CASNo: "", IsTierII: CswEnumTristate.False, State: "Solid", Constituents: new Collection <CswNbtNode> {
                Constituent
            });
            CswNbtNode PoundsUnit = TestData.Nodes.createUnitOfMeasureNode("Weight", "lb", 4.53592, -1, CswEnumTristate.True);

            TestData.Nodes.createContainerWithRecords("Container", 1, PoundsUnit, ChemicalNode, LocationId);
            TierIIData.TierIIDataRequest Request = new TierIIData.TierIIDataRequest
            {
                LocationId = LocationId.ToString(),
                StartDate  = DateTime.Today.AddDays(-1).ToString(),
                EndDate    = DateTime.Today.ToString()
            };
            TierIIData Data = TierIIAction.getTierIIData(Request);

            Assert.AreEqual(1, Data.Materials.Count);
            Assert.AreEqual(0.1, Data.Materials[0].MaxQty);
        }
예제 #27
0
        public override void update()
        {
            //Set the default value for the Available Work Units prop
            CswNbtMetaDataObjectClass UserOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.UserClass );
            foreach( CswNbtObjClassUser UserNode in UserOC.getNodes( false, true, IncludeHiddenNodes: true ) )
            {
                CswPrimaryKey WorkUnitId = UserNode.WorkUnitId;
                if( null == WorkUnitId )
                {
                    WorkUnitId = UserNode.GetFirstAvailableWorkUnitNodeId();
                }

                CswNbtNode WorkUnitNode = _CswNbtSchemaModTrnsctn.Nodes[WorkUnitId];
                UserNode.AvailableWorkUnits.AddValue( WorkUnitId.ToString() );
                UserNode.postChanges( false );
            }

            //Move the Available Work Units prop the the Profile tab
            foreach( CswNbtMetaDataNodeType UserNT in UserOC.getNodeTypes() )
            {
                CswNbtMetaDataNodeTypeTab firstTab = UserNT.getFirstNodeTypeTab();
                CswNbtMetaDataNodeTypeProp AvailWorkUnitsNTP = UserNT.getNodeTypePropByObjectClassProp( CswNbtObjClassUser.PropertyName.AvailableWorkUnits );
                AvailWorkUnitsNTP.removeFromAllLayouts();
                AvailWorkUnitsNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, firstTab.TabId );

                CswNbtMetaDataNodeTypeTab profileTab = UserNT.getNodeTypeTab( "Profile" );
                CswNbtMetaDataNodeTypeProp WorkUnitNTP = UserNT.getNodeTypePropByObjectClassProp( CswNbtObjClassUser.PropertyName.WorkUnit );
                WorkUnitNTP.updateLayout( CswEnumNbtLayoutType.Edit, false, profileTab.TabId );
            }

            //Remove extra white space from Work Units name template
            CswNbtMetaDataObjectClass WorkUnitOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.WorkUnitClass );
            foreach( CswNbtMetaDataNodeType WorkUnitNT in WorkUnitOC.getNodeTypes() )
            {
                CswNbtMetaDataNodeTypeProp NameNTP = WorkUnitNT.getNodeTypePropByObjectClassProp( CswNbtObjClassWorkUnit.PropertyName.Name );
                WorkUnitNT.setNameTemplateText( CswNbtMetaData.MakeTemplateEntry( NameNTP.PropName ) );
            }


        } // update()
예제 #28
0
        public void TierII_1Day_MaterialPresentInChildOfChildLocation()
        {
            CswPrimaryKey LocationIdA  = TestData.Nodes.createLocationNode().NodeId;
            CswPrimaryKey LocationIdB  = TestData.Nodes.createLocationNode(ParentLocationId: LocationIdA).NodeId;
            CswPrimaryKey LocationIdC  = TestData.Nodes.createLocationNode(ParentLocationId: LocationIdB).NodeId;
            CswNbtNode    ChemicalNode = TestData.Nodes.createMaterialNode(State: "Solid");
            CswNbtNode    PoundsUnit   = TestData.Nodes.createUnitOfMeasureNode("Weight", "lb", 4.53592, -1, CswEnumTristate.True);

            TestData.Nodes.createContainerWithRecords("Container", 1, PoundsUnit, ChemicalNode, LocationIdC);
            TierIIData.TierIIDataRequest Request = new TierIIData.TierIIDataRequest
            {
                LocationId = LocationIdA.ToString(),
                StartDate  = DateTime.Today.AddDays(-1).ToString(),
                EndDate    = DateTime.Today.ToString()
            };
            TierIIData Data = TierIIAction.getTierIIData(Request);

            Assert.AreEqual(1, Data.Materials.Count);
            Assert.AreEqual(1, Data.Materials[0].MaxQty);
            Assert.AreEqual(1, Data.Materials[0].AverageQty);
            Assert.AreEqual(1, Data.Materials[0].Locations.Count);
        }
예제 #29
0
        public void TierII_2Days_MaterialDispenseIntoChildContainer()
        {
            CswPrimaryKey           LocationId      = TestData.Nodes.createLocationNode().NodeId;
            CswNbtNode              ChemicalNode    = TestData.Nodes.createMaterialNode(State: "Solid");
            CswNbtNode              PoundsUnit      = TestData.Nodes.createUnitOfMeasureNode("Weight", "lb", 4.53592, -1, CswEnumTristate.True);
            CswNbtObjClassContainer SourceContainer = TestData.Nodes.createContainerWithRecords("Container", 1, PoundsUnit, ChemicalNode, LocationId, DateTime.Today.AddDays(-1), CswEnumNbtContainerUseTypes.Closed);
            CswNbtNode              ChildContainer  = TestData.Nodes.createContainerNode("Container", 0, PoundsUnit, ChemicalNode, LocationId);

            SourceContainer.DispenseOut(CswEnumNbtContainerDispenseType.Dispense, 0.5, PoundsUnit.NodeId, DestinationContainer: ChildContainer);
            ChildContainer.postChanges(false);
            TierIIData.TierIIDataRequest Request = new TierIIData.TierIIDataRequest
            {
                LocationId = LocationId.ToString(),
                StartDate  = DateTime.Today.AddDays(-1).ToString(),
                EndDate    = DateTime.Today.ToString()
            };
            TierIIData Data = TierIIAction.getTierIIData(Request);

            Assert.AreEqual(1, Data.Materials.Count);
            Assert.AreEqual(1, Data.Materials[0].MaxQty);
            Assert.AreEqual(1, Data.Materials[0].AverageQty);
        }
예제 #30
0
        public void TierII_1Day_MaterialPresent()
        {
            CswPrimaryKey LocationId   = TestData.Nodes.createLocationNode().NodeId;
            CswNbtNode    ChemicalNode = TestData.Nodes.createMaterialNode(State: "Solid");
            CswNbtNode    PoundsUnit   = TestData.Nodes.createUnitOfMeasureNode("Weight", "lb", 4.53592, -1, CswEnumTristate.True);

            TestData.Nodes.createContainerWithRecords("Container", 1, PoundsUnit, ChemicalNode, LocationId);
            TierIIData.TierIIDataRequest Request = new TierIIData.TierIIDataRequest
            {
                LocationId = LocationId.ToString(),
                StartDate  = DateTime.Today.AddDays(-1).ToString(),
                EndDate    = DateTime.Today.ToString()
            };
            TierIIData Data = TierIIAction.getTierIIData(Request);

            Assert.AreEqual(1, Data.Materials.Count);
            Assert.AreEqual(1, Data.Materials[0].MaxQty);
            Assert.AreEqual(1, Data.Materials[0].AverageQty);
            Assert.IsNotNullOrEmpty(Data.Materials[0].TradeName);                 //Material name exists
            Assert.AreEqual("12-34-0", Data.Materials[0].CASNo);                  //Material data exists
            Assert.AreEqual("Storage", Data.Materials[0].Storage[0].UseType);     //Container data exists
            Assert.AreEqual("New Room", Data.Materials[0].Locations[0].Location); //Location data exists
        }