Beispiel #1
0
        public static UIClick Pager(String model, String cmd, bool isCache, String closeEvent)
        {
            var key = new WebMeta().Put("model", model, "cmd", cmd);

            key.Put("ColseEvent", closeEvent);
            if (isCache)
            {
                key.Put("Cache", isCache);
            }
            return(new UIClick(key)
            {
                Key = "Pager"
            });
        }
Beispiel #2
0
        public WebMeta ToMeta()
        {
            var meta = new WebMeta();

            if (_uiheaders != null)
            {
                meta.Put("Header", this._uiheaders);
            }
            if (this._title != null)
            {
                meta.Put("Title", this._title);
            }
            if (this._uifooter != null)
            {
                meta.Put("Footer", this._uifooter);
            }
            if (Total > 0)
            {
                meta.Put("total", this.Total);
            }
            var metas = new List <WebMeta>();

            foreach (var sec in this.Sections)
            {
                var s = new WebMeta();


                if (sec.Key != null)
                {
                    s.Put("key", sec.Key);
                }
                if (sec._data != null)
                {
                    s.Put("data", sec._data);
                }
                else
                {
                    s.Put("data", sec.data);
                }
                if (sec._header.Count > 0)
                {
                    s.Put("header", sec._header);
                }
                metas.Add(s);
            }
            meta.Put("DataSource", metas);
            return(meta);
        }
Beispiel #3
0
        public UIHeader Coustom(UIView coustomCell)
        {
            var webm = new WebMeta();

            if (coustomCell.Src != null)
            {
                webm.Put("style", coustomCell.Style).Put("items", coustomCell.items).Put("src", coustomCell.Src.AbsoluteUri);//
            }
            else
            {
                webm.Put("style", coustomCell.Style).Put("items", coustomCell.items);
            }
            meta.Put("type", "Custom").Put("data", webm);

            return(this);
        }
Beispiel #4
0
        WebMeta Image(WebRequest request)
        {
            var media_id = this.AsyncDialog("media_id", m =>
            {
                var f = Web.UIDialog.CreateDialog("File");
                f.Config.Put("Submit", new UIClick(new UMC.Web.WebMeta(request.Arguments.GetDictionary()).Put("media_id", "Value"))
                {
                    Command = request.Command,
                    Model   = request.Model
                });
                return(f);
            });
            var url    = new Uri(media_id);
            var urlKey = String.Format("UserResources/{0:YYMMDD}/{1}{2}", DateTime.Now, UMC.Data.Utility.TimeSpan(), url.AbsolutePath.Substring(url.AbsolutePath.LastIndexOf('/')));
            var webr   = UMC.Data.WebResource.Instance();


            var domain  = webr.WebDomain();
            var posmata = new UMC.Web.WebMeta();
            var cell    = UMC.Web.UICell.Create("CMSImage", posmata);

            posmata.Put("src", String.Format("{0}{1}", domain, urlKey));

            webr.Transfer(url, urlKey);
            cell.Style.Padding(10);
            return(new UMC.Web.WebMeta().Cell(cell));
        }
Beispiel #5
0
        void IJSON.Write(TextWriter writer)
        {
            if (String.IsNullOrEmpty(_type))
            {
                var webm = new WebMeta();
                if (this.Src != null)
                {
                    webm.Put("style", _style).Put("items", this.items).Put("src", this.Src.AbsoluteUri).Put("key", this.Key);//
                }
                else
                {
                    webm.Put("style", _style).Put("items", this.items);//
                }

                UMC.Data.JSON.Serialize(webm, writer);
            }
            else
            {
                writer.Write("{");
                UMC.Data.JSON.Serialize("key", writer);
                writer.Write(":");
                UMC.Data.JSON.Serialize(this._type, writer);


                writer.Write(",");

                UMC.Data.JSON.Serialize("data", writer);
                writer.Write(":");
                var webm = new WebMeta();
                if (this.Src != null)
                {
                    webm.Put("style", _style).Put("items", this.items).Put("src", this.Src.AbsoluteUri).Put("key", this.Key);//
                }
                else
                {
                    webm.Put("style", _style).Put("items", this.items);//
                }

                UMC.Data.JSON.Serialize(webm, writer);



                writer.Write("}");
            }
        }
