コード例 #1
0
 void Append()
 {
     if (data.Count > 0 || dataText.Length > 0)
     {
         if (dataText.Length > 0)
         {
             data.Put("m" + data.Count.ToString(), dataText.ToString());
         }
         dataText = new StringBuilder();
         var sb = new StringBuilder();
         for (int i = 0; i < data.Count; i++)
         {
             sb.Append("{m");
             sb.Append(i);
             sb.Append("}");
         }
         var cell = UICell.Create(data["type"] ?? "CMSText", data);
         data.Remove("type");
         cell.Format.Put("text", sb.ToString());
         cell.Style.Copy(style);
         cells.Add(cell);
         data  = new WebMeta();
         style = new UIStyle();
     }
 }
コード例 #2
0
        WebMeta Text()
        {
            var webr = UMC.Data.WebResource.Instance();
            var data = new UMC.Web.WebMeta().Put("text", "插入文字");
            var cell = UICell.Create("CMSText", data);

            return(new UMC.Web.WebMeta().Cell(cell));
        }
コード例 #3
0
            public UICell Paster(String text, string type)
            {
                switch ((type ?? "").ToLower().Trim())
                {
                case "text":
                case "shell":
                    dataText.Append(text);
                    break;

                case "html":
                case "xml":
                    CheckXml(text);

                    break;

                default:
                    Check(text);
                    Append();
                    break;
                }
                if (dataText.Length > 0)
                {
                    data.Put("h" + data.Count.ToString(), dataText.ToString());
                }
                dataText = new StringBuilder();
                var sb = new StringBuilder();

                for (int i = 0; i < data.Count; i++)
                {
                    sb.Append("{h");
                    sb.Append(i);
                    sb.Append("}");
                }
                var cell = UICell.Create("CMSCode", data);

                if (String.IsNullOrEmpty(type) == false)
                {
                    data.Put("type", type);
                }
                cell.Format.Put("text", sb.ToString());
                cell.Style.Copy(style);

                return(cell);
            }
コード例 #4
0
        void Header(string text)
        {
            int i = 0;

            while (i < text.Length && text[i] == '#')
            {
                i++;
                if (i == 6)
                {
                    break;
                }
            }
            int size = 26 - (i - 1) * 2;

            var cell = UICell.Create("CMSText", new WebMeta().Put("text", text.Substring(i).Trim()).Put("Key", i));

            cell.Format.Put("text", "{text}");
            cell.Style.Bold().Size(size);
            cells.Add(cell);
        }
コード例 #5
0
ファイル: Markdown.cs プロジェクト: wushunming/UMC.NET
            public UICell Transform(String text)
            {
                Check(text);
                Append();
                if (dataText.Length > 0)
                {
                    data.Put("h" + data.Count.ToString(), dataText.ToString());
                }
                dataText = new StringBuilder();
                var sb = new StringBuilder();

                for (int i = 0; i < data.Count; i++)
                {
                    sb.Append("{h");
                    sb.Append(i);
                    sb.Append("}");
                }
                var cell = UICell.Create("CMSCode", data);

                cell.Format.Put("text", sb.ToString());
                cell.Style.Copy(style);

                return(cell);
            }
コード例 #6
0
        void TitleDesc(Design_Item parent, List <Design_Item> items, UISection U)
        {
            UMC.Data.WebResource webr = UMC.Data.WebResource.Instance();


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

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

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

                int len = items.Count;

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

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

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

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

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

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

            var sub = subEntity.Single();

            var user = UMC.Security.Identity.Current;

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

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

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

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

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

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



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



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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            this.Context.Send("Subject.Save", true);
        }
