예제 #1
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var model = request.Model;
            var proid = UMC.Data.Utility.Guid(this.AsyncDialog("Id", g => this.DialogValue(request.Url.ToString())));

            if (proid.HasValue == false)
            {
                this.Prompt("参数不正确");
            }
            var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>();

            var sub = subEntity.Where.And().Equal(new Subject {
                Id = proid
            }).Entities.Single();

            if (sub == null)
            {
                this.Prompt("参数不正确");
            }
            var Type = this.AsyncDialog("Type", g =>
            {
                //return this.DialogValue("auto");
                var sheet = new Web.UISheetDialog()
                {
                    Title = "更多"
                };                                                    //屏蔽
                sheet.Options.Add(new Web.UIClick("Id", proid.ToString(), "Type", "Share")
                {
                    Command = request.Command, Model = model, Text = "分享到应用"
                });
                //sheet.Options.Add(new Web.UIClick("Id", proid.ToString(), "Type", "0") { Command = request.Command, Model = model, Text = "屏蔽此作者" });
                //sheet.Options.Add(new Web.UIClick("Id", proid.ToString(), "Type", "1") { Command = request.Command, Model = model, Text = "屏蔽此项目" });
                sheet.Options.Add(new Web.UIClick("Id", proid.ToString(), "Type", "Off")
                {
                    Command = request.Command, Model = model, Text = "举报内容"
                });
                return(sheet);
            });
            var user = Security.Identity.Current;

            switch (Type)
            {
            case "Off":
                var frm = this.AsyncDialog("Settings", g =>
                {
                    var fm   = new UIFormDialog();
                    fm.Title = "举报";
                    fm.AddRadio("违规性质", "Type").Put("内容质量差").Put("旧闻重复").Put("内容不实").Put("标题夸张").Put("低俗色情")
                    .Put("其他问题").Put("侵犯名誉/商誉/隐私/肖像权");
                    fm.AddFile("证明材料", "Url", "");
                    fm.AddTextarea("举报描述", "Description", "");
                    return(fm);
                });
                var url = new Uri(frm["Url"]);

                var s = "UserResources/TipOff" + url.AbsolutePath.Substring(url.AbsolutePath.IndexOf('/', 2));    //
                Data.WebResource.Instance().Transfer(url, s);
                var t = new SubjectTipOff();
                Data.Reflection.SetProperty(t, frm.GetDictionary());
                t.user_id      = user.Id;
                t.Url          = Data.WebResource.Instance().ResolveUrl(s);
                t.sub_id       = sub.Id;
                t.CreationTime = DateTime.Now;
                Utility.CMS.ObjectEntity <SubjectTipOff>().Where.And().Equal(new SubjectTipOff {
                    user_id = user.Id, sub_id = sub.Id
                })
                .Entities.IFF(e => e.Update(t) == 0, e => e.Insert(t));
                if (sub.TipOffs.HasValue)
                {
                    subEntity.Update("{0}+{1}", new Subject {
                        TipOffs = 1
                    });
                }
                else
                {
                    subEntity.Update(new Subject {
                        TipOffs = 1
                    });
                }
                this.Prompt("举报成功,我们将尽快处理");
                break;

            case "Share":
                response.Redirect(request.Model, "Share", proid.ToString());
                break;

            default:
            case "Block":

                var ui      = this.AsyncDialog("UI", g => this.DialogValue("none"));
                var section = this.AsyncDialog("section", g => this.DialogValue("1"));
                var row     = this.AsyncDialog("row", g => this.DialogValue("1"));
                var frm2    = Utility.IntParse(this.AsyncDialog("Settings", g =>
                {
                    if (Utility.IntParse(Type, -1) > -1)
                    {
                        return(this.DialogValue(Type));
                    }
                    var fm   = new UISelectDialog();
                    fm.Title = "屏蔽";
                    fm.Options.Put("屏蔽此作者", "0").Put("屏蔽此项目", "1");
                    return(fm);
                }), 0);
                var block = new ProjectBlock {
                    user_id = user.Id, ref_id = sub.user_id, Type = frm2
                };
                switch (frm2)
                {
                case 0:
                    block.ref_id = sub.user_id;
                    break;

                case 1:
                    block.ref_id = sub.project_id;
                    break;
                }
                if (block.ref_id.HasValue)
                {
                    Utility.CMS.ObjectEntity <ProjectBlock>().Where.And().Equal(block)
                    .Entities.IFF(e => e.Count() == 0, e => e.Insert(block));
                }
                if (ui == "none")
                {
                    this.Prompt("屏蔽成功");
                }
                else
                {
                    var editer = new Web.UISection.Editer(section, row, ui);
                    editer.Delete();
                    editer.ReloadSinle();
                    editer.Builder(this.Context, ui, true);
                }
                break;
            }
        }
예제 #2
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);
        }
