Ejemplo n.º 1
0
        public void ExportXml(TreeViewItem item)
        {
            exportXmlDocument = new XmlDocument();

            using (FileStream stream = new FileStream("QueryTreeViewNode.xml", FileMode.Create))
            {
                XmlDeclaration xmlDeclaration = exportXmlDocument.CreateXmlDeclaration("1.0", "UTF-8", null);
                exportXmlDocument.AppendChild(xmlDeclaration);

                NodeInfo ni = new NodeInfo() { Query = (string)item.Header, IsExpanded = item.IsExpanded };
                XmlElement xe = exportXmlDocument.CreateElement("item");
                xe.SetAttribute("name", ni.Query);

                if (item.IsExpanded)
                {
                    xe.SetAttribute("expand", "true");
                }
                // ルートノードをXmlDocumentに追加
                exportXmlDocument.AppendChild(xe);

                // 再帰的にツリーノードを読み込み、XmlDocument構築
                RecursiveTreeViewItemToXml(item, xe);

                // ファイルに出力
                exportXmlDocument.Save(stream);
            }
        }
Ejemplo n.º 2
0
 public void AddFadingNode(FNode node, float showDuration)
 {
     NodeInfo info = new NodeInfo ();
     info.node = node;
     info.showDuration = showDuration;
     infos.Add (info);
 }
        public ContextMenuStrip CreateMenu(NodeInfo node)
        {
            ContextMenuStrip menu = new ContextMenuStrip();

            foreach (ContextAction action in this.actions)
            {
                if ((action.Controls.Count > 0) && !action.Controls.Contains(this.currentControl))
                {
                    continue;
                }

                if (!action.NoSelection)
                {
                    if (node == null)
                    {
                        continue;
                    }

                    if ((action.NodeType != 0) && !action.NodeType.HasFlag(node.Type))
                    {
                        continue;
                    }

                    if ((action.Predicate != null) && !action.Predicate(node))
                    {
                        continue;
                    }
                }

                ToolStripMenuItem item = this.CreateMenuItem(action, node);
                menu.Items.Add(item);
            }

            return menu;
        }
Ejemplo n.º 4
0
		public void GetData(NodeInfo nodeInfo, CellInfo[] cellData)
		{
//			int commentCol = ShowLinks ? (int) FavoritesGridColumns.Comment
//				: (int) FavoritesGridColumns.Name;

			cellData[(int)FavoritesGridColumns.Name].Text = Name;
			cellData[(int)FavoritesGridColumns.Name].ImageIndex =
				Links.Count > 0
					? FavoritesDummyForm.Instance.FolderStartIndex
					: FavoritesDummyForm.Instance.EmptyFolderStartIndex;

			nodeInfo.Highlight = true;

//			if (ShowLinks)
//			{
//				cellData[(int) FavoritesGridColumns.ColSubj].Image = -1;
//				cellData[(int) FavoritesGridColumns.ColSubj].Text = string.Empty;
//				cellData[(int) FavoritesGridColumns.ColAuthor].Image = -1;
//				cellData[(int) FavoritesGridColumns.ColAuthor].Text = string.Empty;
//				cellData[(int) FavoritesGridColumns.ColDate].Image = -1;
//				cellData[(int) FavoritesGridColumns.ColDate].Text = string.Empty;
//				cellData[(int) FavoritesGridColumns.ColForum].Image = -1;
//				cellData[(int) FavoritesGridColumns.ColForum].Text = string.Empty;
//			}
//			cellData[commentCol].Text = Comment.ToString();
//			cellData[commentCol].Image = -1;

			cellData[(int)FavoritesGridColumns.Comment].Text = Comment;
		}
Ejemplo n.º 5
0
 public Position(NodeInfo nodeInfo, int i)
 {
     left = double.Parse(nodeInfo.data.ControlList[i].Position.Left);
     top = double.Parse(nodeInfo.data.ControlList[i].Position.Top);
     right = double.Parse(nodeInfo.data.ControlList[i].Position.Right);
     bottom = double.Parse(nodeInfo.data.ControlList[i].Position.Bottom);
 }
Ejemplo n.º 6
0
		public NodeInfoCollection GetChildren (NodeInfo root)
		{
			Trace.WriteLineIf (info.Enabled, "GroupingNodeFinder.GetChildren");
			NodeInfoCollection collection = null;

			switch (root.NodeType) {
			case NodeTypes.Type:
				GroupChildNodes (root);
				collection = new NodeInfoCollection ();
				collection.AddRange ((NodeInfoCollection)nodes[""]);
				AddGroup (nestedClasses, collection, root);
				AddGroup (baseNode, collection, root);
				AddGroup (interfacesNode, collection, root);
				AddGroup (constructorsNode, collection, root);
				AddGroup (methodsNode, collection, root);
				AddGroup (fieldsNode, collection, root);
				AddGroup (propertiesNode, collection, root);
				AddGroup (eventsNode, collection, root);
				return collection;
			case NodeTypes.Other:
				if (root.Description is GroupingInfo) {
					Trace.WriteLineIf (info.Enabled, "Found GroupingInfo");
					GroupingInfo g = (GroupingInfo) root.Description;
					collection = (NodeInfoCollection) nodes[g.Group];
					return collection;
				}
				break;
			}

			return finder.GetChildren (root);
		}
Ejemplo n.º 7
0
        public void CompareResults(List<NodeInfo> nodes, string outFile)
        {
            int pos = 0;
            XmlReader reader = XmlReader.Create(outFile);
            IXmlLineInfo li = (IXmlLineInfo)reader;
            XmlNodeType previousNodeType = XmlNodeType.None;
            using (reader) {
                while (reader.Read()) {
                    if (reader.NodeType == XmlNodeType.Whitespace ||
                        reader.NodeType == XmlNodeType.SignificantWhitespace ||
                        reader.NodeType == XmlNodeType.XmlDeclaration)
                        continue;

                    NodeInfo node = new NodeInfo(reader);
                    if (pos >= nodes.Count) {
                        throw new ApplicationException("Found too many nodes");
                    }
                    NodeInfo other = nodes[pos++];
                    if (!node.Equals(other)) {
                        throw new ApplicationException(
                                string.Format("Mismatching nodes at line {0},{1}",
                                li.LineNumber, li.LinePosition));
                    }
                    previousNodeType = node.NodeType;
                }
            }
        }
Ejemplo n.º 8
0
		protected override void AddTypeChildren (NodeInfoCollection c, NodeInfo parent, Type type)
		{
			object instance = parent.ReflectionInstance;

			foreach (MemberInfo mi in GetMembers (type)) {
				AddNode (c, parent, mi, instance);
			}
		}
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NodeInfoEventArgs"/> class.
        /// </summary>
        /// <param name="nodeInfo">Node info.</param>
        public NodeInfoEventArgs(NodeInfo nodeInfo)
        {
            if (nodeInfo == null)
            {
                throw new ArgumentNullException("nodeInfo");
            }

            NodeInfo = nodeInfo;
        }
Ejemplo n.º 10
0
		public override NodeInfoCollection GetChildren (NodeInfo root)
		{
			// We don't want an infinite loop; quite showing children
			Trace.WriteLineIf (info.Enabled, "GetChildren for root.NodeType=" + root.NodeType);
			if (!CanShowChildren (root))
				return new NodeInfoCollection();

			return base.GetChildren (root);
		}
