/// <summary> /// Should return false if the command is not in a state ready to be executed. /// </summary> public override bool Ready() { if (string.IsNullOrWhiteSpace(Target)) { return(false); } var conn = new SqlConnectionStringBuilder { DataSource = Target }; if (string.IsNullOrWhiteSpace(Username)) { conn.IntegratedSecurity = true; } else { conn.UserID = Username; conn.Password = Password; } ConnectionString = conn.ToString(); // Setup the Default Connection Strings ContextConnectionStringManager.SetupDefaultConnections(ConnectionString); return(true); }
/// <summary> /// Preprocess the data and display any errors found /// </summary> private static void PreprocessData() { // Set the Context Connection Strings ContextConnectionStringManager.SetupDefaultConnections(Settings.Target); PreprocessDataEntryCommonMigrations(ContextNames.Reports); PreprocessDataEntryCommonMigrations(ContextNames.Summaries); }
/// <summary> /// Create the Unit Of Work and add it to the dictionary. /// </summary> /// <typeparam name="TUnitOfWork">The Type of Unit Of Work to add to the Dictionary</typeparam> /// <param name="key">Name of the Key to find the UnitOfWork in the Dictionary</param> private UnitOfWork AddUnitOfWork <TUnitOfWork>(string key) where TUnitOfWork : UnitOfWork, new() { var connString = string.Format(ConfigurationManager.ConnectionStrings[key].ConnectionString, _dbSource); ContextConnectionStringManager.SetupDefaultConnections(connString); var unitOfWork = new TUnitOfWork(); _unitsOfWork.Add(key, unitOfWork); return(unitOfWork); }
/// <summary> /// Process the incoming arguments /// </summary> private static void ProcessArguments(Dictionary <string, string> arguments) { // Load Settings Settings.LoadFromArguments(arguments); // Set the Context Connection Strings ContextConnectionStringManager.SetupDefaultConnections(Settings.Target); // Silent mode will hide the console window. if (Settings.Silent) { WindowsInterop.HideConsole(); Log.Info("Running Silent"); } // Make sure we have proper options to continue. var validTarget = !string.IsNullOrWhiteSpace(Settings.Target); var validApplication = !string.IsNullOrWhiteSpace(Settings.AppPoolIdentity); var validImplementation = !string.IsNullOrWhiteSpace(Settings.Implementation); if (!validTarget) { Exit("Invalid target.", 1); } if (!validApplication) { Exit("Application is required.", 1); } if (!validImplementation) { Exit("Implementation is required.", 1); // Is it? (yes for the Meta) } // Log Current Settings Settings.LogCurrentValues(); // If we are dropping databases ask to make sure. if (!Settings.Silent && Settings.Reinstall) { Log.Info(""); Log.Info(@"Reinstalling will drop any existing databases."); // Console Interaction Console.Write(@"Are you sure you want to continue? (y/n): _"); Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop); var answer = Console.ReadLine(); if (answer != null && !string.Equals(answer.Trim(), "y", StringComparison.InvariantCultureIgnoreCase)) { Exit("Installation was aborted!"); } } }