private async Task getItemsAsync() { string arTerm = ARTermsOptions.SelectedValue != null?ARTermsOptions.SelectedValue.ToString() : "1"; string itemType = ItemTypeList.SelectedValue != null?ItemTypeList.SelectedValue.ToString() : null; string trademarkKey = TrademarkList.SelectedValue != null?TrademarkList.SelectedValue.ToString() : null; string countTry = ItemQuatity.Text; string itemKey = ItemKey.Text; bool extraInfo = ExtraInfo.IsChecked ?? false; int qty = 0; if (String.IsNullOrEmpty(countTry) || !int.TryParse(countTry, out qty)) { qty = 0; } DateTime start = DateTime.Now; DateTime end; try { string msg; if (!String.IsNullOrEmpty(itemKey)) //single item fetch { var result = await client.GetItemDetails(itemKey, itemKey, arTerm, 0, extraInfo); msg = result; } else //fetch multiple items { if (!String.IsNullOrEmpty(itemType) || !String.IsNullOrEmpty(trademarkKey)) { var result = await client.GetItemsFilteredAsync(itemType, trademarkKey, "itemFiltered", arTerm, qty, extraInfo); msg = result; } else { var result = await client.GetAllItemsAsync("allItems", qty, arTerm, extraInfo); msg = result; } } end = DateTime.Now; MessageBox.Show(String.Format("Vrijeme izvođenja: {2} minuta i {1} sekundi, {0}", msg, (end - start).Seconds, (end - start).Minutes)); } catch (Exception ex) { ExceptionHandler.Log(ex, ctx.Directory); end = DateTime.Now; MessageBox.Show(String.Format("Došlo je do greške. Vrijeme izvođenja: {0}", (end - start).TotalSeconds)); } }
private static async Task testItemListAsync() { string aspKey = "micpg"; string customerKey = "kupac"; string password = "******"; string cookie = "39983830859dJFaogrSxpgIcfvfy1T"; System.IO.FileInfo f = new FileInfo(String.Format(@"C:\Temp\itemList_{0}.xml", DateTime.Now.ToString("ddMMyyyy_HH_mm"))); using (StreamWriter sw = f.AppendText()) { try { WSContext ctx = new WSContext(aspKey, customerKey, password, @"http://www.microline.hr/WebServices/MOL.asmx", @"C:\Temp", cookie); WSClient client = new WSClient(ctx); var report = await client.GetItemsFilteredAsync(null, "sam", "itemsFilteredSam"); sw.WriteLine(report); } catch (Exception ex) { sw.WriteLine(ex.Message); sw.WriteLine(ex.StackTrace); if (ex.InnerException != null) { sw.WriteLine(ex.InnerException.Message); sw.WriteLine(ex.InnerException.StackTrace); if (ex.InnerException.InnerException != null) { sw.WriteLine(ex.InnerException.InnerException.Message); sw.WriteLine(ex.InnerException.InnerException.StackTrace); } } } } }