Ejemplo n.º 11
0
		void IGetData.GetData(NodeInfo nodeInfo, CellInfo[] cellData)
		{
			var om = _provider.GetRequiredService<IOutboxManager>();
			cellData[0].Text = Description;
			cellData[0].ImageIndex = ImageIndex;
			cellData[1].Text = $"{(om.NewMessages.Count == 0 ? string.Empty : om.NewMessages.Count.ToString())}/{(om.RateMarks.Count == 0 ? string.Empty : om.RateMarks.Count.ToString())}/{(om.DownloadTopics.Count == 0 ? string.Empty : om.DownloadTopics.Count.ToString())}";

			nodeInfo.Highlight = (om.NewMessages.Count > 0)
				|| (om.RateMarks.Count > 0) || (om.DownloadTopics.Count > 0);
		}
Ejemplo n.º 12
0
		static int CountType (NodeInfo root, NodeTypes type)
		{
			int count = 0;
			while (root != null) {
				if (root.NodeType == type)
					++count;
				root = root.Parent;
			}
			return count;
		}
Ejemplo n.º 13
0
		static bool InHistory (int count, NodeInfo root, params NodeTypes[] types)
		{
			while ((root != null) && (count-- != 0)) {
				foreach (NodeTypes t in types)
					if (root.NodeType == t)
						return true;
				root = root.Parent;
			}
			return false;
		}
Ejemplo n.º 14
0
		void IGetData.GetData(NodeInfo nodeInfo, CellInfo[] cellData)
		{
			cellData[OutboxManager.ForumColumn].Text = Source;
			cellData[OutboxManager.ForumColumn].ImageIndex = 
				OutboxImageManager.RegetTopicImageIndex;

			cellData[OutboxManager.SubjectColun].Text = Hint;
			
			cellData[OutboxManager.AddInfoColumn].Text = "ID = " + MessageID;
		}
Ejemplo n.º 15
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="ReducedErrorPruning"/> class.
        /// </summary>
        /// 
        /// <param name="tree">The tree to be prunned.</param>
        /// <param name="inputs">The pruning set inputs.</param>
        /// <param name="outputs">The pruning set outputs.</param>
        /// 
        public ReducedErrorPruning(DecisionTree tree, double[][] inputs, int[] outputs)
        {
            this.tree = tree;
            this.inputs = inputs;
            this.outputs = outputs;
            this.info = new Dictionary<DecisionNode, NodeInfo>();
            this.actual = new int[outputs.Length];

            foreach (var node in tree)
                info[node] = new NodeInfo();

            for (int i = 0; i < inputs.Length; i++)
                trackDecisions(tree.Root, inputs[i], i);
        }
Ejemplo n.º 16
0
		public string GetDescription (NodeInfo node)
		{
			string r = "";
			switch (node.NodeType) {
			case NodeTypes.Type:
				r = GetTypeDescription ((Type)node.ReflectionObject, node.ReflectionInstance);
				break;
			case NodeTypes.BaseType:
				r = GetBaseTypeDescription ((Type)node.ReflectionObject, node.ReflectionInstance);
				break;
			case NodeTypes.Interface:
				r = GetInterfaceDescription ((Type)node.ReflectionObject, node.ReflectionInstance);
				break;
			case NodeTypes.Field:
				r = GetFieldDescription ((FieldInfo)node.ReflectionObject, node.ReflectionInstance);
				break;
			case NodeTypes.Constructor:
				r = GetConstructorDescription ((ConstructorInfo)node.ReflectionObject, node.ReflectionInstance);
				break;
			case NodeTypes.Method:
				r = GetMethodDescription ((MethodInfo) node.ReflectionObject, node.ReflectionInstance);
				break;
			case NodeTypes.Parameter:
				r = GetParameterDescription ((ParameterInfo) node.ReflectionObject, node.ReflectionInstance);
				break;
			case NodeTypes.Property:
				r = GetPropertyDescription ((PropertyInfo) node.ReflectionObject, node.ReflectionInstance);
				break;
			case NodeTypes.Event:
				r = GetEventDescription ((EventInfo) node.ReflectionObject, node.ReflectionInstance);
				break;
			/*
			case NodeTypes.CustomAttributeProvider:
				r = GetCustomAttributeProviderDescription ((ICustomAttributeProvider) node.ReflectionObject, node.ReflectionInstance);
				break;
			 */
			case NodeTypes.Other:
			case NodeTypes.Alias:
				r = GetOtherDescription (node);
				break;
			case NodeTypes.ReturnValue:
				r = GetReturnValueDescription (node);
				break;
			default:
				Debug.Assert (false, 
					String.Format ("Unhandled NodeInfo value: {0}", node.NodeType));
				break;
			}
			return r;
		}
