//public static List<string> filter_Parse { get; set; } #endregion Properties public static void InitializeRepository() { InitializeComponent(); DBContext = new RestorationAlarmDbContext(); //DBContext = new Alarm4RestorationContext(); RestAlarmListDump = new List <RestorationAlarmLists>(); CustAlarmListDump = new List <RestorationAlarmLists>(); QueryAlarmListDump = new List <RestorationAlarmLists>(); // MainRibbonTapVM เป็นผู้ Initailize //qDateTimeCondItem = new TimeCondItem(); //qDateTimeCondEnd = DateTime.Now; //qDateTimeCondStart = qDateTimeCondEnd.AddDays((-1) * 5); fDateTimeCondItem = new TimeCondItem("Week", 1); fDateTimeCondEnd = DateTime.Now; filterParseDeleg = null; sortParseDeleg = null; LastAlarmRecIndex = 0; LastMaxAlarmRecIndex = 0; LastQueryAlarmRecIndex = 0; //StationsName = new List<string>(); dispatcherTimer.Tick += dispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 20); dispatcherTimer.Start(); }
private List <string> GetDatabase() { using (new WaitCursor()) { try { using (var _RestAlarmContext = new RestorationAlarmDbContext(GetDefualtSQLConnString())) { try { _RestAlarmContext.Database.Connection.Open(); DataTable databases = _RestAlarmContext.Database.Connection.GetSchema("Databases"); List <string> TableNames = new List <string>(); foreach (DataRow row in databases.Rows) { string strDatabaseName = row["database_name"].ToString(); TableNames.Add(strDatabaseName); } _RestAlarmContext.Database.Connection.Close(); Console.WriteLine("Break Test"); return(TableNames); } catch (Exception e) { Console.WriteLine(e.Message); System.Windows.Forms.MessageBox.Show(e.Message, "Get SQL Table" , MessageBoxButtons.OK, MessageBoxIcon.Warning); return(null); } } } catch (Exception e) { Console.WriteLine(e.Message); return(null); } } }
public void TestConnected(string connectionString) { //RestEventArgs args = new RestEventArgs(); var _RestAlarmContext = new RestorationAlarmDbContext(connectionString); //return _RestAlarmContext.Database.Exists(); try { _RestAlarmContext.Database.Connection.Open(); _RestAlarmContext.Database.Connection.Close(); Console.WriteLine("Connect Success"); System.Windows.Forms.MessageBox.Show("Connect to: " + this.txtServer.Text + "; " + this.txtSelectedDB.Content + " Success", "Check SQL Connection" , MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception e) { Console.WriteLine(e.Message); System.Windows.Forms.MessageBox.Show(e.Message, "Check SQL Connection" , MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//Constructor overload public RestorationAlarmDBRepo(ConnectionConfig connCfg) { this._connCfg = connCfg; this._RestAlarmContext = new RestorationAlarmDbContext(GetConnString()); }
public RestorationAlarmDBRepo() { this._RestAlarmContext = new RestorationAlarmDbContext(); }