コード例 #1
0
 public Lookup(byte *tableStart, byte *stringStart, byte *stringStop, LookupTypes type)
 {
     _TableStart   = tableStart;
     _StringStart  = stringStart;
     _StringLength = stringStop == null ? 0 : (uint)(stringStop - stringStart);
     _Type         = type;
 }
コード例 #2
0
        static Lookup GetLookup(byte *destination, int available, LookupTypes lookupType, KeyValuePair <ulong, string>[] values)
        {
            Lookup?maybeLookup = null;

            switch (lookupType)
            {
            case LookupTypes.Indexed:
                maybeLookup = GenerateIndexedLookup(values, destination, available);
                break;

            case LookupTypes.Sorted:
                maybeLookup = GenerateSortedLookup(values, destination, available);
                break;

            case LookupTypes.Verbose:
                maybeLookup = GenerateVerboseLookup(values, destination, available);
                break;

            case LookupTypes.Numeric:
                return(new Lookup(null, null, null, LookupTypes.Numeric));
            }

            return(maybeLookup.HasValue ?
                   maybeLookup.GetValueOrDefault() :
                   new Lookup(null, null, null, LookupTypes.Unsupported));
        }
コード例 #3
0
        public DatabaseLookupMessage(
            I2PIdentHash key,
            I2PIdentHash from,
            LookupTypes flags,
            IEnumerable <I2PIdentHash> excludelist)
        {
            var excludecount = excludelist == null ? 0 : excludelist.Count();

            AllocateBuffer(2 * 32 + 1 + 2 + 32 * excludecount);
            var writer = new BufRefLen(Payload);

            writer.Write(key.Hash);
            writer.Write(from.Hash);
            writer.Write8((byte)((byte)flags & ~0x01));

            if (excludecount > 0)
            {
                writer.WriteFlip16((ushort)excludecount);
                foreach (var addr in excludelist)
                {
                    writer.Write(addr.Hash);
                }
            }
            else
            {
                writer.Write16(0);
            }

            //dest.Add( 0 ); // Tags
        }
コード例 #4
0
        void UpdateCachedFields(BufRef reader)
        {
            CachedKey        = new I2PIdentHash(reader);
            CachedFrom       = new I2PIdentHash(reader);
            CachedLookupType = (LookupTypes)reader.Read8();
            if (((byte)CachedLookupType & 0x01) != 0)
            {
                CachedTunnelId = new I2PTunnelId(reader);
            }

            var excludecount = reader.ReadFlip16();

            for (int i = 0; i < excludecount; ++i)
            {
                CachedExcludeList.Add(new DatabaseSearchReplyMessage(reader));
            }

            if (((byte)CachedLookupType & 0x02) != 0)
            {
                CachedReplyKey = new I2PSessionKey(reader);

                var tagcount = reader.Read8();
                CachedTags.Add(new I2PSessionTag(reader));
            }
        }
コード例 #5
0
        public DatabaseLookupMessage(I2PIdentHash key, I2PIdentHash from, LookupTypes flags)
        {
            AllocateBuffer(2 * 32 + 1 + 2);
            var writer = new BufRefLen(Payload);

            writer.Write(key.Hash);
            writer.Write(from.Hash);
            writer.Write8((byte)((byte)flags & ~(byte)LookupTypes.Tunnel));
            writer.Write16(0);
        }
コード例 #6
0
        /* public IList<LkpLookup> GetByListType(IList<int> data)
         * {
         *
         *   var list = new List<LkpLookup>();
         *  // var result = _mapper.Map<List<LkpLookupVw>>(list);
         *
         *   foreach (var item in data)
         *   {
         *        list.AddRange( _lkpLookupRepo.GetAllWhere(x=>x.TypeId==item));
         *   }
         *
         *  // var vw = await _lkpLookupRepo.GetAllWhereAsync(p => p.TypeId == id);
         *  // var result = _mapper.Map<List<LkpLookupVw>>(vw);
         *
         *   return list;
         * }*/

        public async Task <IEnumerable <LkpLookupVw> > GetByListType(LookupTypes id)
        {
            // IEnumerable<Lookup> list = await _unitOfWork.LookupsRepository.GetListByTypeAsync(id);

            // List<LookupViewModel> listVM = _mapper.Map<List<LookupViewModel>>(list);

            var vw     = _lkpLookupRepo.GetListByType(id);
            var result = _mapper.Map <Task <IEnumerable <LkpLookupVw> > >(vw);

            return(await result);
        }