Ejemplo n.º 17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NodeInfoEventArgs"/> class.
        /// </summary>
        /// <param name="nodeInfo">Node info.</param>
        /// <param name="message">XML message.</param>
        public NodeInfoEventArgs(NodeInfo nodeInfo, XmlDocument message)
        {
            if (nodeInfo == null)
            {
                throw new ArgumentNullException("nodeInfo");
            }

            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            NodeInfo = nodeInfo;
            Message = message;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NodeInfoEventArgs"/> class.
        /// </summary>
        /// <param name="nodeInfo">Node info.</param>
        /// <param name="remark">Remark string.</param>
        public NodeInfoEventArgs(NodeInfo nodeInfo, string remark)
        {
            if (nodeInfo == null)
            {
                throw new ArgumentNullException("nodeInfo");
            }

            if (string.IsNullOrEmpty(remark))
            {
                throw new ArgumentNullException("remark");
            }

            NodeInfo = nodeInfo;
            Remark = remark;
        }
Ejemplo n.º 19
0
 public ClusterMetadata GetClusterMetadata()
 {
     var req = CreateRequest("GetClusterMetadata");
     var resp = SendReceive(req);
     var sz = resp.ReadInt32();
     var list = new List<NodeInfo>(sz);
     for (int i = 0; i < sz; i++)
     {
         var node = new NodeInfo();
         node.Address = resp.ReadString();
         node.IsMaster = resp.ReadBoolean();
         list.Add(node);
     }
     return new ClusterMetadata(list);
 }
Ejemplo n.º 20
0
        private static NodeInfo createNodeInfo(DateTime? dt = null)
        {
            NodeInfo node = new NodeInfo();

            node.DiskAvailableFreeSpace = 100500;
            node.DiskUsage = 43.5;
            node.MemAvailable = 54.3;
            node.MemUsage = 34.2;
            node.Net = 3.14;
            node.Offline = false;
            node.ProcUsage = 76.8;
            node.SandBoxTotalSize = 455000;
            node.TimeSnapshot = dt ?? DateTime.Now;

            return node;
        }
Ejemplo n.º 21
0
		void Save (List<NodeInfo> info, TreeIter it)
		{
			do {
				object id = tree.Model.GetValue (it, idColumn);
				NodeInfo ni = new NodeInfo ();
				ni.Id = id;
				ni.Expanded = tree.GetRowExpanded (tree.Model.GetPath (it));
				ni.Selected = tree.Selection.IterIsSelected (it);
				info.Add (ni);
				TreeIter cit;
				if (tree.Model.IterChildren (out cit, it)) {
					ni.ChildInfo = new List<NodeInfo> ();
					Save (ni.ChildInfo, cit);
				}
			}
			while (tree.Model.IterNext (ref it));
		}
Ejemplo n.º 22
0
		void SaveChildren (List<NodeInfo> info, TreePosition it)
		{
			int num = tree.DataSource.GetChildrenCount (it);
			for (int n=0; n<num; n++) {
				var child = tree.DataSource.GetChild (it, n);
				object id = tree.DataSource.GetValue (child, idColumn);
				NodeInfo ni = new NodeInfo ();
				ni.Id = id;
				ni.Expanded = tree.IsRowExpanded (child);
				ni.Selected = tree.IsRowSelected (child);
				info.Add (ni);
				if (tree.DataSource.GetChildrenCount (child) > 0) {
					ni.ChildInfo = new List<NodeInfo> ();
					SaveChildren (ni.ChildInfo, child);
				}
			}
		}
Ejemplo n.º 23
0
		private void AddNode (NodeInfoCollection c, NodeInfo parent, MemberInfo mi, object instance)
		{
			// FIXME: there has to be a cleaner way than this...
			// Don't add node if we don't want to display them.
			bool quit = false;
			switch (mi.MemberType) {
				case MemberTypes.Constructor:
					quit = !ShowConstructors;
					break;
				case MemberTypes.Event:
					quit = !ShowEvents;
					break;
				case MemberTypes.Field:
					quit = !ShowFields;
					break;
				case MemberTypes.Method:
					quit = !ShowMethods;
					break;
				case MemberTypes.Property:
					quit = !ShowProperties;
					break;
				case MemberTypes.TypeInfo:
					// either a Base type or an Interface
					// this is bound to produce buggy behavior...
					quit = !ShowBase && !ShowInterfaces;
					break;

				// case MemberTypes.NestedType
				// we don't break out nested types yet
			}

			if (quit)
				return;

			if (!seenReflectionObjects.Found (mi)) {
				seenReflectionObjects.Add (mi);
				NodeInfo n = new NodeInfo (parent, mi, instance);
				c.Add (n);
			}
			else {
				NodeInfo n = new NodeInfo (parent, "Seen: " + mi.ToString());
				n.NodeType = NodeTypes.Alias;
				c.Add (n);
			}
		}
Ejemplo n.º 24
0
 internal NodeInfo Parse()
 {
     var rslt = new NodeInfo();
     rslt.Name = this.Name;
     if (this.Ref_Workflow != null)
         rslt.RefWorkflow = this.Ref_Workflow.Parse();
     if (Action != null)
         rslt.Actions = this.Action.Parse();
     if (this.Variable != null)
         rslt.Variable = this.Variable.Parse();
     if (this.Init != null)
         rslt.Init = this.Init.Parse();
     if (this.Form != null)
         rslt.Form = this.Form.Parse();
     if (this.Translation != null)
         rslt.Translation = this.Translation.Parse();
     return rslt;
 }
Ejemplo n.º 25
0
		protected override void AddTypeChildren (NodeInfoCollection c, NodeInfo parent, Type type)
		{
			object instance = parent.ReflectionInstance;

			// System.Type information
			if (ShowTypeProperties)
				c.Add (new NodeInfo (parent, 
						new NodeGroup (typeInformation, type,
							new NodeGrouper (GetTypeInformationChildren))));

			// Base Type
			if (ShowBase)
				c.Add (new NodeInfo (parent, NodeTypes.BaseType, type.BaseType, type.BaseType));

			// Implemented Interfaces
			if (ShowInterfaces)
				foreach (Type t in type.GetInterfaces())
					c.Add (new NodeInfo (parent, NodeTypes.Interface, t, instance));

			// Constructors
			if (ShowConstructors)
				foreach (ConstructorInfo ci in type.GetConstructors (BindingFlags))
					c.Add (new NodeInfo (parent, ci, instance));

			// Methods
			if (ShowMethods)
				foreach (MethodInfo mi in type.GetMethods (BindingFlags))
					c.Add (new NodeInfo (parent, mi, instance));

			// Fields
			if (ShowFields)
				foreach (FieldInfo fi in type.GetFields (BindingFlags))
					c.Add (new NodeInfo (parent, fi, instance));

			// Properties
			if (ShowProperties)
				foreach (PropertyInfo pi in type.GetProperties (BindingFlags))
					c.Add (new NodeInfo (parent, pi, instance));

			// Events
			if (ShowEvents)
				foreach (EventInfo ei in type.GetEvents (BindingFlags))
					c.Add (new NodeInfo (parent, ei, instance));
		}
Ejemplo n.º 26
0
        // none Leveller
        public void preorder(Node s, string Arrow, int rootLevel)
        {
            if (s != null)
            {
                // return node info
                #region return node info
                // cout << s.text
                NodeInfo preorderNodeInfo = new NodeInfo();
                preorderNodeInfo.StartLevel = rootLevel;
                preorderNodeInfo.EndLevel = s.Order;
                preorderNodeInfo.Text = s.Text;
                preorderNodeInfo.Arrow = Arrow;
                arrNodeInfo.Add(preorderNodeInfo);
                #endregion

                preorder(s.Left, "Left", s.Order);
                preorder(s.Right, "Right", s.Order);
            }
        }
Ejemplo n.º 27
0
		void Save (ICollection<NodeInfo> collection, TreeIter iter)
		{
			do {
				TreeIter child;

				var node = new NodeInfo {
					Expanded = tree.GetRowExpanded (tree.Model.GetPath (iter)),
					Selected = tree.Selection.IterIsSelected (iter),
					Id = tree.Model.GetValue (iter, idColumn)
				};

				collection.Add (node);

				if (tree.Model.IterChildren (out child, iter)) {
					node.ChildInfo = new List<NodeInfo> ();
					Save (node.ChildInfo, child);
				}
			} while (tree.Model.IterNext (ref iter));
		}
Ejemplo n.º 28
0
        public NodeInfoViewModel(NodeInfo nodeInfo)
        {
            Ensure.ArgumentNotNull(nodeInfo, "nodeInfo");

            Name = nodeInfo.Name;
            HostName = nodeInfo.Hostname;
            HttpAddress = nodeInfo.HttpAddress;
            OS = new BindableCollection<ElasticPropertyViewModel>();
            if (nodeInfo.OS != null)
                foreach (var val in nodeInfo.OS)
                    OS.Add(new ElasticPropertyViewModel {Label = val.Key, Value = val.Value});
            Settings = new BindableCollection<ElasticPropertyViewModel>();
            if (nodeInfo.Settings != null)
                foreach (var val in nodeInfo.Settings)
                    Settings.Add(new ElasticPropertyViewModel {Label = val.Key, Value = val.Value});
            CPU = new BindableCollection<ElasticPropertyViewModel>();
            if (nodeInfo.CPU != null)
                foreach (var val in nodeInfo.CPU)
                    CPU.Add(new ElasticPropertyViewModel {Label = val.Key, Value = val.Value});
        }
Ejemplo n.º 29
0
		private void ComboBoxDrawItem(object sender, DrawItemEventArgs e)
		{
			e.DrawBackground();

			if (e.Index < 0)
				return;

			var bounds = e.Bounds;
			var cont = (FeatureContainer)_comboBox.Items[e.Index];

			bounds.X += _leftMargin + cont.Level * Config.Instance.ForumDisplayConfig.GridIndent;

			var cd = new CellInfo[5];
			var ni = new NodeInfo(_comboBox.ForeColor, _comboBox.BackColor, _comboBox.Font, false);
			((IGetData)cont.Feature).GetData(ni, cd);

			if (cd[0].Image != null)
			{
				e.Graphics.DrawImage(
					cd[0].Image,
					bounds.X,
					bounds.Y,
					cd[0].Image.Width,
					cd[0].Image.Height);

				bounds.X += cd[0].Image.Width;
			}

			var brush =
				(e.State & DrawItemState.Selected) == 0
					? _comboBox.DroppedDown
						? new SolidBrush(ni.ForeColor)
						: SystemBrushes.ControlText
					: SystemBrushes.HighlightText;

			e.Graphics.DrawString(
				cont.Feature.ToString(),
				ni.Highlight ? new Font(_comboBox.Font, FontStyle.Bold) : _comboBox.Font,
				brush, 
				bounds);
		}
Ejemplo n.º 30
0
		private static bool CanShowChildren (NodeInfo node)
		{
			Trace.WriteLineIf (info.Enabled, "CanShowChildren");
			if (node.Parent != null) {
				if (node.NodeType == NodeTypes.Parameter)
					return true;
				if (node.NodeType == NodeTypes.Other)
					return true;
				if (InHistory (2, node, NodeTypes.ReturnValue) && 
						(CountType(node, NodeTypes.ReturnValue) < 2))
					return true;

				NodeTypes t = node.Parent.NodeType;
				// Console.WriteLine ("** CanShowChildren: {0}", t);
				switch (t) {
				case NodeTypes.Type:
				// case NodeTypes.Other:
					return true;
				default:
					return false;
				}
			}
			return true;
		}
Ejemplo n.º 31
0
        public async Task CreateChannels(ActorTester[] froms, ActorTester[] tos)
        {
            var miner       = froms[0].BitcoinRPC;
            int blockToMine = 0;

            bool[] established = froms.Select(_ => false).ToArray();
            while (true)
            {
                if (blockToMine != 0)
                {
                    await miner.GenerateAsync(blockToMine);
                    await WaitLNSynched(miner, tos.Concat(froms).ToArray());

                    blockToMine = 0;
                }
                try
                {
                    for (int i = 0; i < froms.Length; i++)
                    {
                        var to   = tos[i];
                        var from = froms[i];
                        if (established.All(_ => _))
                        {
                            return;
                        }
                        if (established[i])
                        {
                            continue;
                        }

                        var toInfo = await to.RPC.GetInfoAsync();

                        var skippedStates = new[] { "ONCHAIN", "CHANNELD_SHUTTING_DOWN", "CLOSINGD_SIGEXCHANGE", "CLOSINGD_COMPLETE", "FUNDING_SPEND_SEEN" };
                        var channel       = (await from.RPC.ListPeersAsync())
                                            .Where(p => p.Id == toInfo.Id)
                                            .SelectMany(p => p.Channels)
                                            .Where(c => !skippedStates.Contains(c.State ?? ""))
                                            .FirstOrDefault();
                        switch (channel?.State)
                        {
                        case null:
                            var toNodeInfo = new NodeInfo(toInfo.Id, to.P2PHost, toInfo.Port);
                            await from.RPC.ConnectAsync(toNodeInfo);

                            var funds = await from.RPC.ListFundsAsync();

                            if (funds.Outputs.Any(o => o.Status == "unconfirmed"))
                            {
                                blockToMine = 1;
                            }
                            else if (!funds.Outputs.Any(o => o.Status == "confirmed"))
                            {
                                var address = await from.RPC.NewAddressAsync();

                                await miner.SendToAddressAsync(address, Money.Coins(49.0m));

                                blockToMine = 7;
                            }
                            else
                            {
                                await from.RPC.FundChannelAsync(toNodeInfo, Money.Satoshis(16777215));

                                blockToMine = 7;
                            }
                            break;

                        case "CHANNELD_AWAITING_LOCKIN":
                            blockToMine = 1;
                            break;

                        case "CHANNELD_NORMAL":
                            Console.WriteLine($"// Channel established: {from} => {to}");
                            established[i] = true;
                            break;

                        default:
                            throw new NotSupportedException(channel?.State ?? "");
                        }
                    }
                }
                catch (RPCException ex) when(ex.RPCCode == RPCErrorCode.RPC_WALLET_INSUFFICIENT_FUNDS)
                {
                    blockToMine = 101;
                }
            }
        }
Ejemplo n.º 32
0
 private int Id(NodeInfo nodeInfo)
 {
     return(_idMap[nodeInfo]);
 }
Ejemplo n.º 33
0
        public void 开启光照连续取样()
        {
            NodeInfo TheNode = XML_获取设备节点信息("无线光照度采集");

            CM_IOT_IDC_StartContinuousSampling(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr, 1000, 1);
        }
Ejemplo n.º 34
0
        public void 暂停窗帘()
        {
            NodeInfo TheNode = XML_获取设备节点信息("窗帘");

            CM_IOT_EC_Ctrl(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr, 0);
        }
Ejemplo n.º 35
0
        private void TranslateChannelAndContent(List <NodeInfo> nodeInfoList, int targetPublishmentSystemID, int parentID, ETranslateType translateType, bool isChecked, int checkedLevel, List <string> nodeIndexNameList, List <string> filePathList)
        {
            if (nodeInfoList == null || nodeInfoList.Count == 0)
            {
                return;
            }

            if (nodeIndexNameList == null)
            {
                nodeIndexNameList = DataProvider.NodeDao.GetNodeIndexNameList(targetPublishmentSystemID);
            }

            if (filePathList == null)
            {
                filePathList = DataProvider.NodeDao.GetAllFilePathByPublishmentSystemId(targetPublishmentSystemID);
            }

            var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemID);

            foreach (NodeInfo oldNodeInfo in nodeInfoList)
            {
                var nodeInfo = new NodeInfo(oldNodeInfo);
                nodeInfo.PublishmentSystemId = targetPublishmentSystemID;
                nodeInfo.ParentId            = parentID;
                nodeInfo.ContentNum          = 0;
                nodeInfo.ChildrenCount       = 0;

                nodeInfo.AddDate = DateTime.Now;
                if (IsDeleteAfterTranslate.Visible && EBooleanUtils.Equals(IsDeleteAfterTranslate.SelectedValue, EBoolean.True))
                {
                    nodeIndexNameList.Add(nodeInfo.NodeIndexName);
                }

                else if (!string.IsNullOrEmpty(nodeInfo.NodeIndexName) && nodeIndexNameList.IndexOf(nodeInfo.NodeIndexName) == -1)
                {
                    nodeIndexNameList.Add(nodeInfo.NodeIndexName);
                }
                else
                {
                    nodeInfo.NodeIndexName = string.Empty;
                }

                if (!string.IsNullOrEmpty(nodeInfo.FilePath) && filePathList.IndexOf(nodeInfo.FilePath) == -1)
                {
                    filePathList.Add(nodeInfo.FilePath);
                }
                else
                {
                    nodeInfo.FilePath = string.Empty;
                }

                var insertedNodeID = DataProvider.NodeDao.InsertNodeInfo(nodeInfo);

                if (translateType == ETranslateType.All)
                {
                    TranslateContent(targetPublishmentSystemInfo, oldNodeInfo.NodeId, insertedNodeID, isChecked, checkedLevel);
                }

                if (insertedNodeID != 0)
                {
                    var orderByString        = ETaxisTypeUtils.GetChannelOrderByString(ETaxisType.OrderByTaxis);
                    var childrenNodeInfoList = DataProvider.NodeDao.GetNodeInfoList(oldNodeInfo, 0, "", EScopeType.Children, orderByString);
                    if (childrenNodeInfoList != null && childrenNodeInfoList.Count > 0)
                    {
                        TranslateChannelAndContent(childrenNodeInfoList, targetPublishmentSystemID, insertedNodeID, translateType, isChecked, checkedLevel, nodeIndexNameList, filePathList);
                    }

                    if (isChecked)
                    {
                        CreateManager.CreateChannel(targetPublishmentSystemInfo.PublishmentSystemId, insertedNodeID);
                    }
                }
            }
        }
        public override void BuildNode(ITreeBuilder builder, object dataObject, NodeInfo nodeInfo)
        {
            if (!builder.Options["ShowVersionControlOverlays"])
            {
                return;
            }

            // Add status overlays

            if (dataObject is WorkspaceObject)
            {
                WorkspaceObject ce  = (WorkspaceObject)dataObject;
                Repository      rep = VersionControlService.GetRepository(ce);
                if (rep != null)
                {
                    rep.GetDirectoryVersionInfo(ce.BaseDirectory, false, false);
                    AddFolderOverlay(rep, ce.BaseDirectory, nodeInfo, false);
                }
                return;
            }
            else if (dataObject is ProjectFolder)
            {
                ProjectFolder ce = (ProjectFolder)dataObject;
                if (ce.ParentWorkspaceObject != null)
                {
                    Repository rep = VersionControlService.GetRepository(ce.ParentWorkspaceObject);
                    if (rep != null)
                    {
                        rep.GetDirectoryVersionInfo(ce.Path, false, false);
                        AddFolderOverlay(rep, ce.Path, nodeInfo, true);
                    }
                }
                return;
            }

            WorkspaceObject prj;
            FilePath        file;

            if (dataObject is ProjectFile)
            {
                ProjectFile pfile = (ProjectFile)dataObject;
                prj  = pfile.Project;
                file = pfile.FilePath;
            }
            else
            {
                SystemFile pfile = (SystemFile)dataObject;
                prj  = pfile.ParentWorkspaceObject;
                file = pfile.Path;
            }

            if (prj == null)
            {
                return;
            }

            Repository repo = VersionControlService.GetRepository(prj);

            if (repo == null)
            {
                return;
            }

            VersionInfo vi = repo.GetVersionInfo(file);

            nodeInfo.OverlayBottomRight = VersionControlService.LoadOverlayIconForStatus(vi.Status);
        }
