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> /// The GetClusterConfig method. /// </summary> /// <param name="system">The <paramref name="system"/> to get the cluster configuration for.</param> public void GetClusterConfig(VXSystem system) { if (system == null) { return; } var clusterConfig = system.ClusterConfig; if (clusterConfig == null) { return; } AddPropertyInfo(clusterConfig, "Cluster Configuration"); AddPropertyInfo(clusterConfig.TimeConfig, "Time Configuration"); foreach (var node in clusterConfig.NodeConfigurations) { AddPropertyInfo(node, "Node Configuration"); } if (clusterConfig.StatusDescription.Length <= 25) { return; } lvClusterConfigDetails.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); lvClusterConfigDetails.Columns[0].Width = 0; }
/// <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); }
private bool Initialize(string ip, Login login) { _system = new VXSystem(ip); var result = login.Invoke(_system); if (result != Results.Value.OK) { LOG.Error($"Failed to log into VideoXpert system at {ip}"); _started.Set(); return(false); } LOG.Info($"Successfully logged into VideoXpert system {ip}"); _initialized = true; _started.Set(); return(true); }
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()); }
/// <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); } }
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); }