void Remove()
        {
            var user = UMC.Security.Identity.Current;
            var act  = Account.Create(user.Id.Value);

            var a    = act[Account.EMAIL_ACCOUNT_KEY];
            var code = Web.UIDialog.AsyncDialog("Remove", d =>
            {
                var fm = new Web.UIFormDialog()
                {
                    Title = "解除验证"
                };
                fm.AddTextValue().Put("邮箱", a.Name);
                fm.AddVerify("验证码", "Code", "您邮箱收到的验证码")
                .Put("Command", "Email").Put("Model", "Account").Put("SendValue", new UMC.Web.WebMeta().Put("Email", a.Name).Put("Code", "Send")).Put("Start", "YES");

                fm.Submit("确认验证码", this.Context.Request, "Email");
                return(fm);
            });
            var session = new UMC.Configuration.Session <Hashtable>(a.Name);

            if (session.Value != null)
            {
                if (String.Equals(session.Value["Code"] as string, code))
                {
                    Account.Post(a.Name, a.user_id, Security.UserFlags.UnVerification, Account.EMAIL_ACCOUNT_KEY);
                    this.Prompt("邮箱解除绑定成功", false);
                    this.Context.Send(new UMC.Web.WebMeta().Put("type", "Email"), true);
                }
            }
            this.Prompt("您输入的验证码错误");
        }
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var TypeId = UMC.Data.Utility.Guid(Web.UIDialog.AsyncDialog("Id", d =>
            {
                return(new LinkDialog()
                {
                    IsPage = true, Title = "连接列表"
                });
            }), true);

            var cateEntity = Database.Instance().ObjectEntity <UMC.Data.Entities.Link>();


            cateEntity.Where.And().Equal(new UMC.Data.Entities.Link
            {
                Id = TypeId ?? Guid.Empty
            });
            var link = cateEntity.Single() ?? new Data.Entities.Link();


            var userValue = this.AsyncDialog("User", d =>
            {
                var fdlg   = new Web.UIFormDialog();
                fdlg.Title = "网页连接";

                if (link.Id.HasValue == false)
                {
                    link.Id = Guid.NewGuid();
                    request.Arguments["Id"] = link.Id.ToString();
                }
                fdlg.AddFile("图片", "_Header", Data.WebResource.Instance().ImageResolve(link.Id.Value, "1", 5))
                .Command("Design", "Picture", new UMC.Web.WebMeta().Put("id", link.Id).Put("seq", "1"));
                fdlg.AddText("网址", "Url", link.Url).Put("tip", "");
                fdlg.AddText("网址标题", "Caption", link.Caption);
                fdlg.AddText("所属组", "GroupBy", link.GroupBy);


                fdlg.Submit("确认", this.Context.Request, "Settings.Link");
                return(fdlg);
            });

            UMC.Data.Reflection.SetProperty(link, userValue.GetDictionary());
            if (link.Id.HasValue)
            {
                link.ModifiedTime = DateTime.Now;
                cateEntity.Update(link);
            }
            else
            {
                link.IsMenu       = true;
                link.Times        = 0;
                link.CreationTime = DateTime.Now;
                link.ModifiedTime = DateTime.Now;
                link.Favs         = 0;
                link.Id           = TypeId;// Guid.NewGuid();
                cateEntity.Insert(link);
            }
            this.Prompt("更新成功", false);
            this.Context.Send(new UMC.Web.WebMeta().Put("type", "Settings.Link"), true);
        }
示例#3
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var Settings = this.AsyncDialog("Settings", g =>
            {
                if (request.SendValues != null && request.SendValues.ContainsKey("media_id"))
                {
                    return(this.DialogValue(new WebMeta().Put("media_id", request.SendValues["media_id"])));
                }
                var from = new Web.UIFormDialog()
                {
                    Title = this.Title ?? "文本数据导入"
                };

                from.AddFile("选择csv文件", "media_id", String.Empty).Put("Accept", "text/csv");
                from.AddRadio("文件编码", "Encoding").Put("中文操作系统标准(GB2312)", "gb2312").Put("英文操作系统标准(UTF8)", "utf-8", true);
                var opts = from.AddTextValue("必须列名");
                foreach (var s in Columns)
                {
                    opts.Add(s, "必须字段");
                }
                from.Submit("确认上传", request, "Pager");
                return(from);
            });
            var media_id = Settings["media_id"];

            if (media_id.EndsWith(".csv") == false)
            {
                this.Prompt("请上传csv文本文件");
            }

            var Key      = this.AsyncDialog("Key", Utility.Guid(Guid.NewGuid()));
            var pathFile = this.AsyncDialog("File", g =>
            {
                string path2 = UMC.Data.Utility.MapPath(String.Format("App_Data\\Static\\TEMP\\{0}\\", Utility.GetRoot(request.Url)));

                var filename = String.Format("{0}{1}.tmp", path2, Key);
                Utility.Copy(new UMC.Net.HttpClient().GetStreamAsync(media_id).Result, filename);

                return(this.DialogValue(filename));
            });

            if (pathFile.EndsWith(".csv"))
            {
                var pad = new Uri(request.Url, String.Format("/TEMP/{0}", pathFile));
                this.Context.Send(new Web.WebMeta().Put("type", "OpenUrl").Put("value", pad.AbsoluteUri), true);
            }
            var columnSettings = this.AsyncDialog("Columns", g =>
            {
                var reader = new System.IO.StreamReader(pathFile, Encoding.GetEncoding(Settings["Encoding"] ?? "utf-8"));
                var cinex  = 0;
                var from   = new Web.UIFormDialog()
                {
                    Title = "核对字段"
                };
                var csvColumns = CSV.FromCsvLine(CSV.ReadLine(reader));
                reader.Close();
                foreach (var c in this.Columns)
                {
                    var opts = from.AddSelect(c, "Col_" + cinex).Put("请选择", "");
                    for (var i = 0; i < csvColumns.Length; i++)
                    {
                        opts.Add(String.Format("{1}(第{0}列)", i + 1, csvColumns[i]), i.ToString(), String.Equals(csvColumns[i], c, StringComparison.CurrentCultureIgnoreCase));
                    }
                    cinex++;
                }
                from.Submit("确认通过");
                return(from);
            });
            var indexs   = new List <int>();
            var maxIndex = -1;

            for (var i = 0; i < this.Columns.Length; i++)
            {
                var cindex = Convert.ToInt32(columnSettings["Col_" + i]);
                if (maxIndex < cindex)
                {
                    maxIndex = cindex;
                }
                indexs.Add(cindex);
            }
            if (indexs.Count == 0)
            {
                this.Prompt("无有效的字段");
            }

            var userName = Utility.GetUsername();

            var log = new CSV.Log(Utility.GetRoot(request.Url), Key, String.Format("开始{0}", this.Title ?? "文本数据导入"));

            Data.Reflection.Start(() =>
            {
                int rowIndex = 1;
                var reader   = new System.IO.StreamReader(pathFile, Encoding.GetEncoding(Settings["Encoding"] ?? "utf-8"));
                System.IO.FileStream file = System.IO.File.Open(String.Format("{0}.csv", pathFile), System.IO.FileMode.Create);


                try
                {
                    var writer = new System.IO.StreamWriter(file, Encoding.UTF8);
                    var total  = 0;
                    var now    = DateTime.Now;


                    var header = CSV.ReadLine(reader);
                    writer.WriteLine(header);

                    int okindex = 0;

                    CSV.EachRow(reader, data =>
                    {
                        rowIndex++;
                        if (data.Length <= maxIndex)
                        {
                            log.Error(String.Format("第{0}行 数据无效", rowIndex));
                            if (okindex + 10 < rowIndex)
                            {
                                throw new ArgumentException(String.Format("连续超过10条无效的数据"));
                            }
                            return;
                        }
                        var hash = new Hashtable();
                        for (var i = 0; i < indexs.Count; i++)
                        {
                            int index = indexs[i];
                            if (data.Length > index)
                            {
                                if (String.IsNullOrEmpty(data[index]))
                                {
                                    log.Error(String.Format("第{0}行 {1}列数据为空", rowIndex, this.Columns[i]));
                                    if (okindex + 10 < rowIndex)
                                    {
                                        throw new ArgumentException(String.Format("连续超过10条无效的数据"));
                                    }
                                    return;
                                }
                            }
                            else
                            {
                                log.Error(String.Format("第{0}行 无{1}列数据", rowIndex, this.Columns[i]));
                                if (okindex + 10 < rowIndex)
                                {
                                    throw new ArgumentException(String.Format("连续超过10条无效的数据"));
                                }
                                return;
                            }
                            hash[this.Columns[i]] = data[index];
                        }
                        if (Do(log, rowIndex, hash))
                        {
                            total++;
                            okindex = rowIndex;
                        }
                        else
                        {
                            foreach (var d in data)
                            {
                                UMC.Data.CSV.CSVFormat(writer, d);
                                writer.Write(",");
                            }
                            writer.WriteLine();
                            writer.Flush();
                        }
                        if (okindex + 10 < rowIndex)
                        {
                            new ArgumentException(String.Format("连续超过10条无效的数据"));
                        }
                    });
                    writer.Flush();
                    writer.Close();
                    log.End("导入数据完成");
                    log.Info(String.Format("导入成功{0}条", total));
                    log.Info(String.Format("用时{0}", DateTime.Now - now));
                }
                catch (Exception ex)
                {
                    log.End(String.Format("在{0}行导入失败", rowIndex));
                    log.Info(ex.Message);
                }
                finally
                {
                    file.Close();
                    reader.Close();
                    log.Close();
                }
            });    //.Start();

            this.Context.Send(new UISectionBuilder("System", "Log", new WebMeta("Key", Key))
                              .Builder(), true);
        }
