public ShopeeProductSearchViewModel() { this.TbxThumbnail = StaticResources.choosingLanguage.SearchPageThumbnail; this.TbxName = StaticResources.choosingLanguage.SearchPageName; this.TbxPrice = StaticResources.choosingLanguage.SearchPagePrice; this.TbxOriginPrice = StaticResources.choosingLanguage.SearchPageOriginalPrice; this.TbxInStock = StaticResources.choosingLanguage.SearchPageInStock; this.TbxView = StaticResources.choosingLanguage.SearchPageView; this.TbxLike = StaticResources.choosingLanguage.SearchPageLike; this.TbxSold = StaticResources.choosingLanguage.SearchPageSold; this.TbxDownloadPage = StaticResources.choosingLanguage.SearchPageDownloadPage; this.TbxDownload = StaticResources.choosingLanguage.SearchPageDownload; this.TbxProductPerPage = StaticResources.choosingLanguage.SearchPageProductPerPage; this.TbxTotalProductS = StaticResources.choosingLanguage.SearchPageTotalProduct; this.TbxInStockS = StaticResources.choosingLanguage.SearchPageInStockS; this.TbxPageS = StaticResources.choosingLanguage.SearchPagePage; this.TbxShopName = StaticResources.choosingLanguage.SearchPageShopName; this.TbxRequire = StaticResources.choosingLanguage.SearchPageRequired; this.TbxCheck = StaticResources.choosingLanguage.SearchPageCheck; this.TbxResult = StaticResources.choosingLanguage.SearchPageResult; this.CbxPlaceHolderShop = StaticResources.choosingLanguage.SearchPageCbxChooseShop; this.TbxSearch = StaticResources.choosingLanguage.SearchPageSearch; this.TbxSearchByShopName = StaticResources.choosingLanguage.SearchPageSearchByShopName; this.TbxProductName = StaticResources.choosingLanguage.SearchPageProductName; this.TbxSearchByProductName = StaticResources.choosingLanguage.SearchPageSearchByProductName; this.TbxMainCategory = StaticResources.choosingLanguage.SearchPageMainCategory; this.CbxPlaceholderMainCategory = StaticResources.choosingLanguage.SearchPageCbxChooseMainCateogry; this.TbxSubCategory = StaticResources.choosingLanguage.SearchPageSubCategory; this.CbxPlaceholderSubCateogry = StaticResources.choosingLanguage.SearchPageCbxChooseSubCategory; this.TbxSearchByCategory = StaticResources.choosingLanguage.SearchPageSearchByCategory; this.TbxCreatedDate = StaticResources.choosingLanguage.SearchPageCreatedDate; this.TbxSortProduct = StaticResources.choosingLanguage.SearchPageSortProduct; this.TbxSortType = StaticResources.choosingLanguage.SearchPageSortType; this.CbxPlaceHolderSortDefault = StaticResources.choosingLanguage.SearchPageSortDefault; this.TbxProductNameInShop = StaticResources.choosingLanguage.SearchPageProductInShop; this.TbxProductNameInCategory = StaticResources.choosingLanguage.SearchPageProductInCategory; this.isTbxShopeNameCountResultShown = Visibility.Collapsed; //this.TbxChoosingProductCount = StaticResources.TotalChoosingProduct; this.TbxCurrentPage = 1; this.isSubCategoriesShown = Visibility.Collapsed; this.isSubSubCategoriesShown = Visibility.Collapsed; this.isCbxShopPickerShown = Visibility.Collapsed; this.isWarningTbxProductNameShown = Visibility.Collapsed; this.isWarningTbxShopNameShown = Visibility.Collapsed; this.isTbxProductNameInShopShown = Visibility.Collapsed; this.isTbxProductNameInCategoryShown = Visibility.Collapsed; this.ListSortType = PickupStaticEntity.getSortType(); if (StaticResources.ListCategories.Count() == 0) { if (StaticResources.SelectedShopLogin != null) { Utility.getCategories(StaticResources.SelectedShopLogin, new AsyncCallback(_getCategoriesCallback)); } } else { this.ListCategories = StaticResources.ListCategories; } ShopeeProductSearchLoading = new DelegateCommand(async() => { //if (StaticResources.SelectedShopLogin == null) //{ // if (StaticResources.lstShopInfoLogin.Count() == 0) // { // await new MessageDialog(StaticResources.choosingLanguage.GlobalWarningLogin).ShowAsync(); // StaticResources.NavigationFrame.Navigate(typeof(ShopeeLoginPage), null, new DrillInNavigationTransitionInfo()); // StaticResources.isLoginPage = true; // } // else // { // await new MessageDialog(StaticResources.choosingLanguage.GlobalWarningPick).ShowAsync(); // } // return; //} //this.TbxChoosingProductCount = StaticResources.TotalChoosingProduct; foreach (var item in this.ListShopItems) { if (StaticResources.dictCanDownload.ContainsKey(item.itemid)) { item.isCanDownload = StaticResources.dictCanDownload[item.itemid]; } else { item.isCanDownload = true; StaticResources.dictCanDownload[item.itemid] = true; } } }); BtCheckShopNameValidate = new DelegateCommand <TextBox>((s) => { if (!string.IsNullOrEmpty(s.Text)) { Utility.getShopID(s.Text, new AsyncCallback(_getShopIDCallback)); this.isWarningTbxShopNameShown = Visibility.Collapsed; } else { this.isWarningTbxShopNameShown = Visibility.Visible; } }); BtPageForward = new DelegateCommand <TextBox>((s) => { this.TbxCurrentPage++; switch (this._currentSearch) { case 1: this._searchByShopNameOffset += 30; if (string.IsNullOrEmpty(this.TbProductNameInShop)) { Utility.getShopItems(StaticResources.SelectedShopLogin, this.SelectedShopSearch.username, this.SelectedShopSearch.shopid, this._searchByShopNameOffset, "shop", new AsyncCallback(_getShopItemsCallback), this._sortBy, this._sortOrder); } else { Utility.getRelevantItemsInShop(StaticResources.SelectedShopLogin, this.SelectedShopSearch.username, this.SelectedShopSearch.shopid, this._searchByShopNameOffset, "shop", this.TbProductNameInShop, new AsyncCallback(_getRelevantItemInShopCallBack), this._sortBy, this._sortOrder); } break; case 2: this._searchByRelevantNameOffset += 30; Utility.getRelevantItems(StaticResources.SelectedShopLogin, s.Text, this.TbxCurrentPage, this._searchByRelevantNameOffset, new AsyncCallback(_getShopItemsCallback), this._sortBy == "pop" ? "relevancy" : this._sortBy, this._sortOrder); break; case 3: this._searchByCategoryOffset += 30; if (string.IsNullOrEmpty(this.TbProductNameInCategory)) { Utility.getShopItems(StaticResources.SelectedShopLogin, "", this._curCatId, this._searchByCategoryOffset, "search", new AsyncCallback(_getShopItemsCallback), this._sortBy == "pop" ? "relevancy" : this._sortBy, this._sortOrder); } else { Utility.getRelevantItemsInShop(StaticResources.SelectedShopLogin, "", this._curCatId, this._searchByShopNameOffset, "search", this.TbProductNameInShop, new AsyncCallback(_getRelevantItemInShopCallBack), this._sortBy == "pop" ? "relevancy" : this._sortBy, this._sortOrder); } break; default: break; } ; }); BtPagePrevious = new DelegateCommand <TextBox>((s) => { this.TbxCurrentPage--; switch (this._currentSearch) { case 1: this._searchByShopNameOffset -= 30; if (string.IsNullOrEmpty(this.TbProductNameInShop)) { Utility.getShopItems(StaticResources.SelectedShopLogin, this.SelectedShopSearch.username, this.SelectedShopSearch.shopid, this._searchByShopNameOffset, "shop", new AsyncCallback(_getShopItemsCallback), this._sortBy, this._sortOrder); } else { Utility.getRelevantItemsInShop(StaticResources.SelectedShopLogin, this.SelectedShopSearch.username, this.SelectedShopSearch.shopid, this._searchByShopNameOffset, "shop", this.TbProductNameInShop, new AsyncCallback(_getRelevantItemInShopCallBack), this._sortBy, this._sortOrder); } break; case 2: this._searchByRelevantNameOffset -= 30; Utility.getRelevantItems(StaticResources.SelectedShopLogin, s.Text, this.TbxCurrentPage, this._searchByRelevantNameOffset, new AsyncCallback(_getShopItemsCallback), this._sortBy == "pop" ? "relevancy" : this._sortBy, this._sortOrder); break; case 3: this._searchByCategoryOffset -= 30; if (string.IsNullOrEmpty(this.TbProductNameInCategory)) { Utility.getShopItems(StaticResources.SelectedShopLogin, "", this._curCatId, this._searchByCategoryOffset, "search", new AsyncCallback(_getShopItemsCallback), this._sortBy == "pop" ? "relevancy" : this._sortBy, this._sortOrder); } else { Utility.getRelevantItemsInShop(StaticResources.SelectedShopLogin, "", this._curCatId, this._searchByShopNameOffset, "search", this.TbProductNameInShop, new AsyncCallback(_getRelevantItemInShopCallBack), this._sortBy == "pop" ? "relevancy" : this._sortBy, this._sortOrder); } break; default: break; } ; }); BtDownloadPageTapped = new DelegateCommand(() => { foreach (var item in ListShopItems) { if (item.isCanDownload == true) { Utility.getItemSearchDetails(StaticResources.SelectedShopLogin, item.shopid, item.name, item.itemid, new AsyncCallback(_getProductDetailCallback)); item.isCanDownload = false; } } }); BtSearchByShopNameTapped = new DelegateCommand(() => { if (this.SelectedShopSearch != null) { this._searchByShopNameOffset = 0; this.TbxCurrentPage = 1; if (string.IsNullOrEmpty(this.TbProductNameInShop)) { Utility.getShopItems(StaticResources.SelectedShopLogin, this.SelectedShopSearch.username, this.SelectedShopSearch.shopid, this._searchByShopNameOffset, "shop", new AsyncCallback(_getShopItemsCallback), this._sortBy, this._sortOrder); } else { Utility.getRelevantItemsInShop(StaticResources.SelectedShopLogin, this.SelectedShopSearch.username, this.SelectedShopSearch.shopid, this._searchByShopNameOffset, "shop", this.TbProductNameInShop, new AsyncCallback(_getRelevantItemInShopCallBack), this._sortBy, this._sortOrder); } this._currentSearch = 1; } }); BtDownloadToLocalDbTapped = new DelegateCommand <Item>((s) => { Utility.getItemSearchDetails(StaticResources.SelectedShopLogin, s.shopid, s.name, s.itemid, new AsyncCallback(_getProductDetailCallback)); s.isCanDownload = false; }); BtSearchByCategoryTapped = new DelegateCommand(() => { this._searchByCategoryOffset = 0; this.TbxCurrentPage = 1; if (string.IsNullOrEmpty(this.TbProductNameInCategory)) { Utility.getShopItems(StaticResources.SelectedShopLogin, "", this._curCatId, this._searchByCategoryOffset, "search", new AsyncCallback(_getShopItemsCallback), this._sortBy == "pop" ? "relevancy" : this._sortBy, this._sortOrder); } else { Utility.getRelevantItemsInShop(StaticResources.SelectedShopLogin, "", this._curCatId, this._searchByShopNameOffset, "search", this.TbProductNameInCategory, new AsyncCallback(_getRelevantItemInShopCallBack), this._sortBy == "pop" ? "relevancy" : this._sortBy, this._sortOrder); } this._currentSearch = 3; }); BtSearchByProductNameTapped = new DelegateCommand <TextBox>((s) => { if (!string.IsNullOrEmpty(s.Text)) { this.TbxCurrentPage = 1; this._searchByRelevantNameOffset = 0; Utility.getRelevantItems(StaticResources.SelectedShopLogin, s.Text, 0, this._searchByRelevantNameOffset, new AsyncCallback(_getShopItemsCallback), this._sortBy == "pop" ? "relevancy" : this._sortBy, this._sortOrder); this._currentSearch = 2; this.isWarningTbxProductNameShown = Visibility.Collapsed; } else { this.isWarningTbxProductNameShown = Visibility.Visible; } }); }
public StartPageViewModel() { if (ApplicationData.Current.LocalSettings.Values["SelectedShopeeServerIndex"] != null) { this.SelectedShopeeServerIndex = (int)ApplicationData.Current.LocalSettings.Values["SelectedShopeeServerIndex"]; } this.GrCheckingConnectionTag = "Visible"; this.ConnectionStatus = "Checking your connection"; new Thread(async() => { while (!await this._checkingNetworkConnection()) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { this.ConnectionStatus = "Connection error! Please checking your network again"; }); Thread.Sleep(10000); } await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { this.GrCheckingConnectionTag = "Collapsed"; this.GrWelcomeTag = "Visible"; this.WvStartPageSource = new Uri("http://18.221.114.122:8000/selltools/HDSD_ShopeeUp.htm"); }); }).Start(); ListShopeeServer = PickupStaticEntity.getShopeeServer(); WvStartPageNavigated = new DelegateCommand(() => { this.GrWelcomeTag = "Collapsed"; }); BtStartPageTapped = new DelegateCommand <ShopeeServer>((s) => { if (this.SelectedShopeeServerIndex == 0) { StaticResources.choosingLanguage = StaticResources.Vietnamese; } else { StaticResources.choosingLanguage = StaticResources.English; } switch (s.ShortRegion) { case "VN": this._dimensionConfigFileName = "/DimensionConfig.json"; this._logisticsChannelsFileName = "/LogisticsConfig.json"; break; case "SG": this._dimensionConfigFileName = "/DimensionConfigSG.json"; this._logisticsChannelsFileName = "/LogisticsConfigSG.json"; break; case "MA": this._dimensionConfigFileName = "/DimensionConfigMA.json"; this._logisticsChannelsFileName = "/LogisticsConfigMA.json"; break; case "ID": this._dimensionConfigFileName = "/DimensionConfigID.json"; this._logisticsChannelsFileName = "/LogisticsConfigID.json"; break; case "PH": this._dimensionConfigFileName = "/DimensionConfigPH.json"; this._logisticsChannelsFileName = "/LogisticsConfigPH.json"; break; default: break; } StaticResources.MainUri = s.UriSet.MainUri; StaticResources.SellerMainUri = s.UriSet.SellerMainUri; StaticResources.HostUri = s.UriSet.HostUri; StaticResources.SellerHostUri = s.UriSet.SellerHostUri; StaticResources.ReferUri = s.UriSet.ReferUri; StaticResources.SellerReferUri = s.UriSet.SellerReferUri; StaticResources.OriginUri = s.UriSet.OriginUri; StaticResources.SellerOriginUri = s.UriSet.SellerOriginUri; StaticResources.ImgServer = s.UriSet.ImgServer; StaticResources.ShortRegion = s.ShortRegion; StaticResources.Currency = s.Currency; StaticResources.ChatUri = s.UriSet.ChatUri; StaticResources.SaleUri = s.UriSet.SaleUri; StaticResources.ShopConfigUri = s.UriSet.ShopConfigUri; StaticResources.lstShopInfoLogin = new ObservableCollection <ShopInfoLogin>(StaticResources.TotalSellerAccount.Where(p => p.ShortRegion == s.ShortRegion)); foreach (var shop in StaticResources.lstShopInfoLogin) { StaticResources.DictGuid[shop.Shop.id] = Guid.NewGuid().ToString(); } try { var path = ApplicationData.Current.LocalFolder.Path; using (var jsonReader = new StreamReader(path + this._dimensionConfigFileName)) { StaticResources.ShopeePreConfig = Newtonsoft.Json.JsonConvert.DeserializeObject <ShopeePreConfig>(jsonReader.ReadToEnd()); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } try { var path = ApplicationData.Current.LocalFolder.Path; using (var jsonReader = new StreamReader(path + this._logisticsChannelsFileName)) { StaticResources.LogisticsChannel = Newtonsoft.Json.JsonConvert.DeserializeObject <ObservableCollection <LogisticsChannelClone> >(jsonReader.ReadToEnd()); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } if (this._frStartPage != null) { this._frStartPage.Navigate(typeof(MainPage), null, new DrillInNavigationTransitionInfo()); //this._frStartPage.Navigate(typeof(ShopeeNewItemPage), null, new DrillInNavigationTransitionInfo()); } ApplicationData.Current.LocalSettings.Values["SelectedShopeeServerIndex"] = this.SelectedShopeeServerIndex; }); FrStartPageLoaded = new DelegateCommand <Frame>((s) => { if (s != null) { this._frStartPage = s; } }); }
public MainPageViewModel() { this.TbxVersion = "2.1.7.0"; this.CbxPlaceholder = StaticResources.choosingLanguage.MainPageChooseAShop; this.TbxMessage = StaticResources.choosingLanguage.MainPageMessageCount; this.TbxOrder = StaticResources.choosingLanguage.MainPageOrderCount; foreach (var shop in StaticResources.lstShopInfoLogin) { if (string.IsNullOrEmpty(shop.token)) { shop.token = Utility.GetTokenFromGuid(shop); } } _getMetaDataTimer = new Timer(async(state) => { foreach (var shop in StaticResources.lstShopInfoLogin) { if (shop.ShopStatus.Contains("Out") == false) { if (string.IsNullOrEmpty(shop.token)) { shop.token = Utility.GetTokenFromGuid(shop); } Utility.SyncMessage(shop, shop.token); await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { shop.NewMessageCount = await Utility.GetMessageCount(shop); shop.NewOrderCount = await Utility.GetNewOrderCount(shop); }); } } }, null, (int)TimeSpan.FromSeconds(5).TotalMilliseconds, (int)TimeSpan.FromMinutes(5).TotalMilliseconds); this._checkingSellerAccount(); StaticResources.GlobalPropertyChanged += (s, e) => { switch (e.PropertyName) { case "SelectedShopLogin": if (this.SelectedShop != StaticResources.SelectedShopLogin) { this.SelectedShop = StaticResources.SelectedShopLogin; } break; default: break; } }; StaticResources.EvJumpToLoginPage += (s, e) => { this.SelectedMainFeatureIndex = -1; this.SelectedMainFeature = null; this.SelectedSettingFeatureIndex = 0; this.SelectedSettingFeature = ListMainManagement[0]; StaticResources.isLoginPage = false; }; this.HadShopInValid += async(s, e) => { await new MessageDialog(StaticResources.choosingLanguage.GlobalWarningValid).ShowAsync(); if (this._navFrame != null) { this._navFrame.Navigate(typeof(ShopeeLoginPage), null, new DrillInNavigationTransitionInfo()); } }; ListMainFeatures = PickupStaticEntity.GetMainFeatures(); ListMainManagement = PickupStaticEntity.GetMainManagement(); ListShop = StaticResources.lstShopInfoLogin; this.SelectedSettingFeatureIndex = null; this.SelectedSettingFeature = null; if (StaticResources.lstShopInfoLogin == null) { StaticResources.lstShopInfoLogin = new ObservableCollection <ShopInfoLogin>(); } BtHamburgerTapped = new DelegateCommand <SplitView>((s) => { _spView = s; s.IsPaneOpen = !s.IsPaneOpen; }); NavigationFrameLoaded = new DelegateCommand <Frame>((s) => { _navFrame = s; StaticResources.NavigationFrame = s; this.SelectedShop = StaticResources.SelectedShopLogin; }); }