Beispiel #1
0
        public ActionResult EmailBody(int id)
        {
            var content = DbUtil.ContentFromID(id);

            content.RemoveGrammarly();
            return(View(content));
        }
        public ActionResult ContentDelete(int id)
        {
            var content = DbUtil.ContentFromID(id);

            DbUtil.Db.Contents.DeleteOnSubmit(content);
            DbUtil.Db.SubmitChanges();
            return(RedirectToAction("Index", "Display"));
        }
Beispiel #3
0
        public ActionResult ContentDelete(int id)
        {
            var content = DbUtil.ContentFromID(id);

            DbUtil.Db.Contents.DeleteOnSubmit(content);
            DbUtil.Db.SubmitChanges();
            var url = GetIndexTabUrl(content);

            return(Redirect(url));
        }
Beispiel #4
0
        public ActionResult ContentDelete(int id)
        {
            var content = DbUtil.ContentFromID(id);

            CurrentDatabase.ExecuteCommand("DELETE FROM dbo.ContentKeywords WHERE Id = {0}", id);
            CurrentDatabase.ExecuteCommand("DELETE FROM dbo.Content WHERE Id = {0}", id);
            var url = GetIndexTabUrl(content);

            return(Redirect(url));
        }
Beispiel #5
0
        public ActionResult ContentUpdate(int id, string name, string title, string body, bool?snippet, int?roleid, string stayaftersave = null)
        {
            var content = DbUtil.ContentFromID(id);

            content.Name  = name;
            content.Title = string.IsNullOrWhiteSpace(title) ? name : title;
            content.Body  = body;
            content.RemoveGrammarly();
            content.RoleID  = roleid ?? 0;
            content.Snippet = snippet;

            if (content.TypeID == ContentTypeCode.TypeEmailTemplate)
            {
                try
                {
                    var captureWebPageBytes = CaptureWebPageBytes(body, 100, 150);
                    var ii = ImageData.Image.UpdateImageFromBits(content.ThumbID, captureWebPageBytes);
                    if (ii == null)
                    {
                        content.ThumbID = ImageData.Image.NewImageFromBits(captureWebPageBytes).Id;
                    }
                    content.DateCreated = DateTime.Now;
                }
                catch (Exception ex)
                {
                    var errorLog = ErrorLog.GetDefault(null);
                    errorLog.Log(new Error(ex));
                }
            }
            DbUtil.Db.SubmitChanges();

            if (string.Compare(content.Name, "StandardExtraValues2", StringComparison.OrdinalIgnoreCase) == 0)
            {
                try
                {
                    CmsData.ExtraValue.Views.GetStandardExtraValues(DbUtil.Db, "People");
                }
                catch (InvalidOperationException ex)
                {
                    if (ex.InnerException is System.Xml.XmlException)
                    {
                        return(Content(Util.EndShowMessage(ex.InnerException.Message, "javascript: history.go(-1)", "Go Back to Repair")));
                    }
                }
            }

            if (stayaftersave == "true")
            {
                return(RedirectToAction("ContentEdit", new { id, snippet }));
            }

            var url = GetIndexTabUrl(content);

            return(Redirect(url));
        }
Beispiel #6
0
        private int SaveDraft(int?draftId, string name, int roleId, string draftSubject,
                              string draftBody, string draftDesign, bool?useUnlayer)
        {
            Content content = null;

            if (draftId.HasValue && draftId > 0)
            {
                content = DbUtil.ContentFromID(draftId.Value);
            }

            if (content != null)
            {
                CurrentDatabase.ArchiveContent(draftId);
            }
            else
            {
                content = new Content
                {
                    Name = name.HasValue()
                        ? name
                        : "new draft " + DateTime.Now.FormatDateTm(),
                    TypeID  = ContentTypeCode.TypeSavedDraft,
                    RoleID  = roleId,
                    OwnerID = Util.UserId
                };
            }

            content.Title = draftSubject;

            if (useUnlayer.GetValueOrDefault())
            {
                var body = new { design = draftDesign, rawHtml = GetBody(draftBody) };
                content.Body   = JsonConvert.SerializeObject(body);
                content.TypeID = ContentTypeCode.TypeUnlayerSavedDraft;
            }
            else
            {
                content.Body = GetBody(draftBody);
            }

            content.Archived       = null;
            content.ArchivedFromId = null;

            content.DateCreated = DateTime.Now;

            if (!draftId.HasValue || draftId == 0)
            {
                CurrentDatabase.Contents.InsertOnSubmit(content);
            }

            CurrentDatabase.SubmitChanges();

            return(content.Id);
        }
Beispiel #7
0
        public ActionResult Content(int?id)
        {
            if (!id.HasValue)
            {
                throw new HttpException(404, "No ID found.");
            }

            var content = DbUtil.ContentFromID(id.Value);

            if (content == null)
            {
                throw new HttpException(404, "No ID found.");
            }
            return(Content(content.Body));
        }
