예제 #1
0
 public HttpResponseMessage UpdatePublishStatue([FromBody] AcademicResources Param)
 {
     try
     {
         AcademicResourcesProvider _Provider = new AcademicResourcesProvider();
         var result = _Provider.UpdatePublishStatue(Param);
         return(Request.CreateResponse(HttpStatusCode.OK, result));
     }
     catch (Exception ex)
     {
         LogFactory _LogFactory = new LogFactory(this.GetType());
         _LogFactory.CreateLog(LogType.Error, "修改学术资源发布状态", "UpdateAcademicResources", ex);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
예제 #2
0
        /// <summary>
        /// 获取学术资源详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private AcademicResources GetAcademicResources(int id)
        {
            AcademicResources result = new AcademicResources();

            try
            {
                string sql = "select * from de2_aresource where id=@id ";
                //执行sql
                MySqlClient _Client = new MySqlClient();
                result = _Client.ExecuteQuery <AcademicResources>(sql, new MySqlParameter("@id", id)).FirstOrDefault();
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "获取学术资源详情", "GetAcademicResources", ex);
            }
            return(result);
        }
예제 #3
0
 /// <summary>
 /// 删除学术资源
 /// </summary>
 /// <param name="Resource"></param>
 /// <returns></returns>
 private bool DelAcademicResources(AcademicResources Resource)
 {
     try
     {
         //删除子文章
         if (Resource.isChild)
         {
             if (DelAcademicResourcesByParentID(Resource.id))
             {
                 return(false);
             }
         }
         //删除目录
         if (Resource.isMenu)
         {
             if (DelMenuByParent(Resource.id))
             {
                 return(false);
             }
         }
         //删除上传文件
         DelResourcesFileByParent(Resource.id);
         //生成sql
         StringBuilder sql = new StringBuilder();
         sql.AppendLine(@"delete from   de2_aresource where id=@id");
         //执行sql语句
         MySqlClient _Client = new MySqlClient();
         _Client.ExecuteNonQuery(sql.ToString(), new MySqlParameter("@id", Resource.id));
         return(true);
     }
     catch (Exception ex)
     {
         LogFactory _LogFactory = new LogFactory(this.GetType());
         _LogFactory.CreateLog(LogType.Error, "删除学术资源", "DelAcademicResources", ex);
         return(false);
     }
 }
예제 #4
0
        /// <summary>
        /// 修改学术资源发布状态
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        public BaseResopne <string> UpdatePublishStatue(AcademicResources Data)
        {
            BaseResopne <string> result = new BaseResopne <string>();

            try
            {
                //获取当前登录人
                AccountProvider _AccountProvider = new AccountProvider();
                var             user             = _AccountProvider.GetCurrentUser();
                if (user == null)
                {
                    result.IsSuccess = false;
                    result.Error     = "获取当前用户信息失败";
                    return(result);
                }
                Data.lastModifyTime  = DateTime.Now;
                Data.lastModifyUsrID = user.id;

                StringBuilder sql = new StringBuilder();
                sql.AppendLine(@"update  de2_aresource set isPublish=@isPublish,lastModifyTime=@lastModifyTime,lastModifyUsrID=@lastModifyUsrID where id=@id");
                //执行sql语句
                MySqlClient _Client = new MySqlClient();
                _Client.ExecuteNonQuery(sql.ToString()
                                        , new MySqlParameter("@isPublish", Data.isPublish)
                                        , new MySqlParameter("@lastModifyTime", Data.lastModifyTime)
                                        , new MySqlParameter("@lastModifyUsrID", Data.lastModifyUsrID)
                                        , new MySqlParameter("@id", Data.id));
                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "修改学术资源发布状态", "UpdatePublishStatue", ex);
                result.IsSuccess = false;
            }
            return(result);
        }
