Beispiel #1
0
        private void Init()
        {
            var retVal = VxGlobal.SetLogLevel(Const.VxSdkLogLevel);

            if (retVal != Results.Value.OK)
            {
                Log.LogThenThrow(new Exception($"Unable to set VxSdk log level. {retVal}"));
            }
            retVal = VxGlobal.SetLogPath(Const.VxSdkLogFilePath);
            if (retVal != Results.Value.OK)
            {
                Log.LogThenThrow(new Exception($"Unable to set VxSdk log path. {retVal}"));
            }

            Uri    baseUri = new Uri(_host.GetBaseUri());
            string authKey = _host.GetAuthToken();

            _system = new VXSystem(baseUri.Host, Const.SdkLicense);
            retVal  = _system.Login(authKey);
            if (!retVal.IsSuccessful())
            {
                Log.LogThenThrow(new Exception($"Unable to login via VxSdk. {retVal}"));
            }
            Log.Debug("Successfully initialized VxSdk");
        }
        /// <summary>
        /// Initializes and logs in to a VideoXpert system.
        /// </summary>
        /// <param name="ip">The IP address of the system.</param>
        /// <param name="username">The user name to log in with.</param>
        /// <param name="password">The password to log in with.</param>
        /// <returns>The Init Task.</returns>
        public static async Task <Results.Value> Init(string ip, string username, string password)
        {
            var retVal = Results.Value.UnknownError;

            try
            {
                system = new VXSystem(ip, 443, true, LicenseKey);
                retVal = await Task.Run(() => system.Login(username, password));
            }
            catch (Exception e)
            {
                Trace.WriteLine(new Exception(Resources.InitErrorMessage, e));
                system = null;
            }

            return(retVal);
        }
Beispiel #3
0
        private bool EnsureAuthKey()
        {
            var retVal = _system.Refresh();

            if (retVal != Results.Value.OK)
            {
                Uri    baseUri = new Uri(_host.GetBaseUri());
                string authKey = _host.GetAuthToken();
                _system.Dispose();

                _system = new VXSystem(baseUri.Host, Const.SdkLicense);
                retVal  = _system.Login(authKey);
                if (!retVal.IsSuccessful())
                {
                    Log.Warn($"Unable to refresh auth key/login via VxSdk. {retVal}");
                }
            }
            return(retVal.IsSuccessful());
        }
Beispiel #4
0
        /// <summary>
        /// Connects to the StarWatch Mock Camera SDK using the information supplied
        /// </summary>
        /// <param name="ip">'ip address' to connect to.</param>
        /// <param name="username">username to connect with. </param>
        /// <param name="password">password to connect with.</param>
        /// <returns>System object if connection was successful, otherwise null</returns>
        public static VXSystem ConnectToDVR(string ip, string username, string password)
        {
            lock (_loggedInSystemLock)
            {
                if (_loggedInSystem != null)
                {
                    return(_loggedInSystem);
                }

                _loggedInSystem = new VXSystem(ip);
                _loggedInSystem.InitializeSdk(SdkKey);
                var result = _loggedInSystem.Login(username, password);
                if (result != Results.Value.OK)
                {
                    return(null);
                }
                return(_loggedInSystem);
            }
        }
Beispiel #5
0
        public async Task <bool> Init(string ip, string username, string password)
        {
            bool success = false;

            try
            {
                _system = new VXSystem(ip);
                var retVal = await Task.Run(() => _system.Login(username, password));

                if (retVal != Results.Value.OK)
                {
                    throw new Exception(retVal + "Unable to login to the VideoXpert system provided ({ip}) with user ({username})");
                }
                success = true;
            }
            catch (Exception e)
            {
                Trace.WriteLine(new Exception("Threw while Init VxSdk", e));
                _system = null;
            }
            return(success);
        }