Exemplo n.º 1
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var identity = UMC.Security.Identity.Current;

            var userId = identity.Id;

            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);
            }


            var logoUrl = webr.ResolveUrl(userId.Value, "1", 4);

            var members = identity.IsAuthenticated ? Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>()
                          .Where.And().Equal(new Data.Entities.ProjectMember {
                user_id = userId
            })
                          .Entities.Count() : 0;

            var suject = identity.IsAuthenticated ?
                         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() : new Subject()
            {
                Seq = 0, Reply = 0, Look = 0
            };

            if (identity.IsAuthenticated)
            {
                members += Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>()
                           .Where.And().Equal(new Data.Entities.Project {
                    user_id = userId
                })
                           .Entities.Count();
            }

            var Discount = new UIHeader.Portrait(identity.IsAuthenticated ? logoUrl : "https://oss.365lu.cn/css/images/header_image.png");

            ;
            var user = identity;

            Discount.Value(user.IsAuthenticated ? user.Alias : "请登录");
            Discount.Click(new UIClick().Send("Account", "Self"));

            if (user.IsAuthenticated)
            {
                var sign = Data.Database.Instance().ObjectEntity <Data.Entities.Account>()
                           .Where.And().Equal(new Data.Entities.Account {
                    user_id = userId, Type = Security.Account.SIGNATURE_ACCOUNT_KEY
                }).Entities.Single();
                //if (sign != null)
                Discount.Time(sign != null ? sign.Name : " ");// user.ActiveTime.ToString());
            }
            else
            {
                Discount.Time(" ");
            }
            var color = 0x63b359;

            Discount.Gradient(color, color);
            var header = new UIHeader();
            var title  = UITitle.Create();

            title.Title = "我的";
            header.AddPortrait(Discount);

            title.Style.BgColor(color);
            title.Style.Color(0xfff);

            var ui = UISection.Create(header, title);


            var uIIcon = new UIIconNameDesc(new UIIconNameDesc.Item('\uF19d', "参与项目", members + "项").Color(0x40c9c6));

            if (user.IsAuthenticated)
            {
                uIIcon.Button("查看", UIClick.Pager("Subject", "Account", new WebMeta().Put("selectIndex", 1)), 0x1890ff);
            }
            else
            {
                uIIcon.Button("请登录", new UIClick().Send("Account", "Login"), 0xb7babb);
            }
            ui.Add(uIIcon);
            uIIcon = new UIIconNameDesc(new UIIconNameDesc.Item('\uF02d', "知识创作", suject.Seq + "篇").Color(0x36a3f7), new UIIconNameDesc.Item('\uf0e6', "被评论", suject.Reply + "次").Color(0x34bfa3));
            //new UIIconNameDesc.Item('\uf06e', "被浏览", suject.Look + "次").Color(0xf4516c),
            ui.Add(uIIcon);


            ui.NewSection()
            .AddCell('\uf198', "新建文档", "采用Markdown格式编写", new Web.UIClick("Markdown").Send("Subject", "Content"))
            .AddCell('\uf13b', "新建富文本文档", "采用富文本格式编写", new Web.UIClick("News").Send("Subject", "Content"))
            .AddCell('\uf0c5', "抓取文档", "从粘贴板版网址中抓取文档", new Web.UIClick()
            {
                Key = "CaseCMS"
            });

            ui.NewSection().AddCell('\uf2e1', "扫一扫", "", new Web.UIClick()
            {
                Key = "Scanning"
            });
            ui.NewSection()
            //.AddCell('\uf19c', "切换企业", "", Web.UIClick.Pager("Platform", "Corp", true))
            .AddCell('\uf013', "设置", "", Web.UIClick.Pager("UI", "Setting", true, "Close"));



            response.Redirect(ui);
        }
