Exemple #1
0
    ///////////////////////////////////////////////////////////////////////////////
    // Public methods                                                            //
    ///////////////////////////////////////////////////////////////////////////////
    #region PUBLICMETHODS

    /// <summary>
    /// Destruction. Clear member fields and close database connections.
    /// </summary>
    public void CleanUp()
    {
      //SqlConnection connectionString = new SqlConnection(Document.ActiveDocument.ExperimentSettings.ServerConnectionString);
      //ServerConnection connection = new ServerConnection(connectionString);
      //Server sqlServer = new Server(connection);
      try
      {
        //// If there are open connections set offline and online to kill all 
        //// active connections, they are not used anymore.
        //int connections = sqlServer.GetActiveDBConnectionCount(Document.ActiveDocument.ExperimentSettings.Name);
        //if (connections > 0)
        //{
        //  string query = "ALTER DATABASE \"" + Document.ActiveDocument.ExperimentSettings.Name +
        //   "\" SET OFFLINE WITH ROLLBACK IMMEDIATE;";
        //  Queries.ExecuteSQLCommand(query);
        //  query = "ALTER DATABASE \"" + Document.ActiveDocument.ExperimentSettings.Name +
        //    "\" SET ONLINE;";
        //  Queries.ExecuteSQLCommand(query);
        //}

        // Close database connection
        if (this.dataSet != null)
        {
          this.dataSet.Dispose();
        }

        //// Detach database from user instance
        //if (sqlServer.Databases.Contains(Document.ActiveDocument.ExperimentSettings.Name))
        //{
        //  sqlServer.DetachDatabase(Document.ActiveDocument.ExperimentSettings.Name, true);
        //}
      }
      catch (Exception ex)
      {
        ExceptionMethods.HandleException(ex);
      }

      activeDocument = null;
      this.isModified = false;
      this.experimentSettings = null;
      this.selectionState = null;
    }
Exemple #2
0
    ///////////////////////////////////////////////////////////////////////////////
    // Construction and Initializing methods                                     //
    ///////////////////////////////////////////////////////////////////////////////
    #region CONSTRUCTION

    /// <summary>
    /// Initializes a new instance of the Document class.
    /// </summary>
    public Document()
    {
      activeDocument = this;
      this.isModified = false;
      this.experimentSettings = new ExperimentSettings();
      this.selectionState = new SelectionsState();
    }