Ejemplo n.º 1
0
 public async Task <wlist[]> getPage(synsetsfilter f, int start, int pageSize)
 {
     try
     {
         var q = (from c in db.wlist.AsNoTracking() select c);
         q = setWordListQueryFilter(f, q);
         q = q.OrderBy(c => c.digit).ThenBy(c => c.homonym).Skip(start * pageSize).Take(pageSize);
         return(await q.ToArrayAsync());
     }
     catch (Exception ex)
     {
         if (Logger != null)
         {
             Logger.LogError(new EventId(0), ex, ex.Message);
             return(null);
         }
         else
         {
             throw ex;
         }
     }
     finally
     {
     }
 }
Ejemplo n.º 2
0
        public async Task <wlist_base> searchWord(synsetsfilter f, string word)
        {
            //System.Runtime.CompilerServices.StrongBox <T>
            try
            {
                string w     = sharedTypes.atod(word, talpha);
                int    start = 0;
                var    q     = (from c in db.wlist select c);

                q = setWordListQueryFilter(f, q);

                q     = q.OrderBy(c => c.digit).ThenBy(c => c.homonym);
                start = await(from c in q where w.CompareTo(c.digit) > 0 select c).CountAsync();

                int pagenumber = start / 100;
                int count      = q.Count();

                if (count <= start)
                {
                    q = q.Skip((start - 1)).Take(1);
                }
                else
                {
                    q = q.Skip(start).Take(1);
                }
                wlist wp = await q.FirstOrDefaultAsync();

                wlist_base r = null;
                if (wp != null)
                {
                    r = (new wlist_base()
                    {
                        CountOfWords = count, wordsPageNumber = pagenumber, id = wp.id, comm = wp.comm, digit = wp.digit, homonym = wp.homonym, hyperonym = wp.hyperonym, id_hyp = wp.id_hyp, id_int = wp.id_int, id_phon = wp.id_phon, id_r = wp.id_r, id_set = wp.id_set, id_syn = wp.id_syn, inactive = wp.inactive, interpretation = wp.interpretation, intsum = wp.intsum, userid = wp.userid, nom = wp.nom, sign = wp.sign, sword = wp.sword, timemarker = wp.timemarker, word = wp.word
                    });
                }
                return(r);
            }
            catch (Exception ex)
            {
                if (Logger != null)
                {
                    Logger.LogError(new EventId(0), ex, ex.Message);
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
Ejemplo n.º 3
0
 private IQueryable <wlist> setWordListQueryFilter(synsetsfilter f, IQueryable <wlist> q)
 {
     try
     {
         if ((f.isStrFiltering) && (!string.IsNullOrEmpty(f.str)))
         {
             string s = sharedTypes.atod(f.str, talpha);
             //switch (f.fetchType)
             //{
             //    case FetchType.StartsWith:
             //        q = q.Where(c => c.digit.StartsWith(s));
             //        //q = q.Where(c => c.reestr.Replace("\"","").StartsWith(f.str));
             //        break;
             //    case FetchType.EndsWith:
             //        q = q.Where(c => c.digit.EndsWith(s));
             //        //q = q.Where(c => c.reestr.Replace("\"", "").EndsWith(f.str));
             //        break;
             //    case FetchType.Contains:
             //        q = q.Where(c => c.digit.Contains(s));
             //        //q = q.Where(c => c.reestr.Replace("\"", "").Contains(f.str));
             //        break;
             //}
             q = q.Where(c => EF.Functions.Like(c.digit, s));
         }
         if (f.ispofs)
         {
             q = (from c in q join ss in db.synsets on c.id_set equals ss.id where ss.pofs == f.pofs select c);
         }
         return(q);
     }
     catch (Exception ex)
     {
         if (Logger != null)
         {
             Logger.LogError(new EventId(0), ex, ex.Message);
             return(null);
         }
         else
         {
             throw ex;
         }
     }
 }
Ejemplo n.º 4
0
 public async Task <int> CountWords(synsetsfilter f)
 {
     try
     {
         var q = (from c in db.wlist select c);
         q = setWordListQueryFilter(f, q);
         return(await q.CountAsync());
     }
     catch (Exception ex)
     {
         if (Logger != null)
         {
             Logger.LogError(new EventId(0), ex, ex.Message);
             return(-1);
         }
         else
         {
             throw ex;
         }
     }
 }