示例#1
0
        public UserProfileViewModel(
            MessageHistoryService messageHistoryServ,
            UserSearcher userSearchingServ,
            FriendsService friendServ,
            Messanger mesServ,
            SessionInfo session,
            MessageSearcher mesSerServ,
            Services.PhotoService.UsersPhotoService profilePhotoService,
            ImageService imageServ,
            Authenticator authenticatorServ,
            ImageUrlService imageUrlServ)
        {
            Messages                 = new FlowDocument();
            controlsVisibility       = false;
            canExecute               = true;
            CurrentSession           = session;
            messageHistoryService    = messageHistoryServ;
            userSearchingService     = userSearchingServ;
            friendService            = friendServ;
            this.profilePhotoService = profilePhotoService;
            imageService             = imageServ;
            Friends = friendService.GetFriends(currentSession.LoggedUser.Id).ResultTask.Result;
            authenticatorService = authenticatorServ;
            imageUrlService      = imageUrlServ;

            FindFriendEmailOrLogin = string.Empty;
            messengerService       = mesServ;
            DocWidth = 248;
            FontSize = 13;
            messageSearchingService = mesSerServ;
            var imageUrl = profilePhotoService.GetProfilePhoto(currentSession.LoggedUser.ProfilePhotoId).Url;

            if (imageUrl.Contains(@"\Resources\images\ProfilePhotos"))
            {
                ImageSource = imageUrl;
            }
            else
            {
                ImageSource = imageUrlService.GetImageUrl(currentSession.LoggedUser.ProfilePhotoId);
            }
        }
示例#2
0
        /// <summary>
        /// 获取图片路径
        /// </summary>
        /// <param name="pictureType">SystemPicture系统图片,ProductPicture商品图片,UserPicture用户图片</param>
        /// <param name="pictureFileNo">图片文件名称编号</param>
        /// <param name="width">宽 0为原图宽</param>
        /// <param name="height">高 0为原图高</param>
        /// <param name="extension">扩展</param>
        /// <returns></returns>
        public string GetImageWebUrl(string pictureType, string pictureFileNo, int width, int height, string extension)
        {
            if (string.IsNullOrEmpty(pictureType) || string.IsNullOrEmpty(pictureFileNo))
            {
                return(string.Empty);
            }

            string site = GetUGCImageSiteUrl(pictureFileNo);

            if (!site.EndsWith("/"))
            {
                site = (site + "/");
            }

            ImageType imageType = ImageType.SystemPictureFile;

            if (pictureType.Equals("ProductPicture", StringComparison.CurrentCultureIgnoreCase))
            {
                imageType = ImageType.ProductPicture;
            }

            if (pictureType.Equals("SystemPicture", StringComparison.CurrentCultureIgnoreCase))
            {
                imageType = ImageType.SystemPictureFile;
            }

            if (pictureType.Equals("UserPicture", StringComparison.CurrentCultureIgnoreCase))
            {
                imageType = ImageType.UserPicture;
            }

            string rurl = ImageUrlService.GetStaticImageUrl(imageType, pictureFileNo, (!string.IsNullOrEmpty(extension) ? extension : "jpg"), width, height);

            string imageUrl = string.Format("{0}{1}", site, rurl.StartsWith("/") ? rurl.Substring(1) : rurl);


            return(imageUrl);
        }
示例#3
0
 private void UpdateServiceProcess()
 {
     while (true)
     {
         try
         {
             ImageUrlService imageService   = new ImageUrlService();
             var             blogImageList  = imageService.GetLocalList();
             int             blogImageCount = blogImageList.Count;
             MessageLog("updating blogImageCount:" + blogImageCount);
             int successCount = 0;
             foreach (ImageUrl image in blogImageList)
             {
                 string localPath = BlogFileDirectory + image.Url;
                 string yunUrl    = UploadUtility.UploadLocalFile(localPath);
                 if (yunUrl == "")
                 {
                     Thread.Sleep(5 * 60 * 1000);
                     continue;
                 }
                 image.YunUrl      = yunUrl;
                 image.ImageStatus = ImageStatus.Yun;
                 if (imageService.Update(image))
                 {
                     MessageLog("update success,localPath:{0} uploaded yunUrl:{1}", localPath, yunUrl);
                     successCount++;
                 }
                 else
                 {
                     MessageLog("update fail,localPath:{0} uploaded yunUrl:{1}", localPath, yunUrl);
                 }
                 Thread.Sleep(15 * 1000);
             }
             MessageLog("updated blogImageCount:" + successCount);
             imageService.Dispose();
             RecommentService recommentService = new RecommentService();
             var coverImageList  = recommentService.GetLocalList();
             int coverImageCount = coverImageList.Count;
             MessageLog("updating coverImageCount:" + coverImageCount);
             successCount = 0;
             foreach (Recomment image in coverImageList)
             {
                 string localPath = CoverFileDirectory + image.CoverName;
                 string yunUrl    = UploadUtility.UploadLocalFile(localPath);
                 if (yunUrl == "")
                 {
                     Thread.Sleep(5 * 60 * 1000);
                     continue;
                 }
                 image.YunUrl      = yunUrl;
                 image.ImageStatus = ImageStatus.Yun;
                 if (recommentService.Update(image))
                 {
                     MessageLog("update success,localPath:{0} uploaded yunUrl:{1}", localPath, yunUrl);
                     successCount++;
                 }
                 else
                 {
                     MessageLog("update fail,localPath:{0} uploaded yunUrl:{1}", localPath, yunUrl);
                 }
                 Thread.Sleep(15 * 1000);
             }
             MessageLog("updated blogImageCount:" + successCount);
             recommentService.Dispose();
             if (blogImageCount == 0 && coverImageCount == 0)
             {
                 MessageLog("record empty,sleeping 10 minutes");
                 Thread.Sleep(10 * 60 * 1000);
             }
         }
         catch (ThreadAbortException threadAbortException)
         {
             Logger.Error(threadAbortException);
             break;
         }
         catch (Exception ex)
         {
             Logger.Error(ex);
             Thread.Sleep(10 * 60 * 1000);
         }
     }
 }