Ejemplo n.º 1
0
        public static void downloadArea()
        {
            String           StationID = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID");
            int              total     = 0;
            int              success   = 0;
            AreaDao          dao       = new AreaDao();
            List <ModelArea> lists     = dao.Select(" Where area_station=" + StationID);

            if (lists != null)
            {
                total = lists.Count;
                logger.Debug("# Start download [AREA] from server.");

                foreach (ModelArea model in lists)
                {
                    List <ModelArea> tmp = dao.SelectOffine(" Where 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.");
            }
        }
Ejemplo n.º 2
0
        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"), "");
        }
Ejemplo n.º 3
0
        private void staff_lounge_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <ModelArea> areaLists = (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);

            if (areaLists != null && areaLists.Count > 0)
            {
                area.DataSource = areaLists;
            }
            else
            {
                MessageBox.Show("ไม่พบ Area ใน " + lounge.Text);
                lounge.SelectedIndex = 0;
                UsernameTextBox.Focus();
            }
        }
Ejemplo n.º 4
0
 private void comboLounge_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (Convert.ToInt16(comboLounge.SelectedValue) > 0)
     {
         List <ModelArea> listArea = (onlineStatus) ? areaDao.Select("where a.area_station=" + lounge_site.SelectedValue + " and a.area_lounge=" + comboLounge.SelectedValue) : areaDao.SelectOffine("where a.area_station=" + lounge_site.SelectedValue + " and a.area_lounge=" + comboLounge.SelectedValue);
         comboArea.DataSource = listArea;
     }
     else
     {
         comboArea.Text = "";
     }
 }