예제 #1
0
        public void EditPicturePanel(int id, string menuTag, string underMenuTag, int style, HttpPostedFileBase thisFile, string header)
        {
            if (thisFile == null)
            {
                return;
            }

            using (this.ef = new CMSDbEntities())
            {
                var pic = this.ef.Panels.Find(id);
                if (pic.PicturePanel == null)
                {
                    return;
                }

                pic.MenuTag             = menuTag;
                pic.UnderMenuTag        = underMenuTag;
                pic.StyleSheet          = style;
                pic.PicturePanel.Header = header;

                if (HttpPostedFileBaseExtensions.IsImage(thisFile))
                {
                    var lenght    = thisFile.ContentLength;
                    var tempimage = new byte[lenght];
                    thisFile.InputStream.Read(tempimage, 0, lenght);
                    pic.PicturePanel.ImageData = tempimage;
                    pic.PicturePanel.ImageType = thisFile.ContentType;
                }

                this.ef.SaveChanges();
            }
        }
예제 #2
0
        public void GetIndexing()
        {
            using (this.ef = new CMSDbEntities())
            {
                if (this.Pan == null)
                {
                    this.Pan = new Collection <Panel>();
                    Collection <Panel> panels = HttpContext.Current.Cache[this.Style.ThisPageId + "content"] as Collection <Panel>;
                    if (panels == null)
                    {
                        var query = from b in this.ef.Panels.Include("PicturePanel").Include("VideoTable").Include("CombomPanel").Include("TextPanel").Include("PanelStyle").Include("GalleryPanel").Include("GalleryPanel.GalleryImages").Where(x => x.PageSettingId == this.Style.ThisPageId).OrderBy(t => t.MenuIndex).ThenBy(t => t.UnderMenuIndex)
                                    where b.PageSettingId == this.Style.ThisPageId
                                    select b;

                        foreach (var item in query)
                        {
                            this.Pan.Add(item);
                        }

                        HttpContext.Current.Cache[this.Style.ThisPageId + "content"] = this.Pan;
                    }
                    else
                    {
                        this.Pan = panels;
                    }
                }
            }
        }
예제 #3
0
        public int EditGalleryImage(int id, string description, string title)
        {
            using (this.ef = new CMSDbEntities())
            {
                var image      = this.ef.GalleryImages.Find(id);
                var panelid    = 0;
                var panelIndex = 0;
                if (image != null)
                {
                    panelid = image.Gallery_Id;
                    image.imageDescription = description;
                    image.imageTitle       = title;
                    this.ef.SaveChanges();
                }

                foreach (var item in this.rc.Pan)
                {
                    if (item.Panel_Id == panelid)
                    {
                        return(panelIndex);
                    }

                    panelIndex++;
                }

                return(panelid);
            }
        }
예제 #4
0
        public void AddPicturePanel(int id, string header, HttpPostedFileBase thisFile)
        {
            if (thisFile == null)
            {
                return;
            }

            var pp = new PicturePanel();

            pp.Header = header;
            pp.P_Id   = id;

            var lenght    = thisFile.ContentLength;
            var tempimage = new byte[lenght];

            thisFile.InputStream.Read(tempimage, 0, lenght);
            pp.ImageData = tempimage;
            pp.ImageType = thisFile.ContentType;

            using (this.ef = new CMSDbEntities())
            {
                this.ef.PicturePanels.Add(pp);
                this.ef.SaveChanges();
            }
        }
예제 #5
0
        public int DeleteGalleryImage(int id)
        {
            using (this.ef = new CMSDbEntities())
            {
                var image      = this.ef.GalleryImages.Find(id);
                var panelid    = 0;
                var panelIndex = 0;
                if (image != null)
                {
                    panelid = image.Gallery_Id;
                    this.ef.ImageFullSizes.Remove(image.ImageFullSize);
                    this.ef.GalleryImages.Remove(image);
                    this.ef.SaveChanges();
                }

                foreach (var item in this.rc.Pan)
                {
                    if (item.Panel_Id == panelid)
                    {
                        return(panelIndex);
                    }

                    panelIndex++;
                }

                return(panelid);
            }
        }
예제 #6
0
 public void AddPanelStyle(PanelStyle newStyle)
 {
     using (this.ef = new CMSDbEntities())
     {
         this.ef.PanelStyles.Add(newStyle);
         this.ef.SaveChanges();
     }
 }
