Example #1
0
        } // restore()

        /// <summary>
        /// Makes a new batch operation instance in the database
        /// </summary>
        public static CswNbtObjClassBatchOp makeNew(CswNbtResources CswNbtResources,
                                                    CswEnumNbtBatchOpName BatchOpName,
                                                    string BatchData,
                                                    CswPrimaryKey UserId = null,
                                                    Double Priority      = Double.NaN)
        {
            CswNbtObjClassBatchOp     BatchNode = null;
            CswNbtMetaDataObjectClass BatchOpOC = CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.BatchOpClass);

            if (BatchOpOC != null)
            {
                CswNbtMetaDataNodeType BatchOpNT = BatchOpOC.getNodeTypes().First();
                if (BatchOpNT != null)
                {
                    CswNbtNode Node = CswNbtResources.Nodes.makeNodeFromNodeTypeId(BatchOpNT.NodeTypeId);
                    BatchNode = Node;

                    BatchNode.BatchData.Text            = BatchData;
                    BatchNode.CreatedDate.DateTimeValue = DateTime.Now;
                    BatchNode.OpName.Text = BatchOpName.ToString();
                    if (false == Double.IsNaN(Priority))
                    {
                        BatchNode.Priority.Value = Priority;
                    }
                    BatchNode.Status.Value       = CswEnumNbtBatchOpStatus.Pending.ToString();
                    BatchNode.User.RelatedNodeId = UserId ?? CswNbtResources.CurrentNbtUser.UserId;

                    BatchNode.postChanges(true);
                }
            }
            return(BatchNode);
        } // makeNew()
        public override void update()
        {
            CswNbtMetaDataObjectClass BatchOpOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.BatchOpClass );

            foreach( CswNbtMetaDataNodeType BatchOpNT in BatchOpOC.getNodeTypes() )
            {
                CswNbtMetaDataNodeTypeProp BatchOpIdNTP = BatchOpNT.getNodeTypeProp( "Batch Op Id" );
                CswNbtView batchOpView = _CswNbtSchemaModTrnsctn.makeNewView( "BatchOps_51743", CswEnumNbtViewVisibility.Hidden );
                CswNbtViewRelationship parent = batchOpView.AddViewRelationship( BatchOpNT, false );
                batchOpView.AddViewPropertyAndFilter( parent, BatchOpIdNTP, FilterMode : CswEnumNbtFilterMode.Null );

                ICswNbtTree batchOpsTree = _CswNbtSchemaModTrnsctn.getTreeFromView( batchOpView, true );
                for( int i = 0; i < batchOpsTree.getChildNodeCount(); i++ )
                {
                    batchOpsTree.goToNthChild( i );

                    CswNbtObjClassBatchOp batchNode = batchOpsTree.getNodeForCurrentPosition();
                    batchNode.Node.Properties[BatchOpIdNTP].AsSequence.setSequenceValue();
                    batchNode.postChanges( false );

                    batchOpsTree.goToParentNode();
                }
            }


        } // update()
Example #3
0
        }//_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()
