コード例 #1
0
        private Collection <CswNbtObjClassInventoryLevel> _InventoryLevels(CswNbtView InventoryLevelView)
        {
            Collection <CswNbtObjClassInventoryLevel> Ret = new Collection <CswNbtObjClassInventoryLevel>();

            if (null != InventoryLevelView && InventoryLevelView.ViewName == _ParentLocationInventoryLevelViewName)
            {
                ICswNbtTree Tree          = _CswNbtResources.Trees.getTreeFromView(InventoryLevelView, false, false, false);
                Int32       LocationCount = Tree.getChildNodeCount();
                if (LocationCount > 0)
                {
                    for (Int32 Loc = 0; Loc < LocationCount; Loc += 1)
                    {
                        Tree.goToNthChild(Loc);
                        Int32 LevelCount = Tree.getChildNodeCount();
                        if (LevelCount > 0)
                        {
                            for (Int32 Lev = 0; Lev < LevelCount; Lev += 1)
                            {
                                Tree.goToNthChild(Lev);
                                CswNbtObjClassInventoryLevel InventoryLevel = Tree.getNodeForCurrentPosition();
                                Ret.Add(InventoryLevel);
                                Tree.goToParentNode();
                            }
                        }
                        Tree.goToParentNode();
                    }
                }
            }
            return(Ret);
        }
コード例 #2
0
        public bool addToCurrentQuantity(CswNbtObjClassInventoryLevel InventoryLevel, double Quantity, CswPrimaryKey UnitId, string Reason)
        {
            bool Ret = false;

            if (null != InventoryLevel)
            {
                Ret = _addToCurrentQuantity(InventoryLevel, Quantity, UnitId, Reason);
            }
            return(Ret);
        }
コード例 #3
0
        public double getCurrentInventoryLevel(CswNbtObjClassInventoryLevel InventoryLevel)
        {
            double     Ret           = 0;
            CswNbtView ContainerView = GetCurrentQuantityView(InventoryLevel, InventoryLevel.Location.SelectedNodeId);

            if (null != ContainerView)
            {
                ICswNbtTree Tree = _CswNbtResources.Trees.getTreeFromView(ContainerView, false, false, false);
                Int32       LocationNodeCount = Tree.getChildNodeCount();
                if (LocationNodeCount > 0)
                {
                    Dictionary <Int32, CswNbtUnitConversion> UnitConversions = new Dictionary <int, CswNbtUnitConversion>();
                    for (Int32 L = 0; L < LocationNodeCount; L += 1)
                    {
                        Tree.goToNthChild(L);
                        Int32 ContainerNodeCount = Tree.getChildNodeCount();
                        if (ContainerNodeCount > 0)
                        {
                            for (Int32 C = 0; C < ContainerNodeCount; C += 1)
                            {
                                Tree.goToNthChild(C);
                                foreach (CswNbtTreeNodeProp Prop in Tree.getChildNodePropsOfNode())
                                {
                                    CswEnumNbtFieldType FieldType = Prop.FieldType;
                                    if (FieldType == CswEnumNbtFieldType.Quantity)
                                    {
                                        Int32 UnitTypeId = Prop.Field1_Fk;
                                        CswNbtUnitConversion Conversion;
                                        if (UnitConversions.ContainsKey(UnitTypeId))
                                        {
                                            Conversion = UnitConversions[UnitTypeId];
                                        }
                                        else
                                        {
                                            Conversion = new CswNbtUnitConversion(_CswNbtResources, new CswPrimaryKey("nodes", UnitTypeId), InventoryLevel.Level.UnitId, InventoryLevel.Material.RelatedNodeId);
                                            UnitConversions.Add(UnitTypeId, Conversion);
                                        }
                                        if (null != Conversion)
                                        {
                                            double ContainerQuantity = Prop.Field1_Numeric;
                                            Ret += Conversion.convertUnit(ContainerQuantity);
                                        }
                                    }
                                }
                                Tree.goToParentNode();
                            }
                        }
                        Tree.goToParentNode();
                    }
                }
            }
            return(Ret);
        }
コード例 #4
0
        private bool _addToCurrentQuantity(CswNbtObjClassInventoryLevel InventoryLevel, double Quantity, CswPrimaryKey UnitId, string Reason)
        {
            bool Ret = false;

            if (null != InventoryLevel)
            {
                CswNbtUnitConversion Conversion = new CswNbtUnitConversion(_CswNbtResources, UnitId, InventoryLevel.Level.UnitId, InventoryLevel.Material.RelatedNodeId);
                InventoryLevel.CurrentQuantity.Quantity += Conversion.convertUnit(Quantity);
                InventoryLevel.CurrentQuantityLog.AddComment(Reason);
                InventoryLevel.postChanges(true);
                Ret = true;
            }
            return(Ret);
        }
