コード例 #1
0
        public JsonResult Editorganization(FormCollection form)
        {
            Common.Json         json      = new Common.Json();
            B_Organization      b_org     = new B_Organization();
            B_Organization_type b_orgtype = new B_Organization_type();
            B_Manager           b_manager = new B_Manager();

            Domain.Organization model = b_org.Get(Convert.ToInt32(form["id"]));

            model.name      = form["txt_name"];
            model.parent_id = Convert.ToInt32(form["txt_parent_id"]);
            if (model.parent_id != 0)
            {
                var m = b_org.Get(model.parent_id);
                if (string.IsNullOrEmpty(model.parent_ids))
                {
                    model.parent_ids = model.parent_id + ",";
                }
                else
                {
                    model.parent_ids = m.parent_ids + m.parent_id + ",";
                }
                model.levels = m.levels + 1;
            }
            else
            {
                model.levels = 0;
            }
            model.orgtype = b_orgtype.Get(Convert.ToInt32(form["txt_orgtype_id"]));
            model.sort_id = Convert.ToInt32(form["txt_sort_id"]);
            model.status  = Convert.ToInt32(form["txt_status"]);
            b_org.Update(model);
            json.msg = "修改成功!";
            return(Json(json));
        }
コード例 #2
0
        public JsonResult AddNews_type(int txt_parent_id, string txt_title, int?txt_sort_id, string txt_seo_title, string txt_seo_keywords, string txt_seo_description)
        {
            Common.Json         json = new Common.Json();
            DAO.BLL.B_News_type b_nt = new DAO.BLL.B_News_type();
            Domain.News_type    m_nt = new Domain.News_type();
            m_nt.parent_id       = txt_parent_id;
            m_nt.title           = txt_title;
            m_nt.sort_id         = txt_sort_id;
            m_nt.seo_title       = txt_seo_title;
            m_nt.seo_keywords    = txt_seo_keywords;
            m_nt.seo_description = txt_seo_description;
            var res = b_nt.Save(m_nt);

            if (res > 0)
            {
                json.msg = "添加成功!";
            }
            else
            {
                json.msg    = "添加失败!";
                json.status = -1;
            }

            return(Json(json));
        }
コード例 #3
0
        public JsonResult EditManager_role(int id, string txt_role_name, string txt_action_type)
        {
            Common.Json            json = new Common.Json();
            DAO.BLL.B_Manager_role b_mr = new DAO.BLL.B_Manager_role();
            var m_mr = b_mr.Get(id);
            List <SearchTemplate> st = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "role_name", value = txt_role_name, searchType = Common.EnumBase.SearchType.Eq
                }
            };
            var res = b_mr.GetCount(st);

            if (m_mr.role_name != txt_role_name)
            {
                if (res > 0)
                {
                    json.status  = -1;
                    json.msg     = "角色名已存在!";
                    json.pitchId = "txt_role_name";
                    return(Json(json));
                }
            }
            Domain.Manager_role model = m_mr;
            model.role_name = txt_role_name;
            b_mr.Update(model);
            B_Manager_role_value b_mrv = new B_Manager_role_value();

            b_mrv.Update(txt_action_type, model.id);
            json.msg = "修改成功!";

            return(Json(json));
        }
コード例 #4
0
        public JsonResult EditNav(int id, string txt_parent_id, string txt_icon_url, string txt_title, string txt_link_url, string txt_sort_id, string txt_is_lock, string txt_action_type)
        {
            Common.Json  json  = new Common.Json();
            B_Navigation b_nav = new B_Navigation();

            Domain.Navigation model = b_nav.GetNav(id);
            model.icon_url = txt_icon_url;
            model.title    = txt_title;
            model.link_url = txt_link_url;
            if (!string.IsNullOrEmpty(model.link_url) && model.link_url != "#")
            {
                model.controllerName = model.link_url.Substring(model.link_url.LastIndexOf("/") + 1);
            }
            else
            {
                model.controllerName = "";
            }
            model.sort_id     = Convert.ToInt32(txt_sort_id);
            model.is_lock     = txt_is_lock;
            model.parent_id   = Convert.ToInt32(txt_parent_id);
            model.action_type = txt_action_type;
            if (model.parent_id == 0)
            {
                model.channel_id = 1;
            }
            else
            {
                model.channel_id = 2;
            }
            b_nav.Update(model);
            json.msg = "修改成功!";
            return(Json(json));
        }
