Ejemplo n.º 1
0
        void Sliders(Design_Item parent, List <Design_Item> baners, UISection U)
        {
            if (baners.Count > 0)
            {
                WebMeta config = UMC.Data.JSON.Deserialize <WebMeta>(parent.Data) ?? new UMC.Web.WebMeta();


                UICell slider2  = UISlider.Create(Sliders(parent.Id.Value, baners));
                int[]  paddings = UIStyle.Padding(config);
                if (paddings.Length > 0)
                {
                    slider2.Style.Padding(paddings);
                }
                U.Add(slider2);
            }
            else if (_editer)
            {
                UIDesc desc = new UIDesc("\ue907");
                desc.Click(new UIClick(parent.Id.ToString())
                           .Send("Design", "Item"));
                desc.Desc("{desc}\r\n配置横幅栏");
                desc.Style.AlignCenter().Name("desc", new UIStyle().Font("wdk").Size(38));
                U.Add(desc);
            }
        }
Ejemplo n.º 2
0
        void Items(Design_Item parent, List <Design_Item> baners, UISection U)
        {
            Guid parentId = parent.Id.Value;
            //List<UIItem> list = new List<UIItem>();
            var item = new UIItems();

            UMC.Data.WebResource webr = UMC.Data.WebResource.Instance();
            for (int i = 0; i < baners.Count && i < 4; i++)
            {
                Design_Item b    = baners[i];
                WebMeta     icon = UMC.Data.JSON.Deserialize <WebMeta>(b.Data) ?? new UMC.Web.WebMeta();
                item.Add(icon);
                icon.Put("click", this.Click(b));
                String t = "100";
                switch (baners.Count)
                {
                case 1:
                    t = "4-1";
                    break;

                case 2:
                    t = "2-1";
                    break;

                case 3:
                    if (i == 0)
                    {
                        t = "2-1";
                    }
                    break;
                }

                icon.Put("src", String.Format("{0}!{1}?{2}", webr.ImageResolve(b.Id.Value, "1", 0), t, TimeSpan(b.ModifiedDate)));
                //list.Add(slider);
            }
            if (item.Count > 0)
            {
                U.Add(item);
            }
            else if (_editer)
            {
                ;
                UIDesc desc = new UIDesc("\ue907");
                desc.Desc("{desc}\r\n配置分块栏");

                desc.Style.AlignCenter().Name("desc", new UIStyle().Font("wdk").Size(38).Click(new UIClick(parentId.ToString())
                                                                                               .Send("Design", "Item")));
                U.Add(desc);
            }
        }
Ejemplo n.º 3
0
        //
        void Sliders(Design_Item parent, List <Design_Item> baners, UISection U)
        {
            if (baners.Count > 0)
            {
                WebMeta config = UMC.Data.JSON.Deserialize <WebMeta>(parent.Data) ?? new UMC.Web.WebMeta();


                var type    = config["type"];
                var sType   = "slider";
                var slider2 = new UISlider(config.ContainsKey("auto"));
                switch (type)
                {
                case "Small":
                    slider2.Small();
                    sType = "4-1";
                    break;

                case "Square":
                    slider2.Square();
                    sType = "350";
                    break;

                default:
                    type = "slider";
                    break;
                }

                Sliders(slider2, parent.Id.Value, sType, baners);


                int[] paddings = UIStyle.Padding(config);
                if (paddings.Length > 0)
                {
                    slider2.Style.Padding(paddings);
                }
                U.Add(slider2);
            }
            else if (_editer)
            {
                UIDesc desc = new UIDesc("\ue907");
                desc.Click(new UIClick(parent.Id.ToString())
                           .Send("Design", "Item"));
                desc.Desc("{desc}\r\n配置横幅栏");
                desc.Style.AlignCenter().Name("desc", new UIStyle().Font("wdk").Size(38));
                U.Add(desc);
            }
        }
Ejemplo n.º 4
0
        void Icons(Guid parentId, List <Design_Item> baners, UISection U)
        {
            List <UIEventText> list = new List <UIEventText>();

            UMC.Data.WebResource webr = UMC.Data.WebResource.Instance();
            foreach (Design_Item b in baners)
            {
                UIEventText slider = new UIEventText(b.ItemName);
                if (String.IsNullOrEmpty(b.Data) == false)
                {
                    WebMeta s = UMC.Data.JSON.Deserialize <WebMeta>(b.Data);

                    slider.Icon(s.Get("icon"), s.Get("color"));
                }
                else
                {
                    slider.Src(webr.ImageResolve(b.Id.Value, "1", 4) + "?" + TimeSpan(b.ModifiedDate));
                }
                slider.Click(this.Click(b));

                list.Add(slider);
            }
            if (list.Count > 0)
            {
                var ic = new UMC.Web.UI.UIIcon();
                ic.Style.Name("icon", new UIStyle().Font("wdk").Size(24));

                ic.Add(list.ToArray());
                //U.AddIcon(new UIStyle().Name("icon", new UIStyle().Font("wdk").Size(24)), list.ToArray());
            }
            else if (_editer)
            {
                UIDesc desc = new UIDesc("\ue907");
                desc.Desc("{desc}\r\n配置图标栏");
                desc.Click(new UIClick(parentId.ToString())
                           .Send("Design", "Item"));

                desc.Style.AlignCenter().Name("desc", new UIStyle().Font("wdk").Size(38));
                U.Add(desc);
            }
        }
Ejemplo n.º 5
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var user = UMC.Security.Identity.Current;

            switch (this.AsyncDialog("Type", "App"))
            {
            case "PC":
                this.Me(request, response);
                return;
            }

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

            if (form.ContainsKey("limit") == false)
            {
                this.Context.Send(new UISectionBuilder(request.Model, request.Command)

                                  .RefreshEvent("Subject.Save", "image", "Subject.Content")
                                  .Builder(), true);
            }


            var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>();

            subEntity.Where.And().Equal(new Subject {
                user_id = user.Id
            });
            subEntity.Where.And().GreaterEqual(new Subject {
                Visible = 0
            });

            var webr = UMC.Data.WebResource.Instance();

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

            string sort = form[("sort")] as string;
            string dir  = form[("dir")] as string;

            var category = form["Project"] as string;
            var model    = request.Model;

            var pics = new List <UMC.Data.Entities.Picture>();

            Guid?CategoryId = UMC.Data.Utility.Guid(category);

            var Keyword = (form["Keyword"] as string ?? String.Empty);

            if (CategoryId.HasValue)
            {
                subEntity.Where.And().Equal(new Data.Entities.Subject {
                    project_id = CategoryId
                });
            }

            if (String.IsNullOrEmpty(Keyword) == false)
            {
                subEntity.Where.And().Like(new Subject {
                    Title = Keyword
                });
            }
            subEntity.Where.And().Greater(new Subject {
                Visible = 0
            });

            if (!String.IsNullOrEmpty(sort))
            {
                if (dir == "DESC")
                {
                    subEntity.Order.Desc(sort);
                }
                else
                {
                    subEntity.Order.Asc(sort);
                }
            }
            else
            {
                subEntity.Order.Desc(new Subject {
                    LastDate = DateTime.Now
                });
            }
            //if (request.IsApp)
            //{

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

            if (start == 0)
            {
                ui.Add(new UMC.Web.UI.UIIcon().Add(new UIEventText("新建Markdown").Icon('\uf198', 0x40c9c6).Click(new Web.UIClick("Markdown").Send("Subject", "Content")).Badge("MD格式")
                                                   , new UIEventText("新建富文本").Icon('\uf13b', 0x1890ff).Click(new Web.UIClick("UIClick").Send("Subject", "Content")).Badge("富文本")
                                                   , new UIEventText("抓取图文").Icon('\uf0c5', 0x36a3f7).Click(new Web.UIClick("UIClick").Send("Subject", "Content"))));
                u2 = ui.NewSection();
                //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" });//.Header.Put("text", "宣传方案");
            }
            if (user.IsAuthenticated == false)
            {
                UIDesc desc = new UIDesc(new UMC.Web.WebMeta().Put("desc", "你尚未登录").Put("icon", "\uF016")).Desc("{icon}\n{desc}").Click(
                    new UIClick().Send("Account", "Login"));

                desc.Style.Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60));
                u2.Add(desc);
                response.Redirect(ui);
            }
            SubjectUIActivity.Search(u2, subEntity, request.Model, "EditUI", start, limit, false);
            if (u2.Total == 0)
            {
                u2.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);
        }
