Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("City Bike Data Tool v2.0 by Kagami");
            Console.WriteLine("-----------------------------------");
            Console.WriteLine("1.DownLoad new data and save.");
            Console.WriteLine("2.Compare new data with other data , and generate compare data.");
            Console.WriteLine("3.Compare two datas in local");
            Console.WriteLine("Please Choose with number:");
            _command = Console.ReadLine();

            switch (_command)
            {
                //1.轉換系統
                case "1":
                    {
                        //下載檔案
                        CBikeDataDownloader _downloader = new CBikeDataDownloader("http://www.c-bike.com.tw/xml/stationlistopendata.aspx");
                        //下載成功
                        if (_downloader.strUnFormatedData != "")
                        {
                            //轉換格式
                            CBikeDataConverter _converter = new CBikeDataConverter(_downloader.strUnFormatedData);

                            string result = _converter.SaveData();

                            if (result != "")
                                Console.WriteLine(result + "Saved.");
                        }
                    }
                    break;

                //2.差異系統
                case "2":
                    {
                        Console.WriteLine("Press file name without sub-file name:");
                        _compareFileName = Console.ReadLine();

                        //讀檔
                        XmlDocument _old = new XmlDocument();
                        try
                        {
                            _old.Load(_compareFileName + ".xml");
                        }
                        catch
                        {
                            Console.WriteLine("Failed to load file! Please check input name is vaild or the file is exist.");
                            break;
                        }

                        //XML為有效的才做
                        if (_old.HasChildNodes)
                        {
                            Console.WriteLine("Load file Successuful!");

                            CBikeDataDownloader _downloader = new CBikeDataDownloader("http://www.c-bike.com.tw/xml/stationlistopendata.aspx");
                            if (_downloader.strUnFormatedData != "")
                            {
                                CBikeDataConverter _converter = new CBikeDataConverter(_downloader.strUnFormatedData);

                                CBikeDataComparer _comparer = new CBikeDataComparer(_converter.FormatedData, _old);

                                string result = _comparer.SaveData();

                                if (result != "")
                                    Console.WriteLine(result + "Saved.");
                            }
                        }
                    }
                    break;
                //3.差異系統(本地比較)
                case "3":
                    {
                        Console.WriteLine("Press NEWER file name without sub-file name:");
                        _NewCompareFile = Console.ReadLine();

                        XmlDocument _new = new XmlDocument();
                        try
                        {
                            _new.Load(_NewCompareFile + ".xml");
                        }
                        catch
                        {
                            Console.WriteLine("Failed to load file! Please check input name is vaild or the file is exist.");
                            break;
                        }

                        Console.WriteLine("Press OLDER file name without sub-file name:");
                        _OldCompareFile = Console.ReadLine();

                        XmlDocument _old = new XmlDocument();
                        try
                        {
                            _old.Load(_OldCompareFile + ".xml");
                        }
                        catch
                        {
                            Console.WriteLine("Failed to load file! Please check input name is vaild or the file is exist.");
                            break;
                        }

                        if (_old.HasChildNodes && _new.HasChildNodes)
                        {
                            Console.WriteLine("Load file Successuful!");

                            CBikeDataComparer _comparer = new CBikeDataComparer(_new, _old);

                            string result = _comparer.SaveData();

                            if (result != "")
                                Console.WriteLine(result + "Saved.");
                        }
                    }
                    break;
                //Etc. 輸入無效的指令
                default:
                    {
                        Console.WriteLine("Not Availeble Command.");
                    }
                    break;
            }

            //清除資料
            _command = "";
            _compareFileName = "";

            _NewCompareFile = "";
            _OldCompareFile = "";

            //結束程式
            Console.WriteLine("Press Any Key to Exit!");
            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("City Bike Data Tool v2.0 by Kagami");
            Console.WriteLine("-----------------------------------");
            Console.WriteLine("1.DownLoad new data and save.");
            Console.WriteLine("2.Compare new data with other data , and generate compare data.");
            Console.WriteLine("3.Compare two datas in local");
            Console.WriteLine("Please Choose with number:");
            _command = Console.ReadLine();


            switch (_command)
            {
            //1.轉換系統
            case "1":
            {
                //下載檔案
                CBikeDataDownloader _downloader = new CBikeDataDownloader("http://www.c-bike.com.tw/xml/stationlistopendata.aspx");
                //下載成功
                if (_downloader.strUnFormatedData != "")
                {
                    //轉換格式
                    CBikeDataConverter _converter = new CBikeDataConverter(_downloader.strUnFormatedData);

                    string result = _converter.SaveData();

                    if (result != "")
                    {
                        Console.WriteLine(result + "Saved.");
                    }
                }
            }
            break;

            //2.差異系統
            case "2":
            {
                Console.WriteLine("Press file name without sub-file name:");
                _compareFileName = Console.ReadLine();

                //讀檔
                XmlDocument _old = new XmlDocument();
                try
                {
                    _old.Load(_compareFileName + ".xml");
                }
                catch
                {
                    Console.WriteLine("Failed to load file! Please check input name is vaild or the file is exist.");
                    break;
                }

                //XML為有效的才做
                if (_old.HasChildNodes)
                {
                    Console.WriteLine("Load file Successuful!");

                    CBikeDataDownloader _downloader = new CBikeDataDownloader("http://www.c-bike.com.tw/xml/stationlistopendata.aspx");
                    if (_downloader.strUnFormatedData != "")
                    {
                        CBikeDataConverter _converter = new CBikeDataConverter(_downloader.strUnFormatedData);

                        CBikeDataComparer _comparer = new CBikeDataComparer(_converter.FormatedData, _old);

                        string result = _comparer.SaveData();

                        if (result != "")
                        {
                            Console.WriteLine(result + "Saved.");
                        }
                    }
                }
            }
            break;

            //3.差異系統(本地比較)
            case "3":
            {
                Console.WriteLine("Press NEWER file name without sub-file name:");
                _NewCompareFile = Console.ReadLine();

                XmlDocument _new = new XmlDocument();
                try
                {
                    _new.Load(_NewCompareFile + ".xml");
                }
                catch
                {
                    Console.WriteLine("Failed to load file! Please check input name is vaild or the file is exist.");
                    break;
                }

                Console.WriteLine("Press OLDER file name without sub-file name:");
                _OldCompareFile = Console.ReadLine();

                XmlDocument _old = new XmlDocument();
                try
                {
                    _old.Load(_OldCompareFile + ".xml");
                }
                catch
                {
                    Console.WriteLine("Failed to load file! Please check input name is vaild or the file is exist.");
                    break;
                }

                if (_old.HasChildNodes && _new.HasChildNodes)
                {
                    Console.WriteLine("Load file Successuful!");

                    CBikeDataComparer _comparer = new CBikeDataComparer(_new, _old);

                    string result = _comparer.SaveData();

                    if (result != "")
                    {
                        Console.WriteLine(result + "Saved.");
                    }
                }
            }
            break;

            //Etc. 輸入無效的指令
            default:
            {
                Console.WriteLine("Not Availeble Command.");
            }
            break;
            }

            //清除資料
            _command         = "";
            _compareFileName = "";

            _NewCompareFile = "";
            _OldCompareFile = "";

            //結束程式
            Console.WriteLine("Press Any Key to Exit!");
            Console.ReadLine();
        }