Exemplo n.º 1
0
        public SysAttachmentsItem ConvertToEntity()
        {
            SysAttachmentsItem entity = new SysAttachmentsItem();

            entity.Id              = Id;
            entity.AppId           = AppId;
            entity.MediaExpireTime = MediaExpireTime;
            entity.Extension       = Extension;
            entity.AttachmentUrl   = AttachmentUrl;
            entity.FileSize        = FileSize;
            entity.Description     = Description;
            entity.MediaId         = MediaId;
            entity.Type            = Type;
            entity.Duration        = Duration;
            entity.CreateTime      = CreateTime;
            entity.AttachmentTitle = AttachmentTitle;
            entity.Width           = Width;
            entity.ThumbUrl        = ThumbUrl;
            entity.Height          = Height;
            entity.UserName        = UserName;
            entity.UserId          = UserId;
            entity.IsDeleted       = IsDeleted;
            entity.DownloadCounts  = DownloadCounts;
            entity.Opend           = Opend;
            return(entity);
        }
        public JsonResult ThumbImageAndInsertIntoDB()
        {
            string saveFullName           = Request["saveFullName"];
            string fileName               = Request["title"];
            string targetFilePath         = Request["targetFilePath"];
            string uploadFileType         = Request["uploadFileType"];
            string pid                    = Request["id"];
            AttachmentsItemPostProperty p = new AttachmentsItemPostProperty()
            {
                SaveFullName   = saveFullName,
                ServerPath     = Server.MapPath("~/"),
                FileName       = fileName,
                TargetFilePath = targetFilePath.Trim('/'),
                UploadFileType = uploadFileType,
                AppId          = int.Parse(Request["appid"]),
                Description    = Request["description"] == null ? string.Empty : Request["description"],
                VideoCoverSrc  = Request["videoCoverSrc"] == null ? string.Empty : Request["videoCoverSrc"].Trim('/'),
                UserName       = User.Identity.Name,
                ViewId         = pid,
            };
            SysAttachmentsItem itemView = _attachmentsItemService.ThumbImageAndInsertIntoDB(p);

            return(Json(new { Id = itemView.Id, AttachmentUrl = itemView.AttachmentUrl, AttachmentTitle = itemView.AttachmentTitle, Description = itemView.Description, Duration = itemView.Duration }
                        , StrJsonTypeTextHtml));
        }
        /// <summary>
        /// 消息内容存储到素材表
        /// </summary>
        /// <param name="news"></param>
        /// <param name="uploadFileType"></param>
        /// <param name="strFileName"></param>
        private static void NewsToAttachments(NewsInfoView news, string uploadFileType, string strFileName)
        {
            IAttachmentsItemService _attachmentsItemService = EngineContext.Current.Resolve <IAttachmentsItemService>();
            string strFullName = (HttpContext.Current == null ? HttpRuntime.AppDomainAppPath : HttpContext.Current.Request.PhysicalApplicationPath) + strFileName;

            AttachmentsItemPostProperty p = new AttachmentsItemPostProperty()
            {
                SaveFullName   = Path.GetFileName(strFullName),
                ServerPath     = HttpRuntime.AppDomainAppPath,
                FileName       = news.NewsTitle,
                TargetFilePath = strFileName.Replace(Path.GetFileName(strFullName), "").Replace("//", "/").Trim('/'),
                UploadFileType = uploadFileType,
                AppId          = news.AppId,
                Description    = news.NewsComment,
                VideoCoverSrc  = string.IsNullOrEmpty(news.ImageSrc) ? news.ImageContent : news.ImageSrc,
                UserName       = _attachmentsItemService.Repository.LoginUserName,// User.Identity.Name,
                MediaId        = news.MediaId,
                // MediaExpireTime=
                //ViewId = pid,
            };
            SysAttachmentsItem itemView = _attachmentsItemService.ThumbImageAndInsertIntoDB(p);
        }