incubator-stonehenge-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From drew...@apache.org
Subject svn commit: r767755 - /incubator/stonehenge/trunk/stocktrader/dotnet/setup_utilities/SetupActions/SetupAction.cs
Date Thu, 23 Apr 2009 01:42:15 GMT
Author: drewbai
Date: Thu Apr 23 01:42:15 2009
New Revision: 767755

URL: http://svn.apache.org/viewvc?rev=767755&view=rev
Log:
Enable Integrated Authentication Mode in the dotnet SetupActions
Apply WindowsAuthSetup.patch for Ben for STONEHENGE-14  

Modified:
    incubator/stonehenge/trunk/stocktrader/dotnet/setup_utilities/SetupActions/SetupAction.cs

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/setup_utilities/SetupActions/SetupAction.cs
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/setup_utilities/SetupActions/SetupAction.cs?rev=767755&r1=767754&r2=767755&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/setup_utilities/SetupActions/SetupAction.cs
(original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/setup_utilities/SetupActions/SetupAction.cs
Thu Apr 23 01:42:15 2009
@@ -42,17 +42,15 @@
     /// </summary>
     public partial class SetupAction 
     {
-        
-
         private string SQL_CONN = null;
         public static readonly string CONNSTRING_SQLAUTH = "server={0};Database={1};user
id={2};password={3};Pooling=false;";
+        public static readonly string CONNSTRING_WINAUTH = @"server={0};Database={1};Integrated
Security=SSPI;";
         //newstrings 
         string CREATE_LOADACCOUNTPROFILEXML = @"setup_utilities\DATALOAD\CreateInsertXMLAccountProfileProc.sql";
         string CREATE_LOADACCOUNTXML = @"setup_utilities\DATALOAD\CreateInsertXMLAccountProc.sql";
         string CREATE_LOADHOLDINGXML = @"setup_utilities\DATALOAD\CreateInsertXMLHoldingProc.sql";
         string CREATE_LOADORDERSXML = @"setup_utilities\DATALOAD\CreateInsertXMLOrdersProc.sql";
         string CREATE_LOADQUOTEXML = @"setup_utilities\DATALOAD\CreateInsertXMLQuoteProc.sql";
-        string CONNSTRING_WINAUTH = @"EMPTY";
         string MSG_CHECK_SQL_AUTH = string.Empty;
         
         public static string dbServer = null;
@@ -62,10 +60,18 @@
         public string dbPassword = null;
         public string authType = null;
         public static readonly string tradeuser = "trade";
-        public static readonly string tradepassword = "yyy";
+        public static readonly string tradepassword = "trade";
         public static readonly string TRADEDB = "StockTraderDB";
         public const string TRADEDB_CREATE_FILE = "createdb.sql";
 
+        string GetConnectionString(string databaseName)
+        {
+            if (authType != null && authType.Equals("Integrated", StringComparison.InvariantCultureIgnoreCase))
+                return string.Format(CONNSTRING_WINAUTH, new object[] { dbServer, databaseName
});
+            
+            return string.Format(CONNSTRING_SQLAUTH, new object[] { dbServer, databaseName,
dbAdmin, dbPassword });
+        }
+
         //public void Install(System.Collections.IDictionary stateSaver)
         public void Install()
         {
@@ -87,7 +93,7 @@
             try
             {
                 createDatabase(installPath, TRADEDB_CREATE_FILE, TRADEDB, tradeuser, tradepassword);
-                createLoadXmlStockTraderDBProcs(installPath, TRADEDB, dbAdmin, dbPassword);
+                createLoadXmlStockTraderDBProcs(installPath, TRADEDB);
                 loadStockTraderDB(installPath, TRADEDB);
             }
             catch (Exception e)
@@ -101,11 +107,9 @@
         /// </summary>
         /// <param name="installPath"></param>
         /// <param name="databaseName"></param>
-        /// <param name="userid"></param>
-        /// <param name="password"></param>
-        public void createLoadXmlStockTraderDBProcs(string installPath, string databaseName,
string userid, string password)
+        public void createLoadXmlStockTraderDBProcs(string installPath, string databaseName)
         {
-            SQL_CONN = String.Format(SetupAction.CONNSTRING_SQLAUTH, new object[] { dbServer,
databaseName, userid, password });
+            SQL_CONN = GetConnectionString(databaseName);
             SqlConnection sqlConnection = new SqlConnection(SQL_CONN);
             sqlConnection.Open();
 
@@ -196,10 +200,7 @@
                                          "ALTER DATABASE [" + repositoryName + "] SET DB_CHAINING
OFF;";
 
             string dropDB = null;
-            if (authType.Equals("Integrated"))
-                SQL_CONN = string.Format(CONNSTRING_WINAUTH, new object[] { dbServer, "master",
dbAdmin, dbPassword });
-            else
-                SQL_CONN = string.Format(CONNSTRING_SQLAUTH, new object[] { dbServer, "master",
dbAdmin, dbPassword });
+            SQL_CONN = GetConnectionString("master");
             SqlConnection sqlConnection = new SqlConnection(SQL_CONN);
             try
             {
@@ -240,10 +241,7 @@
 
                 //Now create user for new DB by logging in to new DB with admin rights
 
-                if (authType.Equals("Integrated"))
-                    SQL_CONN = string.Format(CONNSTRING_WINAUTH, new object[] { dbServer,
repositoryName, dbAdmin, dbPassword });
-                else
-                    SQL_CONN = string.Format(CONNSTRING_SQLAUTH, new object[] { dbServer,
repositoryName, dbAdmin, dbPassword });
+                SQL_CONN = GetConnectionString(repositoryName);
                 sqlConnection = new SqlConnection(SQL_CONN);
                 Server server = new Server(new ServerConnection(sqlConnection));
                 server.ConnectionContext.ExecuteNonQuery(createuser);
@@ -254,10 +252,6 @@
                 System.Data.SqlClient.SqlConnection.ClearAllPools();
 
                 //Login to Master and use SMO to create role mapping of DBO
-                if (authType.Equals("Integrated"))
-                    SQL_CONN = string.Format(CONNSTRING_WINAUTH, new object[] { dbServer,
repositoryName, dbAdmin, dbPassword });
-                else
-                    SQL_CONN = string.Format(CONNSTRING_SQLAUTH, new object[] { dbServer,
repositoryName, dbAdmin, dbPassword });
                 sqlConnection = new SqlConnection(SQL_CONN);
                 //new SMO functionality
                 server = new Server(new ServerConnection(sqlConnection));
@@ -268,7 +262,7 @@
                 sqlConnection.Close();
 
                 //Login as newly created user.  Don't need to but rather test connectivity
here right away to make sure DB in good state for new trade user.
-                SQL_CONN = "server=" + dbServer + ";Database=" + repositoryName + ";user
id=" + userid + ";password=" + password;
+                SQL_CONN = GetConnectionString(repositoryName);
                 sqlConnection = new SqlConnection(SQL_CONN);
                 try
                 {
@@ -308,10 +302,7 @@
         /// <param name="repository"></param>
         public void loadStockTraderDB(string installPath, string repository)
         {
-            if (authType.Equals("Integrated"))
-                SQL_CONN = String.Format(CONNSTRING_WINAUTH, new object[] { dbServer, repository,
dbAdmin, dbPassword });
-            else
-                SQL_CONN = String.Format(SetupAction.CONNSTRING_SQLAUTH, new object[] { dbServer,
repository, dbAdmin, dbPassword });
+            SQL_CONN = GetConnectionString(repository);
             string xmlFile = null;
             string sql = null;
             string table = null;



Mime
View raw message