コード例 #1
0
 public CCTVHierarchyNode GetHierarchy(string hierarchyName = _defaultHierarchy)
 {
     if (!hierarchyName.Equals(_currentTree, StringComparison.OrdinalIgnoreCase))
     {
         _rootNode    = null;
         _currentTree = hierarchyName;
         ClientHub.RegisterHierarchy(hierarchyName, TimeSpan.FromSeconds(5), hierUpdated);
     }
     //目前只能获取默认节点树。
     if (_rootNode == null)
     {
         CCTVHierarchyNode[] roots = ClientHub.GetAllHierarchyRoots();
         if (roots != null && roots.Length > 0)
         {
             if (_fromConfig)
             {
                 if (UserManager.Instance?.CurrentUser != null &&
                     !string.IsNullOrWhiteSpace(UserManager.Instance.CurrentUser.UserName))
                 {
                     ClientHub.UpdateDefault(CCTVInfoType.UserPrivilege);
                     var priv = ClientHub.GetUserPrivilege(UserManager.Instance.CurrentUser.UserName);
                     if (priv != null && priv.AccessibleNodes != null)
                     {
                         roots = HierarchyInfoUtil.FilterNodes(roots, priv.AccessibleNodes).ToArray();
                     }
                 }
             }
             if (roots.Length == 1)
             {
                 _rootNode = roots[0];
             }
             else
             {
                 string id = Guid.NewGuid().ToString();
                 _rootNode = new CCTVHierarchyNode()
                 {
                     Name      = "根节点",
                     Id        = id,
                     Type      = NodeType.Server,
                     ElementId = id,
                     Children  = roots
                 };
             }
         }
     }
     return(_rootNode);
     //if (rootNode == null)
     //    ClientHub.UpdateRegistered<HierarchyInfo>();
     //return rootNode;
 }