예제 #7
0
        public void UpdateSiteStyle(SiteStyleSheet updated, string pagename, bool singlePage, HttpPostedFileBase thisFile, int headerSize, int headerAlign)
        {
            if (updated != null)
            {
                using (this.ef = new CMSDbEntities())
                {
                    var original = this.ef.SiteStyleSheets.Find(this.ef.PageSettings.Find(this.ThisPageId).SiteStyleSheet.Id);

                    original.color_header_background = updated.color_header_background;
                    original.color_header_text       = updated.color_header_text;
                    original.color_header_title      = updated.color_header_title;
                    original.color_site_background   = updated.color_site_background;
                    original.font_family_header      = updated.font_family_header;
                    original.font_family_header_menu = updated.font_family_header_menu;

                    var originalsetting = this.ef.PageSettings.Find(this.ThisPageId);
                    originalsetting.PageName         = pagename;
                    originalsetting.singlePage       = singlePage;
                    originalsetting.HeaderSize       = headerSize;
                    originalsetting.AlignHeaderRight = headerAlign;

                    if (thisFile != null && thisFile.ContentLength > 100)
                    {
                        var lenght    = thisFile.ContentLength;
                        var tempimage = new byte[lenght];
                        thisFile.InputStream.Read(tempimage, 0, lenght);

                        var wi     = new WebImage(tempimage);
                        var height = wi.Height;
                        if (wi.Height > 60)
                        {
lel:
                            var ratio = (double)60 / (double)height;

                            if (ratio != 0)
                            {
                                wi.Resize(Convert.ToInt32(wi.Width * ratio), 60);
                                originalsetting.HeaderImage     = wi.GetBytes();
                                originalsetting.HeaderImageType = thisFile.ContentType;
                            }
                            else
                            {
                                goto lel;
                            }
                        }
                        else
                        {
                            originalsetting.HeaderImage     = tempimage;
                            originalsetting.HeaderImageType = thisFile.ContentType;
                        }
                    }

                    this.ef.SaveChanges();
                }
            }
        }
예제 #8
0
 public void AddTextPanel(int id, string context, string header)
 {
     using (this.ef = new CMSDbEntities())
     {
         this.ef.TextPanels.Add(new TextPanel {
             Context = context, Header = header, P_Id = id
         });
         this.ef.SaveChanges();
     }
 }
예제 #9
0
 public static void EditUser(int id, string passWord)
 {
     using (var ef = new CMSDbEntities())
     {
         var user = ef.AdminLogins.Find(id);
         if (user != null)
         {
             user.pass = passWord;
             ef.SaveChanges();
         }
     }
 }
예제 #10
0
 public static void DeleteUser(int id)
 {
     using (var ef = new CMSDbEntities())
     {
         var user = ef.AdminLogins.Find(id);
         if (user != null)
         {
             ef.AdminLogins.Remove(user);
             ef.SaveChanges();
         }
     }
 }
예제 #11
0
 public void AddGalleryPanel(int id, string header)
 {
     using (this.ef = new CMSDbEntities())
     {
         var gallery = new GalleryPanel()
         {
             Header = header,
             P_Id   = id
         };
         this.ef.GalleryPanels.Add(gallery);
         this.ef.SaveChanges();
     }
 }
예제 #12
0
        public static void AddUser(string userName, string passWord, int pageId)
        {
            using (var ef = new CMSDbEntities())
            {
                AdminLogin al = new AdminLogin();
                al.PageSettingId = pageId;
                al.pass          = passWord;
                al.user          = userName;

                ef.AdminLogins.Add(al);
                ef.SaveChanges();
            }
        }
예제 #13
0
        public void ImageGalleryThumb(int id)
        {
            using (var ef = new CMSDbEntities())
            {
                var entity = ef.GalleryImages.Find(id);
                if (entity == null)
                {
                    return;
                }

                this.ImageFileValue = entity.imageThumb;
                this.ImageType      = entity.imageType;
            }
        }
예제 #14
0
        public void ImageGallery(int id)
        {
            using (var ef = new CMSDbEntities())
            {
                var entity = ef.ImageFullSizes.Find(id);
                if (entity == null)
                {
                    return;
                }

                this.ImageFileValue = entity.imagedata;
                this.ImageType      = entity.imagetype;
            }
        }
예제 #15
0
        public void ImagePanel(int id)
        {
            using (var ef = new CMSDbEntities())
            {
                var entity = ef.PicturePanels.Find(id);
                if (entity == null)
                {
                    return;
                }

                this.ImageFileValue = entity.ImageData;
                this.ImageType      = entity.ImageType;
            }
        }