예제 #5
0
        /// <summary>
        /// 修改学术资源信息
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        public BaseResopne <string> UpdateAcademicResources(AcademicResources Data)
        {
            BaseResopne <string> result = new BaseResopne <string>();

            try
            {
                //获取当前登录人
                AccountProvider _AccountProvider = new AccountProvider();
                var             user             = _AccountProvider.GetCurrentUser();
                if (user == null)
                {
                    result.IsSuccess = false;
                    result.Error     = "获取当前用户信息失败";
                    return(result);
                }
                Data.lastModifyTime  = DateTime.Now;
                Data.lastModifyUsrID = user.id;
                //生成sql
                StringBuilder sql = new StringBuilder();
                sql.AppendLine(@"update  de2_aresource set `name`=@`name`,parentID=@parentID,sourceTypeID=@sourceTypeID,isChild=@,author=@,isPublish=@isPublish,`year`=@`year`,periodNumber=@periodNumber,lastModifyTime=@lastModifyTime,lastModifyUsrID=@lastModifyUsrID,isMenu=@isMenu where id=@id");
                //执行sql语句
                MySqlClient _Client = new MySqlClient();
                _Client.ExecuteNonQuery(sql.ToString()
                                        , new MySqlParameter("@`name`", Data.name)
                                        , new MySqlParameter("@parentID", Data.parentID)
                                        , new MySqlParameter("@sourceTypeID", Data.sourceTypeID)
                                        , new MySqlParameter("@isChild", Data.isChild)
                                        , new MySqlParameter("@author", Data.author)
                                        , new MySqlParameter("@isPublish", Data.isPublish)
                                        , new MySqlParameter("@`year`", Data.year)
                                        , new MySqlParameter("@periodNumber", Data.periodNumber)
                                        , new MySqlParameter("@lastModifyTime", Data.lastModifyTime)
                                        , new MySqlParameter("@lastModifyUsrID", Data.lastModifyUsrID)
                                        , new MySqlParameter("@isMenu", Data.isMenu)
                                        , new MySqlParameter("@id", Data.id));
                //判断文件路径是否为空
                if (string.IsNullOrEmpty(Data.resourceFile))
                {
                    AcademicResources_File _AcademicResources_File = new AcademicResources_File();
                    _AcademicResources_File.lastModifyTime  = DateTime.Now;
                    _AcademicResources_File.lastModifyUsrID = user.id;
                    _AcademicResources_File.parentID        = Data.id;
                    _AcademicResources_File.sourceTypeID    = Data.sourceTypeID;
                    _AcademicResources_File.targetFileUrl   = Data.resourceFile;
                    _AcademicResources_File.title           = Data.name;
                    UpdateResourcesFile(_AcademicResources_File);
                }
                else
                {
                    DelResourcesFileByParent(Data.id);
                }
                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "修改学术资源信息", "UpdateAcademicResources", ex);
                result.IsSuccess = false;
            }
            return(result);
        }
예제 #6
0
        /// <summary>
        /// 保存学术资源信息
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        public BaseResopne <Int32> AddAcademicResources(AcademicResources Data)
        {
            BaseResopne <Int32> result = new BaseResopne <Int32>();

            try
            {
                //获取当前登录人
                AccountProvider _AccountProvider = new AccountProvider();
                var             user             = _AccountProvider.GetCurrentUser();
                if (user == null)
                {
                    result.IsSuccess = false;
                    result.Error     = "获取当前用户信息失败";
                    return(result);
                }
                Data.createUserID    = user.id;
                Data.createTime      = DateTime.Now;
                Data.lastModifyTime  = DateTime.Now;
                Data.lastModifyUsrID = user.id;
                //生成sql
                StringBuilder sql = new StringBuilder();
                sql.AppendLine(@"insert into de2_aresource (`name`,parentID,sourceTypeID,createTime,createUserID,isChild,author,isPublish,`year`,periodNumber,lastModifyTime,lastModifyUsrID,isMenu) values(@`name`,@parentID,@sourceTypeID,@createTime,@createUserID,@isChild,@author,@isPublish,@`year`,@periodNumber,@lastModifyTime,@lastModifyUsrID,@isMenu)");
                //执行sql语句
                MySqlClient _Client    = new MySqlClient();
                var         ResourceID = _Client.Inster(sql.ToString()
                                                        , new MySqlParameter("@`name`", Data.name)
                                                        , new MySqlParameter("@parentID", Data.parentID)
                                                        , new MySqlParameter("@sourceTypeID", Data.sourceTypeID)
                                                        , new MySqlParameter("@createTime", Data.createTime)
                                                        , new MySqlParameter("@createUserID", Data.createUserID)
                                                        , new MySqlParameter("@isChild", Data.isChild)
                                                        , new MySqlParameter("@author", Data.author)
                                                        , new MySqlParameter("@isPublish", Data.isPublish)
                                                        , new MySqlParameter("@`year`", Data.year)
                                                        , new MySqlParameter("@periodNumber", Data.periodNumber)
                                                        , new MySqlParameter("@lastModifyTime", Data.lastModifyTime)
                                                        , new MySqlParameter("@lastModifyUsrID", Data.lastModifyUsrID)
                                                        , new MySqlParameter("@isMenu", Data.isMenu));
                result.Data = Convert.ToInt32(ResourceID);
                //判断文件路径是否为空
                if (!string.IsNullOrEmpty(Data.resourceFile))
                {
                    AcademicResources_File _AcademicResources_File = new AcademicResources_File();
                    _AcademicResources_File.lastModifyTime  = DateTime.Now;
                    _AcademicResources_File.lastModifyUsrID = user.id;
                    _AcademicResources_File.createTime      = DateTime.Now;
                    _AcademicResources_File.createUserID    = user.id;
                    _AcademicResources_File.parentID        = Convert.ToInt32(ResourceID);
                    _AcademicResources_File.sourceTypeID    = Data.sourceTypeID;
                    _AcademicResources_File.targetFileUrl   = Data.resourceFile;
                    _AcademicResources_File.title           = Data.name;
                    AddResourcesFile(_AcademicResources_File);
                }
                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "保存学术资源信息", "AddAcademicResources", ex);
                result.IsSuccess = false;
            }
            return(result);
        }