Esempio n. 1
0
        private void edit_dic_word(HttpContext context)
        {
            //检查权限
            if (!new BLL.manager_role().Exists(adminInfo.role_id, "lucene_pangu", DTEnums.ActionEnum.Edit.ToString()))
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"您没有操作权限!\"}");
                return;
            }

            int    pos       = DTRequest.GetFormInt("p");
            int    frequency = DTRequest.GetFormInt("f");
            string key       = DTRequest.GetFormString("k");

            if (string.IsNullOrEmpty(key))
            {
                context.Response.Write("{\"status\":0 ,\"msg\":\"关键词不能为空!\"}");
                return;
            }
            PanguHelper dic = new PanguHelper();

            if (dic.UpdateWord(key, (double)frequency, pos))
            {
                dic.Save(DateTime.Now.ToString("yyMMddhh"));
                context.Response.Write("{\"status\":1 ,\"msg\":\"修改成功!\"}");
                return;
            }
            context.Response.Write("{\"status\":0 ,\"msg\":\"修改失败!\"}");
        }
Esempio n. 2
0
        private void del_dic_word(HttpContext context)
        {
            //检查权限
            if (!new BLL.manager_role().Exists(adminInfo.role_id, "lucene_pangu", DTEnums.ActionEnum.Delete.ToString()))
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"您没有操作权限!\"}");
                return;
            }

            string key = DTRequest.GetFormString("k");

            if (string.IsNullOrEmpty(key))
            {
                context.Response.Write("{\"status\":0 ,\"msg\":\"关键词不能为空!\"}");
                return;
            }
            PanguHelper dic = new PanguHelper();

            if (dic.DeleteWord(key))
            {
                dic.Save(DateTime.Now.ToString("yyMMddhh"));
                context.Response.Write("{\"status\":1 ,\"msg\":\"删除成功!\"}");
            }
            else
            {
                context.Response.Write("{\"status\":0 ,\"msg\":\"删除失败!\"}");
            }
        }
Esempio n. 3
0
        private void add_dic_word_all(HttpContext context)
        {
            //检查权限
            if (!new BLL.manager_role().Exists(adminInfo.role_id, "lucene_pangu", DTEnums.ActionEnum.Add.ToString()))
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"您没有操作权限!\"}");
                return;
            }

            int    pos       = DTRequest.GetFormInt("p");
            int    frequency = DTRequest.GetFormInt("f");
            string key       = DTRequest.GetFormString("k");

            int sucCount   = 0;
            int errorCount = 0;

            if (string.IsNullOrEmpty(key))
            {
                context.Response.Write("{\"status\":0 ,\"msg\":\"关键词不能为空!\"}");
                return;
            }

            key = Regex.Replace(key, @"\W+", ",");
            string[]    valArr = key.Split(',');
            PanguHelper dic    = new PanguHelper();

            if (valArr.Length > 0)
            {
                foreach (string k in valArr)
                {
                    if (dic.InsertWord(k, (double)frequency, pos))
                    {
                        sucCount++;
                    }
                    else
                    {
                        errorCount++;
                    }
                }
                dic.Save(DateTime.Now.ToString("yyMMddhh"));
                context.Response.Write("{\"status\":1 ,\"msg\":\"" + string.Format("添加成功{0}条,失败{1}条!", sucCount, errorCount) + "\"}");
                return;
            }
            context.Response.Write("{\"status\":0 ,\"msg\":\"添加失败!\"}");
        }