using System;
using System.IO;
using System.Collections.Generic;
using System.Xml;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace MYAPP.Manage.Project.Design.Tour.Map
{
    public partial class List_Map_Scene : MyApp.Web.UI.UserPage
    {
        public int ROW = 0;
        public string _Tour_ID = "";
        public int _MapIndex_ID = 0;
        public string _name = "";

        override protected void AppInit()//程序基本信息初始化
        {
            try
            {
                _Tour_ID = Request.QueryString["Tour_ID"].Trim();
                _MapIndex_ID = Convert.ToInt32(Request.QueryString["MapIndex_ID"].Trim());
            }
            catch (Exception)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "refresh", "<script language=javascript>alert('请勿非法操作!!!');window.close();</script>");
                return;
            }
            pl_view();
            base.AppInit();
        }

        override protected void DataInit()//数据初始化
        {
        }

        protected override void pl_register_script()
        {
            base.pl_register_script();
        }

        protected void Page_Init(object sender, EventArgs e)
        {
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            MyApp.Components.NavUrl.SetUrl(4);
        }

        override protected void pl_view()
        {
            XmlDocument xmldoc;
            xmldoc = MyApp.Components.XML.XmlDocument.Load(MyApp.Components.KRPano.Project.Get_Project_Name(_Tour_ID));

            try
            {
                xds.Data = xmldoc.OuterXml;
                xds.XPath = String.Format("/Project/Maps/Map[position()={0}]/point", _MapIndex_ID);
                this.rp_list.DataSourceID = "xds";
            }
            catch (Exception)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "refresh", "<script language=javascript>alert('错误!!!');history.back()</script>");
                return;
            }
        }

        public string GetElemValueByPath(object scene_id, string attribute)
        {
            string _File_Dir = Server.MapPath(String.Format("/Project/{0}/Scene/{1}/scene.xml", _Tour_ID, scene_id.ToString()));
            StreamReader sr = System.IO.File.OpenText(_File_Dir);
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.LoadXml(sr.ReadToEnd());
            sr.Close();
            XmlNode xmlnode = xmldoc.ChildNodes[0];
            XmlElement xmlelem = (XmlElement)xmlnode;
            if (xmlelem.GetAttribute(attribute).Trim() != "")
            {
                return xmlelem.GetAttribute(attribute).Trim();
            }
            else
            {
                return "　";
            }
        }
    }
}