コード例 #5
0
        public JsonResult login(string un, string pwd, string code, string returnUrl)
        {
            Common.Json json = new Common.Json();
            if (Common.Encrypt.md5(code.ToLower()) != WebHelper.GetSession("lsj_pic_code"))
            {
                json.msg    = "验证码不正确!";
                json.status = -1;
                return(Json(json));
            }
            DAO.BLL.B_Manager b_manager = new DAO.BLL.B_Manager();
            if (ModelState.IsValid)
            {
                List <SearchTemplate> st = new List <SearchTemplate>()
                {
                    new SearchTemplate()
                    {
                        key = "user_name", value = un, searchType = Common.EnumBase.SearchType.Eq
                    },
                    new SearchTemplate()
                    {
                        key = "password", value = Common.Encrypt.md5(pwd), searchType = Common.EnumBase.SearchType.Eq
                    },
                    new SearchTemplate()
                    {
                        key = "is_lock", value = "√", searchType = Common.EnumBase.SearchType.Eq
                    }
                };
                var list_model = b_manager.GetList(st, null);
                if (list_model.Count > 0)
                {
                    FormsAuthentication.SetAuthCookie(list_model[0].id.ToString(), true);
                    if (!String.IsNullOrEmpty(returnUrl))
                    {
                        json.returnUrl = returnUrl;
                    }
                    else
                    {
                        json.returnUrl = "/home/index";
                    }

                    DAO.BLL.B_Manager_log b_log = new DAO.BLL.B_Manager_log();
                    //记录用户所在地区
                    var    userip   = Utils.getIp();
                    string location = "";
                    if (userip.Contains("."))
                    {
                        location = Hui.Utils.IPHelper.GetFullName(userip);
                    }

                    b_log.Add(list_model[0].id, Common.EnumBase.Authorize.登录.Description(), "manager", "用户登录:" + location, Utils.getIp());
                }
                else
                {
                    json.msg    = "用户名或密码不正确!";
                    json.status = -1;
                }
            }

            return(Json(json));
        }
コード例 #6
0
ファイル: ManagerController.cs プロジェクト: radtek/CoinsPro
        public JsonResult EditManager(string id, string txt_user_name, string txt_role_id, string txt_real_name, string txt_mobile, string txt_email, string txt_password, string txt_is_lock)
        {
            Common.Json       json      = new Common.Json();
            DAO.BLL.B_Manager b_manager = new DAO.BLL.B_Manager();
            var m_manager = b_manager.Get(Convert.ToInt32(id));

            if (m_manager.user_name != txt_user_name)
            {
                List <SearchTemplate> st = new List <SearchTemplate>()
                {
                    new SearchTemplate()
                    {
                        key = "user_name", value = txt_user_name, searchType = Common.EnumBase.SearchType.Eq
                    }
                };
                var res = b_manager.GetCount(st);
                if (res > 0)
                {
                    json.status  = -1;
                    json.msg     = "用户名已存在!";
                    json.pitchId = "txt_user_name";
                    return(Json(json));
                }
            }
            if (m_manager.mobile != txt_mobile)
            {
                List <SearchTemplate> st = new List <SearchTemplate>()
                {
                    new SearchTemplate()
                    {
                        key = "mobile", value = txt_mobile, searchType = Common.EnumBase.SearchType.Eq
                    }
                };
                var res = b_manager.GetCount(st);
                if (res > 0)
                {
                    json.status  = -1;
                    json.msg     = "手机号已存在!";
                    json.pitchId = "txt_mobile";
                    return(Json(json));
                }
            }
            m_manager.user_name = txt_user_name;
            m_manager.real_name = txt_real_name;
            m_manager.mobile    = txt_mobile;
            m_manager.email     = txt_email;
            if (m_manager.password != Common.Encrypt.md5(txt_password))
            {
                m_manager.password = Common.Encrypt.md5(txt_password);
            }
            m_manager.is_lock  = txt_is_lock;
            m_manager.add_time = DateTime.Now;
            B_Manager_role b_mr = new B_Manager_role();

            //cascade:有all、save-update、delete、none几个选项,表示  该表做一些操作时 是否作用于 关联的表,比如在一对多关系中如果cascade="all"时,那么父表所做的操作都会作用于子表,比如删除某个用户,那么这个用户下的文章也会关联一起删除。
            m_manager.manager_role = b_mr.Get(Convert.ToInt32(txt_role_id));
            b_manager.Update(m_manager);
            json.msg = "修改成功!";
            return(Json(json));
        }
