Exemplo n.º 1
0
        /// <summary>
        /// 构建Aspx页面
        /// </summary>
        /// <returns></returns>
        public bool BuildAspxPage()
        {
            //初始化页面,构造head,body,form等基本节点
            Page.InitPage();
            Page.Head["runat"] = "server";
            //添加页面指令
            AspxDirective direc4Page = new AspxDirective("Page");
            direc4Page["language"] = "C#";
            if (this.CompileMode) direc4Page["codeBehind"] = Page.PageName + ".cs";
            else direc4Page["codeFile"] = Page.PageName + ".cs";
            direc4Page["codeFile"]= Page.PageName+".cs";
            direc4Page["Inherits"]="UCMLCommon."+this.Name;
            direc4Page["AutoEventWireup"]="False";
            direc4Page["ResponseEncoding"] = "UTF-8";

            AspxDirective direc4Reg = new AspxDirective("Register");
            direc4Reg["TagPrefix"]= "iewc";
            direc4Reg["Namespace"]="Microsoft.Web.UI.WebControls";
            direc4Reg["Assembly"]="Microsoft.Web.UI.WebControls";

            Page.Directives.Add(direc4Page);
            Page.Directives.Add(direc4Reg);
            //添加META标签
            HtmlNode metaCompatible1 = HtmlNode.CreateClosedNode("meta");
            metaCompatible1["http-equiv"] = "X-UA-Compatible";
            metaCompatible1["content"] = "IE=EmulateIE7";

            HtmlNode metaCompatible2 = HtmlNode.CreateClosedNode("meta");
            metaCompatible2["http-equiv"] = "X-UA-Compatible";
            metaCompatible2["content"] = "IE=7";
            this.Page.Head.Append(metaCompatible1);
            this.Page.Head.Append(metaCompatible2);

            //添加JS source 标签
            this.Page.Head.Append(JsContext.GetJsLinkTag("Model/rule/JSRule.js"));
            this.Page.Head.Append(JsContext.GetJsLinkTag("Model/rule/initvalue.js"));
            this.Page.Head.Append(JsContext.GetJsLinkTag("js/UCML_PublicApp.js"));
            this.Page.Head.Append(JsContext.GetJsLinkTag("js/ig_shared.js"));
            this.Page.Head.Append(JsContext.GetJsLinkTag("js/ig_edit.js"));
            this.Page.Head.Append(JsContext.GetJsLinkTag("js/dnncore.js"));
            this.Page.Head.Append(JsContext.GetJsLinkTag("js/dnn.js"));
            this.Page.Head.Append(JsContext.GetJsLinkTag("js/dnn.dom.positioning.js"));
            this.Page.Head.Append(JsContext.GetJsLinkTag("js/ucmlapp.js"));

            //添加js 定义 标签
            JsContext js4Head = new JsContext();
            js4Head.Content.AppendLine("var UCMLResourcePath=\"\";");
            js4Head.Content.AppendLine("var UCMLLocalResourcePath=\"\";");
            js4Head.Content.AppendLine("var BPOName=\""+this.Name+"\";");
            JsFunction init = new JsFunction("Init");
            init.Content.AppendLine("var dobject=window.document.all[\"UCMLBUSIOBJECT\"];");
            init.Content.AppendLine("if (dobject==undefined) return;");
            init.Content.AppendLine(this.Name+"BPO.open();");

            string masterTable = "";
            foreach (UcmlBusiCompPropSet bc in this.BCList)
            {
                string bcBase = bc.Name + "Base";
                if (bc.IsRootBC)
                {
                    masterTable = bcBase;

                    init.Content.AppendLine(bcBase + ".fIDENTITYKey =" + bc.fIDENTITYKey.ToString().ToLower() + ";");
                    init.Content.AppendLine(bcBase + ".AllowModifyJION = " + bc.AllowModifyJION.ToString().ToLower() + ";");
                    init.Content.AppendLine(bcBase + ".fHaveUCMLKey = " + bc.fHaveUCMLKey.ToString().ToLower() + ";");
                    init.Content.AppendLine(bcBase + ".PrimaryKey = \""+bc.PrimaryKey+"\";");
                    init.Content.AppendLine(bcBase + ".Columns = "+this.Name+"BPO."+bc.Name+"Columns;");
                    init.Content.AppendLine(bcBase + ".ChangeOnlyOwnerBy = " + bc.ChangeOnlyOwnerBy.ToString().ToLower() + ";");
                    init.Content.AppendLine(bcBase + ".BPOName = \"" + this.Name + "\";");
                }
                else
                {
                    init.Content.AppendLine(bcBase + ".fIDENTITYKey = " + bc.fIDENTITYKey.ToString().ToLower() + ";");
                    init.Content.AppendLine(bcBase + ".AllowModifyJION = " + bc.AllowModifyJION.ToString().ToLower() + ";");
                    init.Content.AppendLine(bcBase + ".fHaveUCMLKey = " + bc.fHaveUCMLKey.ToString().ToLower() + ";");
                    init.Content.AppendLine(bcBase + ".PrimaryKey = \""+bc.PrimaryKey+"\";");
                    init.Content.AppendLine(bcBase + ".Columns = " + this.Name + "BPO." + bc.Name + "Columns;");
                    init.Content.AppendLine(bcBase + ".ChangeOnlyOwnerBy = " + bc.ChangeOnlyOwnerBy.ToString().ToLower() + ";");
                    init.Content.AppendLine(bcBase + ".TableType = \"S\";");
                    init.Content.AppendLine(bcBase + ".LinkKeyName = \""+bc.LinkKeyName+"\";");
                    init.Content.AppendLine(bcBase + ".PK_COLUMN_NAME = \""+bc.PK_COLUMN_NAME+"\";");
                    init.Content.AppendLine(bcBase + ".MasterTable = "+masterTable+";");
                    init.Content.AppendLine(bcBase + ".BPOName = \""+this.Name+"\";");
                }
            }

            foreach (UcmlVcTabPage vcTab in this.VcTabList)
            {
                foreach (UcmlViewCompnent vc in vcTab.VCList)
                {
                    init.Content.AppendLine(vc.VCName + ".UserDefineHTML=\"" + vc.UserDefineHTML.ToString().ToLower() + "\";");
                    init.Content.AppendLine(vc.BCName+"Base.AddConnectControls("+vc.VCName+");");

                    init.Content.AppendLine(vc.VCName+".BPOName=\""+this.Name+"\";");
                    init.Content.AppendLine(vc.VCName+".AppletName=\""+vc.VCName+"\";");
                    init.Content.AppendLine(vc.VCName + ".EnabledEdit=" + vc.EnabledEdit.ToString().ToLower() + ";");
                    init.Content.AppendLine(vc.VCName + ".haveMenu=" + vc.haveMenu.ToString().ToLower() + ";");
                    init.Content.AppendLine(vc.VCName+".parentNodeID=\"\";");
                    init.Content.AppendLine(vc.VCName+".HiddenID=\"TabStrip_"+vc.VCName+";MultiPage_"+vc.VCName+"\";");
                    init.Content.AppendLine(vc.VCName + ".fHidden=\"" + vc.fHidden.ToString().ToLower() + "\";");
                    init.Content.AppendLine(vc.VCName + ".alignHeight=\"" + vc.alignHeight.ToString().ToLower() + "\";");
                    init.Content.AppendLine(vc.VCName + ".alignWidth=\"" + vc.alignWidth.ToString().ToLower() + "\";");

                    init.Content.AppendLine(vc.VCName+".open();");
                }
            }

            foreach (UcmlBusiCompPropSet bc in this.BCList)
            {
                init.Content.AppendLine(bc.Name + "Base.EnabledEdit=true;");
                init.Content.AppendLine(bc.Name + "Base.EnabledAppend=true;");
                init.Content.AppendLine(bc.Name + "Base.EnabledDelete=true;");
                init.Content.AppendLine(bc.Name + "Base.RecordOwnerType=0;");
                init.Content.AppendLine(bc.Name + "Base.open();");
                init.Content.AppendLine(this.Name+"BPO.AddUseTable("+bc.Name+"Base);");
                init.Content.AppendLine();
            }

            init.Content.AppendLine(this.Name+"BPO.InitBusinessEnv();");
            init.Content.AppendLine();
            //把Init函数加入到JS定义 中
            js4Head.JsFuncs.Add(init);
            this.Page.Head.Append(js4Head.GetJsBlockNode());

            #region 构建主页面
            //构建主页面
            foreach (UcmlVcTabPage vcTab in this.VcTabList)
            {
                //TabStrip控件
                AspxNode tabStrip = new AspxNode("iewc:TabStrip");
                tabStrip["id"] = "TabStrip_" + vcTab.Name;
                tabStrip["TargetID"] = "MultiPage_" + vcTab.Name;
                tabStrip["CssClass"] = "UCML-TAB";
                tabStrip["TabSelectedStyle"] = "border-right:#aca899 1px solid;border-top:white 1px solid;background:#ece9d8;border-left:white 1px solid;color:#0;border-bottom:#aca899 1px solid;";
                tabStrip["TabHoverStyle"] = "border-right:#aca899 1px solid;border-top:white 1px solid;background:#ece9d8;border-left:white 1px solid;color:red;border-bottom:#aca899 1px solid;";
                tabStrip["TabDefaultStyle"] = "border-right:#aca899 1px solid;padding-right:2px;border-top:#aca899 1px solid;padding-left:2px;background:#ece9d8;padding-bottom:2px;border-left:#aca899 1px solid;padding-top:2px;border-bottom:#aca899 1px solid;";
                tabStrip["ForeColor"] = "Black";
                tabStrip["BorderColor"] = "CornflowerBlue";
                tabStrip["BackColor"] = "PapayaWhip";
                tabStrip["Font-Names"] = "Verdana";
                tabStrip["Font-Size"] = "8pt";
                tabStrip["EnableViewState"] = "False";
                //MultiPage控件
                AspxNode multiPage = new AspxNode("iewc:MultiPage");
                multiPage["id"] = "MultiPage_" + vcTab.Name;
                multiPage["width"] = "100%";//待改成变量

                //把TabStrip控件和MultiPage控件挂到MainPanelNode下
                Page.MainPanelNode.Append(tabStrip);
                Page.MainPanelNode.Append(multiPage);

                foreach (UcmlViewCompnent vc in vcTab.VCList)
                {
                    //添加Tab控件
                    AspxNode tab = new AspxNode("iewc:Tab");
                    tab["id"] = "Tab_" + vc.VCName;
                    tab["Text"] = vc.Caption;
                    //添加TabSeperator控件
                    HtmlNode tabSep = HtmlNode.CreateClosedNode("iewc:TabSeparator");
                    //挂到tabStrip下
                    tabStrip.Append(tab);
                    tabStrip.Append(tabSep);

                    //添加PageView控件
                    AspxNode pageView = new AspxNode("iewc:PageView");
                    pageView["id"] = "PageView_" + vc.VCName;
                    pageView["Text"] = vc.Caption;
                    //添加Panel控件
                    AspxNode panel = new AspxNode("asp:Panel");
                    panel["id"] = vc.VCName + "_Module";
                    panel["style"] = "overflow:hidden";
                    panel["CssClass"] = "UCML-Panel";
                    panel["width"] = "100%";//待改成变量
                    //挂载PageView到MultiPage
                    multiPage.Append(pageView);
                    //挂载Panel到PageView下
                    pageView.Append(panel);
                    //添加ToolBar
                    //添加ToolButton

                    HtmlNode pageNode = null;
                    if (vc.VCNode == null) pageNode = new HtmlNode("div");
                    else
                    {
                        if (vc.VCNode.Childs.Count == 1 && vc.VCNode.Childs[0].OnlyText) vc.VCNode.Childs.Clear();
                        pageNode = vc.VCNode;
                    }
                    //构造ContextMenu
                    HtmlNode span = new HtmlNode("span");
                    span["id"] = "theContextMenu" + vc.VCName;
                    span["style"] = "Z-INDEX:3103;LEFT:0px;VISIBILITY:hidden;BEHAVIOR: url(menubar.htc);WIDTH:200px;POSITION:absolute;TOP: 0px;HEIGHT:20px";
                    if (vc.Kind == 163)
                    {
                        panel.Append(pageNode);
                        //添加VCName Div
                        HtmlNode div = new HtmlNode("div");
                        div["id"] = vc.VCName;
                        div["style"] = "BEHAVIOR:url(UCMLDBGrid.htc);width:100%;height:200";
                        div["title"] = vc.Caption;
                        panel.Append(div);

                        div.Append(span);
                    }
                    else if (vc.Kind == 164)
                    {
                        HtmlNode div = new HtmlNode("div");
                        div["id"] = vc.VCName;
                        div["style"] = "BEHAVIOR:url(UCMLEdit.htc);Width:100%;Height:200";
                        div["title"] = vc.Caption;
                        panel.Append(div);

                        panel.Append(pageNode);
                        div.Append(span);
                    }
            #endregion 构建主页面
                }
            }

            JsContext tailJS = new JsContext();
            tailJS.Content.AppendLine("document.write('<DIV style=\"BORDER-RIGHT: #0066ff 1px solid; BORDER-TOP: #0066ff 1px solid; Z-INDEX: 103; LEFT: 201px; VISIBILITY: hidden; BORDER-LEFT: #0066ff 1px solid; WIDTH: 272px; BORDER-BOTTOM: #0066ff 1px solid; POSITION: absolute; TOP: 229px; HEIGHT: 27px; BACKGROUND-COLOR: #ffffcc; TEXT-ALIGN: center\" ms_positioning=\"FlowLayout\" id=\"MsgPanel\"></DIV>');");
            JsFunction contextMenu = new JsFunction("document.oncontextmenu");
            contextMenu.Content.AppendLine("event.returnValue = false; ");
            contextMenu.Content.AppendLine("event.cancelBubble = true; ");
            contextMenu.Content.AppendLine("return false; ");
            tailJS.JsFuncs.Add(contextMenu);

            this.Page.Body.Append(tailJS.GetJsBlockNode());
            return true;
        }
Exemplo n.º 2
0
        public void InitPage()
        {
            FormNode = new AspxNode("form");//添加Form节点
            FormNode["id"] = "Form1";
            FormNode["method"] = "post";

            AspxNode naviBar = new AspxNode("asp:Panel");//添加导航条节点
            naviBar["id"] = "NaviPageBar";
            naviBar["visible"] = "false";
            naviBar["style"] = "Z-INDEX:100;LEFT:0px;TOP:0px";
            naviBar["height"] = "20px";
            naviBar["width"] = "100%";

            MainPanelNode = new HtmlNode("div");
            MainPanelNode["id"] = "MainPanel";
            MainPanelNode["style"] = "Z-INDEX:100;left:0px;top:0px";
            MainPanelNode["class"] = "UCML-MailPanel";

            FormNode.Append(naviBar);
            FormNode.Append(MainPanelNode);
            Body.Append(FormNode);
            //添加body属性
            Body["onload"] = "Init()";
            Body["class"] = "UCML-BODY";
            Body["leftMargin"] = "0";
            Body["topMargin"] = "0";
        }