/// <summary> /// 获取一个token /// </summary> /// <param name="token"></param> /// <returns></returns> public UserDTO GetUserByToken(string token) { if (string.IsNullOrEmpty(token)) { return(null); } CacheFilter cacheFilter = new CacheFilter() { Key = token }; var tokenResult = _cache.Query <TokenDTO>(cacheFilter); if (tokenResult == null) { return(null); } string userId = tokenResult.UserId; UserFilter filter = new UserFilter() { Id = userId }; var user = _userRepository.GetUser(filter); var result = new UserDTO(); result.Convert(user); return(result); }
/// <summary> /// 获取系统的所有storages /// </summary> /// <returns></returns> private static List <StorageDAO> GetStorages() { var cacheFilter = new CacheFilter(_storageCacheKey); var cacheClient = new RedisClientCache(); List <StorageDAO> storages = cacheClient.Query <List <StorageDAO> >(cacheFilter); if (storages == null || storages.Count == 0) { string sql = "select * from t_sys_storage where misdelete=0 order by mitemid"; string connectionString = ConfigurationManager.AppSetting("ConnectionString"); IORM _orm = new SugarORM(connectionString); var client = _orm.GetSqlClient <SqlSugarClient>(); storages = client.SqlQueryable <StorageDAO>(sql).ToList(); CacheModel storageCache = new CacheModel() { Key = _storageCacheKey, Data = storages }; if (cacheClient.IsExistCacheKey(cacheFilter)) { cacheClient.Delete(cacheFilter); } cacheClient.Add(storageCache); } return(storages); }
public EthRpcMethod(string method, RpcMethodType rpcMethodType, RpcCacheStrategy rpcCacheStrategy, int cacheOption, ParamToString paramDelegate = null, CacheFilter filter = null) { Method = method; RpcMethodType = rpcMethodType; RpcCacheStrategy = rpcCacheStrategy; CacheOption = cacheOption; ParamDelegate = paramDelegate; FilterDelegate = filter; }
public bool Delete(CacheFilter filter) { if (!RedisHelper.Exists(filter.Key)) { return(false); } long deleteRowCount = RedisHelper.Del(filter.Key); return(deleteRowCount > 0); }
public List <T> Filtrate(CacheFilter <T> filter, out int totalCount) { LogStopwatch watch = new LogStopwatch(this.GetType().Name + ".Filtrate", ""); watch.Start(); try { return(filter.Filtrate(this.CacheList, out totalCount)); } finally { watch.Stop(); } }
/// <summary> /// 查询缓存 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="filter"></param> /// <returns></returns> public T Query <T>(CacheFilter filter) { if (!RedisHelper.Exists(filter.Key)) { return(default(T)); } string data = RedisHelper.Get <string>(filter.Key); if (string.IsNullOrWhiteSpace(data)) { return(default(T)); } return(JsonConvert.DeserializeObject <T>(data)); }
/// <summary> /// Constructor /// </summary> /// <param name="items">Collection of checked filters in the associated TabPage</param> /// <param name="fltForPlaceholder">Filter to use if placeholder is found in collection</param> public ChainedFiltersOR(CheckedListBox.CheckedItemCollection items, CacheFilter fltForPlaceholder) { if ((items != null) && (items.Count != 0)) { filters = new CacheFilter[items.Count]; int i = 0; foreach (object obj in items) { filters[i] = obj as CacheFilter; if (filters[i]._bToIgnore && (fltForPlaceholder != null)) { filters[i] = fltForPlaceholder; } i++; } } }
public List <T> Filtrate(CacheFilter <T> filter) { this.EnableValidate(); LogStopwatch watch = new LogStopwatch(this.GetType().Name + ".Filtrate", ""); watch.Start(); this.Lock.AcquireReaderLock(10000); try { return(filter.Filtrate(this._cacheList)); } finally { this.Lock.ReleaseReaderLock(); watch.Stop(); } }
/// <summary> /// 校验token /// </summary> /// <param name="token"></param> /// <returns></returns> public OperationResult ValidateToken(string token) { OperationResult result = new OperationResult(); if (string.IsNullOrEmpty(token)) { return(result); } CacheFilter filter = new CacheFilter() { Key = token }; var tokenCache = _cache.Query <TokenDTO>(filter); //没有找到token或者token的过期日期小于当前日期加一个小时 if (tokenCache == null || tokenCache.ExpireDateTime < DateTime.Now) { return(result); } tokenCache.ExpireDateTime = DateTime.Now.AddHours(1); CacheModel model = new CacheModel() { Key = tokenCache.Token, Data = tokenCache }; //更新一下token的过期时间 _cache.Update(model); result.Success = true; result.Data = tokenCache; return(result); }
/// <summary> /// 释放存在缓存键值 /// </summary> /// <param name="filter"></param> /// <returns></returns> public bool IsExistCacheKey(CacheFilter filter) { return(RedisHelper.Exists(filter.Key)); }
void ICache.Delete(CacheFilter filter) { throw new NotImplementedException(); }
//======================= // Render //======================= /// <summary>Renders the individual <see cref="Filter"/> property</summary> /// <param name="tPosition">Inspector position and size of <paramref name="tProperty"/></param> /// <param name="tProperty">Serialized <see cref="Filter"/> property</param> /// <param name="tLabel">GUI Label of the drawer</param> public override void OnGUI(Rect tPosition, SerializedProperty tProperty, GUIContent tLabel) { // Properties SerializedProperty tempNamespaceProperty = tProperty.FindPropertyRelative("_typeNamespace"); SerializedProperty tempClassProperty = tProperty.FindPropertyRelative("_typeClass"); SerializedProperty tempWhiteListProperty = tProperty.FindPropertyRelative("_whiteList"); SerializedProperty tempBlackListProperty = tProperty.FindPropertyRelative("_blackList"); // Validate cache CacheFilter tempCache = cache[tProperty.propertyPath]; if (!tempCache.validateNamespace(tempNamespaceProperty, tempClassProperty)) { tempNamespaceProperty.stringValue = tempCache.namespaceName; tempClassProperty.stringValue = tempCache.className; tProperty.serializedObject.ApplyModifiedProperties(); } else if (!tempCache.validateClass(tempClassProperty)) { tempClassProperty.stringValue = tempCache.className; tProperty.serializedObject.ApplyModifiedProperties(); } // Draw tPosition.height = base.GetPropertyHeight(tProperty, tLabel); tProperty.isExpanded = EditorGUI.Foldout(tPosition, tProperty.isExpanded, isArray ? (tempNamespaceProperty.stringValue + "." + tempClassProperty.stringValue) : tProperty.displayName); if (tProperty.isExpanded) { ++EditorGUI.indentLevel; // Namespace tPosition.y += tPosition.height + EditorGUIUtility.standardVerticalSpacing; tPosition.height = EditorGUI.GetPropertyHeight(tempNamespaceProperty); EditorGUI.BeginChangeCheck(); int tempSelectedNamespace = EditorGUI.Popup(tPosition, tempNamespaceProperty.displayName, tempCache.selectedNamespace, _namespaceNames); if (EditorGUI.EndChangeCheck()) { tempCache.selectedNamespace = tempSelectedNamespace; tempNamespaceProperty.stringValue = tempCache.namespaceName; tempClassProperty.stringValue = tempCache.className; tProperty.serializedObject.ApplyModifiedProperties(); } // Classes tPosition.y += tPosition.height + EditorGUIUtility.standardVerticalSpacing; tPosition.height = EditorGUI.GetPropertyHeight(tempClassProperty); EditorGUI.BeginChangeCheck(); int tempSelectedClass = EditorGUI.Popup(tPosition, tempClassProperty.displayName, tempCache.selectedClass, tempCache.classNames); if (EditorGUI.EndChangeCheck()) { tempCache.selectedClass = tempSelectedClass; tempClassProperty.stringValue = tempCache.className; tProperty.serializedObject.ApplyModifiedProperties(); } // Lists DrawFilterList(ref tPosition, tempWhiteListProperty, tempCache); DrawFilterList(ref tPosition, tempBlackListProperty, tempCache); --EditorGUI.indentLevel; } }
/// <summary>Utility function for rendering a <see cref="Filter"/> list element</summary> /// <param name="tPosition">Inspector position and size of <paramref name="tElement"/></param> /// <param name="tElement">Serialized element property</param> /// <param name="tCache">Cached filter drop-down data</param> private static void DrawFilterListElement(ref Rect tPosition, SerializedProperty tElement, CacheFilter tCache) { // Determine member selection int tempSelectedMember = tCache.findMember(tElement.stringValue); if (tempSelectedMember < 0) { tempSelectedMember = 0; } // Dropdown tPosition.y += tPosition.height + EditorGUIUtility.standardVerticalSpacing; tPosition.height = EditorGUI.GetPropertyHeight(tElement); EditorGUI.BeginChangeCheck(); tempSelectedMember = EditorGUI.Popup(tPosition, tElement.displayName, tempSelectedMember, tCache.memberNames); if (EditorGUI.EndChangeCheck() || String.IsNullOrEmpty(tElement.stringValue)) { tElement.stringValue = tCache.members[tempSelectedMember].serializedName; tElement.serializedObject.ApplyModifiedProperties(); } }
/// <summary>Utility function for rendering a <see cref="Filter"/> list</summary> /// <param name="tPosition">Inspector position and size of <paramref name="tList"/></param> /// <param name="tList">Serialized list property</param> /// <param name="tCache">Cached filter drop-down data</param> private static void DrawFilterList(ref Rect tPosition, SerializedProperty tList, CacheFilter tCache) { tPosition.y += tPosition.height + EditorGUIUtility.standardVerticalSpacing; tPosition.height = EditorGUI.GetPropertyHeight(tList, false); tList.isExpanded = EditorGUI.Foldout(tPosition, tList.isExpanded, tList.displayName); if (tList.isExpanded) { ++EditorGUI.indentLevel; // Size tPosition.y += tPosition.height + EditorGUIUtility.standardVerticalSpacing; tPosition.height = EditorGUIUtility.singleLineHeight; int tempSize = EditorGUI.IntField(tPosition, "Size", tList.arraySize); if (tempSize < 0) { tempSize = 0; } tList.arraySize = tempSize; // Draw elements int tempListLength = tList.arraySize; for (int i = 0; i < tempListLength; ++i) { DrawFilterListElement(ref tPosition, tList.GetArrayElementAtIndex(i), tCache); } --EditorGUI.indentLevel; } }
public bool IdFGenerator() { if (_Daddy != null) { // le code du plugin est ici : // ********************************* // Efface les caches déjà existantes _Daddy._caches = new Dictionary <string, Geocache>(); // Efface les waypoints déjà existants _Daddy._waypoints = new Dictionary <String, Waypoint>(); // Charge un fichier (avec son chemin complet) _Daddy.LoadFile(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\PQ\12044886_IdFMystery1.gpx"); _Daddy.LoadFile(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\PQ\13353760_IdFMystery2.gpx"); _Daddy.JoinWptsGC(); _Daddy.PostTreatmentLoadCache(); _Daddy.BuildListViewCache(); _Daddy.PopulateListViewCache(null); // On exécute des filtres déjà sauvegardés // Pas implémentable pour l'instant, objets private bool filtres_mode_OR = true; // On récupère le résultat de chaque filtre en mode "OU" (sinon c'est "ET") List <CacheFilter> les_filtres = new List <CacheFilter>(); const String f1 = "bonus"; // Mettre le nom qu'on veut const String f2 = "final"; // Mettre le nom qu'on veut foreach (Object obj in _Daddy.cbFilterList.Items) { CacheFilter fil = (CacheFilter)(obj); switch (fil._description) { case f1: case f2: { les_filtres.Add(fil); break; } default: break; } } if (les_filtres.Count != 0) { List <EXListViewItem> forcedList = new List <EXListViewItem>(); if (filtres_mode_OR) { ChainedFiltersOR chnf = new ChainedFiltersOR(les_filtres); // Build list of caches foreach (EXListViewItem item in _Daddy._listViewCaches) // /!\ BCR : à rendre public ! { Geocache cache = _Daddy._caches[item.Text]; if (chnf.ToBeDisplayed(cache)) { forcedList.Add(item); } } } else { ChainedFiltersAND chnf = new ChainedFiltersAND(les_filtres); // Build list of caches foreach (EXListViewItem item in _Daddy._listViewCaches) { Geocache cache = _Daddy._caches[item.Text]; if (chnf.ToBeDisplayed(cache)) { forcedList.Add(item); } } } _Daddy.PopulateListViewCache(forcedList); } // On sauve le résultat _Daddy.ExportGPXBrutal(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\IdF_Bonus.gpx"); // ********************************* // Génération du Fichier GGZ IdF _Daddy.LoadFile(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\IdF_Bonus.gpx"); _Daddy.LoadZip(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\PQ\IdFMulti+.zip"); _Daddy.LoadZip(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\PQ\IdFNight.zip"); _Daddy.LoadZip(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\PQ\IdF Mystery décodé.zip"); _Daddy.LoadZip(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\PQ\IdF Mystery sur place.zip"); _Daddy.LoadFile(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\PQ\12227826_IdFTradi1.gpx"); _Daddy.LoadFile(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\PQ\12227994_IdFTradi2.gpx"); _Daddy.LoadFile(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\PQ\12228003_IdFTradi3.gpx"); _Daddy.LoadFile(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\PQ\12228015_IdFTradi4.gpx"); _Daddy.LoadFile(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\PQ\13437328_IdFTradi5.gpx"); _Daddy.JoinWptsGC(); _Daddy.PostTreatmentLoadCache(); _Daddy.BuildListViewCache(); _Daddy.PopulateListViewCache(null); _Daddy.ExportGGZ(@"F:\Documents\5- GeoCaching\MyGeocachingManager\GPX\IdF.ggz", false); return(true); } else { MessageBox.Show("Daddy is missing :-("); return(false); } }