示例#1
0
        private void FrmReport_Load(object sender, EventArgs e)
        {
            if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo") != null)
            {
                String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(',');

                if (userInfo[6].Equals("9"))
                {
                    lounge_site.DataSource = siteDao.Select("");
                }
                else
                {
                    String StationID = ManageLOG.getValueFromRegistry("WiFi Management", "StationID");
                    if (!String.IsNullOrEmpty(StationID))
                    {
                        lounge_site.DataSource = siteDao.Select(" where id=" + StationID);
                    }
                    else
                    {
                        lounge_site.DataSource = siteDao.Select("");
                    }
                }
            }
            stations = siteDao.Select("");
            groups   = groupDao.Select("");
            users    = userDao.Select("");

            this.reportViewer1.RefreshReport();
        }
示例#2
0
        private void FrmStaff_Load(object sender, EventArgs e)
        {
            StationID = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID");
            if (!String.IsNullOrEmpty(StationID))
            {
                String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(',');

                if (!userInfo[6].Equals("9"))
                {
                    staff_station.DataSource    = stationDao.Select(" where id = " + StationID);
                    staff_station.SelectedIndex = 0;
                    staff_station.Enabled       = false;
                }
                else
                {
                    staff_station.DataSource    = stationDao.Select("");
                    staff_station.SelectedIndex = 0;
                    staff_station.Enabled       = true;
                }
            }
            user_role.DataSource    = roleDao.Select(" Where role_code <> 'SPECIAL'");
            user_role.SelectedIndex = 0;
            //initial
            refresh();
        }
示例#3
0
        private void FrmLoad_Load(object sender, EventArgs e)
        {
            StationDao siteDao = new StationDao();

            lounge_site.DataSource = siteDao.Select("");
            refresh();
        }
示例#4
0
        public static void downloadStation()
        {
            String              StationID = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID");
            int                 total     = 0;
            int                 success   = 0;
            StationDao          dao       = new StationDao();
            List <ModelStation> lists     = dao.Select("");

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

                foreach (ModelStation model in lists)
                {
                    List <ModelStation> tmp = dao.SelectOffine(" Where id='" + model.id + "'");
                    if (tmp != null)
                    {
                        if (tmp.Count > 0)
                        {
                        }
                        else
                        {
                            if (dao.InsertOffine(model))
                            {
                                success++;
                            }
                        }
                    }
                }
                logger.Debug("# Summary=> Total Download total: " + total + " success: " + success + " fail: " + (total - success));
                logger.Debug("# End Download data from server.");
            }
        }
示例#5
0
        private void FrmAuthenCode_Load(object sender, EventArgs e)
        {
            StationDao siteDao = new StationDao();

            lounge_site.DataSource = siteDao.Select("");
            //initial
            refresh();
        }
示例#6
0
        private void B_ADD_Click(object sender, EventArgs e)
        {
            if (isValidInputData())
            {
                ModelStation model = new ModelStation();
                model.id        = this.id;
                model.site_code = site_code.Text;
                model.site_name = site_name.Text;

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

                case "แก้ไข":
                    result = siteDao.Update(model);
                    if (result)
                    {
                        MessageBox.Show("แก้ไขข้อมูลเรียบร้อยแล้ว");
                    }
                    break;
                }
                if (result)
                {
                    refresh();
                }
            }
        }
示例#7
0
        private void refresh()
        {
            String StationID = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID");

            lounge_site.DataSource   = siteDao.Select(" where id=" + StationID);
            dataGridView1.DataSource = loungeDao.Select(" where lounge_station=" + StationID);

            B_DELETE.Visible = false;
            B_ADD.Enabled    = true;
            B_CANCEL.Enabled = true;

            B_ADD.Text = "บันทึก";

            lounge_site.SelectedIndex = 0;
            lounge_name.Text          = "";
        }
示例#8
0
 private void FrmFtp_Load(object sender, EventArgs e)
 {
     stations = siteDao.Select("");
     groups   = groupDao.Select("");
     users    = userDao.Select("");
 }
示例#9
0
 private void refresh()
 {
     staff_station.DataSource = siteDao.Select("");
     user_role.DataSource     = roleDao.Select(" Where role_code <> 'SPECIAL'");
 }
