/// <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);
            }
        }
        /// <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);
            }
        }
        /// <summary>
        /// 批量删除资源
        /// </summary>
        /// <param name="rm">资源ID</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool deleteResource2(ResourceModel rm, JSZX_ResourceEntities db)
        {
            string[] ids      = rm.Ids;
            string[] isSelect = rm.isSelect;
            string   userId   = rm.UserId;

            try
            {
                if (ids != null)
                {
                    for (int i = 0; i < ids.Length; i++)
                    {
                        if (isSelect[i] == "1")
                        {
                            string     id = ids[i];
                            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", "deleteResource2", ex.Message);
                return(false);
            }
        }
        /// <summary>
        /// 保存资源信息
        /// </summary>
        /// <param name="rm">资源信息</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool insertResource(ResourceModel rm, JSZX_ResourceEntities db)
        {
            try
            {
                T_Resource tr = new T_Resource();
                tr.ID            = rm.Id;
                tr.NAME          = rm.Name;
                tr.TYPE_ID       = rm.TypeId;
                tr.INTRODUCTION  = rm.Introduction;
                tr.LABEL         = rm.Label;
                tr.NOTE          = rm.Note;
                tr.STATUS        = "0";
                tr.DEL_FLG       = "0";
                tr.ORIGIN_FLG    = "1";
                tr.SHARE_FLG     = "1";
                tr.EXCELLENT_FLG = "0";
                tr.CREATEID      = rm.UserId;
                tr.CREATETIME    = DateTime.Now;
                tr.MODIFYID      = rm.UserId;
                tr.MODIFYTIME    = DateTime.Now;

                db.T_Resource.Add(tr);

                doAppendix(rm, db);

                db.SaveChanges();

                //上传资源时,可以获得积分
                PointRule pr = new PointRule();
                pr.AddPoint(tr.ID, tr.MODIFYID, "0");
                //上传资源时,可以获得积分

                return(true);
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("Resource", "insertResource", ex.Message);
                return(false);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="rm"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool examineResource(ResourceModel rm, JSZX_ResourceEntities db)
        {
            try
            {
                T_Resource tr = db.T_Resource.First(t => t.ID == rm.Id);

                tr.TYPE_ID       = rm.TypeId;
                tr.INTRODUCTION  = rm.Introduction;
                tr.LABEL         = rm.Label;
                tr.STATUS        = rm.Status;
                tr.EXCELLENT_FLG = rm.Excellent_Flg;
                tr.MODIFYID      = rm.UserId;
                tr.MODIFYTIME    = DateTime.Now;
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("Resource", "examineResource", ex.Message);
                return(false);
            }
        }
        /// <summary>
        /// 批量审核资源
        /// </summary>
        /// <param name="rm"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool examineResource2(ResourceModel rm, JSZX_ResourceEntities db)
        {
            string[] ids          = rm.Ids;
            string[] isSelect     = rm.isSelect;
            string   status       = rm.Status;
            string   excellentFlg = rm.Excellent_Flg;
            string   userId       = rm.UserId;

            try
            {
                if (ids != null)
                {
                    for (int i = 0; i < ids.Length; i++)
                    {
                        if (isSelect[i] == "1")
                        {
                            string     id = ids[i];
                            T_Resource tr = db.T_Resource.First(t => t.ID == id);

                            tr.STATUS        = status;
                            tr.EXCELLENT_FLG = excellentFlg;
                            tr.MODIFYID      = userId;
                            tr.MODIFYTIME    = DateTime.Now;
                        }
                    }
                }

                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("Resource", "examineResource2", ex.Message);
                return(false);
            }
        }
        /// <summary>
        /// 大文件上传数据保存
        /// </summary>
        /// <param name="model"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public Boolean JavaUploadSaveData(JavaUploadModel model, JSZX_ResourceEntities db)
        {
            try
            {
                #region 资源
                T_Resource rModel = new T_Resource();
                rModel.ID            = model.ID;
                rModel.NAME          = model.Name;
                rModel.TYPE_ID       = model.TypeID;
                rModel.INTRODUCTION  = model.Introduction;
                rModel.LABEL         = model.Label;
                rModel.NOTE          = model.Note;
                rModel.STATUS        = "0";
                rModel.DEL_FLG       = "0";
                rModel.ORIGIN_FLG    = "1";
                rModel.SHARE_FLG     = "1";
                rModel.EXCELLENT_FLG = "0";
                rModel.CREATEID      = model.CreateID;
                rModel.CREATETIME    = DateTime.Now;
                db.T_Resource.Add(rModel);
                #endregion

                #region 附件
                if (model.FileUrl != null && model.FileUrl.Length > 0)
                {
                    #region 循环插入附件
                    for (int i = 0; i < model.FileUrl.Length; i++)
                    {
                        string path     = model.FileUrl[i];
                        string fileType = Constant.GetFileType(System.IO.Path.GetExtension(path));
                        string fileID   = System.IO.Path.GetFileNameWithoutExtension(path);

                        T_Res_Appendix aModel = new T_Res_Appendix();
                        aModel.ID                = fileID;
                        aModel.RES_ID            = model.ID;
                        aModel.FILE_NAME         = model.FileName[i];
                        aModel.UPLOAD_TIME       = DateTime.Now;
                        aModel.AUTHOR            = model.Author;
                        aModel.ACTIVE_TIME_START = StringToDateTime(model.ActiveTimeStart);
                        aModel.ACTIVE_TIME_END   = StringToDateTime(model.ActiveTimeEnd);
                        aModel.CREATEID          = model.CreateID;
                        aModel.CREATETIME        = DateTime.Now;
                        aModel.DEL_FLG           = "0";
                        aModel.FILE_URL          = path;
                        aModel.TYPE_FLG          = fileType;
                        aModel.IS_FOREVER        = model.isForever == "1" ? true : false;
                        db.T_Res_Appendix.Add(aModel);

                        #region 转换任务
                        T_ToChange change = new T_ToChange();
                        change.ID             = Guid.NewGuid().ToString();
                        change.FileName       = fileID;
                        change.SourceFilePath = path;
                        change.TargetFilePath = Constant.DISK_ADDRESS + Constant.UPLOADDIRECTORY + "\\" + Constant.SWFDIRECTORY;
                        string sql = "update JSZX_Resource.dbo.T_Res_Appendix set READ_URL=@TargetFilePath,[IMAGE]=@FileFirstImg,[PAGECOUNT]=@PageCount where ID='" + fileID + "'";
                        change.RetSql   = sql;
                        change.TaskTime = DateTime.Now;
                        db.T_ToChange.Add(change);
                        #endregion
                    }
                    #endregion
                    db.SaveChanges();
                    return(true);
                }
                else
                {
                    clsLog.ErrorLog("Resource", "ShareResource", "Error! 缺少必要的附件!");
                    return(false);
                }
                #endregion
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("Resource", "JavaUploadSaveData", "Error! " + ex.Message);
                return(false);
            }
        }