/// <summary> /// Default constructor /// </summary> public InstanceInfo() { this._serverProperties = null; this.IsEnabled = true; this.IsODBC = false; this.IsDynamicConnection = false; }
public static ServerProperties Load( InstanceInfo instance, CurrentStorage storage ) { ServerProperties storedProps = storage.ServerInstanceDirectory .GetServerProperties(instance); return(storedProps); }
public ServerProperties LoadServerProperties(CurrentStorage storage) { ServerProperties storedProps = ServerProperties.Load(this, storage); if (storedProps != null) { this._serverProperties = storedProps; } return(this._serverProperties); }
public ServerProperties InitServerProperties(CurrentStorage storage, int timeout = 0) { if (this._serverProperties == null) { try { this._serverProperties = ServerProperties.Query(this, timeout); storage.ServerInstanceDirectory.GetId(this.ConnectionGroup, this); // Save properties } catch (Exception exc) { log.WarnFormat( "Unable to retrieve instance version from remote server. Instance:'{0}';Authentication:'{1}';Exception:'{2}'", Instance, Authentication, exc ); ServerProperties storedProps = LoadServerProperties(storage); if (storedProps == null) { log.WarnFormat( "Instance version is not available. Instance:'{0}';Authentication:'{1}';Exception:'{2}'", Instance, Authentication, exc ); throw; } } } return(this._serverProperties); }
public void SetServerProperties(ServerProperties props) { this._serverProperties = props; }
public ServerProperties LoadServerProperties(CurrentStorage storage) { ServerProperties storedProps = ServerProperties.Load(this, storage); if (storedProps != null) { this._serverProperties = storedProps; } return this._serverProperties; }
public ServerProperties InitServerProperties(CurrentStorage storage, int timeout = 0) { if (this._serverProperties == null) { try { this._serverProperties = ServerProperties.Query(this, timeout); storage.ServerInstanceDirectory.GetId(this.ConnectionGroup, this); // Save properties } catch (Exception exc) { log.WarnFormat( "Unable to retrieve instance version from remote server. Instance:'{0}';Authentication:'{1}';Exception:'{2}'", Instance, Authentication, exc ); ServerProperties storedProps = LoadServerProperties(storage); if (storedProps == null) { log.WarnFormat( "Instance version is not available. Instance:'{0}';Authentication:'{1}';Exception:'{2}'", Instance, Authentication, exc ); throw; } } } return this._serverProperties; }
public InstanceInfo(ServerProperties serverProps) : this() { this._serverProperties = serverProps; }
/// <summary> /// The validate license. /// </summary> /// <param name="fullSlowCheck">The full slow check.</param> /// <returns> /// The <see cref="LicenseState" />. /// </returns> public LicenseState ValidateLicense(bool fullSlowCheck, bool withCheckConnection = true) { if (this._foundLicenseState != null) { return this._foundLicenseState; } this._foundLicenseState = new LicenseState { Instance = this.Instance }; if (this.LicenseInfo == null) { if (AppVersionHelper.IsNotRelease()) { return this._foundLicenseState; } this._foundLicenseState.AddProblem(LicenseProblemType.LicenseNotDefined, string.Empty); } else { this._foundLicenseState.AddProblems(this.LicenseInfo.IsLicenseInfoCorrect()); DateTime dateTime; if (fullSlowCheck && withCheckConnection) { if (this._serverProperties != null) { dateTime = this._serverProperties.Date; } else { try { ServerProperties props = ServerProperties.Query(this); dateTime = props.Date; this._serverProperties = props; } catch (Exception exc) { log.Error("Exception:", exc); log.ErrorFormat( "Instance:'{0}';Authentication:'{1}';Exception:'{2}'", Instance, Authentication, exc ); dateTime = DateTime.MaxValue; } } } else { dateTime = DateTime.Now; } var buildDateObject = Assembly.GetExecutingAssembly() .GetCustomAttributes(typeof (BuildDateAttribute), false) .FirstOrDefault(); DateTime buildDate = DateTime.MaxValue; if (buildDateObject is BuildDateAttribute) { buildDate = (buildDateObject as BuildDateAttribute).BuildDate; } if (dateTime == DateTime.MaxValue) { this._foundLicenseState.AddProblem(LicenseProblemType.CantConnect, string.Empty); } else if (this._foundLicenseState.IsCorrect && fullSlowCheck && (dateTime > this.LicenseInfo.ExpiryDate)) { this._foundLicenseState.AddProblem(LicenseProblemType.Expired, string.Empty); } else if (buildDate > this.LicenseInfo.BuildExpiryDate) { this._foundLicenseState.AddProblem(LicenseProblemType.BuildExpiryDateNotValid, string.Empty); } else { if (AppVersionHelper.IsNotDebug()) { string hash = this.GetHash(); CryptoProcessor cryptoProcessor = new CryptoProcessor( Program.Model.Settings.SystemSettings.PublicKeyXmlSign, Program.Model.Settings.SystemSettings.PrivateKeyXmlDecrypt ); if (!cryptoProcessor.Verify(hash, this.LicenseInfo.Signature)) { this._foundLicenseState.AddProblem(LicenseProblemType.WrongSignature, string.Empty); } } } } var result = this._foundLicenseState; if (!fullSlowCheck) { this._foundLicenseState = null; } return result; }
private List<InstanceInfo> ExecuteSelectInstancesCommand(SQLiteConnection connection, string sql) { List<InstanceInfo> result = new List<InstanceInfo>(); new SqlSelectCommand( connection, sql, reader => { InstanceVersion version = new InstanceVersion(reader[ServerInstanceDirectory.ServerInstanceVersionFn].ToString()); ServerProperties props = new ServerProperties( version, reader[ServerInstanceDirectory.ServerInstanceNameFn].ToString(), DateTime.Now ); AuthenticationInfo auth = new AuthenticationInfo { IsWindows = (bool) reader[LoginDirectory.IsWinAuthFn], Username = reader[LoginDirectory.LoginFn].ToString(), Password = this._cryptoService.Decrypt(reader[LoginDirectory.PasswordFn].ToString()) }; result.Add( new InstanceInfo(props) { Authentication = auth, Instance = reader[ServerInstanceDirectory.ConnectionNameFn].ToString(), IsEnabled = true, Name = reader[ServerInstanceDirectory.ConnectionNameFn].ToString(), DbType = reader[ServerInstanceDirectory.DbTypeFn].ToString(), IsODBC = (bool) reader[ServerInstanceDirectory.IsOdbcFn] } ); } ).Execute(100); return result; }
/// <summary> /// The validate license. /// </summary> /// <param name="fullSlowCheck">The full slow check.</param> /// <returns> /// The <see cref="LicenseState" />. /// </returns> public LicenseState ValidateLicense(bool fullSlowCheck, bool withCheckConnection = true) { if (this._foundLicenseState != null) { return(this._foundLicenseState); } this._foundLicenseState = new LicenseState { Instance = this.Instance }; if (this.LicenseInfo == null) { if (AppVersionHelper.IsNotRelease()) { return(this._foundLicenseState); } this._foundLicenseState.AddProblem(LicenseProblemType.LicenseNotDefined, string.Empty); } else { this._foundLicenseState.AddProblems(this.LicenseInfo.IsLicenseInfoCorrect()); DateTime dateTime; if (fullSlowCheck && withCheckConnection) { if (this._serverProperties != null) { dateTime = this._serverProperties.Date; } else { try { ServerProperties props = ServerProperties.Query(this); dateTime = props.Date; this._serverProperties = props; } catch (Exception exc) { log.Error("Exception:", exc); log.ErrorFormat( "Instance:'{0}';Authentication:'{1}';Exception:'{2}'", Instance, Authentication, exc ); dateTime = DateTime.MaxValue; } } } else { dateTime = DateTime.Now; } var buildDateObject = Assembly.GetExecutingAssembly() .GetCustomAttributes(typeof(BuildDateAttribute), false) .FirstOrDefault(); DateTime buildDate = DateTime.MaxValue; if (buildDateObject is BuildDateAttribute) { buildDate = (buildDateObject as BuildDateAttribute).BuildDate; } if (dateTime == DateTime.MaxValue) { this._foundLicenseState.AddProblem(LicenseProblemType.CantConnect, string.Empty); } else if (this._foundLicenseState.IsCorrect && fullSlowCheck && (dateTime > this.LicenseInfo.ExpiryDate)) { this._foundLicenseState.AddProblem(LicenseProblemType.Expired, string.Empty); } else if (buildDate > this.LicenseInfo.BuildExpiryDate) { this._foundLicenseState.AddProblem(LicenseProblemType.BuildExpiryDateNotValid, string.Empty); } else { if (AppVersionHelper.IsNotDebug()) { string hash = this.GetHash(); CryptoProcessor cryptoProcessor = new CryptoProcessor( Program.Model.Settings.SystemSettings.PublicKeyXmlSign, Program.Model.Settings.SystemSettings.PrivateKeyXmlDecrypt ); if (!cryptoProcessor.Verify(hash, this.LicenseInfo.Signature)) { this._foundLicenseState.AddProblem(LicenseProblemType.WrongSignature, string.Empty); } } } } var result = this._foundLicenseState; if (!fullSlowCheck) { this._foundLicenseState = null; } return(result); }