Ejemplo n.º 6
0
        void TitleDesc(Design_Item parent, List <Design_Item> items, UISection U)
        {
            UMC.Data.WebResource webr = UMC.Data.WebResource.Instance();


            //WebMeta config = Utility.isNull(UMC.Data.JSON.deserialize(parent.Data, WebMeta.class), new UMC.Web.WebMeta());
            WebMeta config = UMC.Data.JSON.Deserialize <WebMeta>(parent.Data) ?? new UMC.Web.WebMeta();

            int rows = UMC.Data.Utility.IntParse(config.Get("Total"), 1);

            if (rows <= 1)
            {
                int[] padding = UIStyle.Padding(config);
                foreach (Design_Item i in items)
                {
                    UICell tdesc = this.TitleDesc(config, i, "cms1", webr);
                    if (padding.Length > 0)
                    {
                        tdesc.Style.Padding(padding);
                    }
                    U.Add(tdesc);
                }
            }
            else
            {
                int    m    = 0;
                String hide = config.Get("Hide") ?? "";
                if (hide.Contains("HideTitle"))
                {
                    m |= 1;
                }
                if (hide.Contains("HideDesc"))
                {
                    m |= 2;
                }
                if (hide.Contains("HideLeft"))
                {
                    m |= 4;
                }
                if (hide.Contains("HideRight"))
                {
                    m |= 8;
                }

                int len = items.Count;

                for (int i = 0; (i + rows - 1) < len; i = i + rows)
                {
                    List <WebMeta> ls = new List <WebMeta>();//<>();
                    for (int c = 0; c < rows; c++)
                    {
                        UICell p = TitleDesc(config, items[i + c], "350", webr);
                        ls.Add(new UMC.Web.WebMeta().Put("value", p.Data).Put("format", p.Format).Put("style", p.Style));
                    }
                    UICell desc     = UICell.Create("ItemsTitleDesc", new UMC.Web.WebMeta().Put("items", ls.ToArray()).Put("total", rows).Put("show", m));
                    int[]  paddings = UIStyle.Padding(config);
                    if (paddings.Length > 0)
                    {
                        desc.Style.Padding(paddings);
                    }
                    U.Add(desc);
                }
                int total = len % rows;

                if (total > 0)
                {
                    List <WebMeta> ls = new List <WebMeta>();
                    for (int c = total; c > 0; c--)
                    {
                        UICell p = TitleDesc(config, items[len - c], "350", webr);
                        ls.Add(new UMC.Web.WebMeta().Put("value", p.Data).Put("format", p.Format).Put("style", p.Style));
                    }

                    UICell desc     = UICell.Create("ItemsTitleDesc", new UMC.Web.WebMeta().Put("items", ls.ToArray()).Put("total", rows).Put("show", m));
                    int[]  paddings = UIStyle.Padding(config);
                    if (paddings.Length > 0)
                    {
                        desc.Style.Padding(paddings);
                    }
                    U.Add(desc);
                }
            }
            if (items.Count == 0 && _editer)
            {
                UIDesc desc = new UIDesc("\ue907");
                desc.Desc("{desc}\r\n配置图文栏");

                desc.Style.AlignCenter().Name("desc", new UIStyle().Font("wdk").Size(38).Click(new UIClick(parent.Id.ToString())
                                                                                               .Send("Design", "Item")));
                U.Add(desc);
            }
        }
