예제 #1
0
        public async void init()
        {
            try
            {
                MainPage.Current.ActiveProgressRing();
                CategoryList.Clear();
                InitCategory();
                ResultList.Clear();
                string jsonResult = await LinqHelper.GetSearchData(SearchModel, "BlockQuery");

                var result = JsonConvert.DeserializeObject <JsonSearchResultTemplate <BlockEntry> >(jsonResult);
                if (result.ResultCode == (int)ResultCodeType.操作成功)
                {
                    SearchModel.TotalCount = result.Data.TotalSize;
                    SearchModel.PageIndex  = result.Data.PageIndex;
                    SearchModel.PageSize   = result.Data.PageSize;
                    result.Data.Data.ToList().ForEach(item => { ResultList.Add(item); });
                    var length = ResultList.Count > 0 ? ResultList.Max(x => x.Keywords.Length) : 0;
                    BlockEntryControl.KeywordMinWidth = length * BlockEntryControl.FontSize;
                }
                else
                {
                    await MainPage.ShowMessage(result.ResultCode);
                }
            }
            catch (Exception ex)
            {
                await MainPage.ShowErrorMessage(ex.Message);
            }
            finally
            {
                MainPage.Current.InActiveProgressRing();
            }
        }
예제 #2
0
        public async Task ExecuteLoadCategoriesAsync()
        {
            try
            {
                IsBusy = true;

                CategoryList.Clear();

                List <Category> listCat = _userSettings.GetCategoriesLocal();

                if (listCat == null)
                {
                    listCat = await _expenseTrackerService.GetCategoryListAsync();
                }

                foreach (Category cat in listCat)
                {
                    CategoryList.Add(cat.Name);
                }
            }
            catch (Exception ex)
            {
                await base.ShowErrorMessageAsync("Error getting category list : " + ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #3
0
        /// <summary>
        /// Method to Get the Product Structures(Hierachie) to fill the Category and Subcategory Combobox
        /// </summary>
        public void GetProductStructure()
        {
            if (CategoryList.Count() > 0)
            {
                CategoryList.Clear();
            }

            if (SubCategoryList.Count() > 0)
            {
                SubCategoryList.Clear();
            }

            using (var db = new DataSmartDBContext())
            {
                var structure = db.ProductStructure.ToList();

                if (structure != null)
                {
                    foreach (var d in structure)
                    {
                        CategoryList.Add(d.Category_1);
                        SubCategoryList.Add(d.Category_2);
                    }
                    CategoryList    = CategoryList.Distinct().ToList();
                    SubCategoryList = SubCategoryList.Distinct().ToList();
                }
            }
        }
 /// <summary>
 /// Database loaded message handler, load the database content
 /// </summary>
 /// <param name="obj"></param>
 void DatabaseLoadedHandler(DatabaseLoadedMessage obj)
 {
     CategoryList.Clear();
     foreach (var cat in obj.DatabaseModel.Categories.Select(x => x.Name))
     {
         CategoryList.Add(cat);
     }
 }
예제 #5
0
        public void UpdateCategories(Dictionary <string, int> categories)
        {
            CategoryList.Clear();

            foreach (KeyValuePair <string, int> entry in categories)
            {
                CategoryList.Items.Add(entry.Key, entry.Value);
            }
        }
 /// <summary>
 /// Empty all database related ressources
 /// </summary>
 /// <param name="obj"></param>
 private void DatabaseUnloadedHandler(DatabaseUnloadedMessage obj)
 {
     CategoryList.Clear();
     SelectedCategory                      = null;
     CategoryInEdition                     = null;
     originalCategoryInEdition             = null;
     NewCategoryFormVisibility             = false;
     CategoryDeletionConfimationVisibility = false;
     categoryToDelete                      = null;
 }
예제 #7
0
        public async void RefreshAsync()
        {
            while (true)
            {
                try
                {
                    using (var httpClient = new HttpClient())
                    {
                        FoodClient foodClient = new FoodClient(httpClient);
                        Task <ICollection <Food> > allFoodTask = foodClient.GetAllFoodAsync();
                        FoodList.Clear();
                        foreach (var item in await allFoodTask)
                        {
                            FoodList.Add(item);
                        }

                        CategoryClient categoryClient = new CategoryClient(httpClient);
                        Task <ICollection <Category> > allCategoryTask = categoryClient.GetAllCategoryAsync();
                        CategoryList.Clear();
                        foreach (var item in await allCategoryTask)
                        {
                            CategoryList.Add(item);
                        }

                        StorageClient storageClient = new StorageClient(httpClient);
                        Task <ICollection <Storage> > allStorageTask = storageClient.GetAllStorageAsync();
                        StorageList.Clear();
                        foreach (var item in await allStorageTask)
                        {
                            StorageList.Add(item);
                        }

                        SlotClient slotClient = new SlotClient(httpClient);
                        Task <ICollection <Slot> > allSlotTask = slotClient.GetAllSlotAsync();
                        SlotList.Clear();
                        foreach (var item in await allSlotTask)
                        {
                            SlotList.Add(item);
                        }
                    }
                    return;
                }
                catch
                {
                    Thread.Sleep(500);
                }
            }
        }
예제 #8
0
        public void Refresh()
        {
            #if DEBUG
            Console.WriteLine("Refresh()");
            #endif

            // Force reload of performance counter categories
            // (Note: Windows 7 reports categories as not existing unless they contain a counter instance)
            Assembly   assembly          = typeof(PerformanceCounterCategory).Assembly;
            Type       type              = assembly.GetType("System.Diagnostics.PerformanceCounterLib");
            MethodInfo closeAllTables    = type.GetMethod("CloseAllTables", BindingFlags.NonPublic | BindingFlags.Static);
            MethodInfo closeAllLibraries = type.GetMethod("CloseAllLibraries", BindingFlags.NonPublic | BindingFlags.Static);
            closeAllTables.Invoke(null, null);
            closeAllLibraries.Invoke(null, null);

            categories.Clear();
        }
예제 #9
0
        private async Task LoadCategoriesFromDataBase()
        {
            CategoryList.Clear();
            var CategoryModels = await _categoryService.GetCategoriesAsync(App.CurrentUserId);

            CategoryList.Add(new CategoryViewModel(
                                 -1,
                                 App.CurrentUserId,
                                 "No Category",
                                 CategoryTappedCommand
                                 ));

            if (CategoryModels != null)
            {
                foreach (var model in CategoryModels)
                {
                    CategoryList.Add(model.ToViewModel(CategoryTappedCommand));
                }
            }
        }
예제 #10
0
        public async void ExecuteLoadCategories()
        {
            try
            {
                IsBusy = true;

                CategoryList.Clear();

                List <Category> listCat = await _expenseTrackerWebApiService.GetCategoryList();

                foreach (Category cat in listCat)
                {
                    CategoryList.Add(cat.Name);
                }
            }
            catch (Exception ex)
            {
                await base.ShowErrorMessage("Cannot connect to server. " + ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #11
0
        private async void KeywordsCategoryControl_SubmitClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                KeywordsCategoryControl.ActiveProgressRing();
                #region  除多余类目
                var length = KeywordsCategoryControl.deleteIds?.Count;
                for (int i = 0; i < length; i++)
                {
                    var DeleteObject = await LinqHelper.DeleteData("BlockQueryCategory", KeywordsCategoryControl.deleteIds[i]);

                    var result = JsonConvert.DeserializeObject <JsonChangedTemplate>(DeleteObject);
                    //  string DeleteResultCode = DeleteObject.GetNamedValue("ResultCode").ToString();
                    if (result.ResultCode != (int)ResultCodeType.操作成功)
                    {
                        throw (new Exception("KeywordsCategory 删除失败" + result.Message));
                    }
                }
                #endregion
                #region Update the CategoryList exist before
                var updateList = KeywordsCategoryControl.CategoryList.Where(x => !String.IsNullOrEmpty(x.Id)).ToList();
                for (int i = 0; i < updateList.Count; i++)
                {
                    var item = updateList[i];
                    if (!String.IsNullOrEmpty(item.Id))
                    {
                        var updateResult = await LinqHelper.UpdateData("BlockQueryCategory", item);

                        var result = JsonConvert.DeserializeObject <JsonChangedTemplate>(updateResult);
                        if (result.ResultCode != (int)ResultCodeType.操作成功)
                        {
                            throw (new Exception("KeywordsCategory 更新" + result.Message));
                        }
                    }
                }
                #endregion
                #region 批量上传 新增类目
                var newlist = KeywordsCategoryControl.CategoryList.Where(x => String.IsNullOrEmpty(x.Id));
                if (newlist != null && newlist.Count() > 0)
                {
                    var jsonArray  = JsonConvert.SerializeObject(newlist);
                    var jsonResult = await LinqHelper.SaveBatchData(jsonArray, "BlockQueryCategory");

                    var result = JsonConvert.DeserializeObject <JsonChangedTemplate>(jsonResult);
                    await MainPage.ShowMessage(result.ResultCode);
                }
                #endregion

                CategoryList.Clear();
                InitCategory();
                KeywordsCategoryControl.Dispose();
            }
            catch (Exception ex)
            {
                await MainPage.ShowErrorMessage(ex.Message);
            }
            finally
            {
                KeywordsCategoryControl.InActiveProgressRing();
            }
        }