Example #1
0
        /// <summary>
        /// 从服务器同步列表
        /// </summary>
        /// <returns></returns>
        public async Task <bool> GetLatestCates()
        {
            try
            {
                var result = await CloudService.GetCateInfoAsync();

                if (result == null)
                {
                    throw new ArgumentNullException();
                }

                var respJson  = JsonObject.Parse(result.JsonSrc);
                var isSuccess = JsonParser.GetBooleanFromJsonObj(respJson, "isSuccessed");
                if (!isSuccess)
                {
                    throw new ArgumentException();
                }

                var cateObj = JsonParser.GetStringFromJsonObj(respJson, "Cate_Info");
                var list    = GenerateList(cateObj.ToString());
                if (list == null)
                {
                    throw new ArgumentNullException();
                }

                Categories = list;
                await SerializerHelper.SerializerToJson <ObservableCollection <ToDoCategory> >(Categories, SerializerFileNames.CategoryFileName);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }