Example #1
0
        /// <summary>
        /// 数据信息工整
        /// </summary>
        public static void FixModules()
        {
            BLL.modules bmodules = new BLL.modules();
            var         list     = bmodules.GetList();

            for (int i = 0; i < list.Count; i++)
            {
                var item        = list[i];
                var itempath    = item.path;
                var itempathArr = itempath.Trim('-').Split('-');
                var pathdeep    = itempathArr.Length;

                var innerList  = bmodules.GetList().FindAll(c => c.path.IndexOf(itempath) > -1);
                var realModule = bmodules.GetList().Find(c => c.path == itempath);//绝对存在

                if (realModule != null)
                {
                    if (innerList.Count > 1)
                    {
                        realModule.stem     = 1;
                        realModule.haschild = 1;
                    }
                    else
                    {
                        realModule.stem     = 0;
                        realModule.haschild = 0;
                    }

                    bmodules.Update(realModule);
                }
            }
        }
Example #2
0
        /// <summary>
        /// 删除外键数据相关
        /// </summary>
        /// <param name="ids"></param>
        public static void FixModulesExt(string ids)
        {
            BLL.modules bmodules = new BLL.modules();
            var         arr      = ids.Split(',');

            for (int i = 0; i < arr.Length; i++)
            {
                var id     = arr[i];
                var module = bmodules.Get(Int32.Parse(id));

                if (module != null)
                {
                    var list = bmodules.GetList().FindAll(c => c.path.IndexOf(module.path) > -1);
                    for (int j = 0; j < list.Count; j++)
                    {
                        var sub = list[j];
                        bmodules.Del(sub.id);
                    }
                }
            }
        }
Example #3
0
        public void ProcessRequest(HttpContext context)
        {
            var str = "";

            if (HttpContext.Current.Session[userKey] != null)
            {
                context.Response.ContentType = "text/plain";
                var postType = context.Request.Form["module"];
                var parentid = context.Request.Form["id"];

                try
                {
                    if (postType == "modules")
                    {
                        BLL.modules bmodules = new BLL.modules();
                        var         lst      = bmodules.GetListByPage("parentid=" + parentid, " path asc", 0, 100);
                        str = "{\"code\":1,\"data\":" + JsonConvert.SerializeObject(lst) + "}";
                    }
                    else if (postType == "menus")
                    {
                        BLL.menus bmenus = new BLL.menus();
                        var       lst    = bmenus.GetListByPage("parentid=" + parentid, " path asc", 0, 100);
                        str = "{\"code\":1,\"data\":" + JsonConvert.SerializeObject(lst) + "}";
                    }
                }
                catch (System.Exception)
                {
                    str = "{\"code\":-2,\"msg\":\"位置错误\"}";
                    throw;
                }
            }
            else
            {
                str = "{\"code\":-1,\"msg\":\"权限错误\"}";
            }
            context.Response.Write(str);
        }
Example #4
0
        public void ProcessRequest(HttpContext context)
        {
            var str  = "";
            var user = (Model.users)HttpContext.Current.Session[userKey];

            BLL.logs blogs = new BLL.logs();
            if (user != null)
            {
                context.Response.ContentType = "text/plain";
                var id     = context.Request.Form["id"];//ids:2,4,6
                var tb     = context.Request.Form["model"];
                var flag   = context.Request.Form["flag"];
                var flagcn = context.Request.Form["flagcn"];
                var v      = Int32.Parse(context.Request.Form["v"]);

                if (!string.IsNullOrEmpty(id))
                {
                    if (tb == "users")
                    {
                        BLL.users   bl  = new BLL.users();
                        Model.users mod = bl.Get(Int32.Parse(id));
                        if (flag == "isadmin")
                        {
                            mod.isadmin    = v;
                            mod.modifydate = DateTime.Now;
                            bl.Update(mod);
                        }
                    }
                    else if (tb == "posts")
                    {
                        BLL.posts   bl  = new BLL.posts();
                        Model.posts mod = bl.Get(Int32.Parse(id));
                        switch (flag)
                        {
                        case "top":
                            mod.top = v;
                            break;

                        case "hot":
                            mod.hot = v;
                            break;

                        case "intro":
                            mod.intro = v;
                            break;

                        case "read":
                            mod.read = v;
                            break;

                        case "blank":
                            mod.blank = v;
                            break;

                        case "enable":
                            mod.enable = v;
                            break;
                        }
                        mod.modifydate = DateTime.Now;
                        bl.Update(mod);
                    }
                    else if (tb == "modules")
                    {
                        BLL.modules   bl  = new BLL.modules();
                        Model.modules mod = bl.Get(Int32.Parse(id));
                        switch (flag)
                        {
                        case "blank":
                            mod.blank = v;
                            break;
                        }
                        bl.Update(mod);
                    }

                    //保存日志
                    Model.logs lg = new Model.logs();
                    lg.loginfo = "表:" + tb + ",ID:" + id + "设置" + flagcn;
                    App_Code.PageBase.UserLog("修改", lg);

                    str = "{\"code\":1,\"msg\":\"" + id + "修改成功\"}";
                }
                else
                {
                    str = "{\"code\":0,\"msg\":\"ID传值错误\"}";
                }
            }
            else
            {
                str = "{\"code\":-1,\"msg\":\"权限错误\"}";
            }
            context.Response.Write(str);
        }
