static void Main(string[] args) { //設定使用哪個抓取Setting類別 var setting = new AppsettingConfig(); //建立工廠 將配置檔傳入建構子中 InvoiceApiFactroy factory = new InvoiceApiFactroy(setting); //建立查詢參數 //下面範例查詢 發票民國106年7.8月中獎發票 QryWinningListModel model = new QryWinningListModel() { invTerm = "10608" }; //在工廠中藉由傳入參數 取得Api產品 var api = factory.GetProxyInstace(model); //api回傳結果 var result = api.ExcuteApi(model); Console.WriteLine(result); Console.ReadKey(); }
private static Task <string> AsnycTest() { //Register Assembly you want to inject. ApiTypeProvider.Instance.RegisterAssembly(Assembly.GetExecutingAssembly()); #region 使用工廠模式 //建立查詢參數 //下面範例查詢 發票民國106年7.8月中獎發票 QryWinningListModel model = new QryWinningListModel() { invTerm = "10610" }; //建立工廠 將配置檔傳入建構子中 InvoiceApiFactory factory = new InvoiceApiFactory(); //在工廠中藉由傳入參數 取得Api產品 var api = factory.GetProxyInstace(model); //api回傳結果 var result = api.ExecuteApiAsync(model); Console.WriteLine(result.Result); #endregion #region 使用 InvoiceApiContext DonateQueryModel donateModel = new DonateQueryModel() { qKey = "伊甸" }; InvoiceApiContext apiContext = new InvoiceApiContext(); return(apiContext.ExecuteApiAsync(donateModel)); #endregion }
public ActionResult QryWinningList() { QryWinningListModel model = new QryWinningListModel() { invTerm = "10604" }; var api = MoblieInvoiceApiFactroy.GetInstace(model); var resultJson = api.ExcuteApi(model); var resultModle = JsonConvert.DeserializeObject <QryWinningListViewModel>(resultJson); return(View(resultModle)); }
static void Main(string[] args) { //Register Assembly you want to inject. ApiTypeProvider.Instance.RegisterAssembly(Assembly.GetExecutingAssembly()); string result = string.Empty; #region 使用工廠模式 //建立查詢參數 //下面範例查詢 發票民國106年7.8月中獎發票 QryWinningListModel model = new QryWinningListModel() { invTerm = "10610" }; //建立工廠 將配置檔傳入建構子中 InvoiceApiFactory factory = new InvoiceApiFactory(); //在工廠中藉由傳入參數 取得Api產品 var api = factory.GetProxyInstace(model); //api回傳結果 result = api.ExecuteApi(model); Console.WriteLine(result); #endregion #region 使用 InvoiceApiContext DonateQueryModel donateModel = new DonateQueryModel() { qKey = "伊甸" }; InvoiceApiContext apiContext = new InvoiceApiContext(); result = apiContext.ExecuteApi(donateModel); #endregion Console.WriteLine(result); Console.ReadKey(); }