Ejemplo n.º 37
0
        public void 警笛(int seconds)
        {
            NodeInfo TheNode = XML_获取设备节点信息("警笛");

            CM_IOT_WCAW_Ctrl(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr, seconds);
        }
Ejemplo n.º 38
0
 /// <summary>
 /// Gets the tree-formatted path to the specified identifier.
 /// ex: 'NodeSourceName|ChildNodeName\ObjectName'
 /// </summary>
 public override string GetTreePath(NodeInfo info)
 {
     return(ParentSource.Name + "|" + info.Identifier.Replace("|", "\\"));
 }
Ejemplo n.º 39
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            var permissions = PermissionsManager.GetPermissions(Body.AdministratorName);

            PageUtils.CheckRequestParameter("PublishmentSystemID", "NodeID");
            var nodeID = Body.GetQueryInt("NodeID");

            relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, nodeID);
            nodeInfo          = NodeManager.GetNodeInfo(PublishmentSystemId, nodeID);
            tableName         = NodeManager.GetTableName(PublishmentSystemInfo, nodeInfo);
            tableStyle        = NodeManager.GetTableStyle(PublishmentSystemInfo, nodeInfo);
            styleInfoList     = TableStyleManager.GetTableStyleInfoList(tableStyle, tableName, relatedIdentities);

            if (nodeInfo.Additional.IsPreviewContents)
            {
                new Action(() =>
                {
                    DataProvider.ContentDao.DeletePreviewContents(PublishmentSystemId, tableName, nodeInfo);
                }).BeginInvoke(null, null);
            }

            if (!HasChannelPermissions(nodeID, AppManager.Cms.Permission.Channel.ContentView, AppManager.Cms.Permission.Channel.ContentAdd, AppManager.Cms.Permission.Channel.ContentEdit, AppManager.Cms.Permission.Channel.ContentDelete, AppManager.Cms.Permission.Channel.ContentTranslate))
            {
                if (!Body.IsAdministratorLoggin)
                {
                    PageUtils.RedirectToLoginPage();
                    return;
                }
                PageUtils.RedirectToErrorPage("您无此栏目的操作权限!");
                return;
            }

            attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(NodeManager.GetContentAttributesOfDisplay(PublishmentSystemId, nodeID));

            //this.attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(this.nodeInfo.Additional.ContentAttributesOfDisplay);

            spContents.ControlToPaginate = rptContents;
            rptContents.ItemDataBound   += rptContents_ItemDataBound;
            spContents.ItemsPerPage      = PublishmentSystemInfo.Additional.PageSize;

            var administratorName = AdminUtility.IsViewContentOnlySelf(Body.AdministratorName, PublishmentSystemId, nodeID)
                    ? Body.AdministratorName
                    : string.Empty;

            if (Body.IsQueryExists("SearchType"))
            {
                var owningNodeIdList = new List <int>
                {
                    nodeID
                };
                spContents.SelectCommand = DataProvider.ContentDao.GetSelectCommend(tableStyle, tableName, PublishmentSystemId, nodeID, permissions.IsSystemAdministrator, owningNodeIdList, Body.GetQueryString("SearchType"), Body.GetQueryString("Keyword"), Body.GetQueryString("DateFrom"), string.Empty, false, ETriState.All, false, false, false, administratorName);
            }
            else
            {
                spContents.SelectCommand = BaiRongDataProvider.ContentDao.GetSelectCommend(tableName, nodeID, ETriState.All, administratorName);
            }

            spContents.SortField     = BaiRongDataProvider.ContentDao.GetSortFieldName();
            spContents.SortMode      = SortMode.DESC;
            spContents.OrderByString = ETaxisTypeUtils.GetOrderByString(tableStyle, ETaxisType.OrderByTaxisDesc);

            //分页的时候,不去查询总条数,直接使用栏目的属性:ContentNum
            spContents.IsQueryTotalCount = false;
            spContents.TotalCount        = nodeInfo.ContentNum;

            if (!IsPostBack)
            {
                var nodeName = NodeManager.GetNodeNameNavigation(PublishmentSystemId, nodeID);
                BreadCrumbWithItemTitle(AppManager.Cms.LeftMenu.IdContent, "内容管理", nodeName, string.Empty);

                ltlContentButtons.Text = WebUtils.GetContentCommands(Body.AdministratorName, PublishmentSystemInfo, nodeInfo, PageUrl, GetRedirectUrl(PublishmentSystemId, nodeInfo.NodeId), false);
                spContents.DataBind();

                if (styleInfoList != null)
                {
                    foreach (var styleInfo in styleInfoList)
                    {
                        if (styleInfo.IsVisible)
                        {
                            var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName);
                            SearchType.Items.Add(listitem);
                        }
                    }
                }

                //添加隐藏属性
                SearchType.Items.Add(new ListItem("内容ID", ContentAttribute.Id));
                SearchType.Items.Add(new ListItem("添加者", ContentAttribute.AddUserName));
                SearchType.Items.Add(new ListItem("最后修改者", ContentAttribute.LastEditUserName));
                SearchType.Items.Add(new ListItem("内容组", ContentAttribute.ContentGroupNameCollection));

                if (Body.IsQueryExists("SearchType"))
                {
                    DateFrom.Text = Body.GetQueryString("DateFrom");
                    ControlUtils.SelectListItems(SearchType, Body.GetQueryString("SearchType"));
                    Keyword.Text            = Body.GetQueryString("Keyword");
                    ltlContentButtons.Text += @"
<script>
$(document).ready(function() {
	$('#contentSearch').show();
});
</script>
";
                }

                ltlColumnHeadRows.Text  = ContentUtility.GetColumnHeadRowsHtml(styleInfoList, attributesOfDisplay, tableStyle, PublishmentSystemInfo);
                ltlCommandHeadRows.Text = ContentUtility.GetCommandHeadRowsHtml(Body.AdministratorName, tableStyle, PublishmentSystemInfo, nodeInfo);
            }
        }
    public static void Print(this BNode root, int topMargin = 2, int leftMargin = 2)
    {
        if (root == null)
        {
            return;
        }
        int rootTop = Console.CursorTop + topMargin;
        var last    = new List <NodeInfo>();
        var next    = root;

        for (int level = 0; next != null; level++)
        {
            var item = new NodeInfo {
                Node = next, Text = next.item.ToString(" 0 ")
            };
            if (level < last.Count)
            {
                item.StartPos = last[level].EndPos + 1;
                last[level]   = item;
            }
            else
            {
                item.StartPos = leftMargin;
                last.Add(item);
            }
            if (level > 0)
            {
                item.Parent = last[level - 1];
                if (next == item.Parent.Node.left)
                {
                    item.Parent.Left = item;
                    item.EndPos      = Math.Max(item.EndPos, item.Parent.StartPos);
                }
                else
                {
                    item.Parent.Right = item;
                    item.StartPos     = Math.Max(item.StartPos, item.Parent.EndPos);
                }
            }
            next = next.left ?? next.right;
            for (; next == null; item = item.Parent)
            {
                Print(item, rootTop + 2 * level);
                if (--level < 0)
                {
                    break;
                }
                if (item == item.Parent.Left)
                {
                    item.Parent.StartPos = item.EndPos;
                    next = item.Parent.Node.right;
                }
                else
                {
                    if (item.Parent.Left == null)
                    {
                        item.Parent.EndPos = item.StartPos;
                    }
                    else
                    {
                        item.Parent.StartPos += (item.StartPos - item.Parent.EndPos) / 2;
                    }
                }
            }
        }
        Console.SetCursorPosition(0, rootTop + 2 * last.Count - 1);
    }