示例#4
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var TypeId = UMC.Data.Utility.Guid(Web.UIDialog.AsyncDialog("Id", dkey =>
            {
                var menus = new List <UMC.Data.Entities.Menu>();
                UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Menu>().Order.Asc(new UMC.Data.Entities.Menu {
                    Seq = 0
                })
                .Entities.Query(dr => menus.Add(dr));
                //menubar

                var menu = new List <WebMeta>();

                foreach (var p in menus.FindAll(d => d.ParentId == Guid.Empty))
                {
                    var IsDisable = p.IsDisable == true;
                    var m         = new WebMeta().Put("icon", p.Icon).Put("text", p.Caption).Put("id", p.Id).Put("disable", p.IsDisable == true);

                    //m.Put("url")
                    menu.Add(m);
                    var data2 = new System.Data.DataTable();
                    data2.Columns.Add("id");
                    data2.Columns.Add("text");
                    data2.Columns.Add("url");
                    data2.Columns.Add("disable", typeof(bool));
                    var childs = menus.FindAll(c => c.ParentId == p.Id);
                    if (childs.Count > 0)
                    {
                        foreach (var ch in childs)
                        {
                            data2.Rows.Add(ch.Id, ch.Caption, ch.Url, IsDisable || ch.IsDisable == true);
                        }

                        m.Put("menu", data2);
                    }
                    else
                    {
                        m.Put("url", p.Url);
                    }
                }

                response.Redirect(menu);
                return(this.DialogValue("none"));
            }), true);

            var cateEntity = Database.Instance().ObjectEntity <UMC.Data.Entities.Menu>();


            cateEntity.Where.And().Equal(new UMC.Data.Entities.Menu
            {
                Id = TypeId ?? Guid.Empty
            });
            var link = cateEntity.Single() ?? new Data.Entities.Menu();

            var parentId = link.ParentId ?? UMC.Data.Utility.Guid(this.AsyncDialog("ParentId", "none")) ?? Guid.Empty;


            var userValue = this.AsyncDialog("Settings", d =>
            {
                var fdlg   = new Web.UIFormDialog();
                fdlg.Title = "菜单设置";

                if (parentId == Guid.Empty)
                {
                    fdlg.AddOption("菜单图标", "Icon", link.Icon, String.IsNullOrEmpty(link.Icon) ? "请选择" : "已选择").PlaceHolder("请参考UMC图标库")
                    .Command("System", "Icon");
                }
                fdlg.AddText("菜单标题", "Caption", link.Caption);
                if (parentId == Guid.Empty)
                {
                    fdlg.AddText("菜单网址", "Url", link.Url).NotRequired();
                }
                else
                {
                    fdlg.AddText("菜单网址", "Url", link.Url);//.Put("tip", "");
                }
                fdlg.AddNumber("展示顺序", "Seq", link.Seq);
                if (link.Id.HasValue)
                {
                    fdlg.AddCheckBox("", "Status", "n").Add("禁用此菜单", "Disable", link.IsDisable == true);
                    fdlg.AddUIIcon("\uf13e", "权限设置").Command(request.Model, "Auth", link.Id.ToString());
                }


                fdlg.Submit("确认", this.Context.Request, "Settings.Menu");
                return(fdlg);
            });

            UMC.Data.Reflection.SetProperty(link, userValue.GetDictionary());
            if (link.Id.HasValue)
            {
                link.IsDisable = (userValue["Status"] ?? "").Contains("Disable");
                cateEntity.Update(link);
                this.Prompt("更新成功", false);
            }
            else
            {
                link.ParentId  = parentId;
                link.Id        = Guid.NewGuid();
                link.IsDisable = false;
                cateEntity.Insert(link);
                this.Prompt("添加成功", false);
            }
            this.Context.Send(new UMC.Web.WebMeta().Put("type", "Settings.Menu"), true);
        }
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var user = UMC.Security.Identity.Current;
            var act  = Account.Create(user.Id.Value);


            var value = Web.UIDialog.AsyncDialog("Email", d =>
            {
                var acc = act[UMC.Security.Account.EMAIL_ACCOUNT_KEY];
                if (acc != null && (acc.Flags & UserFlags.UnVerification) != UserFlags.UnVerification)
                {
                    return(new Web.UIConfirmDialog("您确认解除与邮箱的绑定吗")
                    {
                        Title = "解除确认", DefaultValue = "Change"
                    });
                }


                var t = new Web.UITextDialog()
                {
                    Title = "邮箱绑定", DefaultValue = acc != null ? acc.Name : ""
                };
                t.Config["submit"] = "下一步";
                return(t);
            });

            switch (value)
            {
            case "Change":

                Remove();
                return;
            }

            if (Data.Utility.IsEmail(value) == false)
            {
                this.Prompt("邮箱格式不正确");
            }


            var entity = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>();

            entity.Where.And().Equal(new UMC.Data.Entities.Account {
                Name = value, Type = Account.EMAIL_ACCOUNT_KEY
            }).And().Unequal(new Data.Entities.Account {
                user_id = user.Id
            });
            if (entity.Count() > 0)
            {
                this.Prompt("此邮箱已存在绑定");
            }


            var Code = UMC.Web.UIDialog.AsyncDialog("Code", g =>
            {
                var fm = new Web.UIFormDialog()
                {
                    Title = "验证码"
                };
                fm.AddTextValue().Put("邮箱", value);
                fm.AddVerify("验证码", "Code", "您邮箱收到的验证码")
                .Put("Command", "Email").Put("Model", "Account").Put("SendValue", new UMC.Web.WebMeta().Put("Email", value).Put("Code", "Send")).Put("Start", "YES");

                fm.Submit("确认验证码", request, "Email");
                return(fm);
            });

            if (Code == "Send")
            {
                this.SendEmail(value);
                this.Prompt("验证码已发送");
            }
            var session = new UMC.Configuration.Session <Hashtable>(value);

            if (session.Value != null)
            {
                var code = session.Value["Code"] as string;
                if (String.Equals(code, Code))
                {
                    Account.Post(value, user.Id.Value, Security.UserFlags.Normal, Account.EMAIL_ACCOUNT_KEY);
                    this.Prompt("邮箱绑定成功", false);
                    this.Context.Send(new UMC.Web.WebMeta().Put("type", "Email"), true);
                }
            }


            this.Prompt("您输入的验证码错误");
        }