コード例 #7
0
 public JsonResult SetSession()
 {
     Common.Json json = new Common.Json();
     Session["test"] = "当前时间: " + DateTime.Now;
     json.msg        = "写入成功!";
     json.status     = 0;
     return(Json(json));
 }
コード例 #8
0
ファイル: ManagerController.cs プロジェクト: radtek/CoinsPro
        public JsonResult AddManager(string txt_user_name, string txt_role_id, string txt_real_name, string txt_mobile, string txt_email, string txt_password, string txt_is_lock)
        {
            Common.Json           json      = new Common.Json();
            B_Manager             b_manager = new B_Manager();
            List <SearchTemplate> st        = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "user_name", value = txt_user_name, searchType = Common.EnumBase.SearchType.Eq
                }
            };
            var res = b_manager.GetCount(st);

            if (res > 0)
            {
                json.status  = -1;
                json.msg     = "用户名已存在!";
                json.pitchId = "txt_user_name";
                return(Json(json));
            }
            st = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "mobile", value = txt_mobile, searchType = Common.EnumBase.SearchType.Eq
                }
            };
            res = b_manager.GetCount(st);
            if (res > 0)
            {
                json.status  = -1;
                json.msg     = "手机号已存在!";
                json.pitchId = "txt_mobile";
                return(Json(json));
            }
            Domain.Manager model = new Domain.Manager();
            model.user_name = txt_user_name;
            model.real_name = txt_real_name;
            model.mobile    = txt_mobile;
            model.email     = txt_email;
            model.password  = Common.Encrypt.md5(txt_password);
            model.is_lock   = txt_is_lock;
            model.add_time  = DateTime.Now;
            B_Manager_role b_mr = new B_Manager_role();

            //必须给一个角色对象,这里相当于又执行了一条update,可以在这里修改对应角色的内容(这就是NHibernate搞的鬼)
            model.manager_role = b_mr.Get(Convert.ToInt32(txt_role_id));
            res = b_manager.Save(model);
            if (res <= 0)
            {
                json.status = -1;
                json.msg    = "添加失败!";
                return(Json(json));
            }
            json.msg = "添加成功!";
            return(Json(json));
        }
コード例 #9
0
        public JsonResult EditUser(int id, string txt_user_name, string txt_mobile, string txt_email, string txt_nick_name, string txt_password)
        {
            HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
            Common.Json     json   = new Common.Json();
            DAO.BLL.B_Users b_user = new DAO.BLL.B_Users();
            var             m_user = b_user.GetUser(id);

            if (m_user.user_name != txt_user_name)
            {
                List <SearchTemplate> st = new List <SearchTemplate>()
                {
                    new SearchTemplate()
                    {
                        key = "user_name", value = txt_user_name, searchType = Common.EnumBase.SearchType.Eq
                    },
                };
                var res = b_user.GetCount(st);
                if (res > 0)
                {
                    json.status  = -1;
                    json.msg     = "用户名已存在!";
                    json.pitchId = "txt_user_name";
                    return(Json(json));
                }
            }
            if (m_user.mobile != txt_mobile)
            {
                List <SearchTemplate> st = new List <SearchTemplate>()
                {
                    new SearchTemplate()
                    {
                        key = "mobile", value = txt_mobile, searchType = Common.EnumBase.SearchType.Eq
                    },
                };
                var res = b_user.GetCount(st);
                if (res > 0)
                {
                    json.status  = -1;
                    json.msg     = "手机号已存在!";
                    json.pitchId = "txt_mobile";
                    return(Json(json));
                }
            }
            m_user.user_name = txt_user_name;
            m_user.mobile    = txt_mobile;
            if (m_user.password != txt_password)
            {
                m_user.password = Common.Encrypt.md5(txt_password);
            }
            m_user.email     = txt_email;
            m_user.nick_name = txt_nick_name;
            b_user.Update(m_user);
            json.msg = "修改成功!";
            return(Json(json));
        }
コード例 #10
0
 public JsonResult DelUser(string ids)
 {
     Common.Json     json   = new Common.Json();
     DAO.BLL.B_Users b_user = new DAO.BLL.B_Users();
     foreach (var id in ids.Split(new char[] { ',' }))
     {
         b_user.Delete(Convert.ToInt32(id));
     }
     json.msg = "成功删除" + ids.Split(new char[] { ',' }).Length + "条记录!";
     return(Json(json));
 }