Ejemplo n.º 41
0
        public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo)
        {
            var extensionPoint = (ExtensionPoint)dataObject;

            nodeInfo.Label = extensionPoint.Path;
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="node"></param>
 public QueryNodeInfoResponse(NodeInfo node)
 {
     Node = node;
 }
Ejemplo n.º 43
0
 public bool Equals(NodeInfo other)
 {
     return(this.nt == other.nt && this.name == other.name &&
            this.value == other.value);
 }
Ejemplo n.º 44
0
        public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo)
        {
            base.BuildNode(treeBuilder, dataObject, nodeInfo);

            Project p = dataObject as Project;

            string escapedProjectName = GLib.Markup.EscapeText(p.Name);

            if (p is DotNetProject && ((DotNetProject)p).LanguageBinding == null)
            {
                nodeInfo.Icon           = Context.GetIcon(Stock.Project);
                nodeInfo.Label          = escapedProjectName;
                nodeInfo.StatusSeverity = TaskSeverity.Error;
                nodeInfo.StatusMessage  = GettextCatalog.GetString("Unknown language '{0}'", ((DotNetProject)p).LanguageName);
                nodeInfo.DisabledStyle  = true;
                return;
            }
            else if (p is UnknownProject)
            {
                var up = (UnknownProject)p;
                nodeInfo.StatusSeverity = TaskSeverity.Warning;
                nodeInfo.StatusMessage  = up.UnsupportedProjectMessage.TrimEnd('.');
                nodeInfo.Label          = escapedProjectName;
                nodeInfo.DisabledStyle  = true;
                nodeInfo.Icon           = Context.GetIcon(p.StockIcon);
                return;
            }

            nodeInfo.Icon = Context.GetIcon(p.StockIcon);
            var sc = p.ParentSolution?.StartupConfiguration;

            if (sc != null && IsStartupProject(p, sc))
            {
                nodeInfo.Label = "<b>" + escapedProjectName + "</b>";
            }
            else
            {
                nodeInfo.Label = escapedProjectName;
            }

            // Gray out the project name if it is not selected in the current build configuration

            SolutionConfiguration      conf = p.ParentSolution.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
            SolutionConfigurationEntry ce   = null;
            bool noMapping     = conf == null || (ce = conf.GetEntryForItem(p)) == null;
            bool missingConfig = false;

            if (p.SupportsBuild() && (noMapping || !ce.Build || (missingConfig = p.Configurations [ce.ItemConfiguration] == null)))
            {
                nodeInfo.DisabledStyle = true;
                if (missingConfig)
                {
                    nodeInfo.StatusSeverity = TaskSeverity.Error;
                    nodeInfo.StatusMessage  = GettextCatalog.GetString("Invalid configuration mapping");
                }
                else
                {
                    nodeInfo.StatusSeverity = TaskSeverity.Information;
                    nodeInfo.StatusMessage  = GettextCatalog.GetString("Project not built in active configuration");
                }
            }
        }
