public void Delete(string logicalName, string nodeId)
        {
            CCTVHierarchyInfo info = GetInfo(logicalName, nodeId);

            if (info != null)
            {
                update(logicalName, info, true);
            }
        }
Exemple #2
0
 public void Post([FromBody] CCTVHierarchyInfo info, string logicalName = "Default")
 {
     if (info == null)
     {
         throw new HttpRequestException("逻辑树节点内容不能为空。");
     }
     if (string.IsNullOrWhiteSpace(info.Id))
     {
         info.Id = Guid.NewGuid().ToString();
     }
     HierarchyPersistence.Instance.Put(logicalName, info);
 }
 private void update(string logicalName, CCTVHierarchyInfo info, bool isDeleted)
 {
     getSynchronizer(logicalName).PutUpdate(new List <ObjectItem <CCTVHierarchyInfo> >()
     {
         new ObjectItem <CCTVHierarchyInfo>()
         {
             Key       = info.Id,
             IsDeleted = isDeleted,
             Item      = info
         }
     });
 }
Exemple #4
0
        private void getHierarchyInfo(string parentId, VideoParser.Video video)
        {
            string videoId = getNodeId(video.Id);

            _dictHier[videoId] = new CCTVHierarchyInfo()
            {
                Id        = videoId,
                Name      = video.Name,
                Type      = NodeType.Video,
                ParentId  = parentId,
                ElementId = videoId
            };
        }
Exemple #5
0
        private void getHierarchyInfo(string parentId, VideoParser.Node node)
        {
            string nodeId = getNodeId(node.Id);

            _dictHier[nodeId] = new CCTVHierarchyInfo()
            {
                Id        = nodeId,
                Name      = node.Name,
                Type      = getNodeType(node),
                ParentId  = parentId,
                ElementId = nodeId
            };

            VideoParser.Server server = node as VideoParser.Server;
            if (server != null)
            {
                if (server.Childs != null)
                {
                    foreach (VideoParser.Node child in server.Childs)
                    {
                        getHierarchyInfo(nodeId, child);
                    }
                }
            }
            else
            {
                VideoParser.Front front = node as VideoParser.Front;
                if (front != null)
                {
                    if (front.Childs != null)
                    {
                        foreach (VideoParser.Video child in front.Childs)
                        {
                            getHierarchyInfo(nodeId, child);
                        }
                    }
                }
            }
        }
Exemple #6
0
        // PUT: api/VideoInfoNode/5
        public IHttpActionResult Put(string id, [FromBody] VideoInfoNodeViewModel vinvm)
        {
            CCTVVideoInfoWrap viw = vinvm.VideoInfo;

            if (string.IsNullOrWhiteSpace(id))
            {
                return(BadRequest("视频ID不能为空"));
            }
            if (viw == null)
            {
                return(BadRequest("数据不能为空"));
            }

            //更新基本信息
            if (viw.StaticInfo != null)
            {
                viw.StaticInfo.VideoId = id;
                //生成码流的URL
                if (viw.StaticInfo.Platform == CCTVPlatformType.CCTV2)
                {
                    StreamUrlGenner.BuildStreamUrl(viw.StaticInfo.Streams, viw.DeviceInfo);
                }
                StaticPersistence.Instance.Put(id, viw.StaticInfo);
            }
            //更新基本信息以外的其他信息。
            if (viw.Control != null)
            {
                viw.Control.VideoId = id;
                ControlPersistence.Instance.Put(id, viw.Control);
            }
            if (viw.CameraLimits != null)
            {
                viw.CameraLimits.VideoId = id;
                CameraPersistence.Instance.Put(id, viw.CameraLimits);
            }
            if (viw.TargetTrack != null)
            {
                viw.TargetTrack.VideoId = id;
                TargetTrackPersistence.Instance.Put(id, viw.TargetTrack);
            }
            if (viw.VideoTrack != null)
            {
                viw.VideoTrack.VideoId = id;
                VideoTrackPersistence.Instance.Put(id, viw.VideoTrack);
            }
            if (viw.VideoAnalyze != null)
            {
                viw.VideoAnalyze.VideoId = id;
                AnalyzePersistence.Instance.Put(id, viw.VideoAnalyze);
            }
            if (viw.DeviceInfo != null)
            {
                viw.DeviceInfo.VideoId = id;
                DevicePersistence.Instance.Put(id, viw.DeviceInfo);
            }

            CCTVHierarchyInfo hi = new CCTVHierarchyInfo();

            hi.Id        = vinvm.NodeId;
            hi.ParentId  = vinvm.ParentId;
            hi.Type      = NodeType.Video;
            hi.Name      = viw.StaticInfo.Name;
            hi.ElementId = viw.StaticInfo.VideoId;
            if (string.IsNullOrWhiteSpace(hi.Id))
            {
                hi.Id = Guid.NewGuid().ToString();
            }
            HierarchyPersistence.Instance.Put(CCTVLogicalTree.DefaultName, hi);
            return(Ok("修改视频信息成功"));
        }
 public void Put(string logicalName, CCTVHierarchyInfo info)
 {
     update(logicalName, info, false);
 }