Пример #1
0
        private void Rename()
        {
            Entities Entities    = new Entities(ConfigurationManager.ConnectionStrings["canyoucodedb"].ConnectionString);
            var      excludeLogs = new[] { "/images/company-logo.png", "/images/profile-pic.png" };

            var companiesToModify = Entities.Company.Where(c => !excludeLogs.Contains(c.Logo.ToLower())).ToList();

            companiesToModify.ForEach(c =>
            {
                var oldFilename = Path.GetFileName(c.Logo);
                var extn        = Path.GetExtension(c.Logo);

                var new80Filename = oldFilename.Replace(extn, "-80" + extn);
                CYCBlobHelper.Rename("company", oldFilename, new80Filename);

                var originalFilename    = oldFilename.Replace(extn, "-original" + extn);
                var newOriginalFilename = oldFilename;
                CYCBlobHelper.Rename("company", originalFilename, newOriginalFilename);
            });

            var excludePics         = new[] { "/images/profile-pic.png" };
            var consultantsToModify = Entities.Consultant.Where(c => !excludePics.Contains(c.Picture.ToLower())).ToList();

            consultantsToModify.ForEach(c =>
            {
                var oldFilename = Path.GetFileName(c.Picture);
                var extn        = Path.GetExtension(c.Picture);

                var new80Filename = oldFilename.Replace(extn, "-80" + extn);
                CYCBlobHelper.Rename("profile", oldFilename, new80Filename);

                var originalFilename    = oldFilename.Replace(extn, "-original" + extn);
                var newOriginalFilename = oldFilename;
                CYCBlobHelper.Rename("profile", originalFilename, newOriginalFilename);
            });

            var excludePortfolios  = new[] { "/images/page-placeholder.png", "/images/page-placeholder2.png", "/images/page-placeholder3.png" };
            var portfoliosToModify = Entities.PortfolioEntry.Where(c => !excludePortfolios.Contains(c.Image.ToLower())).ToList();

            portfoliosToModify.ForEach(p =>
            {
                if (!string.IsNullOrEmpty(p.Image))
                {
                    var oldFilename = Path.GetFileName(p.Image);
                    var extn        = Path.GetExtension(p.Image);

                    var new80Filename = oldFilename.Replace(extn, "-564" + extn);
                    CYCBlobHelper.Rename("portfolio", oldFilename, new80Filename);

                    var originalFilename    = oldFilename.Replace(extn, "-original" + extn);
                    var newOriginalFilename = oldFilename;
                    CYCBlobHelper.Rename("portfolio", originalFilename, newOriginalFilename);
                }
            });
        }
Пример #2
0
        private void CreatePortolio_800()
        {
            Entities Entities = new Entities(ConfigurationManager.ConnectionStrings["canyoucodedb"].ConnectionString);

            var excludePortfolios  = new[] { "/images/page-placeholder.png", "/images/page-placeholder2.png", "/images/page-placeholder3.png" };
            var portfoliosToModify = Entities.PortfolioEntry.Where(c => !excludePortfolios.Contains(c.Image.ToLower())).ToList();

            portfoliosToModify.ForEach(p =>
            {
                if (!string.IsNullOrEmpty(p.Image))
                {
                    var blob = CYCBlobHelper.GetBlob("portfolio", p.Image);
                    if (blob != null)
                    {
                        FileUtil.SaveResizedImage(blob, 800, 2000);
                    }
                }
            });
        }