Ejemplo n.º 1
0
        private async Task SearchData(string sw, synincParams incp, synsetsfilter f, syndictParams dp)
        {
            var w = await db.searchWord(f, sw);

            if (w != null)
            {
                incp.currentPage = w.wordsPageNumber;
                incp.idset       = w.id_set;
                incp.wid         = w.id;
                dp.entry         = await db.getEntry(incp.idset);

                dp.w     = dp.entry != null ? (from c in dp.entry._wlist where c.id == incp.wid select c.word).FirstOrDefault() : "";
                dp.count = w.CountOfWords;
                int count_plus = dp.count % 100;
                dp.maxpage = count_plus > 0 ? (dp.count / 100) + 1 : (dp.count / 100);
                if (dp.incp.currentPage >= dp.maxpage)
                {
                    dp.incp.currentPage = dp.maxpage - 1;
                }
                if (dp.incp.currentPage < 0)
                {
                    dp.incp.currentPage = 0;
                }
            }
            else
            {
                incp.currentPage    = 0;
                incp.wid            = 0;
                dp.entry            = null;
                dp.count            = 0;
                dp.maxpage          = 0;
                dp.incp.currentPage = 0;
            }
        }
Ejemplo n.º 2
0
        private async Task <syndictParams> prepaireData(synincParams incp, synsetsfilter f)
        {
            syndictParams dp = new syndictParams()
            {
                incp = incp, f = f, id_lang = db.lid.id_lang
            };

            if (incp.idset != 0)
            {
                dp.entry = await db.getEntry(incp.idset);

                dp.w     = dp.entry != null ? (from c in dp.entry._wlist where c.id == incp.wid select c.word).FirstOrDefault() : ""; //await db.getWord(incp.wid);
                dp.count = await db.CountWords(f);

                int count_plus = dp.count % 100;
                dp.maxpage = count_plus > 0 ? (dp.count / 100) + 1 : (dp.count / 100);
                if (dp.incp.currentPage >= dp.maxpage)
                {
                    dp.incp.currentPage = dp.maxpage - 1;
                }
                if (dp.incp.currentPage < 0)
                {
                    dp.incp.currentPage = 0;
                }
            }
            else
            {
                await SearchData(string.Empty, incp, f, dp);
            }
            return(dp);
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> SearchWord(synincParams incp, synsetsfilter f, int count, int maxpage)
        {
            try
            {
                var dps = new syndictParams()
                {
                    incp = incp, f = f, id_lang = db.lid.id_lang
                };
                dps.count   = count;
                dps.maxpage = maxpage;
                dps.entry   = await db.getEntry(incp.idset);

                dps.w      = dps.entry != null ? (from c in dps.entry._wlist where c.id == incp.wid select c.word).FirstOrDefault() : "";
                ViewBag.dp = new dictParams()
                {
                    syn = dps, vtype = viewtype.synsets
                };
                return(View("Index", dps));
            }
            catch (Exception ex)
            {
                ApplicationLogging.CreateLogger <synsetsController>().LogError(new EventId(0), ex, ex.Message);
                return(BadRequest("Зверніться до розробника"));
            }
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> SearchWord(synincParams incp, synsetsfilter f, int count, int maxpage)
        {
            var dps = new syndictParams()
            {
                incp = incp, f = f, id_lang = db.lid.id_lang
            };

            dps.count   = count;
            dps.maxpage = maxpage;
            dps.entry   = await db.getEntry(incp.idset);

            if (dps.entry != null)
            {
                dps.w = (from c in dps.entry._wlist where c.id == incp.wid select c.word).FirstOrDefault();
            }
            else
            {
                dps.w = "";
            }
            ViewBag.dp = new dictParams()
            {
                syn = dps, vtype = viewtype.synsets
            };
            return(View("Index", dps));
        }
Ejemplo n.º 5
0
        public async Task <IViewComponentResult> InvokeAsync(syndictParams dp)
        {
            try
            {
                dp.page = await db.getPage(dp.f, dp.incp.currentPage, 100);

                return(View("wordsListSynsets", dp));
            }
            catch (Exception ex)
            {
                ApplicationLogging.CreateLogger <wordsListSynsets>().LogError(new EventId(0), ex, ex.Message);
                throw new Exception("Помилка БД. Зверніться до розробника");
            }
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Search(synincParams incp, synsetsfilter f)
        {
            var dps = new syndictParams()
            {
                f = f, incp = incp
            };

            await SearchData(incp.wordSearch, incp, f, dps);

            ViewBag.dp = new dictParams()
            {
                syn = dps, vtype = viewtype.synsets
            };
            return(Redirect(Url.Action("SearchWord", "synsets",
                                       new { wid = incp.wid, isStrFiltering = f.isStrFiltering, str = f.str, ispofs = f.ispofs, pofs = f.pofs, currentPage = incp.currentPage, wordSearch = incp.wordSearch, idset = incp.idset, count = dps.count, maxpage = dps.maxpage }, null, null, $"wid-{incp.wid}")));
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> Search(synincParams incp, synsetsfilter f)
        {
            try
            {
                var dps = new syndictParams()
                {
                    f = f, incp = incp
                };
                await SearchData(incp.wordSearch, incp, f, dps);

                ViewBag.dp = new dictParams()
                {
                    syn = dps, vtype = viewtype.synsets
                };
                return(Redirect(Url.Action("SearchWord", "synsets",
                                           new { wid = incp.wid, isStrFiltering = f.isStrFiltering, str = f.str, ispofs = f.ispofs, pofs = f.pofs, currentPage = incp.currentPage, wordSearch = incp.wordSearch, idset = incp.idset, count = dps.count, maxpage = dps.maxpage }, null, null, $"wid-{incp.wid}")));
            }
            catch (Exception ex)
            {
                ApplicationLogging.CreateLogger <synsetsController>().LogError(new EventId(0), ex, ex.Message);
                return(BadRequest("Зверніться до розробника"));
            }
        }
Ejemplo n.º 8
0
        public async Task <IViewComponentResult> InvokeAsync(syndictParams dp)
        {
            dp.page = await db.getPage(dp.f, dp.incp.currentPage, 100);

            return(View("wordsListSynsets", dp));
        }