Esempio n. 1
0
 private void Button_ReTry_Click(object sender, RoutedEventArgs e)
 {
     new Window_SetTimeOut().ShowDialog();
     isRetry = true;
     this.Close();
     ImageDownloadService.ReTryAsync();
 }
Esempio n. 2
0
        /// <summary>
        /// 异步初始化数据
        /// </summary>
        /// <returns></returns>
        private async Task InitAsync()
        {
            var list = await Task.Run(() =>
            {
                JObject init_result = wcs.WeChatInit();
                WeChatUser          = JObjectToUser(init_result["User"]);
                ImageDownloadService.Add(WeChatUser);
                return(init_result["ContactList"].Select(contact => JObjectToUser(contact)));
            });

            //将数据传输到聊天列表组件
            ChatListManager.AddChat(list.Distinct(new WeChatUserComparer()).ToArray());

            //开启微信状态通知
            await Task.Run(() =>
            {
                wcs.WxStatusNotify(WeChatUser.UserName);
            });

            //加载通讯录
            await LoadAllContact();

            //加载群组成员
            await UpdateInitGroupMember(list.Where(p => p.IsRoomContact()).Select(p => p.UserName).Distinct().ToArray());

            StartWeChatSyncTask();
        }
        private async void Button_Start_Click(object sender, RoutedEventArgs e)
        {
            registerCommands();
            await ImageDownloadService.StartDownload(DownloadTaskCollection);

            TextBox_UrlInput.Focus();
        }
