public JObject dispenseSourceContainer(string DispenseType, string Quantity, string UnitId, string RequestItemId) { JObject ret = new JObject(); if (null != _SourceContainer) { CswEnumNbtContainerDispenseType DispenseTypeEnum = _getDispenseTypeFromAction(DispenseType); CswPrimaryKey UnitOfMeasurePk = new CswPrimaryKey(); UnitOfMeasurePk.FromString(UnitId); CswPrimaryKey RequestItemPk = new CswPrimaryKey(); RequestItemPk.FromString(RequestItemId); Double RealQuantity = CswConvert.ToDouble(Quantity); if (DispenseTypeEnum == CswEnumNbtContainerDispenseType.Add) { RealQuantity = -RealQuantity; // deducting negative quantity is adding quantity } _SourceContainer.DispenseOut(DispenseTypeEnum, RealQuantity, UnitOfMeasurePk, RequestItemPk); _SourceContainer.postChanges(false); string ViewId = _getViewForAllDispenseContainers(); ret["viewId"] = ViewId; } return(ret); }
/// <summary> /// Abstract override to be called on onButtonClick /// </summary> public override bool onPropertySetButtonClick(NbtButtonData ButtonData) { if (null != ButtonData.NodeTypeProp) { //Remember: Save is an OCP too switch (ButtonData.NodeTypeProp.getObjectClassPropName()) { case PropertyName.Fulfill: CswNbtObjClassContainer NodeAsContainer = null; switch (ButtonData.SelectedText) { case FulfillMenu.Dispose: NodeAsContainer = _CswNbtResources.Nodes.GetNode(Container.RelatedNodeId); if (null != NodeAsContainer) { NodeAsContainer.DisposeContainer(); NodeAsContainer.postChanges(true); Status.Value = Statuses.Completed; } ButtonData.Action = CswEnumNbtButtonAction.refresh; break; case FulfillMenu.Move: if (null != Container.RelatedNodeId) { NodeAsContainer = _CswNbtResources.Nodes.GetNode(Container.RelatedNodeId); if (null != NodeAsContainer) { NodeAsContainer.Location.SelectedNodeId = Location.SelectedNodeId; NodeAsContainer.Location.CachedNodeName = Location.CachedNodeName; NodeAsContainer.Location.CachedPath = Location.CachedPath; NodeAsContainer.postChanges(false); Status.Value = Statuses.Completed; ButtonData.Action = CswEnumNbtButtonAction.refresh; } } break; } //switch( ButtonData.SelectedText ) _getNextStatus(ButtonData.SelectedText); ButtonData.Data["requestitem"] = ButtonData.Data["requestitem"] ?? new JObject(); ButtonData.Data["requestitem"]["requestitemid"] = NodeId.ToString(); ButtonData.Data["requestitem"]["containerid"] = (Container.RelatedNodeId ?? new CswPrimaryKey()).ToString(); ButtonData.Data["requestitem"]["locationid"] = (Location.SelectedNodeId ?? new CswPrimaryKey()).ToString(); break; }//case PropertyName.Fulfill: } return(true); }
private void _executeReconciliationAction(CswNbtResources _CswNbtResources, CswNbtObjClassContainerLocation ContainerLocation) { CswNbtObjClassUser UserNode = _CswNbtResources.Nodes[ContainerLocation.ActionByUser.RelatedNodeId]; // case 30346 - use user's info for audit context if (null != UserNode) { _CswNbtResources.AuditFirstName = UserNode.FirstName; _CswNbtResources.AuditLastName = UserNode.LastName; _CswNbtResources.AuditUsername = UserNode.Username; } CswNbtObjClassContainer Container = _CswNbtResources.Nodes[ContainerLocation.Container.RelatedNodeId]; if (null != Container) { CswEnumNbtContainerLocationActionOptions Action = ContainerLocation.Action.Value; if (Action == CswEnumNbtContainerLocationActionOptions.Undispose || Action == CswEnumNbtContainerLocationActionOptions.UndisposeAndMove) { Container.UndisposeContainer(OverridePermissions: true, CreateContainerLocation: false); } if (Action == CswEnumNbtContainerLocationActionOptions.MoveToLocation || Action == CswEnumNbtContainerLocationActionOptions.UndisposeAndMove) { Container.Location.SelectedNodeId = ContainerLocation.Location.SelectedNodeId; Container.Location.RefreshNodeName(); Container.Location.CreateContainerLocation = false; } Container.Missing.Checked = Action == CswEnumNbtContainerLocationActionOptions.MarkMissing ? CswEnumTristate.True : CswEnumTristate.False; Container.postChanges(false); } }
/// <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 void _setContainerLocations() { IEnumerable <CswPrimaryKey> ContainerNodePks = this.getContainersInGroup(); if (ContainerNodePks.Count() > 0) { int BatchThreshold = CswNbtBatchManager.getBatchThreshold(_CswNbtResources); if (ContainerNodePks.Count() > BatchThreshold) { // Shelve this to a batch operation CswNbtBatchOpSyncLocation op = new CswNbtBatchOpSyncLocation(_CswNbtResources); CswNbtObjClassBatchOp BatchNode = op.makeBatchOp(ContainerNodePks, this.Location.SelectedNodeId); } else { foreach (CswPrimaryKey CurrentContainerNodePk in ContainerNodePks) { CswNbtObjClassContainer CurrentContainer = _CswNbtResources.Nodes[CurrentContainerNodePk]; if (null != CurrentContainer) { CurrentContainer.Location.SelectedNodeId = this.Location.SelectedNodeId; CurrentContainer.postChanges(false); } } } } }
public override void CommitOperation(ref OperationData OpData) { CswNbtObjClassContainer containerToDispose = _CswNbtResources.Nodes[OpData.Field1.NodeId]; if (_CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Edit, containerToDispose.NodeType) && _CswNbtResources.Permit.can(CswEnumNbtActionName.DisposeContainer)) { if (CswEnumTristate.True == containerToDispose.Disposed.Checked) { OpData.Field1.StatusMsg = "Container " + OpData.Field1.Value + " is already disposed"; OpData.Log.Add(DateTime.Now + " - ERROR: Attempted to dispose already disposed container " + OpData.Field1.Value); } else { containerToDispose.DisposeContainer(); containerToDispose.postChanges(false); OpData.Log.Add(DateTime.Now + " - Disposed container " + OpData.Field1.Value); OpData.Field1.Value = string.Empty; } OpData.Field1.ServerValidated = false; } else { string statusMsg = "You do not have permission to dispose Container (" + OpData.Field1.Value + ")"; OpData.Field1.StatusMsg = statusMsg; OpData.Field1.ServerValidated = false; OpData.Log.Add(DateTime.Now + " - ERROR: " + statusMsg); } }
public JObject dispenseIntoChildContainers(string ContainerNodeTypeId, string DispenseGrid, string RequestItemId) { JObject ret = new JObject(); if (null != _SourceContainer) { CswPrimaryKey RequestItemPk = new CswPrimaryKey(); RequestItemPk.FromString(RequestItemId); JArray GridArray = JArray.Parse(DispenseGrid); JObject jBarcodes = new JObject(); ret["barcodes"] = jBarcodes; for (Int32 i = 0; i < GridArray.Count; i += 1) { if (GridArray[i].Type == JTokenType.Object) { JObject CurrentRow = (JObject)GridArray[i]; int NumOfContainers = CswConvert.ToInt32(CurrentRow["containerNo"]); double QuantityToDispense = CswConvert.ToDouble(CurrentRow["quantity"]); string UnitId = CswConvert.ToString(CurrentRow["unitid"]); CswCommaDelimitedString Barcodes = new CswCommaDelimitedString(); Barcodes.FromString(CswConvert.ToString(CurrentRow["barcodes"])); CswPrimaryKey UnitOfMeasurePK = new CswPrimaryKey(); UnitOfMeasurePK.FromString(UnitId); if (NumOfContainers == 0) { _SourceContainer.DispenseOut( CswEnumNbtContainerDispenseType.Dispense, QuantityToDispense, UnitOfMeasurePK, RequestItemPk); _SourceContainer.postChanges(false); } else { for (Int32 c = 0; c < NumOfContainers; c += 1) { CswNbtObjClassContainer ChildContainer = _createChildContainer(ContainerNodeTypeId, UnitOfMeasurePK, Barcodes[c]); _SourceContainer.DispenseOut( CswEnumNbtContainerDispenseType.Dispense, QuantityToDispense, UnitOfMeasurePK, RequestItemPk, ChildContainer); //ChildContainer.DispenseIn( CswEnumNbtContainerDispenseType.Dispense, QuantityToDispense, UnitOfMeasurePK, RequestItemPk, _SourceContainer ); ChildContainer.postChanges(false); JObject BarcodeNode = new JObject(); jBarcodes[ChildContainer.NodeId.ToString()] = BarcodeNode; BarcodeNode["nodeid"] = ChildContainer.NodeId.ToString(); BarcodeNode["nodename"] = ChildContainer.NodeName; } _SourceContainer.postChanges(false); } } } _SourceContainer.postChanges(false); string ViewId = _getViewForAllDispenseContainers(); ret["viewId"] = ViewId; } return(ret); }
}//_dispense() private void _reconcile(string operation, string barcode, JObject update, CswNbtObjClassBatchOp BatchNode) { try { string newLocationBarcode = update["location"].ToString(); CswNbtObjClassContainer containerNode = _getNodeFromBarcode(barcode, CswEnumNbtObjectClass.ContainerClass, CswNbtObjClassContainer.PropertyName.Barcode, false); if (null != containerNode) { containerNode.CreateContainerLocationNode(CswEnumNbtContainerLocationTypeOptions.ReconcileScans, newLocationBarcode, barcode); containerNode.Location.RefreshNodeName(); containerNode.postChanges(false); } else { string msg = _generateErrorMessage(operation, barcode, null, "A container with barcode " + barcode + " does not exist."); _storeError(BatchNode, msg); } } catch (Exception e) { string msg = "The reconcile operation failed for the container barcode " + barcode + "with exception: " + e; _storeError(BatchNode, msg); } }//_reconcile()
public override void CommitOperation(ref OperationData OpData) { CswNbtObjClassContainer containerToDispense = _CswNbtResources.Nodes[OpData.Field1.NodeId]; if (_CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Edit, containerToDispense.NodeType) && _CswNbtResources.Permit.can(CswEnumNbtActionName.DispenseContainer)) { double quantityToDispense = CswConvert.ToDouble(OpData.Field2.Value); if (quantityToDispense > containerToDispense.Quantity.Quantity) { OpData.Field2.StatusMsg = "Cannot dispense " + quantityToDispense + containerToDispense.Quantity.CachedUnitName + " when containter only has " + containerToDispense.Quantity.Gestalt; OpData.Log.Add(DateTime.Now + " - ERROR: Attempted to dispense " + quantityToDispense + containerToDispense.Quantity.CachedUnitName + " when containter only has " + containerToDispense.Quantity.Gestalt); OpData.Field2.ServerValidated = false; } else { containerToDispense.DispenseOut(CswEnumNbtContainerDispenseType.Dispense, quantityToDispense, containerToDispense.Quantity.UnitId); containerToDispense.postChanges(false); OpData.Field1.SecondValue = " (current quantity: " + containerToDispense.Quantity.Quantity + containerToDispense.Quantity.CachedUnitName + ")"; OpData.Log.Add(DateTime.Now + " - Dispensed " + OpData.Field2.Value + " " + containerToDispense.Quantity.CachedUnitName + " out of container " + containerToDispense.Barcode.Barcode + ". " + containerToDispense.Quantity.Gestalt + " left in container"); base.CommitOperation(ref OpData); } } else { string statusMsg = "You do not have permission to dispense Container (" + OpData.Field2.Value + ")"; OpData.Field2.StatusMsg = statusMsg; OpData.Field2.ServerValidated = false; OpData.Log.Add(DateTime.Now + " - ERROR: " + statusMsg); } }
public void setStatusTestMissing() { CswNbtObjClassContainer ContainerNode = TestData.Nodes.createContainerNode(); ContainerNode.Missing.Checked = CswEnumTristate.True; ContainerNode.postChanges(false); CswNbtObjClassContainerLocation ContainerLocationNode = TestData.Nodes.createContainerLocationNode( ContainerNode.Node, CswEnumNbtContainerLocationActionOptions.Ignore.ToString(), Type: CswEnumNbtContainerLocationTypeOptions.ReconcileScans.ToString()); Assert.AreEqual(CswEnumNbtContainerLocationStatusOptions.Missing.ToString(), ContainerLocationNode.Status.Value); }
}//_updateOwner() private void _transfer(string operation, string barcode, JObject update, CswNbtObjClassBatchOp BatchNode) { try { string newOwnerBarcode = update["user"].ToString(); CswNbtNode newOwnerNode = _getNodeFromBarcode(newOwnerBarcode, CswEnumNbtObjectClass.UserClass, CswNbtObjClassUser.PropertyName.Barcode); if (null != newOwnerNode) { CswPrimaryKey newOwnerNodeId = newOwnerNode.NodeId; CswNbtObjClassContainer containerNode = _getNodeFromBarcode(barcode, CswEnumNbtObjectClass.ContainerClass, CswNbtObjClassContainer.PropertyName.Barcode); if (null != containerNode) { containerNode.TransferContainer(newOwnerNodeId); containerNode.postChanges(false); } else { string msg = _generateErrorMessage(operation, barcode, new Dictionary <string, string> { { "New Owner", newOwnerBarcode }, { "New Location", update["location"].ToString() } }, "A container with barcode " + barcode + " does not exist."); _storeError(BatchNode, msg); } } else { string msg = _generateErrorMessage(operation, barcode, new Dictionary <string, string> { { "New Owner", newOwnerBarcode }, { "New Location", update["location"].ToString() } }, "The User barcode, " + newOwnerBarcode + ", does not exist"); _storeError(BatchNode, msg); } } catch (Exception e) { string msg = "The transfer operation failed for the container barcode " + barcode + "with exception: " + e; _storeError(BatchNode, msg); } }//_transfer()
}//_transfer() private void _dispense(string operation, string barcode, JObject update, CswNbtObjClassBatchOp BatchNode) { try { string uom = update["uom"].ToString().ToLower(); CswPrimaryKey uomId = null; CswNbtMetaDataObjectClass UnitOfMeasureOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.UnitOfMeasureClass); foreach (CswNbtObjClassUnitOfMeasure currentUnitOfMeasureNode in UnitOfMeasureOC.getNodes(false, false, false, true)) { string unitName = currentUnitOfMeasureNode.NodeName.ToLower(); if (unitName == uom) { uomId = currentUnitOfMeasureNode.NodeId; } } if (null != uomId) { CswNbtObjClassContainer containerNode = _getNodeFromBarcode(barcode, CswEnumNbtObjectClass.ContainerClass, CswNbtObjClassContainer.PropertyName.Barcode); if (null != containerNode) { containerNode.DispenseOut(CswEnumNbtContainerDispenseType.Dispense, CswConvert.ToDouble(update["qty"]), uomId); containerNode.postChanges(false); } else { string msg = _generateErrorMessage(operation, barcode, new Dictionary <string, string> { { "Dispense Data", update.ToString() } }, "A container with barcode " + barcode + " does not exist."); _storeError(BatchNode, msg); } } else { string msg = _generateErrorMessage(operation, barcode, new Dictionary <string, string> { { "Dispense Data", update.ToString() } }, "The UOM of " + uom + " that was provided does not exist."); _storeError(BatchNode, msg); } } catch (Exception e) { string msg = "The dispense operation failed for the container barcode " + barcode + "with exception: " + e; _storeError(BatchNode, msg); } }//_dispense()
private static Int32 moveContainers(CswNbtResources NbtResources, CswNbtObjClassRequestItem RequestItem, CswNbtRequestDataModel.RequestFulfill Request) { Int32 Ret = 0; if (null != RequestItem) { foreach (string ContainerId in Request.ContainerIds) { CswNbtObjClassContainer ContainerNode = NbtResources.Nodes[ContainerId]; if (null != ContainerNode) { ContainerNode.Location.SelectedNodeId = RequestItem.Location.SelectedNodeId; ContainerNode.Location.RefreshNodeName(); ContainerNode.postChanges(ForceUpdate: false); Ret += 1; } } } return(Ret); }
private void _toggleAllowRequestForContainers( bool Allow ) { CswNbtView MyContainers = new CswNbtView( _CswNbtResources ); MyContainers.ViewName = "Related Containers"; CswNbtMetaDataObjectClass ContainerOC = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.ContainerClass ); CswNbtMetaDataObjectClassProp MaterialOCP = ContainerOC.getObjectClassProp( CswNbtObjClassContainer.PropertyName.Material ); CswNbtViewRelationship Root = MyContainers.AddViewRelationship( ContainerOC, false ); MyContainers.AddViewPropertyAndFilter( Root, MaterialOCP, NodeId.PrimaryKey.ToString(), CswEnumNbtSubFieldName.NodeID ); ICswNbtTree ContainersTree = _CswNbtResources.Trees.getTreeFromView( MyContainers, false, false, false ); for( int i = 0; i < ContainersTree.getChildNodeCount(); i++ ) { ContainersTree.goToNthChild( i ); CswNbtObjClassContainer CurrentContainer = ContainersTree.getNodeForCurrentPosition(); CurrentContainer.ToggleAllowRequest( Allow ); CurrentContainer.postChanges( false ); } }//_toggleAllowRequestForContainers()
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); }
public void threadCallBack(ICswResources CswResources) { _LogicRunStatus = CswEnumScheduleLogicRunStatus.Running; CswNbtResources _CswNbtResources = (CswNbtResources)CswResources; _CswNbtResources.AuditContext = "Scheduler Task: " + RuleName; if (CswEnumScheduleLogicRunStatus.Stopping != _LogicRunStatus) { try { if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.Containers)) { int ContainersProcessedPerIteration = CswConvert.ToInt32(_CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.NodesProcessedPerCycle)); int TotalProcessedThisIteration = 0; while (TotalProcessedThisIteration < ContainersProcessedPerIteration && _ContainerIdsWithoutReceiveTransactions.Count > 0 && (CswEnumScheduleLogicRunStatus.Stopping != _LogicRunStatus)) { _createReceiveDispenseTransaction(_CswNbtResources, _ContainerIdsWithoutReceiveTransactions[0], _ContainerHasOtherTransactions[0]); CswNbtObjClassContainer expiredContainer = _CswNbtResources.Nodes[_ContainerIdsWithoutReceiveTransactions[0]]; if (null != expiredContainer) { expiredContainer.Status.Value = CswEnumNbtContainerStatuses.Expired; expiredContainer.postChanges(false); } _ContainerIdsWithoutReceiveTransactions.RemoveAt(0); TotalProcessedThisIteration++; } } _CswScheduleLogicDetail.StatusMessage = "Completed without error"; _LogicRunStatus = CswEnumScheduleLogicRunStatus.Succeeded; } catch (Exception Exception) { _CswScheduleLogicDetail.StatusMessage = "CswScheduleLogicExpiredContainers::GetExpiredContainers() exception: " + Exception.Message + "; " + Exception.StackTrace; _CswNbtResources.logError(new CswDniException(_CswScheduleLogicDetail.StatusMessage)); _LogicRunStatus = CswEnumScheduleLogicRunStatus.Failed; } } }
private void _dispose(string operation, string barcode, CswNbtObjClassBatchOp BatchNode) { try { CswNbtObjClassContainer ContainerNode = _getNodeFromBarcode(barcode, CswEnumNbtObjectClass.ContainerClass, CswNbtObjClassContainer.PropertyName.Barcode); if (null != ContainerNode) { ContainerNode.DisposeContainer(); ContainerNode.postChanges(false); } else { string msg = _generateErrorMessage(operation, barcode, null, "A container with barcode " + barcode + " does not exist."); _storeError(BatchNode, msg); } } catch (Exception e) { string msg = "The dispose operation failed for the container barcode " + barcode + "with exception: " + e; _storeError(BatchNode, msg); } }//_dispose()