Exemplo n.º 2
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var key = this.AsyncDialog("Key", g => this.DialogValue("EDITER"));

            Guid?projectId = UMC.Data.Utility.Guid(this.AsyncDialog("Project", "EDITER")); //["Project"]);
            var  type      = this.AsyncDialog("Type", "All");


            var userId = Utility.Guid(Web.UIDialog.AsyncDialog("UserId", dKey =>
            {
                if (request.SendValues == null || request.SendValues.ContainsKey("start") == false)
                {
                    var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments);
                    buider.CloseEvent("UI.Event");
                    this.Context.Send(buider.Builder(), true);
                }

                var webr = UMC.Data.WebResource.Instance();
                var form = request.SendValues ?? new UMC.Web.WebMeta();

                int limit   = UMC.Data.Utility.IntParse(form["limit"] as string, 25);
                int start   = UMC.Data.Utility.IntParse(form["start"] as string, 0);
                var sestion = start == 0 ? UISection.Create(new UIHeader().Search("搜索"), new UITitle("选择成员")) : UISection.Create();

                var objectEntity = Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new Data.Entities.ProjectMember {
                    project_id = projectId
                }).Entities;
                switch (type)
                {
                default:
                    break;

                case "User":
                    objectEntity.Where.And().Equal(new ProjectMember {
                        AuthType = WebAuthType.User
                    });
                    break;

                case "Guest":
                    objectEntity.Where.And().Equal(new ProjectMember {
                        AuthType = WebAuthType.Guest
                    });
                    break;

                case "Admin":
                    objectEntity.Where.And().Equal(new ProjectMember {
                        AuthType = WebAuthType.Admin
                    });
                    break;
                }
                var Keyword = (form["Keyword"] as string ?? String.Empty);


                if (String.IsNullOrEmpty(Keyword) == false)
                {
                    objectEntity.Where.And().Like(new ProjectMember {
                        Alias = Keyword
                    });
                }
                objectEntity.Query(start, limit, dr =>
                {
                    var cellUI = new UIIconNameDesc(new UIIconNameDesc.Item(webr.ResolveUrl(dr.user_id.Value, "1", "4"), dr.Alias,
                                                                            dr.CreationTime.ToString())
                                                    .Click(new UIClick(new WebMeta(request.Arguments).Put(dKey, dr.user_id)).Send(request.Model, request.Command)));
                    sestion.Add(cellUI);
                });
                if (sestion.Total == 0)
                {
                    sestion.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(sestion);
                return(this.DialogValue("none"));
            }));


            var member = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>()
                         .Where.And().Equal(new Data.Entities.ProjectMember {
                user_id = userId, project_id = projectId
            }).Entities.Single();

            this.Context.Send(new WebMeta().UIEvent(key, new ListItem(member.Alias, member.user_id.ToString())), true);
        }
        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);
            }
        }