Beispiel #6
0
        public static UIClick Pager(String model, String cmd, WebMeta search, String refreshEvent)
        {
            var key = new WebMeta().Put("model", model, "cmd", cmd).Put("search", search);

            key.Put("RefreshEvent", refreshEvent);
            return(new UIClick(key)
            {
                Key = "Pager"
            });
        }
Beispiel #7
0
        /// <summary>
        /// 列表选择框,
        /// </summary>
        /// <param name="title"></param>
        /// <param name="code"></param>
        /// <param name="value"></param>
        public WebMeta AddOption(string title, string code, string value, String text)
        {
            WebMeta v = new WebMeta();

            v["Title"] = title;
            v.Put("Text", text).Put("DefaultValue", value);
            v["Type"] = "Option";
            v["Name"] = code;
            this.dataSrouce.Add(v);
            return(v);
        }
Beispiel #8
0
            public Profile Account(string amount, String tip, String tag, UIClick click)
            {
                var acount = new WebMeta().Put("amount", amount);

                if (String.IsNullOrEmpty(tip) == false)
                {
                    acount.Put("tag", tip);
                }

                if (String.IsNullOrEmpty(tip) == false)
                {
                    acount.Put("tag", tip);
                }

                if (click != null)
                {
                    acount.Put("click", click);
                }
                meta.Put("account", acount);
                return(this);
            }
Beispiel #9
0
        public static UIClick Pager(String model, String cmd, WebMeta search, bool isCache)
        {
            var key = new WebMeta().Put("model", model, "cmd", cmd).Put("search", search);

            if (isCache)
            {
                key.Put("Cache", isCache);
            }
            return(new UIClick(key)
            {
                Key = "Pager"
            });
        }
Beispiel #10
0
        public string AsyncDialog(String asyncId, String model, String cmd, WebMeta meta)
        {
            return(this.AsyncDialog(asyncId, g =>
            {
                var click = new UIClick(Context.Request.Arguments.Put(asyncId, "Value")).Send(Context.Request.Model, Context.Request.Command);;
                this.Context.runtime.Client.UIEvent = click;
                var data = new Hashtable();
                data["Click"] = Data.JSON.Serialize(click);

                data["POS-MODEL"] = model;
                data["POS-COMMAND"] = cmd;
                this.Context.runtime.Client.Session.Storage(data, Context);
                Context.Response.Redirect(model, cmd, meta.Put("Key", "Click"), true);
                return UMC.Web.UIDialog.ReturnValue(asyncId);
            }));
        }
Beispiel #11
0
        protected void Search(string model, string cmd, WebMeta param, string submodel, string subcmd, WebMeta send)
        {
            var p = new WebMeta();

            if (param != null)
            {
                p.Set("params", param);
            }
            p["model"] = model;
            p["cmd"]   = cmd;

            var sub = new WebMeta();

            sub["model"] = submodel;
            sub["cmd"]   = subcmd;
            if (send != null)
            {
                sub.Put("send", send);
            }
            p.Set("submit", sub);
            this.Config.Set("search", p);
        }
