Example #1
0
        private DeviceCatalogNotify createCatalog(Gateway gw, Platform plat)
        {
            DeviceCatalogNotify notify = new DeviceCatalogNotify();

            notify.DeviceID = gw.SipNumber;
            DeviceItemsCollection items = buildDeviceItems(gw.SipNumber, plat);

            if (items != null)
            {
                notify.Items = items;
            }
            return(notify);
        }
Example #2
0
        private DeviceCatalogResp createCatalogResp(Gateway gw, Platform plat)
        {
            DeviceCatalogResp resp = new DeviceCatalogResp();

            resp.DeviceID = gw.SipNumber;
            DeviceItemsCollection items = buildDeviceItems(gw.SipNumber, plat);

            if (items != null)
            {
                resp.Items = items;
            }
            return(resp);
        }
Example #3
0
        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);
            }
        }