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); }
void Setting(Guid userId) { var userEntity = UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.User>(); var user = userEntity.Where.And().Equal(new Data.Entities.User { Id = userId }).Entities.Single(); var userRoleEntity = UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.UserToRole>(); userRoleEntity.Where.And().Equal(new Data.Entities.UserToRole { user_id = user.Id }); var roleEntity = UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Role>(); roleEntity.Where.And().Unequal(new Data.Entities.Role { Rolename = UMC.Security.Membership.GuestRole }); var userValue = Web.UIFormDialog.AsyncDialog("User", d => { var fdlg = new Web.UIFormDialog(); fdlg.Menu("角色", "Settings", "Role"); fdlg.Title = String.Format("账户设置", user.Username); var opts2 = new Web.ListItemCollection(); opts2.Add("别名", user.Alias); opts2.Add("登录名", user.Username); if (user.ActiveTime.HasValue) { opts2.Add("最后登录", String.Format("{0:yy-MM-dd HH:mm}", user.ActiveTime)); } if (user.RegistrTime.HasValue) { opts2.Add("注册时间", String.Format("{0:yy-MM-dd HH:mm}", user.RegistrTime)); } fdlg.AddTextValue(opts2); var flags = user.Flags ?? UMC.Security.UserFlags.Normal; var opts = new Web.ListItemCollection(); var selected = ((int)(flags & UMC.Security.UserFlags.Lock)) > 0; opts.Add("锁定", "1", selected); selected = ((int)(flags & UMC.Security.UserFlags.Disabled)) > 0; opts.Add("禁用", "16", selected); fdlg.AddCheckBox("状态", "Flags", opts, "0"); var uRs = new List <UMC.Data.Entities.UserToRole>(userRoleEntity.Query()); opts = new Web.ListItemCollection(); roleEntity.Query(dr => { switch (dr.Rolename) { case UMC.Security.Membership.AdminRole: opts.Add("超级管理员", dr.Id.ToString(), uRs.Exists(ur => ur.role_id == dr.Id)); break; case UMC.Security.Membership.UserRole: opts.Add("内部员工", dr.Id.ToString(), uRs.Exists(ur => ur.role_id == dr.Id)); break; case "TrainAdmin": opts.Add("培训管理员", dr.Id.ToString(), uRs.Exists(ur => ur.role_id == dr.Id)); break; case "StoreManager": opts.Add("店长", dr.Id.ToString(), uRs.Exists(ur => ur.role_id == dr.Id)); break; case "Finance": opts.Add("财务", dr.Id.ToString(), uRs.Exists(ur => ur.role_id == dr.Id)); break; default: opts.Add(dr.Rolename, dr.Id.ToString(), uRs.Exists(ur => ur.role_id == dr.Id)); break; } }); fdlg.AddCheckBox("部门角色", "Roles", opts, "None"); return(fdlg); }); var Flags = UMC.Security.UserFlags.Normal; foreach (var k in userValue["Flags"].Split(',')) { Flags = Flags | UMC.Data.Utility.Parse(k, UMC.Security.UserFlags.Normal); } userEntity.Update(new Data.Entities.User { Flags = Flags, Alias = userValue["Alias"] }); if ((Flags & Security.UserFlags.Disabled) == Security.UserFlags.Disabled) { UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Session>() .Where.And().Equal(new Data.Entities.Session { user_id = user.Id }).Entities.Delete(); } var rids = new List <Data.Entities.UserToRole>(); foreach (var k in userValue["Roles"].Split(',')) { switch (k) { case "None": break; default: rids.Add(new Data.Entities.UserToRole { role_id = new Guid(k), user_id = userId }); break; } } userRoleEntity.Delete(); if (rids.Count > 0) { userRoleEntity.Insert(rids.ToArray()); UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Session>() .Where.And().Equal(new Data.Entities.Session { user_id = userId }).Entities.Delete(); } UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Session>() .Where.And().Equal(new Data.Entities.Session { user_id = userId }).Entities.Delete(); this.Prompt("设置成功"); }
public override void ProcessActivity(WebRequest request, WebResponse response) { var key = this.AsyncDialog("Key", g => this.DialogValue("EDITER")); var user = Security.Identity.Current; var sid = Web.UIDialog.AsyncDialog("Id", d => { if (request.SendValues == null || request.SendValues.ContainsKey("start") == false) { var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments); buider.CloseEvent("UI.Event"); buider.RefreshEvent("Subject.ProjectItem"); this.Context.Send(buider.Builder(), true); } UITitle title = UITitle.Create(); title.Title = "我参与的项目"; switch (key) { case "EDITER": break; default: title.Title = "选择项目"; break; } var ui = UISection.Create(title); Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project { user_id = user.Id }) .And().In("Id", Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember { user_id = user.Id }) .And().In(new ProjectMember { AuthType = WebAuthType.Admin }, WebAuthType.User).Entities.Script(new ProjectMember { project_id = Guid.Empty })).Entities.Order.Asc(new Project { Sequence = 0 }).Entities.Query(dr => { ui.AddCell(dr.Caption, new UIClick(new WebMeta(request.Arguments).Put("Id", dr.Id)).Send(request.Model, request.Command)); }); if (ui.Length == 0) { ui.Add("Desc", new UMC.Web.WebMeta().Put("desc", "你未有编辑权限的项目").Put("icon", "\uF016"), new UMC.Web.WebMeta().Put("desc", "{icon}\n{desc}"), new UIStyle().Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60))); } response.Redirect(ui); return(this.DialogValue("none")); }); var cmdId = UMC.Data.Utility.Guid(sid) ?? Guid.Empty; var category = new ProjectItem(); var objectEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectItem>(); category = objectEntity.Where.And().Equal(new ProjectItem { Id = cmdId }).Entities.Single() ?? category; switch (key) { case "EDITER": break; default: this.Context.Send(new WebMeta().UIEvent(key, new ListItem(category.Caption, category.Id.ToString())), true); break; } var Project = Utility.Guid(this.AsyncDialog("Project", g => this.DialogValue("Team"))).Value; var project = Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>().Where.And().Equal(new Data.Entities.Project { Id = Project }) .Entities.Single(); if (project != null && project.user_id == user.Id) { } else { var member = Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember { project_id = Project, user_id = user.Id }).Entities.Single(); if (member != null) { switch (member.AuthType) { case WebAuthType.Admin: break; default: this.Prompt("您未有编辑栏位权限"); break; } } else { this.Prompt("您未有编辑栏位权限"); } } var Caption = this.AsyncDialog("Caption", d => { var fmdg = new Web.UIFormDialog(); fmdg.Title = category.Id.HasValue ? "编辑栏位" : "新建栏位"; fmdg.AddText("栏位名称", "Caption", category.Caption); if (category.Id.HasValue) { fmdg.AddText("栏位简码", "Code", category.Code); fmdg.AddCheckBox("", "Status", "NO").Put("隐藏", "Hide", category.Hide == true).Put("删除", "DEL"); } fmdg.Submit("确认", request, "Subject.ProjectItem", "Subject.ProjectItem.Del"); return(fmdg); }); var team = new ProjectItem(); UMC.Data.Reflection.SetProperty(team, Caption.GetDictionary()); if (category.Id.HasValue == false) { team.Id = Guid.NewGuid(); team.project_id = Project; team.Code = Utility.Parse36Encode(team.Id.Value.GetHashCode()); team.user_id = user.Id; team.CreationTime = DateTime.Now; team.Sequence = Utility.TimeSpan(); team.Hide = false; objectEntity.Insert(team); var portfolio = new Portfolio() { Id = Guid.NewGuid(), Caption = "随笔", Count = 0, CreationTime = DateTime.Now, Sequence = 0, user_id = user.Id, project_item_id = team.Id, project_id = Project, }; Utility.CMS.ObjectEntity <UMC.Data.Entities.Portfolio>() .Insert(portfolio); Utility.CMS.ObjectEntity <ProjectDynamic>() .Insert(new ProjectDynamic { Time = Utility.TimeSpan(), user_id = user.Id, Explain = "创建了栏位", project_id = portfolio.project_id, refer_id = portfolio.Id, Title = portfolio.Caption, Type = DynamicType.ProjectItem }); this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.ProjectItem").Put("id", team.Id).Put("text", team.Caption) .Put("path", String.Format("{0}/{1}", project.Code, team.Code)) , true); } else { var status = Caption["Status"] ?? ""; if (status.Contains("DEL")) { if (Utility.CMS.ObjectEntity <ProjectItem>().Where.And().Equal(new ProjectItem { project_id = category.project_id.Value }).Entities.Count() == 1) { this.Prompt("最少需要一个栏位"); } Utility.CMS.ObjectEntity <Portfolio>().Where.And().Equal(new Portfolio { project_item_id = category.Id }).Entities.Delete(); Utility.CMS.ObjectEntity <Subject>().Where.And().Equal(new Subject { project_item_id = category.Id }).Entities.Update(new Subject { last_user_id = user.Id, LastDate = DateTime.Now, Visible = -1 }); objectEntity.Delete(); Utility.CMS.ObjectEntity <ProjectDynamic>() .Insert(new ProjectDynamic { Time = Utility.TimeSpan(), //DateTime.Now, user_id = user.Id, Explain = "删除了栏位", project_id = category.project_id, refer_id = category.Id, Title = category.Caption, Type = DynamicType.ProjectItem }); this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.ProjectItem.Del").Put("id", category.Id).Put("text", team.Caption), true); } else { if (String.Equals(team.Code, category.Code, StringComparison.CurrentCulture) == false) { if (Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectItem>() .Where.And().Equal(new ProjectItem { Code = team.Code, project_id = category.project_id }).Entities.Count() > 0) { this.Prompt("存在相同的简码"); } } team.Hide = status.Contains("Hide"); objectEntity.Update(team); Utility.CMS.ObjectEntity <ProjectDynamic>() .Insert(new ProjectDynamic { Time = Utility.TimeSpan(), user_id = user.Id, Explain = "修改了栏位", project_id = category.project_id, refer_id = category.Id, Title = category.Caption, Type = DynamicType.ProjectItem }); this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.ProjectItem").Put("id", category.Id).Put("text", team.Caption), true); } } this.Prompt("修改成功"); }