コード例 #8
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var ProjectId = Utility.Guid(this.AsyncDialog("Id", g =>
            {
                this.Prompt("请输入项目");

                return(this.DialogValue("Project"));
            })) ?? Guid.Empty;
            var project = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project {
                Id = ProjectId
            }).Entities.Single();

            var Model = this.AsyncDialog("Model", ml =>
            {
                if (project == null)
                {
                    return(this.DialogValue("News"));
                }
                var form = (request.SendValues ?? new UMC.Web.WebMeta()).GetDictionary();
                if (form.ContainsKey("start") == false)
                {
                    if (request.IsApp)
                    {
                        var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments);
                        this.Context.Send(buider.Builder(), true);
                    }
                    else
                    {
                        if (request.Url.Query.Contains("_v=Sub"))
                        {
                            this.Context.Send("Subject.Path", new WebMeta().Put("Path", project.Code), true);
                        }
                        else
                        {
                            var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments);
                            this.Context.Send(buider.Builder(), true);
                        }
                    }
                }
                var webr      = UMC.Data.WebResource.Instance();
                UISection ui  = null;
                UISection ui2 = null;

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

                var items = new List <WebMeta>();//
                items.Add(new UMC.Web.WebMeta().Put("text", "团队成员", "search", "Member", "Key", "List"));
                items.Add(new UMC.Web.WebMeta().Put("text", "文档资讯", "search", "Subs", "Key", "List"));
                items.Add(new UMC.Web.WebMeta().Put("text", "项目动态", "search", "Dynamic", "Key", "List"));

                var Keyword = (form["Keyword"] as string ?? String.Empty);
                if (String.IsNullOrEmpty(Keyword) && selectIndex > -1)
                {
                    Keyword = items[selectIndex]["search"];
                }

                int start   = UMC.Data.Utility.IntParse(form["start"] as string, 0);
                var nextKey = this.AsyncDialog("NextKey", g => this.DialogValue("Header"));;
                if (start == 0 && String.Equals(nextKey, "Header"))
                {
                    ;

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

                    var members = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>()
                                  .Where.And().Equal(new Data.Entities.ProjectMember {
                        project_id = project.Id
                    })
                                  .Entities.Count() + 1;



                    var suject =
                        Utility.CMS.ObjectEntity <Subject>()
                        .Where.And().Equal(new Subject {
                        project_id = project.Id
                    })
                        .Entities.GroupBy().Sum(new Subject {
                        Reply = 0
                    })
                        .Sum(new Subject {
                        Look = 0
                    }).Count(new Subject {
                        Seq = 0
                    }).Single();



                    var Discount = new UIHeader.Portrait(logoUrl);


                    Discount.Value(project.Caption);
                    Discount.Time(project.Description);

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

                    title.Title = "项目介绍";
                    title.Style.BgColor(color);
                    title.Style.Color(0xfff);
                    header.AddPortrait(Discount);

                    ui = UISection.Create(header, title);
                    bool isIsAttention;

                    UIIconNameDesc uIIcon = new UIIconNameDesc(); //
                    uIIcon.Put("icon", '\uF0c0').Put("color", "#40c9c6").Put("name", "团队规模").Put("desc", members + "人");
                    if (request.Model == "Subject")
                    {
                        uIIcon.Button(SubjectAttentionActivity.Attention(project.Id.Value, out isIsAttention), Web.UIClick.Click(new Web.UIClick("Id", project.Id.ToString())
                        {
                            Model = request.Model, Command = "ProjectAtten"
                        }), isIsAttention ? 0x25b864 : 0xe67979);
                    }
                    ui.Add(uIIcon);

                    uIIcon = new UIIconNameDesc(new UIIconNameDesc.Item('\uF02d', "文章数量", suject.Seq + "篇").Color(0x36a3f7), new UIIconNameDesc.Item('\uf06e', "浏览总数", suject.Look + "次").Color(0x34bfa3));
                    ui.Add(uIIcon);
                    ui2 = ui.NewSection();
                }
                else
                {
                    ui2 = ui = UISection.Create();
                }
                if (start == 0 && String.Equals(nextKey, "Self") == false)
                {
                    if (selectIndex > 0)
                    {
                        ui2.Add(UICell.Create("TabFixed", new UMC.Web.WebMeta().Put("items", items).Put("selectIndex", selectIndex)));
                    }
                    else
                    {
                        ui2.Add(UICell.Create("TabFixed", new UMC.Web.WebMeta().Put("items", items)));;
                    }
                }
                ui2.Key   = "List";
                int limit = UMC.Data.Utility.IntParse(form["limit"] as string, 25);
                switch (Keyword)
                {
                default:
                case "Subs":
                    {
                        var Type = this.AsyncDialog("Type", "Items");

                        var itemId = Utility.Guid(this.AsyncDialog("CId", project.Id.ToString()));


                        switch (Type)
                        {
                        case "Items":
                            {
                                var subs = new List <Subject>();
                                Utility.CMS.ObjectEntity <Subject>().Where.And().In(new Subject {
                                    project_id = project.Id
                                }).Entities
                                .GroupBy(new Subject {
                                    project_item_id = Guid.Empty
                                })
                                .Count(new Subject {
                                    Look = 0
                                })
                                .Query(dr => subs.Add(dr));

                                var projects      = new List <ProjectItem>();
                                var projectEntity = Utility.CMS.ObjectEntity <ProjectItem>();
                                projectEntity.Where.And().In(new ProjectItem {
                                    project_id = project.Id
                                });

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

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

                        case "Portfolio":
                            {
                                var subs = new List <Subject>();
                                Utility.CMS.ObjectEntity <Subject>().Where.And().In(new Subject {
                                    project_item_id = itemId
                                }).Entities
                                .GroupBy(new Subject {
                                    portfolio_id = Guid.Empty
                                })
                                .Count(new Subject {
                                    Look = 0
                                })
                                .Query(dr => subs.Add(dr));


                                var item = Utility.CMS.ObjectEntity <ProjectItem>().Where.And().In(new ProjectItem {
                                    Id = itemId
                                }).Entities.Single();
                                var navData = new WebMeta().Put("item", item.Caption).Put("Icon", '\uf022');

                                navData.Put("nav", "目录");
                                navData.Put("split", '\uf105');
                                var cell = UICell.Create("UI", navData);
                                cell.Style.Name("nav").Click(new UIClick(new WebMeta().Put("key", "List").Put("send", new WebMeta().Put("CId", item.project_id).Put("Type", "Items")))
                                {
                                    Key = "Query"
                                }).Color(0x36a3f7);
                                cell.Style.Name("item").Color(0x999);
                                cell.Format.Put("text", "{nav} {split} {item}");
                                cell.Style.Name("split").Font("wdk");

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

                        case "Subs":
                            {
                                var ui3 = ui2;
                                if (start == 0)
                                {
                                    var portfolio = Utility.CMS.ObjectEntity <Portfolio>().Where.And().In(new Portfolio {
                                        Id = itemId
                                    }).Entities.Single();
                                    var item = Utility.CMS.ObjectEntity <ProjectItem>()
                                               .Where.And().In(new ProjectItem {
                                        Id = portfolio.project_item_id
                                    }).Entities.Single();

                                    var navData = new WebMeta().Put("item", item.Caption).Put("Icon", '\uf022');

                                    navData.Put("nav", "目录");
                                    navData.Put("split", '\uf105');
                                    navData.Put("port", portfolio.Caption);
                                    var cell = UICell.Create("UI", navData);
                                    cell.Style.Name("nav").Click(new UIClick(new WebMeta().Put("key", "List").Put("send", new WebMeta().Put("CId", item.project_id).Put("Type", "Items")))
                                    {
                                        Key = "Query"
                                    }).Color(0x36a3f7);
                                    cell.Style.Name("item").Color(0x36a3f7).Click(new UIClick(new WebMeta().Put("key", "List").Put("send", new WebMeta().Put("CId", item.Id).Put("Type", "Portfolio")))
                                    {
                                        Key = "Query"
                                    });
                                    cell.Format.Put("text", "{nav} {split} {item} {split} {port}");

                                    cell.Style.Name("port").Color(0x999);
                                    cell.Style.Name("split").Font("wdk");
                                    ui2.Add(cell);

                                    ui3 = ui2.NewSection();
                                }
                                ui3.Key       = "Subs";
                                var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>();
                                subEntity.Order.Desc(new Subject {
                                    ReleaseDate = DateTime.Now
                                });
                                subEntity.Where.And().Equal(new Data.Entities.Subject {
                                    Status = 1, portfolio_id = itemId
                                }).And().Greater(new Subject {
                                    Status = 0, Visible = -1
                                });
                                SubjectUIActivity.Search(request.Model, ui3, subEntity, start, limit);
                                if (ui3.Total == 0)
                                {
                                    ui3.Add("Desc", new UMC.Web.WebMeta().Put("desc", "尚未有发布的项目资讯").Put("icon", "\uF016")
                                            , new UMC.Web.WebMeta().Put("desc", "{icon}\n{desc}"), new UIStyle().Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60)));
                                }
                            }
                            break;
                        }
                    }
                    break;

                case "Member":
                    {
                        var style     = new UIStyle().AlignLeft();
                        int mlimit    = limit * 4;
                        int mstart    = start * 4;
                        var ids       = new List <Guid>();
                        var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>();
                        subEntity.Where.And().Equal(new ProjectMember {
                            project_id = project.Id
                        });
                        subEntity.Order.Desc(new ProjectMember {
                            CreationTime = DateTime.Now
                        });
                        var wids = new List <Guid>();
                        var pms  = new List <ProjectMember>();
                        if (mstart == 0)
                        {
                            ids.Add(project.user_id.Value);
                            subEntity.Where.And().In(new ProjectMember {
                                AuthType = WebAuthType.Admin
                            }, WebAuthType.User)
                            .And().Unequal(new ProjectMember {
                                user_id = project.user_id
                            }).Entities.Order.Desc(new ProjectMember {
                                AuthType = 0
                            });
                            subEntity.Query(dr => { pms.Add(dr); ids.Add(dr.user_id.Value); });
                            wids.AddRange(ids);
                        }
                        subEntity.Where.Reset().And().Equal(new ProjectMember {
                            project_id = project.Id, AuthType = WebAuthType.Guest
                        });
                        subEntity.Query(mstart, mlimit, dr => ids.Add(dr.user_id.Value));
                        if (ids.Count > 0)
                        {
                            var users = new List <User>();
                            Utility.CMS.ObjectEntity <User>()
                            .Where.And().In(new User {
                                Id = ids[0]
                            }, ids.ToArray()).Entities.Query(dr => users.Add(dr));

                            if (wids.Count > 0)
                            {
                                var puser = users.Find(u => u.Id == project.user_id) ?? new User {
                                    Alias = "未知", Id = project.user_id
                                };


                                ui2.Add(new UIIconNameDesc(new UIIconNameDesc.Item(webr.ResolveUrl(puser.Id.Value, "1", "4"), puser.Alias, "创立于" + Utility.GetDate(project.CreationTime))
                                                           .Click(request.IsApp ? UIClick.Pager(request.Model, "Account", new WebMeta().Put("Id", puser.Id), true) : new UIClick(puser.Id.ToString()).Send(request.Model, "Account"))).Button("立项人", null, 0xb7babb));


                                var ites = new List <UIIconNameDesc.Item>();
                                foreach (var pm in pms)
                                {
                                    var v = users.Find(u => u.Id == pm.user_id) ?? new User {
                                        Alias = pm.Alias
                                    };
                                    var text = "专栏作家";
                                    switch (pm.AuthType)
                                    {
                                    case WebAuthType.Admin:
                                        text = "管理员";
                                        break;

                                    case WebAuthType.User:
                                        break;
                                    }
                                    ites.Add(new UIIconNameDesc.Item(webr.ResolveUrl(pm.user_id.Value, "1", "4"), v.Alias, text)
                                             .Click(request.IsApp ? UIClick.Pager(request.Model, "Account", new WebMeta().Put("Id", pm.user_id), true) : new UIClick(pm.user_id.ToString()).Send(request.Model, "Account")));
                                    if (ites.Count % 2 == 0)
                                    {
                                        ui2.Add(new UIIconNameDesc(ites.ToArray()));
                                        ites.Clear();
                                    }
                                }
                                if (ites.Count > 0)
                                {
                                    ui2.Add(new UIIconNameDesc(ites.ToArray()));
                                }
                                ids.RemoveAll(g => wids.Exists(w => w == g));
                            }

                            var icons = new List <UIEventText>();
                            foreach (var id in ids)
                            {
                                var v = users.Find(u => u.Id == id);
                                icons.Add(new UIEventText(v.Alias).Src(webr.ResolveUrl(v.Id.Value, "1", "4")).Click(request.IsApp ? UIClick.Pager(request.Model, "Account", new WebMeta().Put("Id", v.Id), true) : new UIClick(v.Id.ToString()).Send(request.Model, "Account")));

                                if (icons.Count % 4 == 0)
                                {
                                    ui2.Add(new Web.UI.UIIcon().Add(icons.ToArray()));
                                    icons.Clear();
                                }
                            }
                            if (icons.Count > 0)
                            {
                                var ls = new Web.UI.UIIcon().Add(icons.ToArray());
                                ls.Style.Copy(style);
                                ui2.Add(ls);     // new Web.UI.UIIcon().Add(icons.ToArray()));
                                //ui2.AddIcon(style, icons.ToArray());
                            }
                            //if (icons.Count > 0)
                            //    ui2.AddIcon(style, icons.ToArray());
                        }
                        var m     = subEntity.Count();
                        int total = m / 4;
                        if (m % 4 > 0)
                        {
                            total++;
                        }
                        ui.Total = total;
                        response.Redirect(ui);
                    }
                    break;

                case "Writer":
                    {
                        int mlimit    = limit * 4;
                        int mstart    = start * 4;
                        var ids       = new List <ProjectMember>();
                        var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>();
                        subEntity.Where.And().Equal(new ProjectMember {
                            project_id = project.Id
                        });
                        subEntity.Where.And().In(new ProjectMember {
                            AuthType = WebAuthType.Admin
                        }, WebAuthType.User);
                        subEntity.Order.Desc(new ProjectMember {
                            CreationTime = DateTime.Now
                        });
                        subEntity.Query(mstart, mlimit, dr => ids.Add(dr));


                        var style = new UIStyle().AlignRight();
                        if (ids.Count > 0)
                        {
                            var icons = new List <UIEventText>();
                            foreach (var v in ids)
                            {
                                icons.Add(new UIEventText(v.Alias).Src(webr.ResolveUrl(v.user_id.Value, "1", "4")).Click(UIClick.Pager(request.Model, "Account", new WebMeta().Put("Id", v.user_id), true)));

                                if (icons.Count % 4 == 0)
                                {
                                    ui2.Add(new Web.UI.UIIcon().Add(icons.ToArray()));
                                    icons.Clear();
                                }
                            }
                            if (icons.Count > 0)
                            {
                                var ls = new Web.UI.UIIcon().Add(icons.ToArray());
                                ls.Style.Copy(style);
                                ui2.Add(ls);     // new Web.UI.UIIcon().Add(icons.ToArray()));
                                //ui2.AddIcon(style, icons.ToArray());
                            }
                        }
                        var m     = subEntity.Count();
                        int total = m / 4;
                        if (m % 4 > 0)
                        {
                            total++;
                        }
                        ui.Total = total;
                        response.Redirect(ui);
                    }
                    break;

                case "Dynamic":
                    {
                        var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectDynamic>();
                        subEntity.Where.And().Equal(new ProjectDynamic
                        {
                            project_id = project.Id
                        }).Entities.Order.Desc(new ProjectDynamic {
                            Time = 0
                        });

                        var subs = new List <ProjectDynamic>();
                        var uids = new List <Guid>();
                        subEntity.Query(start, limit, dr =>
                        {
                            subs.Add(dr);
                            uids.Add(dr.user_id ?? Guid.Empty);
                        });
                        var cates = new List <User>();
                        if (uids.Count > 0)
                        {
                            Utility.CMS.ObjectEntity <User>().Where.And().In(new User {
                                Id = uids[0]
                            }, uids.ToArray())
                            .Entities.Query(dr => cates.Add(dr));
                        }
                        foreach (var sub in subs)
                        {
                            var user2 = cates.Find(d => d.Id == sub.user_id) ?? new User();

                            var data = new WebMeta().Put("alias", user2.Alias, "desc", sub.Explain).Put("time", sub.Time)
                                       .Put("name", sub.Title)
                                       .Put("src", webr.ResolveUrl(sub.user_id ?? Guid.Empty, "1", 5));
                            var cell = UICell.Create("IconNameDesc", data);

                            cell.Format.Put("desc", "{alias} {time} {desc}");
                            cell.Style.Name("name").Size(14);
                            ui2.Add(cell);
                        }
                        ui.Total = subEntity.Count();
                        if (ui.Total == 0)
                        {
                            //   webr.

                            ui2.Add("Desc", new UMC.Web.WebMeta().Put("desc", "尚未有此项目动态").Put("icon", "\uF016")
                                    , new UMC.Web.WebMeta().Put("desc", "{icon}\n{desc}"), new UIStyle().Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60)));
                        }
                    }
                    break;
                }



                response.Redirect(ui);
                return(this.DialogValue("none"));
            });
            var user = Security.Identity.Current;

            if (user.IsAuthenticated == false)
            {
                this.Prompt("请登录", false);
                response.Redirect("Account", "Login");
            }
            if (project == null || project.user_id == user.Id)
            {
                switch (Model)
                {
                case "Icon":

                    response.Redirect("Design", "Picture", new WebMeta().Put("id", project.Id).Put("seq", 1), true);

                    break;

                case "Transfer":
                    var userId = Utility.Guid(this.AsyncDialog("Transfer", request.Model, "Member", new WebMeta().Put("Type", "Admin").Put("Project", project.Id))).Value;
                    this.AsyncDialog("Confirm", g => new UIConfirmDialog("你确认转移项目拥有者身份吗"));
                    Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project {
                        Id = project.Id
                    }).Entities
                    .Update(new Project {
                        user_id = userId
                    });
                    Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember {
                        user_id = userId, project_id = project.Id
                    })
                    .Entities.Update(new ProjectMember {
                        user_id = project.user_id, CreationTime = DateTime.Now, Alias = user.Alias
                    });

                    this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Project").Put("Id", project.Id).Put("Text", project.Caption)
                                      .Put("Code", project.Code), true);

                    break;
                }


                var Caption = this.AsyncDialog("Settings", d =>
                {
                    var fmdg   = new Web.UIFormDialog();
                    fmdg.Title = "编辑项目";
                    switch (Model)
                    {
                    case "News":
                        fmdg.Title = "新建项目";
                        fmdg.AddText("项目名称", "Caption", "");
                        fmdg.Submit("确认", request, "Subject.Project");
                        return(fmdg);

                    //break;
                    default:
                    case "Caption":
                        fmdg.Title = "项目名称";
                        fmdg.AddText("项目名称", "Caption", project.Caption);
                        break;

                    case "Description":
                        fmdg.Title = "项目介绍";
                        fmdg.AddText("项目介绍", "Description", project.Description);
                        break;

                    case "Code":
                        fmdg.Title = "项目简码";
                        fmdg.AddText("项目简码", "Code", project.Code).PlaceHolder("短小易记有助于访问和传播").Put("tip", "");
                        break;
                    }
                    fmdg.Submit("确认", request, "Subject.Project");
                    fmdg.AddUI("对接", "配置钉钉应用").Command(request.Model, "Dingtalk", project.Id.ToString());
                    fmdg.AddUI("对接", "配置钉钉机器人").Command(request.Model, "DDRobot", project.Id.ToString());
                    //fmdg.AddUI("对接", "配置钉钉机器人").Command(request.Model, request.Command, new WebMeta().Put("Id", project.Id.ToString(), "Model", "Transfer"));
                    return(fmdg);
                });
                var team = new Project();
                if (Model == "News")
                {
                    UMC.Data.Reflection.SetProperty(team, Caption.GetDictionary());
                    team.ModifiedTime = DateTime.Now;


                    team.Id           = Guid.NewGuid();
                    team.user_id      = user.Id;
                    team.Code         = Utility.Parse36Encode(team.Id.Value.GetHashCode());
                    team.CreationTime = DateTime.Now;
                    team.Sequence     = 0;


                    Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>().Insert(team);

                    var strt = UMC.Security.AccessToken.Current.Data["DingTalk-Setting"] as string;//, Utility.Guid(projectId)).Commit();
                    if (String.IsNullOrEmpty(strt) == false)
                    {
                        var userSetting = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectUserSetting>()
                                          .Where.And().Equal(new ProjectUserSetting {
                            Id = Utility.Guid(strt, true)
                        }).Entities.Single();

                        if (userSetting != null)
                        {
                            var setting2 = new ProjectSetting()
                            {
                                user_setting_id = userSetting.Id, project_id = team.Id, Type = 11
                            }; Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectSetting>().Insert(setting2);
                        }
                    }
                    Data.WebResource.Instance().Transfer(new Uri("https://oss.365lu.cn/UserResources/app/zhishi-icon.jpg"), team.Id.Value, 1);
                    var p = new ProjectItem()
                    {
                        Id           = Guid.NewGuid(),
                        Caption      = "Home",
                        Code         = Utility.Parse36Encode(Guid.NewGuid().GetHashCode()),
                        CreationTime = DateTime.Now,
                        project_id   = team.Id,
                        Sequence     = 0,
                        user_id      = user.Id,
                    };
                    Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectItem>()
                    .Insert(p);

                    var portfolio = new Portfolio()
                    {
                        Id              = Guid.NewGuid(),
                        Caption         = "随笔",
                        Count           = 0,
                        CreationTime    = DateTime.Now,
                        Sequence        = 0,
                        user_id         = user.Id,
                        project_id      = team.Id,
                        project_item_id = p.Id,
                    };
                    Utility.CMS.ObjectEntity <UMC.Data.Entities.Portfolio>()
                    .Insert(portfolio);

                    Utility.CMS.ObjectEntity <ProjectDynamic>()
                    .Insert(new ProjectDynamic
                    {
                        Time       = Utility.TimeSpan(),                         //DateTime.Now,
                        user_id    = user.Id,
                        Explain    = "创建了项目",
                        project_id = team.Id,
                        refer_id   = team.Id,
                        Title      = team.Caption,
                        Type       = DynamicType.Project
                    });

                    this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Project").Put("id", team.Id).Put("text", team.Caption)
                                      .Put("code", team.Code), true);
                }
                UMC.Data.Reflection.SetProperty(team, Caption.GetDictionary());
                if (String.IsNullOrEmpty(team.Code) == false)
                {
                    if (team.Code.Length < 3)
                    {
                        this.Prompt("项目简码必须大于3个字符");
                    }
                    if (System.Text.RegularExpressions.Regex.IsMatch(team.Code, "^\\d+$") == true)
                    {
                        this.Prompt("项目简码不能全是数字");
                    }
                    if (System.Text.RegularExpressions.Regex.IsMatch(team.Code, "^\\w+$") == false)
                    {
                        this.Prompt("项目简码只能是字符和数字");
                    }
                    if (String.Equals(team.Code, project.Code, StringComparison.CurrentCulture) == false)
                    {
                        if (Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>()
                            .Where.And().Equal(new Project
                        {
                            Code = team.Code
                        }).Entities.Count() > 0)
                        {
                            this.Prompt("存在相同的简码");
                        }
                    }
                }

                team.ModifiedTime = DateTime.Now;
                var objectEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>();
                objectEntity.Where.And().Equal(new Project
                {
                    Id = project.Id
                });
                objectEntity.Update(team);
                this.Prompt("修改成功", false);
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Project").Put("id", project.Id).Put("text", team.Caption ?? project.Caption).Put("code", team.Code ?? project.Code), true);
            }
        }
