Beispiel #1
0
 /// <summary>
 /// The validate.
 /// </summary>
 /// <returns>
 /// The <see cref="ValidateResult"/>.
 /// </returns>
 public ValidateResult Validate()
 {
     string error = string.IsNullOrEmpty(this.DataFileName) ? "Data file name cannot be empty" : null;
     var result = new ValidateResult(error == null, error);
     return result;
 }
Beispiel #2
0
        /// <summary>
        /// The validate database.
        /// </summary>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <returns>
        /// The <see cref="ValidateResult"/>.
        /// </returns>
        public ValidateResult ValidateDatabase(IProgressCallback callback)
        {
            this.Logger.Info("Validate database");
            string error = null;

            using (var connection = new SQLiteConnection(this._connectionString))
            {
                error = string.Empty;
                using (
                    var getFlightCmd = new SQLiteCommand(@"SELECT COUNT(*) FROM FLIGHT WHERE LJOURNEYID NOT IN (SELECT LID FROM JOURNEY)", connection)
                    )
                {
                    connection.Open();
                    object result = getFlightCmd.ExecuteScalar();

                    long orphanCount;
                    if (result == null || result is DBNull)
                    {
                        orphanCount = 0;
                    }
                    else
                    {
                        orphanCount = (long)result;
                    }

                    if (orphanCount > 0)
                    {
                        error = string.Format("There are {0} orphan flights without any assosiated journey detail", orphanCount);
                    }
                }
            }

            var valResult = new ValidateResult(error == null, error);
            return valResult;
        }
Beispiel #3
0
        /// <summary>
        /// The validate.
        /// </summary>
        /// <returns>
        /// The <see cref="ValidateResult"/>.
        /// </returns>
        public ValidateResult Validate()
        {
            string error = null;

            if (this.ApiKey == null || this.ApiKey.Length < 1 || this.ApiSecret == null || this.ApiSecret.Length < 1)
            {
                error = "User did not configure DropBox account";
            }
            else
            {
                bool sameAppKey = ObjectExtension.AreEquals(this.ApiKey, DropBoxSyncConfigBuilder.ApiKey)
                                  && ObjectExtension.AreEquals(this.ApiSecret, DropBoxSyncConfigBuilder.ApiSec);
                if (sameAppKey)
                {
                    if (this.UserToken == null || this.UserToken.Length < 1 || this.UserSecret == null || this.UserSecret.Length < 1)
                    {
                        error = "User did not authorize with DropBox";
                    }
                }
                else
                {
                    error = "The authorization token is invalid. It is necessary to re-authenticate with DropBox!";
                }
            }

            var result = new ValidateResult(error == null, error);
            this.DropBoxBaseFolder = "/" + this.DropBoxBaseFolder.Replace('\\', '/').Trim('/');
            return result;
        }