Esempio n. 1
0
        /// <summary>
        /// 插入Z_Role_Menu
        /// </summary>
        /// <param name="role_id">角色ID</param>
        /// <param name="menus">菜单code串</param>
        /// <returns></returns>
        public bool Update_Menus(string role_id, string menus)
        {
            try
            {
                using (JSZX_ResourceEntities db = new JSZX_ResourceEntities())
                {
                    var list = (
                        from t in db.Z_Role_Menu
                        where t.Role_ID == role_id
                        select t
                        ).ToList();

                    for (int i = 0; i < list.Count; i++)
                    {
                        db.Z_Role_Menu.Remove(list[i]);
                    }
                    db.SaveChanges();
                }

                return(Insert_Menus(role_id, menus));
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 更新Z_Role
        /// </summary>
        /// <param name="id">角色ID</param>
        /// <param name="title">角色名称</param>
        /// <param name="remark">描述</param>
        /// <returns></returns>
        public bool Update_Role(string id, string title, string remark)
        {
            try
            {
                using (JSZX_ResourceEntities db = new JSZX_ResourceEntities())
                {
                    var list = (
                        from t in db.Z_Role
                        where t.ID == id
                        select t
                        ).Take(1).ToList();

                    if (list != null && list.Count > 0)
                    {
                        var it = list.First();
                        it.Title    = title;
                        it.Remark   = remark;
                        it.EditMan  = "";
                        it.EditDate = DateTime.Now;
                        it.Version  = Parameters.Version;
                        db.SaveChanges();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 获得凭证
        /// </summary>
        /// <param name="Account"></param>
        /// <param name="guid"></param>
        /// <param name="pLoginReturn"></param>
        /// <returns></returns>
        public bool Verification(string Account, string guid, out LoginReturn pLoginReturn)
        {
            pLoginReturn = new LoginReturn();
            try
            {
                using (JSZX_ResourceEntities db = new JSZX_ResourceEntities())
                {
                    var rls = (from t in db.Z_User where t.ID == Account select t).Take(1).ToList();

                    if (rls.Count > 0)
                    {
                        var pl = rls.First();

                        #region /*给返回类 赋值 start*/
                        //ID
                        pLoginReturn.ID = pl.ID;
                        //姓名
                        pLoginReturn.Name = pl.Name;
                        //权限ID
                        pLoginReturn.Role_ID = pl.PageRole_ID;
                        //类型
                        pLoginReturn.Type = pl.Type;

                        pLoginReturn.DataRole = pl.DataRole;
                        #endregion

                        return(true);
                    }
                }
            }
            catch (Exception ex) { string s = ex.Message; }
            return(false);
        }
Esempio n. 4
0
        /// <summary>
        /// 插入Z_Role
        /// </summary>
        /// <param name="id">角色ID</param>
        /// <param name="title">角色名称</param>
        /// <param name="remark">描述</param>
        /// <returns></returns>
        public bool Insert_Role(ref string id, string title, string remark)
        {
            try
            {
                using (JSZX_ResourceEntities db = new JSZX_ResourceEntities())
                {
                    id = Guid.NewGuid().ToString();

                    Z_Role it = new Z_Role();
                    it.ID       = id;
                    it.Title    = title;
                    it.Remark   = remark;
                    it.Del      = false;
                    it.EditMan  = "";
                    it.EditDate = DateTime.Now;
                    it.Version  = Parameters.Version;
                    db.Z_Role.Add(it);
                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 5
0
        /**获取新的版本号**/
        public int GetVersionNum(JSZX_ResourceEntities db, string AId)
        {
            List <string> OidArr = new List <string>();

            GetVersion(db, AId, ref OidArr);
            return(OidArr.Count + 1);
        }
Esempio n. 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="res_type"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public List <T_Resource> GetResourceList(string res_type, JSZX_ResourceEntities db)
        {
            List <T_Resource> rlt = null;
            var query             = from t in db.T_Resource
                                    select t;

            if (!string.IsNullOrEmpty(res_type))
            {
                query = query.Where(t => t.TYPE_ID.Contains(res_type));
            }
            //审核状态:通过(1)
            query = query.Where(t => t.STATUS.Contains("1"));
            //删除状态:未删除(0)
            query = query.Where(t => t.DEL_FLG.Contains("0"));
            //公开状态:公开(1)
            query = query.Where(t => t.SHARE_FLG.Contains("1"));
            int a = query.Count();

            query = query.OrderByDescending((t => t.CREATETIME));
            rlt   = query.ToList();
            DateTime dt = DateTime.Now.AddHours(0); //缓存6小时

            System.Web.HttpRuntime.Cache.Insert("T_Resource", rlt, null, dt, System.Web.Caching.Cache.NoSlidingExpiration);

            return(rlt);
        }
Esempio n. 7
0
 /**根据资源附件ID获取之前所有的版本ID**/
 private void GetVersion(JSZX_ResourceEntities db, string Aid, ref List <VersionModel> VersionList)
 {
     try
     {
         var query = from t in db.V_Version select t;
         query = query.Where(t => t.NID == Aid);
         query = query.OrderByDescending(t => t.CreateTime);
         List <V_Version> models = query.ToList();
         if (models != null && models.Count > 0)
         {
             foreach (V_Version model in models)
             {
                 VersionModel vModel = new VersionModel();
                 vModel.ID      = model.OID;
                 vModel.Name    = model.FileName;
                 vModel.Version = model.VERSION_NUM;
                 vModel.DtTime  = model.CreateTime;
                 VersionList.Add(vModel);
                 GetVersion(db, model.OID, ref VersionList);
             }
         }
         else
         {
             return;
         }
     }
     catch (Exception)
     {
         return;
     }
 }
Esempio n. 8
0
        /// <summary>
        /// 保存评价
        /// </summary>
        /// <param name="rm">评价信息</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool insertScore(ResourceModel rm, JSZX_ResourceEntities db)
        {
            try
            {
                T_Res_Score score = new T_Res_Score();
                score.ID         = Guid.NewGuid().ToString();
                score.RES_ID     = rm.Id;
                score.APPEND_ID  = rm.AppId;
                score.GRADE      = Convert.ToDecimal(rm.Grade);
                score.REVIEW     = rm.Review;
                score.CREATEID   = rm.UserId;
                score.CREATETIME = DateTime.Now;

                db.T_Res_Score.Add(score);

                AddReviewNum(rm.Id, rm.AppId, Convert.ToDouble(rm.Grade), rm.UserId, db);

                db.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("Resource", "insertScore", ex.Message);
                return(false);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 查询分类有无被使用
        /// </summary>
        /// <param name="typeId"></param>
        /// <returns></returns>
        public Boolean TypeIsUsed(string typeId)
        {
            bool ret = false;

            try
            {
                if (!string.IsNullOrEmpty(typeId))
                {
                    using (JSZX_ResourceEntities db = new JSZX_ResourceEntities())
                    {
                        string typeStr = GetTypeCondition(db, typeId);
                        var    query   = from t in db.T_Resource select t;
                        query = query.Where(t => typeStr.Contains(t.TYPE_ID));
                        query = query.Where(t => t.DEL_FLG == "0");//只需要判断没有被删除的资源当中,有没有使用该分类
                        if (query.Count() > 0)
                        {
                            ret = true;
                        }
                    }
                }
                else
                {
                    ret = true;
                }
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("Resource", "TypeIsUsed", "Error! " + ex.Message);
            }
            return(ret);
        }
Esempio n. 10
0
        /// <summary>
        /// 删除资源
        /// </summary>
        /// <param name="id">资源ID</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool deleteResource(string id, string userId, JSZX_ResourceEntities db)
        {
            try
            {
                T_Resource tr = db.T_Resource.First(t => t.ID == id);

                tr.DEL_FLG    = "1";
                tr.MODIFYID   = userId;
                tr.MODIFYTIME = DateTime.Now;

                List <T_Res_Appendix> list = db.T_Res_Appendix.Where(t => t.RES_ID == id).ToList();

                if (list != null)
                {
                    foreach (T_Res_Appendix item in list)
                    {
                        item.DEL_FLG    = "1";
                        item.MODIFYID   = userId;
                        item.MODIFYTIME = DateTime.Now;
                    }
                }

                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("Resource", "deleteResource", ex.Message);
                return(false);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 获取资源分类
        /// </summary>
        /// <param name="db"></param>
        /// <returns></returns>
        public List <ComboTreeModels> GetResTypeList(string type, JSZX_ResourceEntities db)
        {
            List <T_Res_Type> list = new List <T_Res_Type>();

            var query = from t in db.T_Res_Type orderby t.BELONG_ID, t.ID select t;

            query = query.OrderBy(t => t.CREATETIME);
            list  = query.ToList();

            List <ComboTreeModels> treeList = new List <ComboTreeModels>();

            if (list != null && list.Count > 0)
            {
                ReturnTreeList(list, null, 1, ref treeList);

                if (type == "combox")
                {
                    ComboTreeModels tree1 = new ComboTreeModels();
                    tree1.id     = "";
                    tree1.text   = "";
                    tree1.belong = "";
                    treeList.Insert(0, tree1);
                }
            }

            return(treeList);
        }
Esempio n. 12
0
        /// <summary>
        /// 新建分类
        /// </summary>
        /// <param name="type">分类名</param>
        /// <param name="father">分类名</param>
        /// <param name="userId">用户</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool insertResType(string type, string father, string userId, JSZX_ResourceEntities db)
        {
            try
            {
                T_Res_Type rt = new T_Res_Type();
                rt.ID = Guid.NewGuid().ToString();
                if (father != "-1")
                {
                    rt.BELONG_ID = father;
                }

                rt.NAME       = type;
                rt.CREATEID   = userId;
                rt.CREATETIME = DateTime.Now;

                db.T_Res_Type.Add(rt);
                db.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("Resource", "insertResType", ex.Message);
                return(false);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 前台管理 获取精品资源
        /// </summary>
        /// <param name="db"></param>
        /// <returns></returns>
        public List <View_Res_Appendix> GetExcellentAppendix(string typeFlag, JSZX_ResourceEntities db)
        {
            List <View_Res_Appendix> list = new List <View_Res_Appendix>();

            DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));

            var query = from t in db.View_Res_Appendix
                        where t.EXCELLENT_FLG == "1" &&
                        t.STATUS == "1" &&
                        t.DEL_FLG == "0" &&
                        t.APP_DEl_FLG == "0" &&
                        typeFlag.Contains(t.TYPE_FLG) &&
                        (t.IS_FOREVER == true || (t.IS_FOREVER == false && t.ACTIVE_TIME_START <= dt && t.ACTIVE_TIME_END >= dt))
                        select t;

            query = query.OrderByDescending(t => t.UPLOAD_TIME);

            if (typeFlag == "1")
            {
                list = query.Take(Constant.HOME_VIDEO_NUMBER).ToList();
            }
            else
            {
                list = query.Take(Constant.HOME_DOC_NUMBER).ToList();
            }

            return(list);
        }
Esempio n. 14
0
        /// <summary>
        /// 更新资源信息
        /// </summary>
        /// <param name="rm">资源信息</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool updateResource(ResourceModel rm, JSZX_ResourceEntities db)
        {
            try
            {
                T_Resource tr = db.T_Resource.First(t => t.ID == rm.Id);

                tr.NAME         = rm.Name;
                tr.TYPE_ID      = rm.TypeId;
                tr.INTRODUCTION = rm.Introduction;
                tr.STATUS       = "0";
                tr.LABEL        = rm.Label;
                tr.NOTE         = rm.Note;
                tr.MODIFYID     = rm.UserId;
                tr.MODIFYTIME   = DateTime.Now;

                doAppendix(rm, db);

                db.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("Resource", "updateResource", ex.Message);
                return(false);
            }
        }
Esempio n. 15
0
 /**根据资源附件ID获取之前所有的版本ID**/
 private void GetVersion(JSZX_ResourceEntities db, string Aid, ref List <string> OidArr)
 {
     try
     {
         var query = from t in db.T_Version select t;
         query = query.Where(t => t.NID == Aid);
         query = query.OrderByDescending(t => t.CreateTime);
         List <T_Version> models = query.ToList();
         if (models != null && models.Count > 0)
         {
             foreach (T_Version model in models)
             {
                 OidArr.Add(model.OID);
                 GetVersion(db, model.OID, ref OidArr);
             }
         }
         else
         {
             return;
         }
     }
     catch (Exception)
     {
         return;
     }
 }
Esempio n. 16
0
        /// <summary>
        /// 插入Z_Role_Menu
        /// </summary>
        /// <param name="role_id">角色ID</param>
        /// <param name="menus">菜单code串</param>
        /// <returns></returns>
        public bool Insert_Menus(string role_id, string menus)
        {
            try
            {
                using (JSZX_ResourceEntities db = new JSZX_ResourceEntities())
                {
                    string[] codes = menus.Split(',');
                    for (int i = 0; i < codes.Length; i++)
                    {
                        if (codes[i] != "")
                        {
                            Z_Role_Menu it = new Z_Role_Menu();
                            it.Role_ID   = role_id;
                            it.Menu_Code = codes[i];
                            it.Del       = false;
                            it.EditMan   = "";
                            it.EditDate  = DateTime.Now;
                            it.Version   = Parameters.Version;
                            db.Z_Role_Menu.Add(it);
                        }
                    }
                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// 根据分类获取附件总件数
        /// </summary>
        /// <param name="typeId">分类id</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public int GetFileSizeByTypeId(string typeId, string like, JSZX_ResourceEntities db)
        {
            DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));

            string typeStr = GetTypeCondition(db, typeId);
            var    query   = from t in db.AppendixByLike(like, dt) where typeStr.Contains(t.TYPE_ID) select t;

            return(query.Count());
        }
Esempio n. 18
0
        /// <summary>
        /// 获取资源评分
        /// </summary>
        /// <param name="id">资源ID</param>
        /// <param name="db"></param>
        /// <returns>资源评分信息</returns>
        public List <View_Score> GetResourceScoreGrade(string id, JSZX_ResourceEntities db)
        {
            List <View_Score> list = null;

            var query = from t in db.View_Score where t.RES_ID == id select t;

            list = query.ToList();

            return(list);
        }
Esempio n. 19
0
        /// <summary>
        /// 获取附件信息
        /// </summary>
        /// <param name="id">资源ID</param>
        /// <param name="db"></param>
        /// <returns>附件信息</returns>
        public List <T_Res_Appendix> GetAppendixList(string id, JSZX_ResourceEntities db)
        {
            List <T_Res_Appendix> list = new List <T_Res_Appendix>();

            var query = from t in db.T_Res_Appendix where t.DEL_FLG == "0" && t.RES_ID == id select t;

            list = query.ToList();

            return(list);
        }
Esempio n. 20
0
        /// <summary>
        /// 获取资源提问信息
        /// </summary>
        /// <param name="id">资源ID</param>
        /// <param name="db"></param>
        /// <returns>提问信息</returns>
        public List <View_Qa> GetResQa(string id, JSZX_ResourceEntities db)
        {
            List <View_Qa> list = null;

            var query = from t in db.View_Qa where t.ID == id select t;

            list = query.ToList();

            return(list);
        }
Esempio n. 21
0
        /// <summary>
        /// 根据类型获取所有子类型
        /// </summary>
        /// <param name="db"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public string GetTypeCondition(JSZX_ResourceEntities db, string type)
        {
            List <T_Res_Type> list = new List <T_Res_Type>();
            var query = from t in db.T_Res_Type orderby t.BELONG_ID, t.ID select t;

            list = query.ToList();
            string ret = type + ",";

            ReturnTypeStr(list, type, ref ret);
            return(ret);
        }
Esempio n. 22
0
        /// <summary>
        /// 更新附件信息
        /// </summary>
        /// <param name="rm">附件id</param>
        /// <param name="db"></param>
        private void updateAppendix(AppendixModel am, JSZX_ResourceEntities db)
        {
            T_Res_Appendix app = db.T_Res_Appendix.FirstOrDefault(t => t.ID == am.Id);

            app.AUTHOR            = am.Author;
            app.ACTIVE_TIME_START = am.GetStartTime();
            app.ACTIVE_TIME_END   = am.GetEndTime();
            app.MODIFYID          = am.ModifyId;
            app.MODIFYTIME        = DateTime.Now;
            app.IS_FOREVER        = am.getIsForever();
        }
Esempio n. 23
0
        /// <summary>
        /// 记录下载数
        /// </summary>
        /// <param name="id">资源id</param>
        /// <param name="appId">附件id</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool AddDownLoadNum(string id, string appId, string userId, JSZX_ResourceEntities db)
        {
            T_Res_Result result = null;

            try
            {
                //var query = from t in db.T_Res_Result
                //            where t.RES_ID == id && t.APPEND_ID == appId
                //            select t;
                //资源ID不作为条件检索数据,附件ID唯一,才是关键字
                var query = from t in db.T_Res_Result
                            where t.APPEND_ID == appId
                            select t;

                List <T_Res_Result> list = query.ToList();

                if (list == null || list.Count == 0)
                {
                    result              = new T_Res_Result();
                    result.ID           = Guid.NewGuid().ToString();
                    result.RES_ID       = id;
                    result.APPEND_ID    = appId;
                    result.DOWNLOAD_NUM = 1;
                    result.CREATEID     = userId;
                    result.CREATETIME   = DateTime.Now;

                    db.T_Res_Result.Add(result);
                    db.SaveChanges();
                }
                else
                {
                    //result = db.T_Res_Result.First(t => t.APPEND_ID == appId && t.RES_ID == id);
                    //资源ID不作为条件检索数据,附件ID唯一,才是关键字
                    result = db.T_Res_Result.First(t => t.APPEND_ID == appId);

                    int downloadNum = Convert.ToInt32(result.DOWNLOAD_NUM);
                    downloadNum = downloadNum + 1;

                    result.DOWNLOAD_NUM = downloadNum;
                    result.MODIFYID     = userId;
                    result.MODIFYTIME   = DateTime.Now;

                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("Resource", "AddDownLoadNum", ex.Message);
                return(false);
            }
        }
Esempio n. 24
0
        /// <summary>
        /// 获取分类和其子分类id
        /// </summary>
        /// <param name="typeId"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        private string[] GetAllType(string typeId, JSZX_ResourceEntities db)
        {
            string[] type = { };

            var query = from t in db.T_Res_Type
                        where t.ID == typeId || t.BELONG_ID == typeId
                        select t.ID;

            type = query.ToArray();

            return(type);
        }
Esempio n. 25
0
        //#region 获取ftp地址,上传文件大小信息
        ///// <summary>
        ///// 获取ftp地址,上传文件大小信息
        ///// </summary>
        ///// <param name="db"></param>
        ///// <returns></returns>
        //public Z_FTP_Parameters GetFtpInfo(GM_BasiceEntities db)
        //{
        //    Z_FTP_Parameters ftp = null;

        //    var query = from t in db.Z_FTP_Parameters select t;
        //    query = query.OrderByDescending(t => t.EditDate);
        //    ftp = query.FirstOrDefault();

        //    return ftp;
        //}
        //#endregion

        /// <summary>
        /// 安全退出
        /// </summary>
        /// <param name="guid"></param>
        public void outLogin(string guid)
        {
            #region /*更改数据库信息 start*/
            JSZX_ResourceEntities db = new JSZX_ResourceEntities();
            var rlt = (from t in db.Z_User
                       where t.GUID == guid
                       select t).Take(1).ToList();
            var up = rlt.First();
            up.GUID = "";
            //保存数据
            db.SaveChanges();
            #endregion
        }
Esempio n. 26
0
 public Boolean DelType(string typeID, JSZX_ResourceEntities db)
 {
     try
     {
         DelTypeList(typeID, db);
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         clsLog.ErrorLog(clsName, "DelType", ex.Message);
         return(false);
     }
 }
Esempio n. 27
0
 /**获取最新版本信息和之前版本号**/
 public T_Res_Appendix GetVersionContrast(JSZX_ResourceEntities db, string Aid, ref List <VersionModel> VersionList)
 {
     try
     {
         T_Res_Appendix model = db.T_Res_Appendix.First(t => t.ID == Aid);
         GetVersion(db, Aid, ref VersionList);
         return(model);
     }
     catch (Exception ex)
     {
         clsLog.ErrorLog("Resource", "GetVersionContrast", "Error! " + ex.Message);
         return(null);
     }
 }
Esempio n. 28
0
 public Boolean AddType(T_Res_Type newType, JSZX_ResourceEntities db)
 {
     try
     {
         db.T_Res_Type.Add(newType);
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         clsLog.ErrorLog(clsName, "AddType", ex.Message);
         return(false);
     }
 }
Esempio n. 29
0
        /// <summary>
        /// 根据id获取分类
        /// </summary>
        /// <param name="id">分类id</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public T_Res_Type GetTypeById(string id, JSZX_ResourceEntities db)
        {
            T_Res_Type type = new T_Res_Type();

            var query = from t in db.T_Res_Type where t.ID == id select t;

            List <T_Res_Type> typeList = query.ToList();

            if (typeList != null)
            {
                type = typeList[0];
            }

            return(type);
        }
Esempio n. 30
0
        /// <summary>
        /// 获取资源详细信息
        /// </summary>
        /// <param name="id">资源ID</param>
        /// <param name="db"></param>
        /// <returns>资源详细信息</returns>
        public View_Resource GetResourceDetail(string id, JSZX_ResourceEntities db)
        {
            View_Resource        detail = new View_Resource();
            List <View_Resource> list   = null;

            var query = from t in db.View_Resource where t.DEL_FLG == "0" && t.ID == id select t;

            list = query.ToList();
            if (list != null && list.Count > 0)
            {
                detail = list[0];
            }

            return(detail);
        }