Ejemplo n.º 45
0
 public Task <IActionResult> Fund(
     [ModelBinder(typeof(NodeInfoModelBinder))]
     NodeInfo nodeInfo)
 {
     return(null);
 }
Ejemplo n.º 46
0
        public void 查询光照报警范围()
        {
            NodeInfo TheNode = XML_获取设备节点信息("无线光照度采集");

            CM_IOT_IDC_QueryLimit(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr);
        }
Ejemplo n.º 47
0
 public Stabilize(NodeInfo @from, NodeInfo to, CorrelationId correlationId) : base(@from, to)
 {
     CorrelationId = correlationId;
 }
Ejemplo n.º 48
0
 public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo)
 {
     nodeInfo.Label = "Dependencies";
 }
Ejemplo n.º 49
0
        public void 电源关闭()
        {
            NodeInfo TheNode = XML_获取设备节点信息("电源控制");

            CM_IOT_POWER_Ctrl(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr, 0);
        }
Ejemplo n.º 50
0
 /// <summary>
 /// Constructs the parent NodeInfo based on the values in the supplied NodeInfo.
 /// </summary>
 public override NodeInfo GetParentNodeInfo(NodeInfo info)
 {
     return(new NodeInfo(ParentSource.GetNodeType <UnextractedObjectViewRootNodeType>(), ""));
 }
