protected void ReloadFlies(object obj) { try { CommandItems.Clear(); XmlDocument xml = new XmlDocument(); xml.Load("node.xml"); foreach (XmlNode xn in xml.FirstChild.ChildNodes) { CommandItem ci = new CommandItem(); ci.Ip = xn.Attributes["ip"].Value; ci.Port = Convert.ToInt32(xn.Attributes["port"].Value); ci.CommName = byte.Parse(xn.Attributes["command"].Value); CommandItems.Add(ci); } } catch (Exception ex) { if (EventMylog != null) { EventMylog("加载异常", ex.Message); } } }
protected void ReloadFlies(object obj) { try { CommandItemS.Clear(); XmlDocument xml = new XmlDocument(); xml.Load("node.xml"); List <String> iplist = new List <string>(); foreach (XmlNode xn in xml.FirstChild.ChildNodes) { string type = "json"; if (Wptype == WeavePortTypeEnum.Bytes) { type = "byte"; } if (type == xn.Attributes["type"].Value) { bool isok = true; CommandItem ci = new CommandItem(); ci.Ip = xn.Attributes["ip"].Value; ci.Port = Convert.ToInt32(xn.Attributes["port"].Value); ci.CommName = byte.Parse(xn.Attributes["command"].Value); CommandItemS.Add(ci); foreach (string s in iplist) { if (s == ci.Ip + ":" + ci.Port) { isok = false; } } if (isok) { iplist.Add(ci.Ip + ":" + ci.Port); } } } int countpipeline = iplist.Count * (int)pipeline; if (countpipeline > 60000) { if (EventMylog != null) { EventMylog("设置异常", "你所开启的通道不能超过6万,计算方法,不同的(IP+PORT)总数*通道数量。开启当前设置需要:" + countpipeline + "本地连接,此链接不被系统支持。"); } return; } foreach (string s in iplist) { P2Pclient[,,,] client4_10temp = new P2Pclient[10, 10, 10, 10]; for (int i = (int)pipeline; i > 1; i--) { String im = (i - 1).ToString(), temp = ""; for (int j = 0; j < 4 - im.Length; j++) { temp += "0"; } im = temp + im; System.Threading.Thread.Sleep(100); P2Pclient ct = newp2p(s.Split(':')[0], Convert.ToInt32(s.Split(':')[1])); //P2Pclient ct = new P2Pclient(false); client4_10temp[int.Parse(im.Substring(0, 1)), int.Parse(im.Substring(1, 1)), int.Parse(im.Substring(2, 1)), int.Parse(im.Substring(3, 1))] = ct; } client4_10temp[0, 0, 0, 0] = newp2p(s.Split(':')[0], Convert.ToInt32(s.Split(':')[1])); foreach (CommandItem ci in CommandItemS) { if (s == ci.Ip + ":" + ci.Port) { ci.Client4_10 = client4_10temp; } } } EventMylog("加载成功", "已完成通道加载。"); } catch (Exception ex) { if (EventMylog != null) { EventMylog("加载异常", ex.Message); } } }
protected void ReloadFlies2(object obj) { try { foreach (CommandItem ci in CommandItemS2) { foreach (P2Pclient Client in ci.Client) { Client.Stop(); } } CommandItemS2.Clear(); foreach (CommandItem ci in CommandItemS) { foreach (P2Pclient Client in ci.Client) { Client.Stop(); } } CommandItemS.Clear(); XmlDocument xml = new XmlDocument(); xml.Load(System.AppDomain.CurrentDomain.BaseDirectory + "/" + filename); foreach (XmlNode xn in xml.FirstChild.ChildNodes) { CommandItem ci = new CommandItem(); ci.Ip = xn.Attributes["ip"].Value; ci.Port = Convert.ToInt32(xn.Attributes["port"].Value); ci.CommName = byte.Parse(xn.Attributes["command"].Value); ci.Commfun = xn.Attributes["Commfun"].Value; P2Pclient p2p = new P2Pclient(false); p2p.ReceiveServerEvent += P2p_receiveServerEvent; p2p.Timeoutevent += P2p_timeoutevent; p2p.ErrorMge += P2p_ErrorMge; if (p2p.Start(ci.Ip, ci.Port, false)) { ci.Client.Add(p2p); if (xn.Attributes["type"].Value == "receive") { CommandItemS.Add(ci); } else if (xn.Attributes["type"].Value == "push") { CommandItemS2.Add(ci); } } else { if (EventMylog != null) { EventMylog("节点连接失败", "命令:" + ci.CommName + ":节点连接失败,抛弃此节点"); } } } } catch (Exception ex) { if (EventMylog != null) { EventMylog("加载异常", ex.Message); } } }