コード例 #7
0
 public async Task <IEnumerable <LkpLookup> > GetListByType(LookupTypes id)
 {
     return(_db.LkpLookups.Where(x => x.TypeId == (int)id).Select(v => new LkpLookup
     {
         Id = v.Id,
         AName = v.AName,
         LName = v.LName,
         ParentId = v.ParentId,
         DefaultValue = v.DefaultValue,
         TypeId = v.TypeId,
         Value = v.Value
     }).ToList());
 }
コード例 #8
0
ファイル: LookupSource.cs プロジェクト: jb3622/Jalapeno
        private DataTable GetData(LookupTypes lookupType, string whereClause = "")
        {
            var table = new DataTable();
            if (_factory.OpenConnection())
                try
                {
                    var info = GetInfo(lookupType);
                    if (info != null)
                        table = _factory.CreateTable(info.Sql.Replace("<whereClause>", whereClause));

                }
                catch (Exception ex)
                {
                    ExceptionHandler.RaiseException(ex, "GetData: " + lookupType.ToString());
                }
            return table;
        }
コード例 #9
0
ファイル: LookupSource.cs プロジェクト: jb3622/Jalapeno
        /// <summary>
        /// Get a list of lookup items for the lookuptype
        /// </summary>
        /// <param name="lookupType"></param>
        /// <param name="whereClause"></param>
        /// <returns></returns>
        public List<LookupItem> GetItems(LookupTypes lookupType, string whereClause = "")
        {
            var items = new List<LookupItem>();
            var info = this.GetInfo(lookupType);

            // Must clear the cache if the user has logged off and logged on again with a different Id.
            if (_userId == string.Empty)
                _userId = Session.User.NetworkId.ToUpper();
            else if (_userId != Session.User.NetworkId.ToUpper())
            {
                ClearCache();
                _userId = Session.User.NetworkId.ToUpper();
            }

            // Get values from cache?
            if (whereClause == string.Empty && info.CacheAllowed && _cache.ContainsKey(lookupType))
                _cache.TryGetValue(lookupType, out items);

            // No items in the cache so get from?
            if (items.Count == 0)
            {
                var data = GetData(lookupType, whereClause);
                if (data != null && data.Rows.Count > 0)
                    foreach (DataRow row in data.Rows)
                        items.Add(new LookupItem(row.ItemArray[0], row[1].ToString()));

                if (info.CacheAllowed)
                    _cache.Add(lookupType, items);
            }

            return items;
        }
コード例 #10
0
ファイル: LookupSource.cs プロジェクト: jb3622/Jalapeno
 public LookupSourceInfo GetInfo(LookupTypes lookupType)
 {
     LookupSourceInfo info = null;
     _lookupSourceInfo.TryGetValue(lookupType, out info);
     return info;
 }
コード例 #11
0
ファイル: LookupSource.cs プロジェクト: jb3622/Jalapeno
 public static void ClearCache(LookupTypes lookupType)
 {
     if (_cache.ContainsKey(lookupType))
         _cache.Remove(lookupType);
 }
コード例 #12
0
        public async Task <IEnumerable <LkpLookupVw> > GetByListType(LookupTypes id)
        {
            var result = await _lookupService.GetByListType(id);

            return(await _lookupService.GetByListType(id));
        }
コード例 #13
0
        public int GetLookupIdByTypeAndCode(LookupTypes lookupType, string lookupCode)
        {
            var lookupId = _lookup.GetLookupIdByTypeAndCode(lookupType, lookupCode);

            return(lookupId);
        }
コード例 #14
0
        public string GetLookupCodeById(int lookupId, LookupTypes lookupType)
        {
            var code = _lookup.GetLookupCodeById(lookupId, lookupType);

            return(code);
        }
コード例 #15
0
        public string GetLookupDescById(int lookupId, LookupTypes lookupType)
        {
            var lookupDesc = _lookup.GetLookupDescById(lookupId, lookupType);

            return(lookupDesc);
        }