/// <summary> /// 添加数据采集服务器在数据中心的注册信息 /// </summary> /// <param name="dcs"></param> /// <returns></returns> public string AddDCS(DCSService dcs) { lock (_object) { DCSService d = dcs; DCSInfo dcinfo = null; int iCount = this._dcsList.Where(p => p.ID == d.ID).Count(); if (iCount == 0) { dcinfo = new DCSInfo(dcs.ID) { DcsService = d, IP = d.IP, IsRegister = true, Name = d.Name, Port = d.Port }; dcinfo.IP = d.IP; dcinfo.Name = d.Name; dcinfo.Port = d.Port; dcinfo.IsRegister = true; dcinfo.DcsService = d; this._dcsList.Add(dcinfo); } else { dcinfo = this._dcsList.Where(p => p.ID == d.ID).Single(); if (!dcinfo.IsRegister) { dcinfo.IP = d.IP; dcinfo.Name = d.Name; dcinfo.Port = d.Port; dcinfo.IsRegister = true; dcinfo.DcsService = d; } else { return("服务器已注册"); } } Console.WriteLine("服务器:{0}-{1} {2}:{3}注册成功", d.ID, d.Name, d.IP, d.Port); return(""); } }
public void Register(string dscID, string dscName, string dscIP, string dscPort) { this.ID = dscID; this.Name = dscName; this.IP = dscIP; this.Port = dscPort; _iDCSClient = OperationContext.Current.GetCallbackChannel <IDCSClient>(); DCSRegister.getInstance().CheckDCSService(); DCSService dcs = DCSRegister.getInstance().getDcsSevice(dscID); if (dcs != null) { if (this.Equals(dcs)) { Console.WriteLine("本次注册的对象已存在"); } else { Console.WriteLine("本次注册的对象不同。"); } } DCSRegister.getInstance().AddDCS(this); }