Example #5
0
        public void ProcessRequest(HttpContext context)
        {
            var str = "";

            if (HttpContext.Current.Session[userKey] != null)
            {
                context.Response.ContentType = "text/plain";
                var start    = int.Parse(context.Request.Form["start"]);
                var draw     = int.Parse(context.Request.Form["draw"]);
                var length   = int.Parse(context.Request.Form["length"]);
                var search   = context.Request.Form["search[value]"] ?? "";
                var postType = context.Request.QueryString["moduletype"];
                var mid      = context.Request.QueryString["id"];

                try
                {
                    if (!string.IsNullOrEmpty(search))
                    {
                        switch (postType)
                        {
                        case "msgs":
                            search = " and " + ("postby like '%" + search + "%' or content like '%" + search + "%' or ext1 like '%" + search + "%' or ext2 like '%" + search + "%'  ");
                            break;

                        case "news":
                            search = " and " + ("postby like '%" + search + "%' or title like '%" + search + "%' or keywords like '%" + search + "%' or contentview like '%" + search + "%'  ");
                            break;

                        case "cases":
                            search = " and " + ("postby like '%" + search + "%' or title like '%" + search + "%' or keywords like '%" + search + "%' or contentview like '%" + search + "%'  ");
                            break;

                        case "friendlinks":
                            search = " and " + ("keywords like '%" + search + "%' or ext1 like '%" + search + "%' or ext2 like '%" + search + "%' ");
                            break;

                        case "widgets":
                            search = " and " + ("title like '%" + search + "%' or content like '%" + search + "%' or ext2 like '%" + search + "%' ");
                            break;

                        case "users":
                            search = ("username like '%" + search + "%' or email like '%" + search + "%'   ");    //users 非posts表
                            break;

                        case "logs":
                            search = ("username like '%" + search + "%' or loginfo like '%" + search + "%'   ");    //users 非posts表
                            break;

                        case "modules":
                            search = ("(title like '%" + search + "%' or url like '%" + search + "%'   )");    //modules 非posts表
                            break;

                        case "menus":
                            search = ("(title like '%" + search + "%' or keywords like '%" + search + "%'  or linktag like '%" + search + "%'   )");    //menus 非posts表
                            break;
                        }
                    }

                    if (postType == "users")
                    {
                        BLL.users busers = new BLL.users();
                        var       cond   = search;
                        var       count  = busers.Count(cond);
                        var       lst    = busers.GetListByPage(cond, " id desc", start, length);
                        str = "{\"code\":1,\"draw\":" + draw + ",\"recordsTotal\":" + count + ",\"recordsFiltered\":" + count + ",\"data\":" + JsonConvert.SerializeObject(lst) + "}";
                    }
                    else if (postType == "logs")
                    {
                        BLL.logs blogs = new BLL.logs();
                        var      cond  = search;
                        var      count = blogs.Count(cond);
                        var      lst   = blogs.GetListByPage(cond, " id desc", start, length);
                        str = "{\"code\":1,\"draw\":" + draw + ",\"recordsTotal\":" + count + ",\"recordsFiltered\":" + count + ",\"data\":" + JsonConvert.SerializeObject(lst) + "}";
                    }
                    else if (postType == "modules")
                    {
                        BLL.modules bmodules = new BLL.modules();
                        var         cond     = (!string.IsNullOrEmpty(mid) ? (" path like '%-" + mid + "-%' ") : "") + (!string.IsNullOrEmpty(search) ? " and " + search : "");
                        var         count    = bmodules.Count(cond);
                        var         lst      = bmodules.GetListByPage(cond, " path asc", start, length);
                        str = "{\"code\":1,\"draw\":" + draw + ",\"recordsTotal\":" + count + ",\"recordsFiltered\":" + count + ",\"data\":" + JsonConvert.SerializeObject(lst) + "}";
                    }
                    else if (postType == "menus")
                    {
                        BLL.menus bmenus = new BLL.menus();
                        var       cond   = (!string.IsNullOrEmpty(mid) ? (" path like '%-" + mid + "-%' ") : "") + (!string.IsNullOrEmpty(search) ? " and " + search : "");
                        var       count  = bmenus.Count(cond);
                        var       lst    = bmenus.GetListByPage(cond, " path asc", start, length);
                        str = "{\"code\":1,\"draw\":" + draw + ",\"recordsTotal\":" + count + ",\"recordsFiltered\":" + count + ",\"data\":" + JsonConvert.SerializeObject(lst) + "}";
                    }
                    else
                    {
                        BLL.posts bposts = new BLL.posts();
                        var       cond   = "ext='" + postType + "' " + search;
                        var       count  = bposts.Count(cond);
                        var       lst    = bposts.GetListByPage(cond, (postType == "msgs" ? " read=0 and " : "") + " id desc ", start, length);
                        str = "{\"code\":1,\"draw\":" + draw + ",\"recordsTotal\":" + count + ",\"recordsFiltered\":" + count + ",\"data\":" + JsonConvert.SerializeObject(lst) + "}";
                    }
                }
                catch (System.Exception)
                {
                    str = "{\"code\":-2,\"msg\":\"位置错误\"}";
                    throw;
                }
            }
            else
            {
                str = "{\"code\":-1,\"msg\":\"权限错误\"}";
            }
            context.Response.Write(str);
        }
