private void RefreshRemain() { System.Threading.Thread t = new System.Threading.Thread(delegate() { try { var context = new DBClassDataContext(Globals.ConnectionString); var it = (from n in context.item select n).ToList(); int cnt; cnt = (from n in it where n.item_kansa_end == null && n.item_sellprice != null && n.item_kansa_flag1 == null select n).Count(); ControlUtil.SafelyOperated(this.textBox_remain, (MethodInvoker) delegate() { this.textBox_remain.Text = cnt.ToString(); }); int allcnt; allcnt = (from n in it where n.item_kansa_end == null && n.item_sellprice != null select n).Count(); ControlUtil.SafelyOperated(this.textBox_allkansa, (MethodInvoker) delegate() { this.textBox_allkansa.Text = allcnt.ToString(); }); int sum; sum = (from n in it where n.item_kansa_end == null && n.item_sellprice != null select n.item_sellprice.Value).Sum(); ControlUtil.SafelyOperated(this.textBox_sum, (MethodInvoker) delegate() { this.textBox_sum.Text = sum.ToString("#,##0"); }); } catch { } }); t.IsBackground = true; t.Start(); }
protected void setTitleConvBarcodeThread(object obj, BarcodeType type) { TextBox textbox = (TextBox)obj; if (toolStripStatusLabel1.Text == this.tooltip_BarcodeSearching) { return; } bool f = false; try { ControlUtil.SafelyOperated(this, (MethodInvoker) delegate() { toolStripStatusLabel1.Text = this.tooltip_BarcodeSearching; isbn = textbox.Text; button_next.Enabled = Button_next_Enable(); }); f = this.setTitleConvIsbn_Impl(textbox, type); } catch (Exception e) { MessageBox.Show(e.Message, "ISBN/JAN検索"); } finally { if (f == false) { //書名をセットしなかった } ControlUtil.SafelyOperated(this, (MethodInvoker) delegate() { toolStripStatusLabel1.Text = null; button_next.Enabled = Button_next_Enable(); }); } }
//別スレッド protected bool setTitleConvIsbn_Impl(TextBox textbox, BarcodeType type) { string code = textbox.Text; SignedRequestHelper helper = new SignedRequestHelper("test", "test", "ecs.amazonaws.jp"); IDictionary <string, string> requestParams = new Dictionary <string, String>(); requestParams["Service"] = "AWSECommerceService"; requestParams["Version"] = "2009-11-01"; requestParams["Operation"] = "ItemLookup"; requestParams["ItemId"] = code; if (type == BarcodeType.Isbn) { requestParams["IdType"] = "ISBN"; } //else if (type == BarcodeType.Jan) else { requestParams["IdType"] = "EAN"; } requestParams["SearchIndex"] = "All"; string url = helper.Sign(requestParams); System.Diagnostics.Debug.WriteLine(url); System.Net.WebClient webc = new System.Net.WebClient(); using (Stream st = webc.OpenRead(url)) { if (st == null) { return(false); } using (StreamReader sr = new StreamReader(st, Encoding.UTF8)) { XmlDocument xdoc = new XmlDocument(); xdoc.Load(sr); XmlNodeList xlist = xdoc.GetElementsByTagName("Title", @"http://webservices.amazon.com/AWSECommerceService/2009-11-01"); if (xlist.Count > 0) { XmlNode xtitle = xlist.Item(0); ControlUtil.SafelyOperated(this, (MethodInvoker) delegate() { textbox.Text = xtitle.InnerText; }); return(true); } } } ControlUtil.SafelyOperated(this, (MethodInvoker) delegate() { // cell.DataGridView[ColumnName.isbn, cell.RowIndex].Value = null; }); return(false); }
public static object SafelyOperated(Control context, Delegate process) { return(ControlUtil.SafelyOperated(context, process, null)); }
private void button_tagprint_Click(object sender, EventArgs e) { ControlUtil.DGV_ExSelect(this.dataGridView1); this.PrintSelections(); }