コード例 #9
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var strId = this.AsyncDialog("Id", g =>
            {
                return(new Web.UITextDialog()
                {
                    Title = "主题"
                });
            });
            var form = request.SendValues ?? new UMC.Web.WebMeta();

            var sid = UMC.Data.Utility.Guid(strId, true);
            var seq = Utility.IntParse(this.AsyncDialog("Seq", g =>
            {
                return(this.DialogValue("0"));
            }), 0);
            var webr = UMC.Data.WebResource.Instance();
            var Url  = this.AsyncDialog("Url", gK =>
            {
                if (form.ContainsKey("limit") == false)
                {
                    this.Context.Send(new UISectionBuilder(request.Model, request.Command, request.Arguments)

                                      .CloseEvent("image")
                                      .Builder(), true);
                }

                var args = request.Arguments.GetDictionary();

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

                int start     = UMC.Data.Utility.IntParse(form["start"] as string, 0);
                var ui        = UISection.Create();
                var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>();
                subEntity.Where.And().Equal(new UMC.Data.Entities.Subject {
                    Id = sid
                });

                var title = new UITitle("正文图片");
                //title.Float();
                ui.Title = title;

                var items  = new List <WebMeta>();
                var domain = webr.WebDomain();


                var su2bs = subEntity.Single() ?? new UMC.Data.Entities.Subject {
                    Id = sid
                };

                var celss = UMC.Data.JSON.Deserialize <WebMeta[]>((String.IsNullOrEmpty(su2bs.DataJSON) ? "[]" : su2bs.DataJSON)) ?? new UMC.Web.WebMeta[] { };
                foreach (var pom in celss)
                {
                    switch (pom["_CellName"])
                    {
                    case "CMSImage":
                        var value = pom.GetMeta("value");
                        var src   = value["src"];
                        if (String.IsNullOrEmpty(src) == false)
                        {
                            if (src.StartsWith(domain) || src.StartsWith("http://www.365lu.cn") || src.StartsWith("https://www.365lu.cn") || src.StartsWith("https://oss.") || src.StartsWith("http://oss.")
                                )
                            {
                                var ind = src.IndexOf("!");
                                if (ind > 0)
                                {
                                    src = src.Substring(0, ind);
                                }
                                items.Add(new UMC.Web.WebMeta().Put("src", src + "!200").Put("click", new Web.UIClick(new UMC.Web.WebMeta(args).Put(gK, src))
                                {
                                    Model   = request.Model,
                                    Command = request.Command
                                }));
                            }
                        }

                        break;
                    }
                }
                if (items.Count > 0)
                {
                    var nine = new UMC.Web.WebMeta().Put("images", items);
                    ui.NewSection().Add(UICell.Create("NineImage", nine));
                }
                else
                {
                    ui.Add("Desc", new UMC.Web.WebMeta().Put("desc", "图文未有图片或图片非本站").Put("icon", "\uF016"), new UMC.Web.WebMeta().Put("desc", "{icon}\n{desc}"),

                           new UIStyle().Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60)));
                }
                //ui.AddCells(celss); ;

                response.Redirect(ui);
                return(this.DialogValue("none"));
            });

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

            entity.Where.And().Equal(new UMC.Data.Entities.Picture {
                Seq = seq, group_id = sid
            });
            var pic  = entity.Single();
            var user = UMC.Security.Identity.Current;

            if (pic == null)
            {
                pic = entity.Where.Reset().And().Equal(new Picture {
                    group_id = sid
                }).Entities.Max(new Picture {
                    Seq = 0
                });                                                                                                          //.Seq + 1;
                pic.Seq = (pic.Seq ?? 0) + 1;
                var photo = new UMC.Data.Entities.Picture
                {
                    group_id   = sid,
                    Seq        = pic.Seq,
                    user_id    = user.Id,
                    UploadDate = DateTime.Now
                };
                entity.Insert(photo);
            }
            else
            {
                entity.Update(new UMC.Data.Entities.Picture
                {
                    Location   = request.UserHostAddress,
                    UploadDate = DateTime.Now,
                    user_id    = user.Id
                });
            }
            webr.Transfer(new Uri(Url), sid.Value, pic.Seq ?? 1);
            this.Context.Send("image", true);
        }
