예제 #1
0
        public string GetPhotoAbsoluteWebPath(Guid userID)
        {
            var path = SearchInCache(userID, Size.Empty, out _);

            if (!string.IsNullOrEmpty(path))
            {
                return(path);
            }

            try
            {
                var    data = UserManager.GetUserPhoto(userID);
                string photoUrl;
                string fileName;
                if (data == null || data.Length == 0)
                {
                    photoUrl = GetDefaultPhotoAbsoluteWebPath();
                    fileName = "default";
                }
                else
                {
                    photoUrl = SaveOrUpdatePhoto(userID, data, -1, new Size(-1, -1), false, out fileName);
                }

                UserPhotoManagerCache.AddToCache(userID, Size.Empty, fileName);

                return(photoUrl);
            }
            catch
            {
            }
            return(GetDefaultPhotoAbsoluteWebPath());
        }
예제 #2
0
        private string GetSizedPhotoAbsoluteWebPath(Guid userID, Size size, out bool isdef)
        {
            var res = SearchInCache(userID, size, out isdef);

            if (!string.IsNullOrEmpty(res))
            {
                return(res);
            }

            try
            {
                var data = UserManager.GetUserPhoto(userID);

                if (data == null || data.Length == 0)
                {
                    //empty photo. cache default
                    var photoUrl = GetDefaultPhotoAbsoluteWebPath(size);

                    UserPhotoManagerCache.AddToCache(userID, size, "default");
                    isdef = true;
                    return(photoUrl);
                }

                //Enqueue for sizing
                SizePhoto(userID, data, -1, size);
            }
            catch { }

            isdef = false;
            return(GetDefaultPhotoAbsoluteWebPath(size));
        }
예제 #3
0
        private readonly WorkerQueue <ResizeWorkerItem> ResizeQueue;//TODO: configure

        public UserPhotoManager(
            UserManager userManager,
            WebImageSupplier webImageSupplier,
            TenantManager tenantManager,
            StorageFactory storageFactory,
            UserPhotoManagerCache userPhotoManagerCache,
            IOptionsMonitor <ILog> options,
            WorkerQueueOptionsManager <ResizeWorkerItem> optionsQueue,
            SettingsManager settingsManager,
            IServiceProvider serviceProvider)
        {
            ResizeQueue           = optionsQueue.Value;
            UserManager           = userManager;
            WebImageSupplier      = webImageSupplier;
            TenantManager         = tenantManager;
            StorageFactory        = storageFactory;
            UserPhotoManagerCache = userPhotoManagerCache;
            SettingsManager       = settingsManager;
            ServiceProvider       = serviceProvider;
            Log = options.Get("ASC.Web.Photo");
        }