private void bwAsync_DoWork(object sender, DoWorkEventArgs e) { Stopwatch mStopWatch = new Stopwatch(); mStopWatch.Start(); SanitaLogEx.d(TAG, "Start database cache..."); PostMessage("Start database cache ..."); IsCacheCompleted = false; try { //Update timer SystemInfo.NOW = SoftUpdatePresenter.GetCurrentTime(null, null); //Kiểm tra và nâng cấp cấu trúc database Splasher.Status = "Check and update database..."; SoftUpdatePresenter.DoUpdateDatabaseSQL(); using (IDbConnection connection = SoftUpdatePresenter.GetConnection()) { //Open connection connection.Open(); //Begin transtation using (IDbTransaction trans = connection.BeginTransaction()) { Splasher.Status = "Đang xử lý : Danh sách danh mục...".Translate(); DM_Intent_Type.InitDefaultList(DM_Intent_TypePresenter.GetDM_Intent_Types(connection, trans)); MyVar.mListDM_Intent_Type = DM_Intent_Type.GetDefaultList(0).OrderBy(p => p.DM_Intent_TypeID).ToList(); DM_Entity_Type.InitDefaultList(DM_Entity_TypePresenter.GetDM_Entity_Types(connection, trans)); MyVar.mListDM_Entity_Type = DM_Entity_Type.GetDefaultList(0).OrderBy(p => p.DM_Entity_TypeID).ToList(); MyVar.mListUser = UserPresenter.GetUsers(connection, trans); MyVar.mListHome = HomePresenter.GetHomes(connection, trans); MyVar.mListRoom = RoomPresenter.GetRooms(connection, trans); MyVar.mListDevice = DevicePresenter.GetDevices(connection, trans); //----------------------------------------------------------------------------- //Commit transtation trans.Commit(); //Close connection connection.Close(); } } SanitaLogEx.d(TAG, "End database cache..."); } catch (Exception ex) { SanitaLogEx.e(TAG, "bwAsync_DoWork error !", ex); } IsCacheCompleted = true; }
private void bwAsync_Worker(object sender, DoWorkEventArgs e) { ProcessingType type = (ProcessingType)e.Argument; e.Result = type; switch (type) { case ProcessingType.LoadData: { DM_Intent_Type.InitDefaultList(DM_Intent_TypePresenter.GetDM_Intent_Types(null, null)); mListDM_Intent_Type = DM_Intent_Type.GetDefaultList(1).OrderBy(p => p.DM_Intent_TypeID).ToList(); MyVar.mListDM_Intent_Type = DM_Intent_Type.GetDefaultList(0).OrderBy(p => p.DM_Intent_TypeID).ToList(); } break; default: break; } }