Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="webImage"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <exception cref="BusinessLogicException"></exception>
        public virtual void SaveLogoInLogoFolder(IWebImage webImage, int width = WIDTH_LOGO, int height = HEIGHT_LOGO)
        {
            if (string.IsNullOrEmpty(this.LogoFolder))
            {
                throw new ApplicationCriticalException(
                          $"Generate first unique folder name by method {nameof(GenerateFolder)} and set it to {nameof(LogoFolder)}");
            }

            if (!Directory.Exists(Path.Combine(Config.UploadFolderFullPath, LogoFolder)))
            {
                DirectoryInfo info = Directory.CreateDirectory(Path.Combine(Config.UploadFolderFullPath, LogoFolder));
                this.LogoFolder = info.Name;
            }

            webImage
            ?.Resize(width, height)
            ?.Save(Path.Combine(Config.UploadFolderFullPath, this.LogoFolder, LOGO_NAME));
        }
Beispiel #2
0
        /// <summary>
        /// Delete all items from tempFolderPath and create there temp image
        /// </summary>
        /// <param name="webImage">IWebImage</param>
        /// <param name="tempFolderPath">path of current temp folder genereted for logo store</param>
        /// <param name="width">width</param>
        /// <param name="height">heightparam>
        public virtual void SaveTempLogo(IWebImage webImage, string tempFolderPath, int width = WIDTH_LOGO, int height = HEIGHT_LOGO)
        {
            var dirInfo = new DirectoryInfo(tempFolderPath);

            dirInfo.GetFiles()
            .ToList().ForEach(f => f.Delete());

            dirInfo.GetDirectories()
            .ToList().ForEach(d => d.Delete(true));

            if (webImage != null)
            {
                string fileName = $"{Guid.NewGuid():N}";

                webImage
                .Resize(width, height)
                .Save(Path.Combine(tempFolderPath, fileName));
            }
        }