public static void downloadLounge() { String StationID = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID"); int total = 0; int success = 0; LoungeDao dao = new LoungeDao(); List <ModelLounge> lists = dao.Select(" Where l.lounge_station=" + StationID); if (lists != null) { total = lists.Count; logger.Debug("# Start download [LOUNGE] from server."); foreach (ModelLounge model in lists) { List <ModelLounge> tmp = dao.SelectOffline(" Where l.id='" + model.id + "'"); if (tmp != null) { if (tmp.Count > 0) { } else { if (dao.InsertOffline(model)) { success++; } } } } logger.Debug("# Summary=> Total Download total: " + total + " success: " + success + " fail: " + (total - success)); logger.Debug("# End Download data from server."); } }
private void FrmLogin_Load(object sender, EventArgs e) { StationID = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID"); String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(','); //14,1,26,สนามบินสุวรรณภูมิ Inter,Lounge Inter,Area 1,1,Admin,admin1,admin1 if (userInfo.Length >= 1) { staffId = Convert.ToInt32(userInfo[0]); } if (userInfo.Length >= 2) { loungeId = Convert.ToInt32(userInfo[1]); } if (userInfo.Length >= 3) { areaId = Convert.ToInt32(userInfo[2]); } if (userInfo.Length >= 4) { stationName = userInfo[3]; station.Text = stationName; } if (userInfo.Length >= 7) { roleId = Convert.ToInt32(userInfo[6]); } if (userInfo.Length >= 8) { roleName = userInfo[7]; } if (userInfo.Length >= 9) { username = userInfo[8]; } if (userInfo.Length >= 10) { password = userInfo[9]; } siteDao = new StationDao(); loungeDao = new LoungeDao(); areaDao = new AreaDao(); roleDao = new RoleDao(); //Check server is alive status = Connection.IsServerConnected(); //station.DataSource = (status) ? siteDao.Select(" Where id=" + StationID) : siteDao.SelectOffine(" Where id=" + StationID); List <ModelLounge> lounges = (status) ? loungeDao.Select(" where l.lounge_station=" + StationID) : loungeDao.SelectOffline(" where l.lounge_station=" + StationID); lounge.DataSource = lounges; try { bool bIsLoungeChild = false; foreach (ModelLounge l in lounges) { if (l.id == loungeId) { bIsLoungeChild = true; break; } } if (bIsLoungeChild) { if (loungeId > 0) { lounge.SelectedValue = loungeId; } else { lounge.SelectedIndex = 0; } } else { lounge.SelectedIndex = 0; } } catch (Exception ex) { logger.Error(ex.Message); //lounge.SelectedIndex = 0; } List <ModelArea> areas = (status) ? areaDao.Select(" where a.area_station=" + StationID + " and a.area_lounge=" + lounge.SelectedValue) : areaDao.SelectOffine(" where a.area_station=" + StationID + " and a.area_lounge=" + lounge.SelectedValue); area.DataSource = areas; try { bool bIsAreaChild = false; foreach (ModelArea a in areas) { if (a.id == areaId) { bIsAreaChild = true; break; } } if (bIsAreaChild) { if (areaId > 0) { area.SelectedValue = areaId; } else { area.SelectedIndex = 0; } } else { area.SelectedIndex = 0; } } catch (Exception ex) { logger.Error(ex.Message); //area.SelectedIndex = 0; } LAPPTITLE.Text = Application.ProductName; LAPPCOMPANY.Text = Application.CompanyName; LUPDATE_DATE.Text = "Version " + Application.ProductVersion; UsernameTextBox.Focus(); if (!status) { UsernameTextBox.Text = username; PasswordTextBox.Text = password; } lSupport.Text = String.Format(lSupport.Text, ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATInternet"), ""); }
private void lounge_site_SelectedIndexChanged(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; StationID = Convert.ToInt16(lounge_site.SelectedValue); List <ModelLounge> loungeList = (onlineStatus) ? loungeDao.Select("where l.lounge_station=" + StationID) : loungeDao.SelectOffline("where l.lounge_station=" + StationID); ModelLounge model1 = new ModelLounge(); model1.id = -1; //model1.id = ""; model1.lounge_name = ""; loungeList.Insert(0, model1); comboLounge.DataSource = loungeList; refreshData(); Cursor = Cursors.Default; }