/// <summary> /// Returns the auto-generated device names /// </summary> public List <string> PreConnect(string clusterNetworkName, string instanceName, string deviceSetName, int numDevices, IBackupDatabase dbComponent, Dictionary <string, List <string> > dbConfig, bool isBackup, IUpdateNotification notifier, out long estimatedTotalBytes) { string serverConnectionName = clusterNetworkName == null ? "." : clusterNetworkName; string dataSource = string.IsNullOrEmpty(instanceName) ? serverConnectionName : string.Format(@"{0}\{1}", serverConnectionName, instanceName); string connectionString = string.Format("Data Source={0};Initial Catalog=master;Integrated Security=SSPI;Asynchronous Processing=true;", dataSource); notifier.OnConnecting(string.Format("Connecting: {0}", connectionString)); mCnn = new SqlConnection(connectionString); mCnn.Open(); List <string> deviceNames = new List <string>(numDevices); deviceNames.Add(deviceSetName); for (int i = 1; i < numDevices; i++) { deviceNames.Add(string.Format("dev{0}", i)); } mCmd = new SqlCommand(); mCmd.Connection = mCnn; mCmd.CommandTimeout = 0; if (isBackup) { dbComponent.ConfigureBackupCommand(dbConfig, deviceNames, mCmd); estimatedTotalBytes = CalculateEstimatedDatabaseSize(mCnn, dbConfig); } else { dbComponent.ConfigureRestoreCommand(dbConfig, deviceNames, mCmd); estimatedTotalBytes = 0; } return(deviceNames); }
/// <summary> /// Returns the auto-generated device names /// </summary> public List <string> PreConnect(string clusterNetworkName, string instanceName, string deviceSetName, int numDevices, IBackupDatabase dbComponent, Dictionary <string, List <string> > dbConfig, int isBackup, IUpdateNotification notifier, out long estimatedTotalBytes) { var serverConnectionName = clusterNetworkName ?? "."; var dataSource = string.IsNullOrEmpty(instanceName) ? serverConnectionName : string.Format(@"{0}\{1}", serverConnectionName, instanceName); var connectionString = dbConfig.ContainsKey("user") ? string.Format("Data Source={0};Initial Catalog=master;Integrated Security=False;User ID={1};Password={2};Asynchronous Processing=true;;Connect Timeout=2147483647", dataSource, dbConfig["user"][0], dbConfig.ContainsKey("password") ? dbConfig["password"][0] : null) : string.Format("Data Source={0};Initial Catalog=master;Integrated Security=True;Asynchronous Processing=true;Connect Timeout=2147483647", dataSource); notifier.OnConnecting(string.Format("Connecting: {0}", connectionString)); _mCnn = new SqlConnection(connectionString); _mCnn.Open(); var deviceNames = new List <string>(numDevices) { deviceSetName }; for (var i = 1; i < numDevices; i++) { deviceNames.Add(Guid.NewGuid().ToString()); } _mCmd = new SqlCommand { Connection = _mCnn, CommandTimeout = 0 }; estimatedTotalBytes = 0; //Console.WriteLine(mCmd); switch (isBackup) { case 1: dbComponent.ConfigureBackupCommand(dbConfig, deviceNames, _mCmd); estimatedTotalBytes = CalculateEstimatedDatabaseSize(_mCnn, dbConfig); break; case 2: dbComponent.ConfigureRestoreCommand(dbConfig, deviceNames, _mCmd); estimatedTotalBytes = 0; break; case 3: dbComponent.ConfigureVerifyCommand(dbConfig, deviceNames, _mCmd); estimatedTotalBytes = 0; break; default: Console.WriteLine("Default case"); break; } return(deviceNames); }