Пример #1
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();
        }
Пример #2
0
        /// <summary>
        /// 删除附件信息
        /// </summary>
        /// <param name="rm">附件id</param>
        /// <param name="db"></param>
        private void DeleteAppendix(AppendixModel am, JSZX_ResourceEntities db)
        {
            T_Res_Appendix app = db.T_Res_Appendix.FirstOrDefault(t => t.ID == am.Id);

            app.DEL_FLG    = "1";
            app.MODIFYID   = am.ModifyId;
            app.MODIFYTIME = DateTime.Now;

            //删除评价信息
            var query = from t in db.T_Res_Score where t.APPEND_ID == am.Id select t;
            List <T_Res_Score> scoList = query.ToList();

            if (scoList != null)
            {
                foreach (T_Res_Score item in scoList)
                {
                    db.T_Res_Score.Remove(item);
                    db.SaveChanges();
                }
            }

            //删除问题信息
            var             query2 = from t in db.T_Res_Qa where t.APPEND_ID == am.Id select t;
            List <T_Res_Qa> qaList = query2.ToList();

            if (qaList != null)
            {
                foreach (T_Res_Qa item in qaList)
                {
                    db.T_Res_Qa.Remove(item);
                    db.SaveChanges();
                }
            }

            //删除评价结果表
            var query3 = from t in db.T_Res_Result where t.APPEND_ID == am.Id select t;
            List <T_Res_Result> resList = query3.ToList();

            if (resList != null)
            {
                foreach (T_Res_Result item in resList)
                {
                    db.T_Res_Result.Remove(item);
                    db.SaveChanges();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 插入附件信息
        /// </summary>
        /// <param name="rm">附件id</param>
        /// <param name="db"></param>
        private void insertAppendix(AppendixModel am, JSZX_ResourceEntities db)
        {
            T_Res_Appendix tra = new T_Res_Appendix();

            tra.ID                = am.Id;
            tra.RES_ID            = am.Res_Id;
            tra.FILE_NAME         = am.FileName;
            tra.UPLOAD_TIME       = am.GetUploadTime();
            tra.AUTHOR            = am.Author;
            tra.ACTIVE_TIME_START = am.GetStartTime();
            tra.ACTIVE_TIME_END   = am.GetEndTime();
            tra.IS_FOREVER        = am.getIsForever();

            tra.CREATEID   = am.CreateId;
            tra.CREATETIME = DateTime.Now;

            tra.DEL_FLG  = "0";
            tra.FILE_URL = am.FileUrl;
            tra.TYPE_FLG = am.TypeFlg;

            db.T_Res_Appendix.Add(tra);

            T_ToChange change = new T_ToChange();

            change.ID             = Guid.NewGuid().ToString();
            change.FileName       = am.Id;
            change.SourceFilePath = am.FileUrl;
            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='" + am.Id + "'";

            change.RetSql   = sql;
            change.TaskTime = DateTime.Now;

            db.T_ToChange.Add(change);
        }
Пример #4
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);
                    }
                }
            }
        }