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

            try
            {
                this.RadynTryUpdateModel(MenuHtml, collection);
                MenuHtml.CurrentUICultureName = collection["LanguageId"];

                if (ContentManagerComponent.Instance.MenuHtmlFacade.Insert(MenuHtml))
                {
                    ShowMessage(Resources.Common.InsertSuccessMessage, Resources.Common.MessaageTitle,
                                messageIcon: MessageIcon.Succeed);
                    return(Redirect("~/ContentManager/MenuHtml/Index"));
                }
                ShowMessage(Resources.Common.ErrorInInsert, Resources.Common.MessaageTitle,
                            messageIcon: MessageIcon.Error);
                return(Redirect("~/ContentManager/MenuHtml/Index"));
            }
            catch (Exception exception)
            {
                ShowExceptionMessage(exception);
                return(View(MenuHtml));
            }
        }
예제 #2
0
        public ActionResult Create(FormCollection collection)
        {
            var MenuHtml = new MenuHtml();

            try
            {
                this.RadynTryUpdateModel(MenuHtml, collection);
                MenuHtml.CurrentUICultureName = collection["LanguageId"];
                MenuHtml.Enabled = true;
                if (WebDesignComponent.Instance.MenuHtmlFacade.Insert(this.WebSite.Id, MenuHtml))
                {
                    ShowMessage(Resources.Common.InsertSuccessMessage, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Succeed);
                    return(this.SubmitRedirect(collection, new { Id = MenuHtml.Id }));
                }
                ShowMessage(Resources.Common.ErrorInInsert, Resources.Common.MessaageTitle,
                            messageIcon: MessageIcon.Error);

                return(Redirect("~/WebDesign/MenuHtml/Index"));
            }
            catch (Exception exception)
            {
                ShowExceptionMessage(exception);
                return(View(MenuHtml));
            }
        }
예제 #3
0
        public bool Insert(Guid congressId, MenuHtml htmlDesgin)
        {
            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.ContentManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                htmlDesgin.IsExternal = true;
                var htmlDesginTransactinalFacade =
                    ContentManagerComponent.Instance.MenuHtmlTransactinalFacade(this.ContentManagerConnection);
                if (htmlDesgin.Enabled)
                {
                    var list = new CongressMenuHtmlBO().Where(this.ConnectionHandler,
                                                              html => html.CongressId == congressId);

                    foreach (var html in list)
                    {
                        html.MenuHtml.Enabled = false;
                        if (!htmlDesginTransactinalFacade.Update(html.MenuHtml))
                        {
                            throw new Exception("خطایی در ویرایش Html وجود دارد");
                        }
                    }
                }
                htmlDesgin.CurrentUICultureName = htmlDesgin.CurrentUICultureName;
                if (!htmlDesginTransactinalFacade.Insert(htmlDesgin))
                {
                    throw new Exception("خطایی در ذخیره Html وجود دارد");
                }
                var CongressMenuHtml = new CongressMenuHtml {
                    MenuHtmlId = htmlDesgin.Id, CongressId = congressId
                };
                if (!new CongressMenuHtmlBO().Insert(this.ConnectionHandler, CongressMenuHtml))
                {
                    throw new Exception("خطایی در ذخیره Html وجود دارد");
                }
                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 static void CreateMenuItem(IEntity entity)
        {
            var queue = MenuHtml.MenuHtmlCodeQueue(entity);

            using var sw = new StreamWriter(entity.Path + entity.FileName);

            while (queue.Any())
            {
                sw.WriteLine(queue.Dequeue());
            }
        }
예제 #5
0
        private void TView1_MouseDown(object sender, MouseEventArgs e)
        {
            TreeNode sTreeNode = TView1.GetNodeAt(e.X, e.Y);

            if (sTreeNode != null)
            {
                TView1.SelectedNode = sTreeNode;
                if (e.Button == MouseButtons.Right)
                {
                    MenuHtml.Show(TView1, e.X, e.Y);
                }
            }
        }
예제 #6
0
 public bool Insert(Guid WebSiteId, MenuHtml htmlDesgin)
 {
     try
     {
         this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
         this.ContentManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
         htmlDesgin.IsExternal = true;
         var htmlDesginTransactinalFacade = ContentManagerComponent.Instance.MenuHtmlTransactinalFacade(this.ContentManagerConnection);
         htmlDesgin.CurrentUICultureName = htmlDesgin.CurrentUICultureName;
         if (!htmlDesginTransactinalFacade.Insert(htmlDesgin))
         {
             throw new Exception("خطایی در ذخیره Html وجود دارد");
         }
         var CongressMenuHtml = new WebDesign.DataStructure.MenuHtml {
             MenuHtmlId = htmlDesgin.Id, WebSiteId = WebSiteId
         };
         if (!new MenuHtmlBO().Insert(this.ConnectionHandler, CongressMenuHtml))
         {
             throw new Exception("خطایی در ذخیره Html وجود دارد");
         }
         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);
     }
 }
예제 #7
0
 private static void GenerateChildMenuWithDynamicHtml(ref StringBuilder stringWriter, Menu getmenu, MenuHtml menuHtml)
 {
     foreach (var menu in getmenu.Children)
     {
         if (string.IsNullOrEmpty(menu.Text))
         {
             continue;
         }
         if (menu.Children.Count > 0)
         {
             var subMenuBodyreplace = menuHtml.HasChildBody.Replace("{menutitle}", menu.Text);
             var value            = subMenuBodyreplace.Replace("{menulink}", GetMenuLink(menu));
             var stringWritercild = new StringBuilder();
             GenerateChildMenuWithDynamicHtml(ref stringWritercild, menu, menuHtml);
             stringWriter.Append(value.Replace("{childbody}", stringWritercild.ToString()));
         }
         else
         {
             var replace  = menuHtml.ChildMenuBody.Replace("{menutitle}", menu.Text);
             var valuesum = replace.Replace("{menulink}", GetMenuLink(menu));
             stringWriter.Append(valuesum);
         }
     }
 }
예제 #8
0
        public static string GenerateMenuWithDynamicHtml(this IEnumerable <Menu> enumerable, MenuHtml menuHtml)
        {
            if (menuHtml == null || string.IsNullOrEmpty(menuHtml.ChildMenuBody) ||
                string.IsNullOrEmpty(menuHtml.MasterBody) || string.IsNullOrEmpty(menuHtml.HasChildBody) || string.IsNullOrEmpty(menuHtml.RootMenuBody))
            {
                return(string.Empty);
            }
            var stringWriter = new StringBuilder();

            foreach (var menu in enumerable)
            {
                if (string.IsNullOrEmpty(menu.Text))
                {
                    continue;
                }

                if (menu.Children.Count > 0)
                {
                    var subMenuBodyreplace = menuHtml.HasChildBody.Replace("{menutitle}", menu.Text);
                    var value            = subMenuBodyreplace.Replace("{menulink}", GetMenuLink(menu));
                    var stringWritercild = new StringBuilder();
                    GenerateChildMenuWithDynamicHtml(ref stringWritercild, menu, menuHtml);
                    stringWriter.Append(value.Replace("{childbody}", stringWritercild.ToString()));
                }
                else
                {
                    var replace  = menuHtml.RootMenuBody.Replace("{menutitle}", menu.Text);
                    var valuesum = replace.Replace("{menulink}", GetMenuLink(menu));
                    stringWriter.Append(valuesum);
                }
            }
            var newValue = stringWriter.ToString();

            return(menuHtml.MasterBody.Replace("{childbody}", newValue));
        }