コード例 #1
0
 /// <summary>
 /// Dispose object DBM
 /// </summary>
 public void Dispose()
 {
     GC.SuppressFinalize(this);
     CloseConnection();
     if (null != SqlConn)
     {
         SqlConn.Dispose();
     }
 }
コード例 #2
0
 internal void closeSqlConnection()
 {
     if (this.SqlConn != null)
     {
         if (SqlConn.State != ConnectionState.Closed)
         {
             SqlConn.Close();
         }
         SqlConn.Dispose();
     }
 }
コード例 #3
0
        /// <summary>
        /// Imports the completed.
        /// </summary>
        /// <param name="success">if set to <c>true</c> [success].</param>
        protected override void ImportCompleted(bool success)
        {
            _end = DateTime.Now;
            var elapsed = _end.Subtract(_start);

            AppendLog(elapsed.ToString("hh\\:mm\\:ss") + " elapsed.");

            AppendLog("Closing database connections.");
            try
            {
                AccessConn.Close();
                AccessConn.Dispose();
            }
            catch (Exception e)
            {
                AppendLog("******************************************************************************");
                AppendLog("Error closing Access database table:");
                AppendLog(e.Message);
                AppendLog("******************************************************************************");
            }

            try
            {
                //if (HospCompDataBc != null)
                //{
                //    HospCompDataBc.Close();
                //    HospCompDataDt.Dispose();
                //}
                SqlConn.Close();
                SqlConn.Dispose();
            }
            catch (Exception e)
            {
                AppendLog("******************************************************************************");
                AppendLog("Error closing SQL database table:");
                AppendLog(e.Message);
                AppendLog("******************************************************************************");
            }

            try
            {
                if (success)
                {
                    var rootXml = new XElement("LogLines");
                    foreach (var line in LogFile)
                    {
                        rootXml.Add(new XElement("LogLine", line));
                    }
                    DataContextObject.Summary = rootXml.ToString();
                    DataContextObject.Summary = rootXml.ToString();

                    var fi = new DateTimeFormatInfo();
                    DataContextObject.DatasetItem.VersionMonth = fi.GetMonthName(DataContextObject.Month);
                    DataContextObject.DatasetItem.VersionYear  = DataContextObject.Year;

                    if (DataContextObject.DatasetItem.IsReImport)
                    {
                        var linesImported = Session.Query <NursingHomeTarget>()
                                            .Count(hc => hc.Dataset.Id == DataContextObject.DatasetItem.Id);

                        if (DataContextObject.DatasetItem.File.Contains(" (#"))
                        {
                            DataContextObject.DatasetItem.File = DataContextObject.DatasetItem.File.SubStrBefore(" (#");
                        }

                        DataContextObject.DatasetItem.File += " (# Rows Imported: " + linesImported + ")";
                    }
                    AppendLog("Import completed successfully.");
                }
                else
                {
                    AppendLog("Import was not completed successfully.");
                }

                Done = true;
                // WPF CommandManager periodically calls IsValid to see if the Next/Done button should be enabled.
                // In multi-threaded wizard steps, IsValid returns the value of the Done flag. Call InvalidateRequerySuggested here
                // on the UI thread after setting the Done flag to force WPF to call IsValid now so the Next/Done button will become enabled.
                //Application.Current.DoEvents();
                NotifyUi(this, new ExtendedEventArgs <Action>(CommandManager.InvalidateRequerySuggested));
            }
            finally
            {
                base.ImportCompleted(success);
            }
        }