/[AnywhereTS-MSSQL]/trunk/AnywhereTS.DBSupport/DBConnector.cs
ViewVC logotype

Diff of /trunk/AnywhereTS.DBSupport/DBConnector.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 116 by william, Sat Jul 14 08:03:33 2012 UTC revision 119 by william, Sat Jul 14 09:08:55 2012 UTC
# Line 47  namespace AnywhereTS.DBSupport Line 47  namespace AnywhereTS.DBSupport
47    
48          public static string GetConnectionString()          public static string GetConnectionString()
49          {          {
50              return string.Format(@"Data Source={0}\{1};Initial Catalog={2};Integrated Security=SSPI", DBServerAddress, DBServerInstance, DBDatabase);              return string.Format(@"Data Source={0}\{1};Database={2};Integrated Security=SSPI", DBServerAddress, DBServerInstance, DBDatabase);
51          }          }
52          protected DBConnection connection;          protected DBConnection connection;
53          #region DBServerAddress, DBServerInstance, DBDatabase          #region DBServerAddress, DBServerInstance, DBDatabase
# Line 290  namespace AnywhereTS.DBSupport Line 290  namespace AnywhereTS.DBSupport
290          public string[] ParseScriptToCommands(string strScript)          public string[] ParseScriptToCommands(string strScript)
291          {          {
292              string[] commands;              string[] commands;
293              commands = Regex.Split(strScript, "GO\r\n", RegexOptions.IgnoreCase);              commands = strScript.Split(new string[] { string.Format("GO{0}", System.Environment.NewLine) }, StringSplitOptions.RemoveEmptyEntries);
294              return commands;              return commands;
295          }          }
296          #endregion          #endregion
297          #region public virtual bool RunScript(string strFile, out Exception ErrorInfo)          #region public virtual bool RunScript(string strFile, out Exception ErrorInfo)
298          public virtual bool RunScript(string strFile, out Exception ErrorInfo)          public bool RunScript(string strFile, out Exception ErrorInfo)
299          {          {
300              ErrorInfo = null;              ErrorInfo = null;
301              try              try
# Line 304  namespace AnywhereTS.DBSupport Line 304  namespace AnywhereTS.DBSupport
304                  strCommands = ParseScriptToCommands(strFile);                  strCommands = ParseScriptToCommands(strFile);
305                  if (this.ConnectionIsOpen)                  if (this.ConnectionIsOpen)
306                  {                  {
307                      foreach (string strCmd in strCommands)                      if (!ClientRunScript(strCommands, out ErrorInfo))
308                      {                      {
309                          if (strCmd.Length > 0)                          return false;
                         {  
                             // Substitute database directory with the decided one.  
                             DBCommand command = this.CreateCommandInstance(strCmd, new List<DBParameter>(), out ErrorInfo);  
                             command.ExecuteNonQuery();  
                         }  
310                      }                      }
                     return true;  
311                  }                  }
312                  else                  else
313                  {                  {
314                      Logging.ATSAdminLog.Fatal(string.Format("Failed to run script: [database connection is not open] {0}{1}", System.Environment.NewLine, strFile));                      Logging.DatabaseLog.Fatal(string.Format("Failed to run script: [database connection is not open] {0}{1}", System.Environment.NewLine, strFile));
315                      return false;                      return false;
316                  }                  }
317              }              }
# Line 339  namespace AnywhereTS.DBSupport Line 333  namespace AnywhereTS.DBSupport
333              }              }
334              return false;              return false;
335          }          }
336            public abstract bool ClientRunScript(string[] strCommands, out Exception ErrorInfo);
337          #endregion          #endregion
338          #endregion          #endregion
339    

Legend:
Removed from v.116  
changed lines
  Added in v.119

  ViewVC Help
Powered by ViewVC 1.1.22