Esempio n. 1
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            Guid designId = UMC.Data.Utility.Guid(this.AsyncDialog("Id", g => this.DialogValue(Guid.Empty.ToString()))).Value;//this.DialogValue(response.Ticket[AttributeNames.TICKET_STORE_ID])), true).Value;


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

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

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

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

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

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

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


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

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

                    switch (headers.Length)
                    {
                    case 0:

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

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


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


                        break;
                    }


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

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

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

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

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

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


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

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

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

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

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


                    chash.Add("sections", tabs);
                    chash.Add("title", title);
                    response.Redirect(chash);
                }
                else
                {
                    UIDesigner designer = new UIDesigner(false);
                    response.Redirect(designer.Section("", designId));
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 表单对话框
 /// </summary>
 protected WebMeta AsyncDialog(string asyncId, UMC.Web.AsyncDialogFormCallback callback)
 {
     return(UIFormDialog.AsyncDialog(asyncId, d => callback(asyncId)));
 }
Esempio n. 3
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            Guid Team    = UMC.Data.Utility.Guid(this.AsyncDialog("Project", "auto")).Value;
            var  project = Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>()
                           .Where.And().Equal(new Project {
                Id = Team
            }).Entities.Single();

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

            subEntity.Where.And().Equal(new ProjectMember {
                project_id = project.Id
            });
            var sId = this.AsyncDialog("Id", g =>
            {
                var webr = UMC.Data.WebResource.Instance();
                var form = request.SendValues ?? new UMC.Web.WebMeta();

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

                string sort = form[("sort")] as string;
                string dir  = form[("dir")] as string;



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

                if (!String.IsNullOrEmpty(sort) && sort.StartsWith("_") == false)
                {
                    if (String.IsNullOrEmpty(Keyword))
                    {
                        switch (sort)
                        {
                        case "Admin":
                            subEntity.Where.And().Equal(new ProjectMember {
                                AuthType = Web.WebAuthType.Admin
                            });
                            break;

                        case "Write":
                            subEntity.Where.And().Equal(new ProjectMember {
                                AuthType = Web.WebAuthType.User
                            });
                            break;

                        case "Read":
                            subEntity.Where.And().Equal(new ProjectMember {
                                AuthType = Web.WebAuthType.Guest
                            });
                            break;

                        default:
                            if (dir == "DESC")
                            {
                                subEntity.Order.Desc(sort);
                            }
                            else
                            {
                                subEntity.Order.Asc(sort);
                            }
                            break;
                        }
                    }
                }
                else
                {
                    subEntity.Order.Desc(new ProjectMember {
                        CreationTime = DateTime.MaxValue
                    });
                }
                if (String.IsNullOrEmpty(Keyword) == false)
                {
                    subEntity.Where.And().In("user_id", Utility.CMS.ObjectEntity <User>()
                                             .Where.And().Like(new User {
                        Alias = Keyword
                    }).Entities.Script(new User {
                        Id = Guid.Empty
                    }));
                }
                var subs = new List <ProjectMember>();
                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));
                }
                var data = new System.Data.DataTable();
                data.Columns.Add("project_id");
                data.Columns.Add("user_id");
                data.Columns.Add("alias");
                data.Columns.Add("auth");
                data.Columns.Add("time");
                data.Columns.Add("src");
                foreach (var sub in subs)
                {
                    var s = "互联网用户";
                    switch (sub.AuthType)
                    {
                    case Web.WebAuthType.All:
                        break;

                    case Web.WebAuthType.Guest:
                        s = "读者";
                        break;

                    case Web.WebAuthType.User:
                        s = "专栏作家";
                        break;

                    case Web.WebAuthType.Admin:
                        s = "管理员";
                        break;
                    }
                    var user2 = cates.Find(d => d.Id == sub.user_id) ?? new User()
                    {
                        Alias = sub.Alias
                    };
                    data.Rows.Add(sub.project_id, sub.user_id, user2.Alias, s, sub.CreationTime, webr.ResolveUrl(sub.user_id ?? Guid.Empty, "1", 4));
                }
                var hashc      = new System.Collections.Hashtable();
                hashc["data"]  = data;
                var total      = subEntity.Count();;
                hashc["total"] = total; // subEntity.Count();
                if (total == 0)
                {
                    switch (sort)
                    {
                    case "Admin":
                        hashc["msg"] = "未有管理员成员";
                        break;

                    case "Write":
                        hashc["msg"] = "未有专栏作家成员";
                        break;

                    case "Read":
                        hashc["msg"] = "未有读者成员";
                        break;

                    default:
                        if (String.IsNullOrEmpty(Keyword) == false)
                        {
                            hashc["msg"] = String.Format("未搜索到“{0}”对应的团队成员", Keyword);
                        }
                        else
                        {
                            hashc["msg"] = "现在还未有团队成员";
                        }
                        break;
                    }
                }
                response.Redirect(hashc);
                return(this.DialogValue("none"));
            });
            var Id   = Utility.Guid(sId) ?? Guid.Empty;
            var user = UMC.Security.Identity.Current;

            if (Id == Guid.Empty)
            {
                if (user.IsAuthenticated == false)
                {
                    response.Redirect("Account", "Login");
                }
                if (project.user_id == user.Id)
                {
                    this.Prompt("你是创立者,拥有最大权限");
                }

                switch (sId)
                {
                case "follow":
                    subEntity.Where.And().Equal(new ProjectMember {
                        user_id = user.Id
                    });
                    if (subEntity.Count() > 0)
                    {
                        this.Prompt("你已经加入此项目");
                    }
                    else
                    {
                        this.AsyncDialog("Confirm", g => new UIConfirmDialog("你确认加入此项目吗"));
                    }
                    break;

                case "Self":
                    break;

                default:

                    UMC.Web.UIFormDialog.AsyncDialog("From", d =>
                    {
                        var key  = Utility.Scanning(new UIClick(new WebMeta().Put("Project", Team).Put("Id", "Self")).Send(request.Model, request.Command), 0);
                        var url  = new Uri(String.Format("{1}Click/{0}", Utility.Parse62Encode(key), UMC.Data.WebResource.Instance().WebDomain()));
                        var form = new UMC.Web.UIFormDialog()
                        {
                            Title = "扫码加入"
                        };

                        form.AddImage(new Uri(Data.Utility.QRUrl(url.AbsoluteUri)));
                        form.AddTextValue()
                        .Put("使用方式", "使用微信或者钉钉“扫一扫”");

                        form.HideSubmit();


                        return(form);
                    });
                    break;
                }
                subEntity.Where.And().Equal(new ProjectMember {
                    user_id = user.Id
                });

                if (subEntity.Count() == 0)
                {
                    subEntity.Insert(new ProjectMember
                    {
                        CreationTime = DateTime.Now,
                        AuthType     = Web.WebAuthType.Guest,
                        project_id   = Team,
                        user_id      = user.Id,
                        Alias        = user.Alias
                    });

                    Utility.CMS.ObjectEntity <ProjectDynamic>()
                    .Insert(new ProjectDynamic
                    {
                        Time       = Utility.TimeSpan(DateTime.Now),
                        user_id    = user.Id,
                        Explain    = String.Format("{0} 加入了项目", user.Alias),
                        project_id = Team,
                        refer_id   = user.Id,
                        Title      = "项目成员",
                        Type       = DynamicType.Member
                    });
                }
                else
                {
                    this.AsyncDialog("Confirm", d => new UIConfirmDialog("你需要退出此项目组吗"));
                    subEntity.Delete();
                }
                UMC.Configuration.ConfigurationManager.ClearCache(Team, "Data");

                this.Context.Send("Subject.Member", true);
            }
            else
            {
                if (project != null && project.user_id == user.Id)
                {
                }
                else
                {
                    var team = Utility.CMS.ObjectEntity <ProjectMember>().Where.And().Equal(new ProjectMember
                    {
                        project_id = project.Id,
                        user_id    = user.Id
                    }).Entities.Single();
                    if (team != null)
                    {
                        switch (team.AuthType)
                        {
                        case WebAuthType.Admin:
                            break;

                        default:
                            this.Prompt("只有管理员,才能管理团队成员");
                            break;
                        }
                    }
                    else
                    {
                        this.Prompt("只有管理员,才能管理团队成员");
                    }
                }

                var member = subEntity.Where.And().Equal(new ProjectMember {
                    user_id = Id
                }).Entities.Single();
                var arg  = request.Arguments;
                var Type = this.AsyncDialog("Type", g =>
                {
                    var optls   = new Web.UISheetDialog();
                    optls.Title = "成员操作";;
                    optls.Options.Add(new UIClick(new WebMeta(arg).Put(g, "Del"))
                    {
                        Command = request.Command,
                        Model   = request.Model,
                        Text    = "移除此成员"
                    });
                    optls.Options.Add(new UIClick(new WebMeta(arg).Put(g, "Admin"))
                    {
                        Command = request.Command,
                        Model   = request.Model,
                        Text    = "设置为管理员"
                    });
                    optls.Options.Add(new UIClick(new WebMeta(arg).Put(g, "Write"))
                    {
                        Command = request.Command,
                        Model   = request.Model,
                        Text    = "设置专栏作家"
                    });
                    optls.Options.Add(new UIClick(new WebMeta(arg).Put(g, "Read"))
                    {
                        Command = request.Command,
                        Model   = request.Model,
                        Text    = "设置读者"
                    });



                    return(optls);
                });

                switch (Type)
                {
                case "Del":
                    subEntity.Delete();

                    Utility.CMS.ObjectEntity <ProjectDynamic>()
                    .Insert(new ProjectDynamic
                    {
                        Time       = Utility.TimeSpan(),         //DateTime.Now,
                        user_id    = user.Id,
                        Explain    = "移除了项目成员",
                        project_id = Team,
                        refer_id   = member.user_id,
                        Title      = "项目成员",
                        Type       = DynamicType.Member
                    });
                    break;

                case "Admin":
                    subEntity.Update(new ProjectMember {
                        AuthType = WebAuthType.Admin
                    });
                    Utility.CMS.ObjectEntity <ProjectDynamic>()
                    .Insert(new ProjectDynamic
                    {
                        Time       = Utility.TimeSpan(),         //DateTime.Now,
                        user_id    = user.Id,
                        Explain    = "设置成员为管理员",
                        project_id = Team,
                        refer_id   = member.user_id,
                        Title      = "项目成员",
                        Type       = DynamicType.Member
                    });
                    break;

                case "Write":
                    subEntity.Update(new ProjectMember {
                        AuthType = WebAuthType.User
                    });
                    Utility.CMS.ObjectEntity <ProjectDynamic>()
                    .Insert(new ProjectDynamic
                    {
                        Time       = Utility.TimeSpan(DateTime.Now),
                        user_id    = user.Id,
                        Explain    = "设置成员为专栏作家",
                        project_id = Team,
                        refer_id   = member.user_id,
                        Title      = "项目成员",
                        Type       = DynamicType.Member
                    });
                    break;

                case "Read":
                    subEntity.Update(new ProjectMember {
                        AuthType = WebAuthType.Guest
                    });
                    Utility.CMS.ObjectEntity <ProjectDynamic>()
                    .Insert(new ProjectDynamic
                    {
                        Time       = Utility.TimeSpan(DateTime.Now),
                        user_id    = user.Id,
                        Explain    = "设置成员为读者",
                        project_id = Team,
                        refer_id   = member.user_id,
                        Title      = "项目成员",
                        Type       = DynamicType.Member
                    });
                    break;
                }
                UMC.Configuration.ConfigurationManager.ClearCache(Team, "Data");
                this.Context.Send("Subject.Team", true);
            }
        }