Beispiel #8
0
        public ActionResult ContentEdit(int?id, bool?snippet)
        {
            if (!id.HasValue)
            {
                throw new HttpException(404, "No ID found.");
            }
            var content = DbUtil.ContentFromID(id.Value);

            if (snippet == true)
            {
                content.Snippet = true;
                DbUtil.Db.SubmitChanges();
            }
            return(RedirectEdit(content));
        }
Beispiel #9
0
        public ActionResult SaveDraft(int tagId, bool wantParents, int saveid, string name, string subject, string body, int roleid)
        {
            Content content = null;

            if (saveid > 0)
            {
                content = DbUtil.ContentFromID(saveid);
            }
            if (content == null)
            {
                content = new Content
                {
                    Name = name.HasValue() ? name
                        : "new draft " + DateTime.Now.FormatDateTm(),
                    TypeID = ContentTypeCode.TypeSavedDraft,
                    RoleID = roleid
                };
                content.OwnerID = Util.UserId;
            }

            content.Title = subject;
            content.Body  = body;

            content.DateCreated = DateTime.Now;

            if (saveid == 0)
            {
                DbUtil.Db.Contents.InsertOnSubmit(content);
            }
            DbUtil.Db.SubmitChanges();

            var m = new MassEmailer
            {
                TagId       = tagId,
                wantParents = wantParents,
                Host        = Util.Host,
                Subject     = subject,
            };

            System.Diagnostics.Debug.Print("Template ID: " + content.Id);

            ViewBag.parents    = wantParents;
            ViewBag.templateID = content.Id;
            return(View("Compose", m));
        }
Beispiel #10
0
        private static int SaveDraft(int?draftId, string name, int roleId, string draftSubject, string draftBody)
        {
            Content content = null;

            if (draftId.HasValue && draftId > 0)
            {
                content = DbUtil.ContentFromID(draftId.Value);
            }

            if (content != null)
            {
                DbUtil.Db.ArchiveContent(draftId);
            }
            else
            {
                content = new Content
                {
                    Name = name.HasValue()
                        ? name
                        : "new draft " + DateTime.Now.FormatDateTm(),
                    TypeID  = ContentTypeCode.TypeSavedDraft,
                    RoleID  = roleId,
                    OwnerID = Util.UserId
                };
            }

            content.Title          = draftSubject;
            content.Body           = GetBody(draftBody);
            content.Archived       = null;
            content.ArchivedFromId = null;

            content.DateCreated = DateTime.Now;

            if (!draftId.HasValue || draftId == 0)
            {
                DbUtil.Db.Contents.InsertOnSubmit(content);
            }

            DbUtil.Db.SubmitChanges();

            return(content.Id);
        }
Beispiel #11
0
        public ActionResult SaveDraft(int tagId, bool wantParents, int saveid, string name, string subject, string body, int roleid)
        {
            Content content;

            if (saveid > 0)
            {
                content = DbUtil.ContentFromID(saveid);
            }
            else
            {
                content = new Content {
                    Name = name, TypeID = ContentTypeCode.TypeSavedDraft, RoleID = roleid
                }
            };

            content.Title   = subject;
            content.Body    = body;
            content.OwnerID = Util.UserId;

            if (saveid == 0)
            {
                DbUtil.Db.Contents.InsertOnSubmit(content);
            }
            DbUtil.Db.SubmitChanges();

            var m = new MassEmailer
            {
                TagId       = tagId,
                wantParents = wantParents,
                CmsHost     = DbUtil.Db.CmsHost,
                Host        = Util.Host,
                Subject     = subject,
            };

            System.Diagnostics.Debug.Print("Template ID: " + content.Id);

            ViewBag.parents    = wantParents;
            ViewBag.templateID = content.Id;
            return(View("Compose", m));
        }
