コード例 #1
0
ファイル: UIWorldLoad.cs プロジェクト: windlex/mylualib
        // Token: 0x060010DA RID: 4314 RVA: 0x00407B80 File Offset: 0x00405D80
        public UIWorldLoad(GenerationProgress progress)
        {
            this._progressBar.Top.Pixels = 370f;
            this._progressBar.HAlign     = 0.5f;
            this._progressBar.VAlign     = 0f;
            this._progressBar.Recalculate();
            this._progressMessage.CopyStyle(this._progressBar);
            UIHeader expr_7D_cp_0_cp_0 = this._progressMessage;

            expr_7D_cp_0_cp_0.Top.Pixels = expr_7D_cp_0_cp_0.Top.Pixels - 70f;
            this._progressMessage.Recalculate();
            this._progress = progress;
            base.Append(this._progressBar);
            base.Append(this._progressMessage);
        }
コード例 #2
0
        void Prepare()
        {
            Config = new ConfigHeader(gameConfig);
            Log    = new LogHeader(this);
            UI     = new UIHeader(this);
            ADS    = new AdsHeader(this, adsProvider);

            #region === Инициализация Аналитики ===
            var metrPref = Resources.Load <GameObject>("SmartMobileCore/Prefabs/[Analytics]");
            if (metrPref == null)
            {
                Debug.LogError("Не найден префаб SmartMobileCore/Prefabs/[Analytics]");
            }
            var metrGo = Instantiate(metrPref);
            metrGo.name = "[Analytics]";
            Metrica     = metrGo.GetComponent <Analytics>();
            #endregion
        }