コード例 #10
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            switch (request.SendValue)
            {
            case "AnimImage":

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

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


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

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

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

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

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

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

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

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

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

            var footer = new UIFootBar();

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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


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

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

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

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

            ui.Add(v);

            var uiitems = new UIItems();

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

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

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

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

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

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

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

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

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

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

            button.Button(new UIEventText("安装").Badge("1d"));
            button.Style.AlignCenter();
            ui.NewSection().Add(button);
            ui.Title.Right(new UIEventText('\uf2e1', "33d").Click(new UIClick()
            {
                Key = "Float"
            }));                                                                                    //.Badge("21"));
            response.Redirect(ui);
        }
コード例 #11
0
        void Check(string text)
        {
            int index = 0;

            while (index < text.Length)
            {
                if (index + 1 >= text.Length)
                {
                    Append();
                    return;
                }
                switch (text[index])
                {
                case '#':
                {
                    int end = text.IndexOf('\n', index);
                    if (end > index)
                    {
                        Header(text.Substring(index, end - index));

                        index = end + 1;
                    }
                    else
                    {
                        Header(text.Substring(index));
                        index = text.Length;
                    }
                    continue;
                }

                case '`':
                {
                    if (text.Substring(index, 3) == "```")
                    {
                        int end = text.IndexOf("\n```", index + 1);
                        if (end > index)
                        {
                            String content = text.Substring(index, end - index);
                            var    hindex  = content.IndexOf('\n');
                            var    htype   = content.Substring(3, hindex - 3).Trim();
                            content = content.Substring(hindex + 1);

                            var cell = UICell.Create("CMSCode", new WebMeta().Put("code", content).Put("type", htype));

                            cell.Format.Put("text", "{code}");


                            cells.Add(cell);
                            index = text.IndexOf('\n', end + 1) + 1;

                            continue;
                        }
                    }
                }
                break;

                case '>':
                {
                    if (cells.Count > 0)
                    {
                        var cell = cells[cells.Count - 1];
                        if (cell.Type == "CMSRel")
                        {
                            var d = cell.Data as WebMeta;

                            cells.RemoveAt(cells.Count - 1);
                            this.data = d;
                            this.dataText.Append("\r\n");
                            this.style = cell.Style;
                            this.data.Put("type", "CMSRel");
                            index = CheckRow(text, index + 1);
                            continue;
                        }
                    }
                    this.data.Put("type", "CMSRel");
                    index = CheckRow(text, index + 1);
                    continue;
                }

                case '|':
                {
                    int end = text.IndexOf('\n', index);
                    if (end > index)
                    {
                        var    grids  = new List <String>();
                        String conent = text.Substring(index, end - index).Trim().Replace(" ", "");
                        if (conent[conent.Length - 1] == '|')
                        {
                            int    end2    = text.IndexOf('\n', end + 1);  //.Trim();
                            String conent2 = text.Substring(end + 1, end2 - end - 1).Trim();
                            grids.Add(conent);
                            conent2 = conent2.Replace(" ", "");

                            if (System.Text.RegularExpressions.Regex.IsMatch(conent2, "^[\\|:-]+$"))
                            {
                                grids.Add(conent2);
                                if (conent2.Split('|').Length == conent.Split('|').Length)
                                {
                                    bool isGO = true;
                                    while (isGO)
                                    {
                                        isGO = false;
                                        int end3 = text.IndexOf('\n', end2 + 1);


                                        String conent3 = end3 > 0 ? text.Substring(end2 + 1, end3 - end2 - 1).Trim() : text.Substring(end2 + 1).Trim();
                                        if (conent3.StartsWith("|") && conent3.EndsWith("|"))
                                        {
                                            isGO = true;
                                            grids.Add(conent3);
                                            end2 = end3 > 0 ? end3 : text.Length - 1;
                                        }
                                    }
                                    this.Grid(grids);
                                    index = end2 + 1;
                                    continue;
                                }
                            }
                        }
                    }
                }
                break;

                case '[':
                {
                    int end = text.IndexOf("]", index + 1);
                    if (end > index && end + 1 < text.Length)
                    {
                        if (text[end + 1] == ':')
                        {
                            String content = text.Substring(index, end - index).Trim('[', ']');
                            if (content.IndexOf('\n') == -1)
                            {
                                int end2 = text.IndexOf("\n", end + 1);
                                if (end2 == -1)
                                {
                                    var url = text.Substring(end + 2).Trim().Trim(' ', '(', ')').Split(' ')[0];
                                    webRel.Put(content, url);
                                }
                                else
                                {
                                    var url = text.Substring(end + 2, end2 - end - 2).Trim().Trim(' ', '(', ')').Split(' ')[0];
                                    webRel.Put(content, url);
                                    //Check(text, end2 + 1);

                                    index = end2 + 1;
                                }
                                continue;
                            }
                        }
                    }
                }
                break;

                case ' ':
                    while (text.Length > index && text[index] == ' ')
                    {
                        index++;
                    }
                    break;
                }

                index = this.CheckRow(text, index);
            }
        }
コード例 #12
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);
        }
コード例 #13
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            Guid designId = UMC.Data.Utility.Guid(this.AsyncDialog("Id", g => this.DialogValue(Guid.Empty.ToString()))).Value;//this.DialogValue(response.Ticket[AttributeNames.TICKET_STORE_ID])), true).Value;


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

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

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

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

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

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

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


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

                        default:
                            new UIDesigner(true).Section(section, headers[0].Id.Value);
                            break;
                        }
                    }
                    else
                    {
                        new UIDesigner(true).Section(section, designId);
                    }
                    if (section.Length == 0)
                    {
                        section.Add("Desc", new UMC.Web.WebMeta().Put("desc", "未有设计分类项,请添加").Put("icon", "\uEA05")
                                    , new UMC.Web.WebMeta().Put("desc", "{icon}\n{desc}"),
                                    new UIStyle().Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60)));
                    }
                    UIFooter footer = new UIFooter();
                    footer.IsFixed  = true;// e);

                    switch (headers.Length)
                    {
                    case 0:

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

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


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


                        break;
                    }


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

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

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

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

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

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


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

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

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

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

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


                    chash.Add("sections", tabs);
                    chash.Add("title", title);
                    response.Redirect(chash);
                }
                else
                {
                    UIDesigner designer = new UIDesigner(false);
                    response.Redirect(designer.Section("", designId));
                }
            }
        }