コード例 #11
0
ファイル: DictionController.cs プロジェクト: radtek/CoinsPro
        public JsonResult DelOrganization_type(string ids)
        {
            Common.Json         json      = new Common.Json();
            B_Organization_type b_orgtype = new B_Organization_type();

            foreach (var id in ids.Split(new char[] { ',' }))
            {
                b_orgtype.Delete(Convert.ToInt32(id));
            }
            json.msg = "成功删除" + ids.Split(new char[] { ',' }).Length + "条记录!";
            return(Json(json));
        }
コード例 #12
0
        public JsonResult DelNav(string ids)
        {
            Common.Json  json  = new Common.Json();
            B_Navigation b_nav = new B_Navigation();

            foreach (var id in ids.Split(new char[] { ',' }))
            {
                b_nav.Delete(Convert.ToInt32(id));
            }
            json.msg = "成功删除" + ids.Split(new char[] { ',' }).Length + "条记录!";
            return(Json(json));
        }
コード例 #13
0
        public JsonResult DelManager_role(string ids)
        {
            Common.Json    json = new Common.Json();
            B_Manager_role b_mr = new B_Manager_role();

            foreach (var id in ids.Split(new char[] { ',' }))
            {
                b_mr.Delete(Convert.ToInt32(id));
            }
            json.msg = "成功删除" + ids.Split(new char[] { ',' }).Length + "条记录!";
            return(Json(json));
        }
コード例 #14
0
ファイル: DictionController.cs プロジェクト: radtek/CoinsPro
        public JsonResult EditOrganization_type(FormCollection form)
        {
            Common.Json         json      = new Common.Json();
            B_Organization_type b_orgtype = new B_Organization_type();

            Domain.Organization_type m_orgtype = b_orgtype.Get(Convert.ToInt32(form["id"]));
            m_orgtype.orgtype_name = form["txt_name"];
            m_orgtype.sort_id      = Convert.ToInt32(form["txt_sort_id"]);
            m_orgtype.remark       = form["txt_remark"];
            b_orgtype.Update(m_orgtype);
            json.msg = "修改成功!";
            return(Json(json));
        }
コード例 #15
0
        public JsonResult AddUser(string txt_user_name, string txt_mobile, string txt_email, string txt_nick_name, string txt_password)
        {
            Common.Json           json   = new Common.Json();
            DAO.BLL.B_Users       b_user = new DAO.BLL.B_Users();
            List <SearchTemplate> st     = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "user_name", value = txt_user_name, searchType = Common.EnumBase.SearchType.Eq
                },
            };
            var res = b_user.GetCount(st);

            if (res > 0)
            {
                json.status  = -1;
                json.msg     = "用户名已存在!";
                json.pitchId = "txt_user_name";
                return(Json(json));
            }
            st = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "mobile", value = txt_mobile, searchType = Common.EnumBase.SearchType.Eq
                },
            };
            res = b_user.GetCount(st);
            if (res > 0)
            {
                json.status  = -1;
                json.msg     = "手机号已存在!";
                json.pitchId = "txt_mobile";
                return(Json(json));
            }
            Domain.Users m_user = new Domain.Users();
            m_user.user_name = txt_user_name;
            m_user.mobile    = txt_mobile;
            m_user.password  = Common.Encrypt.md5(txt_password);
            m_user.email     = txt_email;
            m_user.nick_name = txt_nick_name;
            res = b_user.Save(m_user);
            if (res <= 0)
            {
                json.status = -1;
                json.msg    = "添加失败!";
                return(Json(json));
            }
            json.msg = "添加成功!";
            return(Json(json));
        }
コード例 #16
0
        public JsonResult DelNews(string ids)
        {
            Common.Json json  = new Common.Json();
            B_News      b_new = new B_News();

            foreach (var id in ids.Split(new char[] { ',' }))
            {
                var m_new = b_new.Get(Convert.ToInt32(id));
                b_new.Delete(Convert.ToInt32(id));
                string pastImg = Path.Combine(Request.MapPath("/") + "../Images", m_new.img_url);//旧文件的物理路径
            }
            json.msg = "成功删除" + ids.Split(new char[] { ',' }).Length + "条记录!";
            return(Json(json));
        }
