Exemple #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.");
            }
        }
Exemple #2
0
        private void B_ADD_Click(object sender, EventArgs e)
        {
            if (isValidInputData())
            {
                ModelArea model = new ModelArea();
                model.id           = this.id;
                model.area_station = Convert.ToInt16(area_station.SelectedValue);
                model.area_lounge  = Convert.ToInt16(area_lounge.SelectedValue);
                model.area_name    = area_name.Text;

                Boolean result = false;
                switch (B_ADD.Text)
                {
                case "บันทึก":
                    //Check Exist
                    List <ModelArea> stationLists = areaDao.Select(" Where area_name='" + model.area_name + "'");
                    if (stationLists.Count > 0)
                    {
                        MessageBox.Show("มีข้อมูล " + model.area_name + " ในระบบแล้ว");
                        area_name.Text = "";
                    }
                    else
                    {
                        result = areaDao.Insert(model);
                        if (result)
                        {
                            MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว");
                        }
                    }
                    break;

                case "แก้ไข":
                    result = areaDao.Update(model);
                    if (result)
                    {
                        MessageBox.Show("แก้ไขข้อมูลเรียบร้อยแล้ว");
                    }
                    break;
                }
                if (result)
                {
                    refresh();
                }
            }
        }
Exemple #3
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 = "";
     }
 }
Exemple #4
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();
            }
        }
Exemple #5
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"), "");
        }
