public static NodeValue Parse(string strValue)
        {
            NodeValue result = new NodeValue();

            if (strValue.StartsWith("1"))
            {
                result.IsActive = true;
            }
            else
            {
                result.IsActive = false;
            }

            if (strValue.Substring(1, 2).Equals("OU"))
            {
                result.OType = ValueType.OU;
            }
            else
            {
                result.OType = ValueType.Position;
            }

            result.ObjectId = int.Parse(strValue.Substring(3));
            return(result);
        }
 private void SetTreeNode(TreeNode treeNode, AuthorizationDS.OrganizationUnitRow ou)
 {
     treeNode.Text         = ou.OrganizationUnitName;
     treeNode.Value        = NodeValue.FromObject(ou).ToString();
     treeNode.ShowCheckBox = true;
     treeNode.ImageUrl     = "~/Images/department.png";
 }
 protected void ChangeOrganizationUnitBtn_Click(object sender, EventArgs e)
 {
     if (this.OrganizationTreeView.CheckedNodes.Count == 1)
     {
         TreeNode  newParentNode   = this.OrganizationTreeView.CheckedNodes[0];
         NodeValue parentNodeValue = NodeValue.Parse(newParentNode.Value);
         if (parentNodeValue.OType == NodeValue.ValueType.OU)
         {
             if (parentNodeValue.IsActive)
             {
                 TreeNode  childNode      = this.OrganizationTreeView.SelectedNode;
                 NodeValue childNodeValue = NodeValue.Parse(childNode.Value);
                 this.AuthBLL.SetPositionParentOU(childNodeValue.ObjectId, parentNodeValue.ObjectId);
                 childNode.Parent.ChildNodes.Remove(childNode);
                 newParentNode.ChildNodes.Add(childNode);
                 this.OrganizationTreeView_SelectedNodeChanged(null, null);
             }
             else
             {
                 PageUtility.ShowModelDlg(this, "目标组织机构处于非激活状态,不能迁移");
                 return;
             }
         }
         else
         {
             PageUtility.ShowModelDlg(this, "请先选择目标组织机构");
             return;
         }
     }
     else
     {
         PageUtility.ShowModelDlg(this, "请选择唯一目标组织机构");
         return;
     }
 }
 protected void UpdatePositionBtn_Click(object sender, EventArgs e)
 {
     try {
         NodeValue  nodeValue       = NodeValue.Parse(this.OrganizationTreeView.SelectedNode.Value);
         List <int> positionTypeIds = new List <int>();
         foreach (ListItem li in this.PositionTypeCtl.Items)
         {
             if (li.Selected)
             {
                 if (li.Value.Length > 0)
                 {
                     positionTypeIds.Add(int.Parse(li.Value));
                 }
                 else
                 {
                     positionTypeIds.Clear();
                     break;
                 }
             }
         }
         this.AuthBLL.UpdatePosition(nodeValue.ObjectId, this.PositionNameCtl.Text, positionTypeIds);
         AuthorizationDS.PositionRow position = this.AuthBLL.ActivePosition(nodeValue.ObjectId, this.PositionIsActiveCtl.Checked);
         this.SetTreeNode(this.OrganizationTreeView.SelectedNode, position);
     } catch (ApplicationException ex) {
         PageUtility.DealWithException(this, ex);
     }
 }
    protected void AddOrganizationUnitBtn_Click(object sender, EventArgs e)
    {
        TreeNode  parentNode      = this.OrganizationTreeView.SelectedNode;
        NodeValue parentNodeValue = NodeValue.Parse(parentNode.Value);
        string    strTypeId       = this.NewUnitTypeCtl.SelectedValue;
        int?      typeId          = null;

        if (strTypeId.Length == 0)
        {
            typeId = null;
        }
        else
        {
            typeId = int.Parse(strTypeId);
        }
        int?costCenterID = null;

        if (this.NewCostCenterDDL.SelectedValue != "0")
        {
            costCenterID = int.Parse(this.NewCostCenterDDL.SelectedValue);
        }

        AuthorizationDS.OrganizationUnitRow newOU = this.AuthBLL.AddOrganizationUnit(this.NewUnitNameCtl.Text, this.NewUnitCodeCtl.Text, parentNodeValue.ObjectId, typeId, costCenterID);
        parentNode.ChildNodes.Add(NewTreeNode(newOU));
        this.ClearNewOUPanel();
    }
    protected void AddPositionBtn_Click(object sender, EventArgs e)
    {
        NodeValue  nodeValue       = NodeValue.Parse(this.OrganizationTreeView.SelectedNode.Value);
        List <int> positionTypeIds = new List <int>();

        foreach (ListItem li in this.NewPositionTypeCtl.Items)
        {
            if (li.Selected)
            {
                if (li.Value.Length > 0)
                {
                    positionTypeIds.Add(int.Parse(li.Value));
                }
                else
                {
                    positionTypeIds.Clear();
                    break;
                }
            }
        }
        AuthorizationDS.PositionRow newPosition = this.AuthBLL.AddPosition(this.NewPositionNameCtl.Text, nodeValue.ObjectId, positionTypeIds);

        TreeNode childNode = new TreeNode();

        this.SetTreeNode(childNode, newPosition);
        this.OrganizationTreeView.SelectedNode.ChildNodes.Add(childNode);
    }