示例#6
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var key = this.AsyncDialog("Key", g => this.DialogValue("Editer"));
            var sid = Web.UIDialog.AsyncDialog("Id", d =>
            {
                var grid = new SubjectCategoryDialog()
                {
                    IsPage       = true,
                    CloseEvent   = "UI.Event",
                    RefreshEvent = "Subject.Category"
                };
                if (!request.IsCashier)
                {
                    grid.Visible = Visibility.Visible;
                }
                if (request.IsMaster)
                {
                    grid.Menu("新建", request.Model, request.Command, new WebMeta("Key", "Editer", d, Guid.NewGuid().ToString()));
                }
                return(grid);
            });
            var cmdId = UMC.Data.Utility.Guid(sid) ?? Guid.Empty;

            var category = new Category();

            var objectEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Category>();

            category = objectEntity.Where.And().Equal(new Category {
                Id = cmdId
            }).Entities.Single() ?? category;

            if (key == "Editer" && request.IsMaster)
            {
            }
            else
            {
                this.Context.Send(new WebMeta().UIEvent(key, new ListItem(category.Caption, category.Id.ToString())), true);
            }
            var Settings = Web.UIFormDialog.AsyncDialog("Settings", d =>
            {
                var fmdg = new Web.UIFormDialog();
                if (category.Id.HasValue == false)
                {
                    fmdg.Title = "新建栏位";
                    fmdg.AddText("栏位名称", "Caption", category.Caption);
                    fmdg.AddOption("版务人员", "user_id", (category.user_id ?? Guid.Empty).ToString(), "请选择版务人员")
                    .Put("placeholder", "请选择版务人员").Command("Settings", "SelectUser");
                    fmdg.AddNumber("显示顺序", "Sequence", category.Sequence);
                }
                else
                {
                    fmdg.Title = "编辑栏位";
                    fmdg.AddText("栏位名称", "Caption", category.Caption);
                    var value = (category.user_id ?? Guid.Empty);
                    var text  = "请设置";
                    if (value != Guid.Empty)
                    {
                        var uAlias = UMC.Data.Database.Instance().ObjectEntity <User>()
                                     .Where.And().Equal(new User {
                            Id = value
                        }).Entities.Single();
                        if (uAlias != null)
                        {
                            text = uAlias.Alias;
                        }
                    }
                    fmdg.AddOption("版务人员", "user_id", value.ToString(), text).Put("placeholder", "请选择版务人员")
                    .Command("Settings", "SelectUser");
                    fmdg.AddNumber("显示顺序", "Sequence", category.Sequence);
                    fmdg.AddRadio("可见状态", "Visible")
                    .Put("可见", Visibility.Visible.ToString(), category.Visible == Visibility.Visible)
                    .Put("隐藏", Visibility.Hidden.ToString(), category.Visible == Visibility.Hidden);
                }
                fmdg.Submit("确认提交", request, "Subject.Category");
                if (category.Id.HasValue)
                {
                    fmdg.AddUI("专题主题设计", "去设计").Command("Design", "Page", category.Id.ToString());
                }
                return(fmdg);
            });

            UMC.Data.Reflection.SetProperty(category, Settings.GetDictionary());

            if (category.Id.HasValue == false)
            {
                category.Id = Guid.NewGuid();

                category.Count      = 0;
                category.Attentions = 0;
                category.Visible    = Visibility.Visible;

                objectEntity.Insert(category);
            }
            else
            {
                objectEntity.Update(category);
            }
            this.Prompt("修改成功", false);
            this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Category"), true);
        }
示例#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);

            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);
        }
示例#8
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            int type = UMC.Data.Utility.Parse(this.AsyncDialog("AccountType", g =>
            {
                return Web.UIDialog.ReturnValue("-1");
            }), 0);
            var cUser = UMC.Security.Identity.Current;
            Guid user_id = UMC.Data.Utility.Guid(this.AsyncDialog("user_id", g =>
            {
                return Web.UIDialog.ReturnValue(cUser.Id.Value.ToString());
            })) ?? Guid.Empty;

            var user = UMC.Data.Database.Instance().ObjectEntity<UMC.Data.Entities.User>()
                .Where.And().Equal(new UMC.Data.Entities.User { Id = user_id }).Entities.Single();
            if (user == null)
            {

                type = 0;
            }

            string VerifyCode = this.AsyncDialog("VerifyCode", g =>
            {
                return Web.UIDialog.ReturnValue("0");
            });

            var Password = Web.UIFormDialog.AsyncDialog("Password", d =>
            {
                if (request.SendValues != null)
                {
                    var meta = request.SendValues;
                    if (meta.ContainsKey("NewPassword"))
                    {
                        return Web.UIDialog.ReturnValue(meta);
                    }
                }
                var dialog = new Web.UIFormDialog();

                if (type > 0)
                {
                    dialog.Title = "找回密码";
                }
                else if (type < 0)
                {
                    dialog.Title = "修改密码";
                    if (cUser.IsAuthenticated == false)
                    {
                        this.Prompt("请登录");
                    }
                    dialog.AddPassword("原密码", "Password", true);//.Put("plo")
                }
                else
                {
                    if (cUser.IsAuthenticated == false)
                    {
                        this.Prompt("请登录");
                    }
                    dialog.Title = "设置密码";
                }
                dialog.AddPassword("新密码", "NewPassword", false);
                dialog.AddPassword("确认新密码", "NewPassword2", false).Put("ForName", "NewPassword");
                dialog.Submit("确认修改", request, "account");
                return dialog;

            });
            var mc = UMC.Security.Membership.Instance();
            if (Password.ContainsKey("Password"))
            {


                if (mc.Password(cUser.Name, Password["Password"], 0) == 0)
                {
                    mc.Password(cUser.Name, Password["NewPassword"]);
                    this.Prompt("密码修改成功,您可以用新密码登录了", false);

                    WebMeta print = new UMC.Web.WebMeta();
                    print["type"] = "account";
                    print["name"] = "Password";
                    print["value"] = "Password";
                    this.Context.Send(print, true);

                }
                else
                {
                    this.Prompt("您的原密码不正确");
                }
            }
            else
            {

                if (user == null && cUser.Id == user_id)
                {
                    Membership.Instance().CreateUser(cUser.Id.Value, cUser.Name, Password["NewPassword"], cUser.Alias);
                    this.Prompt("密码修改成功,您可以用新密码登录了", false);
                    this.Context.Send(new UMC.Web.WebMeta().Put("type", "account"), true);
                }

                var eac = UMC.Data.Database.Instance().ObjectEntity<UMC.Data.Entities.Account>()
                   .Where.And().Equal(new Data.Entities.Account { user_id = user_id, Type = type }).Entities.Single();

                var acc = Account.Create(eac);
                if (String.Equals(acc.Items[Account.KEY_VERIFY_FIELD] as string, VerifyCode))
                {
                    mc.Password(user.Username, Password["NewPassword"]);
                    acc.Items.Clear();
                    acc.Commit();
                    this.Prompt("密码修改成功,您可以用新密码登录了", false);
                    this.Context.Send(new UMC.Web.WebMeta().Put("type", "account"), true);
                }
                else
                {
                    this.Prompt("非法入侵");
                }
            }

        }
        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);
            }
        }
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var refer_id = UMC.Data.Utility.Guid(this.AsyncDialog("Refer", g =>
            {
                return(new Web.UITextDialog()
                {
                    Title = "评论的主题"
                });
            }));

            var user = UMC.Security.Identity.Current;

            var Id = UMC.Data.Utility.Guid(this.AsyncDialog("Id", g =>
            {
                return(this.DialogValue(Guid.NewGuid().ToString()));
            })).Value;

            var commentEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Comment>()
                                .Where.And().In(new Comment {
                Id = refer_id
            }, Id).Entities;
            var commant = commentEntity.Single();

            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 Content = Web.UIDialog.AsyncDialog("Content", g =>
            {
                var from = new Web.UIFormDialog();
                if (commant != null)
                {
                    from.Title = "回复评论";
                }
                else
                {
                    from.Title = "评论";
                }
                if (request.IsApp)
                {
                    var sn = new WebMeta(request.Arguments);
                    sn.Put("Id", Id).Put("Refer", refer_id);
                    var ms = new WebMeta().Put("submit", new UIClick(sn)
                    {
                        Text = commant != null ? "请回复" : "请评论"
                    }.Send(request.Model, request.Command));

                    this.Context.Send(commant == null ? "Comment" : "Reply", ms, true);
                }
                from.AddTextarea("内容", "Content", String.Empty).Put("MinSize", "6");

                if (commant == null)
                {
                    from.AddFiles("图片上传", "Picture").Put("required", "none")
                    .Command("Design", "Picture", new UMC.Web.WebMeta().Put("id", Id));
                }

                from.Submit(commant != null ? "确认回复" : "确认评论", request, "UI.Event");
                return(from);
            });
            var image = this.AsyncDialog("image", "none");

            if (image != "none")
            {
                var webr = UMC.Data.WebResource.Instance();
                var imgs = image.Split(',');
                var ls   = new List <Picture>();
                for (var i = 0; i < imgs.Length; i++)
                {
                    webr.Transfer(new Uri(imgs[i]), Id, i + 1);
                    ls.Add(new Picture {
                        group_id = Id, Seq = i + 1, UploadDate = DateTime.Now, user_id = user.Id
                    });
                }
                if (ls.Count > 0)
                {
                    var entity = UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Picture>();

                    entity.Where.And().Equal(new UMC.Data.Entities.Picture {
                        group_id = Id
                    }).Entities.Delete();
                    entity.Insert(ls.ToArray());
                }
            }
            if (commant != null)
            {
                if (commant.Id == Id)
                {
                    return;
                }
                var forId = commant.for_id ?? Guid.Empty;
                if (forId == Guid.Empty)
                {
                    forId = commant.Id.Value;
                }
                var entity = Utility.CMS.ObjectEntity <Subject>()
                             .Where.And().Equal(new Subject {
                    Id = commant.ref_id
                }).Entities;
                var sinle = entity.Single(new Subject {
                    Reply = 0, project_id = Guid.Empty
                });
                if (sinle != null)
                {
                    if (sinle.Reply.HasValue)
                    {
                        entity.Update("{0}+{1}", new Subject {
                            Reply = 1
                        });
                    }
                    else
                    {
                        entity.Update(new Subject {
                            Reply = 1
                        });
                    }
                }

                commentEntity.Insert(new Comment
                {
                    Id          = Id,
                    CommentDate = DateTime.Now,
                    for_id      = forId,
                    ref_id      = commant.ref_id,
                    Content     = Content,
                    Effective   = 0,
                    Farworks    = 0,
                    Invalid     = 0,
                    project_id  = sinle != null ? sinle.project_id : null,
                    Reply       = 0,
                    Score       = 0,
                    Unhealthy   = 0,
                    Visible     = 0,
                    Poster      = user.Alias,
                    user_id     = user.Id
                });
                var cm = Utility.CMS.ObjectEntity <UMC.Data.Entities.Comment>()
                         .Where.And().Equal(new Data.Entities.Comment {
                    Id = commant.Id
                })
                         .Entities.Single();
                var editer = new Web.UISection.Editer(section, row);
                editer.Put((Utility.Comment(cm, request.Model)), false);
                editer.Builder(this.Context, ui, true);
            }
            else
            {
                var entity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>()
                             .Where.And().Equal(new Subject {
                    Id = refer_id
                }).Entities;
                var sinle = entity.Single(new Subject {
                    Reply = 0, project_id = Guid.Empty
                });
                commentEntity.Insert(new Comment
                {
                    Id          = Id,
                    CommentDate = DateTime.Now,
                    for_id      = Guid.Empty,
                    ref_id      = refer_id,
                    project_id  = sinle != null ? sinle.project_id : null,
                    Content     = Content,
                    Effective   = 0,
                    Farworks    = 0,
                    Invalid     = 0,
                    Reply       = 0,
                    Score       = 0,
                    Unhealthy   = 0,
                    Visible     = 0,
                    Poster      = user.Alias,
                    user_id     = user.Id
                });
                if (sinle != null)
                {
                    if (sinle.Reply.HasValue)
                    {
                        entity.Update("{0}+{1}", new Subject {
                            Reply = 1
                        });
                    }
                    else
                    {
                        entity.Update(new Subject {
                            Reply = 1
                        });
                    }


                    var editer = new Web.UISection.Editer(1, 1);
                    var cm     = Utility.CMS.ObjectEntity <UMC.Data.Entities.Comment>()
                                 .Where.And().Equal(new Data.Entities.Comment {
                        Id = Id, for_id = Guid.Empty
                    })
                                 .Entities.Single();

                    if (commentEntity.Where.Reset().And().Equal(new Comment {
                        ref_id = refer_id, for_id = Guid.Empty
                    }).And().Greater(new Comment
                    {
                        Visible = -1
                    }).Entities.Count() == 1)
                    {
                        editer.Put(Utility.Comment(cm, request.Model), false);
                    }
                    else
                    {
                        editer.Insert(Utility.Comment(cm, request.Model));
                    }

                    editer.Builder(this.Context, ui, true);
                }
            }
        }
