Exemplo n.º 1
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()
Exemplo n.º 2
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()
Exemplo n.º 3
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()