Example #4
0
        } // _addNodeToData()

        public static void UploadBulkEditData(ICswResources CswResources, BulkEditReturn ret, BulkEditUpload Params)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            CswTempFile temp     = new CswTempFile(CswResources);
            string      tempPath = temp.saveToTempFile(Params.PostedFile.InputStream, CswResources.AccessId + "_bulkedit_" + DateTime.Now.Ticks.ToString());

            DataSet uploadDataSet = CswNbtImportTools.ReadExcel(tempPath);

            if (uploadDataSet.Tables.Count > 0)
            {
                DataTable uploadTable = uploadDataSet.Tables[0];

                CswNbtBatchOpBulkEdit batch     = new CswNbtBatchOpBulkEdit(NbtResources);
                CswNbtObjClassBatchOp batchNode = batch.makeBatchOp(uploadTable);

                CswNbtView BatchOpsView = new CswNbtView((CswNbtResources)CswResources);
                BatchOpsView.ViewName = "New Batch Operations";
                BatchOpsView.ViewMode = CswEnumNbtViewRenderingMode.Tree;
                CswNbtViewRelationship BatchRel = BatchOpsView.AddViewRelationship(batchNode.NodeType, false);
                BatchRel.NodeIdsToFilterIn.Add(batchNode.NodeId);

                BatchOpsView.SaveToCache(true);
                ret.ViewId = BatchOpsView.SessionViewId.ToString();
            } // if( uploadDataSet.Tables.Count > 0 )
        }     // UploadBulkEditData()
        /// <summary>
        /// Run the next iteration of this batch operation
        /// </summary>
        public void runBatchOp(CswNbtObjClassBatchOp BatchNode)
        {
            try
            {
                if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.MultiDelete)
                {
                    BatchNode.start();
                    MultiDeleteBatchData BatchData = new MultiDeleteBatchData(BatchNode.BatchData.Text);
                    if (BatchData.DeleteNodeIds.Count > 0)
                    {
                        string NodeIdStr = BatchData.DeleteNodeIds.First.ToString();
                        _deleteNode(NodeIdStr);

                        // Setup for next iteration
                        BatchData.DeleteNodeIds.RemoveAt(0);
                        BatchNode.BatchData.Text    = BatchData.ToString();
                        BatchNode.PercentDone.Value = getPercentDone(BatchNode);
                    }
                    else
                    {
                        BatchNode.finish();
                    }
                    BatchNode.postChanges(false);
                }
            }
            catch (Exception ex)
            {
                BatchNode.error(ex);
            }
        }
        } // getPercentDone()

        /// <summary>
        /// Run the next iteration of this batch operation
        /// </summary>
        public void runBatchOp(CswNbtObjClassBatchOp BatchNode)
        {
            try
            {
                if (BatchNode.OpNameValue == CswEnumNbtBatchOpName.Receiving)
                {
                    _CswNbtSdTabsAndProps = new CswNbtSdTabsAndProps(_CswNbtResources);

                    BatchNode.start();

                    ReceivingBatchData BatchData = new ReceivingBatchData(BatchNode.BatchData.Text);

                    CswNbtActReceiving        ActReceiving      = new CswNbtActReceiving(_CswNbtResources);
                    CswNbtReceivingDefinition UpdatedReceiptDef = ActReceiving.receiveContainers(BatchData.ReceiptDef, ref _NodesProcessed, _MaxNodeProcessed);

                    ReceivingBatchData UpdatedBatchData = new ReceivingBatchData(UpdatedReceiptDef);
                    BatchNode.BatchData.Text = UpdatedBatchData.ToString();

                    if (0 == BatchData.CountNumberContainersToCreate() || 0 == _NodesProcessed)
                    {
                        BatchNode.finish();
                    }

                    _NodesProcessed = 0; //reset this for Unit Test purposes

                    BatchNode.PercentDone.Value = getPercentDone(BatchNode);
                    BatchNode.BatchData.Text    = BatchData.ToString();
                    BatchNode.postChanges(false);
                }
            }
            catch (Exception ex)
            {
                BatchNode.error(ex);
            }
        } // runBatchOp()
        } // getPercentDone()

        /// <summary>
        /// Run the next iteration of this batch operation
        /// </summary>
        public void runBatchOp(CswNbtObjClassBatchOp BatchNode)
        {
            try
            {
                if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.MultiEdit)
                {
                    BatchNode.start();

                    MultiEditBatchData BatchData = new MultiEditBatchData(BatchNode.BatchData.Text);
                    if (BatchData.SourceNodeId != null && BatchData.CopyNodeIds.Count > 0 && BatchData.NodeTypePropIds.Count > 0)
                    {
                        CswNbtNode SourceNode = _CswNbtResources.Nodes[BatchData.SourceNodeId];
                        if (SourceNode != null)
                        {
                            string NodeIdStr = BatchData.CopyNodeIds.First.ToString();

                            CswPrimaryKey CopyToNodePk = new CswPrimaryKey();
                            CopyToNodePk.FromString(NodeIdStr);

                            if (Int32.MinValue != CopyToNodePk.PrimaryKey)
                            {
                                CswNbtNode CopyToNode = _CswNbtResources.Nodes[CopyToNodePk];
                                if (CopyToNode != null &&
                                    _CswNbtResources.Permit.isNodeWritable(CswEnumNbtNodeTypePermission.Edit, CopyToNode.getNodeType(), CopyToNode.NodeId))
                                {
                                    foreach (CswNbtMetaDataNodeTypeProp NodeTypeProp in BatchData.NodeTypePropIds.Select(PropId => _CswNbtResources.MetaData.getNodeTypeProp(CswConvert.ToInt32(PropId))))
                                    {
                                        CopyToNode.Properties[NodeTypeProp].copy(SourceNode.Properties[NodeTypeProp]);
                                    }

                                    CopyToNode.postChanges(false);

                                    //BatchNode.appendToLog( "Copied values for: " + CopyToNode.NodeName + " (" + CopyToNode.NodeId.PrimaryKey.ToString() + ")" );
                                } // if( CopyToNode != null )
                            }     // if( Int32.MinValue != CopyToNodePk.PrimaryKey )

                            // Setup for next iteration
                            BatchData.CopyNodeIds.RemoveAt(0);
                            BatchNode.BatchData.Text    = BatchData.ToString();
                            BatchNode.PercentDone.Value = getPercentDone(BatchNode);
                        } // if( SourceNode != null )
                        else
                        {
                            BatchNode.finish();
                        }
                    }
                    else
                    {
                        BatchNode.finish();
                    }

                    BatchNode.postChanges(false);
                } // if( BatchNode != null && BatchNode.OpNameValue == NbtBatchOpName.MultiEdit )
            }
            catch (Exception ex)
            {
                BatchNode.error(ex);
            }
        } // runBatchOp()
        } // getPercentDone()

        /// <summary>
        /// Create a new batch operation to handle recalcution of inventory levels
        /// </summary>
        public CswNbtObjClassBatchOp makeBatchOp(CswPrimaryKey PrevLocation, CswPrimaryKey CurrentLocation)
        {
            CswNbtObjClassBatchOp    BatchNode = null;
            InventoryLevelsBatchData BatchData = new InventoryLevelsBatchData(PrevLocation, CurrentLocation);

            BatchNode = CswNbtBatchManager.makeNew(_CswNbtResources, _BatchOpName, BatchData);
            return(BatchNode);
        } // makeBatchOp()
        /// <summary>
        /// Create a new batch operation to handle creation of Containers from the receiving wizard
        /// </summary>
        public CswNbtObjClassBatchOp makeBatchOp(CswNbtReceivingDefinition ReceiptDefinition)
        {
            CswNbtObjClassBatchOp BatchNode = null;
            ReceivingBatchData    BatchData = new ReceivingBatchData(ReceiptDefinition);

            BatchNode = CswNbtBatchManager.makeNew(_CswNbtResources, _BatchOpName, BatchData.ToString());
            return(BatchNode);
        } // makeBatchOp()