예제 #3
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var config = this.AsyncDialog("Key", g => this.DialogValue("none"));

            switch (config)
            {
            case "Version":
            case "Builder":
            case "json":
            case "Android":
            case "IOS":
                break;

            default:
                if (request.IsMaster == false)
                {
                    this.Prompt("只有管理员才能设置App");
                }
                break;
            }
            var file = Reflection.ConfigPath("App.json");

            if (System.IO.File.Exists(file) == false)
            {
                using (System.IO.Stream stream = new System.Net.Http.HttpClient().GetStreamAsync("http://oss.365lu.cn/UserResources/demo.json").Result)
                {
                    UMC.Data.Utility.Copy(stream, file);
                }
            }
            var appConfig = Data.JSON.Deserialize(Utility.Reader(file)) as Hashtable;

            switch (config)
            {
            case "Version":
            {
                int vindex = request.UserAgent.IndexOf("android");
                if (vindex > 0)
                {
                    var v    = request.UserAgent.Substring(request.UserAgent.IndexOf("V", vindex) + 1);
                    var cfgs = UMC.Configuration.ProviderConfiguration.GetProvider(Reflection.ConfigPath("Version.xml"));
                    if (cfgs == null)
                    {
                        this.Prompt("提示", "当前已经是最新版本");
                    }

                    var provider = cfgs[config];
                    if (provider != null)
                    {
                        if (Data.Utility.IntParse(provider["versionCode"], 0) > UMC.Data.Utility.IntParse(v, 0))
                        {
                            this.AsyncDialog("Confirm", g =>
                                {
                                    return(new UMC.Web.UIConfirmDialog("您有新版本,点击确认安装")
                                    {
                                        Title = "新版本安装"
                                    });
                                });
                            var meta = new UMC.Web.WebMeta();
                            meta.Put("name", provider.Name);
                            meta.Put("text", provider["text"]);
                            meta.Put("title", provider["title"]);
                            meta.Put("src", provider["src"]).Put("type", "Download");
                            this.Context.Send(meta, true);
                        }
                        else
                        {
                            this.Prompt("提示", "当前已经是最新版本");
                        }
                    }
                    else
                    {
                        this.Prompt("提示", "当前已经是最新版本");
                    }
                }
                else
                {
                    this.Prompt("苹果版本自动更新");
                }
            }
            break;

            case "Builder":
                if (String.IsNullOrEmpty(appConfig["AppName"] as string))
                {
                    this.Prompt("应用名称不能为空");
                }
                if (String.IsNullOrEmpty(appConfig["IconSrc"] as string))
                {
                    this.Prompt("请上传图标");
                }
                if (String.IsNullOrEmpty(appConfig["BgSrc"] as string))
                {
                    this.Prompt("请上传启动图");
                }
                var dataKey = new Hashtable();
                dataKey["root"]      = Utility.GetRoot(request.Url);
                dataKey["host"]      = new Uri(request.Url, "/").AbsoluteUri.Trim('/');
                appConfig["DataKey"] = dataKey;
                response.Redirect(appConfig);
                break;

            case "json":
                appConfig["IsMaster"] = request.IsMaster;
                response.Redirect(appConfig);
                break;

            case "Reset":
            {
                var ResetName = this.AsyncDialog("Reset", g =>
                    {
                        var k = new UISelectDialog()
                        {
                            Title = "选择参考的默认的界面架构"
                        };
                        k.Options.Add("DOME架构", "demo");
                        return(k);
                    });
                String stream = new System.Net.Http.HttpClient().GetStringAsync(String.Format("http://oss.365lu.cn/UserResources/{0}.json", ResetName)).Result;

                var appConfig2 = Data.JSON.Deserialize(stream) as Hashtable;
                appConfig2["BgSrc"]   = appConfig["BgSrc"];
                appConfig2["IconSrc"] = appConfig["IconSrc"];
                appConfig2["AppName"] = appConfig["AppName"];
                appConfig2["Android"] = appConfig["Android"];
                appConfig2["IOS"]     = appConfig["IOS"];
                appConfig             = appConfig2;
            }
            break;

            case "News":
            {
                var key = this.AsyncDialog("Sheet", g =>
                    {
                        var k = new UIFormDialog()
                        {
                            Title = "新增Bar"
                        };
                        k.AddText("标题", "text", String.Empty);
                        k.AddOption("图标", "icon").Command("System", "Icon");
                        k.AddCheckBox("", "max", "no").Put("显示大按钮", "true");
                        k.AddRadio("Bar加载类型", "Type")
                        .Put("默认主页", "Home").Put("电商购物篮", "Cart").Put("电商品类页", "Category").Put("Tabs", "Tab配置页").Put("点击项", "Click")
                        .Put("基本页", "Pager");
                        k.Submit("确认提交", request, "AppConfig");
                        return(k);
                    });
                var footbar = new ArrayList(appConfig["footBar"] as Array);
                var data    = new WebMeta().Put("key", key["Type"]).Put("text", key["text"]).Put("icon", key["icon"]);
                if ((key["max"] ?? "").Contains("true"))
                {
                    data.Put("max", true);
                }
                footbar.Add(data);
                appConfig["footBar"] = footbar;
            }
            break;

            case "Android":
            case "IOS":
                appConfig[config] = this.AsyncDialog("Value", g =>
                {
                    var k = new UITextDialog()
                    {
                        Title = config + "下载地址", DefaultValue = appConfig[config] as string
                    };
                    return(k);
                });
                break;

            case "BgSrc":
            case "IconSrc":
            {
                var AppName = this.AsyncDialog("Value", g =>
                    {
                        var k = new UITextDialog()
                        {
                            Title = "值"
                        };
                        return(k);
                    });
                var Key  = String.Format("UserResources/{0}/{1}/{2}", Utility.GetRoot(request.Url), config, AppName.Substring(AppName.LastIndexOf('/') + 1));
                var webR = UMC.Data.WebResource.Instance();
                webR.Transfer(new Uri(AppName), Key);
                appConfig[config] = new Uri(request.Url, webR.WebDomain() + Key).AbsoluteUri;
            }
            break;

            case "AppName":
            {
                var AppName = this.AsyncDialog("AppName", g =>
                    {
                        var k = new UITextDialog()
                        {
                            Title        = "应用名称",
                            DefaultValue = appConfig["AppName"] as string
                        };
                        return(k);
                    });
                appConfig["AppName"] = AppName;
            }
            break;

            case "Del":
            {
                var footbar = new ArrayList(appConfig["footBar"] as Array);

                var index = Utility.IntParse(this.AsyncDialog("Index", "0"), -1);
                footbar.RemoveAt(index);
                appConfig["footBar"] = footbar;
            }
            break;

            default:
            {
                var footbar = new ArrayList(appConfig["footBar"] as Array);
                var index   = Utility.IntParse(this.AsyncDialog("Index", "0"), -1);

                var hash     = footbar[index] as Hashtable;
                var settings = this.AsyncDialog("Settings", g =>
                    {
                        var fm   = new UIFormDialog();
                        fm.Title = "图标";
                        fm.AddText("标题", "text", hash["text"] as string);
                        fm.AddOption("图标", "icon", hash["icon"] as string, hash["icon"] as string).Command("System", "Icon");
                        switch (config)
                        {
                        case "Setting":
                            switch (hash["key"] as string ?? "Click")
                            {
                            case "Home":
                            case "Category":
                                break;

                            case "Cart":
                                fm.AddCheckBox("", "max", "no").Put("显示大按钮", "true", hash.ContainsKey("max"));
                                break;

                            case "Click":
                                fm.AddCheckBox("", "max", "no").Put("显示大按钮", "true", hash.ContainsKey("max"));
                                var click = (hash["click"] as Hashtable) ?? new Hashtable();
                                fm.AddText("事件模块", "model", click["model"] as string);
                                fm.AddText("事件指令", "cmd", click["cmd"] as string);
                                fm.AddText("事件参数", "send", click["send"] as string).NotRequired();
                                break;

                            case "Tabs":
                                fm.AddText("数据源模块", "model", hash["model"] as string);
                                fm.AddText("数据源指令", "cmd", hash["cmd"] as string);
                                break;

                            case "Pager":
                                fm.AddText("加载模块", "model", hash["model"] as string);
                                fm.AddText("加载指令", "cmd", hash["cmd"] as string);
                                break;

                            default:
                                this.Prompt("固定页面,不支持设置");;
                                break;
                            }
                            break;
                        }
                        return(fm);
                    });

                hash["text"] = settings["text"];
                hash["icon"] = settings["icon"];
                if ((settings["max"] ?? "").Contains("true"))
                {
                    hash["max"] = true;
                }
                else
                {
                    hash.Remove("max");
                }
                switch (hash["key"] as string)
                {
                case "Click":
                    var click = new WebMeta().Put("model", settings["model"])
                                .Put("cmd", settings["cmd"]);
                    if (String.IsNullOrEmpty(settings["model"]) == false)
                    {
                        click.Put("send", settings["send"]);
                    }
                    hash["click"] = click;
                    break;

                case "Cart":
                    break;

                case "Tabs":
                    hash["model"] = settings["model"];
                    hash["cmd"]   = settings["cmd"];
                    break;

                case "Pager":
                    hash["model"] = settings["model"];
                    hash["cmd"]   = settings["cmd"];
                    break;
                }
            }
            break;
            }

            Utility.Writer(file, Data.JSON.Serialize(appConfig), false);
            this.Context.Send("AppConfig", new WebMeta().Put("Config", appConfig), true);
        }