Beispiel #12
0
        void Subject(String model, UISection ui, UMC.Data.Entities.Subject sub, Project project, bool isEditer)
        {
            var webr = UMC.Data.WebResource.Instance();
            var user = UMC.Security.Identity.Current;

            if (project != null)
            {
                bool isIsAttention;

                var attent = new UMC.Web.WebMeta().Put("desc", project.Description ?? "未写描述", "name", project.Caption)
                             .Put("src", webr.ImageResolve(project.Id.Value, "1", 4));

                var desc2 = UICell.Create("IconNameDesc", attent);
                if (model == "Subject")
                {
                    attent.Put("button", SubjectAttentionActivity.Attention(sub.project_id.Value, out isIsAttention))
                    .Put("button-click", Web.UIClick.Click(new Web.UIClick("Id", project.Id.ToString())
                    {
                        Model = model, Command = "Attention"
                    }))
                    .Put("button-color", isIsAttention ? "#25b864" : "#e67979");

                    desc2.Format.Put("button", "{button}");
                    if (isIsAttention == false)
                    {
                        desc2.Style.Fixed();
                    }
                }
                attent.Put("click", new Web.UIClick("Id", project.Id.ToString())
                {
                    Model = model, Command = "ProjectUI"
                });

                desc2.Style.Name("desc", new UIStyle().Color(0x999)).Name("name", new UIStyle().Bold());

                desc2.Style.Name("border", "none");

                ui.Title.Name("text", project.Caption);

                ui.Title.Name("src", webr.ImageResolve(project.Id.Value, "1", 4));

                ui.Add(desc2);
                if (user.IsAuthenticated)
                {
                    UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.ProjectAccess>()
                    .Where.And().Equal(new UMC.Data.Entities.ProjectAccess
                    {
                        user_id = user.Id,
                        sub_id  = sub.Id
                    })
                    .Entities.IFF(e => e.Update("{0}+{1}", new UMC.Data.Entities.ProjectAccess {
                        Times = 1
                    }
                                                , new UMC.Data.Entities.ProjectAccess {
                        LastAccessTime = DateTime.Now
                    }) == 0,
                                  e => e.Insert(new UMC.Data.Entities.ProjectAccess
                    {
                        CreationTime   = DateTime.Now,
                        Times          = 1,
                        LastAccessTime = DateTime.Now,
                        sub_id         = sub.Id,
                        user_id        = user.Id
                    }));
                }
            }


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

            foreach (var pom in celss)
            {
                switch (pom["_CellName"])
                {
                case "CMSImage":
                {
                    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;

                case "CMSCode":
                {
                    var value = pom.GetDictionary()["value"] as Hashtable;
                    if (value != null && value.ContainsKey("code"))
                    {
                        var code = value["code"] as string;
                        var type = value["type"] as string;
                        if (String.IsNullOrEmpty(code) == false)
                        {
                            var cell = Data.Markdown.Highlight(code, type);
                            pom.Put("value", cell.Data);
                            pom.Put("format", cell.Format);
                            pom.Put("style", cell.Style);
                        }
                    }
                }

                break;
                }
            }

            ui.AddCells(celss);;


            var cateData = new UMC.Web.WebMeta().Put("icon", "\uf02c", "name", sub.Poster).Put("look", (sub.Look ?? 0) + "").Put("Reply", (sub.Reply ?? 0) + "");

            var footer2 = new UIButton(cateData);

            footer2.Title("{icon}  {name} | 阅读({look}) | 评论({Reply})");

            footer2.Style.Color(0x999).Size(14).Name("icon", new UIStyle().Font("wdk"));
            ui.Add(footer2);
            if (project != null && isEditer)
            {
                ui.Title.Name("Editer", "OK");
                if (this.Context.Request.IsApp)
                {
                    footer2.Button(new UIEventText("编辑图文").Style(new UIStyle().Color(0x3F51B5).Name("border", "none")).Click(new UIClick(sub.Id.ToString())
                    {
                        Model   = model,
                        Command = "EditUI"
                    }));
                }
            }
        }
Beispiel #13
0
 /// <summary>
 /// 反转动画
 /// </summary>
 /// <param name="duration"></param>
 /// <returns></returns>
 public UIStyle Reverse(float duration)
 {
     meta.Put("animation-name", "reverse").Put("animation-duration", duration);
     return(this);
 }
Beispiel #14
0
 public UIDataSourceBuilder Menu(params Web.UIClick[] clicks)
 {
     _data.Put("menu", clicks);
     return(this);
 }
        public static void Search(UISection ui, Data.Sql.IObjectEntity <Subject> subEntity, String model, String cmd, int start, int limit, bool isblock)
        {
            var subs    = new List <Subject>();
            var cateids = new List <Guid>();
            var ids     = new List <Guid>();
            var itemIds = new List <Guid>();

            var search = UMC.Data.Reflection.CreateInstance <Subject>();

            search.DataJSON  = null;
            search.Content   = null;
            search.ConfigXml = null;
            subEntity.Query(search, start, limit, dr =>
            {
                subs.Add(dr);
                if (dr.project_id.HasValue)
                {
                    cateids.Add(dr.project_id ?? Guid.Empty);
                }
                ids.Add(dr.Id.Value);
                if (dr.project_item_id.HasValue)
                {
                    itemIds.Add(dr.project_item_id.Value);
                }
            });
            var cates  = new List <Project>();
            var pitems = new List <Data.Entities.ProjectItem>();


            if (itemIds.Count > 0)
            {
                Utility.CMS.ObjectEntity <ProjectItem>().Where.And().In(new ProjectItem
                {
                    Id = itemIds[0]
                }, itemIds.ToArray())
                .Entities.Query(dr => pitems.Add(dr));
            }
            if (cateids.Count > 0)
            {
                Utility.CMS.ObjectEntity <Project>().Where.And().In(new Project {
                    Id = cateids[0]
                }, cateids.ToArray())
                .Entities.Query(dr => cates.Add(dr));
            }
            var pics = new List <UMC.Data.Entities.Picture>();

            if (ids.Count > 0)
            {
                Utility.CMS.ObjectEntity <Data.Entities.Picture>().Where.And().In(new Data.Entities.Picture
                {
                    group_id = ids[0]
                }, ids.ToArray()).Entities.Order.Asc(new Data.Entities.Picture {
                    Seq = 0
                }).Entities.Query(g => pics.Add(g));
            }
            ;
            var items = ui;
            var webr  = UMC.Data.WebResource.Instance();


            foreach (var sub in subs)
            {
                if (sub.Visible == 0)
                {
                    continue;
                }
                var ims = new List <UMC.Data.Entities.Picture>();
                pics.RemoveAll(g =>
                {
                    if (g.group_id == sub.Id)
                    {
                        ims.Add(g);
                        return(true);
                    }
                    return(false);
                });
                var imgs = new List <String>();

                if (ims.Count > 0)
                {
                    switch (ims.Count)
                    {
                    case 2:
                    case 1:

                        imgs.Add(webr.ResolveUrl(sub.Id.Value, 1, "0") + "!cms" + ((sub.IsPicture ?? false) ? "1" : "3") + "?_ts=" + UMC.Data.Utility.TimeSpan(ims[0].UploadDate.Value));

                        break;

                    default:
                        for (var i = 0; i < 3; i++)
                        {
                            imgs.Add(webr.ResolveUrl(sub.Id.Value, ims[i].Seq ?? 0, "0") + "!cms3?_ts=" + UMC.Data.Utility.TimeSpan(ims[i].UploadDate.Value));
                        }
                        break;
                    }
                }
                var click = new Web.UIClick(sub.Id.ToString()).Send(model, cmd);
                var data  = new UMC.Web.WebMeta().Put("title", sub.Title).Put("reply", (sub.Reply ?? 0).ToString()).Put("look", (sub.Look ?? 0).ToString());


                var cate  = cates.Find(g => g.Id == sub.project_id);
                var pitem = pitems.Find(g => g.Id == sub.project_item_id);
                data.Put("pname", cate == null ? "草稿" : cate.Caption);
                if (sub.project_id == sub.user_id)
                {
                    data.Put("iname", "");
                }
                else
                {
                    data.Put("iname", pitem == null ? "" : pitem.Caption);
                }
                data.Put("time", Utility.GetDate(sub.ReleaseDate));
                if (cate != null && pitem != null)
                {
                    data.Put("spa", new WebMeta().Put("id", sub.Id).Put("path", String.Format("{0}/{1}/{2}", cate.Code, pitem.Code, sub.Code)));
                }
                else
                {
                    data.Put("sub-id", Utility.Guid(sub.Id.Value));//.Put("path", String.Format("{0}/{1}/{2}", cate.Code, pitem.Code, sub.Code)));
                }
                data.Put("desc", sub.Description);
                UICell cell;
                switch (imgs.Count)
                {
                case 0:
                    cell = new UICMS(click, data);
                    break;

                default:
                    cell = (sub.IsPicture ?? false) ? new UICMS(click, data, imgs[0], true) : (ims.Count > 2 ? new UICMS(click, data, imgs[0], imgs[1], imgs[2]) : new UICMS(click, data, imgs[0]));


                    break;
                }
                cell.Format.Put("left", "{pname} {iname} {time}");
                cell.Style.Name("licon", new UIStyle().Size(12).Font("wdk")).Name("ricon", new UIStyle().Size(12).Font("wdk"));
                cell.Style.Name("pname").Color(0x777);
                cell.Style.Name("iname").Color(0x777);
                if (isblock)
                {
                    cell.Style.Name("block").Size(12).Color(0xaaa).Font("wdk").Click(UIClick.Click(new UIClick("Id", sub.Id.ToString(), "Type", "Block").Send(model, "TipOff")));
                    data.Put("block", "\uea0d");

                    cell.Format.Put("right", "\uF06E{1:licon} {look}   \uF0E6{1:ricon} {reply}  {2:block}");
                }
                else
                {
                    cell.Format.Put("right", "\uF06E{1:licon} {look}   \uF0E6{1:ricon} {reply}");
                }
                items.Add(cell);
            }
            ui.Total = subEntity.Count();;
        }
Beispiel #16
0
 public UIEventText Key(String key)
 {
     meta.Put("key", key);
     return(this);
 }
Beispiel #17
0
 public UIItem(string title, String desc)
 {
     meta.Put("title", title);
     meta.Put("desc", desc);
 }
Beispiel #18
0
 public UIPrice Price(decimal?price)
 {
     meta.Put("price", price);
     return(this);
 }
Beispiel #19
0
 public UIStyle Radius(int radius)
 {
     meta.Put("border-radius", radius);
     return(this);
 }
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var refer_id = UMC.Data.Utility.Guid(this.AsyncDialog("Refer", g =>
            {
                return(new Web.UITextDialog()
                {
                    Title = "评论的主题"
                });
            })).Value;
            var user = UMC.Security.Identity.Current;

            if (user.IsAuthenticated == false)
            {
                this.Prompt("不支持匿名点赞,请登录", false);
                response.Redirect("Account", "Login");
            }

            var ui      = this.AsyncDialog("UI", g => this.DialogValue("none"));
            var section = this.AsyncDialog("section", g => this.DialogValue("1"));
            var row     = this.AsyncDialog("row", g => this.DialogValue("1"));


            Utility.CMS.ObjectEntity <UMC.Data.Entities.Proposal>()
            .Where.And().Equal(new Proposal {
                user_id = user.Id, ref_id = refer_id
            }).Entities.IFF(e =>
            {
                if (e.Count() > 0)
                {
                    e.Delete();

                    var cmdEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Comment>()
                                    .Where.And().Equal(new Comment {
                        Id = refer_id
                    })
                                    .Entities;
                    cmdEntity.Update("{0}+{1}", new Comment {
                        Effective = -1
                    });
                    var cmt = cmdEntity.Single();
                    if (cmt != null)
                    {
                        var vale = new UMC.Web.WebMeta().Put("section", section).Put("row", row).Put("method", "PUT").Put("reloadSinle", true);

                        vale.Put("value", new UMC.Web.WebMeta().Cell(Utility.Comment(cmt, request.Model)));

                        this.Context.Send(new UMC.Web.WebMeta().UIEvent("UI.Edit", ui, vale), true);
                    }

                    return(false);
                }
                return(true);
            }
                            , e =>
            {
                e.Insert(new UMC.Data.Entities.Proposal
                {
                    ref_id       = refer_id,
                    user_id      = user.Id,
                    Poster       = user.Alias,
                    CreationDate = DateTime.Now
                });
                var cmdEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Comment>()
                                .Where.And().Equal(new Comment {
                    Id = refer_id
                })
                                .Entities;
                cmdEntity.Update("{0}+{1}", new Comment {
                    Effective = 1
                });
                var cmt = cmdEntity.Single();
                if (cmt != null)
                {
                    var vale = new UMC.Web.WebMeta().Put("section", section).Put("row", row).Put("method", "PUT").Put("reloadSinle", true);

                    vale.Put("value", new UMC.Web.WebMeta().Cell(Utility.Comment(cmt, request.Model)));

                    this.Context.Send(new UMC.Web.WebMeta().UIEvent("UI.Edit", ui, vale), true);
                }
            });
        }