Beispiel #12
0
        public ActionResult EmailBody(int id)
        {
            var content = DbUtil.ContentFromID(id);

            return(View(content));
        }
        public ActionResult ContentUpdate(int id, string name, string title, string body, int?roleid, string stayaftersave = null)
        {
            var content = DbUtil.ContentFromID(id);

            content.Name   = name;
            content.Title  = title;
            content.Body   = body;
            content.RoleID = roleid ?? 0;

            string sRenderType = DbUtil.Db.Setting("RenderEmailTemplate", "none");

            if (content.TypeID == ContentTypeCode.TypeEmailTemplate)
            {
                //                switch (sRenderType)
                //                {
                //                    case "Local":// Uses local server resources
                //                    case "true":
                var captureWebPageBytes = CaptureWebPageBytes(body, 100, 150);
                var ii = ImageData.Image.UpdateImageFromBits(content.ThumbID, captureWebPageBytes);
                if (ii == null)
                {
                    content.ThumbID = ImageData.Image.NewImageFromBits(captureWebPageBytes).Id;
                }
                //                        break;
                //
                //                    case "Service": // Used to send HTML to another server for offloaded processing
                //                        var coll = new NameValueCollection();
                //                        coll.Add("sHTML", body.Replace("\r", "").Replace("\n", "").Replace("\t", ""));
                //
                //                        var wc = new WebClient();
                //                        var resp = wc.UploadValues(ConfigurationManager.AppSettings["CreateThumbnailService"], "POST",
                //                            coll);
                //
                //                        ii = ImageData.DbUtil.Db.Images.FirstOrDefault(i => i.Id == content.ThumbID);
                //                        if (ii != null)
                //                            ImageData.Image.UpdateImageFromBits(content.ThumbID, resp);
                //                        else
                //                            content.ThumbID = ImageData.Image.NewImageFromBits(resp).Id;
                //                        break;
                //                }
                content.DateCreated = DateTime.Now;
            }
            DbUtil.Db.SubmitChanges();

            if (string.Compare(content.Name, "StandardExtraValues2", ignoreCase: true) == 0)
            {
                try
                {
                    StandardExtraValues.GetExtraValues();
                }
                catch (InvalidOperationException ex)
                {
                    if (ex.InnerException is System.Xml.XmlException)
                    {
                        return(Content(Util.EndShowMessage(ex.InnerException.Message, "javascript: history.go(-1)", "Go Back to Repair")));
                    }
                }
            }

            if (stayaftersave == "true")
            {
                return(RedirectEdit(content));
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult ContentEdit(int id)
        {
            var content = DbUtil.ContentFromID(id);

            return(RedirectEdit(content));
        }
Beispiel #15
0
        public ActionResult ContentUpdate(int id, string name, string title, string body, bool?snippet, int?roleid, string contentKeyWords, string stayaftersave = null)
        {
            var content = DbUtil.ContentFromID(id);

            content.Name  = name;
            content.Title = string.IsNullOrWhiteSpace(title) ? name : title;
            content.Body  = body;
            content.RemoveGrammarly();
            content.RoleID  = roleid ?? 0;
            content.Snippet = snippet;
            content.SetKeyWords(CurrentDatabase, contentKeyWords.SplitStr(",").Select(vv => vv.Trim()).ToArray());

            if (content.TypeID == ContentTypeCode.TypeEmailTemplate)
            {
                try
                {
                    var captureWebPageBytes = CaptureWebPageBytes(body, 100, 150);
                    var ii = ImageData.Image.UpdateImageFromBits(content.ThumbID, captureWebPageBytes);
                    if (ii == null)
                    {
                        content.ThumbID = ImageData.Image.NewImageFromBits(captureWebPageBytes).Id;
                    }

                    content.DateCreated = DateTime.Now;
                }
                catch (Exception ex)
                {
                    var errorLog = ErrorLog.GetDefault(null);
                    errorLog.Log(new Error(ex));
                }
            }

            CurrentDatabase.SubmitChanges();

            if (string.Compare(content.Name, "CustomReportsMenu", StringComparison.OrdinalIgnoreCase) == 0)
            {
                try
                {
                    var list = ReportsMenuModel.CustomItems1;
                }
                catch (Exception ex)
                {
                    if (ex is System.Xml.XmlException)
                    {
                        return(Content(Util.EndShowMessage(ex.Message, "javascript: history.go(-1)", "There is invalid XML in this document. Go Back to Repair")));
                    }
                }
            }
            else if (string.Compare(content.Name, "CustomReports", StringComparison.OrdinalIgnoreCase) == 0)
            {
                try
                {
                    var list = CurrentDatabase.ViewCustomScriptRoles.ToList();
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("XML parsing", ignoreCase: true))
                    {
                        return(Content(Util.EndShowMessage(ex.InnerException?.Message, "javascript: history.go(-1)", "There is invalid XML in this document. Go Back to Repair")));
                    }
                }
            }
            else if (string.Compare(content.Name, "StandardExtraValues2", StringComparison.OrdinalIgnoreCase) == 0)
            {
                try
                {
                    CmsData.ExtraValue.Views.GetStandardExtraValues(CurrentDatabase, "People");
                }
                catch (InvalidOperationException ex)
                {
                    if (ex.InnerException is System.Xml.XmlException)
                    {
                        return(Content(Util.EndShowMessage(ex.InnerException.Message, "javascript: history.go(-1)", "There is invalid XML in this document. Go Back to Repair")));
                    }
                }
            }

            if (stayaftersave == "true")
            {
                return(RedirectToAction("ContentEdit", new { id, snippet }));
            }

            var url = GetIndexTabUrl(content);

            return(Redirect(url));
        }