コード例 #2
0
        public void RegisterDefault(CCTVInfoType type, TimeSpan interval, SyncUpdateHandler updateHandler, string savePath)
        {
            if (_syncParams.ContainsKey(type))
            {
                IDisposable dis = _syncParams[type] as IDisposable;
                dis.Dispose();
            }
            switch (type)
            {
            case CCTVInfoType.TargetTrackInfo:
            {
                SyncParams <CCTVTargetTrack>             sp   = new SyncParams <CCTVTargetTrack>(DefaultSections.TargetTrackInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVTargetTrack> sync = new StaticInfoSynchronizer <CCTVTargetTrack>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVTargetTrack>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.VideoAnalyzeInfo:
            {
                SyncParams <CCTVVideoAnalyze>             sp   = new SyncParams <CCTVVideoAnalyze>(DefaultSections.VideoAnalyzeInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVVideoAnalyze> sync = new StaticInfoSynchronizer <CCTVVideoAnalyze>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVVideoAnalyze>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.VideoTrackInfo:
            {
                SyncParams <CCTVVideoTrack>             sp   = new SyncParams <CCTVVideoTrack>(DefaultSections.VideoTrackInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVVideoTrack> sync = new StaticInfoSynchronizer <CCTVVideoTrack>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVVideoTrack>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.CameraLimitsInfo:
            {
                SyncParams <CCTVCameraLimits>             sp   = new SyncParams <CCTVCameraLimits>(DefaultSections.CameraLimitsInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVCameraLimits> sync = new StaticInfoSynchronizer <CCTVCameraLimits>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVCameraLimits>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.DynamicInfo:
            {
                SyncParams <CCTVDynamicInfo>             sp   = new SyncParams <CCTVDynamicInfo>(DefaultSections.DynamicInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVDynamicInfo> sync = new StaticInfoSynchronizer <CCTVDynamicInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVDynamicInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.GlobalInfo:
            {
                SyncParams <CCTVGlobalInfo>             sp   = new SyncParams <CCTVGlobalInfo>(DefaultSections.GlobalInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVGlobalInfo> sync = new StaticInfoSynchronizer <CCTVGlobalInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVGlobalInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.HierarchyInfo:
            {
                SyncParams <CCTVHierarchyInfo>             sp   = new SyncParams <CCTVHierarchyInfo>(HierarchyInfoUtil.CreateSection("Default"), interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVHierarchyInfo> sync = new StaticInfoSynchronizer <CCTVHierarchyInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVHierarchyInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.LogicalTree:
            {
                SyncParams <CCTVLogicalTree>             sp   = new SyncParams <CCTVLogicalTree>(DefaultSections.LogicalTree, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVLogicalTree> sync = new StaticInfoSynchronizer <CCTVLogicalTree>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVLogicalTree>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.OnlineStatus:
            {
                SyncParams <CCTVOnlineStatus>             sp   = new SyncParams <CCTVOnlineStatus>(DefaultSections.OnlineStatus, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVOnlineStatus> sync = new StaticInfoSynchronizer <CCTVOnlineStatus>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVOnlineStatus>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.ServerInfo:
            {
                SyncParams <CCTVServerInfo>             sp   = new SyncParams <CCTVServerInfo>(DefaultSections.ServerInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVServerInfo> sync = new StaticInfoSynchronizer <CCTVServerInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVServerInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.StaticInfo:
            {
                SyncParams <CCTVStaticInfo>             sp   = new SyncParams <CCTVStaticInfo>(DefaultSections.StaticInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVStaticInfo> sync = new StaticInfoSynchronizer <CCTVStaticInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVStaticInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.ControlConfig:
            {
                SyncParams <CCTVControlConfig>             sp   = new SyncParams <CCTVControlConfig>(DefaultSections.ControlConfig, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVControlConfig> sync = new StaticInfoSynchronizer <CCTVControlConfig>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVControlConfig>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.DeviceInfo:
            {
                SyncParams <CCTVDeviceInfo>             sp   = new SyncParams <CCTVDeviceInfo>(DefaultSections.DeviceInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVDeviceInfo> sync = new StaticInfoSynchronizer <CCTVDeviceInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVDeviceInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.UserInfo:
            {
                SyncParams <CCTVUserInfo>             sp   = new SyncParams <CCTVUserInfo>(DefaultSections.UserInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVUserInfo> sync = new StaticInfoSynchronizer <CCTVUserInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVUserInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.Privilege:
            {
                SyncParams <CCTVPrivilege>             sp   = new SyncParams <CCTVPrivilege>(DefaultSections.Privilege, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVPrivilege> sync = new StaticInfoSynchronizer <CCTVPrivilege>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVPrivilege>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.UserPrivilege:
            {
                {
                    SyncParams <CCTVUserPrivilege>             sp   = new SyncParams <CCTVUserPrivilege>(DefaultSections.UserPrivilege, interval, updateHandler, savePath);
                    StaticInfoSynchronizer <CCTVUserPrivilege> sync = new StaticInfoSynchronizer <CCTVUserPrivilege>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                    _syncParams[type] = new ParamHolder <CCTVUserPrivilege>()
                    {
                        Sync  = sync,
                        Param = sp
                    };
                }
            }
            break;

            default:
                break;
            }
        }
コード例 #3
0
        public CCTVHierarchyNode[] GetAllHierarchyRoots()
        {
            var hInfos = GetDefaultInfoFull <CCTVHierarchyInfo>(CCTVInfoType.HierarchyInfo);

            return(HierarchyInfoUtil.BuildTree(hInfos).ToArray());
        }
コード例 #4
0
        public void RegisterHierarchy(string logicalTreeName, TimeSpan interval, SyncUpdateHandler updateHandler, string savePath)
        {
            if (_syncParams.ContainsKey(CCTVInfoType.HierarchyInfo))
            {
                IDisposable dis = _syncParams[CCTVInfoType.HierarchyInfo] as IDisposable;
                dis.Dispose();
            }
            SyncParams <CCTVHierarchyInfo>             sp   = new SyncParams <CCTVHierarchyInfo>(HierarchyInfoUtil.CreateSection(logicalTreeName), interval, updateHandler, savePath);
            StaticInfoSynchronizer <CCTVHierarchyInfo> sync = new StaticInfoSynchronizer <CCTVHierarchyInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);

            _syncParams[CCTVInfoType.HierarchyInfo] = new ParamHolder <CCTVHierarchyInfo>()
            {
                Sync  = sync,
                Param = sp
            };
        }