コード例 #3
0
        public StartWithBaseUI(Builder builder, UIState uistate, Mod mod)
        {
            this.builder = builder;
            FieldInfo field = typeof(UIWorldLoad).GetField("_progressBar", BindingFlags.Instance | BindingFlags.NonPublic);

            if (field != null && uistate is UIWorldLoad)
            {
                pbar = (UIGenProgressBar)field.GetValue(uistate);
            }
            else
            {
                pbar = null;
            }

            field = typeof(UIWorldLoad).GetField("_progressMessage", BindingFlags.Instance | BindingFlags.NonPublic);
            if (field != null && uistate is UIWorldLoad)
            {
                pmes = (UIHeader)field.GetValue(uistate);
            }
            else
            {
                pmes = null;
            }



            doNotBuildBase = false;
            pauseActive    = false;


            settingsPannel = new UIPanel();
            settingsPannel.Left.Precent = 2.025f;
            settingsPannel.Top.Precent  = 0.025f;
            settingsPannel.Width.Set(0f, 0.95f);
            settingsPannel.Height.Set(0f, 0.95f);
            settingsPannel.SetPadding(0);
            settingsPannel.BackgroundColor = new Color(73, 94, 171);

            buttonDict = new Dictionary <string, UIScalableImageButtton>();

            string content = "base";
            UIScalableImageButtton base2Button = new UIScalableImageButtton(mod.GetTexture("images/base2"), content);

            base2Button.Id = "ba2";
            buttonDict.Add(base2Button.Id, base2Button);

            UIScalableImageButtton base3Button = new UIScalableImageButtton(mod.GetTexture("images/base3"), content);

            base3Button.Id = "ba3";
            buttonDict.Add(base3Button.Id, base3Button);

            UIScalableImageButtton base3bButton = new UIScalableImageButtton(mod.GetTexture("images/base3b"), content);

            base3bButton.Id = "b3b";
            buttonDict.Add(base3bButton.Id, base3bButton);

            UIScalableImageButtton base4Button = new UIScalableImageButtton(mod.GetTexture("images/base4e"), content);

            base4Button.Id = "ba4";
            buttonDict.Add(base4Button.Id, base4Button);

            UIScalableImageButtton base6Button = new UIScalableImageButtton(mod.GetTexture("images/base6"), content);

            base6Button.Id = "ba6";
            buttonDict.Add(base6Button.Id, base6Button);


            content = "tile";
            foreach (var sty in builder.TileTypeDict)
            {
                UIScalableImageButtton fur = new UIScalableImageButtton(ModContent.GetTexture("Terraria/Item_" + sty.Value.ItemID), content);
                fur.Id = sty.Key;
                buttonDict.Add(fur.Id, fur);
            }
            content = "wall";
            foreach (var sty in builder.wallTypeDict)
            {
                UIScalableImageButtton fur = new UIScalableImageButtton(ModContent.GetTexture("Terraria/Item_" + sty.Value.ItemIDofWallType), content);
                fur.Id = sty.Key;
                buttonDict.Add(fur.Id, fur);
            }

            content = "deskChair";//former namer furniture
            foreach (var sty in builder.deskChairTypeDict)
            {
                UIScalableImageButtton dc = new UIScalableImageButtton(ModContent.GetTexture("Terraria/Item_" + sty.Value.ItemIDWorkBench), content);
                dc.Id = sty.Key;
                buttonDict.Add(dc.Id, dc);
            }

            content = "lantern";
            foreach (var sty in builder.lanternTypeDict)
            {
                UIScalableImageButtton fur = new UIScalableImageButtton(ModContent.GetTexture("Terraria/Item_" + sty.Value.ItemIDLantern), content);
                fur.Id = sty.Key;
                buttonDict.Add(fur.Id, fur);
            }
            content = "platform";
            foreach (var sty in builder.platformTypeDict)
            {
                UIScalableImageButtton fur = new UIScalableImageButtton(ModContent.GetTexture("Terraria/Item_" + sty.Value.ItemID), content);
                fur.Id = sty.Key;
                buttonDict.Add(fur.Id, fur);
            }

            content = "numbers";
            UIScalableImageButtton pause = new UIScalableImageButtton(mod.GetTexture("images/pause"), content);

            pause.Id = "counterPause";
            buttonDict.Add(pause.Id, pause);

            UIScalableImageButtton rand = new UIScalableImageButtton(mod.GetTexture("images/qm"), content);

            rand.Id = "random";
            buttonDict.Add(rand.Id, rand);
            for (int num = 0; num < 10; num++)
            {
                UIScalableImageButtton fur = new UIScalableImageButtton(mod.GetTexture("images/" + num), content);
                fur.Id = "config" + num;
                buttonDict.Add(fur.Id, fur);
            }
            UIScalableImageButtton save = new UIScalableImageButtton(mod.GetTexture("images/configSave"), content);

            save.Id = "configSave";
            buttonDict.Add(save.Id, save);

            statusText = new UIText("", 0.5f, true);
            settingsPannel.Append(statusText);
            statusText.HAlign        = 0.5f;
            statusText.VAlign        = 1.0f;
            statusText.PaddingBottom = pause.Height.Pixels + 2 * paddingY;
            statusText.MarginLeft    = 0;
            statusText.TextColor     = new Color(0.85f, 0.85f, 0.85f, 0.85f);

            counterText = new UIText("42", 2, true);
            settingsPannel.Append(counterText);
            counterText.HAlign        = 0.0f;
            counterText.VAlign        = 1.0f;
            counterText.PaddingBottom = paddingY;
            counterText.MarginLeft    = padding;



            foreach (var but in buttonDict)
            {
                UIScalableImageButtton butt = buttonDict[but.Key];
                settingsPannel.Append(butt);
                butt.OnClick      += clickBase;
                butt.OnRightClick += rightClickPannel;
                //butt.SetVisibility(0.8f, 0.8f);
            }


            InitButtons();
            setSize();
            uistate.Append(settingsPannel);
            settingsPannel.OnRightClick += rightClickPannel;
            uistate.Append(settingsPannel);

            startIcon = new UIScalableImageButtton(Texture2D.FromStream(Main.instance.GraphicsDevice, new MemoryStream(mod.GetFileBytes("icon.png"))), content);
            startIcon.Height.Pixels *= 2;
            startIcon.Width.Pixels  *= 2;
            startIcon.PaddingRight   = -startIcon.Width.Pixels;
            startIcon.PaddingTop     = -startIcon.Height.Pixels;
            startIcon.VAlign         = 0f;
            startIcon.HAlign         = 1f;
            startIcon.OnClick       += leftClickicon;
            startIcon.OnRightClick  += rightClickicon;
            uistate.Append(startIcon);
            //uistate.Append(this);

            lastSave = -1;
        }