예제 #16
0
        public void AddPanel(int styleSheet, string menuTag, string underMenuTag)
        {
            using (this.ef = new CMSDbEntities())
            {
                var style = this.ef.PanelStyles.Find(styleSheet);

                var query = from b in this.ef.Panels
                            where b.MenuTag == menuTag
                            where b.PageSettingId == this.rc.Style.ThisPageId
                            select b;

                var query2 = from b in this.ef.Panels
                             orderby b.MenuIndex
                             where b.PageSettingId == this.rc.Style.ThisPageId
                             select b;

                if (query.Any())
                {
                    var highest = 1;
                    foreach (var item in query)
                    {
                        if (item.UnderMenuIndex > highest)
                        {
                            highest = Convert.ToInt32(item.UnderMenuIndex, CultureInfo.CurrentCulture);
                        }
                    }

                    this.ef.Panels.Add(new Panel {
                        MenuTag = menuTag, PanelStyle = style, UnderMenuTag = underMenuTag, PageSettingId = this.rc.Style.ThisPageId, MenuIndex = query.First().MenuIndex, UnderMenuIndex = highest + 1
                    });
                    this.ef.SaveChanges();
                }
                else
                {
                    var index = 1;
                    foreach (var item in query2)
                    {
                        if (item.MenuIndex > index)
                        {
                            index = Convert.ToInt32(item.MenuIndex, CultureInfo.CurrentCulture);
                        }
                    }

                    this.ef.Panels.Add(new Panel {
                        MenuTag = menuTag, PanelStyle = style, UnderMenuTag = underMenuTag, PageSettingId = this.rc.Style.ThisPageId, MenuIndex = index + 1, UnderMenuIndex = 1
                    });
                    this.ef.SaveChanges();
                }
            }
        }
예제 #17
0
        public void RemoveHeaderLogo()
        {
            using (this.ef = new CMSDbEntities())
            {
                var page = this.ef.PageSettings.Find(this.ThisPageId);
                if (page == null)
                {
                    return;
                }

                page.HeaderImage     = null;
                page.HeaderImageType = null;
                this.ef.SaveChanges();
            }
        }
예제 #18
0
        public ActionResult DeleteGalleryImage(int id)
        {
            using (var ef = new CMSDbEntities())
            {
                var image = ef.GalleryImages.Find(id);
                if (image != null)
                {
                    ef.ImageFullSizes.Remove(image.ImageFullSize);
                    ef.GalleryImages.Remove(image);
                    ef.SaveChanges();
                }
            }

            return this.Redirect(this.Request.UrlReferrer.ToString());
        }
예제 #19
0
        public void AddVideoPanel(int id, string video, string header)
        {
            using (this.ef = new CMSDbEntities())
            {
                const string Pattern     = @"(?:https?:\/\/)?(?:www\.)?(?:(?:(?:youtube.com\/watch\?[^?]*v=|youtu.be\/)([\w\-]+))(?:[^\s?]+)?)";
                const string Replacement = "$1";

                var rgx    = new Regex(Pattern);
                var result = rgx.Replace(video, Replacement);

                this.ef.VideoTables.Add(new VideoTable {
                    VideoHeader = header, VideoUrl = result, P_Id = id, VideoSize = "Large"
                });
                this.ef.SaveChanges();
            }
        }
예제 #20
0
        public void DeletePanelStyle(int id)
        {
            if (id == 1)
            {
                return;
            }

            using (this.ef = new CMSDbEntities())
            {
                var query2 = from b in this.ef.PanelStyles
                             orderby b.Id
                             select b;
                if (query2.Count() < 2)
                {
                }
                else
                {
                    var ps = this.ef.PanelStyles.Find(id);

                    var query = from b in this.ef.Panels.Include("PanelStyle")
                                where b.StyleSheet == id
                                orderby b.Panel_Id
                                select b;

                    foreach (var item in query)
                    {
                        if (query2.First().Id != id)
                        {
                            item.StyleSheet = query2.First().Id;
                        }
                        else
                        {
                            item.StyleSheet = query2.Last().Id;
                        }
                    }

                    if (ps == null)
                    {
                    }
                    else
                    {
                        this.ef.PanelStyles.Remove(ps);
                        this.ef.SaveChanges();
                    }
                }
            }
        }
예제 #21
0
        public void EditGalleryPanel(int id, int style, string header, string menuTag, string underMenuTag)
        {
            using (this.ef = new CMSDbEntities())
            {
                var gallery = this.ef.Panels.Find(id);
                if (gallery.GalleryPanel == null)
                {
                    return;
                }

                gallery.MenuTag             = menuTag;
                gallery.UnderMenuTag        = underMenuTag;
                gallery.StyleSheet          = style;
                gallery.GalleryPanel.Header = header;
                this.ef.SaveChanges();
            }
        }