Exemple #6
0
        public static void Main(string[] args)
        {
            //Boolean closeFtp = false;
            //String xx = Configurations.deCode("U0VSVkVSPTIwMi40Ny4yNTAuMjAzO0RBVEFCQVNFPWF1dGhlbmNvZGVkYjtVSUQ9YzExO1BBU1NXT1JEPVBAc3N3MHJkOw==");
            //Console.WriteLine();
            //
            //String xxx = ManageLOG.deCode("U0VSVkVSPTIwMi40Ny4yNTAuMjAzO0RBVEFCQVNFPWF1dGhlbmNvZGVkYjtVSUQ9Y2F0MDE7UEFTU1dPUkQ9UEBzc3cwcmQ7");
            //Console.WriteLine("");
            try
            {
                RadDao radDao = new RadDao();
                // radDao.getAthCodeInfo("628821");
                //Console.WriteLine();

                /*
                 * 0 = Run all station.
                 * format : ????.exe {station} {yyyyMMdd}
                 */
                String _station = args.Length > 0 ? (args[0].Equals("0") ? "" : String.IsNullOrEmpty(args[0]) ? "" : " Where id=" + args[0]) : "";
                Sftp   sftp     = new Sftp("sftp.bangkokair.net", "cat2gos", "C@t2g0s");
                Console.WriteLine("sftp.bangkokair.net Connected. " + DateTime.Now);
                //if (!closeFtp)
                //{
                sftp.Connect(22);
                //}


                DateTime       runDate = args.Length > 0 ? (String.IsNullOrEmpty(args[1]) ? DateTime.Now.AddDays(-1) : new DateTime(Convert.ToInt16(args[1].Substring(0, 4)), Convert.ToInt16(args[1].Substring(4, 2)), Convert.ToInt16(args[1].Substring(6, 2)), 0, 0, 0)) : DateTime.Now.AddDays(-1);//Run pevios day
                TransactionDao tranDao = new TransactionDao();

                StationDao stationDao = new StationDao();
                LoungeDao  loungeDao  = new LoungeDao();
                AreaDao    areaDao    = new AreaDao();

                List <ModelStation> stations = stationDao.Select("" + _station);
                if (stations.Count > 0)
                {
                    foreach (ModelStation station in stations)
                    {
                        if (station.id != 99)
                        {
                            List <ModelLounge> lounges = loungeDao.Select(" Where lounge_station=" + station.id);
                            if (lounges.Count > 0)
                            {
                                foreach (ModelLounge lounge in lounges)
                                {
                                    List <ModelArea> areas = areaDao.Select(" Where area_station=" + station.id + " and area_lounge=" + lounge.id);
                                    if (areas.Count > 0)
                                    {
                                        foreach (ModelArea area in areas)
                                        {
                                            String        PATH_LOCAL = String.Format(@"{0}{1}\Gen log\Log {2} {3}", Configurations.DailyTransactionLogsPath, station.site_code, lounge.lounge_name, area.area_name);
                                            String        PATH_FTP   = String.Format("{0}/Gen log/Log {1} {2}", station.site_code, lounge.lounge_name, area.area_name);
                                            DirectoryInfo di         = new DirectoryInfo(@"" + PATH_LOCAL);
                                            //if (!closeFtp)
                                            //{
                                            if (!di.Exists)
                                            {
                                                di.Create();
                                            }
                                            //Create path on server
                                            sftp.Mkdir(PATH_FTP);
                                            //}

                                            //ignore group_id=32 ==> cat test group.
                                            String cri = "where date(create_date) = date('" + runDate.ToString("yyyy-MM-dd") + "') and LoungePlace=" + station.id + " and LoungeType=" + lounge.id + " and LoungeArea=" + area.id + " and group_id <> 32  order by LoungePlace asc,LoungeType asc,LoungeArea asc,update_date desc";
                                            List <ModelTransaction> lists = tranDao.Select(cri, station.id);

                                            ManageLOG mangeLog = new ManageLOG();
                                            if (lists.Count > 0)
                                            {
                                                mangeLog.fileName   = String.Format(@"{0}\export_{1}.csv", PATH_LOCAL, runDate.ToString("yyyy-MM-dd"));
                                                mangeLog.folderName = PATH_LOCAL;
                                                String header = "No,Username,Type,GenDate,GroupName,Duration,PassengerName,FromCity,ToCity,AirlineCode,FlightNo,DateOfFlight,SeatNo,LoungePlace,LoungeType,LoungeArea,Owner,Begin_Date,Status,Remark,AccessCode,Remark2,LastUpdate,LastUpdateBy";
                                                mangeLog.WriteLog(header);
                                                int seq = 1;
                                                foreach (ModelTransaction transaction in lists)
                                                {
                                                    String athCodeBeginUse = transaction.begin_date.ToString("yyyy-MM-dd HH:mm:ss");
                                                    try
                                                    {
                                                        athCodeBeginUse = radDao.getAthCodeInfo(transaction.ath_id);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        logger.Debug("* Skip get begindate of " + station.site_code + ">>" + lounge.lounge_name + ">>" + area.area_name + " ::ID::" + transaction.id);
                                                        logger.Error("*  " + ex.InnerException.Message);
                                                    }


                                                    mangeLog.WriteLog(
                                                        seq + "," +                                                                   //No
                                                        Utils.CustomUtils.RemoveSpecialCharacters(transaction.passenger_name + "" + transaction.flight_no + "" + transaction.seat_no) + "," +
                                                        transaction.type + "," +                                                      //Type
                                                        transaction.create_date.ToString("yyyy-MM-dd HH:mm:ss") + "," +
                                                        transaction.group_idName + "," +                                              //GroupName
                                                        transaction.duration + "," +                                                  //Duration
                                                        Utils.CustomUtils.RemoveSpecialCharacters(transaction.passenger_name) + "," + //PassengerName
                                                        Utils.CustomUtils.RemoveSpecialCharacters(transaction.from_city) + "," +      //FromCity
                                                        Utils.CustomUtils.RemoveSpecialCharacters(transaction.to_city) + "," +        //ToCity
                                                        Utils.CustomUtils.RemoveSpecialCharacters(transaction.airline_code) + "," +   //AirlineCode
                                                        Utils.CustomUtils.RemoveSpecialCharacters(transaction.flight_no) + "," +      //FlightNo
                                                        transaction.date_of_flight.ToString("yyyy-MM-dd HH:mm:ss") + "," +
                                                        Utils.CustomUtils.RemoveSpecialCharacters(transaction.seat_no) + "," +        //SeatNo
                                                        transaction.LoungeSiteCode + "," +                                            //LoungePlace
                                                        transaction.LoungeName + "," +                                                //LoungeType
                                                        transaction.LoungeAreaName + "," +                                            //LoungeArea
                                                        transaction.create_byName + "," +                                             //Owner
                                                        athCodeBeginUse + "," +
                                                        transaction.status + "," +                                                    //Status
                                                        Utils.CustomUtils.RemoveSpecialCharacters(transaction.remark) + "," +         //Remark
                                                        transaction.ath_id + "," +                                                    //AccessCode
                                                        Utils.CustomUtils.RemoveSpecialCharacters(transaction.remakr2) + "," +        //Remark2
                                                        transaction.update_date.ToString("yyyy-MM-dd HH:mm:ss") + "," +
                                                        transaction.update_byName                                                     //LastUpdateBy
                                                        );
                                                    //Update begindate
                                                    tranDao.UpdateBeginDate(transaction, station.id);
                                                    seq++;
                                                }
                                            }
                                            else
                                            {
                                                mangeLog.fileName   = String.Format(@"{0}\export_{1} No data.csv", PATH_LOCAL, runDate.ToString("yyyy-MM-dd"));
                                                mangeLog.folderName = PATH_LOCAL;
                                                mangeLog.WriteLog("");
                                                logger.Debug("Transaction of " + station.site_code + ">>" + lounge.lounge_name + ">>" + area.area_name + " is empty");
                                            }

                                            /*
                                             * TRANSFER FILE TO SERVER.
                                             */
                                            //if (!closeFtp)
                                            //{
                                            sftp.Put(mangeLog.fileName, PATH_FTP);
                                            //}
                                        }
                                    }
                                    else
                                    {
                                        logger.Debug("Area of " + station.site_code + ">>" + lounge.lounge_name + " is empty.");
                                    }
                                }
                            }
                            else
                            {
                                logger.Debug("Lounge of " + station.site_code + " is empty.");
                            }
                        }
                    }
                }
                else
                {
                    logger.Debug("Station is empty.");
                }

                /*
                 * CLOSE FTP
                 */
                sftp.Close();
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }