private void addDevices(IEnumerable <CCTVStaticInfo> infos) { Gateway gw = InfoService.Instance.CurrentGateway; if (infos != null && infos.Count() > 0) { Dictionary <string, string> dictIdPairs = new Dictionary <string, string>(); IEnumerable <SipIdMap> dids = InfoService.Instance.GetAllSipIdMap(); if (dids != null) { foreach (SipIdMap sp in dids) { dictIdPairs[sp.StaticId] = sp.SipNumber; } } foreach (CCTVStaticInfo si in infos) { string sip = null; if (dictIdPairs.ContainsKey(si.VideoId)) { sip = dictIdPairs[si.VideoId]; } else { sip = SipIdGenner.GenDeviceID(); InfoService.Instance.PutSipIdMap(si.VideoId, new SipIdMap(si.VideoId, sip), false); } VirtualDevice vd = new VirtualDevice(si, gw, sip, _sipServer.Proxy.Registrar); _allDevices[si.VideoId] = vd; _allAOR.Add(vd.LocalAOR); vd.Start(); } } }
private DeviceItemsCollection buildDeviceItems(string parentId, Platform plat) { //过滤出仅平台鉴权用户可用的视频列表。 List <string> acIds = getUserDeviceId(plat); IEnumerable <CCTVStaticInfo> infos = InfoService.Instance.GetAllStaticInfo(); if (infos != null) { Dictionary <string, string> dictIdPairs = new Dictionary <string, string>(); IEnumerable <SipIdMap> dids = InfoService.Instance.GetAllSipIdMap(); if (dids != null) { foreach (SipIdMap sp in dids) { dictIdPairs[sp.StaticId] = sp.SipNumber; } } DeviceItemsCollection items = new DeviceItemsCollection(); foreach (CCTVStaticInfo si in infos) { CCTVControlConfig cc = InfoService.Instance.GetControlConfig(si.VideoId); string sip = null; if (dictIdPairs.ContainsKey(si.VideoId)) { sip = dictIdPairs[si.VideoId]; } else { sip = SipIdGenner.GenDeviceID(); InfoService.Instance.PutSipIdMap(si.VideoId, new SipIdMap(si.VideoId, sip), false); } ItemType it = new ItemType() { DeviceID = sip, ParentID = parentId, Event = StatusEvent.ADD, Name = si.Name, Manufacturer = "Seecool", Model = "Seecool", Owner = "Seecool", CivilCode = sip, Block = "", Address = "1", Parental = 0, SafetyWay = 0, RegisterWay = 1, CertNum = "1", Certifiable = 1, ErrCode = 400, EndTime = DateTime.Now, Secrecy = 0, IPAddress = cc?.Ip, Port = cc == null ? 8000 : cc.Port, Password = cc?.Password, Status = StatusType.ON, Longitude = si.Longitude, Latitude = si.Latitude }; items.Add(it); } return(items); } else { return(null); } }