Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserID"] == null) return;
        // 將使用者程式碼置於此以初始化網頁
        string strLeftMenu = string.Empty;

        int AreaCount = 1;

        //利用LoginInfo取得此User的AP Detail Menu.
        PccCommonForC.PccErrMsg myLabel = new PccCommonForC.PccErrMsg(Server.MapPath(Session["PageLayer"] + "XmlDoc"), Session["CodePage"].ToString(), "Label");
        string strDetailPageLayer = Session["PageLayer"].ToString();

        if (Request.QueryString["ApID"] != null)
        {
            //取得應用程式之APID
            string strApID = Request.Params["ApID"];
            //string ApFolder = "", MenuItem ="", MenuName ="";
            string ApFolder = string.Empty;

            PccCommonForC.PccMsg myMsg = new PccCommonForC.PccMsg();
            myMsg.LoadXml(Session["XmlLoginInfo"].ToString());

            if (strApID.Length > 0 && strDetailPageLayer.Length > 0)
            {
                //strDetailPageLayer = strDetailPageLayer.Substring(0,strDetailPageLayer.Length - 3);

                //判斷是否有系統可以使用,若沒有則直接跳出
                if (myMsg.QueryNodes("Authorize") != null)
                {
                    foreach (XmlNode myNode in myMsg.QueryNodes("Authorize"))
                    {
                        //假如不是點選這個系統則直接跳出並判斷下一個
                        if (strApID != myMsg.Query("APID", myNode)) continue;

                        //取得這個AP的最上層之Folder
                        ApFolder = GetApFolder(myMsg.Query("APLink", myNode));

                        //判斷是否有選單系統可以使用,若沒有則直接跳出
                        if (myMsg.QueryNodes("ApMenu", (XmlElement)myNode) != null)
                        {
                            foreach (XmlNode myDetailNode in myMsg.QueryNodes("ApMenu", (XmlElement)myNode))
                            {
                                if (myMsg.Query("show_mk", myDetailNode).Equals("Y"))
                                {
                                    //判斷是否為Web Service的Menu若是則直接跳過 2005/3/8
                                    if (myMsg.Query("MenuLink", myDetailNode).IndexOf(".asmx", 0) > 0)
                                        continue;

                                    //本來在越南區還會做Menu的語系轉換,我認為沒有必要,因為那是直接從資料庫取得的資訊
                                    //這是可以做修改的,而且可利用中(英)對照來解決。實做方式如下:
                                    //有一個很大的缺點,就是若在LabelMsg.xml中沒有加入相對應的值則無法顯示。20060626
                                    /* //060306 判斷語系是否為中文
                                    if(Session["CodePage"].ToString() =="CP950")
                                    {
                                        SaveDataToHashMenu(myMsg.Query("MenuManage",(XmlElement)myDetailNode),strDetailPageLayer,ApFolder,myMsg.Query("MenuNM",(XmlElement)myDetailNode),myMsg.Query("MenuLink",(XmlElement)myDetailNode));
                                    }
                                    else
                                    {
                                        MenuItem = "M" + strApID + int.Parse(myMsg.Query("MENUID",myDetailNode)).ToString();
                                        MenuName = myLabel.GetErrMsg(MenuItem,"MenuItem");
                                        SaveDataToHashMenu(myMsg.Query("MenuManage",(XmlElement)myDetailNode),strDetailPageLayer, ApFolder, MenuName, myMsg.Query("MenuLink",(XmlElement)myDetailNode));

                                    }	*/

                                    SaveDataToHashMenu(myMsg.Query("MenuManage", (XmlElement)myDetailNode), strDetailPageLayer, ApFolder, myMsg.Query("MenuNM", (XmlElement)myDetailNode), myMsg.Query("MenuLink", (XmlElement)myDetailNode));
                                }
                            }
                        }
                    }
                }
            }

            strLeftMenu += "var menus = new Array (";
            int count = 1;

            if (m_Menu.Count > 0)
            {
                AreaCount += m_Menu.Count;
                strLeftMenu += AreaCount.ToString() + ","; //總共多少分區
                strLeftMenu += GetWelcome(strDetailPageLayer, strApID, ref myLabel) + ",";

                /*
                本來在這個地方越南地區也是有做語系的處理,就是在本來設定的image如:N_Open.gif變成N_Open_VN.gif
                我持的理由還是一樣,我覺得Menu區不必做語系的轉換,因為這可以在早期就決定是會在那裡實做,而且可以
                更新圖形即可,而且最好是放在某一個Floder,而其Floder的Name放在Cofig中,這樣比較有彈性。20060626
                */
                //設定一般區
                if (m_Menu.ContainsKey("N"))
                {
                    strLeftMenu += "\"<image src=" + strDetailPageLayer + "images/MenuArea/N_Open.gif />\",";
                    count = m_Menu["N"].ToString().Split(',').Length / 4;
                    strLeftMenu += count.ToString() + ","; //一個大項次的開始,表示有多少個Item
                    strLeftMenu += m_Menu["N"].ToString();
                }

                foreach (string strArea in m_Menu.Keys)
                {
                    if (!strArea.Equals("N") && !strArea.Equals("Y"))
                    {
                        strLeftMenu += "\"<image src=" + strDetailPageLayer + "images/MenuArea/" + strArea + "_Open.gif />\",";
                        count = m_Menu[strArea].ToString().Split(',').Length / 4;
                        strLeftMenu += count.ToString() + ","; //第一個大項次的開始,表示有多少個Item
                        strLeftMenu += m_Menu[strArea].ToString();
                    }
                }

                //設定權限管理區
                if (m_Menu.ContainsKey("Y"))
                {
                    strLeftMenu += "\"<image src=" + strDetailPageLayer + "images/MenuArea/Y_Open.gif />\",";
                    count = m_Menu["Y"].ToString().Split(',').Length / 4;
                    strLeftMenu += count.ToString() + ","; //一個大項次的開始,表示有多少個Item
                    strLeftMenu += m_Menu["Y"].ToString();
                }

                strLeftMenu = strLeftMenu.Substring(0, strLeftMenu.Length - 1);
            }
            else //表示沒有選單權限
            {
                strLeftMenu += AreaCount.ToString() + ","; //總共多少分區
                strLeftMenu += GetWelcome(strDetailPageLayer, strApID, ref myLabel);
            }

            strLeftMenu += ");";

        }

        txtLeftMenu.Value = strLeftMenu;
    }