コード例 #14
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var ProjectId = Utility.Guid(this.AsyncDialog("Id", g =>
            {
                this.Prompt("请输入项目");

                return(this.DialogValue("Project"));
            })) ?? Guid.Empty;

            UISection ui      = null;
            var       project = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project {
                user_id = ProjectId
            }).Entities.Single();

            //var svs = request.SendValues ?? new UMC.Web.WebMeta();
            var form    = (request.SendValues ?? new UMC.Web.WebMeta()).GetDictionary();
            int start   = UMC.Data.Utility.IntParse(form["start"] as string, 0);
            var nextKey = this.AsyncDialog("NextKey", g => this.DialogValue("Header"));;

            if (start == 0 && String.Equals(nextKey, "Header"))
            {
                var logoUrl = UMC.Data.WebResource.Instance().ResolveUrl(String.Format("{0}{1}/1/0.jpg!200", UMC.Data.WebResource.ImageResource, project.Id));

                //    var mcode = "您未登录";

                var members = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>()
                              .Where.And().Equal(new Data.Entities.ProjectMember {
                    project_id = project.Id
                })
                              .Entities.Count() + 1;
                var subs = Utility.CMS.ObjectEntity <Subject>().Where.And().Equal(new Data.Entities.Subject {
                    project_id = project.Id
                }).Entities.Count();


                //Sections.Add(cmsText);

                String mcode = String.Format("成员 {0} 图文 {1}", members, subs);

                var Discount = new UIHeader.Profile(project.Caption, mcode, logoUrl);


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

                title.Title = "项目介绍";
                header.AddProfile(Discount, "{number}", "{amount}");


                ui = UISection.Create(header, title);
                if (String.IsNullOrEmpty(project.Description) == false)
                {
                    var cmsText = UICell.Create("CMSText", new UMC.Web.WebMeta().Put("text", project.Description));
                    cmsText.Style.Size(14).Color(0x999);
                }
            }
            else
            {
                ui = UISection.Create();
            }
            var items = new List <WebMeta>();

            items.Add(new UMC.Web.WebMeta().Put("text", "文章", "search", "Subs"));
            items.Add(new UMC.Web.WebMeta().Put("text", "成员", "search", "Member"));
            items.Add(new UMC.Web.WebMeta().Put("text", "动态", "search", "Dynamic"));
            int limit       = UMC.Data.Utility.IntParse(form["limit"] as string, 25);
            var selectIndex = UMC.Data.Utility.IntParse(this.AsyncDialog("selectIndex", g => this.DialogValue("0")), 0);
            var webr        = UMC.Data.WebResource.Instance();

            switch (selectIndex)
            {
            case 0:
            {
                var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>();
                subEntity.Order.Desc(new Subject {
                        ReleaseDate = DateTime.Now
                    });
                subEntity.Where.And().Equal(new Data.Entities.Subject {
                        Status = 1, IsDraught = false, project_id = project.Id
                    });
                SubjectUIActivity.Search(ui, subEntity, start, limit);
                response.Redirect(ui);
            }
            break;

            case 1:
            {
                int mlimit    = limit * 4;
                int mstart    = start * 4;
                var ids       = new List <Guid>();
                var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>();
                subEntity.Order.Desc(new ProjectMember {
                        CreationTime = DateTime.Now
                    });
                subEntity.Query(mstart, mlimit, dr => ids.Add(dr.user_id.Value));
                if (mstart == 0)
                {
                    ids.Add(project.user_id.Value);
                }
                if (ids.Count > 0)
                {
                    var users = new List <User>();
                    UMC.Data.Database.Instance().ObjectEntity <User>()
                    .Where.And().In(new User {
                            Id = ids[0]
                        }, ids.ToArray()).Entities.Query(dr => users.Add(dr));

                    var icons = new List <UIEventText>();
                    foreach (var v in users)
                    {
                        icons.Add(new UIEventText(v.Alias).Src(webr.ResolveUrl(v.Id.Value, "1", "4")));

                        if (icons.Count % 4 == 0)
                        {
                            ui.AddIcon(icons.ToArray());
                            icons.Clear();
                        }
                    }
                    if (icons.Count > 0)
                    {
                        ui.AddIcon(icons.ToArray());
                    }
                }
                var m     = subEntity.Count();
                int total = m / 4;
                if (m % 4 > 0)
                {
                    total++;
                }
                ui.Total = total;
                response.Redirect(ui);
            }
            break;

            case 2:
            {
                var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectDynamic>();
                subEntity.Where.And().Equal(new ProjectDynamic
                    {
                        project_id = project.Id
                    }).Entities.Order.Desc(new ProjectDynamic {
                        Time = DateTime.MinValue
                    });

                var subs = new List <ProjectDynamic>();
                var uids = new List <Guid>();
                subEntity.Query(start, limit, dr =>
                    {
                        subs.Add(dr);
                        uids.Add(dr.user_id ?? Guid.Empty);
                    });
                var cates = new List <User>();
                if (uids.Count > 0)
                {
                    UMC.Data.Database.Instance().ObjectEntity <User>().Where.And().In(new User {
                            Id = uids[0]
                        }, uids.ToArray())
                    .Entities.Query(dr => cates.Add(dr));
                }
                foreach (var sub in subs)
                {
                    var sType = "成员动态";
                    switch (sub.Type)
                    {
                    case DynamicType.Member:
                        break;

                    case DynamicType.Portfolio:
                        sType = "文集动态";
                        break;

                    case DynamicType.Project:
                        sType = "项目动态";
                        break;

                    case DynamicType.Subject:
                        sType = "文档动态";
                        break;

                    case DynamicType.ProjectItem:
                        sType = "栏位动态";
                        break;
                    }
                    //



                    var user2 = cates.Find(d => d.Id == sub.user_id) ?? new User();

                    var data = new WebMeta().Put("alias", user2.Alias, "type", sType, "desc", sub.Explain).Put("time", sub.Time)
                               .Put("title", sub.Title);
                    var cell = UIImageTitleBottom.Create(webr.ResolveUrl(sub.user_id ?? Guid.Empty, "1", 5), data);

                    cell.Format.Put("left", "{alias} {time} {desc}").Put("right", "{type}");
                    cell.Style.Name("image-radius", 30);
                    ui.Add(cell);
                    //data.Rows.Add(sub.user_id, sub.Title, sub.Explain, sub.Time, sType, webr.ResolveUrl(sub.user_id ?? Guid.Empty, "1", 5),
                    //user2.Alias);
                }
                ui.Total = subEntity.Count();
            }
            break;
            }



            //var appKey = UMC.Security.Principal.Current.AppKey ?? Guid.Empty;


            //var li = ui.NewSection();// UIClick.Pager("Member", "Order", new WebADNuke.Web.WebMeta().Put("type", "App", "selectIndex", "0"))
            //li.AddCell("我的订单", "查看全部", UIClick.Pager("Member", "Order", new UMC.Web.WebMeta().Put("type", "App", "selectIndex", "0")));
            //li.AddCell("我的佣金", "", new Web.UIClick() { Command = "Commission", Model = "Member" });
            //li.AddCell("我的收藏", new Web.UIClick() { Command = "Favs", Model = request.Model });
            //li.AddCell("我的优惠券", new Web.UIClick() { Command = "Coupons", Model = "Member" });
            //if (appKey == Guid.Empty)
            //{

            //    var cate = Utility.CMS.ObjectEntity<UMC.Data.Entities.Category>().Where.And().Equal(new Data.Entities.Category { user_id = user.Id })
            //          .Entities.Count();
            //    if (cate > 0)
            //    {
            //        li.NewSection().AddCell("我的版务", new Web.UIClick() { Command = "Apply", Model = "Subject" });

            //    }
            //    li.AddCell("我的图文", new Web.UIClick() { Command = "Self", Model = "Subject" });
            //    li.NewSection().AddCell("积分政策", UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "Subject.Points")));
            //}
            //else
            //{
            //li.AddCell("我的图文", new Web.UIClick() { Command = "Self", Model = "Subject" });
            //li.NewSection().AddCell("卡券分享", "被领取即可获的收益", UIClick.Pager("Corp", "Coupons"));
            ////}


            //if (request.IsApp)
            //{
            //    ui.NewSection().AddCell('\uf083', "扫一扫", "", new Web.UIClick() { Key = "Scanning" });
            //    //.AddCell('\uf0c5', "软文转码", "将检测粘贴板", new Web.UIClick() { Key = "CaseCMS" });
            //    ui.NewSection()
            //        //.AddCell('\uf19c', "切换企业", "", Web.UIClick.Pager("Platform", "Corp", true))
            //        .AddCell('\uf013', "设置", "", Web.UIClick.Pager("UI", "Setting", true, "Close"));


            //}
            //else
            //{
            //    ui.NewSection()
            //        .AddCell('\uf013', "设置", "", Web.UIClick.Pager("UI", "Setting", true, "Close"));

            //}

            response.Redirect(ui);


            //}
        }
コード例 #15
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var identity = UMC.Security.Identity.Current;
            var userId   = Utility.Guid(this.AsyncDialog("Id", g =>
            {
                if (identity.IsAuthenticated == false)
                {
                    response.Redirect("Account", "Login");
                }
                return(this.DialogValue(identity.Id.ToString()));
            }), true);

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

            if (form.ContainsKey("limit") == false)
            {
                var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments);
                this.Context.Send(buider.Builder(), true);
            }
            int       start = UMC.Data.Utility.IntParse(form["start"] as string, 0);
            UISection ui, ui2;
            var       selectIndex = UMC.Data.Utility.IntParse(this.AsyncDialog("selectIndex", g => this.DialogValue("0")), 0);

            var items = new List <WebMeta>();

            items.Add(new UMC.Web.WebMeta().Put("text", "知识录", "search", "Subs", "Key", "List"));
            items.Add(new UMC.Web.WebMeta().Put("text", "参与项目", "search", "Project", "Key", "List"));
            items.Add(new UMC.Web.WebMeta().Put("text", "个人动态", "search", "Dynamic", "Key", "List"));

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

            if (String.IsNullOrEmpty(Keyword) && selectIndex > -1)
            {
                Keyword = items[selectIndex]["search"];
            }
            var nextKey = this.AsyncDialog("NextKey", g => this.DialogValue("Header"));;

            if (start == 0 && String.Equals(nextKey, "Header"))
            {
                var sign = Utility.CMS.ObjectEntity <Data.Entities.Account>()
                           .Where.And().Equal(new Data.Entities.Account {
                    user_id = userId, Type = Security.Account.SIGNATURE_ACCOUNT_KEY
                }).Entities.Single();

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

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

                var suject =
                    Utility.CMS.ObjectEntity <Subject>()
                    .Where.And().Equal(new Subject {
                    user_id = userId
                })
                    .Entities.GroupBy().Sum(new Subject {
                    Reply = 0
                })
                    .Sum(new Subject {
                    Look = 0
                }).Count(new Subject {
                    Seq = 0
                }).Single();



                var Discount = new UIHeader.Portrait(logoUrl);

                ;
                var user = identity.Id == userId ? new User {
                    Id = identity.Id, Alias = identity.Alias
                } : Utility.CMS.ObjectEntity <Data.Entities.User>()
                .Where.And().Equal(new Data.Entities.User {
                    Id = userId
                }).Entities.Single();
                if (user != null)
                {
                    Discount.Value(user.Alias);
                }
                else
                {
                    var member = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>()
                                 .Where.And().Equal(new Data.Entities.ProjectMember {
                        user_id = userId
                    })
                                 .Entities.Single();
                    if (member != null)
                    {
                        Discount.Value(member.Alias);
                    }
                }

                if (sign != null)
                {
                    Discount.Time(sign.Name);// user.ActiveTime.ToString());
                }
                var color = 0x63b359;
                Discount.Gradient(color, color);
                var header = new UIHeader();
                var title  = UITitle.Create();

                title.Title = identity.Id == userId ? "我的知识录" : "成员详情";
                header.AddPortrait(Discount);

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

                ui = UISection.Create(header, title);


                var uIIcon = new UIIconNameDesc(new UIIconNameDesc.Item('\uF02d', "知识创作", suject.Seq + "篇").Color(0x36a3f7), new UIIconNameDesc.Item('\uF19d', "关注项目", members + "项").Color(0x40c9c6));
                ui.Add(uIIcon);

                ui2 = ui.NewSection();
            }
            else
            {
                ui2 = ui = UISection.Create();
            }
            ui2.Key = "List";
            if (start == 0 && String.Equals(nextKey, "Self") == false)
            {
                if (selectIndex > 0)
                {
                    ui2.Add(UICell.Create("TabFixed", new UMC.Web.WebMeta().Put("items", items).Put("selectIndex", selectIndex)));
                }
                else
                {
                    ui2.Add(UICell.Create("TabFixed", new UMC.Web.WebMeta().Put("items", items)));;
                }
            }

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

            switch (Keyword)
            {
            default:
            case "Subs":
            {
                var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>();
                subEntity.Order.Desc(new Subject {
                        ReleaseDate = DateTime.Now
                    });
                subEntity.Where.And().Equal(new Data.Entities.Subject {
                        Status = 1, IsDraught = false, user_id = userId
                    });
                subEntity.Where.And().Greater(new Subject {
                        Visible = -1
                    });
                SubjectUIActivity.Search(request.Model, ui2, subEntity, start, limit);

                if (ui2.Total == 0)
                {
                    ui2.Add("Desc", new UMC.Web.WebMeta().Put("desc", "尚未有知识资讯").Put("icon", "\uF016")
                            , new UMC.Web.WebMeta().Put("desc", "{icon}\n{desc}"), new UIStyle().Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60)));
                }
            }
            break;

            case "Project":
            {
                var ids       = new List <Guid>();
                var subMebs   = new List <ProjectMember>();
                var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>();
                subEntity.Where.And().Equal(new ProjectMember {
                        user_id = userId
                    });
                subEntity.Order.Desc(new ProjectMember {
                        AuthType = 0
                    }).Desc(new ProjectMember {
                        CreationTime = DateTime.Now
                    });;
                subEntity.Query(start, limit, dr =>
                    {
                        ids.Add(dr.project_id.Value);
                        subMebs.Add(dr);
                    });


                var proEntity = Utility.CMS.ObjectEntity <Project>();
                if (start == 0)
                {
                    proEntity.Where.And().Equal(new Project {
                            user_id = userId
                        });
                }
                if (ids.Count > 0)
                {
                    proEntity.Where.Or().In(new Project {
                            Id = ids[0]
                        }, ids.ToArray());
                }
                var projects = new List <Project>();
                var pids     = new List <Guid>();
                proEntity.Query(dr =>
                    {
                        projects.Add(dr);
                        pids.Add(dr.Id.Value);
                    });

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


                    if (start == 0)
                    {
                        var mp = projects.FindAll(p => p.user_id == userId);

                        foreach (var p in mp)
                        {
                            var sub    = subs.Find(s => s.project_id == p.Id);
                            var cellUI = new UIIconNameDesc(new UIIconNameDesc.Item(webr.ResolveUrl(p.Id.Value, "1", "4"), p.Caption,
                                                                                    String.Format("知识{0}篇", sub == null ? 0 : sub.Seq))
                                                            .Click(request.IsApp ? UIClick.Pager(request.Model, "ProjectUI", new WebMeta().Put("Id", p.Id), true) : new UIClick(p.Id.ToString()).Send(request.Model, "ProjectUI")));

                            cellUI.Button("创立人", null, 0xccc);

                            //
                            ui2.Add(cellUI);
                        }
                        subMebs.RemoveAll(d => mp.Exists(p => p.Id == d.project_id));
                        //if(mp!=nul)
                    }
                    foreach (var vd in subMebs)
                    {
                        var p = projects.Find(u => u.Id == vd.project_id);
                        if (p == null)
                        {
                            continue;
                        }

                        var sub = subs.Find(s => s.project_id == p.Id);

                        var cellUI = new UIIconNameDesc(new UIIconNameDesc.Item(webr.ResolveUrl(p.Id.Value, "1", "4"), p.Caption,
                                                                                String.Format("知识{0}篇", sub == null ? 0 : sub.Seq))
                                                        .Click(request.IsApp ? UIClick.Pager(request.Model, "ProjectUI", new WebMeta().Put("Id", p.Id), true) : new UIClick(p.Id.ToString()).Send(request.Model, "ProjectUI")));
                        switch (vd.AuthType)
                        {
                        case WebAuthType.Admin:
                            cellUI.Button("管理员", null, 0xccc);
                            break;

                        case WebAuthType.User:
                            cellUI.Button("专栏作家", null, 0xccc);
                            break;
                        }
                        //
                        ui2.Add(cellUI);
                    }
                }
                var m     = subEntity.Count();
                int total = m;

                ui.IsNext = total > start + limit;
                if (start == 0 && ids.Count == 0 && pids.Count == 0)
                {
                    ui2.Add("Desc", new UMC.Web.WebMeta().Put("desc", "尚未有参与项目").Put("icon", "\uF016")
                            , new UMC.Web.WebMeta().Put("desc", "{icon}\n{desc}"), new UIStyle().Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60)));
                }
                response.Redirect(ui);
            }
            break;

            case "Dynamic":
            {
                var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectDynamic>();
                subEntity.Where.And().Equal(new ProjectDynamic
                    {
                        user_id = userId
                    }).Entities.Order.Desc(new ProjectDynamic {
                        Time = 0
                    });

                var subs = new List <ProjectDynamic>();
                var uids = new List <Guid>();
                subEntity.Query(start, limit, dr =>
                    {
                        subs.Add(dr);
                        uids.Add(dr.project_id ?? Guid.Empty);
                    });
                var cates = new List <Project>();
                if (uids.Count > 0)
                {
                    Utility.CMS.ObjectEntity <Project>().Where.And().In(new Project {
                            Id = uids[0]
                        }, uids.ToArray())
                    .Entities.Query(dr => cates.Add(dr));
                }
                foreach (var sub in subs)
                {
                    var user2 = cates.Find(d => d.Id == sub.user_id) ?? new Project();

                    var data = new WebMeta().Put("alias", user2.Caption, "desc", sub.Explain).Put("time", Utility.TimeSpan(sub.Time ?? 0))
                               .Put("name", sub.Title)
                               .Put("src", webr.ResolveUrl(sub.project_id ?? Guid.Empty, "1", 5));
                    data.Put("click", new UIClick(new WebMeta().Put("Id", sub.user_id).Put("Time", sub.Time)).Send(request.Model, "Dynamic"));
                    var cell = UICell.Create("IconNameDesc", data);

                    cell.Format.Put("desc", "{alias} {time} {desc}");
                    cell.Style.Name("name").Size(14);
                    ui2.Add(cell);
                }
                ui.Total = subEntity.Count();
                if (ui.Total == 0)
                {
                    ui2.Add("Desc", new UMC.Web.WebMeta().Put("desc", "尚未有个人动态").Put("icon", "\uF016")
                            , new UMC.Web.WebMeta().Put("desc", "{icon}\n{desc}"), new UIStyle().Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60)));
                }
            }
            break;
            }



            response.Redirect(ui);
        }