コード例 #4
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var user = UMC.Security.Identity.Current;


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

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

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



            if (user.IsAuthenticated)
            {
                var cell = UICell.Create("UI", new UMC.Web.WebMeta().Put("text", "退出登录").Put("Icon", '\uf011').Put("click", new UIClick()
                {
                    Model   = "Account",
                    Command = "Close"
                }));
                cell.Style.Name("text", new UIStyle().Color(0xf00));
                ui.NewSection().NewSection()
                .Add(cell);
                //}
                //else
                //{
                //    var cell = UICell.Create("UI", new UMC.Web.WebMeta().Put("text", "登录").Put("Icon", '\uf007').Put("click", new UIClick()
                //    {
                //        Model = "Account",
                //        Command = "Login"
                //    }));
                //    cell.Style.Name("text", new UIStyle().Color(0xf00));
                //    ui.NewSection().NewSection()
                //        .Add(cell);
            }
            response.Redirect(ui);
        }
コード例 #5
0
        public UIWorldLoadSpecial(GenerationProgress progress)
        {
            instance        = this;
            menuTexture     = ModContent.GetTexture("WorldGenPreviewer/menu");
            previousTexture = ModContent.GetTexture("WorldGenPreviewer/previous");
            playTexture     = ModContent.GetTexture("WorldGenPreviewer/play");
            pauseTexture    = ModContent.GetTexture("WorldGenPreviewer/pause");
            nextTexture     = ModContent.GetTexture("WorldGenPreviewer/next");

            menuButton     = new UIImageButton(menuTexture);
            previousButton = new UIImageButton(previousTexture);
            playButton     = new UIImageButton(playTexture);
            pauseButton    = new UIImageButton(pauseTexture);
            nextButton     = new UIImageButton(nextTexture);
            cancelButton   = new UIImageButton(ModContent.GetTexture("WorldGenPreviewer/cancel"));

            passesPanel = new UIPanel();
            passesPanel.SetPadding(3);
            passesPanel.Left.Pixels = listHidden ? panelWidth : 0;
            passesPanel.HAlign      = 1f;
            passesPanel.Top.Set(0f, 0f);
            passesPanel.Width.Set(panelWidth, 0f);
            passesPanel.Height.Set(0f, 1f);
            passesPanel.BackgroundColor = new Color(73, 94, 171);

            passesList = new UIList();
            passesList.Width.Set(0f, 1f);
            passesList.Height.Set(0f, 1f);
            passesList.ListPadding = 12f;
            passesPanel.Append(passesList);

            UIScrollbar passesListScrollbar = new UIScrollbar();

            passesListScrollbar.SetView(100f, 1000f);
            passesListScrollbar.Height.Set(0f, 1f);
            passesListScrollbar.HAlign = 1f;
            passesPanel.Append(passesListScrollbar);
            passesList.SetScrollbar(passesListScrollbar);

            int order = 0;

            for (int i = 0; i < WorldGenPreviewerModWorld.generationPasses.Count; i++)
            {
                GenPass pass = WorldGenPreviewerModWorld.generationPasses[i];
                if (pass.Name != "World Gen Paused")
                {
                    order++;
                    UIPassItem testLabel = new UIPassItem(order, pass, pass.Name, 1f, false);
                    //testLabel.Top.Pixels = y;
                    //y += 10;
                    passesList.Add(testLabel);
                    //passesPanel.Append(testLabel);
                }
            }
            Append(passesPanel);

            buttonPanel = new UIPanel();
            buttonPanel.SetPadding(0);
            //buttonPanel.Left.Set(0f, .5f);
            buttonPanel.HAlign = 0.5f;
            buttonPanel.Top.Set(180f, 0f);
            //buttonPanel.Width.Set(170f, 0f);
            buttonPanel.Height.Set(32 + spacing * 2 + 16, 0f);
            buttonPanel.BackgroundColor = new Color(73, 94, 171);

            float calculatedWidth = spacing;

            buttonPanel.Append(menuButton);
            menuButton.OnClick    += MenuClick;
            menuButton.Left.Pixels = calculatedWidth;
            menuButton.Top.Pixels  = spacing;
            calculatedWidth       += spacing + 32;

            buttonPanel.Append(previousButton);
            previousButton.OnClick    += PreviousClick;
            previousButton.Left.Pixels = calculatedWidth;
            previousButton.Top.Pixels  = spacing;
            calculatedWidth           += spacing + 32;

            buttonPanel.Append(playButton);
            playButton.OnClick    += PlayClick;
            playButton.Left.Pixels = calculatedWidth;
            playButton.Top.Pixels  = spacing;
            calculatedWidth       += spacing + 32;

            buttonPanel.Append(pauseButton);
            pauseButton.OnClick    += PauseClick;
            pauseButton.Left.Pixels = calculatedWidth;
            pauseButton.Top.Pixels  = spacing;
            calculatedWidth        += spacing + 32;

            buttonPanel.Append(nextButton);
            nextButton.OnClick    += NextClick;
            nextButton.Left.Pixels = calculatedWidth;
            nextButton.Top.Pixels  = spacing;
            calculatedWidth       += spacing + 32;

            buttonPanel.Append(cancelButton);
            cancelButton.OnClick    += CancelClick;
            cancelButton.Left.Pixels = calculatedWidth;
            cancelButton.Top.Pixels  = spacing;
            calculatedWidth         += spacing + 32;

            statusLabel        = new UIText("Status: Normal", 1f, false);
            statusLabel.VAlign = 1f;
            statusLabel.HAlign = 0.5f;
            statusLabel.Top.Set(-5f, 0f);
            buttonPanel.Append(statusLabel);

            buttonPanel.Width.Pixels = calculatedWidth;
            Append(buttonPanel);

            this._progressBar.Top.Pixels = 70f;
            this._progressBar.HAlign     = 0.5f;
            this._progressBar.VAlign     = 0f;
            this._progressBar.Recalculate();
            this._progressMessage.CopyStyle(this._progressBar);
            UIHeader expr_78_cp_0 = this._progressMessage;

            expr_78_cp_0.Top.Pixels = expr_78_cp_0.Top.Pixels - 70f;
            this._progressMessage.Recalculate();
            this._progress = progress;
            base.Append(this._progressBar);
            base.Append(this._progressMessage);
        }