Beispiel #21
0
 public UIHeader Slider(System.Collections.IList sliders)
 {
     meta.Put("type", "Slider").Put("data", new WebMeta().Put("data", sliders));
     return(this);
 }
Beispiel #22
0
 public Profile(string name, String number, String src)
 {
     meta.Put("name", name);
     meta.Put("number", number);
     meta.Put("src", src);
 }
Beispiel #23
0
 public Portrait(String src)
 {
     meta.Put("src", src);
 }
Beispiel #24
0
        protected virtual void Scanning(Uri url)
        {
            var domain = new Uri(url, Data.WebResource.Instance().WebDomain()).AbsoluteUri;

            if (domain.Contains(url.Host))
            {
                var paths = new List <String>();

                paths.AddRange(url.LocalPath.Trim('/').Split('/'));
                if (paths.Count == 0)
                {
                    return;
                }
                switch (paths[0])
                {
                case "download":
                case "app":
                    if (String.IsNullOrEmpty(url.Query))
                    {
                        this.OpenUrl(url);
                    }
                    var query = url.Query.Substring(1);
                    var user  = UMC.Security.Identity.Current;
                    if (user.IsAuthenticated == false)
                    {
                        this.Context.Response.Redirect("Account", "Login");
                    }
                    var dever = Data.Utility.Guid(query);
                    if (dever.HasValue)
                    {
                        var webr = Data.WebResource.Instance();
                        this.AsyncDialog("Device", g =>
                        {
                            webr.Push(dever.Value, new WebMeta().Put("msg", "扫码成功").Put("src", webr.ImageResolve(user.Id.Value, "1", 4)));
                            var fm   = new UIFormDialog();
                            fm.Title = "扫码登录";
                            var desc = new UI.UIDesc(new UMC.Web.WebMeta().Put("desc", "正在进行扫码登录").Put("icon", "\uF108"));
                            desc.Desc("{icon}\n{desc}");
                            desc.Style.Align(1)
                            .Color(0xaaa).Padding(40, 20).BgColor(0xfff).Name("icon", new UIStyle().Font("wdk").Size(160));
                            fm.Add(desc);

                            fm.Submit("确认登录", this.Context.Request, "PC.Login");
                            return(fm);
                        });

                        UMC.Security.AccessToken.Login(user, dever.Value, "PC");
                        webr.Push(dever.Value, new WebMeta().Put("msg", "OK").Put("type", "SignIn").Put("root", Data.Utility.GetRoot(this.Context.Request.Url)));
                        this.Context.Send("PC.Login", true);
                    }
                    else
                    {
                        this.OpenUrl(url);
                    }
                    break;

                case "Click":
                case "Pager":
                    var p = paths[0];
                    paths.RemoveAt(0);
                    var data = new UMC.Web.WebMeta();
                    if (String.IsNullOrEmpty(url.Query) == false)
                    {
                        var query2 = System.Web.HttpUtility.ParseQueryString(url.Query.Substring(1));
                        for (var i = 0; i < query2.Count; i++)
                        {
                            var qV = query2.Get(i);
                            var qK = query2.GetKey(i);
                            if (String.IsNullOrEmpty(qK) == false)
                            {
                                if (String.IsNullOrEmpty(qV) == false)
                                {
                                    data.Put(qK, qV);
                                }
                                else
                                {
                                    data.Put("Id", qK);
                                }
                            }
                        }
                    }

                    var model = "Corp";
                    var cmd   = "Scanning";
                    if (paths.Count > 1)
                    {
                        model = paths[0];
                        cmd   = paths[1];
                        paths.RemoveRange(0, 2);
                    }
                    var SValue = String.Empty;
                    if (paths.Count == 1)
                    {
                        SValue = paths[0];
                        data.Put("Id", paths[0]);
                    }
                    else
                    {
                        while (paths.Count > 0)
                        {
                            if (paths.Count > 1)
                            {
                                data.Put(paths[0], paths[1]);
                            }
                            paths.RemoveRange(0, 2);
                        }
                    }
                    if (p == "Click")
                    {
                        if (data.Count > 0)
                        {
                            if (String.IsNullOrEmpty(SValue) || data.Count > 1)
                            {
                                this.Context.Response.Redirect(model, cmd, data, true);
                            }
                            else
                            {
                                this.Context.Response.Redirect(model, cmd, SValue, true);
                            }
                        }
                        else
                        {
                            this.Context.Response.Redirect(model, cmd, true);
                        }
                    }
                    else
                    {
                        if (data.Count > 0)
                        {
                            this.Context.Send("Pager", new UMC.Web.WebMeta().Put("model", model, "cmd", cmd).Put("search", data), true);
                        }
                        else
                        {
                            this.Context.Send("Pager", new UMC.Web.WebMeta().Put("model", model, "cmd", cmd), true);
                        }
                    }
                    break;
                }
            }
        }