コード例 #5
0
        public bool isLevelPastThreshhold(CswNbtObjClassInventoryLevel InventoryLevel)
        {
            bool Ret = false;

            switch (InventoryLevel.Type.Value)
            {
            case CswNbtObjClassInventoryLevel.Types.Maximum:
                Ret = (InventoryLevel.CurrentQuantity.Quantity > InventoryLevel.Level.Quantity);
                break;

            case CswNbtObjClassInventoryLevel.Types.Minimum:
                Ret = (InventoryLevel.CurrentQuantity.Quantity < InventoryLevel.Level.Quantity);
                break;
            }

            return(Ret);
        }
コード例 #6
0
        /// <summary>
        /// Sends notification email and returns Now
        /// </summary>
        /// <returns></returns>
        public DateTime sendPastThreshholdEmail(CswNbtObjClassInventoryLevel InventoryLevel)
        {
            foreach (CswNbtObjClassUser User in InventoryLevel.Subscribe.SelectedUsers())
            {
                if (false == string.IsNullOrEmpty(User.Email) &&
                    false == string.IsNullOrEmpty(InventoryLevel.Type.Value))
                {
                    string Subject = InventoryLevel.Status.Value + " alert for " + InventoryLevel.Material.CachedNodeName + " at " + InventoryLevel.Location.CachedFullPath;
                    string Message = "The status for Inventory Level: " + InventoryLevel.Node.NodeName + " has changed to " + InventoryLevel.Status.Value + "\n";
                    Message += "Material: " + InventoryLevel.Material.CachedNodeName + "\n";
                    Message += "Location: " + InventoryLevel.Location.CachedFullPath + "\n";
                    Message += "Current Quantity: " + InventoryLevel.CurrentQuantity.Gestalt + "\n";
                    Message += "Threshhold: " + InventoryLevel.Level.Gestalt + "\n";

                    _sendEmail(User.Email, Subject, Message);
                }
            }
            return(DateTime.Now);
        }
コード例 #7
0
        public CswNbtView GetCurrentQuantityView(CswNbtObjClassInventoryLevel InventoryLevel, CswPrimaryKey StartLocationId)
        {
            CswNbtView Ret = null;

            if (CswTools.IsPrimaryKey(InventoryLevel.Material.RelatedNodeId))
            {
                Ret = new CswNbtView(_CswNbtResources);
                CswNbtViewRelationship LocationRel = _SdLocations.getAllChildrenLocationRelationship(Ret, StartLocationId);

                CswNbtMetaDataObjectClass     ContainerOc = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ContainerClass);
                CswNbtMetaDataObjectClassProp LocationOcp = ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Location);
                CswNbtMetaDataObjectClassProp MaterialOcp = ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Material);
                CswNbtMetaDataObjectClassProp DisposedOcp = ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Disposed);
                CswNbtMetaDataObjectClassProp MissingOcp  = ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Missing);
                CswNbtMetaDataObjectClassProp QuantityOcp = ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Quantity);

                CswNbtViewRelationship ContainerRel = Ret.AddViewRelationship(LocationRel, CswEnumNbtViewPropOwnerType.Second, LocationOcp, false);
                Ret.AddViewPropertyAndFilter(ContainerRel, MaterialOcp, InventoryLevel.Material.RelatedNodeId.PrimaryKey.ToString(), CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID, FilterMode: CswEnumNbtFilterMode.Equals);
                Ret.AddViewPropertyAndFilter(ContainerRel, DisposedOcp, CswEnumTristate.True.ToString(), CswNbtFieldTypeRuleLogical.SubFieldName.Checked, FilterMode: CswEnumNbtFilterMode.NotEquals);
                Ret.AddViewPropertyAndFilter(ContainerRel, MissingOcp, CswEnumTristate.True.ToString(), CswNbtFieldTypeRuleLogical.SubFieldName.Checked, FilterMode: CswEnumNbtFilterMode.NotEquals);
                Ret.AddViewProperty(ContainerRel, QuantityOcp);
            }
            return(Ret);
        }
コード例 #8
0
 public bool doSendEmail(CswNbtObjClassInventoryLevel InventoryLevel)
 {
     return(isLevelPastThreshhold(InventoryLevel) && InventoryLevel.LastNotified.DateTimeValue <= DateTime.Now.AddDays(-1));
 }