コード例 #6
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var ProjectId = Utility.Guid(this.AsyncDialog("Id", g =>
            {
                this.Prompt("请输入项目");

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

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

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

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

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

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


                //Sections.Add(cmsText);

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

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


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

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


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

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

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

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

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

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

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

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

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

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

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

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



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

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

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



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


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

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

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


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


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

            //}

            response.Redirect(ui);


            //}
        }
コード例 #7
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var identity = UMC.Security.Identity.Current;

            var userId = identity.Id;

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

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


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

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

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

            if (identity.IsAuthenticated)
            {
                members += Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>()
                           .Where.And().Equal(new Data.Entities.Project {
                    user_id = userId
                })
                           .Entities.Count();
            }

            var Discount = new UIHeader.Portrait(identity.IsAuthenticated ? logoUrl : "https://oss.365lu.cn/css/images/header_image.png");

            ;
            var user = identity;

            Discount.Value(user.IsAuthenticated ? user.Alias : "请登录");
            Discount.Click(new UIClick().Send("Account", "Self"));

            if (user.IsAuthenticated)
            {
                var sign = Data.Database.Instance().ObjectEntity <Data.Entities.Account>()
                           .Where.And().Equal(new Data.Entities.Account {
                    user_id = userId, Type = Security.Account.SIGNATURE_ACCOUNT_KEY
                }).Entities.Single();
                //if (sign != null)
                Discount.Time(sign != null ? sign.Name : " ");// user.ActiveTime.ToString());
            }
            else
            {
                Discount.Time(" ");
            }
            var color = 0x63b359;

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

            title.Title = "我的";
            header.AddPortrait(Discount);

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

            var ui = UISection.Create(header, title);


            var uIIcon = new UIIconNameDesc(new UIIconNameDesc.Item('\uF19d', "参与项目", members + "项").Color(0x40c9c6));

            if (user.IsAuthenticated)
            {
                uIIcon.Button("查看", UIClick.Pager("Subject", "Account", new WebMeta().Put("selectIndex", 1)), 0x1890ff);
            }
            else
            {
                uIIcon.Button("请登录", new UIClick().Send("Account", "Login"), 0xb7babb);
            }
            ui.Add(uIIcon);
            uIIcon = new UIIconNameDesc(new UIIconNameDesc.Item('\uF02d', "知识创作", suject.Seq + "篇").Color(0x36a3f7), new UIIconNameDesc.Item('\uf0e6', "被评论", suject.Reply + "次").Color(0x34bfa3));
            //new UIIconNameDesc.Item('\uf06e', "被浏览", suject.Look + "次").Color(0xf4516c),
            ui.Add(uIIcon);


            ui.NewSection()
            .AddCell('\uf198', "新建文档", "采用Markdown格式编写", new Web.UIClick("Markdown").Send("Subject", "Content"))
            .AddCell('\uf13b', "新建富文本文档", "采用富文本格式编写", new Web.UIClick("News").Send("Subject", "Content"))
            .AddCell('\uf0c5', "抓取文档", "从粘贴板版网址中抓取文档", new Web.UIClick()
            {
                Key = "CaseCMS"
            });

            ui.NewSection().AddCell('\uf2e1', "扫一扫", "", new Web.UIClick()
            {
                Key = "Scanning"
            });
            ui.NewSection()
            //.AddCell('\uf19c', "切换企业", "", Web.UIClick.Pager("Platform", "Corp", true))
            .AddCell('\uf013', "设置", "", Web.UIClick.Pager("UI", "Setting", true, "Close"));



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

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

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

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

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

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

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

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

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



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



                    var Discount = new UIHeader.Portrait(logoUrl);


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

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

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

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

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

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

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


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

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

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

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

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


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

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

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

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

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

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

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

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

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

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


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


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

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

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

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

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


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

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

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

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

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

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

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



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

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

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

                    break;

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

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

                    break;
                }


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

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

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

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


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


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

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

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

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

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

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

                team.ModifiedTime = DateTime.Now;
                var objectEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Project>();
                objectEntity.Where.And().Equal(new Project
                {
                    Id = project.Id
                });
                objectEntity.Update(team);
                this.Prompt("修改成功", false);
                this.Context.Send(new UMC.Web.WebMeta().Put("type", "Subject.Project").Put("id", project.Id).Put("text", team.Caption ?? project.Caption).Put("code", team.Code ?? project.Code), true);
            }
        }
