Ejemplo n.º 1
0
        /// <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);
            }
        }
Ejemplo n.º 2
0
        /// <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);
            }
        }
Ejemplo n.º 3
0
        /// <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);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 保存提问
        /// </summary>
        /// <param name="rm">提问信息</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool insertQa(ResourceModel rm, JSZX_ResourceEntities db)
        {
            try
            {
                T_Res_Qa qa = new T_Res_Qa();
                qa.ID         = Guid.NewGuid().ToString();
                qa.RES_ID     = rm.Id;
                qa.APPEND_ID  = rm.AppId;
                qa.QUESTION   = rm.Question;
                qa.CREATEID   = rm.UserId;
                qa.CREATETIME = DateTime.Now;

                db.T_Res_Qa.Add(qa);

                db.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("Resource", "insertQa", ex.Message);
                return(false);
            }
        }
Ejemplo n.º 5
0
        /// <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);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 保存附件信息
        /// </summary>
        /// <param name="rm">附件信息</param>
        /// <param name="db"></param>
        private void doAppendix(ResourceModel rm, JSZX_ResourceEntities db)
        {
            string[] fileNames   = rm.FileName;
            string[] saveNames   = rm.SaveName;
            string[] authors     = rm.Author;
            string[] activeStart = rm.ActiveTimeStart;
            string[] activeEnd   = rm.ActiveTimeEnd;
            string[] uploadTime  = rm.UploadTime;
            string[] fileType    = rm.FileType;
            string[] fileUrl     = rm.FileUrl;
            string[] dataType    = rm.DataType;
            string[] isForever   = rm.isForever;

            if (fileNames != null)
            {
                for (int i = 0; i < fileNames.Length; i++)
                {
                    string saveName = saveNames[i];

                    string ext = "";
                    string id  = saveName;
                    if (fileNames[i] != null && fileNames[i].LastIndexOf('.') > 0)
                    {
                        id  = saveName.Substring(0, saveName.LastIndexOf('.'));
                        ext = fileNames[i].Substring(fileNames[i].LastIndexOf('.'), fileNames[i].Length - fileNames[i].LastIndexOf('.')).ToLower();
                    }

                    AppendixModel am = null;
                    if (dataType[i] == "add")
                    {
                        am = new AppendixModel();

                        am.Id       = id;
                        am.Res_Id   = rm.Id;
                        am.FileName = fileNames[i];
                        am.SaveName = saveName;
                        am.Ext      = ext;
                        am.Author   = authors[i];
                        am.SetUploadTime(uploadTime[i]);
                        am.SetStartTime(activeStart[i]);
                        am.SetEndTime(activeEnd[i]);
                        am.FileUrl  = fileUrl[i];
                        am.TypeFlg  = fileType[i];
                        am.CreateId = rm.UserId;
                        am.setIsForever(isForever[i]);

                        insertAppendix(am, db);
                    }
                    else if (dataType[i] == "update")
                    {
                        am        = new AppendixModel();
                        am.Id     = id;
                        am.Author = authors[i];
                        am.SetStartTime(activeStart[i]);
                        am.SetEndTime(activeEnd[i]);
                        am.ModifyId = rm.UserId;
                        am.setIsForever(isForever[i]);

                        updateAppendix(am, db);
                    }
                    else if (dataType[i] == "delete")
                    {
                        am          = new AppendixModel();
                        am.Id       = id;
                        am.ModifyId = rm.UserId;
                        DeleteAppendix(am, db);
                    }
                    /**更新资源附件 2014-12-19 5920 **/
                    else //前台更新了附件 此时的dataType是旧的附件ID
                    {
                        string OldFileID = dataType[i];
                        /**逻辑删除旧的附件**/
                        T_Res_Appendix app = db.T_Res_Appendix.FirstOrDefault(t => t.ID == OldFileID);
                        app.DEL_FLG    = "1";
                        app.MODIFYID   = rm.UserId;
                        app.MODIFYTIME = DateTime.Now;
                        /**添加新的附件**/
                        am          = new AppendixModel();
                        am.Id       = id;
                        am.Res_Id   = rm.Id;
                        am.FileName = fileNames[i];
                        am.SaveName = saveName;
                        am.Ext      = ext;
                        am.SetUploadTime(uploadTime[i]);
                        am.Author = authors[i];
                        am.SetStartTime(activeStart[i]);
                        am.SetEndTime(activeEnd[i]);
                        am.FileUrl  = fileUrl[i];
                        am.TypeFlg  = fileType[i];
                        am.CreateId = rm.UserId;
                        am.setIsForever(isForever[i]);

                        insertAppendix(am, db);

                        /**记录下版本更新**/
                        T_Version model = new T_Version();
                        model.ID          = Guid.NewGuid().ToString();
                        model.NID         = id;
                        model.OID         = OldFileID;
                        model.VERSION_NUM = GetVersionNum(db, OldFileID); //这边需要算出之前的所有版本
                        model.USERID      = rm.UserId;
                        model.CreateTime  = DateTime.Now;
                        db.T_Version.Add(model);
                    }
                }
            }
        }