コード例 #17
0
        public JsonResult EditNews_type(int id, int txt_parent_id, string txt_title, int?txt_sort_id, string txt_seo_title, string txt_seo_keywords, string txt_seo_description)
        {
            Common.Json         json = new Common.Json();
            DAO.BLL.B_News_type b_nt = new DAO.BLL.B_News_type();
            var m_nt = b_nt.Get(id);

            m_nt.parent_id       = txt_parent_id;
            m_nt.title           = txt_title;
            m_nt.sort_id         = txt_sort_id;
            m_nt.seo_title       = txt_seo_title;
            m_nt.seo_keywords    = txt_seo_keywords;
            m_nt.seo_description = txt_seo_description;
            b_nt.Update(m_nt);
            json.msg = "修改成功!";
            return(Json(json));
        }
コード例 #18
0
ファイル: Send_smsController.cs プロジェクト: radtek/CoinsPro
        public JsonResult AddSend_sms(string appkey, string secret, string SmsFreeSignName, string SmsParam, string RecNum, string SmsTemplateCode)
        {
            Sms sms = new Sms();
            var res = sms.Send(appkey, secret, SmsFreeSignName, SmsParam, RecNum, SmsTemplateCode);

            Common.Json json = new Common.Json();
            if (res == null || !res.Success)
            {
                json.status = -1;
                json.msg    = "短信发送失败!";
            }
            else
            {
                json.msg = "短信发送成功!";
            }
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
コード例 #19
0
        public JsonResult AddBackups(string txt_dbName, string txt_fileName, string txt_backupType, string txt_remark)
        {
            HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
            Common.Json json      = new Common.Json();
            B_Backups   b_backup  = new B_Backups();
            B_Manager   b_manager = new B_Manager();

            txt_fileName += ".bak";
            var filePath = Server.MapPath("~/Resource/DbBackup/" + txt_fileName);

            //把文件备份成功
            b_backup.BackupDB(txt_dbName, filePath, Convert.ToInt32(txt_backupType));
            Domain.Backups m_backup = new Domain.Backups();
            m_backup.dbName   = txt_dbName;
            m_backup.fileName = txt_fileName;
            m_backup.filePath = "/Resource/DbBackup/" + txt_fileName;
            if (Convert.ToInt32(txt_backupType) == Convert.ToInt32(EnumBase.BackupType.完整备份))
            {
                m_backup.backupType = EnumBase.BackupType.完整备份.Description();
            }
            else if (Convert.ToInt32(txt_backupType) == Convert.ToInt32(EnumBase.BackupType.差异备份))
            {
                m_backup.backupType = EnumBase.BackupType.差异备份.Description();
            }
            else
            {
                m_backup.backupType = EnumBase.BackupType.完整备份.Description();
            }
            m_backup.fileSize   = FileHelper.ToFileSize(FileHelper.GetFileSize(filePath));
            m_backup.addTime    = DateTime.Now;
            m_backup.addManager = b_manager.Get(Convert.ToInt32(base.User.Identity.Name));
            m_backup.remark     = txt_remark;
            m_backup.delManager = new Domain.Manager();//这里给个空对象,否则外键关联会出错的
            var res = b_backup.Save(m_backup);

            if (res > 0)
            {
                json.msg = "备份成功!";
            }
            else
            {
                json.msg    = "备份失败!";
                json.status = -1;
            }
            return(Json(json));
        }
コード例 #20
0
        public JsonResult ExamNews(string ids, int?txt_status)
        {
            Common.Json json  = new Common.Json();
            B_News      b_new = new B_News();

            foreach (var id in ids.Split(new char[] { ',' }))
            {
                var m_new = b_new.Get(Convert.ToInt32(id));
                if (m_new.status != txt_status)
                {
                    m_new.status = txt_status;
                    b_new.Update(m_new);
                }
            }
            json.msg = "成功审核" + ids.Split(new char[] { ',' }).Length + "条记录!";
            return(Json(json));
        }
コード例 #21
0
        public JsonResult AddOrganization(FormCollection form)
        {
            Common.Json         json      = new Common.Json();
            B_Organization      b_org     = new B_Organization();
            B_Organization_type b_orgtype = new B_Organization_type();
            B_Manager           b_manager = new B_Manager();

            Domain.Organization model = new Domain.Organization();

            model.name      = form["txt_name"];
            model.parent_id = Convert.ToInt32(form["txt_parent_id"]);
            if (model.parent_id != 0)
            {
                var m = b_org.Get(model.parent_id);
                if (string.IsNullOrEmpty(model.parent_ids))
                {
                    model.parent_ids = model.parent_id + ",";
                }
                else
                {
                    model.parent_ids = m.parent_ids + m.parent_id + ",";
                }
                model.levels = m.levels + 1;
            }
            else
            {
                model.levels = 0;
            }
            model.orgtype     = b_orgtype.Get(Convert.ToInt32(form["txt_orgtype_id"]));
            model.sort_id     = Convert.ToInt32(form["txt_sort_id"]);
            model.add_manager = b_manager.Get(Convert.ToInt32(base.User.Identity.Name));
            model.add_time    = DateTime.Now;
            model.status      = Convert.ToInt32(form["txt_status"]);
            var res = b_org.Save(model);

            if (res <= 0)
            {
                json.status = -1;
                json.msg    = "添加失败!";
                return(Json(json));
            }
            json.msg = "添加成功!";

            return(Json(json));
        }
コード例 #22
0
        public JsonResult AddWiki(FormCollection form)
        {
            Common.Json    json      = new Common.Json();
            DAO.BLL.B_Wiki b_wiki    = new DAO.BLL.B_Wiki();
            B_Manager      b_manager = new B_Manager();

            Domain.Wiki m_wiki = new Domain.Wiki();
            m_wiki.title     = form["txt_title"];
            m_wiki.tags      = form["txt_tags"];
            m_wiki.synopsis  = form["txt_synopsis"];
            m_wiki.sort_id   = Convert.ToInt32(form["txt_sort_id"]);
            m_wiki.content   = form["txtContent"];
            m_wiki.manager   = b_manager.Get(Convert.ToInt32(base.User.Identity.Name));
            m_wiki.add_time  = DateTime.Now;
            m_wiki.parent_id = Convert.ToInt32(form["txt_parent_id"]);
            if (m_wiki.parent_id != 0)
            {
                var m = b_wiki.Get(m_wiki.parent_id);
                if (string.IsNullOrEmpty(m_wiki.parent_ids))
                {
                    m_wiki.parent_ids = m_wiki.parent_id + ",";
                }
                else
                {
                    m_wiki.parent_ids = m.parent_ids + m.parent_id + ",";
                }
                m_wiki.levels = m.levels + 1;
            }
            else
            {
                m_wiki.levels = 0;
            }
            var res = b_wiki.Save(m_wiki);

            if (res <= 0)
            {
                json.status = -1;
                json.msg    = "添加失败!";
                return(Json(json));
            }
            json.msg = "添加成功!";
            return(Json(json));
        }
コード例 #23
0
ファイル: DictionController.cs プロジェクト: radtek/CoinsPro
        public JsonResult AddOrganization_type(FormCollection form)
        {
            Common.Json         json      = new Common.Json();
            B_Organization_type b_orgtype = new B_Organization_type();

            Domain.Organization_type m_orgtype = new Domain.Organization_type();
            m_orgtype.orgtype_name = form["txt_name"];
            m_orgtype.sort_id      = Convert.ToInt32(form["txt_sort_id"]);
            m_orgtype.remark       = form["txt_remark"];
            var res = b_orgtype.Save(m_orgtype);

            if (res <= 0)
            {
                json.status = -1;
                json.msg    = "添加失败!";
                return(Json(json));
            }
            json.msg = "添加成功!";
            return(Json(json));
        }
コード例 #24
0
        public JsonResult GetSession()
        {
            string   a  = "2017/2/22";
            string   b  = "16:40:51";
            DateTime dt = Convert.ToDateTime(a + " " + b);

            Common.Json json = new Common.Json();
            try
            {
                var res = Session["test"].ToString();
                json.msg    = res;
                json.status = 0;
            }
            catch
            {
                json.status = -1;
                json.msg    = "获取session失败!";
            }
            return(Json(json));
        }
コード例 #25
0
        public JsonResult DelBackups(string ids)
        {
            Common.Json json       = new Common.Json();
            B_Backups   b_backup   = new B_Backups();
            B_Manager   b_mananger = new B_Manager();

            foreach (var id in ids.Split(new char[] { ',' }))
            {
                var    model    = b_backup.Get(Convert.ToInt32(id));
                string filepath = Server.MapPath(model.filePath);
                if (FileDownHelper.FileExists(filepath))
                {
                    FileHelper.DeleteFile(filepath);
                }
                model.delManager = b_mananger.Get(Convert.ToInt32(base.User.Identity.Name));
                model.delTime    = DateTime.Now;
                b_backup.Update(model);
            }
            json.msg = "成功删除" + ids.Split(new char[] { ',' }).Length + "个备份!";
            return(Json(json));
        }
コード例 #26
0
        public JsonResult AddNav(string txt_parent_id, string txt_icon_url, string txt_title, string txt_link_url, string txt_sort_id, string txt_is_lock, string txt_action_type)
        {
            Common.Json  json  = new Common.Json();
            B_Navigation b_nav = new B_Navigation();

            Domain.Navigation model = new Domain.Navigation();

            model.icon_url = txt_icon_url;
            model.title    = txt_title;
            model.link_url = txt_link_url;
            if (!string.IsNullOrEmpty(model.link_url) && model.link_url != "#")
            {
                model.controllerName = model.link_url.Substring(model.link_url.LastIndexOf("/") + 1);
            }
            model.sort_id     = Convert.ToInt32(txt_sort_id);
            model.is_lock     = txt_is_lock;
            model.parent_id   = Convert.ToInt32(txt_parent_id);
            model.action_type = txt_action_type;
            if (model.parent_id == 0)
            {
                model.channel_id = 1;
            }
            else
            {
                model.channel_id = 2;
            }
            var res = b_nav.Save(model);

            if (res <= 0)
            {
                json.status = -1;
                json.msg    = "添加失败!";
                return(Json(json));
            }
            json.msg = "添加成功!";

            return(Json(json));
        }
コード例 #27
0
        public JsonResult AddManager_role(string txt_role_name, string txt_action_type)
        {
            Common.Json            json = new Common.Json();
            DAO.BLL.B_Manager_role b_mr = new DAO.BLL.B_Manager_role();
            List <SearchTemplate>  st   = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "role_name", value = txt_role_name, searchType = Common.EnumBase.SearchType.Eq
                }
            };
            var res = b_mr.GetCount(st);

            if (res > 0)
            {
                json.status  = -1;
                json.msg     = "角色名已存在!";
                json.pitchId = "txt_role_name";
                return(Json(json));
            }
            Domain.Manager_role model = new Domain.Manager_role();
            model.role_name = txt_role_name;
            res             = b_mr.Save(model);
            if (res <= 0)
            {
                json.status = -1;
                json.msg    = "添加失败!";
                return(Json(json));
            }
            B_Manager_role_value b_mrv = new B_Manager_role_value();

            b_mrv.Update(txt_action_type, res);
            json.msg = "添加成功!";

            return(Json(json));
        }
