using System; using System.Collections.Generic; using System.Linq; using System.Text; using Foresight.Cache; using Foresight.Fleet.Services.SystemOption; using Foresight.Fleet.Services; using Foresight.Fleet.Services.Customer; namespace IronIntel.Contractor { public static class CacheManager { private static string CacheRegion { get { return "FLEET_" + SystemParams.CompanyID.ToUpper(); } } public static void Remove(string key) { var client = FleetServiceClientHelper.CreateClient(); try { client.RemoveCache(CacheRegion, key); } catch { } } public static void SetValue(string key, byte[] buffer, TimeSpan expire) { var client = FleetServiceClientHelper.CreateClient(); try { client.SetCache(CacheRegion, key, buffer, (int)expire.TotalSeconds); } catch { } } public static byte[] GetValue(string key) { try { var client = FleetServiceClientHelper.CreateClient(); return client.GetCache(CacheRegion, key); } catch { return null; } } public static void RemoveCustomerCache(string key) { var client = FleetServiceClientHelper.CreateClient(); try { client.RemoveCustomerCacheData(SystemParams.CompanyID, key); } catch { } } public static void SetCustomerCacheData(string key, byte[] buffer, TimeSpan expire) { var client = FleetServiceClientHelper.CreateClient(); try { client.SetCustomerCacheData(SystemParams.CompanyID, key, buffer); } catch { } } public static byte[] GetCustomerCacheData(string key) { try { var client = FleetServiceClientHelper.CreateClient(); return client.GetCustomerCacheData(SystemParams.CompanyID, key); } catch { return null; } } } }