Ejemplo n.º 51
0
        public void 实验箱关闭()
        {
            NodeInfo TheNode = XML_获取设备节点信息("实验箱取电");

            CM_IOT_CONTROLTC_Ctrl(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr, 0);
        }
Ejemplo n.º 52
0
        public static void Print <T>(this  AvlTree <T> root, string textFormat = "0", int spacing = 1, int topMargin = 2, int leftMargin = 2)
        {
            if (root == null)
            {
                return;
            }
            int rootTop = Console.CursorTop + topMargin;
            var last    = new List <NodeInfo <T> >();
            var next    = root.root;

            for (int level = 0; next != null; level++)
            {
                var item = new NodeInfo <T> {
                    Node = next, Text = next.ToString(textFormat)
                };
                if (level < last.Count)
                {
                    item.StartPos = last[level].EndPos + spacing;
                    last[level]   = item;
                }
                else
                {
                    item.StartPos = leftMargin;
                    last.Add(item);
                }
                if (level > 0)
                {
                    item.Parent = last[level - 1];
                    if (next == item.Parent.Node.left)
                    {
                        item.Parent.Left = item;
                        item.EndPos      = Math.Max(item.EndPos, item.Parent.StartPos - 1);
                    }
                    else
                    {
                        item.Parent.Right = item;
                        item.StartPos     = Math.Max(item.StartPos, item.Parent.EndPos + 1);
                    }
                }
                next = next.left ?? next.right;
                for (; next == null; item = item.Parent)
                {
                    int top = rootTop + 2 * level;
                    Print(item.Text, top, item.StartPos);
                    if (item.Left != null)
                    {
                        Print("/", top + 1, item.Left.EndPos);
                        Print("_", top, item.Left.EndPos + 1, item.StartPos);
                    }
                    if (item.Right != null)
                    {
                        Print("_", top, item.EndPos, item.Right.StartPos - 1);
                        Print("\\", top + 1, item.Right.StartPos - 1);
                    }
                    if (--level < 0)
                    {
                        break;
                    }
                    if (item == item.Parent.Left)
                    {
                        item.Parent.StartPos = item.EndPos + 1;
                        next = item.Parent.Node.right;
                    }
                    else
                    {
                        if (item.Parent.Left == null)
                        {
                            item.Parent.EndPos = item.StartPos - 1;
                        }
                        else
                        {
                            item.Parent.StartPos += (item.StartPos - 1 - item.Parent.EndPos) / 2;
                        }
                    }
                }
            }
            Console.SetCursorPosition(0, rootTop + 2 * last.Count - 1);
        }
Ejemplo n.º 53
0
        public void 光照单次取样()
        {
            NodeInfo TheNode = XML_获取设备节点信息("无线光照度采集");

            CM_IOT_IDC_Sampling(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr);
        }
 public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo)
 {
     nodeInfo.Label      = GLib.Markup.EscapeText(GettextCatalog.GetString("References"));
     nodeInfo.Icon       = Context.GetIcon(Stock.OpenReferenceFolder);
     nodeInfo.ClosedIcon = Context.GetIcon(Stock.ClosedReferenceFolder);
 }
 Task ILightningClient.ConnectTo(NodeInfo nodeInfo)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 56
0
        public Message CreateMyInfoMessage(Node MessageTo)
        {
            var p = new Message(network, MessageType.MyInfo);

            p.To = MessageTo.NodeID;
            var t = network.TrustedNodes[MessageTo.NodeID];

            var nodeInfo = new NodeInfo();

            nodeInfo.NodeID   = network.LocalNode.NodeID;
            nodeInfo.NickName = network.LocalNode.NickName;

            nodeInfo.AvatarSize = network.LocalNode.AvatarSize;

            if (MessageTo.IsConnectedLocally || t.AllowNetworkInfo)
            {
                nodeInfo.DestinationInfos = network.Core.DestinationManager.DestinationInfos;
            }
            if (t.AllowProfile)
            {
                nodeInfo.RealName = network.LocalNode.RealName;
                nodeInfo.Email    = network.LocalNode.Email;
            }
            nodeInfo.ClientName    = network.LocalNode.ClientName;
            nodeInfo.ClientVersion = network.LocalNode.ClientVersion;
            if (t.AllowSharedFiles)
            {
                nodeInfo.Bytes = network.LocalNode.Bytes;
                nodeInfo.Files = network.LocalNode.Files;
            }

            var connections = new List <ConnectionInfo>();
            var rooms       = new List <ChatRoomInfo>();
            var memos       = new List <MemoInfo>();

            foreach (var con in network.Connections)
            {
                if (con.NodeLocal != MessageTo & con.NodeRemote != MessageTo)
                {
                    if (con.ConnectionState == ConnectionState.Ready | con.ConnectionState == ConnectionState.Remote)
                    {
                        var n = new ConnectionInfo();
                        var ConnectionSourceNode = con.NodeLocal;
                        var ConnectionDestNode   = con.NodeRemote;
                        n.SourceNodeID       = ConnectionSourceNode.NodeID;
                        n.SourceNodeNickname = ConnectionSourceNode.NickName;
                        n.DestNodeID         = ConnectionDestNode.NodeID;
                        n.DestNodeNickname   = ConnectionDestNode.NickName;
                        connections.Add(n);
                    }
                }
            }

            foreach (var currentRoom in network.ChatRooms)
            {
                var roomInfo = new ChatRoomInfo();
                roomInfo.Id    = currentRoom.Id;
                roomInfo.Name  = currentRoom.Name;
                roomInfo.Users = new string[currentRoom.Users.Count];
                var x = 0;
                foreach (var node in currentRoom.Users.Values)
                {
                    roomInfo.Users[x] = node.NodeID;
                    x++;
                }
                rooms.Add(roomInfo);
            }

            foreach (var currentMemo in network.Memos)
            {
                if (network.Core.IsLocalNode(currentMemo.Node))
                {
                    var info = new MemoInfo(currentMemo);
                    memos.Add(info);
                }
            }

            nodeInfo.KnownConnections = connections.ToArray();
            nodeInfo.KnownChatRooms   = rooms.ToArray();
            nodeInfo.KnownMemos       = memos.ToArray();

            p.Content = nodeInfo;
            return(p);
        }
