Ejemplo n.º 1
0
        public static void SaveLogo(this SponsorBase sponsor, PortalSettings portal, Stream logo, string extension)
        {
            sponsor.ClearLogos(portal);
            var folderName = string.Format("{0}\\{1}", portal.HomeDirectoryMapPath,
                                           Common.Globals.GetSponsorLogoPath(sponsor.ConferenceId, sponsor.SponsorId, "\\")
                                           );

            if (!Directory.Exists(folderName))
            {
                Directory.CreateDirectory(folderName);
            }
            using (var sw = new FileStream(string.Format("{0}original{1}", folderName, extension), FileMode.OpenOrCreate, FileAccess.Write))
            {
                logo.CopyTo(sw);
            }
        }
Ejemplo n.º 2
0
        public SponsorBase GetSponsorBase()
        {
            SponsorBase res = new SponsorBase();

            res.SponsorId            = SponsorId;
            res.ConferenceId         = ConferenceId;
            res.Name                 = Name;
            res.Url                  = Url;
            res.Description          = Description;
            res.ViewOrder            = ViewOrder;
            res.SponsorLevel         = SponsorLevel;
            res.CreatedByUserID      = CreatedByUserID;
            res.CreatedOnDate        = CreatedOnDate;
            res.LastModifiedByUserID = LastModifiedByUserID;
            res.LastModifiedOnDate   = LastModifiedOnDate;
            return(res);
        }
Ejemplo n.º 3
0
        public void ReadSponsorBase(SponsorBase sponsor)
        {
            if (sponsor.SponsorId > -1)
            {
                SponsorId = sponsor.SponsorId;
            }

            if (sponsor.ConferenceId > -1)
            {
                ConferenceId = sponsor.ConferenceId;
            }

            if (!String.IsNullOrEmpty(sponsor.Name))
            {
                Name = sponsor.Name;
            }

            if (!String.IsNullOrEmpty(sponsor.Url))
            {
                Url = sponsor.Url;
            }

            if (!String.IsNullOrEmpty(sponsor.Description))
            {
                Description = sponsor.Description;
            }

            if (sponsor.ViewOrder > -1)
            {
                ViewOrder = sponsor.ViewOrder;
            }

            if (!String.IsNullOrEmpty(sponsor.SponsorLevel))
            {
                SponsorLevel = sponsor.SponsorLevel;
            }
        }
Ejemplo n.º 4
0
        public static string GetLogo(this SponsorBase sponsor, PortalSettings portal, int size)
        {
            var folderName = string.Format("{0}\\{1}", portal.HomeDirectoryMapPath,
                                           Common.Globals.GetSponsorLogoPath(sponsor.ConferenceId, sponsor.SponsorId, "\\")
                                           );

            if (!Directory.Exists(folderName))
            {
                return("");
            }
            var folder = new DirectoryInfo(folderName);
            var files  = folder.GetFiles(size.ToString() + ".*");

            if (files.Length > 0)
            {
                return(files[0].FullName);
            }
            files = folder.GetFiles("original.*");
            if (files.Length == 0)
            {
                return("");
            }
            // resize logic
            var ext = Path.GetExtension(files[0].Name);

            using (var sr = new FileStream(files[0].FullName, FileMode.Open, FileAccess.Read))
            {
                var sizedContent = DotNetNuke.Common.Utilities.ImageUtils.CreateImage(sr, size, size, Path.GetExtension(files[0].Name));
                sizedContent.Seek(0, SeekOrigin.Begin);
                using (var sw = new FileStream(string.Format("{0}{1}{2}", folderName, size, ext), FileMode.OpenOrCreate, FileAccess.Write))
                {
                    sizedContent.CopyTo(sw);
                }
            }
            return(string.Format("{0}{1}{2}", folderName, size, ext));
        }
Ejemplo n.º 5
0
        public static void ClearLogos(this SponsorBase sponsor, PortalSettings portal)
        {
            var folderName = string.Format("{0}\\{1}", portal.HomeDirectoryMapPath,
                                           Common.Globals.GetSponsorLogoPath(sponsor.ConferenceId, sponsor.SponsorId, "\\")
                                           );

            if (!Directory.Exists(folderName))
            {
                return;
            }
            var folder = new DirectoryInfo(folderName);
            var files  = Directory.GetFiles(folderName, "*.*");

            foreach (var f in files)
            {
                try
                {
                    File.Delete(f);
                }
                catch (System.Exception)
                {
                }
            }
        }