示例#10
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            //check offine mode
            #region Initial variable
            StationID = Convert.ToInt16(ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID"));
            if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo") != null)
            {
                String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(',');
                staffId     = Convert.ToInt16(userInfo[0]);
                lounge      = Convert.ToInt16(userInfo[1]);
                area        = Convert.ToInt16(userInfo[2]);
                stationName = userInfo[3];
                loungeName  = userInfo[4];
                areaName    = userInfo[5];
            }
            if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "OnlineStatus") != null)
            {
                onlineStatus = (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "OnlineStatus").Equals("1")) ? true : false;
            }
            #endregion

            lSupport.Text = String.Format(lSupport.Text, ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATInternet"), "");

            switch (staffModel.user_role)
            {
            case 9:
                lounge_site.Enabled    = true;
                lounge_site.DataSource = (onlineStatus) ? siteDao.Select("") : siteDao.SelectOffine("");
                break;

            default:
                lounge_site.Enabled    = false;
                lounge_site.DataSource = (onlineStatus) ? siteDao.Select(" Where id='" + StationID + "'") : siteDao.SelectOffine(" Where id='" + StationID + "'");
                break;
            }

            L_SITE_DESC.Text = loungeName + "-" + areaName;

            group_id.DataSource = (onlineStatus) ? groupDao.Select("") : groupDao.SelectOffine("");

            if (lounge > 0)
            {
                comboLounge.SelectedValue = lounge;
            }
            if (area > 0)
            {
                comboArea.SelectedValue = area;
            }

            //List<ModelLounge> listLounge = (onlineStatus) ? loungeDao.Select(" Where area_station ='" + StationID + "' and area_lounge='" + lounge + "'") : loungeDao.SelectOffine(" Where area_station ='" + StationID + "' and area_lounge='" + lounge + "'");
            //if (listLounge.Count > 0)
            //{
            //    ModelLounge model1 = new ModelLounge();
            //    model1.id = -1;
            //    //model1.id = "";
            //    model1.lounge_name = "";
            //    listLounge.Insert(0, model1);
            //}
            //comboLounge.DataSource = listLounge;
            //List<ModelArea> listArea = (onlineStatus) ? areaDao.Select(" Where area_station ='" + StationID + "' and area_lounge='" + lounge + "'") : areaDao.SelectOffine(" Where area_station ='" + StationID + "' and area_lounge='" + lounge + "'");
            //if (listArea.Count > 0)
            //{
            //    ModelArea model1 = new ModelArea();
            //    model1.id = -1;
            //    model1.area_code = "";
            //    model1.area_name = "";
            //    listArea.Insert(0, model1);
            //}
            //comboArea.DataSource = listArea;



            refreshData();
        }
示例#11
0
        private void initial()
        {
            if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo") != null)
            {
                StationDao siteDao   = new StationDao();
                String[]   userInfo  = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(',');
                String     StationID = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID");
                if (userInfo[6].Equals("9"))
                {
                    lounge_site.DataSource = siteDao.Select("");
                    lounge_site.Enabled    = true;
                    lounge_site.Text       = userInfo[3];
                }
                else
                {
                    if (!String.IsNullOrEmpty(StationID))
                    {
                        lounge_site.DataSource = siteDao.Select(" where id=" + StationID);
                    }
                }
            }


            String[] conStr = ManageLOG.deCode(ManageLOG.getValueFromRegistry(Configurations.AppRegName, "CON")).Split(';');
            if (conStr.Length == 5)
            {
                SIP.Text  = conStr[0].Split('=')[1];
                DBN.Text  = conStr[1].Split('=')[1];
                UN.Text   = conStr[2].Split('=')[1];
                PASS.Text = conStr[3].Split('=')[1];

                if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoPrint") != null)
                {
                    if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoPrint").Equals(""))
                    {
                        cbPrintAuto.Checked = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoPrint").Equals("False") ? false : true;
                    }
                }
                if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoGenAutoPrint") != null)
                {
                    if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoGenAutoPrint").Equals(""))
                    {
                        cbAutoGenPrintAuto.Checked = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoGenAutoPrint").Equals("False") ? false : true;
                    }
                }
                if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "ManualGenAutoPrint") != null)
                {
                    if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "ManualGenAutoPrint").Equals(""))
                    {
                        cbManualGenPrintAuto.Checked = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "ManualGenAutoPrint").Equals("False") ? false : true;
                    }
                }

                if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATInternet") != null)
                {
                    if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATInternet").Equals(""))
                    {
                        txtInternetSupport.Text = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATInternet");
                    }
                }
                if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATApplication") != null)
                {
                    if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATApplication").Equals(""))
                    {
                        txtAppSupport.Text = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATApplication");
                    }
                }

                if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "txtWiFiExpire") != null)
                {
                    if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "txtWiFiExpire").Equals(""))
                    {
                        txtWiFiExpire.Text = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "txtWiFiExpire");
                    }
                }

                String interval = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "Interval");
                if (interval != null)
                {
                    if (!interval.Equals(""))
                    {
                        txtInterval.Text = interval;
                    }
                }
                String SSIDName = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SSIDName");
                if (SSIDName != null)
                {
                    txtSSidName.Text = SSIDName;
                }
                groupBox2.Enabled = true;
            }
            else
            {
                groupBox2.Enabled = false;
            }
        }
示例#12
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);
            }
        }