Ejemplo n.º 57
0
    /// <summary>
    /// Gen MAP
    /// </summary>
    /// <param name="a_genSide">-1:left side || 0:center || 1:right side (ratio vs screen width)</param>
    private void GenMap(int a_genSide = 0)
    {
        // clear old nodes
        m_lNodeObjs.Clear();
        // gen MAP
        GameObject mapObjPref = Resources.Load <GameObject>(AssetPathConstant.FOLDER_MAP_PATH + "/" + m_CurSelectedNode.m_TopicIndex.ToString());

        if (mapObjPref == null)
        {
            return;
        }
        GameObject genMapObj = Instantiate(mapObjPref, transform);

        genMapObj.transform.SetAsFirstSibling();
        m_lGenMapObjs.Add(genMapObj);

        // set SIZE & SCALE following map template
        RectTransform rtMapTemplate = Ref_MapTemplateObj.GetComponent <RectTransform>();
        RectTransform rtMapObj      = genMapObj.GetComponent <RectTransform>();

        rtMapObj.sizeDelta  = rtMapTemplate.sizeDelta;
        rtMapObj.localScale = rtMapTemplate.localScale;

        // set POS following side
        Vector3 mapPos = rtMapObj.localPosition;

        mapPos.x = rtMapTemplate.localPosition.x + (rtMapTemplate.sizeDelta.x * rtMapTemplate.localScale.x * a_genSide);
        mapPos.y = rtMapTemplate.localPosition.y;
        rtMapObj.localPosition = mapPos;

        // set up NODEs of map
        GameObject nodesContObj = genMapObj.transform.GetChild(0).gameObject;

        for (int i = 0; i < m_CurMapInfo.m_lNodes.Count; i++)
        {
            if (i >= nodesContObj.transform.childCount)
            {
                break;
            }

            NodeInfo   curNode = m_CurMapInfo.m_lNodes[i];
            GameObject nodeObj = nodesContObj.transform.GetChild(i).gameObject;
            // set SPRITE depend on STATE of node
            NodeState nodeState = NodeState.Locked;
            // BOSS node (if list of vocas = null)
            if (curNode.m_lVocaIndex.Count == 0)
            {
                nodeState = NodeState.LockedBoss;
            }
            // UNLOCKED node || Unlocked boss node
            if ((curNode.m_TopicIndex == m_LastUnlockedNode.m_TopicIndex && i <= m_LastUnlockedNode.m_NodeIndex) ||
                curNode.m_TopicIndex < m_LastUnlockedNode.m_TopicIndex)
            {
                nodeState = nodeState == NodeState.LockedBoss ? NodeState.UnlockedBoss : NodeState.Unlocked;
            }

            string        spritePath = AssetPathConstant.FOLDER_HIGHLIGHT_NODE_PATH + "/" + ((int)nodeState).ToString();
            Sprite        nodeSprite = Resources.Load <Sprite>(spritePath);
            RectTransform rtNode     = nodeObj.GetComponent <RectTransform>();
            if (nodeSprite)
            {
                Image nodeImg = nodeObj.GetComponentInChildren <Image>();
                nodeImg.sprite   = nodeSprite;
                rtNode.sizeDelta = new Vector2(nodeImg.sprite.rect.width, nodeImg.sprite.rect.height);
            }
            m_lNodeObjs.Add(nodeObj);

            // gen TOUCH ZONE & set SIZE for node
            if (nodeState == NodeState.Unlocked || nodeState == NodeState.UnlockedBoss)
            {
                GameObject nodeTouchZoneObj = Instantiate(Pre_NodeZoneTouch, nodeObj.transform);
                nodeTouchZoneObj.GetComponent <RectTransform>().sizeDelta = rtNode.sizeDelta;

                Button nodeBtn = nodeTouchZoneObj.GetComponent <Button>();
                if (nodeBtn)
                {
                    int btnIndex = i;
                    nodeBtn.onClick.AddListener(() => OnPressNode(btnIndex));
                }
            }
        }
    }
Ejemplo n.º 58
0
        public static void KeepAlive()
        {
            string ver = Version.FileVersion;

            Connect();
            while (Running)
            {
                if ((DateTime.Now - StartupTime).Hours > 10)
                {
                    IsShuttingDown = true;
                }

                var infoGathered = false;

                if (Games == null || (IsShuttingDown && Games.Count == 0))
                {
                    Thread.Sleep(5000);
                    //Running = false;
                    Environment.Exit(0);
                    return;
                }
                //monitor the tcp connection to keep it open
                try
                {
                    if (Games == null)
                    {
                        //uhhhhhhhhh  ok.....
                        continue;
                    }
                    var games = Games.ToList();

                    var info = new NodeInfo
                    {
                        Games                 = new HashSet <GameInfo>(),
                        ClientId              = ClientId,
                        CurrentGames          = games.Count,
                        CurrentPlayers        = games.Sum(x => x?.Players?.Count ?? 0),
                        DuplicateGamesRemoved = DupGamesKilled,
                        ThreadCount           = 0,//Process.GetCurrentProcess().Threads.Count,
                        //TotalGames = GamesStarted,
                        //TotalPlayers = games.Sum(x => x.Players?.Count ?? 0) + TotalPlayers,
                        Uptime       = DateTime.Now - StartupTime,
                        Version      = ver,
                        ShuttingDown = IsShuttingDown,
                        MessagesSent = MessagesSent
                    };

                    foreach (var g in games)
                    {
                        if (g?.Players == null)
                        {
                            try
                            {
                                Games.Remove(g);
                            }
                            catch
                            {
                                // ignored, it was already removed
                            }
                            continue;
                        }
                        var gi = new GameInfo
                        {
                            Language    = g.Language,
                            ChatGroup   = g.ChatGroup,
                            GroupId     = g.ChatId,
                            NodeId      = ClientId,
                            Guid        = g.Guid,
                            State       = g.IsRunning ? GameState.Running : g.IsJoining ? GameState.Joining : GameState.Dead,
                            Users       = g.Players != null ? new HashSet <long>(g.Players.Where(x => !x.IsDead).Select(x => x.TeleUser.Id)) : new HashSet <long>(),
                            PlayerCount = g.Players?.Count ?? 0
                                          //Players = new HashSet<IPlayer>(g.Players)
                        };
                        info.Games.Add(gi);
                    }

                    var json = JsonConvert.SerializeObject(info);
                    infoGathered = true;
                    Client.WriteLine(json);
                }
                catch (Exception e)
                {
                    while (e.InnerException != null)
                    {
                        e = e.InnerException;
                    }
                    Console.WriteLine($"Error in KeepAlive: {e.Message}\n{e.StackTrace}\n");
                    if (infoGathered) //only disconnect if tcp error
                    {
                        if (Client != null)
                        {
                            try
                            {
                                Client.DataReceived          -= ClientOnDataReceived;
                                Client.DelimiterDataReceived -= ClientOnDelimiterDataReceived;
                                Client.Disconnect();
                            }
                            catch
                            {
                                // ignored
                            }
                        }
                        Connect();
                    }
                }
                Thread.Sleep(500);
            }
        }
Ejemplo n.º 59
0
 private string SubNodeId(NodeInfo nodeInfo, int itemIndex)
 {
     return($"{Id(nodeInfo)}_{itemIndex}");
 }
Ejemplo n.º 60
0
        public void 关闭温湿度连续取样()
        {
            NodeInfo TheNode = XML_获取设备节点信息("无线温湿度采集");

            CM_IOT_THDC_StopContinuousSampling(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr);
        }