Beispiel #25
0
 /// <summary>
 /// 向发送客户端发送数据事情
 /// </summary>
 /// <param name="type">数据事件</param>
 /// <param name="data">发送的数据</param>
 /// <param name="endResponse"></param>
 public void Send(String type, WebMeta data, bool endResponse)
 {
     this.Send(data.Put("type", type), endResponse);
 }
Beispiel #26
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var refer_id = UMC.Data.Utility.Guid(this.AsyncDialog("Id", g =>
            {
                return(new Web.UITextDialog()
                {
                    Title = "关注Id"
                });
            }));
            var user = UMC.Security.Identity.Current;

            if (user.IsAuthenticated == false)
            {
                response.Redirect("Account", "Login");
            }

            var section = this.AsyncDialog("section", g => this.DialogValue("1"));
            var row     = this.AsyncDialog("row", g => this.DialogValue("1"));
            var ui      = this.AsyncDialog("UI", g => this.DialogValue("none"));

            var vale = new UMC.Web.WebMeta().Put("section", section).Put("row", row).Put("method", "VALUE").Put("reloadSinle", true);



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

            if (member != null)
            {
                if (member.AuthType == WebAuthType.Guest)
                {
                    memberEnttiy.Delete();
                }
                else
                {
                    this.AsyncDialog("Confrm", g => new UIConfirmDialog("你是项目的专栏作家,要取消此项目关注吗"));
                    memberEnttiy.Delete();
                }

                memberEnttiy.Where.Reset().And().Equal(new ProjectMember {
                    project_id = refer_id
                });                                                                                 // Entities.Delete();

                UMC.Configuration.ConfigurationManager.ClearCache(refer_id.Value, "Data");

                this.Context.Send(new UMC.Web.WebMeta().UIEvent("UI.Edit", ui, vale.Put("value", new UMC.Web.WebMeta().Put("button", "+关注").Put("button-color", "#e67979").Put("desc", String.Format("{0}人", memberEnttiy.Count() + 1)))), true);
            }
            else
            {
                memberEnttiy.Insert(new UMC.Data.Entities.ProjectMember
                {
                    project_id   = refer_id,
                    user_id      = user.Id,
                    CreationTime = DateTime.Now,
                    AuthType     = WebAuthType.Guest
                });

                Utility.CMS.ObjectEntity <ProjectDynamic>()
                .Insert(new ProjectDynamic
                {
                    Time       = Utility.TimeSpan(DateTime.Now),
                    user_id    = user.Id,
                    Explain    = String.Format("{0} 加入了项目", user.Alias),
                    project_id = refer_id,
                    refer_id   = user.Id,
                    Title      = "项目成员",
                    Type       = DynamicType.Member
                });
                UMC.Configuration.ConfigurationManager.ClearCache(refer_id.Value, "Data");
                memberEnttiy.Where.Reset().And().Equal(new ProjectMember {
                    project_id = refer_id
                });
                this.Context.Send(new UMC.Web.WebMeta().UIEvent("UI.Edit", ui, vale.Put("value", new UMC.Web.WebMeta().Put("button", "已关注").Put("button-color", "#25b864").Put("desc", String.Format("{0}人", memberEnttiy.Count() + 1)))), true);
            }
        }