Example #7
0
    private void NodeChangeParameter(int nodeId, string oldParameter, string newParameter)
    {
        NodeValue nodeValue = GetNode(nodeId);

        if (null == nodeValue)
        {
            return;
        }

        BehaviorParameter parameter = null;

        for (int i = 0; i < _globalParameter.parameterList.Count; ++i)
        {
            BehaviorParameter temp = _globalParameter.parameterList[i];
            if (temp.parameterName.CompareTo(newParameter) == 0)
            {
                parameter = temp;
            }
        }

        if (null == parameter)
        {
            return;
        }

        for (int i = 0; i < nodeValue.parameterList.Count; ++i)
        {
            BehaviorParameter temp = nodeValue.parameterList[i];
            if (temp.parameterName.CompareTo(parameter.parameterName) == 0)
            {
                nodeValue.parameterList[i] = parameter.Clone();
                break;
            }
        }
    }
Example #8
0
            public NodeValue FindNodeValue(byte[] key, out Node closestNode)
            {
                closestNode = this;

                while (closestNode._depth < key.Length) //find loop
                {
                    if (closestNode._children == null)
                    {
                        break;
                    }

                    Node child = Volatile.Read(ref closestNode._children[key[closestNode._depth]]);
                    if (child == null)
                    {
                        return(null); //value not found
                    }
                    closestNode = child;
                }

                //either closestNode is leaf or key belongs to closestNode
                NodeValue value = closestNode._value;

                if ((value != null) && KeyEquals(closestNode._depth, value.Key, key))
                {
                    return(value); //value found
                }
                return(null);      //value key does not match
            }
        public bool UserInitializeWith(ValueTypeBase valueType, bool inheritsSupportedValueTypes)
        {
            var manager = ZWaveManager.Current;
            var window  = new MainWindow();

            NodeValue nodeValue = null;

            try
            {
                nodeValue = TryGetNodeValue();
            }
            catch
            {
                //do nothing, node not exist
            }

            window.RefreshWith(manager, nodeValue, (nv) => ZWaveTypeComparability.IsTypesComparable(nv, valueType, inheritsSupportedValueTypes));
            if (window.ShowDialog() ?? false)
            {
                nodeValue = window.GetSelectedNodeValue();
                NodeId    = nodeValue.Node.Id;
                HomeId    = nodeValue.Node.HomeId;
                ValueId   = nodeValue.Id;
                ValueType = ZWaveTypeComparability.CreateValueTypeFromNodeValue(nodeValue);
                Initialize();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #10
0
    private void NodeAddChild(int parentId, int childId)
    {
        NodeValue parentNode = GetNode(parentId);
        NodeValue childNode  = GetNode(childId);

        if (null == parentNode || null == childNode)
        {
            Debug.LogError("node is null");
            return;
        }

        string msg    = string.Empty;
        bool   result = true;

        if (childNode.parentNodeID >= 0)
        {
            result = false;
            if (childNode.parentNodeID != parentId)
            {
                msg = "已经有父节点";
            }
            else
            {
                msg = "不能重复添加父节点";
            }
        }

        if (parentNode.parentNodeID >= 0 && parentNode.parentNodeID == childNode.id)
        {
            msg    = "不能添加父节点作为子节点";
            result = false;
        }

        if (!result && TreeNodeWindow.window != null)
        {
            TreeNodeWindow.window.ShowNotification(msg);
        }

        if (!result)
        {
            return;
        }

        // 修饰节点只能有一个子节点
        if (parentNode.NodeType >= (int)NODE_TYPE.DECORATOR_INVERTER && parentNode.NodeType <= (int)NODE_TYPE.DECORATOR_UNTIL_SUCCESS)
        {
            for (int i = 0; i < parentNode.childNodeList.Count; ++i)
            {
                NodeValue node = GetNode(parentNode.childNodeList[i]);
                if (null != node)
                {
                    node.parentNodeID = -1;
                }
            }
            parentNode.childNodeList.Clear();
        }

        parentNode.childNodeList.Add(childNode.id);
        childNode.parentNodeID = parentNode.id;
    }
Example #11
0
        public Results(CombinedNode node)
        {
            this.node = node;
            InitializeComponent();
            NodeValue result = node.CalcValue;

            lbl_origin.Content = result.Origin;
            lbl_val.Content    = result.Value;
            List <CombinedNode> nodei = node.GetChildren();

            foreach (var item in nodei)
            {
                if (item.Children.Count != 0)
                {
                    GraphControl kontrola = new GraphControl(item);
                    stck_grafi.Children.Add(kontrola);
                }
            }
            List <OdločitvenoDrevoLibrary.Point> tocke;

            if (node.Type == NodeType.Event)
            {
                tocke = node.GetPoints(1, 1, true);
            }
            else
            {
                tocke = node.GetPoints(1, 1, false);
            }
            foreach (var item in tocke)
            {
                draw(item);
            }
            card_tree.Height = tocke.Count() * 40;
            //Canavas_drevo.Height = tocke.Sum(x => x.Y) * 5;
        }
Example #12
0
    void AddNode()
    {
        var node = new NodeValue();

        node.rect = new Rect(mousePosition.x, mousePosition.y, 100, 100);
        nodeRootList.Add(node);
    }
Example #13
0
 protected bool Equals(Vertex other)
 {
     return(Id == other.Id && string.Equals(NodeName, other.NodeName) &&
            NodeValue.Equals(other.NodeValue) &&
            Equals(IncomingNeighbours, other.IncomingNeighbours) &&
            Equals(OutgoingNeighbours, other.OutgoingNeighbours));
 }
 private void SetTreeNode(TreeNode treeNode, AuthorizationDS.PositionRow position)
 {
     treeNode.Text         = position.PositionName;
     treeNode.Value        = NodeValue.FromObject(position).ToString();
     treeNode.ShowCheckBox = false;
     treeNode.ImageUrl     = "~/Images/post.png";
 }
Example #15
0
 /// <summary>
 /// 建構子
 /// </summary>
 /// <param name="parentNode">父節點</param>
 /// <param name="leftNode">左子節點</param>
 /// <param name="rightNode">右子節點</param>
 /// <param name="value">數值</param>
 public Node(Node parentNode, Node leftNode, Node rightNode, NodeValue value)
 {
     ParentNode = parentNode;
     LeftNode   = leftNode;
     RightNode  = rightNode;
     this.Value = value;
 }
Example #16
0
            public Node(Node parent, byte k, int keySpace, NodeValue value)
            {
                if (parent == null)
                {
                    _depth = 0;
                    _k     = 0;
                }
                else
                {
                    _parent = parent;
                    _depth  = _parent._depth + 1;
                    _k      = k;
                }

                if (keySpace > 0)
                {
                    _children = new Node[keySpace];
                }

                _value = value;

                if ((_children == null) && (_value == null))
                {
                    throw new InvalidOperationException();
                }
            }
Example #17
0
    private static Color GetColor(NodeValue nodeValue, int selectNodeId)
    {
        Color color = Color.white;

        if (nodeValue.NodeType == (int)NODE_TYPE.SUB_TREE)
        {
            if (nodeValue.id == selectNodeId)
            {
                color = new Color(0, 1, 0, 0.35f);
            }
            else
            {
                color = new Color(0, 0, 1, 0.35f);
            }
            return(color);
        }

        if (nodeValue.isRootNode || nodeValue.subTreeEntry)
        {
            color = Color.green;
        }
        else if (nodeValue.id == selectNodeId)
        {
            color = new Color(0, 1, 0, 0.35f);
        }
        else
        {
            color = new Color(1f, 0.92f, 0.016f, 1f);
        }

        return(color);
    }
Example #18
0
 public void CalculateReturnsCorrectResultWithMainPath(Form form)
 {
     NodeValue?expected         = new NodeValue((int)form);
     var       fireDamage       = AilmentDamage(DamageType.Fire);
     var       coldDamage       = AilmentDamage(DamageType.Cold);
     var       transformedValue = new FunctionalValue(c => c.GetValues(form, coldDamage).Sum(), "");
     var       paths            = new[]
Example #19
0
    void DrawNodeWindow(int id)
    {
        NodeValue nodeValue = _nodeList[id];

        NodeEditor.Draw(nodeValue, BehaviorManager.Instance.CurrentSelectId);
        GUI.DragWindow();
    }
Example #20
0
    private void ResetScrollPos(List <NodeValue> nodeList)
    {
        if (nodeList.Count <= 0)
        {
            return;
        }

        NodeValue rightmostNode = null;
        NodeValue bottomNode    = null;

        for (int i = 0; i < nodeList.Count; ++i)
        {
            NodeValue nodeValue = nodeList[i];
            if (rightmostNode == null || (nodeValue.position.x > rightmostNode.position.x))
            {
                rightmostNode = nodeValue;
            }
            if (bottomNode == null || (nodeValue.position.y > bottomNode.position.y))
            {
                bottomNode = nodeValue;
            }
        }

        if ((rightmostNode.position.x + rightmostNode.position.width) > contentRect.width)
        {
            contentRect.width = rightmostNode.position.x + rightmostNode.position.width + 50;
        }

        if ((bottomNode.position.y + bottomNode.position.height) > contentRect.height)
        {
            contentRect.height = bottomNode.position.y + +bottomNode.position.height + 50;
        }
    }
Example #21
0
    // 绘制节点
    private void DrawNodeWindows(List <NodeValue> nodeList)
    {
        Action CallBack = () =>
        {
            for (int i = 0; i < nodeList.Count; i++)
            {
                NodeValue nodeValue = nodeList[i];
                string    name      = nodeValue.nodeName; //
                //if (string.IsNullOrEmpty(name))
                //{
                //    if (nodeValue.NodeType < (int)NODE_TYPE.CONDITION)
                //    {
                //        nodeValue.nodeName = NodeEditor.GetTitle((NODE_TYPE)nodeValue.NodeType);
                //    }
                //}

                name = string.Format("{0}_{1}", name, nodeValue.id);
                Rect rect = GUI.Window(i, RectTool.RectTToRect(nodeValue.position), DrawNodeWindow, name);
                nodeValue.position = RectTool.RectToRectT(rect);
                DrawToChildCurve(nodeValue);
            }
        };

        _treeNodeWindow.DrawWindow(CallBack);
    }
Example #22
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void writeNodesForPath(org.neo4j.values.virtual.NodeValue[] nodes) throws java.io.IOException
            internal virtual void WriteNodesForPath(NodeValue[] nodes)
            {
                NodeIndexes.reset(nodes.Length);
                foreach (NodeValue node in nodes)
                {
                    NodeIndexes.putIfAbsent(node.Id(), NodeIndexes.size());
                }

                int size = NodeIndexes.size();

                PackListHeader(size);
                if (size > 0)
                {
                    NodeValue node = nodes[0];
                    foreach (long id in NodeIndexes.keys())
                    {
                        int i = 1;
                        while (node.Id() != id)
                        {
                            node = nodes[i++];
                        }
                        node.WriteTo(this);
                    }
                }
            }
Example #23
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void writePath(org.neo4j.values.virtual.NodeValue[] nodes, org.neo4j.values.virtual.RelationshipValue[] relationships) throws java.io.IOException
            public override void WritePath(NodeValue[] nodes, RelationshipValue[] relationships)
            {
                //A path is serialized in the following form
                // Given path: (a {id: 42})-[r1 {id: 10}]->(b {id: 43})<-[r1 {id: 11}]-(c {id: 44})
                //The serialization will look like:
                //
                // {
                //    [a, b, c]
                //    [r1, r2]
                //    [1, 1, -2, 2]
                // }
                // The first list contains all nodes where the first node (a) is guaranteed to be the start node of
                // the path
                // The second list contains all edges of the path
                // The third list defines the path order, where every other item specifies the offset into the
                // relationship and node list respectively. Since all paths is guaranteed to start with a 0, meaning
                // that
                // a is the start node in this case, those are excluded. So the first integer in the array refers to the
                // position
                // in the relationship array (1 indexed where sign denotes direction) and the second one refers to
                // the offset
                // into the
                // node list (zero indexed) and so on.
                PackStructHeader(PATH_SIZE, PATH);

                WriteNodesForPath(nodes);
                WriteRelationshipsForPath(relationships);

                PackListHeader(2 * relationships.Length);
                if (relationships.Length == 0)
                {
                    return;
                }

                NodeValue node = nodes[0];

                for (int i = 1; i <= 2 * relationships.Length; i++)
                {
                    if (i % 2 == 0)
                    {
                        node = nodes[i / 2];
                        int index = NodeIndexes.getOrDefault(node.Id(), NO_SUCH_ID);
                        Pack(index);
                    }
                    else
                    {
                        RelationshipValue r = relationships[i / 2];
                        int index           = RelationshipIndexes.getOrDefault(r.Id(), NO_SUCH_ID);

                        if (node.Id() == r.StartNode().id())
                        {
                            Pack(index);
                        }
                        else
                        {
                            Pack(-index);
                        }
                    }
                }
            }
Example #24
0
    // 删除节点
    private void DeleteNode(int nodeId)
    {
        for (int i = 0; i < NodeList.Count; ++i)
        {
            NodeValue nodeValue = NodeList[i];
            if (nodeValue.id != nodeId)
            {
                continue;
            }

            RemoveParentNode(nodeValue.id);
            for (int j = 0; j < nodeValue.childNodeList.Count; ++j)
            {
                int       childId   = nodeValue.childNodeList[j];
                NodeValue childNode = GetNode(childId);
                childNode.parentNodeID = -1;
            }

            if (nodeValue.NodeType == (int)NODE_TYPE.SUB_TREE)
            {
                DeleteSubTreeChild(nodeValue.id);
            }

            NodeList.Remove(nodeValue);
            break;
        }
    }
Example #25
0
    private BehaviorTreeData StandardID(BehaviorTreeData data)
    {
        data.rootNodeId = IdTransition(data.fileName, data.rootNodeId);
        for (int i = 0; i < data.nodeList.Count; ++i)
        {
            NodeValue nodeValue = data.nodeList[i];

            nodeValue.id = IdTransition(data.fileName, nodeValue.id);
            if (nodeValue.parentNodeID >= 0)
            {
                nodeValue.parentNodeID = IdTransition(data.fileName, nodeValue.parentNodeID);
            }

            if (nodeValue.parentSubTreeNodeId >= 0)
            {
                nodeValue.parentSubTreeNodeId = IdTransition(data.fileName, nodeValue.parentSubTreeNodeId);
            }

            for (int j = 0; j < nodeValue.childNodeList.Count; ++j)
            {
                nodeValue.childNodeList[j] = IdTransition(data.fileName, nodeValue.childNodeList[j]);
            }

            for (int j = 0; j < nodeValue.ifJudgeDataList.Count; ++j)
            {
                nodeValue.ifJudgeDataList[j].nodeId = IdTransition(data.fileName, nodeValue.ifJudgeDataList[j].nodeId);
            }
        }

        return(data);
    }
Example #26
0
    private void RemoveParentNode(int nodeId)
    {
        NodeValue nodeValue = GetNode(nodeId);

        if (nodeValue.parentNodeID < 0)
        {
            return;
        }

        NodeValue parentNode = GetNode(nodeValue.parentNodeID);

        if (null != parentNode)
        {
            for (int i = 0; i < parentNode.childNodeList.Count; ++i)
            {
                int       childId   = parentNode.childNodeList[i];
                NodeValue childNode = GetNode(childId);
                if (childNode.id == nodeValue.id)
                {
                    parentNode.childNodeList.RemoveAt(i);
                    break;
                }
            }
        }

        nodeValue.parentNodeID = -1;
    }
Example #27
0
    public NodeValue GetNode(int nodeId)
    {
        for (int i = 0; i < NodeList.Count; ++i)
        {
            NodeValue nodeValue = NodeList[i];
            if (nodeValue.id == nodeId)
            {
                return(nodeValue);
            }
        }

        foreach (var kv in _configDataDic)
        {
            BehaviorTreeData treeData = kv.Value;

            for (int i = 0; i < treeData.nodeList.Count; ++i)
            {
                NodeValue nodeValue = treeData.nodeList[i];
                if (nodeValue.id == nodeId)
                {
                    return(nodeValue);
                }
            }
        }

        return(null);
    }
Example #28
0
    private void OpenSubTree(int nodeId)
    {
        if (nodeId < 0)
        {
            _currentOpenSubTreeId = nodeId;
            return;
        }

        NodeValue nodeValue = GetNode(nodeId);

        if (nodeValue.NodeType != (int)NODE_TYPE.SUB_TREE)
        {
            return;
        }

        if (nodeValue.subTreeType == (int)SUB_TREE_TYPE.CONFIG && string.IsNullOrEmpty(nodeValue.subTreeConfig))
        {
            if (EditorUtility.DisplayDialog("警告", "配置文件为空", "确定"))
            {
                return;
            }
        }

        _currentOpenSubTreeId = nodeId;
    }
Example #29
0
    private void DebugNodeParentInfo(int nodeId)
    {
        if (nodeId < 0)
        {
            return;
        }

        StringBuilder sb        = new StringBuilder();
        NodeValue     nodeValue = GetNode(nodeId);

        while (null != nodeValue)
        {
            sb.AppendFormat("{0}->", nodeValue.id);

            NodeValue parentNode = null;
            if (nodeValue.parentNodeID < 0 && nodeValue.parentSubTreeNodeId > 0)
            {
                parentNode = GetNode(nodeValue.parentSubTreeNodeId);
            }
            else
            {
                parentNode = GetNode(nodeValue.parentNodeID);
            }
            nodeValue = parentNode;
        }

        //ProDebug.Logger.LogError(//ProDebug.Logger.StrConcat("ParentInfo:", sb));
    }
Example #30
0
    private NodeRoot GetLeafNode(NodeValue nodeValue)
    {
        string componentName = nodeValue.componentName;

        NodeRoot nodeRoot = null;

        switch (componentName)
        {
        case "NodeActionCooking":
            nodeRoot = new NodeActionCooking();
            break;

        case "NodeActionEat":
            nodeRoot = new NodeActionEat();
            break;

        case "NodeActionMove":
            nodeRoot = new NodeActionMove();
            break;

        case "NodeConditionHasFood":
            nodeRoot = new NodeConditionHasFood();
            break;

        case "NodeConditionHungry":
            nodeRoot = new NodeConditionHungry();
            break;
        }

        return(nodeRoot);
    }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="data"></param>
 /// <param name="itemName"></param>
 /// <returns></returns>
 private string OutputDataValue(NodeValue[] data, string itemName)
 {
     if (data != null && data.Length > 0 && !string.IsNullOrEmpty(itemName))
     {
         List<NodeValue> list = new List<NodeValue>();
         list.AddRange(data);
         NodeValue v = list.Find(new Predicate<NodeValue>(delegate(NodeValue sender)
         {
             return (sender != null) && string.Equals(sender.Name, itemName, StringComparison.InvariantCultureIgnoreCase);
         }));
         if (v != null)
         {
             return v.Value;
         }
     }
     return null;
 }
Example #32
0
        public static NodeValue Parse(string strValue)
        {
            NodeValue result = new NodeValue();
            if (strValue.StartsWith("1")) {
                result.IsActive = true;
            } else {
                result.IsActive = false;
            }

            if (strValue.Substring(1, 2).Equals("OU")) {
                result.OType = ValueType.OU;
            } else {
                result.OType = ValueType.Position;
            }

            result.ObjectId = int.Parse(strValue.Substring(3));
            return result;
        }
Example #33
0
 public static NodeValue FromObject(AuthorizationDS.PositionRow position)
 {
     NodeValue result = new NodeValue();
     result.OType = ValueType.Position;
     result.ObjectId = position.PositionId;
     result.IsActive = position.IsActive;
     return result;
 }
Example #34
0
 public static NodeValue FromObject(AuthorizationDS.OrganizationUnitRow organizationUnit)
 {
     NodeValue result = new NodeValue();
     result.ObjectId = organizationUnit.OrganizationUnitId;
     result.IsActive = organizationUnit.IsActive;
     result.OType = ValueType.OU;
     return result;
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <param name="dict"></param>
        private void SetOutputData(NodeValue[] data, ref Dictionary<string, List<string>> dict)
        {
            if (data != null && data.Length > 0)
            {
                string classID = this.OutputDataValue(data, "ClassID");
                string catalogID = this.OutputDataValue(data, "CatalogID");
                string studentID = this.OutputDataValue(data, "StudentID");

                string key = string.Format("{0}_{1}", classID, catalogID);
                if (dict.ContainsKey(key))
                {
                    List<string> list = dict[key];
                    if (list == null)
                    {
                        list = new List<string>();
                    }
                    list.Add(studentID);
                    dict[key] = list;
                }
                else
                {
                    List<string> list = null;
                    if (!string.IsNullOrEmpty(studentID))
                    {
                        list = new List<string>();
                        list.Add(studentID);
                    }
                    dict[key] = list;
                }
            }
        }
Example #36
0
        private void ReadFromNode(XmlReader reader)
        {
            while (reader.Read())
            {
                if (!reader.HasAttributes)
                    continue;

                var nodeName = StringUtils.ToCamelCase(reader.LocalName);
                var node = new NodeValue();
                while (reader.MoveToNextAttribute())
                    node.AddAttr(reader.LocalName, reader.Value);
                reader.MoveToElement();

                _nodes.Add(nodeName, node);
            }
        }
Example #37
0
        public NodeValue CalculateValue(Player currentPlayer)
        {
            if (_valueCalculated)
            {
                return _value;
            }

            _valueCalculated = true;
            var score = 0;
            if (Children.Any())
            {
                if (State.CurrentPlayer == currentPlayer)
                {
                    score = Children.Select(v => v.CalculateValue(currentPlayer)).Max().Score;
                }
                else
                {
                    score = Children.Select(v => v.CalculateValue(currentPlayer)).Min().Score;
                }

                _value = new NodeValue() { Score = score, ScoreSum = Children.Select(v => v.CalculateValue(currentPlayer).Score).Sum() };
            }
            else
            {
                if (State.Winner == currentPlayer.Block)
                {
                    score = 1000 - depth;
                }
                else if (State.Winner != BlockState.Empty)
                {
                    score = -(1000 - depth);
                }
                else
                {
                    score = Heuristic(currentPlayer);
                }

                _value = new NodeValue { Score = score, ScoreSum = 0 };
            }

            return _value;
        }