コード例 #16
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var Type = this.AsyncDialog("Type", "Client");
            var user = UMC.Security.Identity.Current;

            switch (Type)
            {
            case "Client":
                if (user.IsAuthenticated == false)
                {
                    response.Redirect(request.Model, "Login");
                }
                break;

            case "Cashier":
                if (request.IsCashier == false)
                {
                    response.Redirect("Settings", "Login");
                }

                break;
            }
            var Model = this.AsyncDialog("Model", gkey =>
            {
                WebMeta form = request.SendValues ?? new UMC.Web.WebMeta();

                if (form.ContainsKey("limit") == false)
                {
                    this.Context.Send(new UISectionBuilder(request.Model, request.Command, request.Arguments)
                                      .RefreshEvent("UI.Setting", "image", "Email", "Mobile")
                                      .Builder(), true);
                }
                var account = Security.Account.Create(user.Id.Value);
                var dic     = UMC.Web.UISection.Create();
                var name    = user.Name;
                switch (Type)
                {
                default:
                    dic.Title         = new UITitle("账户信息");
                    var imageTextView = new UMC.Web.UI.UIImageTextValue(Data.WebResource.Instance().ImageResolve(user.Id.Value, "1", 4), "头像", "");
                    imageTextView.Style.Name("image-width", "100");
                    imageTextView.Click(new UIClick("id", user.Id.ToString(), "seq", "1")
                    {
                        Model = "Design", Command = "Picture"
                    });
                    //dic.AddImageTextValue(Data.WebResource.Instance().ImageResolve(user.Id.Value, "1", 4), "头像", 100, new UIClick("id", user.Id.ToString(), "seq", "1")
                    //{ Model = "Design", Command = "Picture" });
                    dic.Add(imageTextView);

                    dic.AddCell("昵称", user.Alias, new UIClick(new WebMeta(request.Arguments).Put(gkey, "Alias")).Send(request.Model, request.Command));


                    dic.AddCell('\uf084', "登录账号", name, new UIClick()
                    {
                        Model = "Account", Command = "Password"
                    });
                    break;

                case "Small":

                    var Discount = new UIHeader.Portrait(Data.WebResource.Instance().ImageResolve(user.Id.Value, "1", 4));


                    Discount.Value(user.Alias);

                    var ac2 = account[Security.Account.SIGNATURE_ACCOUNT_KEY];
                    Discount.Time(ac2 == null ? "未有签名" : ac2.Name);

                    var color = 0xfff;
                    Discount.Gradient(color, color);
                    Discount.Click(new UIClick("id", user.Id.ToString(), "seq", "1")
                    {
                        Model = "Design", Command = "Picture"
                    });
                    var header = new UIHeader();

                    var style = new UIStyle();
                    header.AddPortrait(Discount);
                    header.Put("style", style);

                    style.Name("value").Color(0x111).Size(18).Click(new UIClick(new WebMeta(request.Arguments).Put(gkey, "Alias")).Send(request.Model, request.Command));
                    style.Name("time").Click(new UIClick(new WebMeta(request.Arguments).Put(gkey, "Signature")).Send(request.Model, request.Command));

                    dic.UIHeader = header;

                    break;
                }



                var ac = account[Security.Account.EMAIL_ACCOUNT_KEY];
                if (ac != null && String.IsNullOrEmpty(ac.Name) == false)
                {
                    name = ac.Name;

                    int c = name.IndexOf('@');
                    if (c > 0)
                    {
                        var cname = name.Substring(0, c);
                        name      = name.Substring(0, 2) + "***" + name.Substring(c);
                    }
                    if ((ac.Flags & Security.UserFlags.UnVerification) == Security.UserFlags.UnVerification)
                    {
                        name = name + "(未验证)";
                    }
                }
                else
                {
                    name = "点击绑定";
                }

                var cui = Type == "Small" ? dic : dic.NewSection();

                cui.AddCell('\uf199', "邮箱", name, new UIClick()
                {
                    Command = "Email", Model = "Account"
                });

                ac = account[Security.Account.MOBILE_ACCOUNT_KEY];
                if (ac != null && String.IsNullOrEmpty(ac.Name) == false)
                {
                    name = ac.Name;
                    if (name.Length > 3)
                    {
                        name = name.Substring(0, 3) + "****" + name.Substring(name.Length - 3);
                    }
                    if ((ac.Flags & Security.UserFlags.UnVerification) == Security.UserFlags.UnVerification)
                    {
                        name = name + "(未验证)";
                    }
                }
                else
                {
                    name = "点击绑定";
                }

                cui.AddCell('\ue91a', "手机号码", name, new UIClick()
                {
                    Command = "Mobile", Model = "Account"
                });

                switch (Type)
                {
                case "Small":
                    response.Redirect(dic);
                    break;

                default:
                    ac = account[Security.Account.SIGNATURE_ACCOUNT_KEY];
                    dic.NewSection().AddCell("个性签名", ac == null ? "未有签名" : ac.Name, new UIClick(new WebMeta(request.Arguments).Put(gkey, "Signature")).Send(request.Model, request.Command));

                    break;
                }


                if (request.IsApp == false && request.IsWeiXin == false)
                {
                    UICell cell = UICell.Create("UI", new UMC.Web.WebMeta().Put("text", "退出登录").Put("Icon", "\uf011").Put("click", new UIClick()
                    {
                        Model = "Account", Command = "Close"
                    }));
                    cell.Style.Name("text", new UIStyle().Color(0xf00));
                    dic.NewSection().NewSection().Add(cell);
                }


                response.Redirect(dic);
                return(this.DialogValue("none"));
            });

            switch (Model)
            {
            case "Alias":
                String Alias = this.AsyncDialog("Alias", a => new UITextDialog()
                {
                    Title = "修改别名", DefaultValue = user.Alias
                });
                Membership.Instance().ChangeAlias(user.Name, Alias);
                this.Prompt(String.Format("您的账户的别名已修改成{0}", Alias), false);
                this.Context.Send("UI.Setting", true);


                break;

            case "Signature":

                var account = Security.Account.Create(user.Id.Value);


                var ac    = account[Security.Account.SIGNATURE_ACCOUNT_KEY];
                var reset = Web.UIFormDialog.AsyncDialog("value", g =>
                {
                    var selt   = new Web.UIFormDialog();
                    selt.Title = "个性签名";
                    selt.AddTextarea("个性签名", "Signature", ac == null ? "" : ac.Name);
                    selt.Submit("确认提交", request, "UI.Setting");
                    return(selt);
                });
                var Signature = reset["Signature"];
                Security.Account.Post(Signature, user.Id.Value, Security.UserFlags.Normal, Security.Account.SIGNATURE_ACCOUNT_KEY);



                WebMeta print = new UMC.Web.WebMeta();
                print["type"]      = "UI.Setting";
                print["Signature"] = Signature;
                this.Context.Send(print, true);


                break;
            }
        }