Example #10
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);
        }
Example #11
0
        } // getPercentDone()

        /// <summary>
        /// Run the next iteration of this batch operation
        /// </summary>
        public void runBatchOp(CswNbtObjClassBatchOp BatchNode)
        {
            try
            {
                if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.SyncLocation)
                {
                    BatchNode.start();

                    SyncLocationBatchData BatchData = new SyncLocationBatchData(BatchNode.BatchData.Text);

                    if (BatchData.NodePks.Count > 0)
                    {
                        int NodesProcessedPerIteration = CswConvert.ToInt32(_CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.NodesProcessedPerCycle));
                        for (int i = 0; i < NodesProcessedPerIteration && BatchData.NodePks.Count > 0; i++)
                        {
                            CswNbtNode Node = _CswNbtResources.Nodes[CswConvert.ToString(BatchData.NodePks[0])];
                            BatchData.NodePks.RemoveAt(0);
                            bool LocationUpdated = false;
                            if (null != Node)
                            {
                                CswNbtMetaDataNodeType NodeType = Node.getNodeType();
                                if (null != NodeType)
                                {
                                    CswNbtMetaDataNodeTypeProp LocationNTP = NodeType.getLocationProperty();
                                    if (null != LocationNTP)
                                    {
                                        CswNbtNodePropLocation LocationProp = Node.Properties[LocationNTP];
                                        if (null != LocationProp)
                                        {
                                            LocationProp.SelectedNodeId = BatchData.LocationId;
                                            Node.postChanges(false);
                                            LocationUpdated = true;
                                        }
                                    }
                                }
                            }//if( null != Node )

                            if (false == LocationUpdated)
                            {
                                BatchNode.appendToLog("Unable to update the location of: " + Node.NodeName + " (" + Node.NodeId.ToString() + ")");
                            }
                        }//for( int i = 0; i < NodesProcessedPerIteration && BatchData.NodePks.Count > 0; i++ )
                    }
                    else
                    {
                        BatchNode.finish();
                    }

                    BatchNode.PercentDone.Value = getPercentDone(BatchNode);
                    BatchNode.BatchData.Text    = BatchData.ToString();
                    BatchNode.postChanges(false);
                }
            }
            catch (Exception ex)
            {
                BatchNode.error(ex);
            }
        } // runBatchOp()
        }     // makeBatchOp()

        /// <summary>
        /// Run the next iteration of this batch operation
        /// </summary>
        public void runBatchOp(CswNbtObjClassBatchOp BatchNode)
        {
            try
            {
                if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.FutureNodes)
                {
                    BatchNode.start();

                    FutureNodesBatchData BatchData = new FutureNodesBatchData(BatchNode.BatchData.Text);
                    if (BatchData.GeneratorNodeId != null && BatchData.NextStartDate != DateTime.MinValue)
                    {
                        CswNbtNode GenNode = _CswNbtResources.Nodes[BatchData.GeneratorNodeId];
                        if (null != GenNode)
                        {
                            CswNbtObjClassGenerator GeneratorNode = (CswNbtObjClassGenerator)GenNode;
                            DateTime ThisDate = BatchData.NextStartDate;

                            CswNbtActGenerateNodes CswNbtActGenerateNodes = new CswNbtActGenerateNodes(_CswNbtResources);
                            CswNbtActGenerateNodes.MarkFuture = true;

                            // Run this iteration
                            bool Finished = false;
                            if (ThisDate != DateTime.MinValue &&
                                ThisDate.Date <= BatchData.FinalDate.Date &&
                                (GeneratorNode.FinalDueDate.Empty || ThisDate.Date <= GeneratorNode.FinalDueDate.DateTimeValue.Date))
                            {
                                Finished = CswNbtActGenerateNodes.makeNode(GenNode, ThisDate);
                                //BatchNode.appendToLog( "Created future task for " + ThisDate.ToShortDateString() + "." );
                            }
                            else
                            {
                                BatchNode.finish();
                            }

                            // Setup for next iteration
                            if (Finished)
                            {
                                BatchData.NextStartDate = GeneratorNode.DueDateInterval.getNextOccuranceAfter(ThisDate);
                                if (BatchData.NextStartDate.Date == ThisDate.Date)  // infinite loop guard
                                {
                                    BatchNode.finish();
                                }
                                BatchData.IterationCount += 1;
                            }
                            BatchNode.BatchData.Text    = BatchData.ToString();
                            BatchNode.PercentDone.Value = getPercentDone(BatchNode);
                        } // if( null != GenNode )
                    }     // if( _BatchData.GeneratorNodeId != null && _BatchData.NextStartDate != DateTime.MinValue )

                    BatchNode.postChanges(false);
                } // if( BatchNode != null && BatchNode.OpNameValue == NbtBatchOpName.FutureNodes )
            }
            catch (Exception ex)
            {
                BatchNode.error(ex);
            }
        } // runBatchOp()
        public CswNbtObjClassBatchOp makeNodesBatch(CswNbtCISProNbtMobileData.MobileRequest LegacyData)
        {
            // Send to background task
            CswNbtObjClassBatchOp             BatchNode = null;
            CswNbtBatchOpMobileMultiOpUpdates BatchOp   = new CswNbtBatchOpMobileMultiOpUpdates(_CswNbtResources);

            BatchNode = BatchOp.makeBatchOp(LegacyData);

            return(BatchNode);
        }
        /// <summary>
        /// Returns the percentage of the task that is complete
        /// </summary>
        public Double getPercentDone(CswNbtObjClassBatchOp BatchNode)
        {
            Double ret = 0;

            if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.InventoryLevel)
            {
                ret = 100;
            }
            return(ret);
        } // getPercentDone()
        /// <summary>
        /// Create a new batch operation to handle a deleteNodes/multi edit operation
        /// </summary>
        /// <param name="DeleteNodeIds"></param>
        public CswNbtObjClassBatchOp makeBatchOp(Collection <CswPrimaryKey> DeleteNodeIds)
        {
            CswNbtObjClassBatchOp BatchNode = null;
            MultiDeleteBatchData  BatchData = new MultiDeleteBatchData(string.Empty);

            BatchData.DeleteNodeIds = _pkArrayToJArray(DeleteNodeIds);
            BatchData.StartingCount = DeleteNodeIds.Count();
            BatchNode = CswNbtBatchManager.makeNew(_CswNbtResources, _BatchOpName, BatchData.ToString());
            return(BatchNode);
        }
        } // makeBatchOp()

        /// <summary>
        /// Create a new batch operation to handle future node generation
        /// </summary>
        /// <param name="GenNode">Generator Node</param>
        /// <param name="FinalDate"></param>
        public CswNbtObjClassBatchOp makeBatchOp(CswNbtNode GenNode, DateTime FinalDate)
        {
            CswNbtObjClassBatchOp BatchNode = null;

            if (null != GenNode)
            {
                CswNbtObjClassGenerator GeneratorNode = (CswNbtObjClassGenerator)GenNode;


                // BZ 6752 - The first future node is the first node generated
                // after today + warning days, according to the time interval
                // But it has to include initial due date, no matter what the time interval.

                CswNbtNodePropTimeInterval NextDueDateTimeInterval = GeneratorNode.DueDateInterval;
                Double WarningDays = 0;
                if (GeneratorNode.WarningDays.Value > 0)
                {
                    WarningDays = GeneratorNode.WarningDays.Value;
                }
                DateTime StartDate = DateTime.Now.AddDays(WarningDays).Date;   //bz# 6937 (capture date only, not time)

                DateTime DateOfNextOccurance = DateTime.MinValue;
                if (GeneratorNode.DueDateInterval.getStartDate().Date >= StartDate)  //bz # 6937 (change gt to gteq)
                {
                    DateOfNextOccurance = GeneratorNode.DueDateInterval.getStartDate().Date;
                }
                else
                {
                    DateOfNextOccurance = NextDueDateTimeInterval.getNextOccuranceAfter(StartDate);
                }

                // Determine number of iterations
                Int32    StartingCount = 0;
                DateTime ThisDate      = DateOfNextOccurance;

                while (ThisDate != DateTime.MinValue &&
                       ThisDate.Date <= FinalDate &&
                       (GeneratorNode.FinalDueDate.Empty || ThisDate.Date <= GeneratorNode.FinalDueDate.DateTimeValue.Date))
                {
                    StartingCount++;
                    ThisDate = GeneratorNode.DueDateInterval.getNextOccuranceAfter(ThisDate);
                }

                FutureNodesBatchData BatchData = new FutureNodesBatchData(string.Empty);
                BatchData.GeneratorNodeId = GenNode.NodeId;
                BatchData.NextStartDate   = DateOfNextOccurance;
                BatchData.FinalDate       = FinalDate;
                BatchData.StartingCount   = StartingCount;
                BatchData.IterationCount  = 0;

                BatchNode = CswNbtBatchManager.makeNew(_CswNbtResources, _BatchOpName, BatchData.ToString());
            } // if(null != GeneratorNode)
            return(BatchNode);
        }     // makeBatchOp()
        } // getPercentDone()

        /// <summary>
        /// Create a new batch operation to handle future node generation
        /// </summary>
        /// <param name="GeneratorNodeId">Primary key of Generator</param>
        /// <param name="FinalDate"></param>
        public CswNbtObjClassBatchOp makeBatchOp(CswPrimaryKey GeneratorNodeId, DateTime FinalDate)
        {
            CswNbtObjClassBatchOp BatchNode = null;

            if (null != GeneratorNodeId)
            {
                CswNbtNode GenNode = _CswNbtResources.Nodes[GeneratorNodeId];
                BatchNode = makeBatchOp(GenNode, FinalDate);
            }
            return(BatchNode);
        } // makeBatchOp()
