예제 #1
0
        /// <summary>
        /// 更新用户头像
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="imageBase64">用户头像</param>
        public void UpdateUserAvatar(long userId, string imageBase64)
        {
            #region save iamge

            string fileName            = "UserAvatar_" + userId;
            string relativePath        = HlxBeConsts.USER_AVATAR_DIR + "\\" + fileName;
            string fullNameNoExtension = AppDomain.CurrentDomain.BaseDirectory + relativePath;


            ImageUtil.Base64StringToImage(imageBase64, fullNameNoExtension);

            var imageFilePath = relativePath;
            #endregion

            var item = _userAvatarRepository.FirstOrDefault(x => x.UserId == userId);
            if (item == null)
            {
                item = new UserAvatar()
                {
                    UserId        = userId,
                    ImageFilePath = imageFilePath
                };
                _userAvatarRepository.Insert(item);
            }
            else
            {
                item.ImageFilePath = imageFilePath;
                _userAvatarRepository.Update(item);
            }

            //_userRepository.Update(userId, x =>
            //{
            //    x.AvatarFilePath = imageFilePath;
            //});
        }
예제 #2
0
        public GridRow(WebSearchResult webSearchResult, int count) : this()
        {
            HeaderCell.Value = $"{count + 1}";

            Cells.Add(new DataGridViewTextBoxCell());
            Cells[0].Style.BackColor = webSearchResult.IsVIPad ? Color.DarkOrange : Color.White;

            DataGridViewTextBoxCell dateCell = new DataGridViewTextBoxCell()
            {
                Value = webSearchResult.Date.ToString(CultureInfo.CurrentUICulture)
            };

            Cells.Add(dateCell);
            dateCell.Style.BackColor = webSearchResult.IsHighlighted ? Color.Lavender : Color.White;

            if (webSearchResult.ImageBinary == null && webSearchResult.ImageBase64 != null)
            {
                webSearchResult.ImageBinary = ImageUtil.Base64StringToImage(webSearchResult.ImageBase64);
            }
            Cells.Add(new DataGridViewImageCell()
            {
                Value = (Image)webSearchResult.ImageBinary
            });
            DataGridViewLinkCell linkCell = new DataGridViewLinkCell
            {
                Value = webSearchResult.Title.Text,
                Tag   = webSearchResult.Title.Url
            };

            Cells.Add(linkCell);
            Cells.Add(new DataGridViewTextBoxCell()
            {
                Value = $"{webSearchResult.Price:C}"
            });
            Cells.Add(new DataGridViewTextBoxCell()
            {
                Value = webSearchResult.Category
            });
            Cells.Add(new DataGridViewTextBoxCell()
            {
                Value = webSearchResult.Address
            });
        }
예제 #3
0
        /// <summary>
        ///     发布视频
        /// </summary>
        /// <param name="video"></param>
        /// <param name="livePreviewImageBase64">视频预览图</param>
        /// <returns></returns>
        public long PublishVideo(Video video, string livePreviewImageBase64)
        {
            var id = _videoRepository.InsertAndGetId(video);

            #region save iamge

            if (!string.IsNullOrEmpty(livePreviewImageBase64))
            {
                var fileName            = "LivePreviewImage_" + id;
                var relativePath        = HlxBeConsts.LIVE_PREVIEW_IMAGE_DIR + "\\" + fileName;
                var fullNameNoExtension = AppDomain.CurrentDomain.BaseDirectory + relativePath;

                ImageUtil.Base64StringToImage(livePreviewImageBase64, fullNameNoExtension);

                var imageFilePath = relativePath;
                _videoRepository.Update(id,
                                        x => { x.LivePreviewImagePath = imageFilePath; });
            }

            #endregion

            return(id);
        }