コード例 #17
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"
                    }));
                }
            }
        }
コード例 #18
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var user = UMC.Security.Identity.Current;

            if (user.IsAuthenticated == false)
            {
                response.Redirect(request.Model, "Login");
            }
            var Model = this.AsyncDialog("Model", gkey =>
            {
                WebMeta form = request.SendValues ?? new UMC.Web.WebMeta();

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

                //    var rel = Utility.Database.ObjectEntity<Entities.VIPMember>().Where.And().Equal(relt).Entities.Single() ?? relt;


                var account = Security.Account.Create(user.Id.Value);
                var dic     = UMC.Web.UISection.Create(new UITitle("ÕË»§ÐÅÏ¢"));
                dic.AddImageTextValue(Data.WebResource.Instance().ImageResolve(user.Id.Value, "1", 4), "Í·Ïñ", 100, new UIClick("id", user.Id.ToString(), "seq", "1")
                {
                    Model = "Design", Command = "Image"
                });

                dic.AddCell("êdzÆ", user.Alias, new UIClick("Alias")
                {
                    Command = "Setting", Model = "Account"
                });                                                                                                //.Put("Model", "Account").Put("Command", "Setting").Put("SendValue", "Alias");


                //dic.Title.Right(new UIEventText("ÃÜÂë").Click(new UIClick() { Model = "Account", Command = "Password" }));


                var name = user.Name;
                dic.AddCell('\uf084', "µÇ¼Õ˺Å", name, new UIClick()
                {
                    Model = "Account", Command = "Password"
                });



                var ac = account[Security.Account.EMAIL_ACCOUNT_KEY];
                if (ac != null && String.IsNullOrEmpty(ac.Name) == false)
                {
                    name = ac.Name;

                    int c = name.IndexOf('@');
                    if (c > 0)
                    {
                        var cname = name.Substring(0, c);
                        name      = name.Substring(0, 2) + "***" + name.Substring(c);
                    }
                    if ((ac.Flags & Security.UserFlags.UnVerification) == Security.UserFlags.UnVerification)
                    {
                        name = name + "(δÑéÖ¤)";
                    }
                }
                else
                {
                    name = "µã»÷°ó¶¨";
                }

                var cui = dic.NewSection().AddCell('\uf199', "ÓÊÏä", name, new UIClick()
                {
                    Command = "Email", Model = "Account"
                });
                //.Put("Model", "Account").Put("Command", "Email")

                //.Put("Name", "Email");

                ac = account[Security.Account.MOBILE_ACCOUNT_KEY];
                if (ac != null && String.IsNullOrEmpty(ac.Name) == false)
                {
                    name = ac.Name;
                    if (name.Length > 3)
                    {
                        name = name.Substring(0, 3) + "****" + name.Substring(name.Length - 3);
                    }
                    if ((ac.Flags & Security.UserFlags.UnVerification) == Security.UserFlags.UnVerification)
                    {
                        name = name + "(δÑéÖ¤)";
                    }
                }
                else
                {
                    name = "µã»÷°ó¶¨";
                }

                cui.AddCell('\ue91a', "ÊÖ»úºÅÂë", name, new UIClick()
                {
                    Command = "Mobile", Model = "Account"
                });

                UICell cell = UICell.Create("UI", new UMC.Web.WebMeta().Put("text", "Í˳öµÇ¼").Put("Icon", "\uf011").Put("click", new UIClick()
                {
                    Model = "Account", Command = "Close"
                }));
                cell.Style.Name("text", new UIStyle().Color(0xf00));
                dic.NewSection().NewSection().Add(cell);



                response.Redirect(dic);
                return(this.DialogValue("none"));
            });

            switch (Model)
            {
            case "Alias":
                String Alias = this.AsyncDialog("Alias", a => new UITextDialog()
                {
                    Title = "Ð޸ıðÃû"
                });
                Membership.Instance().ChangeAlias(user.Name, Alias);
                this.Prompt(String.Format("ÄúµÄÕË»§µÄ±ðÃûÒÑÐ޸ijÉ{0}", Alias), false);
                this.Context.Send("Setting", true);


                break;
            }
        }
コード例 #19
0
        public void Wildcard(WebRequest request, WebResponse response, string name)
        {
            var wddEntity = UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Wildcard>();
            var wdk       = wddEntity.Where.And().Equal(new Data.Entities.Wildcard {
                WildcardKey = name
            }).Entities.Single();

            var auths = new List <UMC.Security.Authorize>();

            if (wdk != null)
            {
                var data = new Data.Entity <Data.Entities.Wildcard, List <Security.Authorize> >(wdk, wdk.Authorizes);

                auths.AddRange(data.Config);
            }
            var Type = this.AsyncDialog("WType", gg =>
            {
                var form = request.SendValues ?? new UMC.Web.WebMeta();
                if (form.ContainsKey("limit") == false)
                {
                    this.Context.Send(new UISectionBuilder(request.Model, request.Command, new WebMeta(request.Arguments.GetDictionary()))
                                      .RefreshEvent("Wildcard")
                                      .Builder(), true);
                }
                var ui = UMC.Web.UISection.Create(new UITitle("权限设置"));
                ui.AddCell('\uf084', "标识", name);


                var ui3   = ui.NewSection().AddCell('\uf007', "许可用户", "", new Web.UIClick(new WebMeta(request.Arguments.GetDictionary()).Put(gg, "User")).Send(request.Model, request.Command));
                var users = auths.FindAll(g => g.Type == Security.AuthorizeType.UserAllow);
                var uids  = new List <String>();
                foreach (var u in users)
                {
                    uids.Add(u.Value);
                }

                var dusers = UMC.Security.Membership.Instance().Identity(uids.ToArray());


                foreach (var u in users)
                {
                    var text = u.Value;
                    var u1   = dusers.Find(d => d.Name == u.Value);
                    if (u1 != null)
                    {
                        text = u1.Alias;
                    }
                    var cell = UICell.Create("Cell", new WebMeta().Put("value", u.Value).Put("text", text));//.Put("Icon", '\uf007'));

                    ui3.Delete(cell, new UIEventText().Click(new Web.UIClick(new WebMeta(request.Arguments.GetDictionary()).Put(gg, u.Value)).Send(request.Model, request.Command)));
                }
                if (users.Count == 0)
                {
                    ui3.Add("Desc", new UMC.Web.WebMeta().Put("desc", "未设置许可用户").Put("icon", "\uEA05"), new UMC.Web.WebMeta().Put("desc", "{icon}\n{desc}"),
                            new UIStyle().Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60)));//.Name
                }

                var ui2 = ui.NewSection().AddCell('\uf0c0', "许可角色", "", new Web.UIClick(new WebMeta(request.Arguments.GetDictionary()).Put(gg, "Role")).Send(request.Model, request.Command));

                var roles = auths.FindAll(g => g.Type == Security.AuthorizeType.RoleAllow);

                foreach (var u in roles)
                {
                    var cell = UICell.Create("Cell", new WebMeta().Put("text", u.Value));//.Put("Icon", '\uf0c0'));

                    ui2.Delete(cell, new UIEventText().Click(new Web.UIClick(new WebMeta(request.Arguments.GetDictionary()).Put(gg, u.Value)).Send(request.Model, request.Command)));
                }
                if (roles.Count == 0)
                {
                    ui2.Add("Desc", new UMC.Web.WebMeta().Put("desc", "未设置许可角色").Put("icon", "\uEA05"), new UMC.Web.WebMeta().Put("desc", "{icon}\n{desc}"), new UIStyle().Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60)));//.Name
                }
                response.Redirect(ui);
                return(this.DialogValue("none"));
            });

            switch (Type)
            {
            case "Role":
                var role = this.AsyncDialog("SelectRole", request.Model, "SelectRole");
                auths.RemoveAll(k => String.Equals(k.Value, role));
                auths.Add(new Security.Authorize {
                    Type = UMC.Security.AuthorizeType.RoleAllow, Value = role
                });
                wddEntity.IFF(e => e.Update(new Data.Entities.Wildcard {
                    Authorizes = UMC.Data.JSON.Serialize(auths)
                }) == 0
                              , e => e.Insert(new Data.Entities.Wildcard {
                    WildcardKey = name, Authorizes = UMC.Data.JSON.Serialize(auths)
                }));
                this.Context.Send("Wildcard", true);
                break;

            case "User":

                var user = this.AsyncDialog("SelectUser", request.Model, "SelectUser");
                auths.RemoveAll(k => String.Equals(k.Value, user));
                auths.Add(new Security.Authorize {
                    Type = UMC.Security.AuthorizeType.UserAllow, Value = user
                });
                wddEntity.IFF(e => e.Update(new Data.Entities.Wildcard {
                    Authorizes = UMC.Data.JSON.Serialize(auths)
                }) == 0
                              , e => e.Insert(new Data.Entities.Wildcard {
                    WildcardKey = name, Authorizes = UMC.Data.JSON.Serialize(auths)
                }));
                this.Context.Send("Wildcard", true);
                break;

            default:
                var a = auths.Find(k => String.Equals(Type, k.Value));
                if (a != null)
                {
                    auths.Remove(a);
                    wddEntity.Update(new Data.Entities.Wildcard {
                        Authorizes = UMC.Data.JSON.Serialize(auths)
                    });
                    if (auths.Exists(k => k.Type == a.Type) == false)
                    {
                        this.Context.Send("Wildcard", true);
                    }
                }
                break;
            }
            //var acc =
        }