示例#11
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;
            }
        }
示例#12
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var key  = this.AsyncDialog("Key", g => this.DialogValue("EDITER"));
            var user = Security.Identity.Current;
            var sid  = Web.UIDialog.AsyncDialog("Id", d =>
            {
                if (request.SendValues == null || request.SendValues.ContainsKey("start") == false)
                {
                    var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments);
                    buider.CloseEvent("UI.Event");
                    buider.RefreshEvent("Subject.ProjectItem");
                    this.Context.Send(buider.Builder(), true);
                }
                UITitle title = UITitle.Create();

                title.Title = "我参与的项目";
                switch (key)
                {
                case "EDITER":
                    break;

                default:
                    title.Title = "选择项目";
                    break;
                }

                var ui = UISection.Create(title);

                Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project {
                    user_id = user.Id
                })
                .And().In("Id", Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember {
                    user_id = user.Id
                })
                          .And().In(new ProjectMember {
                    AuthType = WebAuthType.Admin
                }, WebAuthType.User).Entities.Script(new ProjectMember {
                    project_id = Guid.Empty
                })).Entities.Order.Asc(new Project {
                    Sequence = 0
                }).Entities.Query(dr =>
                {
                    ui.AddCell(dr.Caption, new UIClick(new WebMeta(request.Arguments).Put("Id", dr.Id)).Send(request.Model, request.Command));
                });
                if (ui.Length == 0)
                {
                    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)));
                }

                response.Redirect(ui);

                return(this.DialogValue("none"));
            });
            var cmdId = UMC.Data.Utility.Guid(sid) ?? Guid.Empty;

            var category = new ProjectItem();

            var objectEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectItem>();

            category = objectEntity.Where.And().Equal(new ProjectItem
            {
                Id = cmdId
            }).Entities.Single() ?? category;
            switch (key)
            {
            case "EDITER":
                break;

            default:
                this.Context.Send(new WebMeta().UIEvent(key, new ListItem(category.Caption, category.Id.ToString())), true);
                break;
            }
            var Project = Utility.Guid(this.AsyncDialog("Project", g => this.DialogValue("Team"))).Value;

            var project = Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>().Where.And().Equal(new Data.Entities.Project {
                Id = Project
            })
                          .Entities.Single();

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

                    default:
                        this.Prompt("您未有编辑栏位权限");
                        break;
                    }
                }
                else
                {
                    this.Prompt("您未有编辑栏位权限");
                }
            }

            var Caption = this.AsyncDialog("Caption", d =>
            {
                var fmdg   = new Web.UIFormDialog();
                fmdg.Title = category.Id.HasValue ? "编辑栏位" : "新建栏位";
                fmdg.AddText("栏位名称", "Caption", category.Caption);
                if (category.Id.HasValue)
                {
                    fmdg.AddText("栏位简码", "Code", category.Code);
                    fmdg.AddCheckBox("", "Status", "NO").Put("隐藏", "Hide", category.Hide == true).Put("删除", "DEL");
                }
                fmdg.Submit("确认", request, "Subject.ProjectItem", "Subject.ProjectItem.Del");
                return(fmdg);
            });
            var team = new ProjectItem();

            UMC.Data.Reflection.SetProperty(team, Caption.GetDictionary());

            if (category.Id.HasValue == false)
            {
                team.Id           = Guid.NewGuid();
                team.project_id   = Project;
                team.Code         = Utility.Parse36Encode(team.Id.Value.GetHashCode());
                team.user_id      = user.Id;
                team.CreationTime = DateTime.Now;
                team.Sequence     = Utility.TimeSpan();
                team.Hide         = false;

                objectEntity.Insert(team);

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

                Utility.CMS.ObjectEntity <ProjectDynamic>()
                .Insert(new ProjectDynamic
                {
                    Time       = Utility.TimeSpan(),
                    user_id    = user.Id,
                    Explain    = "创建了栏位",
                    project_id = portfolio.project_id,
                    refer_id   = portfolio.Id,
                    Title      = portfolio.Caption,
                    Type       = DynamicType.ProjectItem
                });
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.ProjectItem").Put("id", team.Id).Put("text", team.Caption)
                                  .Put("path", String.Format("{0}/{1}", project.Code, team.Code))
                                  , true);
            }
            else
            {
                var status = Caption["Status"] ?? "";
                if (status.Contains("DEL"))
                {
                    if (Utility.CMS.ObjectEntity <ProjectItem>().Where.And().Equal(new ProjectItem
                    {
                        project_id = category.project_id.Value
                    }).Entities.Count() == 1)
                    {
                        this.Prompt("最少需要一个栏位");
                    }
                    Utility.CMS.ObjectEntity <Portfolio>().Where.And().Equal(new Portfolio
                    {
                        project_item_id = category.Id
                    }).Entities.Delete();
                    Utility.CMS.ObjectEntity <Subject>().Where.And().Equal(new Subject
                    {
                        project_item_id = category.Id
                    }).Entities.Update(new Subject {
                        last_user_id = user.Id, LastDate = DateTime.Now, Visible = -1
                    });
                    objectEntity.Delete();

                    Utility.CMS.ObjectEntity <ProjectDynamic>()
                    .Insert(new ProjectDynamic
                    {
                        Time       = Utility.TimeSpan(),    //DateTime.Now,
                        user_id    = user.Id,
                        Explain    = "删除了栏位",
                        project_id = category.project_id,
                        refer_id   = category.Id,
                        Title      = category.Caption,
                        Type       = DynamicType.ProjectItem
                    });

                    this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.ProjectItem.Del").Put("id", category.Id).Put("text", team.Caption), true);
                }
                else
                {
                    if (String.Equals(team.Code, category.Code, StringComparison.CurrentCulture) == false)
                    {
                        if (Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectItem>()
                            .Where.And().Equal(new ProjectItem
                        {
                            Code = team.Code,
                            project_id = category.project_id
                        }).Entities.Count() > 0)
                        {
                            this.Prompt("存在相同的简码");
                        }
                    }
                    team.Hide = status.Contains("Hide");
                    objectEntity.Update(team);
                    Utility.CMS.ObjectEntity <ProjectDynamic>()
                    .Insert(new ProjectDynamic
                    {
                        Time       = Utility.TimeSpan(),
                        user_id    = user.Id,
                        Explain    = "修改了栏位",
                        project_id = category.project_id,
                        refer_id   = category.Id,
                        Title      = category.Caption,
                        Type       = DynamicType.ProjectItem
                    });
                    this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.ProjectItem").Put("id", category.Id).Put("text", team.Caption), true);
                }
            }
            this.Prompt("修改成功");
        }