Beispiel #27
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);
        }
Beispiel #28
0
 public UISectionBuilder(String model, String cmd)
 {
     _data.Put("model", model, "cmd", cmd);//.Put("search", search);
 }
Beispiel #29
0
        internal static List <WebMeta> Mapping()
        {
            List <WebMeta> metas = new List <WebMeta>();

            if (WebRuntime.webFactorys.Count > 0)
            {
                foreach (var wt in WebRuntime.webFactorys)
                {
                    var     t    = wt.Type;
                    WebMeta meta = new WebMeta();
                    meta.Put("type", t.FullName);
                    meta.Put("name", "." + t.Name);
                    metas.Add(meta);

                    MappingAttribute mapping = (MappingAttribute)t.GetCustomAttributes(typeof(MappingAttribute), false)[0];
                    if (String.IsNullOrEmpty(mapping.Desc) == false)
                    {
                        meta.Put("desc", mapping.Desc);
                    }
                }
            }
            if (WebRuntime.flows.Count > 0)
            {
                var em = WebRuntime.flows.GetEnumerator();
                while (em.MoveNext())
                {
                    var tls = em.Current.Value;
                    foreach (var wt in tls)
                    {
                        var     t    = wt.Type;
                        WebMeta meta = new WebMeta();
                        meta.Put("type", t.FullName);
                        meta.Put("name", em.Current.Key + ".");
                        meta.Put("auth", WebRuntime.authKeys[em.Current.Key].ToString().ToLower());
                        meta.Put("model", em.Current.Key);//.getKey())
                        metas.Add(meta);

                        var mappings = t.GetCustomAttributes(typeof(MappingAttribute), false);//[0];

                        MappingAttribute mapping = (MappingAttribute)mappings[0];
                        if (mappings.Length > 1)
                        {
                            foreach (var m in mappings)
                            {
                                var c = m as MappingAttribute;
                                if (String.Equals(c.Model, em.Current.Key))
                                {
                                    mapping = c;
                                    break;
                                }
                            }
                        }
                        if (String.IsNullOrEmpty(mapping.Desc) == false)
                        {
                            meta.Put("desc", mapping.Desc);
                        }
                    }
                }
            }
            if (WebRuntime.activities.Count > 0)
            {
                var em = WebRuntime.activities.GetEnumerator();
                while (em.MoveNext())
                {
                    var em3 = em.Current.Value.GetEnumerator();
                    while (em3.MoveNext())
                    {
                        var mappings             = em3.Current.Value.GetCustomAttributes(typeof(MappingAttribute), false);
                        MappingAttribute mapping = (MappingAttribute)mappings[0];
                        if (mappings.Length > 1)
                        {
                            foreach (var m in mappings)
                            {
                                var c = m as MappingAttribute;
                                if (String.Equals(c.Model, em.Current.Key) && String.Equals(c.Command, em3.Current.Key))
                                {
                                    mapping = c;
                                    break;
                                }
                            }
                        }

                        WebAuthType authType = mapping.Auth;// WebRuntime.authKeys[em.Current.Key];

                        WebMeta meta = new WebMeta();
                        meta.Put("type", em3.Current.Value.FullName);
                        meta.Put("name", em.Current.Key + "." + em3.Current.Key);
                        meta.Put("auth", authType.ToString().ToLower());
                        meta.Put("model", mapping.Model); //.getKey())
                        meta.Put("cmd", mapping.Command); //.getKey())
                        metas.Add(meta);

                        if (String.IsNullOrEmpty(mapping.Desc) == false)
                        {
                            meta.Put("desc", mapping.Desc);
                        }
                    }
                }
            }
            return(metas);
        }
Beispiel #30
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);
        }