Example #18
0
        /// <summary>
        /// Create a new batch operation to handle clicking an objectclass button for multiple nodes
        /// </summary>
        /// <param name="MultiNodeIds">NodeIds with which ObjectClassButtonClick logic should be applied</param>
        /// <param name="NodeTypePropId">PropId of the ObjectClassButton</param>
        public CswNbtObjClassBatchOp makeBatchOp(Collection <CswPrimaryKey> MultiNodeIds, Int32 NodeTypePropId)
        {
            MultiButtonClickBatchData BatchData = new MultiButtonClickBatchData(string.Empty);

            BatchData.MultiNodeIds   = _pkArrayToJArray(MultiNodeIds);
            BatchData.StartingCount  = MultiNodeIds.Count();
            BatchData.NodeTypePropId = NodeTypePropId;

            CswNbtObjClassBatchOp BatchNode = CswNbtBatchManager.makeNew(_CswNbtResources, _BatchOpName, BatchData.ToString());

            return(BatchNode);
        }
Example #19
0
        /// <summary>
        /// Create a new batch operation to handle an edit of the location property
        /// based on the location property of another node.
        /// </summary>
        /// <param name="NodePks"></param>
        /// <param name="CGLocationId"></param>
        /// <returns></returns>
        public CswNbtObjClassBatchOp makeBatchOp(IEnumerable <CswPrimaryKey> NodePks, CswPrimaryKey LocationId)
        {
            CswNbtObjClassBatchOp BatchNode = null;
            SyncLocationBatchData BatchData = new SyncLocationBatchData(string.Empty);

            BatchData.LocationId    = LocationId;
            BatchData.StartingCount = NodePks.Count();
            BatchData.NodePks       = _pkArrayToJArray(NodePks);

            BatchNode = CswNbtBatchManager.makeNew(_CswNbtResources, _BatchOpName, BatchData.ToString());
            return(BatchNode);
        } // makeBatchOp()
