Example #1
0
        public bool UpdateShop(string name, Alading.HtmlEditor.Editor editor)
        {
            Alading.Entity.Shop focusShop = gridViewShop.GetFocusedRow() as Alading.Entity.Shop;
            if (focusShop != null)
            {
                string  session = SystemHelper.GetSessionKey(focusShop.nick);
                string  value   = editor.BodyHtml;
                ShopRsp shopRsp = TopService.ShopUpdate(session, name, value);

                ShopRsp getShopRsp = TopService.ShopGet(focusShop.nick);
                if (getShopRsp != null)
                {
                    if (name == "desc")
                    {
                        focusShop.desc = getShopRsp.Shop.Description;
                    }
                    else
                    {
                        focusShop.bulletin = getShopRsp.Shop.Bulletin;
                    }
                    focusShop.sid      = getShopRsp.Shop.Sid;
                    focusShop.modified = DateTime.Parse(getShopRsp.Shop.Modified);
                    ShopService.UpdateShop(focusShop);
                }
                return(true);
            }
            else
            {
                XtraMessageBox.Show("请先选择数据", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 点击更新店铺
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barBtnDownload_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            WaitDialogForm waitFrm = null;

            try
            {
                Alading.Entity.Shop focusShop = gridViewShop.GetFocusedRow() as Alading.Entity.Shop;
                if (focusShop == null)//未选中
                {
                    XtraMessageBox.Show("请先选中更新的店铺", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                waitFrm = new WaitDialogForm(Constants.WAIT_LOAD_DATA);
                ShopRsp shopRsp = TopService.ShopGet(focusShop.nick);
                string  session = SystemHelper.GetSessionKey(focusShop.nick);
                UserRsp userRsp = TopService.UserGet(session, focusShop.nick, string.Empty);

                Alading.Entity.Shop shop = new Alading.Entity.Shop();

                if (shopRsp == null || userRsp == null)//从淘宝网未获取到数据
                {
                    waitFrm.Close();
                    XtraMessageBox.Show("未获取到数据", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                ShopCopyData((int)shopShowType, shop, shopRsp.Shop, userRsp.User);

                Alading.Entity.Shop oldShop = ShopService.GetShopByNick(shop.nick);

                if (oldShop == null)//不存在时添加
                {
                    ShopService.AddShop(shop);
                }
                else//存在时更新
                {
                    ShopService.UpdateShop(shop);
                }

                LoadShop(shopShowType);//重新刷新界面
                waitFrm.Close();
                XtraMessageBox.Show("更新成功", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                waitFrm.Close();
                XtraMessageBox.Show(ex.Message, Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #3
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <string>    nicklist = (List <string>)e.Argument;
            int              n        = nicklist.Count;
            int              temp     = 0;//作用是避免进度值propgress没有改变时得重复报告
            BackgroundWorker worker   = (BackgroundWorker)sender;

            for (int i = 0; i < n; i++)
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }

                try
                {
                    string  session = SystemHelper.GetSessionKey(nicklist[i]);
                    ShopRsp shopRsp = TopService.ShopGet(nicklist[i]);
                    UserRsp userRsp = TopService.UserGet(session, nicklist[i], string.Empty);
                    if (shopRsp != null || userRsp != null)
                    {
                        Alading.Entity.Shop shop = new Alading.Entity.Shop();
                        UIHelper.ShopCopyData(shop, shopRsp.Shop, userRsp.User);
                        ShopService.UpdateShop(shop);
                    }

                    //进度报告
                    int propgress = (int)((float)(i + 1) / n * 100);
                    if (propgress > temp)
                    {
                        MyInfo myInfo = new MyInfo();
                        myInfo.nick      = nicklist[i];
                        myInfo.isSucceed = true;
                        worker.ReportProgress(propgress, myInfo);
                    }
                    temp = propgress;
                }
                catch (System.Exception ex)
                {
                    MyInfo myInfo = new MyInfo();
                    myInfo.nick      = nicklist[i];
                    myInfo.isSucceed = false;
                    myInfo.msg       = ex.Message;
                    worker.ReportProgress(0, myInfo);
                }
            }
        }