Beispiel #1
0
        public JsonResult GetManager(int id)
        {
            DAO.BLL.B_Manager b_manager = new B_Manager();
            var res = b_manager.Get(id);

            return(Json(res));
        }
Beispiel #2
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));
        }
        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));
        }
Beispiel #4
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));
        }
Beispiel #5
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));
        }
Beispiel #6
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));
        }
Beispiel #7
0
        public static string select_auth(this HtmlHelper helper, string manager_id, string controllerName)
        {
            B_Navigation          b_nav = new B_Navigation();
            List <SearchTemplate> st    = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "controllerName", value = controllerName, searchType = Common.EnumBase.SearchType.Eq
                }
            };
            var list_nav = b_nav.GetList(st, null);
            int nav_id   = 0;

            if (list_nav.Count > 0)
            {
                nav_id = list_nav[0].id;
            }
            B_Manager_role_value b_mrv     = new B_Manager_role_value();
            B_Manager            b_manager = new B_Manager();
            var m_manager = b_manager.Get(Convert.ToInt32(manager_id));

            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 = nav_id, searchType = Common.EnumBase.SearchType.Eq
                }
            };
            var list_mrv = b_mrv.GetList(st, null);

            if (list_mrv.Count == 0)
            {
                return("");
            }
            StringBuilder sb = new StringBuilder();

            sb.Append("<div id=\"toolbar\" class=\"btn-group\">");
            if (list_mrv[0].action_type.Contains(EnumBase.Authorize.添加.Description()))
            {
                sb.Append("<button id=\"btn_add\" type=\"button\" class=\"btn btn-blue\">");
                sb.Append("<span class=\"glyphicon glyphicon-plus\" aria-hidden=\"true\"></span>" + EnumBase.Authorize.添加.Description());
                sb.Append("</button>");
            }
            if (list_mrv[0].action_type.Contains(EnumBase.Authorize.修改.Description()))
            {
                sb.Append("<button id=\"btn_edit\" type=\"button\" class=\"btn btn-warning\">");
                sb.Append("<span class=\"glyphicon glyphicon-pencil\" aria-hidden=\"true\"></span>" + EnumBase.Authorize.修改.Description());
                sb.Append("</button>");
            }
            if (list_mrv[0].action_type.Contains(EnumBase.Authorize.除.Description()))
            {
                sb.Append("<button id=\"btn_delete\" type=\"button\" class=\"btn btn-danger\">");
                sb.Append("<span class=\"glyphicon glyphicon-remove\" aria-hidden=\"true\"></span>" + EnumBase.Authorize.除.Description());
                sb.Append("</button>");
            }
            if (list_mrv[0].action_type.Contains(EnumBase.Authorize.审核.Description()))
            {
                sb.Append("<button id=\"btn_exam\" type=\"button\" class=\"btn btn-info\">");
                sb.Append("<span class=\"glyphicon glyphicon-check\" aria-hidden=\"true\"></span>" + EnumBase.Authorize.审核.Description());
                sb.Append("</button>");
            }
            if (list_mrv[0].action_type.Contains(EnumBase.Authorize.载.Description()))
            {
                sb.Append("<button id=\"btn_download\" type=\"button\" class=\"btn btn-success\">");
                sb.Append("<span class=\"fa fa-cloud-download\" aria-hidden=\"true\"></span>" + EnumBase.Authorize.载.Description());
                sb.Append("</button>");
            }
            sb.Append("</div>");
            return(sb.ToString());
        }