コード例 #1
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var     list   = new List <WebMeta>();
            var     stitle = "天天录";
            UITitle title  = new UITitle(stitle);
            var     items  = new List <UIClick>();

            var entity = Data.Database.Instance().ObjectEntity <SearchKeyword>()
                         .Where
                         .And().In(new SearchKeyword {
                user_id = Guid.Empty
            })
                         .Entities.Order.Desc(new SearchKeyword {
                Time = 0
            }).Entities;

            entity.Query(0, 20, dr => items.Add(new UIClick(new WebMeta().Put("cmd", "UI", "model", "Subject", "text", dr.Keyword))
            {
                Key = "Search", Text = dr.Keyword
            }));

            if (items.Exists(g => String.Equals(g.Text, stitle, StringComparison.CurrentCultureIgnoreCase)) == false)
            {
                items.Insert(0, new UIClick(new WebMeta().Put("cmd", "UI", "model", "Subject", "text", stitle))
                {
                    Key = "Search", Text = stitle
                });
            }
            title.Items(items.ToArray());
            title.Name("icon", "\uea0e");

            title.Right(new UIEventText().Icon('\uf2e1').Click(UIClick.Scanning()));
            list.Add(new WebMeta().Put("model", "Subject", "cmd", "UI", "text", "知识推荐").Put("RefreshEvent", "Subject.Save"));
            list.Add(new WebMeta().Put("model", "Subject", "cmd", "Follow", "text", "我的关注").Put("RefreshEvent", "Subject.Save"));
            list.Add(new WebMeta().Put("model", "Subject", "cmd", "Self", "text", "我的文档").Put("RefreshEvent", "Subject.Save"));

            response.Redirect(new WebMeta().Put("title", title).Put("sections", list));
        }