Example #20
0
        public CswNbtObjClassBatchOp makeBatchOp(CswNbtCISProNbtMobileData.MobileRequest MobileRequest)
        {
            CswNbtObjClassBatchOp         BatchNode = null;
            MobileMultiOpUpdatesBatchData BatchData = new MobileMultiOpUpdatesBatchData(string.Empty);

            BatchData.StartingCount = MobileRequest.data.MultiOpRows.Count;
            BatchData.Operations    = _operationsCollectionToJArray(MobileRequest.data.MultiOpRows);
            BatchData.Username      = MobileRequest.data.username;

            BatchNode = CswNbtBatchManager.makeNew(_CswNbtResources, _BatchOpName, BatchData.ToString());
            return(BatchNode);
        } // makeBatchOp()
        } // makeBatchOp()

        public Double getPercentDone(CswNbtObjClassBatchOp BatchNode)
        {
            Double ret = 100;

            if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.Receiving)
            {
                ReceivingBatchData BatchData = new ReceivingBatchData(BatchNode.BatchData.Text);
                int containersLeft           = BatchData.CountNumberContainersToCreate();
                int totalContainers          = BatchData.CountTotalContainers();
                ret = Math.Round((Double)(totalContainers - containersLeft) / totalContainers * 100, 0);
            }
            return(ret);
        } // getPercentDone()
