Exemple #1
0
 public void Dispose()
 {
     if (ClientHub != null)
     {
         ClientHub.RemoveUpdateHandler(CCTVInfoType.GlobalInfo, onGlobalInfoUpdate);
     }
 }
        protected DestinationControllerAbstract(XmlNode node, NgExecutionController executionController)
        {
            this.config = node;
            this.executionController = executionController;

            this.eventDistributor = executionController.eventDistributor;
            this.clientHub        = executionController.clientHub;

            this.executionNodeID = node.Attributes["executionNodeUuid"]?.Value;
            this.uuid            = node.Attributes["uuid"]?.Value;

            try {
                name = config.Attributes["name"].Value;
            } catch (Exception) {
                Console.WriteLine("Error: No Name define <destination>");
                return;
            }

            this.triggerIDs      = SetTriggerIDS();
            this.saveMessageFile = SetVar("saveMessageFile", null);
            this.dataSource      = SetVar("dataSource", null);
            this.dataFile        = SetVar("dataFile", null);
            this.excelRowStart   = SetVar("excelRowStart", -1);

            this.amsHost    = SetVar("amshost", null);
            this.amsToken   = SetVar("amstoken", null);
            this.amsAptCode = SetVar("aptcode", null);
            this.amsTimeout = SetVar("amstimeout", null);

            this.ConfigOK = true;
        }
Exemple #3
0
 public CCTVStaticInfo GetStaticInfo(string videoId)
 {
     if (Environment.TickCount - _lastSITick > 60000)
     {
         _lastSITick = Environment.TickCount;
         ClientHub.UpdateDefault(CCTVInfoType.StaticInfo);
     }
     return(ClientHub.GetStaticInfo(videoId));
 }
Exemple #4
0
 public CCTVControlConfig GetControlConfig(string videoId)
 {
     if (Environment.TickCount - _lastCCTick > 60000)
     {
         _lastCCTick = Environment.TickCount;
         ClientHub.UpdateDefault(CCTVInfoType.ControlConfig);
     }
     return(ClientHub.GetControlConfig(videoId));
 }
        public VideoDataSource GetStorageSource()
        {
            ClientHub?.UpdateRegistered <StorageSource>();
            StorageSource ss = ClientHub?.GetRegisteredInfo <StorageSource>("Default");

            return(new VideoDataSource()
            {
                SrcType = SourceType.Remote,
                Storage = ss,
            });
        }
 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;
 }
 private void dispose(bool disposing)
 {
     if (_disposed)
     {
         if (disposing)
         {
             ClientHub.Dispose();
             ThumbnailMgr.Dispose();
         }
         ClientHub    = null;
         ThumbnailMgr = null;
         _disposed    = true;
     }
 }
        /// <summary>
        /// Попытка подключить хаб
        /// </summary>
        private async void TryConnect()
        {
            try
            {
                await ClientHub.StartAsync();

                IsConnected = true;
                System.Diagnostics.Debug.WriteLine("Was connected");
            }
            catch (Exception exception)
            {
                IsConnected = false;
                System.Diagnostics.Debug.WriteLine(exception.Message);
                throw new Exception();
            }
        }
Exemple #9
0
        private void onGlobalInfoUpdate(IEnumerable <string> keysUpdated)
        {
            CCTVGlobalInfo gi = ClientHub.GetGlobalInfo();

            if (gi != null)
            {
                if (CCTV1Info == null || CCTV1Info.ServerHost != gi.CCTV1Host)
                {
                    if (CCTV1Info != null)
                    {
                        CCTV1Info.Stop();
                    }
                    CCTV1Info = new CCTVInfo(gi.CCTV1Host);
                    CCTV1Info.Start();
                    if (_control != null)
                    {
                        _control.CCTV1Info = this.CCTV1Info;
                    }
                }
            }
        }
        public bool Login(string userName, string pwd, ref string errMsg)
        {
            ClientHub.UpdateDefault(CCTVInfoType.UserInfo);
            CCTVUserInfo ui = ClientHub.GetUserInfo(userName);

            if (ui != null)
            {
                if (pwd != null && MD5Encryptor.GetMD5Hash(pwd).Equals(ui.Password))
                {
                    return(true);
                }
                else
                {
                    errMsg = "密码错误";
                    return(false);
                }
            }
            else
            {
                errMsg = "用户不存在";
                return(false);
            }
        }
        private void UpdateWebApiUrl(string ip)
        {
            string url = $"http://{ip}:{ConfigReader.Instance.WebApiPort}";

            if (ClientHub != null)
            {
                ClientHub.Dispose();
            }
            if (ThumbnailMgr != null)
            {
                ThumbnailMgr.Dispose();
            }

            ClientHub    = new CCTVDefaultInfoSync(url);
            ThumbnailMgr = new ThumbnailManager(url, ConstSettings.ThumbnailPath);
            //集中存储配置信息获取。
            SyncParams <StorageSource> param = new SyncParams <StorageSource>("CenterStorage", Timeout.InfiniteTimeSpan);

            ClientHub.RegisterDefault(CCTVInfoType.HierarchyInfo, TimeSpan.Zero);
            ClientHub.RegisterDefault(CCTVInfoType.StaticInfo, TimeSpan.Zero);
            ClientHub.RegisterDefault(CCTVInfoType.OnlineStatus, TimeSpan.FromSeconds(5));
            ClientHub.RegisterDefault(CCTVInfoType.DynamicInfo, TimeSpan.FromSeconds(5));
            ClientHub.RegisterSynchronizer(param);
        }
