Esempio n. 1
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var  user    = UMC.Security.Identity.Current;// ();
            Guid groupId = UMC.Data.Utility.Guid(this.AsyncDialog("id", d =>
            {
                this.Prompt("请传入参数");
                return(this.DialogValue(user.Id.ToString()));
            }), true).Value;

            String Seq = this.AsyncDialog("seq", g =>
            {
                if (request.SendValues != null)
                {
                    return(this.DialogValue(request.SendValues.Get("Seq") ?? "0"));
                }
                else
                {
                    return(this.DialogValue("0"));
                }
            });

            UMC.Data.WebResource webr = UMC.Data.WebResource.Instance();
            String media_id           = this.AsyncDialog("media_id", g =>
            {
                if (request.IsApp)
                {
                    UIDialog f = UIDialog.CreateDialog("File");

                    f.Config.Put("Submit", new UIClick(new WebMeta(request.Arguments.GetDictionary()).Put(g, "Value"))
                                 .Send(request.Model, request.Command));
                    ;
                    return(f);
                }
                else
                {
                    UIFormDialog from = new UIFormDialog();
                    from.Title        = ("图片上传");

                    from.AddFile("选择图片", "media_id", webr.ImageResolve(groupId, Seq, 4));

                    from.Submit("确认上传", request, "image");
                    return(from);
                }
            });


            String type = this.AsyncDialog("type", g => this.DialogValue("jpg"));
            int    seq  = UMC.Data.Utility.Parse(Seq, 1);

            if (media_id.StartsWith("http://") || media_id.StartsWith("https://"))
            {
                Uri url = new Uri(media_id);

                if (url.AbsolutePath.ToLower().EndsWith(type.ToLower()))
                {
                    webr.Transfer(url, groupId, seq, type);
                }
                else
                {
                    webr.Transfer(new Uri(String.Format("{0}?x-oss-process=image/format,{1}", media_id, type)), groupId, seq, type);
                }
            }
            else
            {
                /*
                 * 微信上传
                 * */
            }


            this.Context.Send(new WebMeta().Put("type", "image").Put("id", groupId), true);
        }
Esempio n. 2
0
        public static UIComment Comment(Comment cm, List <Comment> replys, List <UMC.Data.Entities.Picture> pics, UMC.Data.WebResource webr, string model)
        {
            var btnStyle = new UIStyle().Size(12).Name("icon", new UIStyle().Font("wdk").Size(18)).Color(0x666);
            var cell     = new UIComment(webr.ResolveUrl(cm.user_id.Value, 1, "0") + "!50");

            cell.Id = cm.Id.ToString();
            // cell.Tag(new UIEventText("d"));
            var image = new List <UIComment.Image>();

            cell.ImageClick(UIClick.Pager(model, "Account", new WebMeta().Put("Id", cm.user_id), true));

            UMC.Data.Utility.Each(pics, g =>
            {
                if (g.group_id == cm.Id)
                {
                    image.Add(new UIComment.Image
                    {
                        src = webr.ResolveUrl(cm.Id.Value, g.Seq, "0") + "!m200?_ts=" + UMC.Data.Utility.TimeSpan(g.UploadDate.Value),
                        max = webr.ResolveUrl(cm.Id.Value, g.Seq, "0")
                    });
                }
            });
            var nick = cm.Poster;

            if (String.IsNullOrEmpty(nick))
            {
                nick = "游客";
            }
            if (Data.Utility.IsPhone(nick))
            {
                nick = "手机客户";
            }
            cell.Name("name", nick)//.Name("tag", "x").Name("desc", "dd")
            .Content(cm.Content).Name("time", String.Format("{0:yyyy.MM.dd HH:mm}", cm.CommentDate));
            cell.Button(new UIEventText('\uf087', cm.Effective > 0 ? String.Format("( {0} )", cm.Effective) : "赞").Format("{icon} {text}").Style(btnStyle)
                        .Click(Web.UIClick.Click(new UIClick("Refer", cm.Id.ToString())
            {
                Model = model, Command = "Effective"
            }))
                        , new UIEventText('\uF0E5', "回复").Format("{icon} {text}").Style(btnStyle)
                        .Click(Web.UIClick.Click(new UIClick("Refer", cm.Id.ToString())
            {
                Model = model, Command = "Comment"
            })));

            var rs = new List <UIComment.Reply>();

            foreach (var re in replys)
            {
                var ts = new UIComment.Reply {
                    content = "{desc}", title = "{nick} 在 {time} 回复说:"
                };
                ts.data = new UMC.Web.WebMeta().Put("desc", re.Content).Put("time", String.Format("{0:yyyy.MM.dd HH:mm}", re.CommentDate))
                          .Put("nick", re.Poster);

                //ts.style.
                rs.Add(ts);
            }
            cell.Replys(rs.ToArray());
            cell.Images(image.ToArray());
            return(cell);
        }