示例#13
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var type = this.AsyncDialog("type", t => this.DialogValue("auto"));

            switch (type)
            {
            case "wx":
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "login.weixin"), true);
                break;

            case "qq":
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "login.qq"), true);
                break;
            }
            var user = Web.UIFormDialog.AsyncDialog("Login", d =>
            {
                var u = new UMC.Data.Entities.User {
                    Username = String.Empty
                };


                var dialog   = new Web.UIFormDialog();
                dialog.Title = "账户登录";
                if (request.IsApp)
                {
                    dialog.AddText("手机号码", "Username", u.Username).Put("placeholder", "手机");

                    dialog.AddVerify("验证码", "VerifyCode", "您收到的验证码").Put("For", "Username").Put("To", "Mobile")
                    .Put("Command", request.Command).Put("Model", request.Model);
                    dialog.Submit("登录", request, "User");
                    dialog.AddUIIcon("\uf234", "注册新用户").Put("Model", request.Model).Put("Command", "Register");
                }
                else
                {
                    dialog.AddText("用户名", "Username", u.Username).Put("placeholder", "手机/邮箱");

                    dialog.AddPassword("用户密码", "Password", String.Empty);
                    dialog.Submit("登录", request, "User");
                    dialog.AddUIIcon("\uf1c6", "忘记密码").Put("Model", request.Model).Put("Command", "Forget");
                    dialog.AddUIIcon("\uf234", "注册新用户").Put("Model", request.Model).Put("Command", "Register");
                }
                return(dialog);
            });

            if (user.ContainsKey("Mobile"))
            {
                var mobile = user["Mobile"];

                var account = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>()
                              .Where.And().Equal(new UMC.Data.Entities.Account
                {
                    Name = mobile,
                    Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY
                }).Entities.Single();
                if (account == null)
                {
                    this.Prompt("不存在此账户");
                }


                this.SendMobileCode(mobile);
                this.Prompt("验证码已发送", false);
                this.Context.Send(new UMC.Web.WebMeta().UIEvent("VerifyCode", this.AsyncDialog("UI", "none"), new UMC.Web.WebMeta().Put("text", "验证码已发送")), true);
            }

            var username = user["Username"];

            var userManager = UMC.Security.Membership.Instance();

            if (user.ContainsKey("VerifyCode"))
            {
                var VerifyCode = user["VerifyCode"];
                var session    = new UMC.Configuration.Session <Hashtable>(username);
                if (session.Value != null)
                {
                    var code = session.Value["Code"] as string;
                    if (String.Equals(code, VerifyCode) == false)
                    {
                        this.Prompt("请输入正确的验证码");
                    }
                }
                else
                {
                    this.Prompt("请输入正确的验证码");
                }
                var entity = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>();
                UMC.Data.Entities.Account ac = new UMC.Data.Entities.Account
                {
                    Name = username,
                    Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY
                };

                var eData = entity.Where.And().Equal(ac).Entities.Single();
                if (eData == null)
                {
                    this.Prompt("无此号码关联的账户,请注册");
                }
                else
                {
                    var iden = userManager.Identity(eData.user_id.Value);
                    System.Security.Principal.IPrincipal p = iden;
                    if (p.IsInRole(UMC.Security.Membership.UserRole))
                    {
                        this.Prompt("您是内部账户,不可从此入口登录");
                    }


                    UMC.Security.AccessToken.Login(iden, UMC.Security.AccessToken.Token.Value, request.IsApp ? "App" : "Client", true);
                    this.Context.Send("User", true);
                }
            }
            else
            {
                var passwork = user["Password"];

                var maxTimes = 5;
                UMC.Security.Identity identity = null;
                if (UMC.Data.Utility.IsPhone(username))
                {
                    identity = userManager.Identity(username, Security.Account.MOBILE_ACCOUNT_KEY) ?? userManager.Identity(username);
                }
                else if (username.IndexOf('@') > -1)
                {
                    identity = userManager.Identity(username, Security.Account.EMAIL_ACCOUNT_KEY) ?? userManager.Identity(username);
                }
                else
                {
                    identity = userManager.Identity(username);
                }
                if (identity == null)
                {
                    this.Prompt("用户不存在,请确认用户名");
                }
                var times = userManager.Password(identity.Name, passwork, maxTimes);
                switch (times)
                {
                case 0:
                    var iden = userManager.Identity(username);
                    System.Security.Principal.IPrincipal p = iden;
                    if (p.IsInRole(UMC.Security.Membership.UserRole))
                    {
                        this.Prompt("您是内部账户,不可从此入口登录");
                    }


                    UMC.Security.AccessToken.Login(iden, UMC.Security.AccessToken.Token.Value, request.IsApp ? "App" : "Client", true);


                    this.Context.Send("User", true);



                    break;

                case -2:
                    this.Prompt("您的用户已经锁定,请过后登录");
                    break;

                case -1:
                    this.Prompt("您的用户不存在,请确定用户名");

                    break;

                default:
                    this.Prompt(String.Format("您的用户和密码不正确,您还有{0}次机会", maxTimes - times));

                    break;
                }
            }
        }
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var user = Web.UIFormDialog.AsyncDialog("Register", d =>
            {
                if (request.SendValues != null && request.SendValues.Count > 0)
                {
                    return(this.DialogValue(request.SendValues));
                }

                var u = new UMC.Data.Entities.User {
                    Username = String.Empty
                };

                var dialog   = new Web.UIFormDialog();
                dialog.Title = "账户注册";
                dialog.AddText("昵称", "Alias", u.Alias);

                dialog.AddText("手机号码", "Username", u.Username);
                dialog.AddVerify("验证码", "VerifyCode", "您收到的验证码").Put("For", "Username").Put("To", "Mobile")
                .Put("Command", request.Command).Put("Model", request.Model);

                if (request.IsApp == false)
                {
                    dialog.AddPassword("密码", "Password", false);
                    dialog.AddPassword("确认密码", "NewPassword2", false).Put("placeholder", "再输入一次密码").Put("ForName", "Password");
                }
                dialog.Submit("确认注册", request, "register");
                return(dialog);
            });

            if (user.ContainsKey("Mobile"))
            {
                var mobile  = user["Mobile"];
                var account = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>()
                              .Where.And().Equal(new UMC.Data.Entities.Account
                {
                    Name = mobile,
                    Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY
                }).Entities.Single();
                if (account != null)
                {
                    this.Prompt("此手机号码已经注册,你可直接登录");
                }
                this.SendMobileCode(mobile);
                this.Prompt("验证码已发送", false);
                this.Context.Send(new UMC.Web.WebMeta().UIEvent("VerifyCode", this.AsyncDialog("UI", "none"), new UMC.Web.WebMeta().Put("text", "验证码已发送")), true);
            }
            var username = user["Username"];

            if (user.ContainsKey("VerifyCode"))
            {
                var VerifyCode = user["VerifyCode"];
                var session    = new UMC.Configuration.Session <Hashtable>(username);
                if (session.Value != null)
                {
                    var code = session.Value["Code"] as string;
                    if (String.Equals(code, VerifyCode) == false)
                    {
                        this.Prompt("请输入正确的验证码");
                    }
                }
                else
                {
                    this.Prompt("请输入正确的验证码");
                }
            }


            var entity = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>();

            UMC.Data.Entities.Account ac = new UMC.Data.Entities.Account {
                Name = username
            };
            if (Data.Utility.IsEmail(username))
            {
                ac.Type = UMC.Security.Account.EMAIL_ACCOUNT_KEY;
                entity.Where.And().Equal(ac);
            }
            else if (Data.Utility.IsPhone(username))
            {
                ac.Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY;
                entity.Where.And().Equal(ac);
            }
            if (ac.Type.HasValue == false)
            {
                this.Prompt("只支持手机号注册");
            }
            if (entity.Count() > 0)
            {
                switch (ac.Type.Value)
                {
                case UMC.Security.Account.EMAIL_ACCOUNT_KEY:
                    this.Prompt("此邮箱已经注册");
                    break;

                default:
                    this.Prompt("此手机号已经注册");
                    break;
                }
            }
            var passwork     = user["Password"];
            var NewPassword2 = user["NewPassword2"];

            if (String.IsNullOrEmpty(NewPassword2) == false)
            {
                if (String.Equals(passwork, NewPassword2) == false)
                {
                    this.Prompt("两次密码不相同,请确认密码");
                }
            }
            var Alias = user["Alias"] ?? username;
            var uM    = UMC.Security.Membership.Instance();
            var uid   = uM.CreateUser(username, passwork ?? username, Alias);

            if (uid != Guid.Empty)
            {
                if (user.ContainsKey("VerifyCode"))
                {
                    UMC.Security.Account.Post(ac.Name, uid, UMC.Security.UserFlags.Normal, ac.Type.Value);
                }
                else
                {
                    UMC.Security.Account.Post(ac.Name, uid, UMC.Security.UserFlags.UnVerification, ac.Type.Value);
                }
                var iden = uM.Identity(username);

                UMC.Security.AccessToken.Login(iden, UMC.Security.AccessToken.Token.Value, request.IsApp ? "App" : "Client", true);

                this.Context.Send(new UMC.Web.WebMeta().Put("type", "register"), false);
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "User"), false);
                this.Prompt("注册成功");
            }
            else
            {
                this.Prompt("已经存在这个用户");
            }
        }
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var type = this.AsyncDialog("type", t => this.DialogValue("auto"));

            switch (type)
            {
            case "wx":
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "login.weixin"), true);
                break;

            case "qq":
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "login.qq"), true);
                break;
            }
            var user = Web.UIFormDialog.AsyncDialog("Login", d =>
            {
                if (request.SendValues != null && request.SendValues.Count > 0)
                {
                    return(this.DialogValue(request.SendValues));
                }
                if (request.Url.Query.Contains("_v=Sub"))
                {
                    this.Context.Send("Login", true);
                }

                //   var u = new UMC.Data.Entities.User { Username = String.Empty };


                var dialog   = new Web.UIFormDialog();
                dialog.Title = "登录";
                switch (type)
                {
                default:
                case "User":
                    this.Context.Send("LoginChange", false);
                    {
                        dialog.AddText("用户名", "Username", String.Empty).Put("placeholder", "用户名/手机/邮箱");

                        dialog.AddPassword("用户密码", "Password", String.Empty);

                        dialog.Submit("登录", request, "User", "LoginChange");
                        var uidesc = new UMC.Web.UI.UIDesc(new WebMeta().Put("eula", "用户协议").Put("private", "隐私政策"));
                        uidesc.Desc("登录即同意“{eula}”和“{private}”");
                        uidesc.Style.AlignCenter();
                        uidesc.Style.Color(0x888).Size(14).Height(34);
                        uidesc.Style.Name("eula").Color(0x3194d0).Click(new UIClick("365lu/provision/eula").Send("Subject", "UIData"));
                        uidesc.Style.Name("private").Color(0x3194d0).Click(new UIClick("365lu/provision/private").Send("Subject", "UIData"));
                        dialog.Add(uidesc);
                        dialog.AddUIIcon("\uf2c1", "免密登录").Command(request.Model, request.Command, "Mobile");
                        dialog.AddUIIcon("\uf1c6", "忘记密码").Put("Model", request.Model).Put("Command", "Forget");
                        dialog.AddUIIcon("\uf234", "注册新用户").Put("Model", request.Model).Put("Command", "Register");
                    }
                    break;

                case "Mobile":
                    this.Context.Send("LoginChange", false);
                    {
                        dialog.AddText("手机号码", "Username", String.Empty).Put("placeholder", "注册的手机号码");

                        dialog.AddVerify("验证码", "VerifyCode", "您收到的验证码").Put("For", "Username").Put("To", "Mobile")
                        .Put("Command", request.Command).Put("Model", request.Model);
                        dialog.Submit("登录", request, "User", "LoginChange");

                        var uidesc = new UMC.Web.UI.UIDesc(new WebMeta().Put("eula", "用户协议").Put("private", "隐私政策"));
                        uidesc.Desc("登录即同意“{eula}”和“{private}”");
                        uidesc.Style.AlignCenter();
                        uidesc.Style.Color(0x888).Size(14).Height(34);
                        uidesc.Style.Name("eula").Color(0x3194d0).Click(new UIClick("365lu/provision/eula").Send("Subject", "UIData"));
                        uidesc.Style.Name("private").Color(0x3194d0).Click(new UIClick("365lu/provision/private").Send("Subject", "UIData"));
                        dialog.Add(uidesc);
                        dialog.AddUIIcon("\uf13e", "密码登录").Command(request.Model, request.Command, "User");
                        dialog.AddUIIcon("\uf234", "注册新用户").Command(request.Model, "Register");    //.Put("Model", request.Model).Put("Command", "Register");
                    }
                    break;
                }

                return(dialog);
            });

            if (user.ContainsKey("Mobile"))
            {
                var mobile = user["Mobile"];

                var account = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>()
                              .Where.And().Equal(new UMC.Data.Entities.Account
                {
                    Name = mobile,
                    Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY
                }).Entities.Single();
                if (account == null)
                {
                    this.Prompt("不存在此账户");
                }


                this.SendMobileCode(mobile);
                this.Prompt("验证码已发送", false);
                this.Context.Send(new UMC.Web.WebMeta().UIEvent("VerifyCode", this.AsyncDialog("UI", "none"), new UMC.Web.WebMeta().Put("text", "验证码已发送")), true);
            }

            var username = user["Username"];

            var userManager = UMC.Security.Membership.Instance();

            if (user.ContainsKey("VerifyCode"))
            {
                var VerifyCode = user["VerifyCode"];
                var session    = new UMC.Configuration.Session <Hashtable>(username);
                if (session.Value != null)
                {
                    var code = session.Value["Code"] as string;
                    if (String.Equals(code, VerifyCode) == false)
                    {
                        this.Prompt("请输入正确的验证码");
                    }
                }
                else
                {
                    this.Prompt("请输入正确的验证码");
                }
                var entity = Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Account>();
                UMC.Data.Entities.Account ac = new UMC.Data.Entities.Account
                {
                    Name = username,
                    Type = UMC.Security.Account.MOBILE_ACCOUNT_KEY
                };

                var eData = entity.Where.And().Equal(ac).Entities.Single();
                if (eData == null)
                {
                    this.Prompt("无此号码关联的账户,请注册");
                }
                else
                {
                    var iden = userManager.Identity(eData.user_id.Value);
                    //System.Security.Principal.IPrincipal p = iden;
                    //if (p.IsInRole(UMC.Security.Membership.UserRole))
                    //{
                    //    this.Prompt("您是内部账户,不可从此入口登录");
                    //}


                    UMC.Security.AccessToken.Login(iden, UMC.Security.AccessToken.Token.Value, request.IsApp ? "App" : "Client", true);
                    this.Context.Send("User", true);
                }
            }
            else
            {
                var passwork = user["Password"];

                var maxTimes = 5;
                UMC.Security.Identity identity = null;
                if (UMC.Data.Utility.IsPhone(username))
                {
                    identity = userManager.Identity(username, Security.Account.MOBILE_ACCOUNT_KEY) ?? userManager.Identity(username);
                }
                else if (username.IndexOf('@') > -1)
                {
                    identity = userManager.Identity(username, Security.Account.EMAIL_ACCOUNT_KEY) ?? userManager.Identity(username);
                }
                else
                {
                    identity = userManager.Identity(username);
                }
                if (identity == null)
                {
                    this.Prompt("用户不存在,请确认用户名");
                }
                var times = userManager.Password(identity.Name, passwork, maxTimes);
                switch (times)
                {
                case 0:
                    var iden = userManager.Identity(username);
                    //System.Security.Principal.IPrincipal p = iden;
                    //if (p.IsInRole(UMC.Security.Membership.UserRole))
                    //{
                    //    this.Prompt("您是内部账户,不可从此入口登录");
                    //}


                    UMC.Security.AccessToken.Login(iden, UMC.Security.AccessToken.Token.Value, request.IsApp ? "App" : "Client", true);


                    this.Context.Send("User", true);



                    break;

                case -2:
                    this.Prompt("您的用户已经锁定,请过后登录");
                    break;

                case -1:
                    this.Prompt("您的用户不存在,请确定用户名");

                    break;

                default:
                    this.Prompt(String.Format("您的用户和密码不正确,您还有{0}次机会", maxTimes - times));

                    break;
                }
            }
        }
