Beispiel #1
0
        /*
         * SearchBox에 검색어가 없다면, ListBox를 보이지 않도록 함.
         * 검색어가 존재한다면, 그에 맞는 유사 검색어들을 리스트박스에 추가해줌.
         */
        private void SearchBox_TextChanged(object sender, EventArgs e)
        {
            if (SearchBox.Text == "")
            {
                ResultBox.Visible = false;
            }
            else if (SearchBox.Text.Length < 2)
            {
                ResultBox.Visible = false;
            }
            else
            {
                ResultBox.Items.Clear();

                var similarNameRouteList = HttpNetwork.GetInstance().GetBusRouteListLike(SearchBox.Text);
                if (similarNameRouteList == null)
                {
                    return;
                }

                foreach (string similarNameRoute in similarNameRouteList)
                {
                    ResultBox.Items.Add(similarNameRoute);
                }

                ResultBox.Visible = true;
            }
        }
Beispiel #2
0
        public Form1()
        {
            InitializeComponent();

            // 싱글톤 클래스들 초기화.
            MongoDBManager.GetInstance();
            HttpNetwork.GetInstance();

            // 결과박스 보이지 않도록.
            ResultBox.Visible = false;

            // 탭 보이지 않도록.
            TabControl.Visible = false;
        }
Beispiel #3
0
        private void SearchStart()
        {
            ResultBox.Visible  = false;
            searchStr          = SearchBox.Text;
            TabControl.Visible = true;

            int searchRouteId   = HttpNetwork.GetInstance().GetBusRouteList(searchStr);
            int routeDayDriveNm = HttpNetwork.GetInstance().GetRouteDayDrivenNm(searchRouteId);
            var routeList       = HttpNetwork.GetInstance().GetStationsByRouteList(searchRouteId);

            // 노선의 마지막 역의 넘버를 나타내는 변수.
            if (routeList == null)
            {
                MessageBox.Show("정부 API 나빠요.");
                return;
            }
            int lastStationSeq = routeList.Count();

            // route에 있는 station의 승, 하차 총 승객수를 구해준다.
            foreach (var station in routeList)
            {
                Tuple <int, int> passengerNum = MongoDBManager.GetInstance().FindPassengerNumberWithStationId(searchStr, station.stationId);

                station.rideNum   = passengerNum.Item1;
                station.alightNum = passengerNum.Item2;
            }

            // 그 전 역의 타고있는 승객수를 임시 저장하는 변수.
            int previousRemainPassenger = 0;

            // 노선 전체 평균 승객수를 구하기위해 누적시키는 변수.
            float totalRemainPassenger = 0;

            // station의 누적 승객수를 구해준다.
            foreach (var station in routeList)
            {
                if (station.seq == 1)
                {
                    station.remainPassenger        = station.rideNum - station.alightNum;
                    station.averageRemainPassenger = station.remainPassenger / routeDayDriveNm;
                    totalRemainPassenger          += station.averageRemainPassenger;
                    previousRemainPassenger        = station.remainPassenger;
                }
                else if (station.seq == lastStationSeq)
                {
                    station.remainPassenger = 0;
                }
                else
                {
                    station.remainPassenger        = previousRemainPassenger + station.rideNum - station.alightNum;
                    station.averageRemainPassenger = station.remainPassenger / routeDayDriveNm;
                    totalRemainPassenger          += station.averageRemainPassenger;
                    previousRemainPassenger        = station.remainPassenger;
                }
            }

            // 노선 전체 평균 인원 점수.
            float anzaScore = (totalRemainPassenger / lastStationSeq) / 20;

            MakeAnzaScoreTab(routeList, anzaScore, routeDayDriveNm);
        }