Exemplo n.º 1
0
 public static MongoDBManager GetInstance()
 {
     if (_instance == null)
     {
         _instance = new MongoDBManager();
     }
     return(_instance);
 }
Exemplo n.º 2
0
        public Form1()
        {
            InitializeComponent();

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

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

            // 탭 보이지 않도록.
            TabControl.Visible = false;
        }
Exemplo n.º 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);
        }