Ejemplo n.º 1
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     using (yiyilandbEntities dbcontext = new yiyilandbEntities())
     {
         //dbcontext.products
         //this.productsTableAdapter.Fill(this.yiyilandbDataSet.products);
         this.productsTableAdapter.FillBySql(this.yiyilandbDataSet.products, textBox1.Text);
     }
 }
Ejemplo n.º 2
0
        private async Task <bool> DownImage(string id)
        {
            var t = Task.Run(() =>
            {
                //先查询产品信息
                using (yiyilandbEntities dbcontext = new yiyilandbEntities())
                {
                    try
                    {
                        {
                            //下载商品标题图片和详情图片
                            var arrs = from imagedetail in dbcontext.imagedetail
                                       where id == imagedetail.id
                                       select imagedetail;
                            int count = 0;
                            foreach (var item in arrs)
                            {
                                count            = 0;
                                string strimages = item.images;
                                if (!string.IsNullOrEmpty(strimages))
                                {
                                    var images  = strimages.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                                    string path = Path.Combine(AppConfigContext.Instance.WorkingPath, id, "images");
                                    foreach (var uri in images)
                                    {
                                        count++;
                                        DownloadOneFileByURLWithWebClient(count.ToString(), uri, path);
                                    }
                                }
                                count             = 0;
                                string strdetails = item.details;
                                if (!string.IsNullOrEmpty(strdetails))
                                {
                                    var details = strdetails.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                                    string path = Path.Combine(AppConfigContext.Instance.WorkingPath, id, "details");
                                    foreach (var uri in details)
                                    {
                                        count++;
                                        DownloadOneFileByURLWithWebClient(count.ToString(), uri, path);
                                    }
                                }
                            }
                        }
                        {
                            //下载sku图片
                            var arrs = from sku in dbcontext.productskus
                                       where sku.id == id
                                       select sku;
                            string path = Path.Combine(AppConfigContext.Instance.WorkingPath, id, "skus");
                            foreach (var item in arrs)
                            {
                                if (!string.IsNullOrEmpty(item.skname))
                                {
                                    DownloadOneFileByURLWithWebClient(item.skname, item.imageurl, path);
                                }
                            }
                        }
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        return(false);
                    }
                }
            });
            await t;

            return(t.Result);
        }