Ejemplo n.º 2
0
    private void SetMenu()
    {
        string strLeftMenu = string.Empty;
        int AreaCount = 1;

        //LoginInfoUser of AP Detail Menu.
        PccCommonForC.PccErrMsg myLabel = new PccCommonForC.PccErrMsg(Server.MapPath(Session["PageLayer"] + "XmlDoc"), Session["CodePage"].ToString(), "Label");
        string strDetailPageLayer = Session["PageLayer"].ToString();

        if (Request.QueryString["ApID"] != null)
        {
            //APID
            string strApID = Request.Params["ApID"];
            string ApFolder = "", MenuItem = "", MenuName = "";

            PccCommonForC.PccMsg myMsg = new PccCommonForC.PccMsg();
            myMsg.LoadXml(Session["XmlLoginInfo"].ToString());

            if (strApID.Length > 0 && strDetailPageLayer.Length > 0)
            {
                //strDetailPageLayer = strDetailPageLayer.Substring(0,strDetailPageLayer.Length - 3);
                if (myMsg.QueryNodes("Authorize") != null)
                {
                    foreach (XmlNode myNode in myMsg.QueryNodes("Authorize"))
                    {

                        if (strApID != myMsg.Query("APID", myNode)) continue;

                        //Folder
                        ApFolder = GetApFolder(myMsg.Query("APLink", myNode));

                        if (myMsg.QueryNodes("ApMenu", (XmlElement)myNode) != null)
                        {
                            foreach (XmlNode myDetailNode in myMsg.QueryNodes("ApMenu", (XmlElement)myNode))
                            {
                                if (myMsg.Query("show_mk", myDetailNode).Equals("Y"))
                                {

                                    if (myMsg.Query("MenuLink", myDetailNode).IndexOf(".asmx", 0) > 0)
                                        continue;

                                    if (Session["CodePage"].ToString() == "CP950")
                                    {
                                        SaveDataToHashMenu(myMsg.Query("MenuManage", (XmlElement)myDetailNode), strDetailPageLayer, ApFolder, myMsg.Query("MenuNM", (XmlElement)myDetailNode), myMsg.Query("MenuLink", (XmlElement)myDetailNode));
                                    }
                                    else
                                    {
                                        MenuItem = "M" + strApID + int.Parse(myMsg.Query("MENUID", myDetailNode)).ToString();
                                        MenuName = myLabel.GetErrMsg(MenuItem, "MenuItem");
                                        SaveDataToHashMenu(myMsg.Query("MenuManage", (XmlElement)myDetailNode), strDetailPageLayer, ApFolder, MenuName, myMsg.Query("MenuLink", (XmlElement)myDetailNode));

                                    }

                                    // SaveDataToHashMenu(myMsg.Query("MenuManage", (XmlElement)myDetailNode), strDetailPageLayer, ApFolder, myMsg.Query("MenuNM", (XmlElement)myDetailNode), myMsg.Query("MenuLink", (XmlElement)myDetailNode));
                                }
                            }
                        }
                    }
                }
            }

            strLeftMenu = "<div class='glossymenu'>";
            string strLang = "";
            ArrayList arrMenu = new ArrayList();

            if (Session["CodePage"].ToString() != "CP950")
            {
                strLang = "_VN";
            }

            myMsg = new PccMsg();
            myMsg.Load(Server.MapPath(Session["PageLayer"] + @"XmlDoc\ApMenu" + strLang + ".xml"));

            if (myMsg.QueryNodes("Applications/Application") != null)
            {
                foreach (XmlNode apNode in myMsg.QueryNodes("Applications/Application"))
                {
                    if (myMsg.Query("ApID", apNode) == Request.QueryString["ApID"])
                    {
                        if (myMsg.QueryNodes("ApAreas/Area", apNode) != null)
                        {
                            foreach (XmlNode areaNode in myMsg.QueryNodes("ApAreas/Area", apNode))
                            {
                                string AreaMK = myMsg.Query("AreaMK", areaNode);
                                string AreaName = myMsg.Query("AreaName", areaNode);
                                if (m_Menu.ContainsKey(AreaMK))//xet quyen han thay menu
                                {
                                    strLeftMenu += "<a class='menuitem submenuheader' style='cursor:pointer'><span class='area_item'><img  src='" + ResolveUrl("~/") + "Pub/EasyLayout/ImgBody/group_item.png" + "' border='0'>" + AreaName.ToUpper() + "</span></a>";
                                    strLeftMenu += "<div  class='submenu'>";
                                    strLeftMenu += "<ul>";
                                    //add child menu
                                    strLeftMenu += m_Menu[AreaMK].ToString();
                                    strLeftMenu += "</ul>";
                                    strLeftMenu += "</div>"; //end class=menu_body
                                }
                            }
                        }
                        break;
                    }
                }
            }

            /*
            if (m_Menu.Count > 0)
            {
                AreaCount += m_Menu.Count;
                //strLeftMenu += GetWelcome(strDetailPageLayer, strApID);

                string[] strArrMenu = { "N", "R", "S", "W", "M", "Q" };

                for (int w = 0; w < strArrMenu.Length; w++)
                {
                    if (m_Menu.ContainsKey(strArrMenu[w]))
                    {

                        string area_mk = strArrMenu[w];
                        arrMenu.Add(area_mk);
                        //GroupMenu
                        strLeftMenu += "<a class='menuitem submenuheader' style='cursor:pointer'><img src='" + ResolveUrl("~/") + "images/MenuArea/" + area_mk + "_Open" + strLang + ".gif' border='0' ></a>";
                        strLeftMenu += "<div  class='submenu'>";
                        strLeftMenu += "<ul>";
                        //child menu
                        strLeftMenu += m_Menu[area_mk].ToString();
                        strLeftMenu += "</ul>";
                        strLeftMenu += "</div>"; //end class=menu_body
                    }
                }

                foreach (string strArea in m_Menu.Keys) //cac nhom menu khac
                {
                    bool isExits = false;
                    for (int k = 0; k < arrMenu.Count; k++) //kiem tra co ton tai trong menu da co chua
                    {
                        if (strArea == arrMenu[k].ToString() || strArea == "Y")
                        {
                            isExits = true;
                            break;
                        }
                    }

                    if (!isExits)
                    {
                        string area_mk = strArea;

                        //GroupMenu
                        strLeftMenu += "<a class='menuitem submenuheader' style='cursor:pointer'><img src='" + ResolveUrl("~/") + "images/MenuArea/" + area_mk + "_Open" + strLang + ".gif' border='0' ></a>";
                        strLeftMenu += "<div  class='submenu'>";
                        strLeftMenu += "<ul>";
                        //child menu
                        strLeftMenu += m_Menu[area_mk].ToString();
                        strLeftMenu += "</ul>";
                        strLeftMenu += "</div>"; //end class=menu_body
                    }
                }

                //Khu quan ly
                if (m_Menu.ContainsKey("Y"))
                {
                    string area_mk = "Y";
                    arrMenu.Add(area_mk);
                    //GroupMenu
                    strLeftMenu += "<a class='menuitem submenuheader' style='cursor:pointer'><img src='" + ResolveUrl("~/") + "images/MenuArea/" + area_mk + "_Open" + strLang + ".gif' border='0' ></a>";
                    strLeftMenu += "<div  class='submenu'>";
                    strLeftMenu += "<ul>";
                    //child menu
                    strLeftMenu += m_Menu[area_mk].ToString();
                    strLeftMenu += "</ul>";
                    strLeftMenu += "</div>"; //end class=menu_body
                }

            }
            else //表示沒有選單權限
            {
                //strLeftMenu += GetWelcome(strDetailPageLayer, strApID);
            }*/

            strLeftMenu += "</div>"; //end div  class='glossymenu'
        }

        ltrLeftMenu.Text = strLeftMenu;
    }