Example #22
0
        } //_pkArrayToJArray()

        public Double getPercentDone(CswNbtObjClassBatchOp BatchNode)
        {
            Double ret = 100;

            if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.SyncLocation)
            {
                SyncLocationBatchData BatchData = new SyncLocationBatchData(BatchNode.BatchData.Text);
                if (BatchData.StartingCount > 0)
                {
                    ret = Math.Round((Double)(BatchData.StartingCount - BatchData.NodePks.Count) / BatchData.StartingCount * 100, 0);
                }
            }
            return(ret);
        } // getPercentDone()
Example #23
0
        /// <summary>
        /// Restore an existing batch row from the database
        /// </summary>
        public static CswNbtObjClassBatchOp restore(CswNbtResources CswNbtResources, CswPrimaryKey BatchId)
        {
            CswNbtObjClassBatchOp BatchNode = null;

            if (BatchId != null && BatchId.PrimaryKey != Int32.MinValue)
            {
                CswNbtNode Node = CswNbtResources.Nodes[BatchId];
                if (Node != null)
                {
                    BatchNode = Node;
                }
            }
            return(BatchNode);
        } // restore()
Example #24
0
        public Double getPercentDone(CswNbtObjClassBatchOp BatchNode)
        {
            Double ret = 100;

            if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.MultiButtonClick)
            {
                MultiButtonClickBatchData BatchData = new MultiButtonClickBatchData(BatchNode.BatchData.Text);
                if (BatchData.StartingCount > 0)
                {
                    ret = Math.Round((Double)(BatchData.StartingCount - BatchData.MultiNodeIds.Count()) / BatchData.StartingCount * 100, 0);
                }
            }
            return(ret);
        }