Ejemplo n.º 7
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var Id = UMC.Data.Utility.Guid(this.AsyncDialog("Id", g =>
            {
                this.Prompt("请输入参数");
                return(this.DialogValue("none"));
            }), true);

            var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>();

            subEntity.Where.And().Equal(new Subject {
                Id = Id
            });

            var sub = subEntity.Single();

            var user = UMC.Security.Identity.Current;

            if (sub.project_id.HasValue)
            {
                var project = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Project
                {
                    Id = sub.project_id
                }).Entities.Single();
                if (project != null && project.user_id == user.Id)
                {
                }
                else
                {
                    var member = Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember
                    {
                        project_id = sub.project_id,
                        user_id    = user.Id
                    }).Entities.Single();
                    if (member != null)
                    {
                        switch (member.AuthType)
                        {
                        case WebAuthType.Admin:
                        case WebAuthType.User:
                            break;

                        default:
                            if (sub.Status > 0)
                            {
                                this.Context.Send(new UISectionBuilder(request.Model, "UIData", new UMC.Web.WebMeta().Put("Id", Id))

                                                  .Builder(), true);
                            }
                            if (sub.user_id == user.Id)
                            {
                                this.Prompt(String.Format("{0}项目收回了您的编辑权限", project.Caption));
                            }
                            else
                            {
                                this.Prompt("您未有编辑此图文的权限");
                            }
                            break;
                        }
                    }
                    else
                    {
                        if (sub.Status > 0)
                        {
                            this.Context.Send(new UISectionBuilder(request.Model, "UIData", new UMC.Web.WebMeta().Put("Id", Id))

                                              .Builder(), true);
                        }
                        if (sub.user_id == user.Id)
                        {
                            this.Prompt(String.Format("{0}项目收回了你的编辑权限", project.Caption));
                        }
                        else
                        {
                            this.Prompt("您未有编辑此图文的权限");
                        }
                    }
                }
            }
            if (String.IsNullOrEmpty(request.SendValue) == false)
            {
                this.Context.Send(new UISectionBuilder(request.Model, request.Command, new UMC.Web.WebMeta().Put("Id", Id))

                                  .RefreshEvent("Subject.Save", "image", "Subject.Content").CloseEvent("Subject.Del")
                                  .Builder(), true);
            }
            // var appKey = UMC.Security.Principal.Current.AppKey ?? Guid.Empty;

            var Model = this.AsyncDialog("Model", gKey =>
            {
                var webr = UMC.Data.WebResource.Instance();



                UITitle uITItle = UITitle.Create();
                uITItle.Title   = "图文发布";
                var sestion     = UISection.Create(uITItle);



                var pictureEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Picture>();

                pictureEntity.Where.And().GreaterEqual(new Data.Entities.Picture {
                    Seq = 0
                });
                pictureEntity.Order.Asc(new Data.Entities.Picture {
                    Seq = 0
                });
                var images = new List <String>();
                var items  = new List <WebMeta>();
                pictureEntity.Where
                .And().In(new Data.Entities.Picture
                {
                    group_id = sub.Id
                })
                .Entities.Query(dr =>
                {
                    var src      = webr.ResolveUrl(dr.group_id.Value, dr.Seq, "0");
                    var chachKey = "?_ts=" + UMC.Data.Utility.TimeSpan(dr.UploadDate.Value);
                    items.Add(new UMC.Web.WebMeta().Put("src", src + "!200" + chachKey).Put("click", new Web.UIClick(new UMC.Web.WebMeta().Put("Id", dr.group_id.Value).Put("Seq", dr.Seq).Put(gKey, "Picture"))
                    {
                        Model   = request.Model,
                        Command = request.Command
                    }));
                    images.Add(src + "?_ts=" + chachKey);
                });
                var uidesc = new UIDesc(sub.Title);
                uidesc.Style.Bold().Height(50);
                uidesc.Click(new UIClick("Id", Id.ToString(), gKey, "Title")
                {
                    Model = request.Model, Command = request.Command
                });

                var nine = new UMC.Web.WebMeta().Put("images", items);

                sestion.Delete(uidesc, new UIEventText().Click(new UIClick("Id", Id.ToString(), gKey, "Del")
                {
                    Model = request.Model, Command = request.Command
                }));
                var sT = sub.Description ?? sub.Title;
                if (sT.Length > 48)
                {
                    sT = sT.Substring(0, 48) + "...";
                }
                var desc = new UIDesc(sT);
                desc.Style.Height(40).Color(0x999).Size(13);//.Name("border", "none");
                desc.Click(new UIClick("Id", Id.ToString(), gKey, "Desc")
                {
                    Model = request.Model, Command = request.Command
                });
                sestion
                .Add(UICell.Create("NineImage", nine)).Add(desc)
                .AddCell("封面方式", sub.IsPicture == true ? "显示大图" : (images.Count > 2 ? "三张图" : "单张图")
                         , new UIClick("Id", Id.ToString(), gKey, "Show")
                {
                    Model = request.Model, Command = request.Command
                });
                if (images.Count < 3)
                {
                    nine.Put("click", new UIClick("Id", Id.ToString(), gKey, "Image")
                    {
                        Model = request.Model, Command = request.Command
                    });
                }
                if (request.IsApp)
                {
                    sestion.NewSection().AddCell('\uf044', "编辑正文", "", new UIClick(Id.ToString())
                    {
                        Command = "Content", Model = request.Model
                    });
                }
                var status = "审阅中";

                if (sub.Status > 0)
                {
                    status = "已发布";
                }
                else if (sub.Status < 0)
                {
                    if (sub.Status == -2)
                    {
                        status = "被驳回";
                    }
                    else
                    {
                        status = "未发布";
                    }
                }
                var cateName = "草稿";
                if (sub.project_item_id.HasValue)
                {
                    //var portfolio = Utility.CMS.ObjectEntity<UMC.Data.Entities.Portfolio>().Where.And().Equal(new Data.Entities.Portfolio
                    //{
                    //    Id = sub.portfolio_id.Value
                    //}).Entities.Single();

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

                    var Project = Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>().Where.And().Equal(new Data.Entities.Project
                    {
                        Id = sub.project_id.Value
                    }).Entities.Single();
                    cateName = String.Format("{0}/{1}", Project.Caption, ProjectItem.Caption);
                }
                var ness = sestion
                           .NewSection().AddCell("发布状态", status);

                ness.AddCell("所属专栏", cateName
                             , new UIClick("Id", sub.Id.ToString(), gKey, "Project")
                {
                    Model = request.Model, Command = request.Command
                });

                ness.AddCell("评论功能", (sub.IsComment ?? true) ? "开启" : "关闭", new UIClick("Id", Id.ToString(), gKey, "Comment")
                {
                    Model = request.Model, Command = request.Command
                })
                .NewSection()
                .AddCell("浏览正文", "", new UIClick(sub.Id.ToString()).Send(request.Model, "View"))
                .AddCell("管理评论", "", new UIClick(Id.ToString())
                {
                    Command = "Comments", Model = request.Model
                });


                if (request.UserAgent.IndexOf("DingTalk") > 0 && sub.project_id.HasValue)
                {
                    if (Utility.CMS.ObjectEntity <ProjectSetting>()
                        .Where.And().Equal(new ProjectSetting
                    {
                        project_id = sub.project_id,
                        Type = 11
                    }).Entities.Count() > 0)
                    {
                        var strt = UMC.Security.AccessToken.Current.Data["DingTalk-Sub-Id"] as string;//, Utility.Guid(projectId)).Commit();

                        var text = "";
                        if (Utility.Guid(sub.Id.Value) == strt)
                        {
                            text = UMC.Security.AccessToken.Current.Data["DingTalk-Session-Text"] as string;
                        }
                        ness.NewSection().AddCell("发送到群", text, new UIClick("Id", Id.ToString(), gKey, "DingTalk")
                        {
                            Model = request.Model, Command = request.Command
                        });
                    }
                }
                else
                {
                    if (Utility.CMS.ObjectEntity <ProjectSetting>()
                        .Where.And().Equal(new ProjectSetting
                    {
                        project_id = sub.project_id,
                        Type = 12
                    }).Entities.Count() > 0)
                    {
                        ness.NewSection().AddCell("发送到群", "", new UIClick("Id", Id.ToString(), gKey, "DingTalk")
                        {
                            Model = request.Model, Command = request.Command
                        });
                    }
                }
                //}

                sestion.UIFootBar = new UIFootBar().AddText(
                    new UIEventText(sub.Status == 1 ? "下架" : "确认发布").Click(new UIClick("Id", Id.ToString(), "Model", "Status", "Status", sub.Status == 1 ? "-1" : "1")
                {
                    Model   = request.Model,
                    Command = request.Command
                }).Style(new UIStyle().BgColor()), new UIEventText("摘正文摘要").Click(new UIClick("Id", Id.ToString(), "Model", "AutoDesc")
                {
                    Model   = request.Model,
                    Command = request.Command
                }));
                sestion.UIFootBar.IsFixed = true;
                response.Redirect(sestion);

                return(this.DialogValue("none"));
            });

            switch (Model)
            {
            case "Picture":
                var seq = this.AsyncDialog("Seq", "1");
                this.AsyncDialog("Picture", g =>
                {
                    var sel = new Web.UISheetDialog();
                    sel.Options.Add(new UIClick(new UMC.Web.WebMeta().Put("id", sub.Id.Value).Put("seq", seq))
                    {
                        Command = "Picture",
                        Text    = "重新上传",
                        Model   = "Design"
                    }); sel.Options.Add(new UIClick(new UMC.Web.WebMeta().Put("id", sub.Id.Value).Put("seq", seq).Put("media_id", "none"))
                    {
                        Command = "Picture",
                        Text    = "删除图片",
                        Model   = "Design"
                    });
                    return(sel);
                });
                break;

            case "DingTalk":
            {
                if (sub.Status == 1)
                {
                    switch (this.AsyncDialog("Type", g =>
                        {
                            var ds = new UISelectDialog();
                            ds.Options.Put("用机器人发送", "Robot");
                            ds.Options.Put("选择到人发送", "Session");
                            return(ds);
                        }))
                    {
                    case "Robot":
                        if (Utility.CMS.ObjectEntity <ProjectSetting>()
                            .Where.And().Equal(new ProjectSetting
                            {
                                project_id = sub.project_id,
                                Type = 12
                            }).Entities.Count() > 0)
                        {
                            this.Send(request, sub, String.Empty, true);
                            this.Prompt("机器人发送已经发起");
                        }
                        else
                        {
                            this.Prompt("此项目未配置钉钉机器人");
                        }
                        break;
                    }
                }
                var DingTalk = Web.UIDialog.AsyncDialog("TalkId", g =>
                    {
                        if (request.UserAgent.IndexOf("DingTalk") == -1)
                        {
                            this.Prompt("非钉钉环境,不能获取到钉钉会话参数");
                        }
                        var ticket = SubjectDingtalkActivity.JsAccessToken(sub.project_id.Value);
                        if (ticket == null)
                        {
                            this.Prompt("未有钉钉配置");
                        }
                        if (String.IsNullOrEmpty(ticket.AgentId))
                        {
                            this.Prompt("未有钉钉应用ID");
                        }
                        var nonceStr  = Utility.TimeSpan();
                        var timeStamp = Utility.TimeSpan();
                        var url       = (request.UrlReferrer ?? request.Url).AbsoluteUri;

                        String plain = "jsapi_ticket=" + ticket.APITicket + "&noncestr=" + nonceStr + "&timestamp=" + timeStamp
                                       + "&url=" + url;
                        var config = new WebMeta();
                        config.Put("agentId", ticket.AgentId);
                        config.Put("corpId", ticket.CorpId);
                        config.Put("timeStamp", timeStamp.ToString());
                        config.Put("nonceStr", nonceStr.ToString());
                        config.Put("url", url);
                        config.Put("signature", Utility.SHA1(plain).ToLower());
                        config.Put("jsApiList", new string[] { "biz.map.view", "biz.chat.pickConversation" });


                        this.Context.Send("Subject.DingTalk", new WebMeta().Put("method", "pickConversation").Put("Sign", config).Put("Params", new WebMeta(request.Arguments).Put("_model", request.Model, "_cmd", request.Command)).Put("Key", g), true);
                        return(this.DialogValue("none"));
                    });
                if (sub.Status == 1)
                {
                    this.Send(request, sub, DingTalk, false);
                    this.Prompt("会话发送已经发起");
                }
                else
                {
                    UMC.Security.AccessToken.Current.Put("DingTalk-Sub-Id", Utility.Guid(sub.Id.Value)).Put("DingTalk-Session-Text", this.AsyncDialog("TalkId-Text", "Text")).Put("DingTalk-Session-Id", DingTalk).Commit();
                }
            }
            break;

            case "Image":
                Web.UIDialog.AsyncDialog("Image", g =>
                {
                    var dl = new Web.UISheetDialog()
                    {
                        Title = "图片上传"
                    };
                    dl.Options.Add(new Web.UIClick(sub.Id.ToString())
                    {
                        Model = request.Model, Command = "Image", Text = "正文图片"
                    });
                    dl.Options.Add(new Web.UIClick(sub.Id.ToString())
                    {
                        Model = "Design", Command = "Picture", Text = "本地图片"
                    });
                    return(dl);
                });
                break;

            case "Title":
                var title = Web.UIDialog.AsyncDialog("Title", g =>
                {
                    var dl = new Web.UIFormDialog()
                    {
                        Title = "图文标题"
                    };
                    dl.AddTextarea("快文标题", "Title", sub.Title);
                    dl.Submit("确认更改", request, "Subject.Save");
                    return(dl);
                });
                subEntity.Update(new Subject
                {
                    Title = title
                });
                break;

            case "Desc":
                var desc = Web.UIDialog.AsyncDialog("Description", g =>
                {
                    var dl = new Web.UIFormDialog()
                    {
                        Title = "图文摘要"
                    };
                    dl.AddTextarea("图文摘要", "Description", sub.Description ?? sub.Title).Put("Rows", 10);
                    dl.Submit("确认更改", request, "Subject.Save");
                    return(dl);
                });
                subEntity.Update(new Subject
                {
                    Description = desc
                });
                break;

            case "Score":
                var Score = Utility.IntParse(Web.UIDialog.AsyncDialog("Score", g =>
                {
                    var dl = new Web.UIFormDialog()
                    {
                        Title = "图文积分"
                    };
                    dl.AddNumber("图文积分", "Score", sub.Score);
                    dl.Submit("确认更改", request, "Subject.Save");
                    return(dl);
                }), 0);
                if (Score < 0)
                {
                    this.Prompt("积分必须大于或等于零");
                }
                subEntity.Update(new Subject
                {
                    Score = Score
                });
                break;

            case "Project":
            {
                var meta = new WebMeta();
                if (sub.project_id.HasValue)
                {
                    var project = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Project
                        {
                            Id = sub.project_id.Value
                        }).Entities.Single();
                    if (project != null)
                    {
                        if (project.Id == user.Id)
                        {
                        }
                        else
                        {
                            meta.Put("Project", sub.project_id);
                            var member = Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember
                                {
                                    project_id = sub.project_id,
                                    user_id    = user.Id
                                }).Entities.Single();
                            if (member != null)
                            {
                                switch (member.AuthType)
                                {
                                case WebAuthType.Admin:
                                case WebAuthType.User:
                                    break;

                                default:
                                    this.Prompt("您未有编辑此图文的权限");
                                    break;
                                }
                            }
                            else
                            {
                                this.Prompt("您未有编辑此图文的权限");
                            }
                        }
                    }
                }
                var sid = UMC.Data.Utility.Guid(this.AsyncDialog("PortfolioId", request.Model, "Portfolio", meta)).Value;

                var portfolio = Utility.CMS.ObjectEntity <UMC.Data.Entities.Portfolio>()
                                .Where.And().Equal(new Portfolio {
                        Id = sid
                    }).Entities.Single();
                var projectItem = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectItem>()
                                  .Where.And().Equal(new ProjectItem {
                        Id = portfolio.project_item_id
                    }).Entities.Single();
                if (request.IsCashier == false)
                {
                    var project = Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>()
                                  .Where.And().Equal(new Project {
                            Id = portfolio.project_id
                        }).Entities.Single();
                    if (project.user_id.Value != user.Id)
                    {
                        var member = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>()
                                     .Where.And().Equal(new ProjectMember {
                                project_id = project.Id
                            }).Entities.Single();
                        if (member == null)
                        {
                            this.Prompt("你尚未加入此项目的专栏");
                        }
                        else
                        {
                            switch (member.AuthType)
                            {
                            case WebAuthType.Admin:
                            case WebAuthType.User:
                                break;

                            default:
                                this.Prompt("你尚未加入此项目的专栏");
                                break;
                            }
                        }
                    }
                }
                if (String.IsNullOrEmpty(sub.Code))
                {
                    subEntity.Update(new Subject()
                        {
                            Code            = Utility.Parse36Encode(sub.Id.Value.GetHashCode()),
                            portfolio_id    = portfolio.Id,
                            project_id      = projectItem.project_id,
                            project_item_id = projectItem.Id,
                            last_user_id    = user.Id
                        });
                }
                else
                {
                    subEntity.Update(new Subject()
                        {
                            portfolio_id    = portfolio.Id,
                            project_id      = projectItem.project_id,
                            project_item_id = projectItem.Id,
                            last_user_id    = user.Id
                        });
                }
            }
            break;

            case "Comment":
                var s2 = UMC.Data.Utility.IntParse(this.AsyncDialog("Comment", g =>
                {
                    var dl = new Web.UISelectDialog()
                    {
                        Title = "评论功能"
                    };
                    dl.Options.Add("开启评论", "1");
                    dl.Options.Add("关闭评论", "-1");
                    return(dl);
                }), 0);
                subEntity.Update(new Subject
                {
                    IsComment = s2 == 1
                });
                break;

            case "Status":
                var s = UMC.Data.Utility.IntParse(this.AsyncDialog("Status", g =>
                {
                    var dl = new Web.UISelectDialog()
                    {
                        Title = "发布确认"
                    };
                    dl.Options.Add("不发布", "-1");
                    dl.Options.Add("发布", "1");
                    return(dl);
                }), 0);
                if (sub.project_id.HasValue == false || sub.project_item_id.HasValue == false || sub.portfolio_id.HasValue == false)
                {
                    this.Prompt("请选择发布的栏位");
                }
                if ((sub.soure_id ?? Guid.Empty) != Guid.Empty)
                {
                    this.Prompt("提示", "非原创,公共栏目不接收,只限于公众号群发。");
                }
                if (s == 0)
                {
                    if (String.IsNullOrEmpty(sub.Url) == false && sub.Status == -1)
                    {
                        s = 1;
                    }
                }
                if (s == -1 && sub.Status == -2)
                {
                    this.Prompt("被驳回状态,不需要此操作");
                }

                String Sdesc = null;
                if (s > 0)
                {
                    //if (String.IsNullOrEmpty(sub.Code))
                    if (String.IsNullOrEmpty(sub.Description))
                    {
                        //   sub.DataJSON
                        var celss = UMC.Data.JSON.Deserialize <WebMeta[]>((String.IsNullOrEmpty(sub.DataJSON) ? "[]" : sub.DataJSON)) ?? new UMC.Web.WebMeta[] { };
                        var sb    = new StringBuilder();
                        foreach (var pom in celss)
                        {
                            switch (pom["_CellName"])
                            {
                            case "CMSText":
                                var value  = pom.GetMeta("value");
                                var format = pom.GetMeta("format")["text"];
                                var fValue = Utility.Format(format, value.GetDictionary(), String.Empty);
                                if (String.Equals(fValue, sub.Title) == false)
                                {
                                    sb.Append(fValue);
                                }
                                if (sb.Length > 250)
                                {
                                    break;
                                }

                                break;
                            }
                        }
                        Sdesc           = sb.Length > 250 ? sb.ToString(0, 250) : sb.ToString();
                        sub.Description = Sdesc;
                    }

                    var IsDraught = Utility.CMS.ObjectEntity <UMC.Data.Entities.Picture>().Where
                                    .And().In(new Data.Entities.Picture
                    {
                        group_id = sub.Id
                    }).Entities.Count() == 0;
                    subEntity.Update(new Subject
                    {
                        Status      = s,
                        Description = Sdesc,
                        IsDraught   = IsDraught,
                        Code        = String.IsNullOrEmpty(sub.Code) ? Utility.Guid(sub.Id.Value) : null,
                        Poster      = user.Alias,

                        ReleaseDate = DateTime.Now
                    });
                    var cid  = String.Empty;                                                       //
                    var strt = UMC.Security.AccessToken.Current.Data["DingTalk-Sub-Id"] as string; //, Utility.Guid(projectId)).Commit();

                    if (Utility.Guid(sub.Id.Value) == strt)
                    {
                        cid = UMC.Security.AccessToken.Current.Data["DingTalk-Session-Id"] as string;
                    }
                    Send(request, sub, cid, true);
                    if (String.IsNullOrEmpty(strt) == false)
                    {
                        UMC.Security.AccessToken.Current.Put("DingTalk-Sub-Id", String.Empty).Commit();
                    }

                    this.Prompt("发布成功", false);
                }
                else
                {
                    subEntity.Update(new Subject
                    {
                        Status = s,
                        Code   = String.IsNullOrEmpty(sub.Code) ? Utility.Guid(sub.Id.Value) : null,
                    });
                }
                break;

            case "AutoDesc":
            {
                //   sub.DataJSON
                var celss = UMC.Data.JSON.Deserialize <WebMeta[]>((String.IsNullOrEmpty(sub.DataJSON) ? "[]" : sub.DataJSON)) ?? new UMC.Web.WebMeta[] { };
                var sb    = new StringBuilder();
                foreach (var pom in celss)
                {
                    switch (pom["_CellName"])
                    {
                    case "CMSText":
                        var value  = pom.GetMeta("value");
                        var format = pom.GetMeta("format")["text"];

                        var fValue = Utility.Format(format, value.GetDictionary(), String.Empty);
                        if (String.Equals(fValue, sub.Title) == false)
                        {
                            sb.Append(fValue);
                        }
                        if (sb.Length > 250)
                        {
                            break;
                        }

                        break;
                    }
                }
                var Sdesc2 = sb.Length > 250 ? sb.ToString(0, 250) : sb.ToString();

                subEntity.Update(new Subject
                    {
                        Description = Sdesc2
                    });
            }
            break;

            case "Show":
                var m = this.AsyncDialog("Show", g =>
                {
                    var dl = new Web.UISelectDialog()
                    {
                        Title = "封面展示方式"
                    };
                    dl.Options.Put("封面大图形式", "Max").Put("封面小图形式", "Min");
                    return(dl);
                });
                subEntity.Update(new Subject {
                    IsPicture = String.Equals(m, "Max")
                });
                break;

            case "Del":
                subEntity.Update(new Subject {
                    Visible = -1, LastDate = DateTime.Now
                });
                //subEntity.Delete();

                this.Context.Send("Subject.Del", new WebMeta().Put("Id", sub.Id), false);
                break;
            }

            this.Context.Send("Subject.Save", true);
        }