示例#16
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var user    = UMC.Security.Identity.Current;
            var groupId = UMC.Data.Utility.Guid(this.AsyncDialog("id", d =>
            {
                this.Prompt("请传入参数");
                return(this.DialogValue(user.Id.ToString()));
            }), true) ?? Guid.Empty;

            var Seq = this.AsyncDialog("seq", g =>
            {
                if (request.SendValues != null)
                {
                    return(this.DialogValue(request.SendValues["Seq"] ?? "0"));
                }
                else
                {
                    return(this.DialogValue("0"));
                }
            });
            WebResource oosr     = WebResource.Instance();//as OssResource;
            var         media_id = UMC.Web.UIDialog.AsyncDialog("media_id", g =>
            {
                if (request.IsApp)
                {
                    var f = Web.UIDialog.CreateDialog("File");
                    f.Config.Put("Submit", new UIClick(new WebMeta(request.Arguments.GetDictionary()).Put(g, "Value"))
                    {
                        Command = request.Command,
                        Model   = request.Model
                    });
                    return(f);
                }
                else
                {
                    var webr = UMC.Data.WebResource.Instance();
                    var from = new Web.UIFormDialog()
                    {
                        Title = "图片上传"
                    };

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

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

            var pictureEntity = UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Picture>();

            pictureEntity.Order.Asc(new Data.Entities.Picture {
                Seq = 0
            });
            pictureEntity.Where.Reset().And().Equal(new Data.Entities.Picture {
                group_id = groupId
            });
            if (String.Equals(media_id, "none"))
            {
                var seq = UMC.Data.Utility.Parse(Seq, 0);
                if (request.IsApp == false)
                {
                    this.AsyncDialog("Confirm", s =>
                    {
                        return(new Web.UIConfirmDialog(String.Format("确认删除此组第{0}张图片吗", seq))
                        {
                            Title = "删除提示"
                        });
                    });
                }

                if (seq == 1)
                {
                    pictureEntity.Where.And().Greater(new Data.Entities.Picture {
                        Seq = 1
                    });
                    var seqs = pictureEntity.Single();
                    if (seqs != null)
                    {
                        UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Picture>()
                        .Where.And().Equal(new Data.Entities.Picture {
                            Seq = 1, group_id = groupId
                        })
                        .Entities.Update(new Data.Entities.Picture {
                            UploadDate = DateTime.Now
                        });
                        pictureEntity.Where.And().Equal(new UMC.Data.Entities.Picture {
                            Seq = seqs.Seq
                        });

                        oosr.Transfer(new Uri(oosr.ResolveUrl(seqs.group_id.Value, seqs.Seq, 0)), groupId, seq);
                    }
                    else
                    {
                        pictureEntity.Where.Reset().And().Equal(new UMC.Data.Entities.Picture
                        {
                            Seq      = 1,
                            group_id = groupId
                        });
                    }
                    pictureEntity.Delete();
                }
                else
                {
                    pictureEntity.Where.And().Equal(new UMC.Data.Entities.Picture {
                        Seq = seq
                    });
                    pictureEntity.Delete();
                }
            }
            else
            {
                var type = this.AsyncDialog("type", g => this.DialogValue("jpg"));
                var seq  = UMC.Data.Utility.Parse(Seq, -1);
                if (media_id.StartsWith("http://") || media_id.StartsWith("https://"))
                {
                    var url = new Uri(media_id);
                    if (url.Host.StartsWith("oss."))
                    {
                        if (seq > -1)
                        {
                            if (seq < 1)
                            {
                                seq = (pictureEntity.Max(new Data.Entities.Picture {
                                    Seq = 0
                                }).Seq ?? 0) + 1;
                            }

                            UploadImage(groupId, seq, request.UserHostAddress, user.Id);
                        }
                        if (url.AbsolutePath.EndsWith(type, StringComparison.CurrentCultureIgnoreCase))
                        {
                            oosr.Transfer(url, groupId, seq, type);
                        }
                        else
                        {
                            oosr.Transfer(new Uri(String.Format("{0}?x-oss-process=image/format,{1}", media_id, type)), groupId, seq, type);
                        }
                    }
                    else
                    {
                        if (seq < 1)
                        {
                            seq = (pictureEntity.Max(new Data.Entities.Picture {
                                Seq = 0
                            }).Seq ?? 0) + 1;
                        }
                        UploadImage(groupId, seq, request.UserHostAddress, user.Id);
                        oosr.Transfer(new Uri(media_id), groupId, seq);
                    }
                }
            }

            this.Context.Send(new WebMeta().Put("type", "image").Put("id", groupId.ToString()), true);
        }
示例#17
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);
        }
