static void Main(string[] args) { var xmlService1 = new ImportXmlService(); var datas = xmlService1.LoadFormFile(Utils.FilePath.GetFullPath("北捷站點.xml")); Console.WriteLine(string.Format("分析完成,共有{0}筆資料", datas.Count)); datas.ForEach(x => { Console.WriteLine(string.Format("編號 :{0} 名稱:{1}({2}) 描述:{3}", x.StationID, x.StationName, x.ExitName, x.LocationDescription)); }); var jsonService = new ImportJsonService(); var jsonDatas = jsonService.LoadFormFile(Utils.FilePath.GetFullPath("高雄活動.txt")); Console.WriteLine(string.Format("分析完成,共有{0}筆資料", jsonDatas.Count)); jsonDatas.ForEach(x => { Console.WriteLine(string.Format("編號 :{0} 名稱:{1} 地點:{2}", x.PrgId, x.PrgName, x.OrgName)); }); Console.ReadKey(); }
static void Main(string[] args) { var xmlService1 = new ImportXmlService(); var datas = xmlService1.LoadFormFile(@"D:\Works\11003\NKUST_10902-0318\docs\北捷站點.xml"); Console.WriteLine(string.Format("分析完成,共有{0}筆資料", datas.Count)); datas.ForEach(x => { Console.WriteLine(string.Format("編號 :{0} 描述:{1}", x.StationID, x.LocationDescription)); }); var jsonService = new ImportJsonService(); var jsonDatas = jsonService.LoadFormFile(@"D:\Works\11003\NKUST_10902-0318\docs\高雄活動.txt"); Console.WriteLine(string.Format("分析完成,共有{0}筆資料", jsonDatas.Count)); jsonDatas.ForEach(x => { Console.WriteLine(string.Format("編號 :{0} 描述:{1}", x.PRGID, x.ORGNAME)); }); Console.ReadKey(); }
static void Main(string[] args) { //Console.WriteLine("Hello World!"); // test WaterConsumption test = new WaterConsumption() { consumptionOfWater = 36685788, executingUnit = "宜蘭縣", populationServed = 421328, remarks = "無", theDailyDomesticConsumptionOfWaterPerPerson = 238, year = "2008-12-31T00:00:00" }; // 序列化 //string jsonData = JsonConvert.SerializeObject(test); //Console.WriteLine(jsonData); List <WaterConsumption> results = new ImportJsonService().read(@"..\..\..\7D1311DD-E1DE-4B01-A5ED-1FC589A7C082.json"); Console.WriteLine(String.Format("全部共有{0}筆資料\n", results.Count)); foreach (WaterConsumption result in results) { Console.WriteLine("ConsumptionOfWater:" + result.consumptionOfWater); Console.WriteLine("ExecutingUnit:" + result.executingUnit); Console.WriteLine("PopulationServed:" + result.populationServed); Console.WriteLine("Remarks:" + result.remarks); Console.WriteLine("TheDailyDomesticConsumptionOfWaterPerPerson:" + result.theDailyDomesticConsumptionOfWaterPerPerson); Console.WriteLine("Year:" + result.year); Console.WriteLine(""); } }
public IActionResult Import() { string filePath = ConsoleApp1.Utlis.FilePath.getFilePath("7D1311DD-E1DE-4B01-A5ED-1FC589A7C082.json"); List <WaterConsumption> results = new ImportJsonService().read(filePath); _context.waterConsumptions.AddRange(results); _context.SaveChanges(); return(Content("OK")); }
static void Main(string[] args) { // var xmlService1 = new ImportXmlService(); // // var datas = xmlService1.LoadFormFile(Utils.FilePath.GetFullPath("北捷站點.xml")); // Console.WriteLine(string.Format("分析完成,共有{0}筆資料", datas.Count)); // datas.ForEach(x => // { // Console.WriteLine(string.Format("編號 :{0} 名稱:{1}({2}) 描述:{3}", x.StationID, x.StationName?.Zh_tw, x.ExitName.Zh_tw, x.LocationDescription)); // }); // var jsonService = new ImportJsonService(); //var jsonDatas = jsonService.LoadFormFile(Utils.FilePath.GetFullPath("高雄活動.txt")); // Console.WriteLine(string.Format("分析完成,共有{0}筆資料", jsonDatas.Count)); // jsonDatas.ForEach(x => // { // Console.WriteLine(string.Format("編號 :{0} 名稱:{1} 地點:{2}", x.PrgId,x.PrgName, x.OrgName)); // }); var jsonService = new ImportJsonService(); ImportJsonService jsonService1 = jsonService; var jsonDatas = jsonService1.LoadFormFile(Utils.FilePath.GetFullPath("台南國中男女生人數.txt")); Console.WriteLine(string.Format("分析完成,共有{0}筆資料", jsonDatas.Count)); jsonDatas.ForEach(x => { Console.WriteLine(string.Format("學校 :{0} 性別:{1} 人數:{2}", x.School, x.Sex, x.Num)); }); Console.ReadKey(); }