Esempio n. 4
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var username = Web.UIDialog.AsyncDialog("Username", d =>
            {
                var fd   = new UMC.Web.UIFormDialog();
                fd.Title = "找回密码";
                fd.AddText("", "Username").Put("placeholder", "手机号码或邮箱");

                fd.Submit("下一步", request, "Forget");
                return(fd);
            });
            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("只支持手机号和邮箱找回密码");
            }
            var acct = entity.Single();

            if (acct == null)
            {
                switch (ac.Type.Value)
                {
                case UMC.Security.Account.EMAIL_ACCOUNT_KEY:
                    this.Prompt("没有找到此邮箱绑定账户");
                    break;

                default:
                    this.Prompt("没有找到此手机号绑定账户");
                    break;
                }
            }
            var Code = UMC.Web.UIDialog.AsyncDialog("Code", g =>
            {
                var ts = ac.Type.Value == UMC.Security.Account.EMAIL_ACCOUNT_KEY ? "邮箱" : "手机";
                var fd = new UMC.Web.UIFormDialog();
                fd.AddTextValue().Put(ts, username);

                fd.AddVerify("验证码", "Code", String.Format("{0}收到的验证码", ts))
                .Command(request.Model, request.Command, new UMC.Web.WebMeta().Put("Username", username).Put("Code", "Reset"));
                fd.Title = "验证" + ts;
                fd.Submit("验证", request, "Password");
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "Forget"), false);

                return(fd);
            });

            if (String.Equals(Code, "Reset"))
            {
                ;
                if (this.Send(username, UMC.Data.Reflection.GetDataProvider("account", "Forget")))
                {
                    this.Prompt("验证码已经发送,请注意查收", false);
                    this.Context.Send(new UMC.Web.WebMeta().UIEvent("VerifyCode", this.AsyncDialog("UI", "none"), new UMC.Web.WebMeta().Put("text", "验证码已发送")), true);
                }
                else
                {
                    switch (ac.Type.Value)
                    {
                    case UMC.Security.Account.EMAIL_ACCOUNT_KEY:
                        this.Prompt("没有找到此邮箱绑定账户");
                        break;

                    default:
                        this.Prompt("没有找到此手机号绑定账户");
                        break;
                    }
                }
            }
            var account    = Account.Create(acct);
            var VerifyCode = account.Items[Account.KEY_VERIFY_FIELD] as string;

            if (String.Equals(VerifyCode, Code, StringComparison.CurrentCultureIgnoreCase))
            {
                WebMeta print = new UMC.Web.WebMeta();
                print["AccountType"] = acct.Type.ToString();
                print["VerifyCode"]  = Code;
                print["user_id"]     = acct.user_id.ToString();

                this.Context.Send(new UMC.Web.WebMeta().Put("type", "Forget"), false);
                response.Redirect(request.Model, "Password", print, true);
            }
            else
            {
                this.Prompt("您输入的验证码错误");
            }
        }