Example #6
0
        public void ProcessRequest(HttpContext context)
        {
            var str  = "";
            var user = (Model.users)HttpContext.Current.Session[userKey];

            BLL.logs blogs = new BLL.logs();
            if (user != null)
            {
                context.Response.ContentType = "text/plain";
                var id = context.Request.Form["id"];//ids:2,4,6
                var tb = context.Request.Form["model"];

                if (!string.IsNullOrEmpty(id))
                {
                    if (tb == "users")
                    {
                        BLL.users bl = new BLL.users();
                        bl.Del(id);
                    }
                    else if (tb == "logs")
                    {
                        BLL.logs bl = new BLL.logs();
                        bl.Del(id);
                    }
                    else if (tb == "posts")
                    {
                        BLL.posts bl = new BLL.posts();
                        bl.Del(id);
                    }
                    else if (tb == "menus")
                    {
                        BLL.menus bl = new BLL.menus();

                        //先删除删除扩展信息
                        App_Code.PageBase.FixMenusExt(id);

                        //更新扩展信息
                        App_Code.PageBase.FixMenus();
                    }
                    else if (tb == "modules")
                    {
                        BLL.modules bl = new BLL.modules();

                        //先删除删除扩展信息
                        App_Code.PageBase.FixModulesExt(id);

                        //更新扩展信息
                        App_Code.PageBase.FixModules();
                    }

                    //保存日志
                    Model.logs lg = new Model.logs();
                    lg.loginfo = "表:" + tb + ",ID:" + id;
                    App_Code.PageBase.UserLog("删除", lg);

                    str = "{\"code\":1,\"msg\":\"" + id + "删除成功\"}";
                }
                else
                {
                    str = "{\"code\":0,\"msg\":\"ID传值错误\"}";
                }
            }
            else
            {
                str = "{\"code\":-1,\"msg\":\"权限错误\"}";
            }
            context.Response.Write(str);
        }