Ejemplo n.º 8
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 ui        = UISection.Create();
            var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>();

            var sid = UMC.Data.Utility.Guid(strId);

            if (sid.HasValue)
            {
                subEntity.Where.And().Equal(new UMC.Data.Entities.Subject {
                    Id = sid
                });
            }
            else
            {
                var codes = new List <String>(strId.Split('/'));
                switch (codes.Count)
                {
                case 1:
                    codes.Insert(0, "Help");
                    codes.Insert(0, "UMC");
                    break;

                case 2:
                    codes.Insert(0, "UMC");
                    break;

                case 3:
                    break;

                default:
                    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)));

                    response.Redirect(ui);
                    break;
                }

                var team = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project {
                    Code = codes[0]
                }).Entities.Single();
                if (team == null)
                {
                    ui.Add("Desc", new UMC.Web.WebMeta().Put("desc", String.Format("不存在“{0}”此项目", codes[0])).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)));

                    response.Redirect(ui);
                }
                subEntity.Where.And().Equal(new Subject {
                    project_id = team.Id
                });
                var projectItem = Utility.CMS.ObjectEntity <ProjectItem>().Where.And().Equal(new Data.Entities.ProjectItem
                {
                    Code       = codes[1],
                    project_id = team.Id
                }).Entities.Single();
                if (projectItem == null)
                {
                    ui.Add("Desc", new UMC.Web.WebMeta().Put("desc", String.Format("不存在“{0}/{1}”此栏位", team.Code, codes[1])).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)));

                    response.Redirect(ui);
                }
                subEntity.Where.And().Equal(new Subject {
                    project_item_id = projectItem.Id, Code = codes[2]
                });
            }


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

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

            //title.Float();

            var sub = subEntity.Single();

            if (sub == null || sub.Visible == -1)
            {
                if (strId.IndexOf("/") > 0)
                {
                    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)));
                }
                else
                {
                    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)));
                }
                response.Redirect(ui);
            }

            var desc = new UIDesc(sub.Title);

            desc.Style.Bold().Size(18).Name("border", "none");
            if (request.IsApp)
            {
                desc.Style.Padding(55, 10, 10, 10);
            }
            else
            {
                desc.Style.Padding(10);
            }
            ui.Add(desc);


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

            if (String.Equals("markdown", sub.ContentType, StringComparison.CurrentCultureIgnoreCase))
            {
                foreach (var pom in celss)
                {
                    switch (pom["_CellName"])
                    {
                    case "CMSImage":

                        pom.Put("style", new UIStyle().Padding(10));

                        break;
                    }
                }
            }
            else
            {
                foreach (var pom in celss)
                {
                    switch (pom["_CellName"])
                    {
                    case "CMSImage":
                        var value = pom.GetDictionary()["value"] as Hashtable;
                        if (value != null && value.ContainsKey("size"))
                        {
                            value.Remove("size");
                        }

                        pom.Put("style", new UIStyle().Padding(0, 10));

                        break;
                    }
                }
            }
            ui.DisableSeparatorLine();
            ui.AddCells(celss);;

            response.Redirect(ui);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var Id = UMC.Data.Utility.Guid(this.AsyncDialog("Id", g =>
            {
                this.Prompt("请输入参数");
                return(this.DialogValue("none"));
            }), true);

            if (String.IsNullOrEmpty(request.SendValue) == false)
            {
                this.Context.Send(new UISectionBuilder(request.Model, request.Command, new UMC.Web.WebMeta().Put("Id", Id))

                                  .RefreshEvent("Subject.Save", "Subject.WeiXin")
                                  .Builder(), true);
            }
            var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>();

            subEntity.Where.And().Equal(new Subject {
                Id = Id
            });

            var sub  = subEntity.Single();
            var webr = UMC.Data.WebResource.Instance();

            //var appid = "wx141d18e076be64a1";
            var user     = UMC.Security.Identity.Current;
            var appid    = user.Id.ToString();
            var config   = Data.JSON.Deserialize <Hashtable>(sub.ConfigXml) ?? new Hashtable();
            var imageKey = config["images"] as Hashtable ?? new Hashtable();

            config["images"] = imageKey;
            Array articleids = config["articles"] as Array;
            var   subsid     = new List <Guid>();

            if (articleids != null)
            {
                foreach (var o in articleids)
                {
                    subsid.Add(Utility.Guid(o.ToString()).Value);
                }
            }
            var Model = this.AsyncDialog("Model", gKey =>
            {
                UITitle uITItle = UITitle.Create();
                uITItle.Title   = "公众号群发";
                var sestion     = UISection.Create(uITItle);

                var src = webr.ResolveUrl(sub.Id.Value, 1, "0") + "!cms1";
                if (subsid.Count == 0)
                {
                    var image = UICell.Create("CMSImage", new UMC.Web.WebMeta().Put("src", src));
                    image.Style.Padding(0, 10);
                    var title = new UIDesc(sub.Title);
                    title.Style.Bold().Height(40).Name("border", "none");
                    title.Click(new UIClick("Id", Id.ToString(), gKey, "Title")
                    {
                        Model = request.Model, Command = request.Command
                    });

                    var desc = new UIDesc(sub.Description ?? sub.Title);
                    desc.Style.Height(40).Color(0x999).Name("border", "none");
                    desc.Click(new UIClick("Id", Id.ToString(), gKey, "Desc")
                    {
                        Model = request.Model, Command = request.Command
                    });


                    sestion.Add(title)
                    .Add(image)
                    .Add(desc);
                }
                else
                {
                    var image = UICell.Create("CMSImage", new UMC.Web.WebMeta().Put("src", src).Put("title", sub.Title));
                    image.Style.Padding(10, 10, 0, 10);
                    image.Format.Put("title", "{title}");

                    sestion.Add(image);
                    Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>()
                    .Where.And().In(new Subject {
                        Id = subsid[0]
                    }, subsid.ToArray())
                    .Entities.Query(dr =>
                    {
                        var cell = new UIImageTextValue(webr.ResolveUrl(sub.Id.Value, 1, "0") + "!200", dr.Title, null);
                        cell.Style.Name("image-width", 60);
                        cell.Click(new UIClick("Id", dr.Id.ToString(), gKey, "Items")
                        {
                            Model   = request.Model,
                            Command = request.Command
                        });

                        var item = new UMC.Web.WebMeta().Put("_CellName", cell.Type).Put("value", cell.Data).Put("format", cell.Format).Put("style", cell.Style)
                                   .Put("del", new UMC.Web.WebMeta().Put("click", new UIClick("Id", Id.ToString(), gKey, "Del", "Item", dr.Id.ToString())
                        {
                            Model   = request.Model,
                            Command = request.Command
                        }));
                        sestion.AddCells(item);
                    });
                }
                var ctip         = "未同步公众号";
                var ModifiedTime = config["ModifiedTime"] as string;
                if (String.IsNullOrEmpty(ModifiedTime) == false)
                {
                    ctip = String.Format("已同步公众号", Utility.GetDate(Utility.TimeSpan(Utility.IntParse(ModifiedTime, 0))));
                }

                var ls = sestion.NewSection().AddCell("图文封面", config.ContainsKey("thumb_media_id") ? "已同步公众号" : "未同步公众号", new UIClick("Id", Id.ToString(), gKey, "Thumb")
                {
                    Model   = request.Model,
                    Command = request.Command
                }).AddCell("图文正文", ctip, new UIClick("Id", Id.ToString(), gKey, "Content")
                {
                    Model   = request.Model,
                    Command = request.Command
                });
                var mstatus = "";
                if (config.ContainsKey("ContentLoading"))
                {
                    mstatus = "正在同步请等候";
                }
                else
                {
                    mstatus = config.ContainsKey("media_id") ? "已在公众生成" : "未在公众号生成";
                }

                ls.AddCell("群发素材", mstatus, new UIClick("Id", Id.ToString(), gKey, "Material")
                {
                    Model   = request.Model,
                    Command = request.Command
                })
                .NewSection().AddCell("使用帮助", "查看", UIClick.Pager("Message", "UIData", new UMC.Web.WebMeta().Put("Id", "Help.SendWeiXin")));



                sestion.UIFootBar = new UIFootBar().AddText(new UIEventText("追加图文")
                                                            .Click(new UIClick("Id", Id.ToString(), "Model", "Preview")
                {
                    Model   = request.Model,
                    Command = request.Command
                }), new UIEventText("微信预览")
                                                            .Click(new UIClick("Id", Id.ToString(), "Model", "Articles")
                {
                    Model   = request.Model,
                    Command = request.Command
                }).Style(new UIStyle().BgColor()), new UIEventText("确认群发").Click(new UIClick("Id", Id.ToString(), "Model", "SendAll")
                {
                    Model   = request.Model,
                    Command = request.Command
                }));
                sestion.UIFootBar.IsFixed = true;
                response.Redirect(sestion);

                return(this.DialogValue("none"));
            });

            switch (Model)
            {
            case "Articles":
            {
                var sudId = Utility.Guid(this.AsyncDialog("Articles", request.Model, "Select")).Value;

                var   config2   = Data.JSON.Deserialize <Hashtable>(sub.ConfigXml) ?? new Hashtable();
                Array articles2 = config2["articles"] as Array;
                var   subsid2   = new List <Guid>();
                if (articles2 != null)
                {
                    foreach (var o in articles2)
                    {
                        subsid.Add(Utility.Guid(o.ToString()).Value);
                    }
                }
                subsid.Remove(sudId);
                subsid.Add(sudId);
                config2["articles"] = subsid;
                subEntity.Update(new Subject
                    {
                        ConfigXml = Data.JSON.Serialize(config2)
                    });
            }
            break;

            case "Title":
                var title = Web.UIDialog.AsyncDialog("Title", g =>
                {
                    var dl = new Web.UIFormDialog()
                    {
                        Title = "图文标题"
                    };
                    dl.AddTextarea("图文标题", "Title", sub.Title);
                    dl.Submit("确认更改", request, "Subject.Save");
                    return(dl);
                });
                subEntity.Update(new Subject
                {
                    Title = title
                });
                this.Context.Send("Subject.Save", true);
                break;

            case "Desc":
                var desc = Web.UIDialog.AsyncDialog("Description", g =>
                {
                    var dl = new Web.UIFormDialog()
                    {
                        Title = "图文摘要"
                    };
                    dl.AddTextarea("图文摘要", "Description", sub.Description);
                    dl.Submit("确认更改", request, "Subject.WeiXin");
                    return(dl);
                });
                subEntity.Update(new Subject
                {
                    Description = desc
                });
                break;

            case "Thumb":
                if (webr.SubmitCheck(appid) == false)
                {
                    response.Redirect("Message", "Auth");
                }
                if (config.ContainsKey("thumb_media_id"))
                {
                    var thumb_media_id = config["thumb_media_id"] as string;
                    webr.Submit("cgi-bin/material/del_material", Data.JSON.Serialize(new UMC.Web.WebMeta().Put("media_id", thumb_media_id)), appid);
                }

                var src = webr.ResolveUrl(sub.Id.Value, 1, "0") + "!cms1";


                var data = webr.Submit("cgi-bin/material/add_material&type=image", src, appid);
                if (data.ContainsKey("media_id") == false)
                {
                    this.Prompt("同步封面图片失败");
                }
                else
                {
                    config["thumb_media_id"] = data["media_id"];

                    subEntity.Update(new Subject
                    {
                        ConfigXml = Data.JSON.Serialize(config)
                    });
                    this.Prompt("最新封面成功同步到公众号。", false);
                }
                break;

            case "Content":
                if (webr.SubmitCheck(appid) == false)
                {
                    response.Redirect("Message", "Auth");
                }
                if (config.ContainsKey("thumb_media_id") == false)
                {
                    this.Prompt("请先同步封面,再来同步正文");
                }

                var ModifiedTime = Utility.IntParse(config["ModifiedTime"] as string ?? "", 0);
                if (Utility.TimeSpan() - ModifiedTime < 10)
                {
                    this.Prompt("提示", "正在同步,请过一会再更新");
                }
                var res = this.AsyncDialog("Content", g =>
                {
                    if (request.SendValues != null)
                    {
                        var url = request.SendValues["Url"];
                        if (String.IsNullOrEmpty(url) == false)
                        {
                            return(this.DialogValue(System.Text.UTF8Encoding.UTF8.GetString(new UMC.Net.HttpClient().DownloadData(url))));
                        }
                    }
                    var domUrl = new Uri(request.UrlReferrer ?? request.Url, String.Format("{0}Show/{1}/UIMin/Id/{2}", webr.WebDomain(), request.Model, sub.Id)).AbsoluteUri;
                    this.Context.Send(new UMC.Web.WebMeta().Put("type", "OpenUrl").Put("selector", "#body section", "value", domUrl).Put("title", "正文同步到公众号素材")
                                      .Put("submit", new Web.UIClick("Id", sub.Id.ToString(), "Model", "Content", "Url", "Value")
                    {
                        Command = request.Command,
                        Model   = request.Model
                    }), true);
                    return(this.DialogValue("none"));
                });
                config["ContentLoading"] = "YES";
                subEntity.Update(new Subject {
                    ConfigXml = Data.JSON.Serialize(config)
                });
                UMC.Data.Reflection.Start(() =>
                {
                    var udata = new Subject();
                    try
                    {
                        var content            = Content(res, appid, imageKey);
                        config["ModifiedTime"] = Utility.TimeSpan();
                        config.Remove("ContentLoading");
                        udata.Content = content;
                    }
                    catch (Exception ex)
                    {
                        config.Remove("ContentLoading");
                        config["result"] = ex.Message;
                    }
                    finally
                    {
                        udata.ConfigXml = Data.JSON.Serialize(config);
                        subEntity.Update(udata);
                    }
                });

                break;

            case "Material":
                if (webr.SubmitCheck(appid) == false)
                {
                    response.Redirect("Message", "Auth");
                }
                if (config.ContainsKey("ModifiedTime") == false)
                {
                    this.Prompt("提示", String.Format("“{0}”正文未同步到公众号", sub.Title));
                }
                if (config.ContainsKey("thumb_media_id") == false)
                {
                    this.Prompt("提示", String.Format("“{0}”封面未同步到公众号", sub.Title));
                }
                if (config.ContainsKey("media_id"))
                {
                    webr.Submit("cgi-bin/material/del_material", Data.JSON.Serialize(new UMC.Web.WebMeta().Put("media_id", config["media_id"])), appid);
                }

                var content_source_url = new Uri(request.Url, String.Format("{0}Page/{1}/UIData/Id/{2}", webr.WebDomain(), request.Model, sub.Id)).AbsoluteUri;


                var articles = new List <WebMeta>();

                articles.Add(new UMC.Web.WebMeta().Put("title", sub.Title)
                             .Put("author", user.Alias)
                             .Put("digest", sub.Description ?? sub.Title)
                             .Put("thumb_media_id", config["thumb_media_id"])
                             .Put("content", sub.Content)
                             .Put("show_cover_pic", 0)
                             .Put("content_source_url", content_source_url)
                             .Put("need_open_comment", (sub.IsComment ?? true) ? 1 : 0));
                var subs = new List <Subject>();
                if (subsid.Count > 0)
                {
                    Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>().Where.And().In(new Subject
                    {
                        Id = subsid[0]
                    }, subsid.ToArray())
                    .Entities.Query(dr => subs.Add(dr));


                    foreach (var key in subsid)
                    {
                        var csub = subs.Find(g => g.Id == key);

                        var sconfig = Data.JSON.Deserialize <Hashtable>(csub.ConfigXml) ?? new Hashtable();


                        if (sconfig.ContainsKey("ModifiedTime") == false)
                        {
                            this.Prompt("提示", String.Format("“{0}”正文未同步到公众号", csub.Title));
                        }
                        if (sconfig.ContainsKey("thumb_media_id") == false)
                        {
                            this.Prompt("提示", String.Format("“{0}”封面未同步到公众号", csub.Title));
                        }
                        content_source_url = new Uri(request.Url, String.Format("{0}Page/{1}/UIData/Id/{2}", webr.WebDomain(), request.Model, csub.Id)).AbsoluteUri;

                        articles.Add(new UMC.Web.WebMeta().Put("title", csub.Title)
                                     .Put("author", user.Alias)
                                     .Put("digest", csub.Description ?? csub.Title)
                                     .Put("thumb_media_id", sconfig["thumb_media_id"])
                                     .Put("content", csub.Content)
                                     .Put("show_cover_pic", 0)
                                     .Put("content_source_url", content_source_url)
                                     .Put("need_open_comment", (sub.IsComment ?? true) ? 1 : 0));
                    }
                }
                var sData = webr.Submit("cgi-bin/material/add_news", Data.JSON.Serialize(new UMC.Web.WebMeta().Put("articles", articles)), appid);
                if (sData.ContainsKey("media_id") == false)
                {
                    this.Prompt("提示", "上传图文素材失败");
                }
                else
                {
                    config["media_id"]  = sData["media_id"];
                    config["MediaTime"] = Utility.TimeSpan();
                    config["result"]    = "ok";
                    subEntity.Update(new Subject
                    {
                        ConfigXml = Data.JSON.Serialize(config)
                    });
                    this.Prompt("提示", "最新图文素材成功更新到公众号。", false);
                }
                break;

            case "SendAll":
                if (webr.SubmitCheck(appid) == false)
                {
                    response.Redirect("Message", "Auth");
                }
                if (config.ContainsKey("media_id") == false)
                {
                    this.Prompt("提示", "请先生成群发素材");
                }
                if (config.ContainsKey("msg_id"))
                {
                    var msgData = webr.Submit("cgi-bin/message/mass/get", Data.JSON.Serialize(new UMC.Web.WebMeta().Put("msg_id", config["msg_id"])), appid);

                    switch (msgData["msg_status"] as string)
                    {
                    case "SEND_SUCCESS":
                        this.Prompt("提示", "群发发送成功");
                        break;

                    case "SENDING":
                        this.Prompt("提示", "群发正在发送中");
                        break;

                    case "SEND_FAIL":
                        this.Prompt("提示", "群发发送失败,请在公众号后台查看");
                        break;

                    case "DELETE":
                        this.Prompt("提示", "信息已经删除");
                        break;
                    }
                }


                var tag = this.AsyncDialog("tag", t =>
                {
                    var appKey = UMC.Security.Principal.Current.AppKey ?? Guid.Empty;
                    if (appKey == Guid.Empty)
                    {
                        return(this.DialogValue("-1"));
                    }
                    var tags = webr.Submit("cgi-bin/tags/get", String.Empty, appid);
                    if (String.Equals(tags["errcode"], "48001"))
                    {
                        return(this.DialogValue("-1"));
                    }
                    var header = new Web.UIGridDialog.Header("id", 0);
                    header.AddField("name", "粉丝标签");
                    header.AddField("count", "粉丝数");
                    var ls = new ArrayList();
                    ls.Add(new UMC.Web.WebMeta().Put("id", "-1", "name", "所有粉丝", "count", "all"));
                    ls.AddRange(tags["tags"] as Array);
                    var di   = Web.UIGridDialog.Create(header, ls.ToArray());
                    di.Title = "群发的粉丝";
                    return(di);
                });

                var filter = new UMC.Web.WebMeta().Put("is_to_all", tag == "-1");
                if (tag != "-1")
                {
                    filter.Put("tag_id", tag);
                }

                var sendall = new UMC.Web.WebMeta().Put("msgtype", "mpnews").Put("send_ignore_reprint", 0).Put("clientmsgid", Utility.Guid(sub.Id.Value))
                              .Put("filter", filter).Put("mpnews", new UMC.Web.WebMeta().Put("media_id", config["media_id"]));


                var sendData = webr.Submit("cgi-bin/message/mass/sendall", Data.JSON.Serialize(sendall), appid);
                if (sendData.ContainsKey("msg_data_id"))
                {
                    config["msg_id"]      = sendData["msg_id"];
                    config["msg_data_id"] = sendData["msg_data_id"];
                    config["clientmsgid"] = sub.Id;

                    subEntity.Update(new Subject
                    {
                        ConfigXml = Data.JSON.Serialize(config)
                    });
                    this.Prompt("提示", "群发指令已经成功提交");
                }
                else
                {
                    var errcode = (sendData["errcode"] ?? "").ToString();
                    switch (errcode)
                    {
                    case "0":
                        this.Prompt("发送成功");
                        break;

                    case "48001":
                        this.Prompt("群发失败", "此公众号未认证");
                        break;

                    default:
                        this.Prompt("群发失败", "请确认此微信号已经关注公众号");
                        break;
                    }
                }
                break;

            case "Preview":
                if (webr.SubmitCheck(appid) == false)
                {
                    this.Context.Send(new UISectionBuilder("Message", "UIData", new UMC.Web.WebMeta().Put("Id", "Help.Auth"))

                                      .Builder(), true);
                }
                if (config.ContainsKey("media_id") == false)
                {
                    this.Prompt("提示", "请先生成群发素材");
                }
                else
                {
                    var touser = Web.UIDialog.AsyncDialog("Touser", g =>
                    {
                        var dl = new Web.UIFormDialog()
                        {
                            Title = "微信号"
                        };
                        dl.AddText("微信号", "Touser", String.Empty);
                        dl.Submit("确认", request, "Subject.WeiXin");
                        return(dl);
                    });
                    //touser = "******";
                    var preview = new UMC.Web.WebMeta().Put("msgtype", "mpnews")
                                  .Put("touser", touser).Put("mpnews", new UMC.Web.WebMeta().Put("media_id", config["media_id"]));


                    var rdata   = webr.Submit("cgi-bin/message/mass/preview", Data.JSON.Serialize(preview), appid);
                    var errcode = (rdata["errcode"] ?? "").ToString();
                    switch (errcode)
                    {
                    case "0":
                        this.Prompt("发送成功");
                        break;

                    case "48001":
                        this.Prompt("发送失败", "此公众号未认证");
                        break;

                    default:
                        this.Prompt("发送失败", "请确认此微信号已经关注公众号");
                        break;
                    }
                }
                break;

            case "Items":

                this.AsyncDialog("Items", g =>
                {
                    var dl = new Web.UISheetDialog()
                    {
                        Title = "公众号同步"
                    };
                    dl.Options.Add(new UIClick("Id", Id.ToString(), "Model", "Thumb")
                    {
                        Text    = "封面同步到公众号",
                        Model   = request.Model,
                        Command = request.Command
                    });
                    dl.Options.Add(new UIClick("Id", Id.ToString(), "Model", "Content")
                    {
                        Text    = "正文同步到公众号",
                        Model   = request.Model,
                        Command = request.Command
                    });
                    return(dl);
                });
                break;

            case "Del":
                var itemid = Utility.Guid(this.AsyncDialog("Item", "aut"));
                if (itemid.HasValue)
                {
                    subsid.Remove(itemid.Value);
                    config["articles"] = subsid;
                    subEntity.Update(new Subject
                    {
                        ConfigXml = Data.JSON.Serialize(config)
                    });
                }
                break;
            }

            this.Context.Send("Subject.WeiXin", true);
        }