Esempio n. 4
0
        private async void _getProductDetailCallback(IAsyncResult asynchronousResult)
        {
            HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;

            try
            {
                HttpWebResponse response      = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
                string          resultContent = string.Empty;
                using (var reader = new StreamReader(response.GetResponseStream()))
                {
                    resultContent = reader.ReadToEnd();
                };
                if (!string.IsNullOrEmpty(resultContent))
                {
                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                                  () =>
                    {
                        var item = Newtonsoft.Json.JsonConvert.DeserializeObject <ItemSearchDetails>(resultContent).item;
                        if (item != null)
                        {
                            new Thread(() =>
                            {
                                ImageDownloadService.Download(item);
                            }).Start();
                            StaticResources.TotalChoosingProduct++;
                            StaticResources.ChoosingProductFeature.SelfCount++;
                            this.ProductList.Where(p => p.id == item.itemid).FirstOrDefault().isCanDownload = false;
                            StaticResources.dictCanDownload[item.itemid] = false;
                            item.index = StaticResources.TotalChoosingProduct;
                            StaticResources.ListProductDetails.Add(item);
                        }
                    });

                    //isGetProduct = true;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 5
0
        public ShopeeLoginPageViewModel()
        {
            this.TbxHeaderAccount = StaticResources.choosingLanguage.LoginPageHeaderAccount;
            this.TbxUserName      = StaticResources.choosingLanguage.LoginPageUserName;
            this.TbxStatus        = StaticResources.choosingLanguage.LoginPageStatus;
            this.TbxDeleteAll     = StaticResources.choosingLanguage.LoginPageDeleteAll;
            this.TbxDelete        = StaticResources.choosingLanguage.LoginPageDelete;
            this.TbxAddNewAccount = StaticResources.choosingLanguage.LoginPageAddNewAccount;
            this.TbxMessage       = StaticResources.choosingLanguage.LoginPageNewMessage;
            this.TbxOrder         = StaticResources.choosingLanguage.LoginPageNewOrder;
            this.TbxMessageOpen   = StaticResources.choosingLanguage.LoginPageMessageOpen;
            this.TbxOrderOpen     = StaticResources.choosingLanguage.LoginPageOrderOpen;
            this.TbxWeekRevenue   = StaticResources.choosingLanguage.LoginPageWeekRevenue;
            this.TbxMonthRevenue  = StaticResources.choosingLanguage.LoginPageMonthRevenue;
            this.TbxTotalRevenue  = StaticResources.choosingLanguage.LoginPageTotalRevenue;
            this.TbxRevenueReport = StaticResources.choosingLanguage.LoginPageRevenueReport;

            this.isGrLoginFormShown = Visibility.Collapsed;
            this.ListShop           = StaticResources.lstShopInfoLogin;
            //this.ShopeeLoginUri = new Uri(StaticResources.SellerMainUri + "account/signin");
            BtTurnOfLoginFormTapped = new DelegateCommand(() =>
            {
                this.isGrLoginFormShown = Visibility.Collapsed;
                this.TgGrFormLogin      = "******";
            });

            BtOpenChatPageTapped = new DelegateCommand <ShopInfoLogin>(async(s) =>
            {
                StaticResources.isOpenChatPage  = true;
                StaticResources.isOpenOrderPage = false;
                if (StaticResources.SelectedShopLogin == s)
                {
                    await new MessageDialog(StaticResources.choosingLanguage.GlobalWarningCurrentShop).ShowAsync();
                    return;
                }
                StaticResources.SelectedShopLogin = s;
            });

            BtRevenueReportTapped = new DelegateCommand(() =>
            {
                foreach (var shop in StaticResources.lstShopInfoLogin)
                {
                    new Thread(async() =>
                    {
                        await Utility.GetRevenueCount(shop);
                    }).Start();
                }
            });

            BtOpenOrderPageTapped = new DelegateCommand <ShopInfoLogin>(async(s) =>
            {
                StaticResources.isOpenChatPage  = false;
                StaticResources.isOpenOrderPage = true;
                if (StaticResources.SelectedShopLogin == s)
                {
                    await new MessageDialog(StaticResources.choosingLanguage.GlobalWarningCurrentShop).ShowAsync();
                    return;
                }
                StaticResources.SelectedShopLogin = s;
            });

            BtDeleteAccountTapped = new DelegateCommand <ShopInfoLogin>((s) =>
            {
                if (StaticResources.SelectedShopLogin == s)
                {
                    StaticResources.SelectedShopLogin = null;
                }
                StaticResources.lstShopInfoLogin.Remove(s);
                StaticResources.TotalSellerAccount.Remove(s);
                XMLService.xmlSerializeShopInfo(StaticResources.TotalSellerAccount);
            });

            BtDeleteAllAccountTapped = new DelegateCommand(() =>
            {
                foreach (var shop in StaticResources.lstShopInfoLogin)
                {
                    StaticResources.TotalSellerAccount.Remove(shop);
                }
                StaticResources.lstShopInfoLogin.Clear();
                StaticResources.SelectedShopLogin = null;
                XMLService.xmlSerializeShopInfo(StaticResources.TotalSellerAccount);
            });

            BtAddNewAccountTapped = new DelegateCommand(() =>
            {
                //  Clear cookie
                // Login
                // Login -> navigate
                // Lay cookie
                // close

                this.isGrLoginFormShown       = Visibility.Visible;
                this.TgGrFormLogin            = "******";
                Uri loginUri                  = this.ShopeeLoginUri;
                HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();
            });

            wvContentLoadding = new DelegateCommand(() =>
            {
                var httpBaseProtocolFilter = new HttpBaseProtocolFilter();
                var cookieManager          = httpBaseProtocolFilter.CookieManager;
                var cc = cookieManager.GetCookies(this.ShopeeLoginUri);
                bool bAuthenticated = false;
                string strCookie    = string.Empty;
                if (cc == null)
                {
                    return;
                }
                foreach (var cookie in cc)
                {
                    LstShortCookie.Add(new ShortCookie
                    {
                        name   = cookie.Name.ToUpper().TrimEnd().TrimStart(),
                        value  = cookie.Value.TrimEnd().TrimStart(),
                        path   = cookie.Path.TrimEnd().TrimStart(),
                        domain = cookie.Domain.TrimEnd().TrimStart()
                    });
                    strCookie += cookie.Name + "=" + cookie.Value + ";";
                    if (cookie.Name.ToUpper().Contains("SPC_U"))
                    {
                        if (cookie.Value != "-")
                        {
                            bAuthenticated = true;
                        }
                    }
                }
                if (bAuthenticated)
                {
                    string LoginAPIUri = "";
                    var SPC_CDS        = LstShortCookie.Where(p => p.name == "SPC_CDS").FirstOrDefault();
                    if (SPC_CDS != null)
                    {
                        LoginAPIUri = StaticResources.SellerMainUri + "api/v2/login/?SPC_CDS=" + SPC_CDS.value + "&SPC_CDS_VER=2";
                    }
                    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(LoginAPIUri));
                    req.Headers.Add("Cookie", strCookie);
                    req.Host      = StaticResources.SellerHostUri;
                    req.Accept    = "application/json, text/plain, */*";
                    req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36";
                    req.Referer   = StaticResources.SellerReferUri;
                    req.Headers.Add("Accept-Encoding", "zip, deflate, br");
                    //req.Headers.Add("Accept-Language", "vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5");
                    try
                    {
                        var res = (HttpWebResponse)req.GetResponse();
                        string resultContent = string.Empty;
                        using (var reader = new StreamReader(res.GetResponseStream()))
                        {
                            resultContent = reader.ReadToEnd();
                        };
                        if (!string.IsNullOrEmpty(resultContent))
                        {
                            var result = Newtonsoft.Json.JsonConvert.DeserializeObject <ShopInfo>(resultContent);
                            if (!string.IsNullOrEmpty(result.username))
                            {
                                if (StaticResources.lstShopInfoLogin == null)
                                {
                                    StaticResources.lstShopInfoLogin = new ObservableCollection <ShopInfoLogin>();
                                }
                                var tmpShop = StaticResources.TotalSellerAccount.Where(p => p.Shop.shopid == result.shopid && p.ShortRegion == StaticResources.ShortRegion).FirstOrDefault();
                                if (tmpShop != null)
                                {
                                    tmpShop.Shop           = result;
                                    tmpShop.lstLoginCookie = LstShortCookie;
                                    tmpShop.strLoginCookie = strCookie;
                                    tmpShop.ShopStatus     = "Updated";
                                }
                                else
                                {
                                    tmpShop                = new ShopInfoLogin();
                                    tmpShop.Shop           = result;
                                    tmpShop.lstLoginCookie = LstShortCookie;
                                    tmpShop.strLoginCookie = strCookie;
                                    tmpShop.ShortRegion    = StaticResources.ShortRegion;
                                    StaticResources.TotalSellerAccount.Add(tmpShop);
                                    StaticResources.lstShopInfoLogin.Add(tmpShop);
                                    tmpShop.ShopStatus = "New";
                                }
                                StaticResources.DictGuid[tmpShop.Shop.id] = Guid.NewGuid().ToString();
                                StaticResources.SelectedShopLogin         = tmpShop;
                                this.isGrLoginFormShown = Visibility.Collapsed;
                                ImageDownloadService.DownloadAvatar(result);
                                XMLService.xmlSerializeShopInfo(StaticResources.TotalSellerAccount);
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            });


            ShopeeLoginPageLoading = new DelegateCommand(() =>
            {
                //Call browser
            });
        }