Exemple #12
0
 public SipIdMap[] GetAllSipIdMap()
 {
     ClientHub.UpdateRegistered <SipIdMap>();
     return(ClientHub.GetAllRegisteredInfos <SipIdMap>());
 }
Exemple #13
0
 public void PutSipIdMap(string videoId, SipIdMap map, bool isDeleted)
 {
     ClientHub.PutRegisteredInfo(videoId, map, isDeleted);
 }
Exemple #14
0
 private Platform[] getAllPlatform(PlatformType pt)
 {
     ClientHub.UpdateRegistered <Platform>();
     Platform[] plats = ClientHub.GetAllRegisteredInfos <Platform>();
     return(plats?.Where(p => p.Type == pt).ToArray());
 }
Exemple #15
0
 public SipIdMap GetSipIdMap(string videoId)
 {
     ClientHub.UpdateRegistered <SipIdMap>();
     return(ClientHub.GetRegisteredInfo <SipIdMap>(videoId));
 }
 public CCTVGlobalInfo GetGlobalInfo()
 {
     return(ClientHub.GetGlobalInfo());
 }
        protected SourceControllerAbstract(XmlNode node, int chainDepth, List <string> triggersInUse, int serverOffset, NgExecutionController executionController)
        {
            this.node                = node;
            this.triggersInUse       = triggersInUse;
            this.clientHub           = executionController?.clientHub;
            eventDistributor         = executionController?.eventDistributor;
            this.executionController = executionController;
            this.serverOffset        = serverOffset;
            name = node.Attributes["name"]?.Value;
            id   = node.Attributes["ID"]?.Value;

            dataSourceType   = node.Attributes["dataSource"]?.Value;
            flightSourceType = node.Attributes["flttype"]?.Value;

            executionNodeID = node.Attributes["executionNodeUuid"]?.Value;
            uuid            = node.Attributes["uuid"]?.Value;

            if ((flightSourceType != null && flightSourceType != "none") || node.Name == "amsdatadriven")
            {
                if (flightSourceType == "arr")
                {
                    flttype = FlightType.Arrival;
                }
                else if (flightSourceType == "dep")
                {
                    flttype = FlightType.Departure;
                }
                else
                {
                    flttype = FlightType.Both;
                }

                try {
                    if (node.Attributes["flightSetFrom"] != null)
                    {
                        flightSetFrom = int.Parse(node.Attributes["flightSetFrom"]?.Value);
                    }
                    else
                    {
                        flightSetFrom = -180;
                    }
                } catch (Exception) {
                    flightSetFrom = -180;
                }
                try {
                    if (node.Attributes["flightSetTo"] != null)
                    {
                        flightSetTo = int.Parse(node.Attributes["flightSetTo"]?.Value);
                    }
                    else
                    {
                        flightSetTo = 180;
                    }
                } catch (Exception) {
                    flightSetTo = 180;
                }
                try {
                    if (node.Attributes["refreshFlight"] != null)
                    {
                        refreshFlight = bool.Parse(node.Attributes["refreshFlight"]?.Value);
                    }
                    else
                    {
                        refreshFlight = false;
                    }
                } catch (Exception) {
                    refreshFlight = false;
                }
            }
            else
            {
                flttype = FlightType.None;
            }

            switch (dataSourceType)
            {
            case "CSV":
                dataFile            = node.Attributes["dataFile"]?.Value;
                dataSourceFileOrURL = node.Attributes["sourceType"]?.Value;
                dataRestURL         = node.Attributes["dataRestURL"]?.Value;
                break;

            case "Excel":
                dataFile      = node.Attributes["dataFile"]?.Value;
                excelSheet    = node.Attributes["excelSheet"]?.Value;
                excelRowStart = node.Attributes["excelRowStart"]?.Value;
                excelRowEnd   = node.Attributes["excelRowEnd"]?.Value;
                break;

            case "XML":
                dataFile            = node.Attributes["dataFile"]?.Value;
                dataRestURL         = node.Attributes["dataRestURL"]?.Value;
                repeatingElement    = node.Attributes["repeatingElement"]?.Value;
                dataSourceFileOrURL = node.Attributes["sourceType"]?.Value;
                try {
                    xmlToString = bool.Parse(node.Attributes["xmlToString"]?.Value);
                } catch (Exception) {
                    xmlToString = false;
                }
                break;

            case "JSON":
                dataFile            = node.Attributes["dataFile"]?.Value;
                dataRestURL         = node.Attributes["dataRestURL"]?.Value;
                dataSourceFileOrURL = node.Attributes["sourceType"]?.Value;
                repeatingElement    = node.Attributes["repeatingElement"]?.Value;
                break;

            case "DATABASE":
            case "MSSQL":
            case "MySQL":
            case "ORACLE":
                connStr = node.Attributes["connStr"]?.Value;
                sql     = node.Attributes["sql"]?.Value;
                dbType  = node.Attributes["sourceType"]?.Value;
                break;
            }

            dataSourceFileOrURL = dataSourceFileOrURL ?? "file";

            XmlNode filtersDefn = node.SelectSingleNode("./filter");

            if (filtersDefn != null)
            {
                /*
                 * At the top level, there is only one Expresssion, which it self can be a compound
                 * expression or a single data filter
                 *
                 * When the Expression itself is constucted, it recurssive creates all the Expression o
                 * filters configured under it
                 */

                // Cycle through the expressions types (and, or, not, xor) to see if any exist
                foreach (string eType in Expression.expressionTypes)
                {
                    XmlNode exprDefn = filtersDefn.SelectSingleNode($"./{eType}");
                    if (exprDefn != null)
                    {
                        expression = new Expression(exprDefn);
                    }
                }

                FilterFactory fact = new FilterFactory();
                // Cycle through the data filter types (and, or, not, xor) to see if any exist
                foreach (string fType in Expression.filterTypes)
                {
                    XmlNode filtDefn = filtersDefn.SelectSingleNode($"./{fType}");
                    if (filtDefn != null)
                    {
                        topLevelFilter = fact.GetFilter(filtDefn);
                    }
                }

                try {
                    filterTime = filtersDefn.Attributes["filterTime"]?.Value;
                } catch (Exception) {
                    filterTime = "post";
                }

                if (filterTime == null)
                {
                    filterTime = "post";
                }
            }

            // Add the chained controllers
            foreach (XmlNode chained in node.SelectNodes("./chained"))
            {
                chainedController.Add(new RateDrivenSourceController(chained, chainDepth++, triggersInUse, serverOffset, executionController));
            }
        }
 public CCTVOnlineStatus GetOnlineStatus(string videoId)
 {
     return(ClientHub?.GetOnlineStatus(videoId));
 }
 public CCTVControlConfig GetControlConfig(string videoId)
 {
     return(ClientHub.GetControlConfig(videoId));
 }
 public CCTVVideoTrack GetVideoTrack(string videoId)
 {
     return(ClientHub.GetAllVideoTrackInfo(videoId));
 }