Exemplo n.º 4
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            switch (request.SendValue)
            {
            case "AnimImage":

                var uiview = new UIView();
                uiview.Style.Width("80%");
                uiview.Src = new Uri("http://www.365lu.cn/UserResources/1usm4ih/1599785635641/red_packet_bg.png");

                uiview.Add("https://data.kukahome.com/css/images/logo.png", new UIStyle().Name("top", "-20%").Name("width", "25%").Name("border-radius", "50%").Name("border-width", "5%").Name("border-color", "#fff"));


                var style = new UIStyle().Name("top", "30%").Name("width", "30%");

                style.Name("clicked").Name("animation-name", "reverse");
                style.Name("animation-name", "scale");

                uiview.Add(new UIClick("Date").Send(request.Model, request.Command), new Uri("http://www.365lu.cn/UserResources/1usm4ih/1599785654433/icon_open_red_packet1.png"), style);

                uiview.Add("牛人啊,请玩红包", new UIStyle().Color(0xfff).Size(30).Name("width", "80%"));
                this.Context.Send("UIView", new WebMeta().Put("view", uiview), true);
                break;

            case "Date":
                this.AsyncDialog("D", "none");
                this.AsyncDialog("Datec", g =>
                {
                    return(UIDateDialog.CreateDialog("Time"));
                });
                return;;
            }
            var form  = request.SendValues ?? new UMC.Web.WebMeta();
            var start = Utility.IntParse(form["start"], 0);
            var limit = Utility.IntParse(form["limit"], 1000);

            if (form.ContainsKey("limit") == false)
            {
                this.Context.Send(new UISectionBuilder(request.Model, request.Command, request.Arguments)
                                  .RefreshEvent("Builder")
                                  .Builder(), true);
            }

            var videoSrc = new Uri("http://2449.vod.myqcloud.com/2449_22ca37a6ea9011e5acaaf51d105342e3.f20.mp4");
            var ui       = UISection.Create(new UITitle("Demo"));

            if (start == 0)
            {
                UIView coustomCell = new UIView("UMC_User");

                coustomCell.Style.Name("width", "50%");
                coustomCell.Src = new Uri("http://www.365lu.cn/UserResources/1usm4ih/1599785635641/red_packet_bg.png");
                coustomCell.Add("image", new Uri("http://www.365lu.cn/UserResources/1usm4ih/1599785654433/icon_open_red_packet1.png"), new UIStyle().Name("width", "20%").Name("animation-name", "reverse"));
                coustomCell.Add("Text", "你好啊,是不是很好呢", new UIStyle().Name("left", "10").AlignLeft());
                ui.Componen.Add(coustomCell);
                ui.UIHeader = new UIHeader().Coustom(coustomCell);
            }

            var footer = new UIFootBar();

            footer.AddText(new UIEventText("w磊").Style(new UIStyle().Fixed().BgColor().Name("margin", "10").Name("border-radius", "10")));
            ui.UIFootBar   = footer;
            footer.IsFixed = true;
            var uIIcon = new UIIconNameDesc(new UIIconNameDesc.Item('\uF02d', "知识创作", "1篇").Color(0x36a3f7));

            ui.Add(uIIcon);
            uIIcon.Button("图片动画", new UIClick("AnimImage").Send(request.Model, request.Command), 0x36a3f7);
            uIIcon.Style.Name("fixed", "true");
            var text = new UITextDesc(new WebMeta().Put("title", "TextDesc使用说明", "desc", "格式属性title、desc、tag", "tag", "122"));

            text.Click(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/TextDesc"), true));
            ui.Add(text);
            var cell = UICell.Create("UMC_User", new WebMeta().Put("Text", "失人啊").Put("image", "https://www.baidu.com/img/flexible/logo/pc/result.png"));

            cell.Style.Name("Text").Color(0x05d);
            ui.Add(cell);

            var imge = new UIImageTextDesc(new WebMeta().Put("title", "ImageTextDesc使用说明", "desc", "格式属性title、desc、tag", "tag", "122", "right", "right").Put("src", "https://data.kukahome.com/css/images/logo.png"));

            imge.Click(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/ImageTextDesc"), true));
            ui.Add(imge);
            var cmT = new UICMSImage("https://data.kukahome.com/css/images/logo.png");

            cmT.Style.Name("width", "60%").AlignLeft().Padding(10);
            ui.Add(cmT);

            var d = new UITextNameValue("Name", "Text", "Value ");

            d.Click(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/TextNameValue"), true));
            ui.Add(d);

            var img2e = new UIImageTextDescTime(new WebMeta().Put("tag", "I12", "text", "ImageTextDescTime组件", "desc", "desc格式", "time", "time格式", "right", "right").Put("src", "https://data.kukahome.com/css/images/logo.png"));

            img2e.Click(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/ImageTextDescTime"), true));
            ui.Add(img2e);

            UIImageTextValue imageTextValue = new UIImageTextValue("https://data.kukahome.com/css/images/logo.png", "ImageTextValue组件", "Value格式");

            imageTextValue.Click(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/ImageTextValue"), true));
            ui.Add(imageTextValue);


            UI ui3 = new UI("UI组件", "Value格式");

            ui3.Click(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/UI"), true));
            ui3.Icon('\uf013', 0x4CAF50);
            ui.Add(ui3);
            //UIIconNameDesc iconNameDesc = new UIIconNameDesc(new UIIconNameDesc.Item("UI组件", "desc"));
            ui.Add(new UIIconNameDesc(new UIIconNameDesc.Item("UI组件", "desc").Click(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/IconNameDesc"), true))));
            ui.Add(new UIIconNameDesc(new UIIconNameDesc.Item("https://data.kukahome.com/css/images/logo.png", "UI组件", "desc").Click(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/IconNameDesc"), true))));
            ui.Add(new UIIconNameDesc(new UIIconNameDesc.Item("https://data.kukahome.com/css/images/logo.png", "UI组件", "desc")
                                      .Click(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/IconNameDesc"), true))).Button("关注", Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/IconNameDesc"), true), 0x1890ff));

            ui.Add(new UIIconNameDesc(new UIIconNameDesc.Item("https://data.kukahome.com/css/images/logo.png", "UI组件", "desc"), new UIIconNameDesc.Item("https://data.kukahome.com/css/images/logo.png", "UI组件", "desc").Click(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/IconNameDesc"), true))));
            var dis = new UIDiscount(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/IconNameDesc"), true));

            dis.Title("UIDiscount优惠券组件");
            dis.State("有效");
            dis.Value("5元");
            dis.Desc("超级优惠券");
            dis.Start("2020.12.1");
            dis.End("2020.12.1");
            ui.Add(dis);


            var look = new UICMSLook("https://data.kukahome.com/css/images/logo.png", "CMSLook组件", "desc");

            look.Click(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/IconNameDesc"), true));

            ui.Add(look);
            var v = new UISheet("UISheet组件");

            v.AddItem("CMSLook组件", "desc");
            v.AddItem("CMSLook组件", "desc", true);
            //  var look2 = new UIItemText("CMSLook组件", "desc");
            //  look2.Click(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/IconNameDesc"), true));

            ui.Add(v);

            var uiitems = new UIItems();

            uiitems.Add("https://data.kukahome.com/css/images/logo.png", "Title", "desc", 0xff2, 0xff0000);
            uiitems.Add("https://data.kukahome.com/css/images/logo.png", "Title", "desc", 0xff2, 0xff0000);
            uiitems.Add("https://data.kukahome.com/css/images/logo.png", "Title", "desc", 0xff2, 0xff0000);
            uiitems.Add("https://data.kukahome.com/css/images/logo.png", "UIItems", "UIItems");
            //uiitems.Add("https://data.kukahome.com/css/images/logo.png", "UIItems", "UIItems");
            //dis.Click()
            ui.Add(uiitems);
            UINineImage nineImage = new UINineImage();

            nineImage.Add("https://data.kukahome.com/css/images/logo.png");
            nineImage.Add("https://data.kukahome.com/css/images/logo.png");
            nineImage.Add("https://www.365lu.cn/css/images/center_left.svg");
            nineImage.Click(Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "UMC/Rows/IconNameDesc"), true));
            ui.Add(nineImage);
            ui.Add(new Web.UI.UIIcon().Add(new UIEventText('\ue906', "Iicon").Badge("12323"), new UIEventText("Iicon").Src("https://data.kukahome.com/css/images/logo.png"), new UIEventText("Iicon").Src("https://data.kukahome.com/css/images/logo.png").Badge("1")));

            UITitleMore more = new UITitleMore("Slider");
            var         tab  = new UITabFixed();

            tab.Add("列组", "1");

            tab.Add("列组", "1");
            tab.Add("列组", "1");
            tab.Add("列组", "1");
            tab.Add("列组", "1");
            tab.Add("列组", "1");
            tab.Add("列组", "1");
            tab.Add("列组", "1");
            tab.Add("列组", "1");
            tab.Add("列组", "1");
            tab.Add("列组", "1");
            tab.Add("列组", "1");
            tab.Add("列组", "1");
            tab.Add("列组", "1");
            tab.Add("列组", "1");
            tab.Add(new UIClick()
            {
                Text = "在的呢"
            });
            ui.Add(tab);
            var cms = new UICMS(new WebMeta().Put("title", "列组"), videoSrc, "https://data.kukahome.com/css/images/logo.png");

            cms.Left("imy");
            cms.Right("imy");
            ui.Add(cms);
            var cmsImage = new UICMSImage(videoSrc, "https://data.kukahome.com/css/images/logo.png");

            cmsImage.Style.Name("width", "60%").AlignLeft();
            var ui2     = ui.NewSection().Add(more).Add(cmsImage);
            var seilder = new UISlider();

            seilder.Add(videoSrc, "https://data.kukahome.com/css/images/logo.png");
            //seilder.Add("https://data.kukahome.com/css/images/logo.png");/
            seilder.Small();
            ui2.Add(seilder);
            seilder = new UISlider(true);
            seilder.Add("https://data.kukahome.com/css/images/logo.png");
            seilder.Add("https://data.kukahome.com/css/images/logo.png");
            // seilder.Small();
            ui2.Add(seilder);
            seilder = new UISlider();
            seilder.Add("https://data.kukahome.com/css/images/logo.png");
            //seilder.Add("https://data.kukahome.com/css/images/logo.png");
            seilder.Row();
            ui2.Add(seilder);
            UITextItems textItems = new UITextItems();

            textItems.Add(new UIEventText("232323").Style(new UIStyle().BgColor()), new UIEventText("安装").Style(new UIStyle().BgColor()), new UIEventText("安装"), new UIEventText("安装"));
            textItems.Add(new UIEventText("232323"), new UIEventText("安装"), new UIEventText("安装"), new UIEventText("sdsdsfsdfsdfsd").Style(new UIStyle().BgColor()));
            textItems.Add(new UIEventText("232323").Style(new UIStyle().BgColor()), new UIEventText("dsdsd"), new UIEventText("sdsdsd"), new UIEventText("sdsdsd").Style(new UIStyle().BgColor()));

            ui2.Add(textItems);
            UIButton button = new UIButton();

            button.Button(new UIEventText("安装").Badge("1d"));
            button.Style.AlignCenter();
            ui.NewSection().Add(button);
            ui.Title.Right(new UIEventText('\uf2e1', "33d").Click(new UIClick()
            {
                Key = "Float"
            }));                                                                                    //.Badge("21"));
            response.Redirect(ui);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var key = this.AsyncDialog("Key", g => this.DialogValue("Promotion"));

            if (String.IsNullOrEmpty(request.SendValue) == false)
            {
                var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments);
                buider.CloseEvent("UI.Event");
                this.Context.Send(buider.Builder(), true);
            }

            var user = Security.Identity.Current;
            var ui   = UISection.Create();

            var paramsKey = request.SendValues ?? new UMC.Web.WebMeta();

            var start = UMC.Data.Utility.Parse((paramsKey["start"] ?? "0").ToString(), 0);
            var limit = UMC.Data.Utility.Parse((paramsKey["limit"] ?? "25").ToString(), 25);



            var Type   = this.AsyncDialog("Type", "Project");
            var itemId = Utility.Guid(this.AsyncDialog("Item", cId =>
            {
                return(this.DialogValue("none"));
            }));

            switch (Type)
            {
            case "Project":
            {
                ui.Title = new UITitle("我的专栏项目");;
                var ids  = new List <Guid>();
                var pros = new List <Project>();
                Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project {
                        user_id = user.Id
                    })
                .Or().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 =>
                    {
                        pros.Add(dr); ids.Add(dr.Id.Value);
                    });

                if (ids.Count > 0)
                {
                    var webr = UMC.Data.WebResource.Instance();
                    var subs = new List <Subject>();
                    Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>()
                    .Where.And().In(new Subject {
                            project_id = ids[0]
                        }, ids.ToArray())
                    .Entities.GroupBy(new Subject {
                            project_id = Guid.Empty
                        }).Count(new Subject {
                            Seq = 0
                        }).Query(dr => subs.Add(dr));

                    foreach (var p in pros)
                    {
                        var sub  = subs.Find(s => s.project_id == p.Id);
                        var desc = new UIIconNameDesc(new UIIconNameDesc.Item(webr.ResolveUrl(p.Id.Value, "1", "4"), p.Caption,
                                                                              String.Format("知识{0}篇", sub == null ? 0 : sub.Seq))
                                                      .Click(Web.UIClick.Query(new WebMeta().Put("Item", p.Id).Put("Type", "Items"))));

                        if (p.user_id == user.Id)
                        {
                            desc.Button("我的", null, 0x25b864);
                        }
                        ui.Add(desc);
                    }
                }
                else
                {
                    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);
            }
            break;

            case "Items":
            {
                ui.Title = new UITitle("选择专栏");
                var subs = new List <Subject>();
                Utility.CMS.ObjectEntity <Subject>().Where.And().In(new Subject {
                        project_id = itemId
                    }).Entities
                .GroupBy(new Subject {
                        project_item_id = Guid.Empty
                    })
                .Count(new Subject {
                        Look = 0
                    })
                .Query(dr => subs.Add(dr));

                var project = Utility.CMS.ObjectEntity <Project>().Where.And().In(new Project {
                        Id = itemId
                    }).Entities.Single();

                ui.AddCell('\uf112', "返回上一级", project.Caption, new UIClick(new WebMeta().Put("Key", key).Put("Type", "Project"))
                    {
                        Key = "Query"
                    });

                var u3            = ui.NewSection();
                var projects      = new List <ProjectItem>();
                var projectEntity = Utility.CMS.ObjectEntity <ProjectItem>();
                projectEntity.Where.And().In(new ProjectItem {
                        project_id = itemId
                    });

                projectEntity.Order.Asc(new ProjectItem {
                        Sequence = 0
                    });

                projectEntity.Query(dr =>
                    {
                        var su = subs.Find(s => s.project_item_id == dr.Id);
                        u3.AddCell('\uf022', dr.Caption, String.Format("{0}篇", su == null ? 0 : su.Look)
                                   , new UIClick(new WebMeta().Put("Key", key).Put("Item", dr.Id).Put("Type", "Portfolio"))
                        {
                            Key = "Query"
                        });
                    });
            }
            break;

            case "Portfolio":
            {
                ui.Title = new UITitle("选择文集");
                var projectItem = Utility.CMS.ObjectEntity <ProjectItem>().Where.And().Equal(new ProjectItem {
                        Id = itemId
                    }).Entities.Single();
                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));

                ui.AddCell('\uf112', "返回上一级", projectItem.Caption, new UIClick(new WebMeta().Put("Key", key).Put("Type", "Items").Put("Item", projectItem.project_id))
                    {
                        Key = "Query"
                    });

                var ui3 = ui.NewSection();

                Utility.CMS.ObjectEntity <Portfolio>().Where.And().Equal(new Portfolio {
                        project_item_id = projectItem.Id
                    }).Entities
                .Order.Asc(new Portfolio {
                        Sequence = 0
                    }).Entities
                .Query(dr =>
                    {
                        var su = subs.Find(s => s.portfolio_id == dr.Id);
                        ui3.AddCell('\uf22b', dr.Caption, String.Format("{0}篇", su == null ? 0 : su.Look)
                                    , new UIClick(new WebMeta().Put("Key", key).Put("Item", dr.Id).Put("Type", "Subs"))
                        {
                            Key = "Query"
                        });
                    });
            }
            break;

            case "Subs":
            {
                var ui3 = ui;
                if (start == 0)
                {
                    ui.Title = new UITitle("图文选择");
                    var portfolio = Utility.CMS.ObjectEntity <Portfolio>().Where.And().In(new Portfolio {
                            Id = itemId
                        }).Entities.Single();


                    ui.AddCell('\uf112', "返回上一级", portfolio.Caption, new UIClick(new WebMeta().Put("Key", key).Put("Type", "Portfolio").Put("Item", portfolio.project_item_id))
                        {
                            Key = "Query"
                        });


                    ui3 = ui.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
                    });
                this.Search(request.Model, ui3, subEntity, key, 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;

            case "Sub":
            {
                var su = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>().Where.And().Equal(new Subject {
                        Id = itemId.Value
                    }).Entities.Single();

                this.Context.Send(new UMC.Web.WebMeta().UIEvent(key, new Web.ListItem(su.Title, su.Id.ToString())), true);
            }
            break;
            }
            response.Redirect(ui);
        }
Exemplo n.º 7
0
        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 =>
            {
                var ProjectId = Utility.Guid(this.AsyncDialog("Project", g =>
                {
                    if (request.SendValues == null || request.SendValues.ContainsKey("start") == false)
                    {
                        var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments);
                        buider.CloseEvent("UI.Event").RefreshEvent("Subject.Project");
                        this.Context.Send(buider.Builder(), true);
                    }
                    UITitle title = UITitle.Create();

                    title.Title = "我的专栏项目";

                    var ui   = UISection.Create(title);
                    var ids  = new List <Guid>();
                    var pros = new List <Project>();
                    Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project {
                        user_id = user.Id
                    })
                    .Or().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 =>
                    {
                        pros.Add(dr); ids.Add(dr.Id.Value);
                    });

                    if (ids.Count > 0)
                    {
                        var webr = UMC.Data.WebResource.Instance();
                        var subs = new List <Subject>();
                        Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>()
                        .Where.And().In(new Subject {
                            project_id = ids[0]
                        }, ids.ToArray())
                        .Entities.GroupBy(new Subject {
                            project_id = Guid.Empty
                        }).Count(new Subject {
                            Seq = 0
                        }).Query(dr => subs.Add(dr));

                        foreach (var p in pros)
                        {
                            var sub  = subs.Find(s => s.project_id == p.Id);
                            var desc = new UIIconNameDesc(new UIIconNameDesc.Item(webr.ResolveUrl(p.Id.Value, "1", "4"), p.Caption,
                                                                                  String.Format("知识{0}篇", sub == null ? 0 : sub.Seq))
                                                          .Click(Web.UIClick.Query(new WebMeta().Put("Project", p.Id))));

                            //if(desc.Button())
                            if (p.user_id == user.Id)
                            {
                                desc.Button("我的", null, 0x25b864);
                            }
                            ui.Add(desc);
                        }
                    }
                    else
                    {
                        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)));

                        ui.NewSection().AddCell('\uf19d', "创立我的项目"
                                                , "", new UIClick("News").Send(request.Model, "ProjectUI"));
                    }

                    response.Redirect(ui);

                    return(this.DialogValue("Project"));
                })) ?? Guid.Empty;
                if (ProjectId == Guid.Empty)
                {
                    this.Prompt("未传入项目");
                }
                var projectItemId = Utility.Guid(this.AsyncDialog("Item", g => this.DialogValue("Item"))) ?? Guid.Empty;

                if (request.SendValues == null || request.SendValues.ContainsKey("start") == false)
                {
                    var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments);
                    buider.CloseEvent("UI.Event");
                    this.Context.Send(buider.Builder(), true);
                }

                UITitle uITItle = UITitle.Create();
                if (projectItemId == Guid.Empty)
                {
                    uITItle.Title = "选择栏位";
                }
                else
                {
                    uITItle.Title = "选择目录";
                }
                var sestion = UISection.Create(uITItle);
                if (projectItemId == Guid.Empty)
                {
                    var team = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project {
                        Id = ProjectId
                    }).Entities.Single();
                    sestion.AddCell("所属项目", team.Caption);
                    var ui2 = sestion.NewSection();
                    Utility.CMS.ObjectEntity <ProjectItem>().Where.And().Equal(new Data.Entities.ProjectItem {
                        project_id = ProjectId
                    }).Entities.Order.Asc(new ProjectItem {
                        Sequence = 0
                    }).Entities.Query(dr =>
                    {
                        ui2.AddCell(dr.Caption, Web.UIClick.Query(new WebMeta().Put("Item", dr.Id)));
                    });
                }
                else
                {
                    var team = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project
                    {
                        Id = ProjectId
                    }).Entities.Single();
                    sestion.AddCell("所属项目", team.Caption);

                    var project = Utility.CMS.ObjectEntity <ProjectItem>().Where.And().Equal(new Data.Entities.ProjectItem
                    {
                        Id = projectItemId
                    }).Entities.Single();
                    sestion.AddCell("所属栏位", project.Caption);
                    var ui2 = sestion.NewSection();

                    Utility.CMS.ObjectEntity <Portfolio>().Where.And().Equal(new Data.Entities.Portfolio {
                        project_item_id = project.Id
                    })
                    .Entities.Order.Asc(new Portfolio {
                        Sequence = 0
                    }).Entities.Query(dr =>
                    {
                        ui2.AddCell(dr.Caption, new Web.UIClick(new WebMeta(request.Arguments).Put(d, dr.Id)).Send(request.Model, request.Command));
                    });
                }
                response.Redirect(sestion);
                return(this.DialogValue("none"));
            });
            var cmdId = UMC.Data.Utility.Guid(sid) ?? Guid.Empty;

            var category = new Portfolio();

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

            category = objectEntity.Where.And().Equal(new Portfolio
            {
                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 Caption = Web.UIDialog.AsyncDialog("Caption", d =>
            {
                var fmdg   = new Web.UIFormDialog();
                fmdg.Title = category.Id.HasValue ? "编辑" : "新建";
                fmdg.AddText("文集名称", "Caption", category.Caption);
                fmdg.Submit("确认提交", request, "Subject.Portfolio", "Subject.Portfolio.Add");
                return(fmdg);
            });

            category.Caption = Caption;

            if (category.Id.HasValue == false)
            {
                var ItemId = Utility.Guid(this.AsyncDialog("ItemId", g => this.DialogValue("Item"))).Value;

                var project = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectItem>().Where.And().Equal(new ProjectItem
                {
                    Id = ItemId
                }).Entities.Single();
                category.Id              = Guid.NewGuid();
                category.project_id      = project.project_id;
                category.project_item_id = project.Id;

                category.user_id      = user.Id;
                category.CreationTime = DateTime.Now;
                category.Count        = 0;
                category.Sequence     = Utility.TimeSpan();


                objectEntity.Insert(category);

                this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Portfolio.Add").Put("Id", category.Id).Put("Text", category.Caption), true);
            }
            else
            {
                objectEntity.Update(new Portfolio {
                    Caption = Caption
                });
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Portfolio").Put("Id", category.Id), true);
            }
        }