コード例 #28
0
        // OnActionExecuted 在执行操作方法后由 ASP.NET MVC 框架调用。
        // OnActionExecuting 在执行操作方法之前由 ASP.NET MVC 框架调用。
        // OnResultExecuted 在执行操作结果后由 ASP.NET MVC 框架调用。
        // OnResultExecuting 在执行操作结果之前由 ASP.NET MVC 框架调用。

        /// <summary>
        /// 在执行操作方法之前由 ASP.NET MVC 框架调用。
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            #region 记录日志(所有的请求)
            MonitorLog MonLog = new MonitorLog();
            MonLog.ExecuteStartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.ffff", DateTimeFormatInfo.InvariantInfo));
            MonLog.ControllerName   = filterContext.RouteData.Values["controller"] as string;
            MonLog.ActionName       = filterContext.RouteData.Values["action"] as string;
            MonLog.FormCollections  = filterContext.HttpContext.Request.Form;        //form表单提交的数据
            MonLog.QueryCollections = filterContext.HttpContext.Request.QueryString; //Url 参数
            //Logger.Info(MonLog.GetLoginfo());
            filterContext.Controller.ViewData[Key] = MonLog;
            #endregion

            //忽略home的权限验证
            var controllerName = filterContext.RouteData.Values["controller"].ToString().ToLower();
            if (controllerName == "home")
            {
                return;
            }



            var actionName = filterContext.RouteData.Values["action"].ToString().ToLower();

            //忽略首页index的权限验证
            //if (actionName == "index") return;


            var actionType = ActionType(actionName);

            DAO.BLL.B_Navigation  b_nav = new DAO.BLL.B_Navigation();
            List <SearchTemplate> st    = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "controllerName", value = controllerName, searchType = Common.EnumBase.SearchType.Eq
                }
            };
            IList <Domain.Navigation> list_nav = b_nav.GetList(st, null);
            if (list_nav.Count == 0)
            {
                filterContext.Result = new ContentResult {
                    Content = @"抱歉,没有找到该操作!"
                };
                return;
            }
            DAO.BLL.B_Manager_role_value b_mrv     = new DAO.BLL.B_Manager_role_value();
            DAO.BLL.B_Manager            b_manager = new DAO.BLL.B_Manager();
            var m_manager = b_manager.Get(Convert.ToInt32(filterContext.HttpContext.User.Identity.Name));
            st = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "role_id", value = m_manager.manager_role.id, searchType = Common.EnumBase.SearchType.Eq
                },
                new SearchTemplate()
                {
                    key = "nav_id", value = list_nav[0].id, searchType = Common.EnumBase.SearchType.Eq
                }
            };
            var list_mrv = b_mrv.GetList(st, null);
            if (list_mrv.Count == 0)
            {
                filterContext.Result = new ContentResult {
                    Content = @"抱歉,你不具有当前操作的权限!"
                };
                return;
            }
            if (!list_mrv[0].action_type.Contains(actionType))
            {
                //如果是查看,就返回一个空的视图,否则返回一个json
                if (actionType == EnumBase.Authorize.查看.Description())
                {
                    filterContext.Result = new ContentResult {
                        Content = @"抱歉,你不具有当前操作的权限!"
                    };                                                                        // 直接返回 return Content("抱歉,你不具有当前操作的权限!")
                }
                else
                {
                    Common.Json json = new Common.Json();
                    json.msg             = "抱歉,你不具有当前操作的权限!";
                    json.status          = -1;
                    filterContext.Result = new JsonResult()
                    {
                        Data = json
                    };
                }
            }
        }