示例#18
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var strUser = Web.UIDialog.AsyncDialog("Id", d =>
            {
                var dlg      = new UserDialog();
                dlg.IsSearch = true;
                dlg.IsPage   = true;
                if (request.IsMaster)
                {
                    dlg.Menu("创建", "Settings", "User", Guid.Empty.ToString());
                }
                dlg.RefreshEvent = "Setting";
                return(dlg);
            });
            var userId = UMC.Data.Utility.Guid(strUser) ?? Guid.Empty;

            if (request.IsMaster == false)
            {
                this.Prompt("只有管理员才能管理账户");
            }


            var userEntity = UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.User>();
            var user       = userEntity.Where.And().Equal(new Data.Entities.User
            {
                Id = userId
            }).Entities.Single() ?? new Data.Entities.User();

            var isAliassetting = false;

            if (userId != Guid.Empty && user.Id.HasValue)
            {
                var setting = Web.UIDialog.AsyncDialog("Setting", d =>
                {
                    var frm   = new Web.UIRadioDialog();
                    frm.Title = "用户操作";
                    frm.Options.Add("部门角色", "Setting");
                    frm.Options.Add("重置密码", "Passwrod");
                    frm.Options.Add("变更别名", "Alias");

                    if (Web.WebServlet.Auths().Count > 0)
                    {
                        frm.Options.Add("功能授权", "Wildcard");
                    }
                    return(frm);
                });
                switch (setting)
                {
                case "Setting":
                    this.Setting(userId);
                    break;

                case "Wildcard":
                    response.Redirect("Settings", "Wildcard", new UMC.Web.WebMeta().Put("Type", "User", "Value", user.Username), true);
                    break;

                case "Alias":
                    isAliassetting = true;
                    break;
                }
            }

            var users = this.AsyncDialog("User", d =>
            {
                var opts = new Web.ListItemCollection();
                var fmDg = new Web.UIFormDialog();
                if (userId == Guid.Empty || user.Id.HasValue == false)
                {
                    fmDg.Title = "添加新账户";

                    fmDg.AddText("账户名", "Username", String.Empty);
                    fmDg.AddText("别名", "Alias", user.Alias);

                    fmDg.AddPassword("密码", "Password", true);
                }
                else
                {
                    if (isAliassetting)
                    {
                        fmDg.Title = "变更别名";
                        opts.Add("登录名", user.Username);
                        fmDg.AddText("新别名", "Alias", user.Alias);
                    }
                    else
                    {
                        fmDg.Title = "重置密码";
                        opts.Add("别名", user.Alias);
                        opts.Add("登录名", user.Username);
                        fmDg.AddTextValue(opts);
                        fmDg.AddPassword("密码", "Password", true);
                    }
                }
                fmDg.Submit("确认提交", request, "Setting");
                return(fmDg);
            });

            if (userId == Guid.Empty || user.Id.HasValue == false)
            {
                if (userId == Guid.Empty)
                {
                    userId = UMC.Security.Membership.Instance().CreateUser(users["Username"].Trim(), users["Password"] ?? Guid.NewGuid().ToString(), users["Alias"]);
                    if (userId == Guid.Empty)
                    {
                        this.Prompt(String.Format("已经存在{0}用户名", users["Username"]));
                    }
                    else
                    {
                        UMC.Security.Membership.Instance().AddRole(users["Username"].Trim(), UMC.Security.Membership.UserRole);
                    }
                }
                else
                {
                    var uid = UMC.Security.Membership.Instance().CreateUser(userId, users["Username"].Trim(), users["Password"] ?? Guid.NewGuid().ToString(), users["Alias"]);
                    if (uid == null)
                    {
                        this.Prompt(String.Format("已经存在{0}用户名", users["Username"]));
                    }
                }


                this.Prompt("账户添加成功", false);

                this.Context.Send(new UMC.Web.WebMeta().Put("type", "Setting"), true);
            }
            else
            {
                if (users.ContainsKey("Password"))
                {
                    UMC.Security.Membership.Instance().Password(user.Username, users["Password"]);
                    this.Prompt(String.Format("{0}的密码已重置", user.Alias));
                }
                else
                {
                    UMC.Security.Membership.Instance().ChangeAlias(user.Username, users["Alias"]);
                    this.Prompt(String.Format("{0}的别名已重置成{1}", user.Username, users["Alias"]));
                }

                this.Context.Send(new UMC.Web.WebMeta().Put("type", "Setting"), true);
            }
        }
