Exemple #1
0
        /// <summary>
        /// 保存评论的上传附件,返回关联文件
        /// </summary>
        /// <param name="repid"></param>
        /// <param name="filesid"></param>
        public List <FileTemp> ContentReplyFiles(long repid, string filesid)
        {
            //返回文件集合
            List <FileTemp> listFileTemp = new List <FileTemp>();

            var listFile = filesid.Split(',');

            //var reapFile = _contentReplyFileRepository.GetAll().Where(a => a.ContentReplyId==repid);

            //删除原来的评论上传文件
            //foreach (var item in reapFile)
            //{
            //    _contentReplyFileRepository.Delete(item);
            //}
            //新增上传文件
            if (listFile.Count() > 0)
            {
                foreach (var item in listFile)
                {
                    if (item != "" && item != "删除")
                    {
                        var fileId = item.ToInt32();
                        if (fileId != 0)
                        {
                            ContentReplyFile rfiles = new ContentReplyFile
                            {
                                ContentReplyId = repid,
                                FileId         = fileId
                            };
                            _contentReplyFileRepository.Insert(rfiles);
                            //根据文件ID查询出上传文件,并加入返回集合
                            var File_Id = _filesRepository.Get(fileId);
                            var filetp  = new FileTemp();
                            filetp.Id     = File_Id.Id;
                            filetp.Name   = File_Id.TrueName;
                            filetp.Length = File_Id.Length;
                            if (File_Id.Length > 1024 * 1024)
                            {
                                filetp.LengthKb = ((double)(File_Id.Length * 100 / (1024 * 1024)) / 100) + "MB";
                            }
                            else
                            {
                                filetp.LengthKb = ((double)(File_Id.Length * 100 / 1024) / 100) + "KB";
                            }
                            filetp.Uptime = File_Id.UploadTime;
                            filetp.Upurl  = File_Id.Url;

                            listFileTemp.Add(filetp);
                        }
                    }
                }
            }
            return(listFileTemp);
        }
Exemple #2
0
        /// <summary>
        /// 新增评论
        /// </summary>
        /// <param name="contentId"></param>
        /// <param name="replyInfo"></param>
        /// <param name="fileIds">评论上传附件集合</param>
        /// <param name="replyId"></param>
        /// <returns></returns>
        public object CerateReply(int contentId, string replyInfo, string fileIds, int?replyId)
        {
            ContentReply reply = new ContentReply();

            reply.Info         = replyInfo;
            reply.ContentId    = contentId;
            reply.CreationTime = DateTime.Now;
            if (replyId != null)
            {
                reply.ParentId = (long)replyId;
            }
            else
            {
                reply.ParentId = null;
            }
            if (AbpSession.UserId != null)
            {
                reply.DeleteUid = (long)AbpSession.UserId;//因有约束条件FK_EM_CONTENT_REPLY_DELETE_UID 则删除人默认等于创建人
                reply.ReolyUId  = (long)AbpSession.UserId;
                //reply.ReplyUser = _userRepository.Get(reply.ReolyUId);
            }
            var rId = _contentReplyRepository.InsertAndGetId(reply);
            //保存评论附件上传文件
            //上传附件ID集合
            var fileIdList = fileIds.Split(',');
            int fileNumber = 0;

            if (fileIdList.Count() > 0)
            {
                //保存上传附件和评论ID
                foreach (var item in fileIdList)
                {
                    if (item != "" && item != "删除")
                    {
                        var fileId = item.ToInt32();
                        if (fileId != 0)
                        {
                            ContentReplyFile rfiles = new ContentReplyFile
                            {
                                ContentReplyId = rId,
                                FileId         = fileId
                            };
                            _contentReplyFileRepository.Insert(rfiles);
                            fileNumber++;
                        }
                    }
                }
            }
            var        result = _contentReplyRepository.Get(rId);
            ReplyModel rm     = new ReplyModel
            {
                Info          = result.Info,
                ContentId     = result.ContentId,
                Id            = result.Id,
                CreationTime  = result.CreationTime,
                ReplyUserName = _userRepository.Get(result.ReolyUId).Name,
                //返回上传附件数量,刚刚上传,查询不出来
                //IsFileNumber=_contentReplyFileRepository.GetAll().Count(x=>x.ContentReplyId== result.Id)
                IsFileNumber = fileNumber
            };

            if (result.ParentId != null)
            {
                rm.ParentName = _contentReplyRepository.FirstOrDefault((long)result.ParentId).ReplyUser.Name;
            }
            var content    = _contentRepository.Get(contentId);
            var defineType = _contentTypeRepository.Get(content.DefineTypeId);
            var defineId   = Convert.ToInt32(defineType.DefineId);
            //获取内容权限
            var defineConfig = _defineConfigRepository.GetAll().SingleOrDefault(a => a.DefineId == defineId);

            if (defineConfig != null)
            {
                rm.IsReolyFloor = Convert.ToBoolean(defineConfig.IsReolyFloor);
            }
            if (defineConfig != null)
            {
                rm.IsLike = Convert.ToBoolean(defineConfig.IsLike);
            }
            if (defineConfig != null)
            {
                rm.IsReolyFile = Convert.ToBoolean(defineConfig.IsReolyFile);
            }
            if (defineConfig != null)
            {
                rm.IsReolyFloorFile = Convert.ToBoolean(defineConfig.IsReolyFloorFile);
            }
            return(rm);
        }