コード例 #2
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            Guid designId = UMC.Data.Utility.Guid(this.AsyncDialog("Id", g => this.DialogValue(Guid.Empty.ToString()))).Value;//this.DialogValue(response.Ticket[AttributeNames.TICKET_STORE_ID])), true).Value;


            if (_isEditer)
            {
                WebMeta form = request.SendValues ?? request.Arguments;

                this.AsyncDialog("Model", anycId =>
                {
                    if (form.ContainsKey("limit") == false)
                    {
                        this.Context.Send(new UISectionBuilder(request.Model, request.Command, new WebMeta().Put("Id", designId))
                                          .RefreshEvent("Design", "image")
                                          .Builder(), true);
                    }
                    var entity = Database.Instance().ObjectEntity <Design_Item>();
                    entity.Where.And().Equal(new Design_Item {
                        design_id = Guid.Empty, for_id = Guid.Empty
                    });
                    entity.Order.Asc(new Design_Item {
                        Seq = 0
                    });
                    //IObjectEntity<Design_Item> entity = Database.instance().objectEntity(Design_Item.class);
                    //    entity.where().and().equal(new Design_Item().Design_id(Utility.uuidEmpty).For_id(Utility.uuidEmpty));
                    //    entity.order().asc(new Design_Item().Seq(0));
                    Design_Item[] headers = entity.Query();

                    UISection section = UISection.Create(new UITitle("UMC"));

                    int limit = UMC.Data.Utility.Parse(form.Get("limit"), 10);
                    int start = UMC.Data.Utility.Parse(form.Get("start"), 0);

                    switch (headers.Length)
                    {
                    case 0:
                        break;

                    case 1:
                        section.Title.Title = (headers[0].ItemName);
                        //     section.title().right('\ue907', new UIClick("Id", headers[0].Id.toString(), "Model", "none").model(request.model(), request.cmd()));
                        break;

                    default:
                        if (start == 0)
                        {
                            List <WebMeta> items = new List <WebMeta>();
                            foreach (Design_Item item in headers)
                            {
                                items.Add(new UMC.Web.WebMeta().Put("text", item.ItemName).Put("search", new WebMeta().Put("Id", item.Id)));
                            }
                            section.Add(UICell.Create("TabFixed", new UMC.Web.WebMeta().Put("items", items)));
                        }
                        break;
                    }


                    if (designId == Guid.Empty)
                    {
                        switch (headers.Length)
                        {
                        case 0:
                            break;

                        default:
                            new UIDesigner(true).Section(section, headers[0].Id.Value);
                            break;
                        }
                    }
                    else
                    {
                        new UIDesigner(true).Section(section, designId);
                    }
                    if (section.Length == 0)
                    {
                        section.Add("Desc", new UMC.Web.WebMeta().Put("desc", "未有设计分类项,请添加").Put("icon", "\uEA05")
                                    , 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)));
                    }
                    UIFooter footer = new UIFooter();
                    footer.IsFixed  = true;// e);

                    switch (headers.Length)
                    {
                    case 0:

                        footer.AddText(new UIEventText("添加分类项").Click(new UIClick("Model", "News", "Type", "Append").Send(request.Model, request.Command)));
                        break;

                    default:
                        Guid did = designId;
                        if (designId == Guid.Empty)
                        {
                            did = headers[0].Id.Value;
                        }
                        footer.AddIcon(new UIEventText("分类项").Icon('\uf009').Click(new UIClick("Model", "News", "Id", did.ToString()).Send(request.Model, request.Command)));


                        footer.AddText(new UIEventText("增加UI组件").Click(new UIClick(did.ToString()).Send("Design", "Item")));
                        footer.AddText(new UIEventText("查看效果").Style(new UIStyle().BgColor(0xef4f4f))
                                       .Click(new UIClick("Model", "News", "Type", "View").Send(request.Model, request.Command)));


                        break;
                    }


                    section.UIFooter = (footer);
                    response.Redirect(section);
                    return(this.DialogValue("none"));
                });
                String type = this.AsyncDialog("Type", g =>
                {
                    UIRadioDialog di = new UIRadioDialog();
                    di.Title         = ("页面设计");
                    di.Options.Put("编辑分类项", "Edit");
                    di.Options.Put("增加分类项", "Append");
                    di.Options.Put("删除此分类", "Delete");
                    return(di);
                });
                switch (type)
                {
                case "Edit":
                    Design(request, designId);
                    break;

                case "Append":
                    Design(request, Guid.NewGuid());    //.randomUUID());
                    break;

                case "Delete":
                    Delete(designId);
                    break;

                case "View":
                    if (request.IsApp)
                    {
                        List <WebMeta> tabs = new List <WebMeta>();

                        Database.Instance().ObjectEntity <Design_Item>()
                        .Where.And().Equal(new Design_Item()
                        {
                            design_id = Guid.Empty, for_id = Guid.Empty
                        })                                                                                               //(Utility.uuidEmpty).For_id(Utility.uuidEmpty))

                        .Entities.Order.Asc(new Design_Item()
                        {
                            Seq = 0
                        })
                        .Entities.Query(dr =>
                        {
                            tabs.Add(new UMC.Web.WebMeta().Put("text", dr.ItemName).Put("search", new UMC.Web.WebMeta().Put("Id", dr.Id.ToString())).Put("cmd", "Home", "model", "Design"));
                        });
                        if (tabs.Count == 1)
                        {
                            UISectionBuilder builder = new UISectionBuilder("Design", "Home", new WebMeta().Put("Id", tabs[0].GetMeta("search").Get("Id")));
                            //                            builder.builder()
                            this.Context.Send(builder.Builder(), true);    //"Tab", new WebMeta().put("sections", tabs).put("text", "UMC界面设计"), true);
                        }
                        else
                        {
                            this.Context.Send("Tab", new WebMeta().Put("sections", tabs).Put("text", "UMC界面设计"), true);
                        }
                    }
                    else
                    {
                        this.AsyncDialog("From", k =>
                        {
                            UIFormDialog fm = new UMC.Web.UIFormDialog();
                            fm.Title        = ("移动效果体验");
                            fm.AddImage(new Uri(UMC.Data.Utility.QRUrl("https://oss.365lu.cn/Click/Deisgn/Home/")));


                            fm.AddPrompt("请用支持UMC协议的APP“扫一扫”。");

                            return(fm);
                        });
                        break;
                    }
                    break;
                }
            }
            else
            {
                if (designId == Guid.Empty)
                {
                    var entity = Database.Instance().ObjectEntity <Design_Item>();
                    entity.Where.And().Equal(new Design_Item {
                        design_id = Guid.Empty, for_id = Guid.Empty
                    });
                    entity.Order.Asc(new Design_Item {
                        Seq = 0
                    });

                    List <WebMeta> tabs = new List <WebMeta>();
                    entity.Query(dr =>
                    {
                        tabs.Add(new UMC.Web.WebMeta().Put("text", dr.ItemName).Put("search", new UMC.Web.WebMeta().Put("Id", dr.Id)).Put("cmd", "UI", "model", "Design"));
                    });

                    var     chash = new Hashtable();
                    UITitle title = new UITitle("UMC移动界面");
                    title.Left('\uea0e', UIClick.Search());

                    title.Right(new UIEventText().Icon('\uf2c0').Click(new UIClick().Send("Account", "Info")));


                    chash.Add("sections", tabs);
                    chash.Add("title", title);
                    response.Redirect(chash);
                }
                else
                {
                    UIDesigner designer = new UIDesigner(false);
                    response.Redirect(designer.Section("", designId));
                }
            }
        }
