void Portfolio(Guid projectid, WebResponse response) { var ids = new List <Guid>(); var user = UMC.Security.Identity.Current; var projectEntity = Utility.CMS.ObjectEntity <ProjectItem>(); var project = projectEntity.Where.And().In(new ProjectItem { Id = projectid }).Entities.Single(); var team = Utility.CMS.ObjectEntity <Project>().Where.And().In(new Project { Id = project.project_id }).Entities.Single(); var editer = team.user_id == user.Id; int status = 1; if (editer == false) { status = -1; var member = Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember { project_id = team.Id, user_id = user.Id }).Entities.Single(); if (member != null) { switch (member.AuthType) { case WebAuthType.Admin: status = 1; break; case WebAuthType.All: status = -1; break; case WebAuthType.Guest: status = -1; break; case WebAuthType.User: status = 1; break; } } } var menu = new WebMeta(); menu.Put("nav", String.Format("{0}/{1}", team.Code, project.Code)); menu.Put("subs", Portfolio(team, project, status)); response.Redirect(menu);// //return Portfolio(team, project, status); }
void Append() { if (data.Count > 0 || dataText.Length > 0) { if (dataText.Length > 0) { data.Put("m" + data.Count.ToString(), dataText.ToString()); } dataText = new StringBuilder(); var sb = new StringBuilder(); for (int i = 0; i < data.Count; i++) { sb.Append("{m"); sb.Append(i); sb.Append("}"); } var cell = UICell.Create(data["type"] ?? "CMSText", data); data.Remove("type"); cell.Format.Put("text", sb.ToString()); cell.Style.Copy(style); cells.Add(cell); data = new WebMeta(); style = new UIStyle(); } }
public override void ProcessActivity(WebRequest request, WebResponse response) { var ids = new List <String>(); var menus = new List <UMC.Data.Entities.Menu>(); UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Menu>().Where.And().Equal(new Data.Entities.Menu { IsDisable = false }).Entities.Order.Asc(new UMC.Data.Entities.Menu { Seq = 0 }) .Entities.Query(dr => { ids.Add(dr.Id.ToString()); menus.Add(dr); }); var auths = Security.AuthManager.IsAuthorization(ids.ToArray()); var menu = new List <WebMeta>(); foreach (var p in menus.FindAll(d => d.ParentId == Guid.Empty)) { var m = new WebMeta().Put("icon", p.Icon).Put("text", p.Caption).Put("id", p.Id); if (auths[ids.IndexOf(p.Id.ToString())] == false) { continue; } var data2 = new System.Data.DataTable(); data2.Columns.Add("id"); data2.Columns.Add("text"); data2.Columns.Add("url"); var childs = menus.FindAll(c => c.ParentId == p.Id); if (childs.Count > 0) { childs = childs.FindAll(d => auths[ids.IndexOf(d.Id.ToString())]); if (childs.Count == 0) { continue; } foreach (var ch in childs) { data2.Rows.Add(ch.Id, ch.Caption, ch.Url); } m.Put("menu", data2); } else { m.Put("url", p.Url); } menu.Add(m); } response.Redirect(menu); }
void Items(Design_Item parent, List <Design_Item> baners, UISection U) { Guid parentId = parent.Id.Value; //List<UIItem> list = new List<UIItem>(); var item = new UIItems(); UMC.Data.WebResource webr = UMC.Data.WebResource.Instance(); for (int i = 0; i < baners.Count && i < 4; i++) { Design_Item b = baners[i]; WebMeta icon = UMC.Data.JSON.Deserialize <WebMeta>(b.Data) ?? new UMC.Web.WebMeta(); item.Add(icon); icon.Put("click", this.Click(b)); String t = "100"; switch (baners.Count) { case 1: t = "4-1"; break; case 2: t = "2-1"; break; case 3: if (i == 0) { t = "2-1"; } break; } icon.Put("src", String.Format("{0}!{1}?{2}", webr.ImageResolve(b.Id.Value, "1", 0), t, TimeSpan(b.ModifiedDate))); //list.Add(slider); } if (item.Count > 0) { U.Add(item); } else if (_editer) { ; UIDesc desc = new UIDesc("\ue907"); desc.Desc("{desc}\r\n配置分块栏"); desc.Style.AlignCenter().Name("desc", new UIStyle().Font("wdk").Size(38).Click(new UIClick(parentId.ToString()) .Send("Design", "Item"))); U.Add(desc); } }
public UISheet AddItem(String text, string desc, bool isInfo) { var b = new WebMeta().Put("text", text, "desc", desc); if (isInfo) { b.Put("icon", '\uF05A'); } else { b.Put("info", '\uF05D'); } this.items.Add(b); return(this); }
public UIDiscount(UIClick click) { //var t = Create(); data = new WebMeta(); data.Put("click", click); this.Type = "Discount"; //return t; }
public override void ProcessActivity(WebRequest request, WebResponse response) { var oosr = WebResource.Instance(); var Key = this.AsyncDialog("Key", g => { var f = Web.UIDialog.CreateDialog("File"); f.Config.Put("Submit", new UIClick(new WebMeta().Put("Key", "WebResource", "media_id", "Value", "UI", this.AsyncDialog("UI", "none"))) { Command = request.Command, Model = request.Model }); return(f); }); var user = Security.Identity.Current; var media_id = this.AsyncDialog("media_id", "none"); if (String.Equals(media_id, "none") == false) { var url = new Uri(media_id); var name = url.AbsolutePath.Substring(url.AbsolutePath.LastIndexOf('/') + 1); var urlKey = String.Format("UserResources/{0}/{1}/{2}", Utility.Parse62Encode(user.Id.Value.GetHashCode()), Utility.TimeSpan(), name); oosr.Transfer(url, urlKey); var posmata = new WebMeta(); posmata.Put("src", String.Format("{0}{1}", oosr.WebDomain(), urlKey)).Put("name", name); this.Context.Send(new WebMeta().UIEvent(Key, this.AsyncDialog("UI", "none"), posmata), true); } else { var UseKey = UMC.Data.Utility.Parse36Encode(UMC.Security.Identity.Current.Id.Value.GetHashCode()); var sourceKey = new Uri(String.Format("{2}TEMP/{0}/{1}", UMC.Data.Utility.GetRoot(request.Url), Key, oosr.TempDomain())); Key = String.Format("UserResources/{0}/{1}", UseKey, Key); oosr.Transfer(sourceKey, Key); response.Redirect(new WebMeta().Put("src", String.Format("{0}{1}", oosr.WebDomain(), Key))); } }
public override void ProcessActivity(WebRequest request, WebResponse response) { var subId = UMC.Data.Utility.Guid(this.AsyncDialog("Id", request.Model, "Select")); var sub = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>() .Where//.And().In(new Subject { portfolio_id = ids[0] }, ids.ToArray()) .And().Equal(new Subject { Id = subId }).Entities.Single(new Subject { project_id = Guid.Empty }); var user = UMC.Security.Identity.Current; if (user.IsAuthenticated == false) { this.Prompt("请登录", false); response.Redirect("Account", "Login"); } var meta = new WebMeta(); if (sub.project_id.HasValue) { var project = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Project { Id = sub.project_id.Value }).Entities.Single(); if (project != null && project.user_id == user.Id) { } else { meta.Put("Project", sub.project_id); var member = Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember { project_id = sub.project_id, user_id = user.Id }).Entities.Single(); if (member != null) { switch (member.AuthType) { case WebAuthType.Admin: case WebAuthType.User: break; default: this.Prompt("您未有编辑此图文的权限"); break; } } else { this.Prompt("您未有编辑此图文的权限"); } } } var sid = UMC.Data.Utility.Guid(this.AsyncDialog("Portfolio", request.Model, "Portfolio", meta)); var Portfolios = new List <Portfolio>(); var ids = new List <Guid>(); var scheduleEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Portfolio>(); var portfolio = scheduleEntity.Where.And().Equal(new Portfolio { Id = sid }).Entities.Single(); Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>() .Where .And().Equal(new Subject { Id = subId }) .Entities.Update(new Subject { portfolio_id = sid, project_item_id = portfolio.project_item_id, project_id = portfolio.project_id }); this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Portfolio.Change").Put("Id", portfolio.Id).Put("Sub", subId), false); }
UIImageTitleDescBottom TitleDesc(WebMeta config, Design_Item item, String img, UMC.Data.WebResource webr) { //WebMeta data = Utility.isNull(UMC.Data.JSON.deserialize(item.Data, WebMeta.class), new UMC.Web.WebMeta()); WebMeta data = UMC.Data.JSON.Deserialize <WebMeta>(item.Data) ?? new UMC.Web.WebMeta(); int m = 0; String hide = config.Get("Hide") ?? ""; if (hide.Contains("HideTitle")) { m |= 1; data.Remove("title"); } if (hide.Contains("HideDesc")) { m |= 2; data.Remove("desc"); } if (hide.Contains("HideLeft")) { m |= 4; data.Remove("left"); } if (hide.Contains("HideRight")) { m |= 8; data.Remove("right"); } data.Put("show", m); String src = (String.Format("{0}!{1}?{2}", webr.ImageResolve(item.Id.Value, "1", 0), img, TimeSpan(item.ModifiedDate))); // list.add(slider); // UIImageTitleDescBottom btm = new UIImageTitleDescBottom(data, src); btm.Click(this.Click(item)); var left = data["left"]; if (String.IsNullOrEmpty(left) == false) { var p = @"\d+\.?\d{0,2}"; int i = -1; var t = System.Text.RegularExpressions.Regex.Replace(left, p, dr => { i++; switch (i) { case 0: data.Put("price", dr.Value); return("¥{1:price} "); case 1: data.Put("orgin", dr.Value); return(" {orgin}"); } return(dr.Value); }, System.Text.RegularExpressions.RegexOptions.Multiline); btm.Left(t); btm.Style.Name("price", new UIStyle().Size(16).Color(0xdb3652)).Name("unit", new UIStyle().Size(12).Color(0x999)).Name("orgin", new UIStyle().Color(0x999).Size(12).DelLine()); } ; return(btm); }
public static List <WebMeta> Portfolio(Project team, ProjectItem project, int status) { var Portfolios = new List <Portfolio>(); var ids = new List <Guid>(); var scheduleEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Portfolio>(); scheduleEntity.Where.And().Equal(new Portfolio { project_item_id = project.Id }); scheduleEntity.Order.Asc(new Portfolio { Sequence = 0 }); scheduleEntity.Query(dr => { Portfolios.Add(dr); ids.Add(dr.Id.Value); }); var subs = new List <Subject>(); if (ids.Count > 0) { var objectEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>() .Where.And().In(new Subject { portfolio_id = ids[0] }, ids.ToArray()) .And().Equal(new Subject { Visible = 1 }) .Entities.Order.Asc(new Subject { Seq = 0 }); if (status == -1) { objectEntity.Entities.Where.And().Equal(new Subject { Status = 1 }); } objectEntity.Entities.Query(new Subject { Id = Guid.Empty, Title = String.Empty, portfolio_id = Guid.Empty, Code = String.Empty }, dr => subs.Add(dr)); } var data = new List <WebMeta>(); foreach (var p in Portfolios) { var meta = new WebMeta(); meta.Put("id", p.Id).Put("text", p.Caption); var csubs = subs.FindAll(s => s.portfolio_id == p.Id); var dcsub = new List <WebMeta>(); foreach (var cs in csubs) { var mta = new WebMeta().Put("id", cs.Id).Put("text", cs.Title); mta.Put("path", String.Format("{0}/{1}/{2}", team.Code, project.Code, String.IsNullOrEmpty(cs.Code) ? "none" : cs.Code)); dcsub.Add(mta);; } meta.Put("subs", dcsub); if (status < 1 && dcsub.Count == 0) { continue; } data.Add(meta); } return(data); }
List <WebMeta> Portfolio(Guid project_id, Guid subid) { var Portfolios = new List <Portfolio>(); var ids = new List <Guid>(); var scheduleEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Portfolio>(); scheduleEntity.Where.And().Equal(new Portfolio { project_item_id = project_id }); scheduleEntity.Order.Asc(new Portfolio { Sequence = 0 }); scheduleEntity.Query(dr => { Portfolios.Add(dr); ids.Add(dr.Id.Value); }); var subs = new List <Subject>(); if (ids.Count > 0) { var objectEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>() .Where.And().In(new Subject { portfolio_id = ids[0] }, ids.ToArray()) .And().Unequal(new Subject { Id = subid }) .Entities.Order.Asc(new Subject { Seq = 0 }).Entities; objectEntity.Where.And().Equal(new Subject { Status = 1 }); objectEntity.Query(new Subject { Id = Guid.Empty, Title = String.Empty, portfolio_id = Guid.Empty, Code = String.Empty }, dr => subs.Add(dr)); } var data = new List <WebMeta>(); foreach (var p in Portfolios) { var meta = new WebMeta(); meta.Put("id", p.Id).Put("text", p.Caption); var csubs = subs.FindAll(s => s.portfolio_id == p.Id); var dcsub = new List <WebMeta>(); foreach (var cs in csubs) { var mta = new WebMeta().Put("id", cs.Id).Put("text", cs.Title); dcsub.Add(mta);; } meta.Put("subs", dcsub); if (dcsub.Count == 0) { continue; } data.Add(meta); } return(data); }
public override void ProcessActivity(WebRequest request, WebResponse response) { var identity = UMC.Security.Identity.Current; var userId = Utility.Guid(this.AsyncDialog("Id", g => { if (identity.IsAuthenticated == false) { response.Redirect("Account", "Login"); } return(this.DialogValue(identity.Id.ToString())); }), true); var form = (request.SendValues ?? new UMC.Web.WebMeta()).GetDictionary(); var webr = UMC.Data.WebResource.Instance(); if (form.ContainsKey("limit") == false) { var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments); this.Context.Send(buider.Builder(), true); } int start = UMC.Data.Utility.IntParse(form["start"] as string, 0); UISection ui, ui2; var selectIndex = UMC.Data.Utility.IntParse(this.AsyncDialog("selectIndex", g => this.DialogValue("0")), 0); var items = new List <WebMeta>(); items.Add(new UMC.Web.WebMeta().Put("text", "知识录", "search", "Subs", "Key", "List")); items.Add(new UMC.Web.WebMeta().Put("text", "参与项目", "search", "Project", "Key", "List")); items.Add(new UMC.Web.WebMeta().Put("text", "个人动态", "search", "Dynamic", "Key", "List")); var Keyword = (form["Keyword"] as string ?? String.Empty); if (String.IsNullOrEmpty(Keyword) && selectIndex > -1) { Keyword = items[selectIndex]["search"]; } var nextKey = this.AsyncDialog("NextKey", g => this.DialogValue("Header"));; if (start == 0 && String.Equals(nextKey, "Header")) { var sign = Utility.CMS.ObjectEntity <Data.Entities.Account>() .Where.And().Equal(new Data.Entities.Account { user_id = userId, Type = Security.Account.SIGNATURE_ACCOUNT_KEY }).Entities.Single(); var logoUrl = webr.ResolveUrl(userId.Value, "1", 4); var members = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>() .Where.And().Equal(new Data.Entities.ProjectMember { user_id = userId }) .Entities.Count(); var suject = Utility.CMS.ObjectEntity <Subject>() .Where.And().Equal(new Subject { user_id = userId }) .Entities.GroupBy().Sum(new Subject { Reply = 0 }) .Sum(new Subject { Look = 0 }).Count(new Subject { Seq = 0 }).Single(); var Discount = new UIHeader.Portrait(logoUrl); ; var user = identity.Id == userId ? new User { Id = identity.Id, Alias = identity.Alias } : Utility.CMS.ObjectEntity <Data.Entities.User>() .Where.And().Equal(new Data.Entities.User { Id = userId }).Entities.Single(); if (user != null) { Discount.Value(user.Alias); } else { var member = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>() .Where.And().Equal(new Data.Entities.ProjectMember { user_id = userId }) .Entities.Single(); if (member != null) { Discount.Value(member.Alias); } } if (sign != null) { Discount.Time(sign.Name);// user.ActiveTime.ToString()); } var color = 0x63b359; Discount.Gradient(color, color); var header = new UIHeader(); var title = UITitle.Create(); title.Title = identity.Id == userId ? "我的知识录" : "成员详情"; header.AddPortrait(Discount); title.Style.BgColor(color); title.Style.Color(0xfff); ui = UISection.Create(header, title); var uIIcon = new UIIconNameDesc(new UIIconNameDesc.Item('\uF02d', "知识创作", suject.Seq + "篇").Color(0x36a3f7), new UIIconNameDesc.Item('\uF19d', "关注项目", members + "项").Color(0x40c9c6)); ui.Add(uIIcon); ui2 = ui.NewSection(); } else { ui2 = ui = UISection.Create(); } ui2.Key = "List"; if (start == 0 && String.Equals(nextKey, "Self") == false) { if (selectIndex > 0) { ui2.Add(UICell.Create("TabFixed", new UMC.Web.WebMeta().Put("items", items).Put("selectIndex", selectIndex))); } else { ui2.Add(UICell.Create("TabFixed", new UMC.Web.WebMeta().Put("items", items)));; } } int limit = UMC.Data.Utility.IntParse(form["limit"] as string, 25); switch (Keyword) { default: case "Subs": { var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>(); subEntity.Order.Desc(new Subject { ReleaseDate = DateTime.Now }); subEntity.Where.And().Equal(new Data.Entities.Subject { Status = 1, IsDraught = false, user_id = userId }); subEntity.Where.And().Greater(new Subject { Visible = -1 }); SubjectUIActivity.Search(request.Model, ui2, subEntity, start, limit); if (ui2.Total == 0) { ui2.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))); } } break; case "Project": { var ids = new List <Guid>(); var subMebs = new List <ProjectMember>(); var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>(); subEntity.Where.And().Equal(new ProjectMember { user_id = userId }); subEntity.Order.Desc(new ProjectMember { AuthType = 0 }).Desc(new ProjectMember { CreationTime = DateTime.Now });; subEntity.Query(start, limit, dr => { ids.Add(dr.project_id.Value); subMebs.Add(dr); }); var proEntity = Utility.CMS.ObjectEntity <Project>(); if (start == 0) { proEntity.Where.And().Equal(new Project { user_id = userId }); } if (ids.Count > 0) { proEntity.Where.Or().In(new Project { Id = ids[0] }, ids.ToArray()); } var projects = new List <Project>(); var pids = new List <Guid>(); proEntity.Query(dr => { projects.Add(dr); pids.Add(dr.Id.Value); }); if (projects.Count > 0) { var subs = new List <Subject>(); Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>() .Where.And().In(new Subject { project_id = pids[0] }, pids.ToArray()) .Entities.GroupBy(new Subject { project_id = Guid.Empty }).Count(new Subject { Seq = 0 }).Query(dr => subs.Add(dr)); if (start == 0) { var mp = projects.FindAll(p => p.user_id == userId); foreach (var p in mp) { var sub = subs.Find(s => s.project_id == p.Id); var cellUI = new UIIconNameDesc(new UIIconNameDesc.Item(webr.ResolveUrl(p.Id.Value, "1", "4"), p.Caption, String.Format("知识{0}篇", sub == null ? 0 : sub.Seq)) .Click(request.IsApp ? UIClick.Pager(request.Model, "ProjectUI", new WebMeta().Put("Id", p.Id), true) : new UIClick(p.Id.ToString()).Send(request.Model, "ProjectUI"))); cellUI.Button("创立人", null, 0xccc); // ui2.Add(cellUI); } subMebs.RemoveAll(d => mp.Exists(p => p.Id == d.project_id)); //if(mp!=nul) } foreach (var vd in subMebs) { var p = projects.Find(u => u.Id == vd.project_id); if (p == null) { continue; } var sub = subs.Find(s => s.project_id == p.Id); var cellUI = new UIIconNameDesc(new UIIconNameDesc.Item(webr.ResolveUrl(p.Id.Value, "1", "4"), p.Caption, String.Format("知识{0}篇", sub == null ? 0 : sub.Seq)) .Click(request.IsApp ? UIClick.Pager(request.Model, "ProjectUI", new WebMeta().Put("Id", p.Id), true) : new UIClick(p.Id.ToString()).Send(request.Model, "ProjectUI"))); switch (vd.AuthType) { case WebAuthType.Admin: cellUI.Button("管理员", null, 0xccc); break; case WebAuthType.User: cellUI.Button("专栏作家", null, 0xccc); break; } // ui2.Add(cellUI); } } var m = subEntity.Count(); int total = m; ui.IsNext = total > start + limit; if (start == 0 && ids.Count == 0 && pids.Count == 0) { ui2.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); } break; case "Dynamic": { var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectDynamic>(); subEntity.Where.And().Equal(new ProjectDynamic { user_id = userId }).Entities.Order.Desc(new ProjectDynamic { Time = 0 }); var subs = new List <ProjectDynamic>(); var uids = new List <Guid>(); subEntity.Query(start, limit, dr => { subs.Add(dr); uids.Add(dr.project_id ?? Guid.Empty); }); var cates = new List <Project>(); if (uids.Count > 0) { Utility.CMS.ObjectEntity <Project>().Where.And().In(new Project { Id = uids[0] }, uids.ToArray()) .Entities.Query(dr => cates.Add(dr)); } foreach (var sub in subs) { var user2 = cates.Find(d => d.Id == sub.user_id) ?? new Project(); var data = new WebMeta().Put("alias", user2.Caption, "desc", sub.Explain).Put("time", Utility.TimeSpan(sub.Time ?? 0)) .Put("name", sub.Title) .Put("src", webr.ResolveUrl(sub.project_id ?? Guid.Empty, "1", 5)); data.Put("click", new UIClick(new WebMeta().Put("Id", sub.user_id).Put("Time", sub.Time)).Send(request.Model, "Dynamic")); var cell = UICell.Create("IconNameDesc", data); cell.Format.Put("desc", "{alias} {time} {desc}"); cell.Style.Name("name").Size(14); ui2.Add(cell); } ui.Total = subEntity.Count(); if (ui.Total == 0) { ui2.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))); } } break; } response.Redirect(ui); }
public override void ProcessActivity(WebRequest request, WebResponse response) { _IsDesign = IsDesign(request); List <Guid> ids = new List <Guid>(); List <String> strIds = new List <string>(); String strs = this.AsyncDialog("Id", g => this.DialogValue("none"));//, true).Value; if (strs.IndexOf(',') > -1) { foreach (String s in strs.Split(',')) { if (String.IsNullOrEmpty(s) == false) { ids.Add(Utility.Guid(s, true).Value); strIds.Add(s); } } } else { ids.Add(Utility.Guid(strs, true).Value); } List <Guid> pids = new List <Guid>();;// new LinkedList<>(); List <Design_Item> items = new List <Design_Item>(); var itemsEntity = Database.Instance().ObjectEntity <Design_Item>(); if (ids.Count == 1) { itemsEntity.Where.And().Equal(new Design_Item() { design_id = ids[0] }); } else { itemsEntity.Where.And().In(new Design_Item() { design_id = ids[0] }, ids.ToArray()) .And().Equal(new Design_Item { Type = UIDesigner.StoreDesignTypeCustom }); } itemsEntity.Order.Asc(new Design_Item { Seq = 0 }).Entities.Query(dr => items.Add(dr)); List <WebMeta> lis = new List <WebMeta>(); var webr = UMC.Data.WebResource.Instance(); if (strIds.Count > 0) { String config = this.AsyncDialog("Config", g => this.DialogValue("none")); for (int i = 0; i < strIds.Count; i++)// var b in items) { Guid cid = ids[i]; Design_Item item = items.Find(k => k.Id == cid);// Utility.find(items, g->g.Id.compareTo(cid) == 0); if (item != null) { WebMeta pms = JSON.Deserialize <WebMeta>(item.Data); pms.Put("id", strIds[i]); if (_IsDesign) { pms.Put("design", true); if (config.Equals("UISEO")) { pms.Put("click", new UIClick(new UMC.Web.WebMeta().Put("Id", item.Id).Put("Config", config)) .Send("Design", "Custom")); } else { pms.Put("click", UIDesigner.Click(item, true)); } } else { pms.Put("click", UIDesigner.Click(item, false)); } pms.Put("src", webr.ImageResolve(item.Id.Value, "1", 0) + "?" + UIDesigner.TimeSpan(item.ModifiedDate)); lis.Add(pms); } else { if (_IsDesign) { lis.Add(new UMC.Web.WebMeta().Put("design", true).Put("id", strIds[i]).Put("click", new UIClick(new UMC.Web.WebMeta() .Put("Id", Utility.Guid(strIds[i], true).ToString(), "Config", config)) .Send("Design", "Custom"))); } } } } else { items.RemoveAll(g => { switch (g.Type) { case UIDesigner.StoreDesignTypeCustom: case UIDesigner.StoreDesignTypeItem: return(false); } return(true); }); foreach (Design_Item b in items) { WebMeta pms = JSON.Deserialize <WebMeta>(b.Data); pms.Put("id", b.Id); pms.Put("click", UIDesigner.Click(b, _IsDesign)); if (_IsDesign) { pms.Put("design", true); } pms.Put("src", webr.ImageResolve(b.Id.Value, "1", 0) + UIDesigner.TimeSpan(b.ModifiedDate)); lis.Add(pms); } if (items.Count == 0) { if (_IsDesign) { String config = this.AsyncDialog("Config", g => this.DialogValue(strs)); lis.Add(new UMC.Web.WebMeta().Put("design", true).Put("click", new UIClick(new UMC.Web.WebMeta().Put("Config", config)) .Send("Store", "DesignUIItem"))); } } } response.Redirect(lis); }
void Config(WebRequest request, Guid itemId) { UMC.Data.WebResource webr = UMC.Data.WebResource.Instance(); var entity = Database.Instance().ObjectEntity <Design_Item>(); entity.Where.Reset().And().Equal(new Design_Item() { Id = itemId }); Design_Item item = entity.Single(); switch (item.Type ?? 0) { case UIDesigner.StoreDesignTypeItem: case UIDesigner.StoreDesignTypeProduct: item = entity.Where.Reset().And().Equal(new Design_Item() { Id = item.for_id }).Entities.Single(); break; } Design_Item finalItem = item; WebMeta meta = this.AsyncDialog(g => { WebMeta data = UMC.Data.JSON.Deserialize <WebMeta>(finalItem.Data) ?? new UMC.Web.WebMeta(); //WebMeta data = Utility.isNull(UMC.Data.JSON.deserialize(finalItem.Data, WebMeta.class), new UMC.Web.WebMeta()); UIFormDialog from = new UIFormDialog(); from.Title = ("配置"); from.AddText("缩进", "Padding", data.Get("Padding") ?? "0"); from.AddNumber("展示顺序", "Seq", finalItem.Seq); switch (finalItem.Type) { case UIDesigner.StoreDesignTypeBanners: from.Title = ("广告横幅"); break; case UIDesigner.StoreDesignTypeItems: from.Title = ("分块区配置"); from.AddRadio("风格", "Model").Put("展示标题", "Title", data.Get("Model").Equals("Title") || data.ContainsKey("Model") == false).Put("仅显示图片 ", "Image", data.Get("Model").Equals("Image")); break; case UIDesigner.StoreDesignTypeTitleDesc: from.Title = ("图文区配置"); String total = data.Get("Total") ?? "1"; // data["Total"] ??"1"; String model = data.Get("Hide") ?? ""; // data["Hide"] ??""; ; from.AddCheckBox("界面", "Hide", "T").Put("不显示标题", "HideTitle", model.IndexOf("HideTitle") > -1) .Put("不显描述 ", "HideDesc", model.IndexOf("HideDesc") > -1) .Put("不显左角价格 ", "HideLeft", model.IndexOf("HideLeft") > -1) .Put("不显右角说明 ", "HideRight", model.IndexOf("HideRight") > -1); from.AddNumber("图文数量", "Total", Utility.Parse(total, 0)); break; case UIDesigner.StoreDesignTypeCaption: from.Title = "标题配置"; from.AddText("标题", "ItemName", item.ItemName); from.AddCheckBox("标题隐藏", "Show", "Y").Put("隐藏", "Hide", data["Show"] == "Hide"); break; case UIDesigner.StoreDesignTypeProducts: from.Title = "商品展示配置"; from.AddText("标题", "ItemName", item.ItemName); from.AddRadio("展示风格", "Model").Put("分块展示", "Area", data["Model"] == "Area" || data.ContainsKey("Model") == false).Put("分行展示 ", "Rows", data["Model"] == "Rows"); from.AddNumber("单行商品数", "Total", data["Total"] ?? "2"); break; case UIDesigner.StoreDesignTypeCustom: String config = data.Get("Config"); if (String.IsNullOrEmpty(config) == false && config.StartsWith("UI")) { if (config.StartsWith("UI")) { this.Context.Response.Redirect("Design", config); } var d = config.IndexOf('.'); if (d > 0) { this.Context.Response.Redirect("Design", config.Substring(d + 1)); } } this.Prompt("参数错误"); break; default: this.Prompt("参数错误"); break; } from.Submit("确认", request, "Design"); return(from); }, "Setting"); String show = meta.Get("Show"); if (String.IsNullOrEmpty(show) == false) { meta.Put("Show", show.Contains("Hide") ? "Hide" : "Show"); } entity.Where.Reset().And().Equal(new Design_Item() { Id = item.Id }); entity.Update(new Design_Item { ItemName = meta["ItemName"], ModifiedDate = DateTime.Now, Seq = UMC.Data.Utility.IntParse(meta["Seq"], 0), Data = UMC.Data.JSON.Serialize(meta) }); }
public UIItemText Click(UIClick click) { data.Put("click", click); return(this); }
public override void ProcessActivity(WebRequest request, WebResponse response) { var user = UMC.Security.Identity.Current; this._editer = request.IsCashier; var designId = UMC.Data.Utility.Guid(this.AsyncDialog("Id", g => new Web.UITextDialog()), true).Value; if (request.SendValues == null) { var builder2 = new UIDataSource(request.Model, request.Command, new UMC.Web.WebMeta().Put("Id", designId), "CMSImage"); var item = Database.Instance().ObjectEntity <Design_Item>() .Where.And().Equal(new Design_Item { design_id = designId, Type = UIDesigner.StoreDesignTypeBanners, for_id = Guid.Empty }).Entities.Single(); if (item == null) { item = new Design_Item { Id = Guid.NewGuid(), Type = UIDesigner.StoreDesignTypeBanners, for_id = Guid.Empty, design_id = designId }; Database.Instance().ObjectEntity <Design_Item>().Insert(item); } this.Context.Send(new UMC.Web.WebMeta().Put("type", "DataSource").Put("title", "广告图").Put("menu", new object[] { new UIClick(new UMC.Web.WebMeta().Put("Id", item.Id.ToString(), "Type", "Banners")) { Command = "Design", Model = "Item", Text = "新建" } }).Put("DataSource", new object[] { builder2 }).Put("model", "Cells").Put("RefreshEvent", "Design"), true); } var items = new List <Design_Item>(); var itemEntity = Database.Instance().ObjectEntity <Design_Item>() .Where.And().Equal(new Design_Item { design_id = designId }).Entities; itemEntity.Order.Asc(new Design_Item { Seq = 0 }).Entities.Query(dr => { items.Add(dr); }); if (items.Count == 0 && this._editer) { items.Add(new Design_Item { Id = Guid.NewGuid(), Type = UIDesigner.StoreDesignTypeBanners, for_id = Guid.Empty, design_id = designId }); itemEntity.Insert(items.ToArray()); } var groups = items.FindAll(g => g.for_id == Guid.Empty); var parent = groups.Find(g => g.Type == UIDesigner.StoreDesignTypeBanners) ?? new Design_Item() { Id = Guid.NewGuid() }; var list = new List <Object>(); var webr = UMC.Data.WebResource.Instance(); foreach (var b in items.FindAll(g => g.for_id == parent.Id)) { var slider = new WebMeta().Put("src", webr.ResolveUrl(String.Format("{1}{0}/1/0.jpg!slider", b.Id, UMC.Data.WebResource.ImageResource))); if (_editer) { slider.Put("click", new UIClick(new UMC.Web.WebMeta().Put("Id", b.Id)) { Command = "Design", Model = "Item" }); } else { if (String.IsNullOrEmpty(b.Click) == false) { slider.Put("click", UMC.Data.JSON.Deserialize <UIClick>(b.Click)); } } list.Add(slider); } response.Redirect(new UMC.Web.WebMeta().Put("data", list)); }
public override void ProcessActivity(WebRequest request, WebResponse response) { var ProjectId = Utility.Guid(this.AsyncDialog("Id", g => { this.Prompt("请输入项目"); return(this.DialogValue("Project")); })) ?? Guid.Empty; var project = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project { Id = ProjectId }).Entities.Single(); var Model = this.AsyncDialog("Model", ml => { if (project == null) { return(this.DialogValue("News")); } var form = (request.SendValues ?? new UMC.Web.WebMeta()).GetDictionary(); if (form.ContainsKey("start") == false) { if (request.IsApp) { var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments); this.Context.Send(buider.Builder(), true); } else { if (request.Url.Query.Contains("_v=Sub")) { this.Context.Send("Subject.Path", new WebMeta().Put("Path", project.Code), true); } else { var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments); this.Context.Send(buider.Builder(), true); } } } var webr = UMC.Data.WebResource.Instance(); UISection ui = null; UISection ui2 = null; var selectIndex = UMC.Data.Utility.IntParse(this.AsyncDialog("selectIndex", g => this.DialogValue("0")), 0); var items = new List <WebMeta>();// items.Add(new UMC.Web.WebMeta().Put("text", "团队成员", "search", "Member", "Key", "List")); items.Add(new UMC.Web.WebMeta().Put("text", "文档资讯", "search", "Subs", "Key", "List")); items.Add(new UMC.Web.WebMeta().Put("text", "项目动态", "search", "Dynamic", "Key", "List")); var Keyword = (form["Keyword"] as string ?? String.Empty); if (String.IsNullOrEmpty(Keyword) && selectIndex > -1) { Keyword = items[selectIndex]["search"]; } int start = UMC.Data.Utility.IntParse(form["start"] as string, 0); var nextKey = this.AsyncDialog("NextKey", g => this.DialogValue("Header"));; if (start == 0 && String.Equals(nextKey, "Header")) { ; var logoUrl = webr.ResolveUrl(project.Id.Value, "1", 4); var members = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>() .Where.And().Equal(new Data.Entities.ProjectMember { project_id = project.Id }) .Entities.Count() + 1; var suject = Utility.CMS.ObjectEntity <Subject>() .Where.And().Equal(new Subject { project_id = project.Id }) .Entities.GroupBy().Sum(new Subject { Reply = 0 }) .Sum(new Subject { Look = 0 }).Count(new Subject { Seq = 0 }).Single(); var Discount = new UIHeader.Portrait(logoUrl); Discount.Value(project.Caption); Discount.Time(project.Description); var color = 0x63b359; Discount.Gradient(color, color); var header = new UIHeader(); var title = UITitle.Create(); title.Title = "项目介绍"; title.Style.BgColor(color); title.Style.Color(0xfff); header.AddPortrait(Discount); ui = UISection.Create(header, title); bool isIsAttention; UIIconNameDesc uIIcon = new UIIconNameDesc(); // uIIcon.Put("icon", '\uF0c0').Put("color", "#40c9c6").Put("name", "团队规模").Put("desc", members + "人"); if (request.Model == "Subject") { uIIcon.Button(SubjectAttentionActivity.Attention(project.Id.Value, out isIsAttention), Web.UIClick.Click(new Web.UIClick("Id", project.Id.ToString()) { Model = request.Model, Command = "ProjectAtten" }), isIsAttention ? 0x25b864 : 0xe67979); } ui.Add(uIIcon); uIIcon = new UIIconNameDesc(new UIIconNameDesc.Item('\uF02d', "文章数量", suject.Seq + "篇").Color(0x36a3f7), new UIIconNameDesc.Item('\uf06e', "浏览总数", suject.Look + "次").Color(0x34bfa3)); ui.Add(uIIcon); ui2 = ui.NewSection(); } else { ui2 = ui = UISection.Create(); } if (start == 0 && String.Equals(nextKey, "Self") == false) { if (selectIndex > 0) { ui2.Add(UICell.Create("TabFixed", new UMC.Web.WebMeta().Put("items", items).Put("selectIndex", selectIndex))); } else { ui2.Add(UICell.Create("TabFixed", new UMC.Web.WebMeta().Put("items", items)));; } } ui2.Key = "List"; int limit = UMC.Data.Utility.IntParse(form["limit"] as string, 25); switch (Keyword) { default: case "Subs": { var Type = this.AsyncDialog("Type", "Items"); var itemId = Utility.Guid(this.AsyncDialog("CId", project.Id.ToString())); switch (Type) { case "Items": { var subs = new List <Subject>(); Utility.CMS.ObjectEntity <Subject>().Where.And().In(new Subject { project_id = project.Id }).Entities .GroupBy(new Subject { project_item_id = Guid.Empty }) .Count(new Subject { Look = 0 }) .Query(dr => subs.Add(dr)); var projects = new List <ProjectItem>(); var projectEntity = Utility.CMS.ObjectEntity <ProjectItem>(); projectEntity.Where.And().In(new ProjectItem { project_id = project.Id }); projectEntity.Order.Asc(new ProjectItem { Sequence = 0 }); projectEntity.Query(dr => { var su = subs.Find(s => s.project_item_id == dr.Id); ui2.AddCell('\uf022', dr.Caption, String.Format("{0}篇", su == null ? 0 : su.Look) , new UIClick(new WebMeta().Put("key", "List").Put("send", new WebMeta().Put("CId", dr.Id).Put("Type", "Portfolio"))) { Key = "Query" }); }); } break; case "Portfolio": { var subs = new List <Subject>(); Utility.CMS.ObjectEntity <Subject>().Where.And().In(new Subject { project_item_id = itemId }).Entities .GroupBy(new Subject { portfolio_id = Guid.Empty }) .Count(new Subject { Look = 0 }) .Query(dr => subs.Add(dr)); var item = Utility.CMS.ObjectEntity <ProjectItem>().Where.And().In(new ProjectItem { Id = itemId }).Entities.Single(); var navData = new WebMeta().Put("item", item.Caption).Put("Icon", '\uf022'); navData.Put("nav", "目录"); navData.Put("split", '\uf105'); var cell = UICell.Create("UI", navData); cell.Style.Name("nav").Click(new UIClick(new WebMeta().Put("key", "List").Put("send", new WebMeta().Put("CId", item.project_id).Put("Type", "Items"))) { Key = "Query" }).Color(0x36a3f7); cell.Style.Name("item").Color(0x999); cell.Format.Put("text", "{nav} {split} {item}"); cell.Style.Name("split").Font("wdk"); ui2.Add(cell); Utility.CMS.ObjectEntity <Portfolio>().Where.And().Equal(new Portfolio { project_item_id = item.Id }).Entities .Order.Asc(new Portfolio { Sequence = 0 }).Entities .Query(dr => { var su = subs.Find(s => s.portfolio_id == dr.Id); ui2.AddCell('\uf22b', dr.Caption, String.Format("{0}篇", su == null ? 0 : su.Look) , new UIClick(new WebMeta().Put("key", "List").Put("send", new WebMeta().Put("CId", dr.Id).Put("Type", "Subs"))) { Key = "Query" }); }); } break; case "Subs": { var ui3 = ui2; if (start == 0) { var portfolio = Utility.CMS.ObjectEntity <Portfolio>().Where.And().In(new Portfolio { Id = itemId }).Entities.Single(); var item = Utility.CMS.ObjectEntity <ProjectItem>() .Where.And().In(new ProjectItem { Id = portfolio.project_item_id }).Entities.Single(); var navData = new WebMeta().Put("item", item.Caption).Put("Icon", '\uf022'); navData.Put("nav", "目录"); navData.Put("split", '\uf105'); navData.Put("port", portfolio.Caption); var cell = UICell.Create("UI", navData); cell.Style.Name("nav").Click(new UIClick(new WebMeta().Put("key", "List").Put("send", new WebMeta().Put("CId", item.project_id).Put("Type", "Items"))) { Key = "Query" }).Color(0x36a3f7); cell.Style.Name("item").Color(0x36a3f7).Click(new UIClick(new WebMeta().Put("key", "List").Put("send", new WebMeta().Put("CId", item.Id).Put("Type", "Portfolio"))) { Key = "Query" }); cell.Format.Put("text", "{nav} {split} {item} {split} {port}"); cell.Style.Name("port").Color(0x999); cell.Style.Name("split").Font("wdk"); ui2.Add(cell); ui3 = ui2.NewSection(); } ui3.Key = "Subs"; var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>(); subEntity.Order.Desc(new Subject { ReleaseDate = DateTime.Now }); subEntity.Where.And().Equal(new Data.Entities.Subject { Status = 1, portfolio_id = itemId }).And().Greater(new Subject { Status = 0, Visible = -1 }); SubjectUIActivity.Search(request.Model, ui3, subEntity, start, limit); if (ui3.Total == 0) { ui3.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))); } } break; } } break; case "Member": { var style = new UIStyle().AlignLeft(); int mlimit = limit * 4; int mstart = start * 4; var ids = new List <Guid>(); var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>(); subEntity.Where.And().Equal(new ProjectMember { project_id = project.Id }); subEntity.Order.Desc(new ProjectMember { CreationTime = DateTime.Now }); var wids = new List <Guid>(); var pms = new List <ProjectMember>(); if (mstart == 0) { ids.Add(project.user_id.Value); subEntity.Where.And().In(new ProjectMember { AuthType = WebAuthType.Admin }, WebAuthType.User) .And().Unequal(new ProjectMember { user_id = project.user_id }).Entities.Order.Desc(new ProjectMember { AuthType = 0 }); subEntity.Query(dr => { pms.Add(dr); ids.Add(dr.user_id.Value); }); wids.AddRange(ids); } subEntity.Where.Reset().And().Equal(new ProjectMember { project_id = project.Id, AuthType = WebAuthType.Guest }); subEntity.Query(mstart, mlimit, dr => ids.Add(dr.user_id.Value)); if (ids.Count > 0) { var users = new List <User>(); Utility.CMS.ObjectEntity <User>() .Where.And().In(new User { Id = ids[0] }, ids.ToArray()).Entities.Query(dr => users.Add(dr)); if (wids.Count > 0) { var puser = users.Find(u => u.Id == project.user_id) ?? new User { Alias = "未知", Id = project.user_id }; ui2.Add(new UIIconNameDesc(new UIIconNameDesc.Item(webr.ResolveUrl(puser.Id.Value, "1", "4"), puser.Alias, "创立于" + Utility.GetDate(project.CreationTime)) .Click(request.IsApp ? UIClick.Pager(request.Model, "Account", new WebMeta().Put("Id", puser.Id), true) : new UIClick(puser.Id.ToString()).Send(request.Model, "Account"))).Button("立项人", null, 0xb7babb)); var ites = new List <UIIconNameDesc.Item>(); foreach (var pm in pms) { var v = users.Find(u => u.Id == pm.user_id) ?? new User { Alias = pm.Alias }; var text = "专栏作家"; switch (pm.AuthType) { case WebAuthType.Admin: text = "管理员"; break; case WebAuthType.User: break; } ites.Add(new UIIconNameDesc.Item(webr.ResolveUrl(pm.user_id.Value, "1", "4"), v.Alias, text) .Click(request.IsApp ? UIClick.Pager(request.Model, "Account", new WebMeta().Put("Id", pm.user_id), true) : new UIClick(pm.user_id.ToString()).Send(request.Model, "Account"))); if (ites.Count % 2 == 0) { ui2.Add(new UIIconNameDesc(ites.ToArray())); ites.Clear(); } } if (ites.Count > 0) { ui2.Add(new UIIconNameDesc(ites.ToArray())); } ids.RemoveAll(g => wids.Exists(w => w == g)); } var icons = new List <UIEventText>(); foreach (var id in ids) { var v = users.Find(u => u.Id == id); icons.Add(new UIEventText(v.Alias).Src(webr.ResolveUrl(v.Id.Value, "1", "4")).Click(request.IsApp ? UIClick.Pager(request.Model, "Account", new WebMeta().Put("Id", v.Id), true) : new UIClick(v.Id.ToString()).Send(request.Model, "Account"))); if (icons.Count % 4 == 0) { ui2.Add(new Web.UI.UIIcon().Add(icons.ToArray())); icons.Clear(); } } if (icons.Count > 0) { var ls = new Web.UI.UIIcon().Add(icons.ToArray()); ls.Style.Copy(style); ui2.Add(ls); // new Web.UI.UIIcon().Add(icons.ToArray())); //ui2.AddIcon(style, icons.ToArray()); } //if (icons.Count > 0) // ui2.AddIcon(style, icons.ToArray()); } var m = subEntity.Count(); int total = m / 4; if (m % 4 > 0) { total++; } ui.Total = total; response.Redirect(ui); } break; case "Writer": { int mlimit = limit * 4; int mstart = start * 4; var ids = new List <ProjectMember>(); var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>(); subEntity.Where.And().Equal(new ProjectMember { project_id = project.Id }); subEntity.Where.And().In(new ProjectMember { AuthType = WebAuthType.Admin }, WebAuthType.User); subEntity.Order.Desc(new ProjectMember { CreationTime = DateTime.Now }); subEntity.Query(mstart, mlimit, dr => ids.Add(dr)); var style = new UIStyle().AlignRight(); if (ids.Count > 0) { var icons = new List <UIEventText>(); foreach (var v in ids) { icons.Add(new UIEventText(v.Alias).Src(webr.ResolveUrl(v.user_id.Value, "1", "4")).Click(UIClick.Pager(request.Model, "Account", new WebMeta().Put("Id", v.user_id), true))); if (icons.Count % 4 == 0) { ui2.Add(new Web.UI.UIIcon().Add(icons.ToArray())); icons.Clear(); } } if (icons.Count > 0) { var ls = new Web.UI.UIIcon().Add(icons.ToArray()); ls.Style.Copy(style); ui2.Add(ls); // new Web.UI.UIIcon().Add(icons.ToArray())); //ui2.AddIcon(style, icons.ToArray()); } } var m = subEntity.Count(); int total = m / 4; if (m % 4 > 0) { total++; } ui.Total = total; response.Redirect(ui); } break; case "Dynamic": { var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectDynamic>(); subEntity.Where.And().Equal(new ProjectDynamic { project_id = project.Id }).Entities.Order.Desc(new ProjectDynamic { Time = 0 }); var subs = new List <ProjectDynamic>(); var uids = new List <Guid>(); subEntity.Query(start, limit, dr => { subs.Add(dr); uids.Add(dr.user_id ?? Guid.Empty); }); var cates = new List <User>(); if (uids.Count > 0) { Utility.CMS.ObjectEntity <User>().Where.And().In(new User { Id = uids[0] }, uids.ToArray()) .Entities.Query(dr => cates.Add(dr)); } foreach (var sub in subs) { var user2 = cates.Find(d => d.Id == sub.user_id) ?? new User(); var data = new WebMeta().Put("alias", user2.Alias, "desc", sub.Explain).Put("time", sub.Time) .Put("name", sub.Title) .Put("src", webr.ResolveUrl(sub.user_id ?? Guid.Empty, "1", 5)); var cell = UICell.Create("IconNameDesc", data); cell.Format.Put("desc", "{alias} {time} {desc}"); cell.Style.Name("name").Size(14); ui2.Add(cell); } ui.Total = subEntity.Count(); if (ui.Total == 0) { // webr. ui2.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))); } } break; } response.Redirect(ui); return(this.DialogValue("none")); }); var user = Security.Identity.Current; if (user.IsAuthenticated == false) { this.Prompt("请登录", false); response.Redirect("Account", "Login"); } if (project == null || project.user_id == user.Id) { switch (Model) { case "Icon": response.Redirect("Design", "Picture", new WebMeta().Put("id", project.Id).Put("seq", 1), true); break; case "Transfer": var userId = Utility.Guid(this.AsyncDialog("Transfer", request.Model, "Member", new WebMeta().Put("Type", "Admin").Put("Project", project.Id))).Value; this.AsyncDialog("Confirm", g => new UIConfirmDialog("你确认转移项目拥有者身份吗")); Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project { Id = project.Id }).Entities .Update(new Project { user_id = userId }); Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember { user_id = userId, project_id = project.Id }) .Entities.Update(new ProjectMember { user_id = project.user_id, CreationTime = DateTime.Now, Alias = user.Alias }); this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Project").Put("Id", project.Id).Put("Text", project.Caption) .Put("Code", project.Code), true); break; } var Caption = this.AsyncDialog("Settings", d => { var fmdg = new Web.UIFormDialog(); fmdg.Title = "编辑项目"; switch (Model) { case "News": fmdg.Title = "新建项目"; fmdg.AddText("项目名称", "Caption", ""); fmdg.Submit("确认", request, "Subject.Project"); return(fmdg); //break; default: case "Caption": fmdg.Title = "项目名称"; fmdg.AddText("项目名称", "Caption", project.Caption); break; case "Description": fmdg.Title = "项目介绍"; fmdg.AddText("项目介绍", "Description", project.Description); break; case "Code": fmdg.Title = "项目简码"; fmdg.AddText("项目简码", "Code", project.Code).PlaceHolder("短小易记有助于访问和传播").Put("tip", ""); break; } fmdg.Submit("确认", request, "Subject.Project"); fmdg.AddUI("对接", "配置钉钉应用").Command(request.Model, "Dingtalk", project.Id.ToString()); fmdg.AddUI("对接", "配置钉钉机器人").Command(request.Model, "DDRobot", project.Id.ToString()); //fmdg.AddUI("对接", "配置钉钉机器人").Command(request.Model, request.Command, new WebMeta().Put("Id", project.Id.ToString(), "Model", "Transfer")); return(fmdg); }); var team = new Project(); if (Model == "News") { UMC.Data.Reflection.SetProperty(team, Caption.GetDictionary()); team.ModifiedTime = DateTime.Now; team.Id = Guid.NewGuid(); team.user_id = user.Id; team.Code = Utility.Parse36Encode(team.Id.Value.GetHashCode()); team.CreationTime = DateTime.Now; team.Sequence = 0; Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>().Insert(team); var strt = UMC.Security.AccessToken.Current.Data["DingTalk-Setting"] as string;//, Utility.Guid(projectId)).Commit(); if (String.IsNullOrEmpty(strt) == false) { var userSetting = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectUserSetting>() .Where.And().Equal(new ProjectUserSetting { Id = Utility.Guid(strt, true) }).Entities.Single(); if (userSetting != null) { var setting2 = new ProjectSetting() { user_setting_id = userSetting.Id, project_id = team.Id, Type = 11 }; Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectSetting>().Insert(setting2); } } Data.WebResource.Instance().Transfer(new Uri("https://oss.365lu.cn/UserResources/app/zhishi-icon.jpg"), team.Id.Value, 1); var p = new ProjectItem() { Id = Guid.NewGuid(), Caption = "Home", Code = Utility.Parse36Encode(Guid.NewGuid().GetHashCode()), CreationTime = DateTime.Now, project_id = team.Id, Sequence = 0, user_id = user.Id, }; Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectItem>() .Insert(p); var portfolio = new Portfolio() { Id = Guid.NewGuid(), Caption = "随笔", Count = 0, CreationTime = DateTime.Now, Sequence = 0, user_id = user.Id, project_id = team.Id, project_item_id = p.Id, }; Utility.CMS.ObjectEntity <UMC.Data.Entities.Portfolio>() .Insert(portfolio); Utility.CMS.ObjectEntity <ProjectDynamic>() .Insert(new ProjectDynamic { Time = Utility.TimeSpan(), //DateTime.Now, user_id = user.Id, Explain = "创建了项目", project_id = team.Id, refer_id = team.Id, Title = team.Caption, Type = DynamicType.Project }); this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Project").Put("id", team.Id).Put("text", team.Caption) .Put("code", team.Code), true); } UMC.Data.Reflection.SetProperty(team, Caption.GetDictionary()); if (String.IsNullOrEmpty(team.Code) == false) { if (team.Code.Length < 3) { this.Prompt("项目简码必须大于3个字符"); } if (System.Text.RegularExpressions.Regex.IsMatch(team.Code, "^\\d+$") == true) { this.Prompt("项目简码不能全是数字"); } if (System.Text.RegularExpressions.Regex.IsMatch(team.Code, "^\\w+$") == false) { this.Prompt("项目简码只能是字符和数字"); } if (String.Equals(team.Code, project.Code, StringComparison.CurrentCulture) == false) { if (Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>() .Where.And().Equal(new Project { Code = team.Code }).Entities.Count() > 0) { this.Prompt("存在相同的简码"); } } } team.ModifiedTime = DateTime.Now; var objectEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>(); objectEntity.Where.And().Equal(new Project { Id = project.Id }); objectEntity.Update(team); this.Prompt("修改成功", false); this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Project").Put("id", project.Id).Put("text", team.Caption ?? project.Caption).Put("code", team.Code ?? project.Code), true); } }
void Check(string text) { int index = 0; while (index < text.Length) { if (index + 1 >= text.Length) { Append(); return; } switch (text[index]) { case '#': { int end = text.IndexOf('\n', index); if (end > index) { Header(text.Substring(index, end - index)); index = end + 1; } else { Header(text.Substring(index)); index = text.Length; } continue; } case '`': { if (text.Substring(index, 3) == "```") { int end = text.IndexOf("\n```", index + 1); if (end > index) { String content = text.Substring(index, end - index); var hindex = content.IndexOf('\n'); var htype = content.Substring(3, hindex - 3).Trim(); content = content.Substring(hindex + 1); var cell = UICell.Create("CMSCode", new WebMeta().Put("code", content).Put("type", htype)); cell.Format.Put("text", "{code}"); cells.Add(cell); index = text.IndexOf('\n', end + 1) + 1; continue; } } } break; case '>': { if (cells.Count > 0) { var cell = cells[cells.Count - 1]; if (cell.Type == "CMSRel") { var d = cell.Data as WebMeta; cells.RemoveAt(cells.Count - 1); this.data = d; this.dataText.Append("\r\n"); this.style = cell.Style; this.data.Put("type", "CMSRel"); index = CheckRow(text, index + 1); continue; } } this.data.Put("type", "CMSRel"); index = CheckRow(text, index + 1); continue; } case '|': { int end = text.IndexOf('\n', index); if (end > index) { var grids = new List <String>(); String conent = text.Substring(index, end - index).Trim().Replace(" ", ""); if (conent[conent.Length - 1] == '|') { int end2 = text.IndexOf('\n', end + 1); //.Trim(); String conent2 = text.Substring(end + 1, end2 - end - 1).Trim(); grids.Add(conent); conent2 = conent2.Replace(" ", ""); if (System.Text.RegularExpressions.Regex.IsMatch(conent2, "^[\\|:-]+$")) { grids.Add(conent2); if (conent2.Split('|').Length == conent.Split('|').Length) { bool isGO = true; while (isGO) { isGO = false; int end3 = text.IndexOf('\n', end2 + 1); String conent3 = end3 > 0 ? text.Substring(end2 + 1, end3 - end2 - 1).Trim() : text.Substring(end2 + 1).Trim(); if (conent3.StartsWith("|") && conent3.EndsWith("|")) { isGO = true; grids.Add(conent3); end2 = end3 > 0 ? end3 : text.Length - 1; } } this.Grid(grids); index = end2 + 1; continue; } } } } } break; case '[': { int end = text.IndexOf("]", index + 1); if (end > index && end + 1 < text.Length) { if (text[end + 1] == ':') { String content = text.Substring(index, end - index).Trim('[', ']'); if (content.IndexOf('\n') == -1) { int end2 = text.IndexOf("\n", end + 1); if (end2 == -1) { var url = text.Substring(end + 2).Trim().Trim(' ', '(', ')').Split(' ')[0]; webRel.Put(content, url); } else { var url = text.Substring(end + 2, end2 - end - 2).Trim().Trim(' ', '(', ')').Split(' ')[0]; webRel.Put(content, url); //Check(text, end2 + 1); index = end2 + 1; } continue; } } } } break; case ' ': while (text.Length > index && text[index] == ' ') { index++; } break; } index = this.CheckRow(text, index); } }
public UICell Transform(String text) { Check(text); Append(); if (dataText.Length > 0) { data.Put("h" + data.Count.ToString(), dataText.ToString()); } dataText = new StringBuilder(); var sb = new StringBuilder(); for (int i = 0; i < data.Count; i++) { sb.Append("{h"); sb.Append(i); sb.Append("}"); } var cell = UICell.Create("CMSCode", data); cell.Format.Put("text", sb.ToString()); cell.Style.Copy(style); return(cell); }
public UICell Paster(String text, string type) { switch ((type ?? "").ToLower().Trim()) { case "text": case "shell": dataText.Append(text); break; case "html": case "xml": CheckXml(text); break; default: Check(text); Append(); break; } if (dataText.Length > 0) { data.Put("h" + data.Count.ToString(), dataText.ToString()); } dataText = new StringBuilder(); var sb = new StringBuilder(); for (int i = 0; i < data.Count; i++) { sb.Append("{h"); sb.Append(i); sb.Append("}"); } var cell = UICell.Create("CMSCode", data); if (String.IsNullOrEmpty(type) == false) { data.Put("type", type); } cell.Format.Put("text", sb.ToString()); cell.Style.Copy(style); return(cell); }
public override void ProcessActivity(WebRequest request, WebResponse response) { var refer_id = UMC.Data.Utility.Guid(this.AsyncDialog("Refer", g => { return(new Web.UITextDialog() { Title = "评论的主题" }); })); var user = UMC.Security.Identity.Current; var Id = UMC.Data.Utility.Guid(this.AsyncDialog("Id", g => { return(this.DialogValue(Guid.NewGuid().ToString())); })).Value; var commentEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Comment>() .Where.And().In(new Comment { Id = refer_id }, Id).Entities; var commant = commentEntity.Single(); var ui = this.AsyncDialog("UI", g => this.DialogValue("none")); var section = this.AsyncDialog("section", g => this.DialogValue("1")); var row = this.AsyncDialog("row", g => this.DialogValue("1")); var Content = Web.UIDialog.AsyncDialog("Content", g => { var from = new Web.UIFormDialog(); if (commant != null) { from.Title = "回复评论"; } else { from.Title = "评论"; } if (request.IsApp) { var sn = new WebMeta(request.Arguments); sn.Put("Id", Id).Put("Refer", refer_id); var ms = new WebMeta().Put("submit", new UIClick(sn) { Text = commant != null ? "请回复" : "请评论" }.Send(request.Model, request.Command)); this.Context.Send(commant == null ? "Comment" : "Reply", ms, true); } from.AddTextarea("内容", "Content", String.Empty).Put("MinSize", "6"); if (commant == null) { from.AddFiles("图片上传", "Picture").Put("required", "none") .Command("Design", "Picture", new UMC.Web.WebMeta().Put("id", Id)); } from.Submit(commant != null ? "确认回复" : "确认评论", request, "UI.Event"); return(from); }); var image = this.AsyncDialog("image", "none"); if (image != "none") { var webr = UMC.Data.WebResource.Instance(); var imgs = image.Split(','); var ls = new List <Picture>(); for (var i = 0; i < imgs.Length; i++) { webr.Transfer(new Uri(imgs[i]), Id, i + 1); ls.Add(new Picture { group_id = Id, Seq = i + 1, UploadDate = DateTime.Now, user_id = user.Id }); } if (ls.Count > 0) { var entity = UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Picture>(); entity.Where.And().Equal(new UMC.Data.Entities.Picture { group_id = Id }).Entities.Delete(); entity.Insert(ls.ToArray()); } } if (commant != null) { if (commant.Id == Id) { return; } var forId = commant.for_id ?? Guid.Empty; if (forId == Guid.Empty) { forId = commant.Id.Value; } var entity = Utility.CMS.ObjectEntity <Subject>() .Where.And().Equal(new Subject { Id = commant.ref_id }).Entities; var sinle = entity.Single(new Subject { Reply = 0, project_id = Guid.Empty }); if (sinle != null) { if (sinle.Reply.HasValue) { entity.Update("{0}+{1}", new Subject { Reply = 1 }); } else { entity.Update(new Subject { Reply = 1 }); } } commentEntity.Insert(new Comment { Id = Id, CommentDate = DateTime.Now, for_id = forId, ref_id = commant.ref_id, Content = Content, Effective = 0, Farworks = 0, Invalid = 0, project_id = sinle != null ? sinle.project_id : null, Reply = 0, Score = 0, Unhealthy = 0, Visible = 0, Poster = user.Alias, user_id = user.Id }); var cm = Utility.CMS.ObjectEntity <UMC.Data.Entities.Comment>() .Where.And().Equal(new Data.Entities.Comment { Id = commant.Id }) .Entities.Single(); var editer = new Web.UISection.Editer(section, row); editer.Put((Utility.Comment(cm, request.Model)), false); editer.Builder(this.Context, ui, true); } else { var entity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>() .Where.And().Equal(new Subject { Id = refer_id }).Entities; var sinle = entity.Single(new Subject { Reply = 0, project_id = Guid.Empty }); commentEntity.Insert(new Comment { Id = Id, CommentDate = DateTime.Now, for_id = Guid.Empty, ref_id = refer_id, project_id = sinle != null ? sinle.project_id : null, Content = Content, Effective = 0, Farworks = 0, Invalid = 0, Reply = 0, Score = 0, Unhealthy = 0, Visible = 0, Poster = user.Alias, user_id = user.Id }); if (sinle != null) { if (sinle.Reply.HasValue) { entity.Update("{0}+{1}", new Subject { Reply = 1 }); } else { entity.Update(new Subject { Reply = 1 }); } var editer = new Web.UISection.Editer(1, 1); var cm = Utility.CMS.ObjectEntity <UMC.Data.Entities.Comment>() .Where.And().Equal(new Data.Entities.Comment { Id = Id, for_id = Guid.Empty }) .Entities.Single(); if (commentEntity.Where.Reset().And().Equal(new Comment { ref_id = refer_id, for_id = Guid.Empty }).And().Greater(new Comment { Visible = -1 }).Entities.Count() == 1) { editer.Put(Utility.Comment(cm, request.Model), false); } else { editer.Insert(Utility.Comment(cm, request.Model)); } editer.Builder(this.Context, ui, true); } } }
public Item Click(UIClick click) { meta.Put("click", click); return(this); }
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); }
public override void ProcessActivity(WebRequest request, WebResponse response) { var Key = this.AsyncDialog("Key", "none"); var pkd = Utility.Guid(Key); if (pkd.HasValue) { Portfolio(pkd.Value, response); } else if (String.Equals("none", Key) == false) { var keys = Key.Split('/'); if (keys.Length > 1) { var user = UMC.Security.Identity.Current; var team = Utility.CMS.ObjectEntity <Project>().Where.And().In(new Project { Code = keys[0] }).Entities.Single(); var projectEntity = Utility.CMS.ObjectEntity <ProjectItem>(); var project = projectEntity.Where.And().Equal(new ProjectItem { project_id = team.Id, Code = keys[1] }).Entities.Single(); var editer = team.user_id == user.Id; int status = 1; if (editer == false) { status = -1; var member = Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember { project_id = team.Id, user_id = user.Id }).Entities.Single(); if (member != null) { switch (member.AuthType) { case WebAuthType.Admin: status = 1; break; case WebAuthType.All: status = -1; break; case WebAuthType.Guest: status = -1; break; case WebAuthType.User: status = 1; break; } } } var menu = new WebMeta(); if (keys.Length == 3) { var sub = Utility.CMS.ObjectEntity <Subject>().Where.And().Equal(new Subject { project_id = team.Id, project_item_id = project.Id, Code = keys[2] }).Entities.Single(); if (sub != null) { menu.Put("spa", new WebMeta().Put("id", sub.Id).Put("path", String.Format("{0}/{1}/{2}", team.Code, project.Code, sub.Code))); } } menu.Put("nav", String.Format("{0}/{1}", team.Code, project.Code)); menu.Put("subs", Portfolio(team, project, status)); response.Redirect(menu);// } } }
public UICMS Desc(string desc) { data.Put("desc", desc); return(this); }
public UIDiscount Click(UIClick click) { data.Put("click", click); return(this); }
public override void ProcessActivity(WebRequest request, WebResponse response) { var Id = UMC.Data.Utility.Guid(this.AsyncDialog("Id", g => { this.Prompt("请输入参数"); return(this.DialogValue("none")); }), true); var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>(); subEntity.Where.And().Equal(new Subject { Id = Id }); var sub = subEntity.Single(); var user = UMC.Security.Identity.Current; if (sub.project_id.HasValue) { var project = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Project { Id = sub.project_id }).Entities.Single(); if (project != null && project.user_id == user.Id) { } else { var member = Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember { project_id = sub.project_id, user_id = user.Id }).Entities.Single(); if (member != null) { switch (member.AuthType) { case WebAuthType.Admin: case WebAuthType.User: break; default: if (sub.Status > 0) { this.Context.Send(new UISectionBuilder(request.Model, "UIData", new UMC.Web.WebMeta().Put("Id", Id)) .Builder(), true); } if (sub.user_id == user.Id) { this.Prompt(String.Format("{0}项目收回了您的编辑权限", project.Caption)); } else { this.Prompt("您未有编辑此图文的权限"); } break; } } else { if (sub.Status > 0) { this.Context.Send(new UISectionBuilder(request.Model, "UIData", new UMC.Web.WebMeta().Put("Id", Id)) .Builder(), true); } if (sub.user_id == user.Id) { this.Prompt(String.Format("{0}项目收回了你的编辑权限", project.Caption)); } else { this.Prompt("您未有编辑此图文的权限"); } } } } if (String.IsNullOrEmpty(request.SendValue) == false) { this.Context.Send(new UISectionBuilder(request.Model, request.Command, new UMC.Web.WebMeta().Put("Id", Id)) .RefreshEvent("Subject.Save", "image", "Subject.Content").CloseEvent("Subject.Del") .Builder(), true); } // var appKey = UMC.Security.Principal.Current.AppKey ?? Guid.Empty; var Model = this.AsyncDialog("Model", gKey => { var webr = UMC.Data.WebResource.Instance(); UITitle uITItle = UITitle.Create(); uITItle.Title = "图文发布"; var sestion = UISection.Create(uITItle); var pictureEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Picture>(); pictureEntity.Where.And().GreaterEqual(new Data.Entities.Picture { Seq = 0 }); pictureEntity.Order.Asc(new Data.Entities.Picture { Seq = 0 }); var images = new List <String>(); var items = new List <WebMeta>(); pictureEntity.Where .And().In(new Data.Entities.Picture { group_id = sub.Id }) .Entities.Query(dr => { var src = webr.ResolveUrl(dr.group_id.Value, dr.Seq, "0"); var chachKey = "?_ts=" + UMC.Data.Utility.TimeSpan(dr.UploadDate.Value); items.Add(new UMC.Web.WebMeta().Put("src", src + "!200" + chachKey).Put("click", new Web.UIClick(new UMC.Web.WebMeta().Put("Id", dr.group_id.Value).Put("Seq", dr.Seq).Put(gKey, "Picture")) { Model = request.Model, Command = request.Command })); images.Add(src + "?_ts=" + chachKey); }); var uidesc = new UIDesc(sub.Title); uidesc.Style.Bold().Height(50); uidesc.Click(new UIClick("Id", Id.ToString(), gKey, "Title") { Model = request.Model, Command = request.Command }); var nine = new UMC.Web.WebMeta().Put("images", items); sestion.Delete(uidesc, new UIEventText().Click(new UIClick("Id", Id.ToString(), gKey, "Del") { Model = request.Model, Command = request.Command })); var sT = sub.Description ?? sub.Title; if (sT.Length > 48) { sT = sT.Substring(0, 48) + "..."; } var desc = new UIDesc(sT); desc.Style.Height(40).Color(0x999).Size(13);//.Name("border", "none"); desc.Click(new UIClick("Id", Id.ToString(), gKey, "Desc") { Model = request.Model, Command = request.Command }); sestion .Add(UICell.Create("NineImage", nine)).Add(desc) .AddCell("封面方式", sub.IsPicture == true ? "显示大图" : (images.Count > 2 ? "三张图" : "单张图") , new UIClick("Id", Id.ToString(), gKey, "Show") { Model = request.Model, Command = request.Command }); if (images.Count < 3) { nine.Put("click", new UIClick("Id", Id.ToString(), gKey, "Image") { Model = request.Model, Command = request.Command }); } if (request.IsApp) { sestion.NewSection().AddCell('\uf044', "编辑正文", "", new UIClick(Id.ToString()) { Command = "Content", Model = request.Model }); } var status = "审阅中"; if (sub.Status > 0) { status = "已发布"; } else if (sub.Status < 0) { if (sub.Status == -2) { status = "被驳回"; } else { status = "未发布"; } } var cateName = "草稿"; if (sub.project_item_id.HasValue) { //var portfolio = Utility.CMS.ObjectEntity<UMC.Data.Entities.Portfolio>().Where.And().Equal(new Data.Entities.Portfolio //{ // Id = sub.portfolio_id.Value //}).Entities.Single(); var ProjectItem = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectItem>().Where.And().Equal(new Data.Entities.ProjectItem { Id = sub.project_item_id.Value }).Entities.Single(); var Project = Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>().Where.And().Equal(new Data.Entities.Project { Id = sub.project_id.Value }).Entities.Single(); cateName = String.Format("{0}/{1}", Project.Caption, ProjectItem.Caption); } var ness = sestion .NewSection().AddCell("发布状态", status); ness.AddCell("所属专栏", cateName , new UIClick("Id", sub.Id.ToString(), gKey, "Project") { Model = request.Model, Command = request.Command }); ness.AddCell("评论功能", (sub.IsComment ?? true) ? "开启" : "关闭", new UIClick("Id", Id.ToString(), gKey, "Comment") { Model = request.Model, Command = request.Command }) .NewSection() .AddCell("浏览正文", "", new UIClick(sub.Id.ToString()).Send(request.Model, "View")) .AddCell("管理评论", "", new UIClick(Id.ToString()) { Command = "Comments", Model = request.Model }); if (request.UserAgent.IndexOf("DingTalk") > 0 && sub.project_id.HasValue) { if (Utility.CMS.ObjectEntity <ProjectSetting>() .Where.And().Equal(new ProjectSetting { project_id = sub.project_id, Type = 11 }).Entities.Count() > 0) { var strt = UMC.Security.AccessToken.Current.Data["DingTalk-Sub-Id"] as string;//, Utility.Guid(projectId)).Commit(); var text = ""; if (Utility.Guid(sub.Id.Value) == strt) { text = UMC.Security.AccessToken.Current.Data["DingTalk-Session-Text"] as string; } ness.NewSection().AddCell("发送到群", text, new UIClick("Id", Id.ToString(), gKey, "DingTalk") { Model = request.Model, Command = request.Command }); } } else { if (Utility.CMS.ObjectEntity <ProjectSetting>() .Where.And().Equal(new ProjectSetting { project_id = sub.project_id, Type = 12 }).Entities.Count() > 0) { ness.NewSection().AddCell("发送到群", "", new UIClick("Id", Id.ToString(), gKey, "DingTalk") { Model = request.Model, Command = request.Command }); } } //} sestion.UIFootBar = new UIFootBar().AddText( new UIEventText(sub.Status == 1 ? "下架" : "确认发布").Click(new UIClick("Id", Id.ToString(), "Model", "Status", "Status", sub.Status == 1 ? "-1" : "1") { Model = request.Model, Command = request.Command }).Style(new UIStyle().BgColor()), new UIEventText("摘正文摘要").Click(new UIClick("Id", Id.ToString(), "Model", "AutoDesc") { Model = request.Model, Command = request.Command })); sestion.UIFootBar.IsFixed = true; response.Redirect(sestion); return(this.DialogValue("none")); }); switch (Model) { case "Picture": var seq = this.AsyncDialog("Seq", "1"); this.AsyncDialog("Picture", g => { var sel = new Web.UISheetDialog(); sel.Options.Add(new UIClick(new UMC.Web.WebMeta().Put("id", sub.Id.Value).Put("seq", seq)) { Command = "Picture", Text = "重新上传", Model = "Design" }); sel.Options.Add(new UIClick(new UMC.Web.WebMeta().Put("id", sub.Id.Value).Put("seq", seq).Put("media_id", "none")) { Command = "Picture", Text = "删除图片", Model = "Design" }); return(sel); }); break; case "DingTalk": { if (sub.Status == 1) { switch (this.AsyncDialog("Type", g => { var ds = new UISelectDialog(); ds.Options.Put("用机器人发送", "Robot"); ds.Options.Put("选择到人发送", "Session"); return(ds); })) { case "Robot": if (Utility.CMS.ObjectEntity <ProjectSetting>() .Where.And().Equal(new ProjectSetting { project_id = sub.project_id, Type = 12 }).Entities.Count() > 0) { this.Send(request, sub, String.Empty, true); this.Prompt("机器人发送已经发起"); } else { this.Prompt("此项目未配置钉钉机器人"); } break; } } var DingTalk = Web.UIDialog.AsyncDialog("TalkId", g => { if (request.UserAgent.IndexOf("DingTalk") == -1) { this.Prompt("非钉钉环境,不能获取到钉钉会话参数"); } var ticket = SubjectDingtalkActivity.JsAccessToken(sub.project_id.Value); if (ticket == null) { this.Prompt("未有钉钉配置"); } if (String.IsNullOrEmpty(ticket.AgentId)) { this.Prompt("未有钉钉应用ID"); } var nonceStr = Utility.TimeSpan(); var timeStamp = Utility.TimeSpan(); var url = (request.UrlReferrer ?? request.Url).AbsoluteUri; String plain = "jsapi_ticket=" + ticket.APITicket + "&noncestr=" + nonceStr + "×tamp=" + timeStamp + "&url=" + url; var config = new WebMeta(); config.Put("agentId", ticket.AgentId); config.Put("corpId", ticket.CorpId); config.Put("timeStamp", timeStamp.ToString()); config.Put("nonceStr", nonceStr.ToString()); config.Put("url", url); config.Put("signature", Utility.SHA1(plain).ToLower()); config.Put("jsApiList", new string[] { "biz.map.view", "biz.chat.pickConversation" }); this.Context.Send("Subject.DingTalk", new WebMeta().Put("method", "pickConversation").Put("Sign", config).Put("Params", new WebMeta(request.Arguments).Put("_model", request.Model, "_cmd", request.Command)).Put("Key", g), true); return(this.DialogValue("none")); }); if (sub.Status == 1) { this.Send(request, sub, DingTalk, false); this.Prompt("会话发送已经发起"); } else { UMC.Security.AccessToken.Current.Put("DingTalk-Sub-Id", Utility.Guid(sub.Id.Value)).Put("DingTalk-Session-Text", this.AsyncDialog("TalkId-Text", "Text")).Put("DingTalk-Session-Id", DingTalk).Commit(); } } break; case "Image": Web.UIDialog.AsyncDialog("Image", g => { var dl = new Web.UISheetDialog() { Title = "图片上传" }; dl.Options.Add(new Web.UIClick(sub.Id.ToString()) { Model = request.Model, Command = "Image", Text = "正文图片" }); dl.Options.Add(new Web.UIClick(sub.Id.ToString()) { Model = "Design", Command = "Picture", Text = "本地图片" }); return(dl); }); break; case "Title": var title = Web.UIDialog.AsyncDialog("Title", g => { var dl = new Web.UIFormDialog() { Title = "图文标题" }; dl.AddTextarea("快文标题", "Title", sub.Title); dl.Submit("确认更改", request, "Subject.Save"); return(dl); }); subEntity.Update(new Subject { Title = title }); break; case "Desc": var desc = Web.UIDialog.AsyncDialog("Description", g => { var dl = new Web.UIFormDialog() { Title = "图文摘要" }; dl.AddTextarea("图文摘要", "Description", sub.Description ?? sub.Title).Put("Rows", 10); dl.Submit("确认更改", request, "Subject.Save"); return(dl); }); subEntity.Update(new Subject { Description = desc }); break; case "Score": var Score = Utility.IntParse(Web.UIDialog.AsyncDialog("Score", g => { var dl = new Web.UIFormDialog() { Title = "图文积分" }; dl.AddNumber("图文积分", "Score", sub.Score); dl.Submit("确认更改", request, "Subject.Save"); return(dl); }), 0); if (Score < 0) { this.Prompt("积分必须大于或等于零"); } subEntity.Update(new Subject { Score = Score }); break; case "Project": { var meta = new WebMeta(); if (sub.project_id.HasValue) { var project = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Project { Id = sub.project_id.Value }).Entities.Single(); if (project != null) { if (project.Id == user.Id) { } else { meta.Put("Project", sub.project_id); var member = Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember { project_id = sub.project_id, user_id = user.Id }).Entities.Single(); if (member != null) { switch (member.AuthType) { case WebAuthType.Admin: case WebAuthType.User: break; default: this.Prompt("您未有编辑此图文的权限"); break; } } else { this.Prompt("您未有编辑此图文的权限"); } } } } var sid = UMC.Data.Utility.Guid(this.AsyncDialog("PortfolioId", request.Model, "Portfolio", meta)).Value; var portfolio = Utility.CMS.ObjectEntity <UMC.Data.Entities.Portfolio>() .Where.And().Equal(new Portfolio { Id = sid }).Entities.Single(); var projectItem = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectItem>() .Where.And().Equal(new ProjectItem { Id = portfolio.project_item_id }).Entities.Single(); if (request.IsCashier == false) { var project = Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>() .Where.And().Equal(new Project { Id = portfolio.project_id }).Entities.Single(); if (project.user_id.Value != user.Id) { var member = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>() .Where.And().Equal(new ProjectMember { project_id = project.Id }).Entities.Single(); if (member == null) { this.Prompt("你尚未加入此项目的专栏"); } else { switch (member.AuthType) { case WebAuthType.Admin: case WebAuthType.User: break; default: this.Prompt("你尚未加入此项目的专栏"); break; } } } } if (String.IsNullOrEmpty(sub.Code)) { subEntity.Update(new Subject() { Code = Utility.Parse36Encode(sub.Id.Value.GetHashCode()), portfolio_id = portfolio.Id, project_id = projectItem.project_id, project_item_id = projectItem.Id, last_user_id = user.Id }); } else { subEntity.Update(new Subject() { portfolio_id = portfolio.Id, project_id = projectItem.project_id, project_item_id = projectItem.Id, last_user_id = user.Id }); } } break; case "Comment": var s2 = UMC.Data.Utility.IntParse(this.AsyncDialog("Comment", g => { var dl = new Web.UISelectDialog() { Title = "评论功能" }; dl.Options.Add("开启评论", "1"); dl.Options.Add("关闭评论", "-1"); return(dl); }), 0); subEntity.Update(new Subject { IsComment = s2 == 1 }); break; case "Status": var s = UMC.Data.Utility.IntParse(this.AsyncDialog("Status", g => { var dl = new Web.UISelectDialog() { Title = "发布确认" }; dl.Options.Add("不发布", "-1"); dl.Options.Add("发布", "1"); return(dl); }), 0); if (sub.project_id.HasValue == false || sub.project_item_id.HasValue == false || sub.portfolio_id.HasValue == false) { this.Prompt("请选择发布的栏位"); } if ((sub.soure_id ?? Guid.Empty) != Guid.Empty) { this.Prompt("提示", "非原创,公共栏目不接收,只限于公众号群发。"); } if (s == 0) { if (String.IsNullOrEmpty(sub.Url) == false && sub.Status == -1) { s = 1; } } if (s == -1 && sub.Status == -2) { this.Prompt("被驳回状态,不需要此操作"); } String Sdesc = null; if (s > 0) { //if (String.IsNullOrEmpty(sub.Code)) if (String.IsNullOrEmpty(sub.Description)) { // sub.DataJSON var celss = UMC.Data.JSON.Deserialize <WebMeta[]>((String.IsNullOrEmpty(sub.DataJSON) ? "[]" : sub.DataJSON)) ?? new UMC.Web.WebMeta[] { }; var sb = new StringBuilder(); foreach (var pom in celss) { switch (pom["_CellName"]) { case "CMSText": var value = pom.GetMeta("value"); var format = pom.GetMeta("format")["text"]; var fValue = Utility.Format(format, value.GetDictionary(), String.Empty); if (String.Equals(fValue, sub.Title) == false) { sb.Append(fValue); } if (sb.Length > 250) { break; } break; } } Sdesc = sb.Length > 250 ? sb.ToString(0, 250) : sb.ToString(); sub.Description = Sdesc; } var IsDraught = Utility.CMS.ObjectEntity <UMC.Data.Entities.Picture>().Where .And().In(new Data.Entities.Picture { group_id = sub.Id }).Entities.Count() == 0; subEntity.Update(new Subject { Status = s, Description = Sdesc, IsDraught = IsDraught, Code = String.IsNullOrEmpty(sub.Code) ? Utility.Guid(sub.Id.Value) : null, Poster = user.Alias, ReleaseDate = DateTime.Now }); var cid = String.Empty; // var strt = UMC.Security.AccessToken.Current.Data["DingTalk-Sub-Id"] as string; //, Utility.Guid(projectId)).Commit(); if (Utility.Guid(sub.Id.Value) == strt) { cid = UMC.Security.AccessToken.Current.Data["DingTalk-Session-Id"] as string; } Send(request, sub, cid, true); if (String.IsNullOrEmpty(strt) == false) { UMC.Security.AccessToken.Current.Put("DingTalk-Sub-Id", String.Empty).Commit(); } this.Prompt("发布成功", false); } else { subEntity.Update(new Subject { Status = s, Code = String.IsNullOrEmpty(sub.Code) ? Utility.Guid(sub.Id.Value) : null, }); } break; case "AutoDesc": { // sub.DataJSON var celss = UMC.Data.JSON.Deserialize <WebMeta[]>((String.IsNullOrEmpty(sub.DataJSON) ? "[]" : sub.DataJSON)) ?? new UMC.Web.WebMeta[] { }; var sb = new StringBuilder(); foreach (var pom in celss) { switch (pom["_CellName"]) { case "CMSText": var value = pom.GetMeta("value"); var format = pom.GetMeta("format")["text"]; var fValue = Utility.Format(format, value.GetDictionary(), String.Empty); if (String.Equals(fValue, sub.Title) == false) { sb.Append(fValue); } if (sb.Length > 250) { break; } break; } } var Sdesc2 = sb.Length > 250 ? sb.ToString(0, 250) : sb.ToString(); subEntity.Update(new Subject { Description = Sdesc2 }); } break; case "Show": var m = this.AsyncDialog("Show", g => { var dl = new Web.UISelectDialog() { Title = "封面展示方式" }; dl.Options.Put("封面大图形式", "Max").Put("封面小图形式", "Min"); return(dl); }); subEntity.Update(new Subject { IsPicture = String.Equals(m, "Max") }); break; case "Del": subEntity.Update(new Subject { Visible = -1, LastDate = DateTime.Now }); //subEntity.Delete(); this.Context.Send("Subject.Del", new WebMeta().Put("Id", sub.Id), false); break; } this.Context.Send("Subject.Save", true); }
public override void ProcessActivity(WebRequest request, WebResponse response) { var user = UMC.Security.Identity.Current; var code = this.AsyncDialog("code", g => { return(this.DialogValue("none")); }); var redData = new WebMeta(); var paths = new List <String>(); paths.AddRange(code.Split('/')); Project team = null; switch (code) { case "download": case "explore": response.Redirect(redData.Put("type", code)); break; case "none": response.Redirect(redData.Put("type", "index")); break; case "dashboard": if (user.IsAuthenticated) { var type = this.AsyncDialog("type", "project"); if (type != "project") { response.Redirect(redData.Put("type", "self")); } paths.Clear(); team = Dashboard(user); paths.Add(team.Code); break; } else { if (request.UserAgent.IndexOf("DingTalk") > 0) { if (request.UrlReferrer != null && String.IsNullOrEmpty(request.UrlReferrer.Query) == false) { var Key = request.UrlReferrer.Query.Substring(1); if (String.IsNullOrEmpty(Key) == false) { var project = Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>() .Where.And().Equal(new Project { Code = Key }).Entities.Single(); if (project != null) { var projectSetting = Utility.CMS.ObjectEntity <ProjectSetting>() .Where.And().Equal(new ProjectSetting { project_id = project.Id, Type = 11 }).Entities.Single(); if (projectSetting != null) { var uSetting = Utility.CMS.ObjectEntity <ProjectUserSetting>() .Where.And().Equal(new ProjectUserSetting { Id = projectSetting.user_setting_id, Type = 11 }).Entities.Single(); if (uSetting != null) { redData.Put("id", project.Id); redData.Put("DingTalk", uSetting.CorpId); } } } } } } response.Redirect(redData.Put("type", "login")); } break; } if (String.Equals(code, "none")) { if (user.IsAuthenticated) { response.Redirect(redData.Put("type", "index")); } else { response.Redirect(redData.Put("type", "login")); } } if (team == null) { var scheduleEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>(); scheduleEntity.Order.Asc(new Project { CreationTime = DateTime.MinValue }); scheduleEntity.Where.And().Equal(new Project { Code = paths[0] }); team = scheduleEntity.Single(); } if (team == null) { response.Redirect(redData.Put("type", "index")); } var projects = new List <ProjectItem>(); var projectEntity = Utility.CMS.ObjectEntity <ProjectItem>(); projectEntity.Where.And().In(new ProjectItem { project_id = team.Id }); projectEntity.Order.Asc(new ProjectItem { Sequence = 0 }); projectEntity.Query(dr => projects.Add(dr)); var clsName = "EditerAll"; var editer = team.user_id == user.Id; int status = 1; if (editer == false) { clsName = "View"; status = -1; var member = Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember { project_id = team.Id, user_id = user.Id }).Entities.Single(); if (member != null) { switch (member.AuthType) { case WebAuthType.Admin: clsName = "EditerItem"; status = 1; break; case WebAuthType.All: status = -1; break; case WebAuthType.Guest: status = -1; break; case WebAuthType.User: clsName = "EditerDoc"; status = 1; break; } } } var data = new List <WebMeta>(); int pindex = 0; ProjectItem projectItem = null; foreach (var p in projects) { var meta = new WebMeta(); meta.Put("id", p.Id).Put("text", p.Caption).Put("path", String.Format("{0}/{1}", team.Code, p.Code)); switch (clsName) { case "EditerItem": case "EditerAll": break; default: if (p.Hide == true) { meta.Put("hide", true); } break; } if (paths.Count > 1 && String.Equals(paths[1], p.Code, StringComparison.CurrentCultureIgnoreCase)) { projectItem = p;//.Id.Value; pindex = data.Count; } data.Add(meta); } var webr = Data.WebResource.Instance(); var menu = redData.Put("menu", data).Put("selectIndex", pindex).Put("text", team.Caption).Put("code", team.Code).Put("id", team.Id).Put("src", webr.ImageResolve(team.Id.Value, "1", 4)); menu["Auth"] = clsName; if (user.IsAuthenticated) { menu["Authed"] = "OK"; } if (projects.Count > 0) { var pitem = projectItem == null ? projects[pindex] : projectItem; var subs = SubjectPortfolioSubActivity.Portfolio(team, pitem, status); menu.Put("subs", subs).Put("nav", String.Format("{0}/{1}", team.Code, pitem.Code)); } if (paths.Count == 3 && projectItem != null) { var sub = Utility.CMS.ObjectEntity <Subject>().Where.And().Equal(new Subject { project_id = team.Id, project_item_id = projectItem.Id, Code = paths[2] }).Entities.Single(); if (sub != null) { menu.Put("spa", new WebMeta().Put("id", sub.Id).Put("path", String.Format("{0}/{1}/{2}", team.Code, projectItem.Code, sub.Code))); } } if (request.UserAgent.IndexOf("DingTalk") > 0) { if (user.IsAuthenticated == false) { var projectSetting = Utility.CMS.ObjectEntity <ProjectSetting>() .Where.And().Equal(new ProjectSetting { project_id = team.Id, Type = 11 }).Entities.Single(); if (projectSetting != null) { var uSetting = Utility.CMS.ObjectEntity <ProjectUserSetting>() .Where.And().Equal(new ProjectUserSetting { Id = projectSetting.user_setting_id, Type = 11 }).Entities.Single(); if (uSetting != null) { redData.Put("DingTalk", uSetting.CorpId); } } } else if (paths.Count == 2 && paths[1] == "follow") { menu.Put("follow", true); } } else if (paths.Count == 2 && paths[1] == "follow") { menu.Put("follow", true); } response.Redirect(menu); }
/// <summary> /// 创建视频资讯组件 /// </summary> public UICMS(WebMeta data, Uri videoSrc, String src) { this.data = data.Put("src", src).Put("video-src", videoSrc); this.Type = "CMSMax"; }
//public void Button(params UIButton[] btns) //{ // data.Put("buttons", btns); //} public void Button(params UIEventText[] btns) { data.Put("buttons", btns); }