예제 #22
0
        public void MoveUnderMenuIndexUp(int index, int underIndex)
        {
            if (underIndex <= 1)
            {
                return;
            }

            using (this.ef = new CMSDbEntities())
            {
                var query2 = from b in this.ef.Panels
                             where b.MenuIndex == index
                             where b.PageSettingId == this.rc.Style.ThisPageId
                             orderby b.UnderMenuIndex
                             select b;

                if (query2.Count() <= 1)
                {
                    return;
                }

                var thisnew  = query2.First();
                var original = query2.First();

                foreach (var qy in query2)
                {
                    if (underIndex > qy.UnderMenuIndex)
                    {
                        thisnew = qy;
                    }
                    else if (underIndex == qy.UnderMenuIndex)
                    {
                        original = qy;
                    }
                }

                if (thisnew == original)
                {
                    return;
                }

                var undertag = Convert.ToInt32(thisnew.UnderMenuIndex, CultureInfo.CurrentCulture);
                thisnew.UnderMenuIndex  = original.UnderMenuIndex;
                original.UnderMenuIndex = undertag;
                this.ef.SaveChanges();
            }
        }
예제 #23
0
        public void EditComboPanel(int id, string menuTag, string underMenuTag, int style, HttpPostedFileBase thisFile, string align, string header, string context)
        {
            using (this.ef = new CMSDbEntities())
            {
                var combo = this.ef.Panels.Find(id);
                if (combo == null || combo.CombomPanel == null)
                {
                    return;
                }

                combo.MenuTag                  = menuTag;
                combo.UnderMenuTag             = underMenuTag;
                combo.StyleSheet               = style;
                combo.CombomPanel.PictureAlign = align;
                combo.CombomPanel.Header       = header;
                combo.CombomPanel.Context      = context;

                if (thisFile != null && thisFile.ContentLength > 50)
                {
                    var lenght    = thisFile.ContentLength;
                    var tempimage = new byte[lenght];

                    thisFile.InputStream.Read(tempimage, 0, lenght);

                    var wi    = new WebImage(tempimage);
                    var width = wi.Width;
                    if (wi.Width > 279)
                    {
                        var ratio = 279 / width;
                        if (ratio != 0)
                        {
                            wi.Resize(279, Convert.ToInt32(wi.Height * ratio));
                            combo.CombomPanel.ImageData = wi.GetBytes();
                            combo.CombomPanel.ImageType = thisFile.ContentType;
                        }
                    }
                    else
                    {
                        combo.CombomPanel.ImageData = wi.GetBytes();
                        combo.CombomPanel.ImageType = thisFile.ContentType;
                    }
                }

                this.ef.SaveChanges();
            }
        }
예제 #24
0
        public static bool LogOn(string user, string pass, int id)
        {
            using (var ef = new CMSDbEntities())
            {
                var query = from b in ef.AdminLogins
                            where b.PageSettingId == id
                            where b.user.Equals(user)
                            where b.pass.Equals(pass)
                            select b;

                if (query.Count() == 1)
                {
                    return(true);
                }

                return(false);
            }
        }
예제 #25
0
 public void ListAdminUsers(int pageId)
 {
     if (this.AdminLogins == null)
     {
         this.AdminLogins = new Collection <AdminLogin>();
         using (this.ef = new CMSDbEntities())
         {
             var query = from b in this.ef.AdminLogins
                         where b.PageSettingId == pageId
                         orderby b.user
                         select b;
             foreach (var item in query)
             {
                 this.AdminLogins.Add(item);
             }
         }
     }
 }
예제 #26
0
        public void EditTextPanel(int id, string menuTag, string underMenuTag, int style, string header, string context)
        {
            using (this.ef = new CMSDbEntities())
            {
                var text = this.ef.Panels.Find(id);
                if (text.TextPanel == null)
                {
                    return;
                }

                text.MenuTag           = menuTag;
                text.UnderMenuTag      = underMenuTag;
                text.StyleSheet        = style;
                text.TextPanel.Context = context;
                text.TextPanel.Header  = header;
                this.ef.SaveChanges();
            }
        }
