static void Main(String[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { string message = ""; if (DependencyHelper.CheckDependencies(ref message)) { Application.Run(new ScriptWizard()); } else { MessageBox.Show(message, "Dependencies"); } } catch (Exception ex) { MessageBox.Show("Sorry! SQLAzureMW encountered an error. Please see additional information to resolve." + Environment.NewLine + ex.ToString()); } }
static int Main(string[] args) { try { Assembly assem = Assembly.GetEntryAssembly(); AssemblyName assemName = assem.GetName(); Console.WriteLine(CommonFunc.FormatString(Properties.Resources.ProgramVersion, assemName.Name, assemName.Version.ToString())); string message = ""; if (!DependencyHelper.CheckDependencies(ref message)) { Console.WriteLine(message); return(-1); } try { string txt = CommonFunc.GetTextFromFile(CommonFunc.GetAppSettingsStringValue("ObjectSelector")); _ObjectSelector = (ObjectSelector)CommonFunc.DeserializeXmlString(txt, typeof(ObjectSelector)); } catch (Exception ex) { Console.WriteLine(ex.Message); _ObjectSelector = GenerateDefaultObjectSelector(); } finally { if (_ObjectSelector == null) { _ObjectSelector = GenerateDefaultObjectSelector(); } } string argValues = Environment.NewLine + Properties.Resources.ProgramArgs + Environment.NewLine; _outputDir = new StringBuilder(CommonFunc.GetAppSettingsStringValue("OutputDirectory")); _SourceServerName = ConfigurationManager.AppSettings["SourceServerName"]; _SourceUserName = ConfigurationManager.AppSettings["SourceUserName"]; _SourcePassword = ConfigurationManager.AppSettings["SourcePassword"]; _SourceDatabase = ConfigurationManager.AppSettings["SourceDatabase"]; _bSourceConnectNTAuth = CommonFunc.GetAppSettingsBoolValue("SourceConnectNTAuth"); _OutputResultsFile = ConfigurationManager.AppSettings["OutputResultsFile"]; _bAddDateTimeFolder = CommonFunc.GetAppSettingsBoolValue("AppendDateTimeFolder"); for (int index = 0; index < args.Length; index++) { switch (args[index]) { case "-a": case "/a": _bAddDateTimeFolder = args[++index].Equals(Properties.Resources.True, StringComparison.CurrentCultureIgnoreCase); break; case "-S": case "/S": _SourceServerName = args[++index]; break; case "-U": case "/U": _SourceUserName = args[++index]; break; case "-P": case "/P": _SourcePassword = args[++index]; break; case "-D": case "/D": _SourceDatabase = args[++index]; break; case "-o": case "/o": _OutputResultsFile = args[++index]; break; case "-O": case "/O": _outputDir.Remove(0, _outputDir.Length); _outputDir.Append(args[++index]); break; case "-T": case "/T": _bSourceConnectNTAuth = true; break; default: Console.WriteLine(argValues); return(-1); } } int retVal = Process(); return(retVal); } catch (Exception ex) { Console.WriteLine(ex.Message); return(-1); } }
static void Main(string[] args) { Assembly assem = Assembly.GetEntryAssembly(); AssemblyName assemName = assem.GetName(); Console.WriteLine(CommonFunc.FormatString(Properties.Resources.ProgramVersion, assemName.Name, assemName.Version.ToString())); string message = ""; if (!DependencyHelper.CheckDependencies(ref message)) { Console.WriteLine(message); return; } string argValues = Environment.NewLine + Properties.Resources.ProgramArgs + Environment.NewLine; _TargetServerName = CommonFunc.GetAppSettingsStringValue("TargetServerName"); _TargetUserName = CommonFunc.GetAppSettingsStringValue("TargetUserName"); _Collation = CommonFunc.GetAppSettingsStringValue("DBCollation"); _TargetPassword = CommonFunc.GetAppSettingsStringValue("TargetPassword"); _FileToProcess = CommonFunc.GetAppSettingsStringValue("FileToProcess"); _TargetDatabase = CommonFunc.GetAppSettingsStringValue("TargetDatabase"); _TargetDatabaseSize = Convert.ToInt32(ConfigurationManager.AppSettings["TargetDatabaseSize"], CultureInfo.InvariantCulture); _TargetEdition = CommonFunc.GetAppSettingsStringValue("TargetDatabaseEdition"); _OutputResultsFile = CommonFunc.GetAppSettingsStringValue("OutputResultsFile"); _bTargetConnectNTAuth = CommonFunc.GetAppSettingsBoolValue("TargetConnectNTAuth"); _bDropExistingDatabase = CommonFunc.GetAppSettingsBoolValue("DropOldDatabaseIfExists"); for (int index = 0; index < args.Length; index++) { switch (args[index]) { case "-S": case "/S": _TargetServerName = args[++index]; break; case "-U": case "/U": _TargetUserName = args[++index]; break; case "-P": case "/P": _TargetPassword = args[++index]; break; case "-D": case "/D": _TargetDatabase = args[++index]; break; case "-i": case "/i": _FileToProcess = args[++index]; break; case "-c": case "/c": _Collation = args[++index]; break; case "-o": case "/o": _OutputResultsFile = args[++index]; try { File.AppendAllText(_OutputResultsFile, "SQLAzureMWBatchUpload"); } catch (Exception ex) { Console.WriteLine(CommonFunc.FormatString(Properties.Resources.ErrorOpeningFile, _OutputResultsFile, ex.Message)); return; } break; case "-e": case "/e": _TargetEdition = args[++index].ToLower(CultureInfo.InvariantCulture); if (!_TargetEdition.Equals("web") && !_TargetEdition.Equals("business")) { Console.WriteLine(CommonFunc.FormatString(Properties.Resources.InvalidDatabaseEdition, _TargetEdition)); return; } break; case "-s": case "/s": try { int size = Convert.ToInt32(args[++index], CultureInfo.InvariantCulture); if (size != 1 && size != 5 && size != 10 && size != 20 && size != 30 && size != 40 && size != 50 && size != 100 && size != 150) { Console.WriteLine(Properties.Resources.InvalidDatabaseSize); return; } _TargetDatabaseSize = size; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); Console.WriteLine(CommonFunc.FormatString(Properties.Resources.InvalidDatabaseEdition, args[index])); return; } break; case "-T": case "/T": _bTargetConnectNTAuth = true; break; case "-d": case "/d": _bDropExistingDatabase = args[++index].Equals(Properties.Resources.True, StringComparison.CurrentCultureIgnoreCase); break; default: Console.WriteLine(argValues); return; } } Process(); }