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


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

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

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

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

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

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

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


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

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

                    switch (headers.Length)
                    {
                    case 0:

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

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


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


                        break;
                    }


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

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

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

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

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

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


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

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

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

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

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


                    chash.Add("sections", tabs);
                    chash.Add("title", title);
                    response.Redirect(chash);
                }
                else
                {
                    UIDesigner designer = new UIDesigner(false);
                    response.Redirect(designer.Section("", designId));
                }
            }
        }
        protected UIClick Click(UIClick ui)
        {
            String type = this.AsyncDialog("Click", g =>
            {
                UIRadioDialog di = new UIRadioDialog();
                di.Title         = ("关联功能");
                ListItemCollection listItemCollection = di.Options;//new ListItemCollection();
                listItemCollection.Add("连接扫一扫", "Scanning");
                listItemCollection.Add("连接指令", "Setting");
                listItemCollection.Add("连接拨号", "Tel");
                listItemCollection.Add("连接网址", "Url");

                return(di);
            });

            switch (type)
            {
            case "Scanning":
                return(UIClick.Scanning());

            case "Tel":
                return(UIClick.Tel(this.AsyncDialog("Tel", g =>
                {
                    UITextDialog di = new UITextDialog();
                    di.Title = ("拨号号码");
                    return di;
                })));

            case "Url":
                return(UIClick.Url(new Uri(this.AsyncDialog("Url", g =>
                {
                    UITextDialog di = new UITextDialog();
                    di.Title = ("网址地址");
                    return di;
                }))));


            default:
            case "Setting":

                var     c        = UMC.Data.JSON.Deserialize(UMC.Data.JSON.Serialize(ui)) as Hashtable;
                WebMeta settings = this.AsyncDialog(g =>
                {
                    UIFormDialog di = new UIFormDialog();
                    di.Title        = ("功能指令");
                    di.AddText("模块代码", "Model", (String)c["model"]);
                    di.AddText("指令代码", "Command", (String)c["cmd"]);
                    di.AddPrompt("此块内容为专业内容,请由工程师设置");

                    if (c.ContainsKey("send"))
                    {
                        Object send = c["send"];
                        if (send is String)
                        {
                            di.AddText("参数", "Send", (String)send).PlaceHolder("如果没参数,则用none");
                        }
                        else
                        {
                            di.AddText("参数", "Send", UMC.Data.JSON.Serialize(send)).PlaceHolder("如果没参数,则用none");
                        }
                    }
                    else
                    {
                        di.AddText("参数", "Send").PlaceHolder("如果没参数,则用none").NotRequired();
                    }

                    return(di);
                }, "Send");
                UIClick click   = new UIClick();
                String  Model   = settings.Get("Model");
                String  Command = settings.Get("Command");
                String  Send    = settings.Get("Send");
                click.Send(Model, Command);

                if ("none".Equals(Send, StringComparison.CurrentCultureIgnoreCase) == false)
                {
                    if (String.IsNullOrEmpty(Send) == false)
                    {
                        if (Send.StartsWith("{"))
                        {
                            click.Send(UMC.Data.JSON.Deserialize <WebMeta>(Send));
                        }
                        else
                        {
                            click.Send(Send);
                        }
                    }
                }
                return(click);
            }
        }
