예제 #1
0
        public ActionResult Create(FormCollection collection)
        {
            var htmlDesgin = new HtmlDesgin();

            try
            {
                this.RadynTryUpdateModel(htmlDesgin, collection);
                htmlDesgin.CurrentUICultureName = collection["LanguageId"];
                if (WebDesignComponent.Instance.HtmlFacade.Insert(this.WebSite.Id, htmlDesgin))
                {
                    ShowMessage(Resources.Common.InsertSuccessMessage, Resources.Common.MessaageTitle,
                                messageIcon: MessageIcon.Succeed);
                    return(RedirectToAction("Index"));
                }
                ShowMessage(Resources.Common.ErrorInInsert, Resources.Common.MessaageTitle,
                            messageIcon: MessageIcon.Error);
                return(RedirectToAction("Index"));
            }
            catch (Exception exception)
            {
                ShowMessage(Resources.Common.ErrorInInsert + exception.Message, Resources.Common.MessaageTitle,
                            messageIcon: MessageIcon.Error);
                return(View(htmlDesgin));
            }
        }
예제 #2
0
        public ActionResult Create(FormCollection collection)
        {
            var htmlDesgin = new HtmlDesgin();

            try
            {
                this.RadynTryUpdateModel(htmlDesgin, collection);
                htmlDesgin.Enabled = true;
                htmlDesgin.CurrentUICultureName = collection["LanguageId"];
                if (CongressComponent.Instance.BaseInfoComponents.CongressHtmlFacade.Insert(this.Homa.Id, htmlDesgin))
                {
                    ShowMessage(Resources.Common.InsertSuccessMessage, Resources.Common.MessaageTitle,
                                messageIcon: MessageIcon.Succeed);

                    return(Redirect("~/Congress/CongressHtml/Index"));
                }
                ShowMessage(Resources.Common.ErrorInInsert, Resources.Common.MessaageTitle,
                            messageIcon: MessageIcon.Error);

                return(Redirect("~/Congress/CongressHtml/Index"));
            }
            catch (Exception exception)
            {
                ShowExceptionMessage(exception);
                return(View(htmlDesgin));
            }
        }
예제 #3
0
 public bool Insert(Guid congressId, HtmlDesgin htmlDesgin)
 {
     try
     {
         this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
         this.ContentManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
         htmlDesgin.IsExternal = true;
         var htmlDesginTransactinalFacade =
             ContentManagerComponent.Instance.HtmlDesginTransactinalFacade(this.ContentManagerConnection);
         htmlDesgin.CurrentUICultureName = htmlDesgin.CurrentUICultureName;
         if (!htmlDesginTransactinalFacade.Insert(htmlDesgin))
         {
             throw new Exception("خطایی در ذخیره Html وجود دارد");
         }
         var congressHtml = new CongressHtml {
             HtmlDesginId = htmlDesgin.Id, CongressId = congressId
         };
         if (!new CongressHtmlBO().Insert(this.ConnectionHandler, congressHtml))
         {
             throw new Exception(Resources.Congress.ErrorInSaveCongressHtml);
         }
         this.ConnectionHandler.CommitTransaction();
         this.ContentManagerConnection.CommitTransaction();
         return(true);
     }
     catch (KnownException ex)
     {
         this.ConnectionHandler.RollBack();
         this.ContentManagerConnection.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         this.ConnectionHandler.RollBack();
         this.ContentManagerConnection.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }
예제 #4
0
        public bool Insert(Guid websiteId, HtmlDesgin htmlDesgin)
        {
            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.ContentManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                htmlDesgin.IsExternal = true;
                var htmlDesginTransactinalFacade =
                    ContentManagerComponent.Instance.HtmlDesginTransactinalFacade(this.ContentManagerConnection);
                htmlDesgin.CurrentUICultureName = htmlDesgin.CurrentUICultureName;
                if (!htmlDesginTransactinalFacade.Insert(htmlDesgin))
                {
                    throw new Exception("خطایی در ذخیره Html وجود دارد");
                }

                var congressHtml = new Html {
                    HtmlDesginId = htmlDesgin.Id, WebId = websiteId
                };
                if (!new HtmlBO().Insert(this.ConnectionHandler, congressHtml))
                {
                    throw new Exception("خطایی در ذخیره Html وجود دارد");
                }
                this.ConnectionHandler.CommitTransaction();
                this.ContentManagerConnection.CommitTransaction();
                return(true);
            }
            catch (KnownException knownException)
            {
                this.ConnectionHandler.RollBack();
                this.ContentManagerConnection.RollBack();
                throw new KnownException(knownException.Message, knownException);
            }
            catch (Exception ex)
            {
                this.ConnectionHandler.RollBack();
                this.ContentManagerConnection.RollBack();
                throw new KnownException(ex.Message, ex);
            }
        }
예제 #5
0
        public static string GetHtml(this Controller outcontroller, HtmlDesgin design, string htmlTitle, string resourceHtml = "", Guid?DefaultContrainerId = null, bool desginemode = false)
        {
            if (design == null || string.IsNullOrEmpty(design.Body))
            {
                return(string.Empty);
            }
            var       body = design.Body;
            var       partialLoadFacade = ContentManagerComponent.Instance.PartialLoadFacade;
            Container Defaultcontainer  = null;

            if (DefaultContrainerId.HasValue)
            {
                Defaultcontainer = ContentManagerComponent.Instance.ContainerFacade.Get(DefaultContrainerId);
            }
            var parser = new HtmlParser {
                ParseMethod = ParseMethod.All
            };
            var sbElements = new StringBuilder();

            parser.Parse(body);
            HtmlTag firsttag = null;
            var     htmlTag  = parser.Tags.First;

            if (htmlTag != null && !string.IsNullOrEmpty(htmlTag.Name))
            {
                firsttag = htmlTag;
            }
            else
            {
                for (var i = 0; i < parser.Tags.Count; i++)
                {
                    if (parser.Tags[i] == null || string.IsNullOrEmpty(parser.Tags[i].Name))
                    {
                        continue;
                    }
                    firsttag = parser.Tags[i];
                    break;
                }
            }
            if (firsttag != null)
            {
                var span = new TagBuilder(firsttag.Name);
                foreach (HtmlAttribute attribute in htmlTag.Attributes)
                {
                    if (span.Attributes.ContainsKey(attribute.Name))
                    {
                        span.Attributes[attribute.Name] =
                            firsttag.Attributes.AttributeValue(attribute.Value);
                    }
                    else
                    {
                        span.Attributes.Add(attribute.Name, attribute.Value);
                    }
                }


                var partialLoadlist = partialLoadFacade.GetHtmlPartials(design.Id, SessionParameters.Culture, Defaultcontainer);
                outcontroller.GetPartialHtmlByUrl(partialLoadlist, Defaultcontainer);
                if (firsttag.Tags.Count > 0)
                {
                    AddTag(ref span, outcontroller, htmlTitle, firsttag.Tags, partialLoadlist, resourceHtml, design.Id, desginemode);
                }
                sbElements.Append(span);
            }
            sbElements = sbElements.Replace("<theme>", "");
            sbElements = sbElements.Replace("</theme>", "");
            return(sbElements.ToString());
        }