예제 #27
0
        public void AddComboPanel(int id, string header, string context, string align, HttpPostedFileBase thisFile)
        {
            if (thisFile == null)
            {
                return;
            }

            var cp = new CombomPanel();

            cp.Context      = context;
            cp.Header       = header;
            cp.PictureAlign = align;
            cp.P_Id         = id;

            var lenght    = thisFile.ContentLength;
            var tempimage = new byte[lenght];

            thisFile.InputStream.Read(tempimage, 0, lenght);

            var wi    = new WebImage(tempimage);
            var width = wi.Width;

            if (wi.Width > 279)
            {
                var ratio = 279 / width;
                if (ratio != 0)
                {
                    wi.Resize(279, Convert.ToInt32(wi.Height * ratio));
                    cp.ImageData = wi.GetBytes();
                    cp.ImageType = thisFile.ContentType;
                }
            }
            else
            {
                cp.ImageData = wi.GetBytes();
                cp.ImageType = thisFile.ContentType;
            }

            using (this.ef = new CMSDbEntities())
            {
                this.ef.CombomPanels.Add(cp);
                this.ef.SaveChanges();
            }
        }
예제 #28
0
        public void AddGalleryImage(int id, HttpPostedFileBase thisFile)
        {
            if (thisFile == null)
            {
                return;
            }

            using (this.ef = new CMSDbEntities())
            {
                var image = new GalleryImage();
                image.Gallery_Id = id;

                var lenght    = thisFile.ContentLength;
                var tempimage = new byte[lenght];
                thisFile.InputStream.Read(tempimage, 0, lenght);

                var wi     = new WebImage(tempimage);
                var height = wi.Height;
                if (wi.Height > 150)
                {
                    var ratio = 150 / height;
                    if (ratio != 0)
                    {
                        wi.Resize(Convert.ToInt32(wi.Width * ratio), 150);
                        image.imageThumb = wi.GetBytes();
                        image.imageType  = thisFile.ContentType;
                        image.imageTitle = thisFile.FileName;
                    }
                }
                else
                {
                    image.imageThumb = tempimage;
                    image.imageType  = thisFile.ContentType;
                }

                var ifs = new ImageFullSize();
                ifs.imagedata       = tempimage;
                ifs.imagetype       = thisFile.ContentType;
                image.ImageFullSize = ifs;

                this.ef.GalleryImages.Add(image);
                this.ef.SaveChanges();
            }
        }
예제 #29
0
        public void RetrievePanelStyles()
        {
            using (this.ef = new CMSDbEntities())
            {
                if (this.PanelStyles == null)
                {
                    Collection <PanelStyle> ps =
                        HttpContext.Current.Cache[this.Style.ThisPageId + "style"] as Collection <PanelStyle>;
                    if (ps == null)
                    {
                        this.PanelStyles = new Collection <PanelStyle>();
here:
                        var query = from b in this.ef.PanelStyles
                                    where b.PageSettingId == this.Style.ThisPageId
                                    orderby b.Id
                                    select b;

                        if (query.Any())
                        {
                            foreach (var item in query)
                            {
                                this.PanelStyles.Add(item);
                            }

                            HttpContext.Current.Cache[this.Style.ThisPageId + "style"] = this.PanelStyles;
                        }
                        else
                        {
                            this.ef.PanelStyles.Add(new PanelStyle {
                                StyleName = "Default", color_panel_context = "003366", color_panel_title = "003366", color_panel_background = "ddddbb", font_family_panel_context = "Arial", font_family_panel_title = "Arial", PageSettingId = this.Style.ThisPageId
                            });
                            this.ef.SaveChanges();
                            goto here;
                        }
                    }
                    else
                    {
                        this.PanelStyles = ps;
                    }
                }
            }
        }
예제 #30
0
        public ActionResult EditPass(FormCollection collection)
        {
            if (collection != null)
            {
                var uid = Convert.ToInt32(collection["ThisId"], CultureInfo.CurrentCulture);
                ViewBag.ThisId = uid;
                var pwd   = collection["pwd"];
                var npwd  = collection["npwd"];
                var npwd2 = collection["nwpd2"];
                if (npwd == npwd2)
                {
                    using (CMSDbEntities db = new CMSDbEntities())
                    {
                        var user = db.AdminLogins.Find(uid);
                        if (user.pass == pwd)
                        {
                            user.pass = npwd;
                            db.SaveChanges();
                            ViewBag.Success = "Password er nu ændret.";
                            this.rc.ListAdminUsers(this.rc.Style.ThisPageId);
                            return(this.View(this.rc));
                        }
                        else
                        {
                            ViewBag.Error = "Nuværende password matcher ikke med det indtastede.";
                            this.rc.ListAdminUsers(this.rc.Style.ThisPageId);
                            return(this.View(this.rc));
                        }
                    }
                }
                else
                {
                    ViewBag.Error = "De nye passwords stemmer ikke overens med hinanden.";
                    this.rc.ListAdminUsers(this.rc.Style.ThisPageId);
                    return(this.View(this.rc));
                }
            }

            this.rc.ListAdminUsers(this.rc.Style.ThisPageId);
            return(this.View(this.rc));
        }