Exemplo n.º 1
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var TypeId = UMC.Data.Utility.Guid(Web.UIDialog.AsyncDialog("Id", dkey =>
            {
                var menus = new List <UMC.Data.Entities.Menu>();
                UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Menu>().Order.Asc(new UMC.Data.Entities.Menu {
                    Seq = 0
                })
                .Entities.Query(dr => menus.Add(dr));
                //menubar

                var menu = new List <WebMeta>();

                foreach (var p in menus.FindAll(d => d.ParentId == Guid.Empty))
                {
                    var IsDisable = p.IsDisable == true;
                    var m         = new WebMeta().Put("icon", p.Icon).Put("text", p.Caption).Put("id", p.Id).Put("disable", p.IsDisable == true);

                    //m.Put("url")
                    menu.Add(m);
                    var data2 = new System.Data.DataTable();
                    data2.Columns.Add("id");
                    data2.Columns.Add("text");
                    data2.Columns.Add("url");
                    data2.Columns.Add("disable", typeof(bool));
                    var childs = menus.FindAll(c => c.ParentId == p.Id);
                    if (childs.Count > 0)
                    {
                        foreach (var ch in childs)
                        {
                            data2.Rows.Add(ch.Id, ch.Caption, ch.Url, IsDisable || ch.IsDisable == true);
                        }

                        m.Put("menu", data2);
                    }
                    else
                    {
                        m.Put("url", p.Url);
                    }
                }

                response.Redirect(menu);
                return(this.DialogValue("none"));
            }), true);

            var cateEntity = Database.Instance().ObjectEntity <UMC.Data.Entities.Menu>();


            cateEntity.Where.And().Equal(new UMC.Data.Entities.Menu
            {
                Id = TypeId ?? Guid.Empty
            });
            var link = cateEntity.Single() ?? new Data.Entities.Menu();

            var parentId = link.ParentId ?? UMC.Data.Utility.Guid(this.AsyncDialog("ParentId", "none")) ?? Guid.Empty;


            var userValue = this.AsyncDialog("Settings", d =>
            {
                var fdlg   = new Web.UIFormDialog();
                fdlg.Title = "菜单设置";

                if (parentId == Guid.Empty)
                {
                    fdlg.AddOption("菜单图标", "Icon", link.Icon, String.IsNullOrEmpty(link.Icon) ? "请选择" : "已选择").PlaceHolder("请参考UMC图标库")
                    .Command("System", "Icon");
                }
                fdlg.AddText("菜单标题", "Caption", link.Caption);
                if (parentId == Guid.Empty)
                {
                    fdlg.AddText("菜单网址", "Url", link.Url).NotRequired();
                }
                else
                {
                    fdlg.AddText("菜单网址", "Url", link.Url);//.Put("tip", "");
                }
                fdlg.AddNumber("展示顺序", "Seq", link.Seq);
                if (link.Id.HasValue)
                {
                    fdlg.AddCheckBox("", "Status", "n").Add("禁用此菜单", "Disable", link.IsDisable == true);
                    fdlg.AddUIIcon("\uf13e", "权限设置").Command(request.Model, "Auth", link.Id.ToString());
                }


                fdlg.Submit("确认", this.Context.Request, "Settings.Menu");
                return(fdlg);
            });

            UMC.Data.Reflection.SetProperty(link, userValue.GetDictionary());
            if (link.Id.HasValue)
            {
                link.IsDisable = (userValue["Status"] ?? "").Contains("Disable");
                cateEntity.Update(link);
                this.Prompt("更新成功", false);
            }
            else
            {
                link.ParentId  = parentId;
                link.Id        = Guid.NewGuid();
                link.IsDisable = false;
                cateEntity.Insert(link);
                this.Prompt("添加成功", false);
            }
            this.Context.Send(new UMC.Web.WebMeta().Put("type", "Settings.Menu"), true);
        }
Exemplo n.º 2
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var key = this.AsyncDialog("Key", g => this.DialogValue("Editer"));
            var sid = Web.UIDialog.AsyncDialog("Id", d =>
            {
                var grid = new SubjectCategoryDialog()
                {
                    IsPage       = true,
                    CloseEvent   = "UI.Event",
                    RefreshEvent = "Subject.Category"
                };
                if (!request.IsCashier)
                {
                    grid.Visible = Visibility.Visible;
                }
                if (request.IsMaster)
                {
                    grid.Menu("新建", request.Model, request.Command, new WebMeta("Key", "Editer", d, Guid.NewGuid().ToString()));
                }
                return(grid);
            });
            var cmdId = UMC.Data.Utility.Guid(sid) ?? Guid.Empty;

            var category = new Category();

            var objectEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Category>();

            category = objectEntity.Where.And().Equal(new Category {
                Id = cmdId
            }).Entities.Single() ?? category;

            if (key == "Editer" && request.IsMaster)
            {
            }
            else
            {
                this.Context.Send(new WebMeta().UIEvent(key, new ListItem(category.Caption, category.Id.ToString())), true);
            }
            var Settings = Web.UIFormDialog.AsyncDialog("Settings", d =>
            {
                var fmdg = new Web.UIFormDialog();
                if (category.Id.HasValue == false)
                {
                    fmdg.Title = "新建栏位";
                    fmdg.AddText("栏位名称", "Caption", category.Caption);
                    fmdg.AddOption("版务人员", "user_id", (category.user_id ?? Guid.Empty).ToString(), "请选择版务人员")
                    .Put("placeholder", "请选择版务人员").Command("Settings", "SelectUser");
                    fmdg.AddNumber("显示顺序", "Sequence", category.Sequence);
                }
                else
                {
                    fmdg.Title = "编辑栏位";
                    fmdg.AddText("栏位名称", "Caption", category.Caption);
                    var value = (category.user_id ?? Guid.Empty);
                    var text  = "请设置";
                    if (value != Guid.Empty)
                    {
                        var uAlias = UMC.Data.Database.Instance().ObjectEntity <User>()
                                     .Where.And().Equal(new User {
                            Id = value
                        }).Entities.Single();
                        if (uAlias != null)
                        {
                            text = uAlias.Alias;
                        }
                    }
                    fmdg.AddOption("版务人员", "user_id", value.ToString(), text).Put("placeholder", "请选择版务人员")
                    .Command("Settings", "SelectUser");
                    fmdg.AddNumber("显示顺序", "Sequence", category.Sequence);
                    fmdg.AddRadio("可见状态", "Visible")
                    .Put("可见", Visibility.Visible.ToString(), category.Visible == Visibility.Visible)
                    .Put("隐藏", Visibility.Hidden.ToString(), category.Visible == Visibility.Hidden);
                }
                fmdg.Submit("确认提交", request, "Subject.Category");
                if (category.Id.HasValue)
                {
                    fmdg.AddUI("专题主题设计", "去设计").Command("Design", "Page", category.Id.ToString());
                }
                return(fmdg);
            });

            UMC.Data.Reflection.SetProperty(category, Settings.GetDictionary());

            if (category.Id.HasValue == false)
            {
                category.Id = Guid.NewGuid();

                category.Count      = 0;
                category.Attentions = 0;
                category.Visible    = Visibility.Visible;

                objectEntity.Insert(category);
            }
            else
            {
                objectEntity.Update(category);
            }
            this.Prompt("修改成功", false);
            this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Category"), true);
        }