private DupConfigUserResponse GetUserDecisionOnDuplicateConfig() { Console.WriteLine("A configuration with the same Configuration UniqueId is found in the storage. You may choose one of the following options:"); Console.WriteLine(" To update the configuration in the storage, type (U)pdate;"); Console.WriteLine(" To create a new session with this configuration file, type (C)reate;"); Console.WriteLine(" To discard this configuration file and use the version in the storage, type (D)iscard."); Console.WriteLine(); Console.WriteLine("Please type your choice: "); string userResponseStr = Console.ReadLine(); DupConfigUserResponse userResponse = DupConfigUserResponse.Unknown; if (string.IsNullOrEmpty(userResponseStr)) { userResponse = DupConfigUserResponse.Unknown; } if ("Update".Equals(userResponseStr, StringComparison.InvariantCultureIgnoreCase) || "U".Equals(userResponseStr, StringComparison.InvariantCultureIgnoreCase)) { userResponse = DupConfigUserResponse.Update; } else if ("Discard".Equals(userResponseStr, StringComparison.InvariantCultureIgnoreCase) || "D".Equals(userResponseStr, StringComparison.InvariantCultureIgnoreCase)) { userResponse = DupConfigUserResponse.DoNotUpdate; } else if ("Create".Equals(userResponseStr, StringComparison.InvariantCultureIgnoreCase) || "C".Equals(userResponseStr, StringComparison.InvariantCultureIgnoreCase)) { userResponse = DupConfigUserResponse.CreateNew; } else { userResponse = DupConfigUserResponse.Unknown; } return(userResponse); }
private void LaunchFromConfigFile() { try { Configuration config = Configuration.LoadFromFile(m_configFileName); SessionGroupConfigurationManager configSaver = new SessionGroupConfigurationManager(config); try { configSaver.TrySave(); } catch (DuplicateConfigurationException) { DupConfigUserResponse userResponse = GetUserDecisionOnDuplicateConfig(); while (userResponse == DupConfigUserResponse.Unknown) { userResponse = GetUserDecisionOnDuplicateConfig(); } switch (userResponse) { case DupConfigUserResponse.Update: config.UniqueId = Guid.NewGuid().ToString(); configSaver.TrySave(); break; case DupConfigUserResponse.CreateNew: string configFileContent = File.ReadAllText(m_configFileName); configFileContent = Configuration.ReGuidConfigXml(config, configFileContent); config = Configuration.LoadFromXml(configFileContent); configSaver = new SessionGroupConfigurationManager(config); configSaver.TrySave(); break; case DupConfigUserResponse.DoNotUpdate: break; case DupConfigUserResponse.Unknown: default: throw new InvalidOperationException("Unknown user response."); } } catch (Exception) { throw; } List <Guid> runningSessionGroups = new List <Guid>(1); runningSessionGroups.Add(config.SessionGroupUniqueId); if (m_commandSwitch.CommandSwitchSet) { preAuthorizeRules(config); } // kickoff the session group m_pipeProxy.StartSessionGroup(config.SessionGroupUniqueId); while (true) { try { runningSessionGroups.Clear(); runningSessionGroups.AddRange(m_pipeProxy.GetRunningSessionGroups()); // uncomment the following lines for richer debugging message //Console.WriteLine(String.Format("Received {0} entries", runningSessionGroups.Count)); //foreach (Guid guid in runningSessionGroups) //{ // Console.WriteLine(guid.ToString()); //} if (runningSessionGroups.Count == 0 || !runningSessionGroups.Contains(config.SessionGroupUniqueId) || AllRunningSessionGroupsAreInStoppedSyncState(new Guid[] { config.SessionGroupUniqueId })) { break; } } catch (Exception e) { // Ugly, but this approach lets us start the test app // before the endpoint is ready to service requests. Console.WriteLine("Error: {0}", e.Message); // re-initialize proxy InitializeProxy(); } Thread.Sleep(RunningSessionPollingIntervalMillisec); } } catch (System.Data.UpdateException updateEx) { if (updateEx.InnerException != null && updateEx.InnerException is System.Data.SqlClient.SqlException) { if (updateEx.InnerException.Message.Contains("chkSingleUsageOfMigrationSourceInSessions")) { Program.Trace(MigrationConsoleResources.ErrorMigrationSourceUsedMultipleTimes); } } else { throw; } } }