コード例 #29
0
        public JsonResult AddNews(int txt_parent_id, string txt_is_lock, string txt_action_type, string txt_title, int?txt_sort_id, int?txt_click, DateTime?start_time, string txt_source, string txt_author, string txt_summary, string txtContent, string txt_seo_title, string txt_seo_keywords, string txt_seo_description)
        {
            Common.Json json     = new Common.Json();
            var         fileName = "";
            var         name     = "";

            if (Request.Files.Count == 0)
            {
                //json.msg = "没有文件!";
                //json.status = -1;
                //return Json(json);
            }
            else
            {
                HttpPostedFileBase file = Request.Files[0];
                name     = "news/" + DateTime.Now.ToString("yyyyMMddhhmmss") + Path.GetExtension(file.FileName);
                fileName = Path.Combine(Request.MapPath("/") + "../Images", name);
                try
                {
                    file.SaveAs(fileName);
                }
                catch
                {
                    //json.msg = "上传异常!";
                    //json.status = -1;
                    //return Json(json);
                }
            }

            DAO.BLL.B_News      b_new     = new DAO.BLL.B_News();
            DAO.BLL.B_News_type b_nt      = new B_News_type();
            DAO.BLL.B_Manager   b_manager = new B_Manager();
            Domain.News         m_new     = new Domain.News();
            m_new.news_type = b_nt.Get(txt_parent_id);
            m_new.is_lock   = txt_is_lock;
            if (!string.IsNullOrEmpty(txt_action_type))
            {
                if (txt_action_type.Contains(EnumBase.RecommendType.置顶.Description()))
                {
                    m_new.is_top = 1;
                }
                if (txt_action_type.Contains(EnumBase.RecommendType.热门.Description()))
                {
                    m_new.is_hot = 1;
                }
                if (txt_action_type.Contains(EnumBase.RecommendType.推荐.Description()))
                {
                    m_new.is_red = 1;
                }
                if (txt_action_type.Contains(EnumBase.RecommendType.允许评论.Description()))
                {
                    m_new.is_msg = 1;
                }
            }
            m_new.title           = txt_title;
            m_new.img_url         = name;
            m_new.sort_id         = txt_sort_id;
            m_new.source          = txt_source;
            m_new.author          = txt_author;
            m_new.summary         = txt_summary;
            m_new.content         = txtContent;
            m_new.start_time      = start_time;
            m_new.add_time        = DateTime.Now;
            m_new.click           = txt_click;
            m_new.manager         = b_manager.Get(Convert.ToInt32(base.User.Identity.Name));
            m_new.seo_title       = txt_seo_title;
            m_new.seo_keywords    = txt_seo_keywords;
            m_new.seo_description = txt_seo_description;
            var res = b_new.Save(m_new);

            if (res > 0)
            {
                json.msg = "添加成功!";
            }
            else
            {
                json.msg    = "添加失败!";
                json.status = -1;
            }
            return(Json(json));
        }