コード例 #9
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var identity = UMC.Security.Identity.Current;
            var userId   = Utility.Guid(this.AsyncDialog("Id", g =>
            {
                if (identity.IsAuthenticated == false)
                {
                    response.Redirect("Account", "Login");
                }
                return(this.DialogValue(identity.Id.ToString()));
            }), true);

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

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

            var items = new List <WebMeta>();

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

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

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

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

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

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

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



                var Discount = new UIHeader.Portrait(logoUrl);

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

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

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

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

                ui = UISection.Create(header, title);


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

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

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

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

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

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


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

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


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

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

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

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

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

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

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

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

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

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

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

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



            response.Redirect(ui);
        }
コード例 #10
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;
            }
        }
コード例 #11
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var Url = this.AsyncDialog("Id", g =>
            {
                if (request.IsApp == false)
                {
                    return(this.DialogValue("News"));
                }
                var optls   = new Web.UISheetDialog();
                optls.Title = "新建图文";;
                optls.Options.Add(new UIClick("News")
                {
                    Command = request.Command, Model = request.Model, Text = "新建富文本图文"
                });
                optls.Options.Add(new UIClick("Markdown")
                {
                    Command = request.Command, Model = request.Model, Text = "新建Markdown文档"
                });
                optls.Options.Add(new UIClick()
                {
                    Key = "CaseCMS", Text = "抓取粘贴板网址图文"
                });

                return(optls);
            });
            var user = UMC.Security.Identity.Current;

            if (user.IsAuthenticated == false)
            {
                this.Prompt("请先登录", false);
                response.Redirect("Account", "Login");
            }

            var sId = UMC.Data.Utility.Guid(Url);

            if (sId.HasValue == false)
            {
                var sType = "text/html";
                switch (Url)
                {
                case "Project":
                    response.Redirect(request.Model, "ProjectUI", "News", true);
                    break;

                case "Markdown":
                    sType = "markdown";
                    if (request.IsApp)
                    {
                        this.Context.Send("Markdown", new WebMeta().Put("Id", "News"), true);
                    }
                    break;
                }
                if (request.IsApp == false)
                {
                    var sub2 = new Subject()
                    {
                        Visible      = 1,
                        CreationTime = DateTime.Now,
                        Title        = DateTime.Now.ToShortDateString(),
                        IsPicture    = false,
                        IsDraught    = true,
                        Id           = Guid.NewGuid(),
                        ContentType  = sType,
                        LastDate     = DateTime.Now,
                        Poster       = user.Alias,
                        Seq          = Utility.TimeSpan(),
                        last_user_id = user.Id,
                        user_id      = user.Id,
                        Status       = -1
                    };
                    SubjectSaveActivity.Dashboard(user, sub2);
                    Utility.CMS.ObjectEntity <Subject>().Insert(sub2);
                    this.Context.Send("Markdown", new WebMeta().Put("Id", Utility.Guid(sub2.Id.Value)), true);
                }
            }


            var sub = sId.HasValue ? (Utility.CMS.ObjectEntity <Subject>()
                                      .Where.And().Equal(new Subject
            {
                Id = sId
            }).Entities.Single() ?? new Subject {
                Id = sId
            }) : new Subject {
                Id = sId
            };;

            if (String.IsNullOrEmpty(request.SendValue) == false)
            {
                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)
                    {
                        if (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:
                                    this.Prompt("您未有编辑此图文的权限");
                                    break;
                                }
                            }
                            else
                            {
                                this.Prompt("您未有编辑此图文的权限");
                            }
                        }
                    }
                }
                if (String.Equals("markdown", sub.ContentType, StringComparison.CurrentCultureIgnoreCase))
                {
                    this.Context.Send("Markdown", new WebMeta().Put("Id", sId), true);
                }
                else
                {
                    if (request.IsApp)
                    {
                        this.Context.Send(new UISectionBuilder(request.Model, request.Command, new UMC.Web.WebMeta().Put("Id", sId.HasValue ? sId : Guid.NewGuid()))
                                          .CloseEvent("Subject.Save")
                                          .Builder().Put("IsEditer", true), true);
                    }
                    else
                    {
                        this.Context.Send("Markdown", new WebMeta().Put("Id", Utility.Guid(sId.Value)), true);
                    }
                }
            }

            var Next  = this.AsyncDialog("Next", "none");
            var ui    = UISection.Create();
            var title = new UITitle("图文编辑器");

            ui.Title = title;
            title.Right(new UIEventText().Icon('\uf0c7').Click(UIClick.Click(new UIClick("Id", sub.Id.ToString(), "Next", Next)
            {
                Command = "Save",
                Model   = request.Model
            })));


            var celss = UMC.Data.JSON.Deserialize <WebMeta[]>((String.IsNullOrEmpty(sub.DataJSON) ? "[]" : sub.DataJSON)) ?? new UMC.Web.WebMeta[] { };

            foreach (var pom in celss)
            {
                switch (pom["_CellName"])
                {
                case "CMSImage":
                    pom.Put("style", new UIStyle().Padding(0, 10));
                    break;
                }
            }

            if (celss.Length == 0)
            {
                var ed = ui.NewSection();
                ed.DisableSeparatorLine();
                ed.IsEditer = true;
                ed.AddCells(new UMC.Web.WebMeta().Put("_CellName", "CMSText").Put("value", new UMC.Web.WebMeta().Put("text", "新建文档")));
            }
            else
            {
                var ed = ui.NewSection();
                ed.IsEditer = true;
                ed.AddCells(celss);
                ed.DisableSeparatorLine();
            }
            var style  = new UIStyle();
            var footer = new UIHeader();

            ui.UIFooter = footer;//
            footer.Desc(new UMC.Web.WebMeta("icon", "\uf004", "desc", "天天录,录入您知识财富"), "{icon}\n{desc}", style);

            style.Height(350).Color(0xf0f0f0).AlignCenter().BgColor(0xf8f8f8).Name("border", "none");//.BorderColor
            style.Name("icon").Font("wdk").Size(40);


            response.Redirect(ui);
        }