public static void RemoveConfig() { var init = new Yun.ClientCache.CacheFunc(); init.DropTable(_appTableName); _appInfo = null; _yunClient = null; }
/// <summary> /// 保存城购云配置信息 /// </summary> /// <param name="key">客户KEY</param> /// <param name="secret">客户密钥</param> /// <returns></returns> public static void SaveConfig(string key, string secret) { //先更新内存中数据 _appInfo = new AppModel { AppKey = key, AppSecret = secret}; _yunClient = null; //将数据写入缓存中 var init = new Yun.ClientCache.CacheFunc(); init.DropTable(_appTableName); init.Insert(_appTableName, "id", _appInfo, null); }
public void WriteAllCache() { lock (writeLock) { if (writeRuning) return; writeRuning = true; //开单独的线程进行处理 //Task.Factory.StartNew(() => //{ var init = new Yun.ClientCache.CacheFunc(); init.DropTable(_cacheName); var archives = new List<GoodsDetail>(); int i = 1; while (true) { var d = YunClient.Instance.Execute(new GetItemsRequest { PageNum = i, PageSize = 40, NeedPromotion = true, IsDelete = 0, ItemState = 1, }).Items; if (d != null && d.Any()) { i++; foreach (var tt in d) { if (archives.All(e => tt.Id != e.Id)) { archives.Add(tt); } else { throw new Exception(); } } continue; } break; } var addItems = archives.ConvertAll(GoodsDetailInSql.ConvertGoodsInSql); if (addItems.Any()) { init.BulkInsert(_cacheName, "Id", addItems, new[] { "CategoryId", "AreaId", "IsRecommend", "ItemTitle", "MarketPrice", "OffShelfTime","OnShelfTime", "Partners", "Price", "Sales", "SaleType", "Stock", "UpdateTime","SaleType","ShopId","Recommend","CompanyId" }); } writeRuning = false; // }); } }
public void WriteAllCache() { lock (writeLock) { if(writeRuning) return; writeRuning = true; //开单独的线程进行处理 //Task.Factory.StartNew(() => //{ var init = new Yun.ClientCache.CacheFunc(); init.DropTable(_cacheName); var archives = new List<ArticleDetail>(); int i = 1; while (true) { var d = YunClient.Instance.Execute(new GetArchivesRequest { PageNum = i, PageSize = 40 }).Articles; if (d != null && d.Any()) { i++; archives.Add(d); continue; } break; } var addItems = archives.ConvertAll(ArchiveInSql.ConvertArchiveInSql); if (addItems.Any()) { init.BulkInsert(_cacheName, "Id", addItems, new[] {"TaxonomyId", "Title", "Sort", "PostDateTime", "Status", "UserId" }); } writeRuning = false; //}); } }
public void WriteAllCache() { lock (writeLock) { if (writeRuning) return; writeRuning = true; var init = new Yun.ClientCache.CacheFunc(); init.DropTable(_cacheName); var category = YunClient.Instance.Execute(new GetShopItemCategorysRequest { ShopId = 11595 }).Categorys; init.BulkInsert(_cacheName, "Id", category, new[] {"Title", "Sort", "ParentId", "Display" }); writeRuning = false; } }
public void WriteAllCache() { lock (writeLock) { if (writeRuning) return; writeRuning = true; //开单独的线程进行处理 Task.Factory.StartNew(() => { var init = new Yun.ClientCache.CacheFunc(); init.DropTable(_cacheName); var archives = new List<ShopDetail>(); int i = 1; while (true) { var d = YunClient.Instance.Execute(new SearchShopsRequest { PageNum = i, PageSize = 40 }).Shops; if (d != null && d.Any()) { i++; archives.AddRange(d); continue; } break; } var addItems = archives.ConvertAll(ShopInSql.ConvertShopInSql); if (addItems.Any()) { init.BulkInsert(_cacheName, "Id", addItems, new[] { "Id", "CategoryId", "IsOpen", "Title" }); } writeRuning = false; }); } }