コード例 #3
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var strId = this.AsyncDialog("Id", g =>
            {
                return(new Web.UITextDialog()
                {
                    Title = "主题"
                });
            });
            var form = request.SendValues ?? new UMC.Web.WebMeta();

            if (form.ContainsKey("limit") == false)
            {
                this.Context.Send(new UISectionBuilder(request.Model, request.Command, new UMC.Web.WebMeta().Put("Id", strId))

                                  .Builder(), true);
            }
            var sid1      = UMC.Data.Utility.Guid(strId);
            var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>();

            if (sid1.HasValue)
            {
                subEntity.Where.And().Equal(new Data.Entities.Subject {
                    Id = sid1
                });
            }
            if (strId.IndexOf("/") > 0)
            {
                var paths = new List <String>();
                paths.AddRange(strId.Split('/'));
                if (paths.Count == 3)
                {
                    var project = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Project
                    {
                        Code = paths[0]
                    }).Entities.Single();
                    if (project != null)
                    {
                        var projectItem = Utility.CMS.ObjectEntity <ProjectItem>().Where.And().Equal(new ProjectItem
                        {
                            project_id = project.Id,
                            Code       = paths[1]
                        }).Entities.Single();
                        if (projectItem != null)
                        {
                            sid1 = Guid.Empty;
                            subEntity.Where.And().Equal(new Subject
                            {
                                project_id      = project.Id,
                                project_item_id = projectItem.Id,
                                Code            = paths[2]
                            });
                        }
                    }
                }
            }


            int limit = UMC.Data.Utility.IntParse(form["limit"] as string, 25);
            int start = UMC.Data.Utility.IntParse(form["start"] as string, 0);


            var webr    = UMC.Data.WebResource.Instance();
            var user    = UMC.Security.Identity.Current;
            var nextKey = this.AsyncDialog("NextKey", g => this.DialogValue("Subject"));


            var selectIndex = UMC.Data.Utility.IntParse(this.AsyncDialog("selectIndex", g => this.DialogValue("0")), 0);

            UITabFixed tabFixed = new UITabFixed();

            tabFixed.Add("评论", "Comments", "Comments");
            tabFixed.Add("点赞", "Proposal", "Comments");
            tabFixed.Add("已读", "Access", "Comments");
            tabFixed.SelectIndex = selectIndex;



            Subject sub = sid1.HasValue ? subEntity.Single() : null;

            var ui  = UISection.Create();
            var rui = ui;

            if (nextKey == "Subject")
            {
                ui.Key = nextKey;
                if (sub == null || sub.Visible == -1)
                {
                    var title = new UITitle("图文正文");
                    ui.Title = title;
                    if (strId.IndexOf("/") > 0)
                    {
                        ui.Add("Desc", new UMC.Web.WebMeta().Put("desc", "此图文已删除").Put("icon", "\uea0d")
                               , 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)));
                    }
                    else
                    {
                        ui.Add("Desc", new UMC.Web.WebMeta().Put("desc", String.Format("未有{0}路径文档", strId)).Put("icon", "\uea0d")
                               , 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.IsNext = false;
                }
                else
                {
                    //
                    ui.IsNext = true;
                    var title = new UITitle("图文正文");
                    ui.Title = title;
                    title.Name("title", sub.Title);
                    title.Name("Id", sub.Id.ToString());
                    title.Float();
                    if (sub.Status > 0)
                    {
                        if ((sub.PublishTime ?? 0) + 3600 < Utility.TimeSpan())// DateTime.Now)
                        {
                            title.Name("releaseId", sub.Id.ToString());
                        }
                    }
                    var         isEditer    = false;
                    Project     project     = null;
                    ProjectItem projectItem = null;
                    if (sub.project_id.HasValue && sub.project_item_id.HasValue)
                    {
                        project = Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>().Where.And().Equal(new Data.Entities.Project {
                            Id = sub.project_id
                        })
                                  .Entities.Single();



                        projectItem = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectItem>().Where.And().Equal(new Data.Entities.ProjectItem {
                            Id = sub.project_item_id
                        })
                                      .Entities.Single();
                    }

                    UIItem item = null;
                    if (project != null && projectItem != null)
                    {
                        if (String.IsNullOrEmpty(sub.Code) == false)
                        {
                            title.Name("Path", String.Format("{0}/{1}/{2}", project.Code, projectItem.Code, sub.Code));

                            if (request.IsApp)
                            {
                                title.Right('\uf141', UIClick.Click(new UIClick("Id", sub.Id.ToString())
                                {
                                    Command = "TipOff", Model = request.Model
                                }));
                            }

                            var proider = UMC.Data.Reflection.GetDataProvider("cmsui", String.Format("{0}.{1}.{2}", project.Code, projectItem.Code, sub.Code));
                            if (proider == null)
                            {
                                proider = UMC.Data.Reflection.GetDataProvider("cmsui", String.Format("{0}.{1}", project.Code, projectItem.Code, sub.Code));
                            }
                            if (proider != null)
                            {
                                item = UMC.Data.Reflection.CreateObject(proider) as UIItem;
                            }
                        }

                        if (project.user_id == user.Id)
                        {
                            isEditer = true;
                        }
                        else
                        {
                            var member = Utility.CMS.ObjectEntity <ProjectMember>()
                                         .Where.And().Equal(new ProjectMember
                            {
                                project_id = project.Id,
                                user_id    = user.Id
                            }).Entities.Single();
                            if (member != null)
                            {
                                switch (member.AuthType)
                                {
                                case WebAuthType.Admin:
                                case WebAuthType.User:
                                    isEditer = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (item != null && item.Header(ui, sub) == false)
                    {
                        ui.Add("Desc", new UMC.Web.WebMeta().Put("desc", "此图文已删除").Put("icon", "\ue953"), 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.IsNext = false;
                    }
                    else
                    {
                        var desc = new UIDesc(new WebMeta().Put("desc", sub.Title).Put("state", "未发布"));
                        desc.Style.Bold().Size(18).Name("border", "none");
                        if (sub.Status < 0)
                        {
                            desc.Desc("{desc} [{1:state:1}]");
                            desc.Style.Name("state").Color(0x999).Size(13);
                        }
                        //if (request.IsApp)
                        //{
                        desc.Style.Padding(55, 10, 10, 10);
                        //}
                        //else
                        //{
                        //    desc.Style.Padding(10);

                        //}
                        ui.Add(desc);
                    }
                    if (isEditer == false && sub.Status < 1)
                    {
                        ui.Add("Desc", new UMC.Web.WebMeta().Put("desc", "此文档未发布,现还不能查看").Put("icon", "\uF0E6"), 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.IsNext = false;
                    }
                    else
                    {
                        ui.DisableSeparatorLine();
                        Subject(request.Model, ui, sub, project, isEditer);
                        if (sub.Look.HasValue)
                        {
                            subEntity.Update("{0}+{1}", new Data.Entities.Subject {
                                Look = 1
                            });
                        }
                        else
                        {
                            subEntity.Update(new Data.Entities.Subject {
                                Look = 1
                            });
                        }
                        if (item != null && ui.IsNext == true)
                        {
                            item.Footer(ui, sub);
                        }
                        if (ui.IsNext == true)
                        {
                            ui.IsNext = String.Equals(request.Model, "Subject");
                        }
                    }
                }

                if (ui.IsNext == false)
                {
                    response.Redirect(ui);
                }
                if (sub.IsComment == false)
                {
                    ui.IsNext = false;
                }

                ui.Add(SubjectBestActivity.BSSArea(sub, request.Model, request.IsApp));

                ui.StartIndex = 0;
                ui            = ui.NewSection();
                start         = 0;
            }
            var Keyword = (form["Keyword"] as string ?? String.Empty);

            if (String.IsNullOrEmpty(Keyword) && selectIndex > -1)
            {
                Keyword = tabFixed.SelectValue["search"];
            }
            tabFixed.Style.Name("border", "bottom");
            ui.Add(tabFixed);
            ui.Key = "Comments";
            switch (Keyword)
            {
            case "Comments":
            {
                var entity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Comment>();
                entity.Where.And().Equal(new Data.Entities.Comment {
                        ref_id = sub.Id.Value, for_id = Guid.Empty
                    });

                entity.Order.Desc(new Data.Entities.Comment {
                        CommentDate = DateTime.Now
                    });
                entity.Where.And().Greater(new Comment {
                        Visible = -1
                    });
                var count = entity.Count();
                var hash  = Utility.Comments(entity, start, limit, request.Model);
                if (count == 0)
                {
                    rui.IsNext = false;
                    ui.Add("Desc", new UMC.Web.WebMeta().Put("desc", "暂无评论").Put("icon", "\uF0E6"), 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)));
                }
                else
                {
                    ui.AddCells(hash.ToArray());
                    rui.IsNext = ui.Total > limit + start;
                }
            }
            break;

            case "Access":
            {
                var style     = new UIStyle().AlignLeft().Name("border", "none");
                int mlimit    = limit * 4;
                int mstart    = start * 4;
                var ids       = new List <Guid>();
                var accEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectAccess>();
                accEntity.Where.And().Equal(new ProjectAccess {
                        sub_id = sub.Id
                    });
                accEntity.Order.Desc(new ProjectAccess {
                        LastAccessTime = DateTime.Now
                    });
                accEntity.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));

                    var icons = new List <UIEventText>();
                    foreach (var id in ids)
                    {
                        var v = users.Find(u => u.Id == id) ?? new User()
                        {
                            Id = id, Alias = "未知"
                        };
                        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)
                        {
                            ui.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);
                        ui.Add(ls);        // new Web.UI.UIIcon().Add(icons.ToArray()));
                                           //ui2.AddIcon(style, icons.ToArray());
                    }
                }
                var m     = accEntity.Count();
                int total = m / 4;
                if (m % 4 > 0)
                {
                    total++;
                }
                ui.IsNext = (mstart + mlimit) < total;
                if (m == 0)
                {
                    ui.Add("Desc", new UMC.Web.WebMeta().Put("desc", "暂无访问").Put("icon", "\uF0E6"), 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 "Proposal":
            {
                var style     = new UIStyle().AlignLeft().Name("border", "none");
                int mlimit    = limit * 4;
                int mstart    = start * 4;
                var ids       = new List <Guid>();
                var accEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Proposal>();
                accEntity.Where.And().Equal(new Proposal {
                        ref_id = sub.Id
                    });
                accEntity.Order.Desc(new Proposal {
                        CreationDate = DateTime.Now
                    });

                accEntity.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));

                    var icons = new List <UIEventText>();
                    foreach (var id in ids)
                    {
                        var v = users.Find(u => u.Id == id) ?? new User()
                        {
                            Id = id, Alias = "未知"
                        };
                        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)
                        {
                            ui.Add(new Web.UI.UIIcon().Add(icons.ToArray()));
                            //ui.AddIcon(style, icons.ToArray());
                            icons.Clear();
                        }
                    }
                    if (icons.Count > 0)
                    {
                        var ls = new Web.UI.UIIcon().Add(icons.ToArray());
                        ls.Style.Copy(style);
                        ui.Add(ls);        // new Web.UI.UIIcon().Add(icons.ToArray()));
                                           //ui2.AddIcon(style, icons.ToArray());
                    }
                }
                var m     = accEntity.Count();
                int total = m / 4;
                if (m % 4 > 0)
                {
                    total++;
                }
                ui.IsNext = (mstart + mlimit) < total;
                if (m == 0)
                {
                    ui.Add("Desc", new UMC.Web.WebMeta().Put("desc", "暂无点赞").Put("icon", "\uf087"), 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;
            }
            response.Redirect(rui);
        }
コード例 #4
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var Url = this.AsyncDialog("Id", g =>
            {
                if (request.IsApp == false)
                {
                    return(this.DialogValue("News"));
                }
                var optls   = new Web.UISheetDialog();
                optls.Title = "新建图文";;
                optls.Options.Add(new UIClick("News")
                {
                    Command = request.Command, Model = request.Model, Text = "新建富文本图文"
                });
                optls.Options.Add(new UIClick("Markdown")
                {
                    Command = request.Command, Model = request.Model, Text = "新建Markdown文档"
                });
                optls.Options.Add(new UIClick()
                {
                    Key = "CaseCMS", Text = "抓取粘贴板网址图文"
                });

                return(optls);
            });
            var user = UMC.Security.Identity.Current;

            if (user.IsAuthenticated == false)
            {
                this.Prompt("请先登录", false);
                response.Redirect("Account", "Login");
            }

            var sId = UMC.Data.Utility.Guid(Url);

            if (sId.HasValue == false)
            {
                var sType = "text/html";
                switch (Url)
                {
                case "Project":
                    response.Redirect(request.Model, "ProjectUI", "News", true);
                    break;

                case "Markdown":
                    sType = "markdown";
                    if (request.IsApp)
                    {
                        this.Context.Send("Markdown", new WebMeta().Put("Id", "News"), true);
                    }
                    break;
                }
                if (request.IsApp == false)
                {
                    var sub2 = new Subject()
                    {
                        Visible      = 1,
                        CreationTime = DateTime.Now,
                        Title        = DateTime.Now.ToShortDateString(),
                        IsPicture    = false,
                        IsDraught    = true,
                        Id           = Guid.NewGuid(),
                        ContentType  = sType,
                        LastDate     = DateTime.Now,
                        Poster       = user.Alias,
                        Seq          = Utility.TimeSpan(),
                        last_user_id = user.Id,
                        user_id      = user.Id,
                        Status       = -1
                    };
                    SubjectSaveActivity.Dashboard(user, sub2);
                    Utility.CMS.ObjectEntity <Subject>().Insert(sub2);
                    this.Context.Send("Markdown", new WebMeta().Put("Id", Utility.Guid(sub2.Id.Value)), true);
                }
            }


            var sub = sId.HasValue ? (Utility.CMS.ObjectEntity <Subject>()
                                      .Where.And().Equal(new Subject
            {
                Id = sId
            }).Entities.Single() ?? new Subject {
                Id = sId
            }) : new Subject {
                Id = sId
            };;

            if (String.IsNullOrEmpty(request.SendValue) == false)
            {
                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)
                    {
                        if (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:
                                    this.Prompt("您未有编辑此图文的权限");
                                    break;
                                }
                            }
                            else
                            {
                                this.Prompt("您未有编辑此图文的权限");
                            }
                        }
                    }
                }
                if (String.Equals("markdown", sub.ContentType, StringComparison.CurrentCultureIgnoreCase))
                {
                    this.Context.Send("Markdown", new WebMeta().Put("Id", sId), true);
                }
                else
                {
                    if (request.IsApp)
                    {
                        this.Context.Send(new UISectionBuilder(request.Model, request.Command, new UMC.Web.WebMeta().Put("Id", sId.HasValue ? sId : Guid.NewGuid()))
                                          .CloseEvent("Subject.Save")
                                          .Builder().Put("IsEditer", true), true);
                    }
                    else
                    {
                        this.Context.Send("Markdown", new WebMeta().Put("Id", Utility.Guid(sId.Value)), true);
                    }
                }
            }

            var Next  = this.AsyncDialog("Next", "none");
            var ui    = UISection.Create();
            var title = new UITitle("图文编辑器");

            ui.Title = title;
            title.Right(new UIEventText().Icon('\uf0c7').Click(UIClick.Click(new UIClick("Id", sub.Id.ToString(), "Next", Next)
            {
                Command = "Save",
                Model   = request.Model
            })));


            var celss = UMC.Data.JSON.Deserialize <WebMeta[]>((String.IsNullOrEmpty(sub.DataJSON) ? "[]" : sub.DataJSON)) ?? new UMC.Web.WebMeta[] { };

            foreach (var pom in celss)
            {
                switch (pom["_CellName"])
                {
                case "CMSImage":
                    pom.Put("style", new UIStyle().Padding(0, 10));
                    break;
                }
            }

            if (celss.Length == 0)
            {
                var ed = ui.NewSection();
                ed.DisableSeparatorLine();
                ed.IsEditer = true;
                ed.AddCells(new UMC.Web.WebMeta().Put("_CellName", "CMSText").Put("value", new UMC.Web.WebMeta().Put("text", "新建文档")));
            }
            else
            {
                var ed = ui.NewSection();
                ed.IsEditer = true;
                ed.AddCells(celss);
                ed.DisableSeparatorLine();
            }
            var style  = new UIStyle();
            var footer = new UIHeader();

            ui.UIFooter = footer;//
            footer.Desc(new UMC.Web.WebMeta("icon", "\uf004", "desc", "天天录,录入您知识财富"), "{icon}\n{desc}", style);

            style.Height(350).Color(0xf0f0f0).AlignCenter().BgColor(0xf8f8f8).Name("border", "none");//.BorderColor
            style.Name("icon").Font("wdk").Size(40);


            response.Redirect(ui);
        }