示例#19
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var key  = this.AsyncDialog("Key", g => this.DialogValue("EDITER"));
            var user = Security.Identity.Current;
            var sid  = Web.UIDialog.AsyncDialog("Id", d =>
            {
                var ProjectId = Utility.Guid(this.AsyncDialog("Project", g =>
                {
                    if (request.SendValues == null || request.SendValues.ContainsKey("start") == false)
                    {
                        var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments);
                        buider.CloseEvent("UI.Event").RefreshEvent("Subject.Project");
                        this.Context.Send(buider.Builder(), true);
                    }
                    UITitle title = UITitle.Create();

                    title.Title = "我的专栏项目";

                    var ui   = UISection.Create(title);
                    var ids  = new List <Guid>();
                    var pros = new List <Project>();
                    Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project {
                        user_id = user.Id
                    })
                    .Or().In("Id", Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember {
                        user_id = user.Id
                    })
                             .And().In(new ProjectMember {
                        AuthType = WebAuthType.Admin
                    }, WebAuthType.User).Entities.Script(new ProjectMember {
                        project_id = Guid.Empty
                    })).Entities.Order.Asc(new Project {
                        Sequence = 0
                    }).Entities.Query(dr =>
                    {
                        pros.Add(dr); ids.Add(dr.Id.Value);
                    });

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

                        foreach (var p in pros)
                        {
                            var sub  = subs.Find(s => s.project_id == p.Id);
                            var desc = new UIIconNameDesc(new UIIconNameDesc.Item(webr.ResolveUrl(p.Id.Value, "1", "4"), p.Caption,
                                                                                  String.Format("知识{0}篇", sub == null ? 0 : sub.Seq))
                                                          .Click(Web.UIClick.Query(new WebMeta().Put("Project", p.Id))));

                            //if(desc.Button())
                            if (p.user_id == user.Id)
                            {
                                desc.Button("我的", null, 0x25b864);
                            }
                            ui.Add(desc);
                        }
                    }
                    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.NewSection().AddCell('\uf19d', "创立我的项目"
                                                , "", new UIClick("News").Send(request.Model, "ProjectUI"));
                    }

                    response.Redirect(ui);

                    return(this.DialogValue("Project"));
                })) ?? Guid.Empty;
                if (ProjectId == Guid.Empty)
                {
                    this.Prompt("未传入项目");
                }
                var projectItemId = Utility.Guid(this.AsyncDialog("Item", g => this.DialogValue("Item"))) ?? Guid.Empty;

                if (request.SendValues == null || request.SendValues.ContainsKey("start") == false)
                {
                    var buider = new UISectionBuilder(request.Model, request.Command, request.Arguments);
                    buider.CloseEvent("UI.Event");
                    this.Context.Send(buider.Builder(), true);
                }

                UITitle uITItle = UITitle.Create();
                if (projectItemId == Guid.Empty)
                {
                    uITItle.Title = "选择栏位";
                }
                else
                {
                    uITItle.Title = "选择目录";
                }
                var sestion = UISection.Create(uITItle);
                if (projectItemId == Guid.Empty)
                {
                    var team = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project {
                        Id = ProjectId
                    }).Entities.Single();
                    sestion.AddCell("所属项目", team.Caption);
                    var ui2 = sestion.NewSection();
                    Utility.CMS.ObjectEntity <ProjectItem>().Where.And().Equal(new Data.Entities.ProjectItem {
                        project_id = ProjectId
                    }).Entities.Order.Asc(new ProjectItem {
                        Sequence = 0
                    }).Entities.Query(dr =>
                    {
                        ui2.AddCell(dr.Caption, Web.UIClick.Query(new WebMeta().Put("Item", dr.Id)));
                    });
                }
                else
                {
                    var team = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project
                    {
                        Id = ProjectId
                    }).Entities.Single();
                    sestion.AddCell("所属项目", team.Caption);

                    var project = Utility.CMS.ObjectEntity <ProjectItem>().Where.And().Equal(new Data.Entities.ProjectItem
                    {
                        Id = projectItemId
                    }).Entities.Single();
                    sestion.AddCell("所属栏位", project.Caption);
                    var ui2 = sestion.NewSection();

                    Utility.CMS.ObjectEntity <Portfolio>().Where.And().Equal(new Data.Entities.Portfolio {
                        project_item_id = project.Id
                    })
                    .Entities.Order.Asc(new Portfolio {
                        Sequence = 0
                    }).Entities.Query(dr =>
                    {
                        ui2.AddCell(dr.Caption, new Web.UIClick(new WebMeta(request.Arguments).Put(d, dr.Id)).Send(request.Model, request.Command));
                    });
                }
                response.Redirect(sestion);
                return(this.DialogValue("none"));
            });
            var cmdId = UMC.Data.Utility.Guid(sid) ?? Guid.Empty;

            var category = new Portfolio();

            var objectEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Portfolio>();

            category = objectEntity.Where.And().Equal(new Portfolio
            {
                Id = cmdId
            }).Entities.Single() ?? category;
            switch (key)
            {
            case "EDITER":
                break;

            default:
                this.Context.Send(new WebMeta().UIEvent(key, new ListItem(category.Caption, category.Id.ToString())), true);
                break;
            }

            var Caption = Web.UIDialog.AsyncDialog("Caption", d =>
            {
                var fmdg   = new Web.UIFormDialog();
                fmdg.Title = category.Id.HasValue ? "编辑" : "新建";
                fmdg.AddText("文集名称", "Caption", category.Caption);
                fmdg.Submit("确认提交", request, "Subject.Portfolio", "Subject.Portfolio.Add");
                return(fmdg);
            });

            category.Caption = Caption;

            if (category.Id.HasValue == false)
            {
                var ItemId = Utility.Guid(this.AsyncDialog("ItemId", g => this.DialogValue("Item"))).Value;

                var project = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectItem>().Where.And().Equal(new ProjectItem
                {
                    Id = ItemId
                }).Entities.Single();
                category.Id              = Guid.NewGuid();
                category.project_id      = project.project_id;
                category.project_item_id = project.Id;

                category.user_id      = user.Id;
                category.CreationTime = DateTime.Now;
                category.Count        = 0;
                category.Sequence     = Utility.TimeSpan();


                objectEntity.Insert(category);

                this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Portfolio.Add").Put("Id", category.Id).Put("Text", category.Caption), true);
            }
            else
            {
                objectEntity.Update(new Portfolio {
                    Caption = Caption
                });
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Portfolio").Put("Id", category.Id), true);
            }
        }