Ejemplo n.º 1
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public InstanceInfo()
 {
     this._serverProperties   = null;
     this.IsEnabled           = true;
     this.IsODBC              = false;
     this.IsDynamicConnection = false;
 }
Ejemplo n.º 2
0
		/// <summary>
		/// Default constructor
		/// </summary>
		public InstanceInfo()
		{
			this._serverProperties    = null;
			this.IsEnabled            = true;
			this.IsODBC               = false;
			this.IsDynamicConnection  = false;
		}
Ejemplo n.º 3
0
        public static ServerProperties Load(
            InstanceInfo instance,
            CurrentStorage storage
            )
        {
            ServerProperties storedProps = storage.ServerInstanceDirectory
                                           .GetServerProperties(instance);

            return(storedProps);
        }
Ejemplo n.º 4
0
        public ServerProperties LoadServerProperties(CurrentStorage storage)
        {
            ServerProperties storedProps = ServerProperties.Load(this, storage);

            if (storedProps != null)
            {
                this._serverProperties = storedProps;
            }

            return(this._serverProperties);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
		public void SetServerProperties(ServerProperties props)
		{
			this._serverProperties = props;
		}
Ejemplo n.º 7
0
		public ServerProperties LoadServerProperties(CurrentStorage storage)
		{
			ServerProperties storedProps = ServerProperties.Load(this, storage);

			if (storedProps != null)
			{
				this._serverProperties = storedProps;
			}

			return this._serverProperties;
		}
Ejemplo n.º 8
0
		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;
		}
Ejemplo n.º 9
0
		public InstanceInfo(ServerProperties serverProps) : this()
		{
			this._serverProperties = serverProps;
		}
Ejemplo n.º 10
0
		/// <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;
		}
Ejemplo n.º 11
0
		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;
		}
Ejemplo n.º 12
0
 public void SetServerProperties(ServerProperties props)
 {
     this._serverProperties = props;
 }
Ejemplo n.º 13
0
 public InstanceInfo(ServerProperties serverProps) : this()
 {
     this._serverProperties = serverProps;
 }
Ejemplo n.º 14
0
        /// <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);
        }