Exemple #21
0
 public CCTVUserPrivilege GetUserPrivilege(string userName)
 {
     ClientHub.UpdateDefault(CCTVInfoType.UserPrivilege);
     return(ClientHub.GetUserPrivilege(userName));
 }
Exemple #22
0
 public CCTVHierarchyInfo[] GetAllHierarchy()
 {
     ClientHub.UpdateDefault(CCTVInfoType.HierarchyInfo);
     return(ClientHub.GetAllHierarchyInfo());
 }
Exemple #23
0
 public CCTVStaticInfo[] GetAllStaticInfo()
 {
     ClientHub.UpdateDefault(CCTVInfoType.StaticInfo);
     return(ClientHub.GetAllStaticInfo());
 }
 public CCTVDynamicInfo[] GetAllDynamicInfo()
 {
     return(ClientHub.GetAllDynamicInfo());
 }
Exemple #25
0
 public CCTVControlConfig GetControlConfig(string videoId)
 {
     ClientHub.UpdateDefault(CCTVInfoType.ControlConfig);
     return(ClientHub.GetControlConfig(videoId));
 }
 public CCTVHierarchyNode GetHierarchyRoot()
 {
     return(ClientHub?.GetAllHierarchyRoots()?.First());
 }
Exemple #27
0
 public CCTVHierarchyInfo GetHierarchy(string id)
 {
     ClientHub.UpdateDefault(CCTVInfoType.HierarchyInfo);
     return(ClientHub.GetHierarchyInfo(id));
 }
 public CCTVStaticInfo GetStaticInfo(string videoId)
 {
     return(ClientHub?.GetStaticInfo(videoId));
 }
Exemple #29
0
 public void PutPlatformDevices(PlatformDeviceSet platDev, bool isDel)
 {
     ClientHub.PutRegisteredInfo(platDev.PlatformId, platDev, isDel);
 }
 public CCTVDynamicInfo GetDynamicInfo(string videoId)
 {
     return(ClientHub?.GetDynamicInfo(videoId));
 }