コード例 #20
0
        int CheckRow(string text, int index, bool isNextLIne)
        {
            if (String.IsNullOrEmpty(text))
            {
                return(index + 1);
            }
            int oldIndex = -1;

            while (index + 1 < text.Length && text[index] != '\n')
            {
                if (oldIndex == index)
                {
                    index++;
                    continue;
                }
                else
                {
                    oldIndex = index;
                }

                switch (text[index])
                {
                case '\r':
                    index++;
                    continue;

                case '!':
                    if (text[index + 1] == '[' && isNextLIne)
                    {
                        int end = text.IndexOf("]", index + 1);
                        if (end > index)
                        {
                            String content = text.Substring(index + 1, end - index - 1).Trim('[', ']');
                            if (content.IndexOf('\n') == -1)
                            {
                                if (text[end + 1] == '(')
                                {
                                    Append();
                                    int end2 = text.IndexOf(")", end + 1);
                                    if (end2 > end)
                                    {
                                        var url  = text.Substring(end + 1, end2 - end - 1).Trim(' ', '(', ')').Split(' ')[0];
                                        var cell = UICell.Create("CMSImage", new WebMeta().Put("src", url));
                                        cell.Style.Padding(0, 10);
                                        cells.Add(cell);
                                        index = end2 + 1;

                                        continue;
                                    }
                                }
                                else
                                {
                                    Append();

                                    if (webRel.ContainsKey(content))
                                    {
                                        var cell = UICell.Create("CMSImage", new WebMeta().Put("src", webRel[content]));
                                        cell.Style.Padding(0, 10);
                                        cells.Add(cell);
                                    }
                                    else
                                    {
                                        var src = new WebMeta().Put("src", content);
                                        this.webRels.Add(src);
                                        var cell = UICell.Create("CMSImage", src);
                                        cell.Style.Padding(0, 10);
                                        cells.Add(cell);
                                    }
                                    index = end + 1;

                                    continue;
                                }
                            }
                        }
                    }
                    break;

                case '[':
                {
                    int end = text.IndexOf("]", index + 1);
                    if (end > index)
                    {
                        String content = text.Substring(index, end - index).Trim('[', ']');
                        if (content.IndexOf('\n') == -1)
                        {
                            if (text.Length > end + 1 && text[end + 1] == '(')
                            {
                                int end2 = text.IndexOf(")", end + 1);
                                if (end2 > end)
                                {
                                    var url = text.Substring(end + 1, end2 - end - 1).Trim(' ', '(', ')').Split(' ')[0];


                                    AppendData();
                                    style.Name("m" + data.Count.ToString(), new UIStyle().Click(new UIClick(url)
                                        {
                                            Key = "Url"
                                        }));
                                    data.Put("m" + data.Count.ToString(), content);

                                    index = end2 + 1;

                                    continue;
                                }
                            }
                            else
                            {
                                if (String.IsNullOrEmpty(content.Trim()) == false)
                                {
                                    AppendData();

                                    if (webRel.ContainsKey(content))
                                    {
                                        style.Name("m" + data.Count.ToString(), new UIStyle().Click(new UIClick(webRel[content])
                                            {
                                                Key = "Url"
                                            }));
                                    }
                                    else
                                    {
                                        var click = new UIClick(content)
                                        {
                                            Key = "Url"
                                        };
                                        this.links.Add(click);
                                        style.Name("m" + data.Count.ToString(), new UIStyle().Click(click));
                                    }
                                    data.Put("m" + data.Count.ToString(), content);
                                }
                                else
                                {
                                    dataText.Append("[");
                                    dataText.Append(content);
                                    dataText.Append("]");
                                }

                                index = end + 1;

                                continue;
                            }
                        }
                    }
                }
                break;

                case '`':
                {
                    int end = text.IndexOf("`", index + 1);
                    if (end > index)
                    {
                        String content = text.Substring(index, end - index);
                        if (content.IndexOf('\n') == -1)
                        {
                            AppendData();
                            style.Name("m" + data.Count.ToString(), new UIStyle().Color(0xCC6600));
                            data.Put("m" + data.Count.ToString(), content.Trim('`'));


                            index = end + 1;

                            continue;
                        }
                    }
                }
                break;

                case '~':
                    if (text[index + 1] == '~')
                    {
                        int end = text.IndexOf("~~", index + 1);
                        if (end > index)
                        {
                            String content = text.Substring(index, end - index);
                            if (content.IndexOf('\n') == -1)
                            {
                                AppendData();
                                style.Name("m" + data.Count.ToString(), new UIStyle().DelLine());
                                data.Put("m" + data.Count.ToString(), content.Trim('~'));

                                index = end + 2;

                                continue;
                            }
                        }
                    }
                    else
                    {
                        int end = text.IndexOf("~", index + 1);
                        if (end > index)
                        {
                            String content = text.Substring(index, end - index);
                            if (content.IndexOf('\n') == -1)
                            {
                                AppendData();
                                style.Name("m" + data.Count.ToString(), new UIStyle().UnderLine());
                                data.Put("m" + data.Count.ToString(), content.Trim('~'));
                                index = end + 1;

                                continue;
                            }
                        }
                    }
                    break;

                case '*':
                    if (text[index + 1] == '*')
                    {
                        int end = text.IndexOf("**", index + 1);

                        if (end > index)
                        {
                            String content = text.Substring(index, end - index);
                            if (content.IndexOf('\n') == -1)
                            {
                                AppendData();
                                style.Name("m" + data.Count.ToString(), new UIStyle().Bold());
                                data.Put("m" + data.Count.ToString(), content.Trim('*'));

                                index = end + 2;

                                continue;
                            }
                        }
                    }
                    else
                    {
                        int end = text.IndexOf("*", index + 1);
                        if (end > index)
                        {
                            String content = text.Substring(index + 1, end - index);
                            if (content.IndexOf('\n') == -1)
                            {
                                AppendData();
                                style.Name("m" + data.Count.ToString(), new UIStyle().UnderLine());
                                data.Put("m" + data.Count.ToString(), content.Trim('*'));
                                index = end + 1;

                                continue;;
                            }
                        }
                    }
                    break;
                }
                dataText.Append(text[index]);
                index++;
            }
            if (index + 1 == text.Length)
            {
                dataText.Append(text[index]);
            }
            if (isNextLIne)
            {
                Append();
                return(index + 1);
                //Check(text, index + 1);
            }
            return(index);
        }
コード例 #21
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var user = UMC.Security.Identity.Current;


            var header = new UIHeader();
            var title  = UITitle.Create();

            title.Title = "设置";
            var ui = UISection.Create(title);

            if (user.IsAuthenticated)
            {
                ui.NewSection().AddCell("我的账户", new Web.UIClick()
                {
                    Model = "Account", Command = "Self"
                });
            }
            else
            {
                ui.NewSection().AddCell("未登录", "请登录", new Web.UIClick()
                {
                    Model = "Account", Command = "Login"
                });
            }
            ui.NewSection()
            .AddCell("清空缓存", "", new Web.UIClick()
            {
                Key = "ClearCache"
            })
            .AddCell("检查更新", "", new Web.UIClick("Version")
            {
                Model = "UI", Command = "App"
            })
            .AddCell("应用测试", "", new Web.UIClick()
            {
                Model = "UI", Command = "Demo"
            })
            .AddCell("关于作者", "", Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "365lu/help/AboutUs"), true));



            if (user.IsAuthenticated)
            {
                var cell = UICell.Create("UI", new UMC.Web.WebMeta().Put("text", "退出登录").Put("Icon", '\uf011').Put("click", new UIClick()
                {
                    Model   = "Account",
                    Command = "Close"
                }));
                cell.Style.Name("text", new UIStyle().Color(0xf00));
                ui.NewSection().NewSection()
                .Add(cell);
                //}
                //else
                //{
                //    var cell = UICell.Create("UI", new UMC.Web.WebMeta().Put("text", "登录").Put("Icon", '\uf007').Put("click", new UIClick()
                //    {
                //        Model = "Account",
                //        Command = "Login"
                //    }));
                //    cell.Style.Name("text", new UIStyle().Color(0xf00));
                //    ui.NewSection().NewSection()
                //        .Add(cell);
            }
            response.Redirect(ui);
        }
コード例 #22
0
        void Grid(List <String> rows)
        {
            var hStyle = new List <UIStyle>();
            var header = rows[1].Trim('|').Split('|');
            var grid   = new List <List <WebMeta> >();
            int flexs  = 0;

            foreach (var h in header)
            {
                var st = new UIStyle();
                var s  = h.Trim();
                if (s.StartsWith(":") && s.EndsWith(":"))
                {
                    st.AlignCenter();
                }
                else if (s.EndsWith(":"))
                {
                    st.AlignRight();
                }
                else
                {
                    st.AlignLeft();
                }
                int flex = s.Split('-').Length - 1;
                st.Name("flex", flex);
                flexs += flex;
                hStyle.Add(st);
            }
            rows.RemoveAt(1);
            foreach (var row in rows)
            {
                var cells = row.Trim('|').Split('|');
                var cdata = new List <WebMeta>();
                for (int i = 0; i < hStyle.Count; i++)
                {
                    var cstyle = new UIStyle();
                    cstyle.Copy(hStyle[i]);
                    this.style    = cstyle;
                    this.data     = new WebMeta();
                    this.dataText = new StringBuilder();
                    if (i < cells.Length)
                    {
                        CheckRow(cells[i].Trim(), 0, false);
                    }
                    if (dataText.Length > 0)
                    {
                        this.data.Put("m" + data.Count.ToString(), dataText.ToString().Trim());
                    }
                    var sb = new StringBuilder();
                    for (int c = 0; c < data.Count; c++)
                    {
                        sb.Append("{m");
                        sb.Append(c);
                        sb.Append("}");
                    }
                    cdata.Add(new WebMeta().Put("format", sb.ToString()).Put("data", this.data).Put("style", this.style));
                }
                grid.Add(cdata);
            }

            var cell = UICell.Create("CMSGrid", new WebMeta().Put("grid", grid).Put("flex", flexs));

            cells.Add(cell);
            data     = new WebMeta();
            style    = new UIStyle();
            dataText = new StringBuilder();
        }