Example #25
0
        } // makeBatchOp()

        public Double getPercentDone(CswNbtObjClassBatchOp BatchNode)
        {
            Double ret = 100;

            if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.BulkEdit)
            {
                BulkEditBatchData BatchData = new BulkEditBatchData(BatchNode.BatchData.Text);
                if (BatchData.TotalRows > 0)
                {
                    ret = Math.Round((Double)BatchData.CurrentRow / BatchData.TotalRows * 100, 0);
                }
            }
            return(ret);
        } // getPercentDone()
        /// <summary>
        /// Returns the percentage of the task that is complete
        /// </summary>
        public Double getPercentDone(CswNbtObjClassBatchOp BatchNode)
        {
            Double ret = 100;

            if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.FutureNodes)
            {
                FutureNodesBatchData BatchData = new FutureNodesBatchData(BatchNode.BatchData.Text);
                if (BatchData.StartingCount > 0)
                {
                    ret = Math.Round((Double)BatchData.IterationCount / BatchData.StartingCount * 100, 0);
                }
            }
            return(ret);
        } // getPercentDone()
Example #27
0
        }//_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()
        /// <summary>
        /// Create a new batch operation to handle a copyNodeProps/multi edit operation
        /// </summary>
        /// <param name="SourceNode"></param>
        /// <param name="CopyNodeIds"></param>
        /// <param name="NodeTypePropIds"></param>
        public CswNbtObjClassBatchOp makeBatchOp(CswNbtNode SourceNode, Collection <CswPrimaryKey> CopyNodeIds, Collection <Int32> NodeTypePropIds)
        {
            CswNbtObjClassBatchOp BatchNode = null;

            if (null != SourceNode)
            {
                MultiEditBatchData BatchData = new MultiEditBatchData(string.Empty);
                BatchData.SourceNodeId    = SourceNode.NodeId;
                BatchData.CopyNodeIds     = pkArrayToJArray(CopyNodeIds);
                BatchData.StartingCount   = CopyNodeIds.Count();
                BatchData.NodeTypePropIds = Int32CollectionToJArray(NodeTypePropIds);

                BatchNode = CswNbtBatchManager.makeNew(_CswNbtResources, _BatchOpName, BatchData.ToString());
            } // if(null != SourceNode)
            return(BatchNode);
        }     // makeBatchOp()
Example #29
0
        }//_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()
Example #30
0
        public CswNbtObjClassBatchOp makeNodesBatch(CswNbtNode CswNbtNodeGenerator, DateTime FutureDate)
        {
            CswNbtObjClassBatchOp   BatchNode     = null;
            CswNbtObjClassGenerator GeneratorNode = CswNbtNodeGenerator;
            Int32 TargetNodeTypeId = CswConvert.ToInt32(GeneratorNode.TargetType.SelectedNodeTypeIds);

            // Must have create permissions on this generator's target's nodetype
            if (_CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Create, _CswNbtResources.MetaData.getNodeType(TargetNodeTypeId)))
            {
                deleteExistingFutureNodes(CswNbtNodeGenerator);

                // Send to background task
                CswNbtBatchOpFutureNodes BatchOp = new CswNbtBatchOpFutureNodes(_CswNbtResources);
                BatchNode = BatchOp.makeBatchOp(CswNbtNodeGenerator, FutureDate);
            }

            return(BatchNode);
        }