예제 #1
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()
예제 #2
0
        } //_operationsCollectionToJArray()

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

            if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.SyncLocation)
            {
                MobileMultiOpUpdatesBatchData BatchData = new MobileMultiOpUpdatesBatchData(BatchNode.BatchData.Text);
                if (BatchData.StartingCount > 0)
                {
                    ret = Math.Round((Double)(BatchData.StartingCount - BatchData.Operations.Count) / BatchData.StartingCount * 100, 0);
                }
            }
            return(ret);
        } // getPercentDone()
예제 #3
0
        } // getPercentDone()

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

                    MobileMultiOpUpdatesBatchData BatchData = new MobileMultiOpUpdatesBatchData(BatchNode.BatchData.Text);
                    CswNbtObjClassUser            UserNode  = _CswNbtResources.Nodes.makeUserNodeFromUsername(BatchData.Username);
                    _User = UserNode;

                    if (BatchData.Operations.Count > 0)
                    {
                        if (null != UserNode)
                        {
                            CswNbtObjClassRole        RoleNode    = _CswNbtResources.Nodes.makeRoleNodeFromRoleName(UserNode.Rolename);
                            CswNbtMetaDataObjectClass ContainerOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ContainerClass);
                            CswNbtMetaDataNodeType    ContainerNT = ContainerOC.getNodeTypes().FirstOrDefault();

                            int NodesProcessedPerIteration = CswConvert.ToInt32(_CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.NodesProcessedPerCycle));
                            for (int i = 0; i < NodesProcessedPerIteration && BatchData.Operations.Count > 0; i++)
                            {
                                string operation = string.Empty;
                                operation = BatchData.Operations[0]["op"].ToString();
                                operation = operation.ToLower();
                                operation = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(operation);

                                JObject update  = (JObject)BatchData.Operations[0]["update"];
                                string  barcode = BatchData.Operations[0]["barcode"].ToString();

                                if (_CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Edit, ContainerNT, RoleNode))
                                {
                                    switch (operation)
                                    {
                                    case "Dispose":
                                        _dispose(operation, barcode, BatchNode);
                                        break;

                                    case "Move":
                                        _move(operation, barcode, update, BatchNode);
                                        break;

                                    case "Owner":
                                        _updateOwner(operation, barcode, update, BatchNode);
                                        break;

                                    case "Transfer":
                                        _transfer(operation, barcode, update, BatchNode);
                                        break;

                                    case "Dispense":
                                        _dispense(operation, barcode, update, BatchNode);
                                        break;

                                    case "Reconcile":
                                        _reconcile(operation, barcode, update, BatchNode);
                                        break;

                                    default:
                                        string msg = "The operation " + operation + "doesn't exist.";
                                        _storeError(BatchNode, msg);
                                        break;
                                    } //switch (operation)
                                }
                                else
                                {
                                    string msg = "The user " + BatchData.Username + " does not have permission to edit a Container.";
                                    _storeError(BatchNode, msg);
                                }

                                BatchData.Operations.RemoveAt(0);
                            } //forloop
                        }     //if(null != Usernode)
                        else
                        {
                            _storeError(BatchNode, "The user " + BatchData.Username + " does not exist.");
                        }
                    }
                    else
                    {
                        // Send errors via an email
                        if (false == BatchNode.Log.Empty)
                        {
                            _emailErrors(BatchNode);
                        }
                        BatchNode.finish();
                    }

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