Beispiel #3
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var    user = UMC.Security.Identity.Current;
            String ssid = this.AsyncDialog("Id", d => this.DialogValue(user.Id.ToString()));
            Guid?  sId  = UMC.Data.Utility.Guid(ssid);
            String size = this.AsyncDialog("Size", g => this.DialogValue("none"));


            UMC.Data.WebResource webr = UMC.Data.WebResource.Instance();

            var entity = Database.Instance().ObjectEntity <Design_Item>();
            //entity.Where.Reset().And().Equal(new Design_Item() { Id = itemId });

            Design_Item item = null;//entity.single();

            if (sId.HasValue)
            {
                entity.Where.Reset().And().Equal(new Design_Item()
                {
                    Id = sId
                });
                //entity.Where.And().Equal(new Design_Item().Id(sId));

                item = entity.Single();
            }

            if (item != null && item.Type != UIDesigner.StoreDesignType)
            {
                Design_Item finalItem = item;
                String      type      = this.AsyncDialog("Type", g =>
                {
                    UIRadioDialog di = new UIRadioDialog();

                    switch (finalItem.Type)
                    {
                    case UIDesigner.StoreDesignTypeCustom:
                        break;

                    case UIDesigner.StoreDesignType:
                        di.Title = ("页面设计");
                        di.Options.Put("编辑此项", "Edit");
                        di.Options.Put("增加新项", "Append");
                        di.Options.Put("删除此项", "Delete");
                        break;

                    case UIDesigner.StoreDesignTypeItem:
                        di.Title = ("单项设计");
                        di.Options.Put("编辑此项", "Edit");
                        di.Options.Put("配置参数", "Config");
                        di.Options.Put("增加新项", "Append");
                        di.Options.Put("点击到...", "Union");
                        di.Options.Put("删除此项", "Delete");
                        break;

                    case UIDesigner.StoreDesignTypeProduct:
                        di.Title = ("商品栏位");
                        di.Options.Put("调整顺序", "Seq");
                        di.Options.Put("配置参数", "Config");
                        di.Options.Put("增加商品", "Append");
                        di.Options.Put("删除此项", "Delete");
                        break;

                    case UIDesigner.StoreDesignTypeDiscount:
                        di.Title = ("卡券栏位");
                        di.Options.Put("调整顺序", "Seq");
                        //di.options().put("配置参数", "Config");
                        di.Options.Put("增加卡券", "Append");
                        di.Options.Put("删除此项", "Delete");
                        break;

                    case UIDesigner.StoreDesignTypeCaption:

                        di.Title = ("栏目设计");
                        di.Options.Put("编辑栏目", "Config");
                        di.Options.Put("添加横幅区", "AddBanner");
                        di.Options.Put("添加图标区", "AddIcon");
                        di.Options.Put("添加分列区", "AddItem");
                        di.Options.Put("添加图文区", "AddTitleDesc");

                        di.Options.Put("删除栏目", "Delete");
                        return(di);

                    case UIDesigner.StoreDesignTypeBanners:
                        di.Title = ("横幅栏位");
                        di.Options.Put("添加横幅页", "Banners");
                        di.Options.Put("配置参数", "Config");
                        di.Options.Put("删除横幅栏", "Delete");

                        break;

                    case UIDesigner.StoreDesignTypeProducts:
                        di.Title = ("商品栏位");
                        di.Options.Put("添加商品", "Product");
                        di.Options.Put("配置参数", "Config");
                        di.Options.Put("删除商品栏", "Delete");

                        break;

                    case UIDesigner.StoreDesignTypeDiscounts:
                        di.Title = ("卡券栏位");
                        di.Options.Put("添加卡券", "Discount");
                        //di.options().put("配置参数", "Config");
                        di.Options.Put("删除卡券栏", "Delete");

                        break;

                    case UIDesigner.StoreDesignTypeTitleDesc:
                        di.Title = ("图文栏位");
                        di.Options.Put("添加子项", "TitleDesc");

                        di.Options.Put("配置图文", "Config");
                        di.Options.Put("删除图文栏", "Delete");
                        break;

                    case UIDesigner.StoreDesignTypeItems:
                        di.Title = ("分列栏位");
                        di.Options.Put("添加子列", "Items");
                        di.Options.Put("配置参数", "Config");
                        di.Options.Put("删除分列栏", "Delete");
                        break;

                    case UIDesigner.StoreDesignTypeIcons:
                        di.Title = ("图标栏位");
                        di.Options.Put("添加子项", "Icons");
                        di.Options.Put("配置参数", "Config");
                        di.Options.Put("删除图标位", "Delete");
                        break;

                    default:
                        break;
                    }
                    return(di);
                });
                switch (type)
                {
                case "Seq":

                    Seq(request, response, item);
                    break;

                case "Delete":
                    if (item.Type == UIDesigner.StoreDesignType)
                    {
                        entity.Where.Reset().And().Equal(new Design_Item()
                        {
                            design_id = item.Id
                        });
                        if (entity.Count() > 0)
                        {
                            this.Prompt("请先删除子项");
                        }

                        entity.Where.Reset().And().Equal(new Design_Item()
                        {
                            Id = sId
                        });
                        entity.Delete();
                        this.Context.Send("Design", true);
                    }
                    else
                    {
                        entity.Where.Reset().And().Equal(new Design_Item()
                        {
                            for_id = item.Id
                        });
                        if (entity.Count() > 0)
                        {
                            this.Prompt("请先删除子项");
                        }


                        entity.Where.Reset().And().Equal(new Design_Item()
                        {
                            Id = item.Id
                        });
                        entity.Delete();
                        this.Context.Send("Design", true);
                    }
                    break;

                case "TitleDesc":
                    this.TitleDesc(request, sId.Value);
                    break;

                case "Config":
                    this.Config(request, sId.Value);
                    break;

                case "Union":
                    response.Redirect("Design", "Click", sId.ToString(), true);

                    break;

                case "Icons":
                    Icons(request, sId.Value);
                    break;

                case "Banners":
                    Banner(request, sId.Value);
                    break;

                case "Items":
                    Items(request, sId.Value);
                    break;

                case "Edit":
                    if (item.Type == UIDesigner.StoreDesignTypeCustom)
                    {
                        response.Redirect("Design", "Custom", new UMC.Web.WebMeta().Put("Id", item.Id.ToString(), "Size", size), true);
                    }
                    else
                    {
                        Design_Item eitem = entity.Where.Reset().And().Equal(new Design_Item()
                        {
                            Id = item.for_id
                        }).Entities.Single();

                        switch (eitem.Type)
                        {
                        case UIDesigner.StoreDesignTypeTitleDesc:
                            TitleDesc(request, sId.Value);
                            break;

                        case UIDesigner.StoreDesignTypeBanners:
                            Banner(request, sId.Value);
                            break;

                        case UIDesigner.StoreDesignTypeIcons:
                            Icons(request, sId.Value);
                            break;

                        case UIDesigner.StoreDesignTypeItems:
                            Items(request, sId.Value);
                            break;
                        }
                    }
                    break;

                case "AddCaption":
                    this.Caption(request, response, item.design_id.Value, item.Id.Value);
                    break;

                case "AddTitleDesc":
                case "AddProduct":
                case "AddItem":
                case "AddIcon":
                case "AddBanner":


                    Design_Item item3 = new Design_Item()
                    {
                        Id = Guid.NewGuid(), for_id = item.Id, design_id = item.design_id
                    };
                    //Design_Item item3 = new Design_Item().Id(Guid.randomGuid()).Design_id(item.design_id)
                    //        .For_id(item.Id);

                    switch (type)
                    {
                    case "AddProduct":
                        item3.Type = UIDesigner.StoreDesignTypeProducts;
                        break;

                    case "AddIcon":
                        item3.Type = UIDesigner.StoreDesignTypeIcons;
                        break;

                    case "AddTitleDesc":
                        item3.Type = UIDesigner.StoreDesignTypeTitleDesc;
                        break;

                    case "AddBanner":
                        item3.Type = UIDesigner.StoreDesignTypeBanners;
                        break;

                    case "AddItem":
                        item3.Type = UIDesigner.StoreDesignTypeItems;
                        break;

                    case "AddDiscount":
                        item3.Type = UIDesigner.StoreDesignTypeDiscounts;
                        break;
                    }

                    if (item3.Type != null)
                    {
                        Design_Item max = entity
                                          .Where.Reset().And().Equal(new Design_Item()
                        {
                            for_id = item.Id
                        })
                                          .Entities.Max(new Design_Item()
                        {
                            Seq = 0
                        });                                                      //.Seq+1;
                        item3.Seq = (max.Seq ?? 0) + 1;


                        entity.Insert(item3);
                    }
                    break;

                case "Append":

                    if (item.Type == UIDesigner.StoreDesignTypeCustom)
                    {
                        WebMeta meta = UMC.Data.JSON.Deserialize <WebMeta>(item.Data);
                        response.Redirect("Design", "Custom", new UMC.Web.WebMeta().Put("Config", meta.Get("Config")).Put("Size", size), true);
                    }
                    Design_Item aitem = entity.Where.Reset().And().Equal(new Design_Item()
                    {
                        Id = item.for_id
                    }).Entities.Single();


                    switch (aitem.Type)
                    {
                    case UIDesigner.StoreDesignTypeTitleDesc:
                        TitleDesc(request, aitem.Id.Value);
                        break;

                    case UIDesigner.StoreDesignTypeBanners:
                        Banner(request, aitem.Id.Value);
                        break;

                    case UIDesigner.StoreDesignTypeIcons:
                        Icons(request, aitem.Id.Value);
                        break;

                    case UIDesigner.StoreDesignTypeItems:
                        Items(request, aitem.Id.Value);
                        break;
                    }

                    break;
                }
            }
            else
            {
                String type = this.AsyncDialog("Type", g =>
                {
                    UIRadioDialog di = new UIRadioDialog();
                    di.Title         = ("界面设计");
                    di.Options.Put("添加标题栏", "Caption");
                    di.Options.Put("添加广告栏", "Banner");
                    di.Options.Put("添加图标栏", "Icons");
                    di.Options.Put("添加分块栏", "Items");
                    return(di);
                });
                Design_Item item2 = new Design_Item()
                {
                    Id = Guid.NewGuid(), for_id = Guid.Empty, design_id = sId
                };

                //Id=GU.nId(Guid.randomGuid()).Design_id(sId)
                //.For_id(Utility.uuidEmpty);


                switch (type)
                {
                case "Caption":
                    Caption(request, response, sId.Value, Guid.Empty);
                    break;

                case "TitleDesc":
                    item2.Type = UIDesigner.StoreDesignTypeTitleDesc;
                    break;

                case "Products":
                    item2.Type = UIDesigner.StoreDesignTypeProducts;
                    break;

                case "Icons":
                    item2.Type = UIDesigner.StoreDesignTypeIcons;
                    break;

                case "Banner":
                    item2.Type = UIDesigner.StoreDesignTypeBanners;
                    break;

                case "Items":
                    item2.Type = UIDesigner.StoreDesignTypeItems;

                    break;

                case "Discounts":
                    item2.Type = UIDesigner.StoreDesignTypeDiscounts;

                    break;
                }
                if (item2.Type != null)
                {
                    Design_Item max = entity
                                      .Where.Reset().And().Equal(new Design_Item {
                        design_id = sId, for_id = Guid.Empty
                    })
                                      .Entities.Max(new Design_Item {
                        Seq = 0
                    });                                                //.Seq+1;
                    item2.Seq = (max.Seq ?? 0) + 1;


                    entity.Insert(item2);
                }
            }

            this.Context.Send("Design", true);
        }
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            if (request.IsMaster == false)
            {
                this.Prompt("只有管理员才能还原");
            }

            var files = System.IO.Directory.GetFiles(UMC.Data.Utility.MapPath(String.Format("~App_Data/BackUp/{0}", Utility.GetRoot(request.Url))), "*.umc", System.IO.SearchOption.TopDirectoryOnly);
            var index = Utility.IntParse(this.AsyncDialog("Index", g =>
            {
                var rd   = new UIRadioDialog();
                rd.Title = "请选择备份";
                for (var i = 0; i < files.Length; i++)
                {
                    rd.Options.Add(System.IO.Path.GetFileName(files[i]), i.ToString());
                }
                if (files.Length == 0)
                {
                    this.Prompt("未有备份文件");
                }
                return(rd);
            }), 0);
            var path   = String.Format("BackUp/{0}/{1}", Utility.GetRoot(request.Url), System.IO.Path.GetFileName(files[index]));
            var Key    = Utility.Guid(Guid.NewGuid());
            var log    = new UMC.Data.CSV.Log(Utility.GetRoot(request.Url), Key, "开始备份");
            var appKey = Security.Principal.Current.AppKey ?? Guid.Empty;

            Data.Reflection.Start(() =>
            {
                var Initializers = Data.Sql.Initializer.Initializers();
                try
                {
                    var now = DateTime.Now;

                    var database = Reflection.Configuration("database") ?? new UMC.Configuration.ProviderConfiguration();
                    //var count = false;
                    foreach (var initer in Initializers)
                    {
                        if (database.Providers.ContainsKey(initer.ProviderName))
                        {
                            log.Info("正在还原", initer.Caption);
                            var provider2 = Reflection.CreateObject(Reflection.Instance().DatabaseProvider(initer.ProviderName, appKey)) as DbProvider;

                            initer.Restore(log, provider2, path);
                        }

                        else
                        {
                            log.Info("未安装", initer.Caption);
                        }
                    }


                    log.End("还原已完成");
                }
                catch (Exception ex)
                {
                    log.End("还原失败");
                    log.Info(ex.ToString());
                }
            });

            this.Context.Send("Initializer", false);

            response.Redirect("System", "Log", Key);
        }