Inheritance: XmlDocument
        public IDictionary<String, String> getLatLong(String zipCode)
        {
            XmlDataDocument doc = new XmlDataDocument();
            List<String> data = new List<String>();
            String url = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + zipCode;
            doc.Load(url);

            XmlNodeList status = doc.GetElementsByTagName("status");
            String res_status = status[0].InnerText;
            if (!res_status.Equals("OK"))
            {
                data.Add("No Result");
            }

            XmlNodeList result = doc.GetElementsByTagName("result");
            XmlNodeList list = null,location = null;

            String latitude = null, longitude = null;

            for (int i = 0; i < result.Count; i++)
            {
                list = doc.GetElementsByTagName("geometry");
            }
            for (int i = 0; i < list.Count; i++)
            {
                location = doc.GetElementsByTagName("location");
            }

            latitude = location[0].SelectSingleNode("lat").InnerText;
            longitude = location[0].SelectSingleNode("lng").InnerText;
            return  getWeatherData(latitude,longitude);
        }
 /// <summary>
 /// Gets the application configuration setting.
 /// </summary>
 /// <param name="setting">Setting to be returned.</param>
 /// <returns></returns>
 public static string GetValue(string setting)
 {
     //			System.Configuration.AppSettingsReader conf=new System.Configuration.AppSettingsReader();
     //			object v=conf.GetValue(setting, typeof(string));
     //			return v;
     System.Reflection.Assembly asm = System.Reflection.Assembly.GetEntryAssembly();
     System.IO.FileInfo         fi  = new System.IO.FileInfo(asm.Location + ".config");
     System.Xml.XmlDataDocument doc = new System.Xml.XmlDataDocument();
     try
     {
         //Load the XML configuration file.
         doc.Load(fi.FullName);
         //Loop through the nodes to find the target node to be returned.
         foreach (System.Xml.XmlNode node in doc["configuration"]["appSettings"])
         {
             if (node.Name == "add")
             {
                 if (node.Attributes.GetNamedItem("key").Value == setting)
                 {
                     return((string)node.Attributes.GetNamedItem("value").Value);
                 }
             }
         }
         //If not found then the setting probably didn't exist...throw an error.
         throw new Exception();
         //Save the results...
     }
     catch
     {
         //There was an error loading or reading the config file...throw an error.
         throw new Exception("Unable to find the setting.  Check that the configuration file exists and contains the appSettings element.");
     }
 }
Exemple #3
0
        public void AddLink(string title, string uri)
        {
            XmlDocument doc = new XmlDataDocument();
            doc.Load("RssLinks.xml");
            XmlNode rootNode = doc.SelectSingleNode("links");

            XmlNode linkNode = doc.CreateElement("link");

            XmlNode titleNode = doc.CreateElement("title");
            XmlText titleText = doc.CreateTextNode(title);
            titleNode.AppendChild(titleText);

            XmlNode uriNode = doc.CreateElement("uri");
            XmlText uriText = doc.CreateTextNode(uri);
            uriNode.AppendChild(uriText);

            XmlNode defaultshowNode = doc.CreateElement("defaultshow");
            XmlText defaultshowText = doc.CreateTextNode("false");
            defaultshowNode.AppendChild(defaultshowText);

            linkNode.AppendChild(titleNode);
            linkNode.AppendChild(uriNode);
            linkNode.AppendChild(defaultshowNode);

            rootNode.AppendChild(linkNode);

            doc.Save("RssLinks.xml");
        }
Exemple #4
0
 private void Form1_Load(object sender, System.EventArgs e)
 {
     this.dataSet1.ReadXmlSchema ( "locdataschema.xsd" );
     XmlDataDocument datadoc = new XmlDataDocument ( dataSet1 );
     datadoc.Load ( "locdata.xml" );
     this.dataGrid1.DataSource = this.dataSet1.Tables["loctest"];
 }
Exemple #5
0
    public void loaddata()
    {
        XmlDataDocument xml = new XmlDataDocument();
        xml.Load(Server.MapPath("~/" + "ad.xml"));

        XmlNodeList nodes = xml.SelectSingleNode("ttt").ChildNodes;

        DataTable dt = new DataTable();

        dt.Columns.Add("index", typeof(string));
        dt.Columns.Add("src", typeof(string));
        dt.Columns.Add("href", typeof(string));
        dt.Columns.Add("target", typeof(string));

        foreach (XmlNode node in nodes)
        {
            DataRow row = dt.NewRow();

            row["href"] = node.Attributes["href"].Value;
            row["src"] = node.Attributes["src"].Value;
            dt.Rows.Add(row);
        }

        DataList4.DataSource = dt;
        DataList4.DataBind();
    }
        /// <summary>
        /// 由ModBus列表创建IDEquipRes[,]---IDModel[, , , ]相互索引
        /// </summary>
        /// <param name="modbusList">ModBus列表</param>
        public void SetDictionaryWithXml(string xmlPath)
        {
            System.Xml.XmlDataDocument xmlDoc = new System.Xml.XmlDataDocument();
            xmlDoc.Load(xmlPath);

            IDEquipRes tmpIDEqu;
            IDModel    tmpIDMod;

            foreach (XmlNode node1 in xmlDoc.ChildNodes)
            {
                foreach (XmlNode node2 in node1.ChildNodes)
                {
                    if (node2.Name == "Point")
                    {
                        int    equId   = Convert.ToInt32(node2.Attributes["MachineID"].Value);
                        int    resId   = Convert.ToInt32(node2.Attributes["RegID"].Value);
                        int    devId   = Convert.ToInt32(node2.Attributes["DevID"].Value);
                        int    pointId = Convert.ToInt32(node2.Attributes["PointID"].Value);
                        string strType = node2.Attributes["Type"].Value.Trim();

                        tmpIDEqu = new IDEquipRes(equId, resId);
                        tmpIDMod = new IDModel(devId, strType, pointId);

                        //IDEquipRes --> IDModel
                        dictionEToM.Add(tmpIDEqu.ToULongForIndex(), tmpIDMod);

                        //IDModel --> IDEquipRes
                        dictionMToE.Add(tmpIDMod.ToULongForIndex(), tmpIDEqu);
                    }
                }
            }
        } //end of SetIndexWithXml
    public void readChannelFeed()
    {
        XmlDataDocument xmldoc = new XmlDataDocument();
        XmlNodeList xmlnode;
        int i = 0;
        //string str = null;
        xmldoc.Load(formHTTPrequest());
        xmlnode = xmldoc.GetElementsByTagName("feed");
        feedCount = xmlnode.Count;

        dates = new string[xmlnode.Count];
        ids = new string[xmlnode.Count];
        temp = new string[xmlnode.Count];
        air = new string[xmlnode.Count];
        soil = new string[xmlnode.Count];
        light = new string[xmlnode.Count];
        co2_1 = new string[xmlnode.Count];
        co2_2 = new string[xmlnode.Count];
        out_temp = new string[xmlnode.Count];

        for (i = 0; i <= xmlnode.Count - 1; i++)
        {
            dates[i] = xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
            ids[i] = xmlnode[i].ChildNodes.Item(1).InnerText.Trim();
            temp[i] = xmlnode[i].ChildNodes.Item(2).InnerText.Trim();
            air[i] = xmlnode[i].ChildNodes.Item(3).InnerText.Trim();
            soil[i] = xmlnode[i].ChildNodes.Item(4).InnerText.Trim();
            light[i] = xmlnode[i].ChildNodes.Item(5).InnerText.Trim();
            co2_1[i] = xmlnode[i].ChildNodes.Item(6).InnerText.Trim();
            co2_2[i] = xmlnode[i].ChildNodes.Item(7).InnerText.Trim();
            out_temp[i] = xmlnode[i].ChildNodes.Item(8).InnerText.Trim();

        }
    }
Exemple #8
0
 public XmlFile(string FileName)
 {
     this.strDataFileName = FileName;
     this.mydoc = new XmlDataDocument();
     this.mydoc.Load(this.strDataFileName);
     this.mydoc.DataSet.EnforceConstraints = false;
 }
Exemple #9
0
        /// <summary>
        /// Возвращает массив объектов по структуре SysObject
        /// </summary>
        /// <returns></returns>
        public ArrayList getObjectList()
        {
            ArrayList arrField = new ArrayList();
            SysObject sObject;
            DataSet DS = new DataSet();

            try
            {
                GetXMLFileData(DS, Config_Protocol);
            }
            catch (Exception e)
            {
                string sError = e.Message;
            }

            DataRow row;
            XmlDataDocument XDoc = new XmlDataDocument(DS);
            XmlNodeList ProtocolNode = XDoc.DocumentElement.SelectNodes("//objects/obj");

            foreach (XmlNode xmlNode in ProtocolNode)
            {
                row = XDoc.GetRowFromElement((XmlElement)xmlNode);

                if (row != null)
                {
                    sObject.Index= Convert.ToInt16(row[0].ToString());
                    sObject.Type = row[1].ToString();
                    arrField.Add(sObject);
                }
            }

            return arrField;
        }
Exemple #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string connStr = "Data Source=.\\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI;";

        using (SqlConnection conn = new SqlConnection(connStr))
        {
            SqlCommand command = new SqlCommand("select * from customers", conn);
            conn.Open();
            DataSet ds = new DataSet();
            ds.DataSetName = "Customers";
            ds.Load(command.ExecuteReader(), LoadOption.OverwriteChanges, "Customer");
            //Response.ContentType = "text/xml";
            //ds.WriteXml(Response.OutputStream);

            //Added in Listing 13-15
            XmlDataDocument doc = new XmlDataDocument(ds);
            doc.DataSet.EnforceConstraints = false;
            XmlNode node = doc.SelectSingleNode(@"//Customer[CustomerID = 'ANATR']/ContactTitle");
            node.InnerText = "Boss";
            doc.DataSet.EnforceConstraints = true;

            DataRow dr = doc.GetRowFromElement((XmlElement)node.ParentNode);
            Response.Write(dr["ContactName"].ToString() + " is the ");
            Response.Write(dr["ContactTitle"].ToString());
        }
    }
        public IDictionary<String, String> getWeatherData(String lat, String lon)
        {
            XmlDataDocument doc = new XmlDataDocument();
            IDictionary<String, String> data = new Dictionary<String, String>();
            String url ="http://api.openweathermap.org/data/2.5/forecast/daily?lat=" + lat + "&lon=" + lon + "&cnt=5&mode=xml";
            doc.Load(url);

            XmlNodeList locationList = doc.GetElementsByTagName("location");
            XmlNodeList foreCastList = doc.GetElementsByTagName("time");

            data["City"] = locationList[0].SelectSingleNode("name").InnerText;
            data["Country"] = locationList[0].SelectSingleNode("country").InnerText;

            String temperature,wind,clouds;

            for (int i = 0; i < 5; i++)
            {
                temperature = "Temperature : Morn = " + foreCastList[i].SelectSingleNode("temperature").Attributes["morn"].Value +
                            ",Evening = " + foreCastList[i].SelectSingleNode("temperature").Attributes["eve"].Value + ",Night = " + foreCastList[i].SelectSingleNode("temperature").Attributes["night"].Value;
                wind = "Wind : " + foreCastList[i].SelectSingleNode("windSpeed").Attributes["name"].Value;
                clouds = "Clouds : " + foreCastList[i].SelectSingleNode("clouds").Attributes["value"].Value;

                data[foreCastList[i].Attributes["day"].Value] = temperature + " | " + wind + " | " + clouds;
            }
            return data;
        }
Exemple #12
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            XmlDataDocument doc = new XmlDataDocument ();
            doc.Load ( "locdata.xml" );
            XmlNodeList nodes = doc.GetElementsByTagName("city");
            foreach ( XmlNode n in nodes )
            {
                listBox1.Items.Add ( n.InnerText );

            }
            label1.Text = string.Format("Total {0} Item(s).", listBox1.Items.Count);

            //			StreamReader reader = new StreamReader ( "loctest2.csv" );
            //			string contents = reader.ReadToEnd ();
            //			reader.Close ();
            //			foreach ( string s in contents.Split ( "\n\r".ToCharArray() ) )
            //			{
            //				if ( s.Trim() == string.Empty ) continue;
            //				foreach ( string p in s.Split ( ",".ToCharArray() ) )
            //				{
            //					string temp = p.Replace ( "\"", "" );
            //					listBox1.Items.Add ( temp.Trim() );
            //				}
            //
            //
            //			}
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //try
            //{
                if (this.RssUrl.Length == 0)
                    throw new ApplicationException("Не указана ссылка на RSS-ленту.");

                XmlDataDocument feed = new XmlDataDocument();
                feed.Load(GetFullUrl(this.RssUrl));
                XmlNodeList posts = feed.GetElementsByTagName("item");

                DataTable table = new DataTable("Feed");
                table.Columns.Add("Title", typeof(string));
                table.Columns.Add("Description", typeof(string));
                table.Columns.Add("Link", typeof(string));
                table.Columns.Add("PubDate", typeof(DateTime));

                foreach (XmlNode post in posts)
                {
                    DataRow row = table.NewRow();
                    row["Title"] = post["title"].InnerText;
                    row["Description"] = post["description"].InnerText.Trim();
                    row["Link"] = post["link"].InnerText;
                    row["PubDate"] = DateTime.Parse(post["pubDate"].InnerText);
                    table.Rows.Add(row);
                }

                dlArticles.DataSource = table;
                dlArticles.DataBind();
            //}
            /*catch (Exception)
            {
                this.Visible = false;
            }*/
        }
        private void createCsvFile()
        {
            XmlDataDocument xmldoc = new XmlDataDocument();
            string name = null;
            string year = null;
            string corp = null;
            string line = null;
            string code = null;
            XmlNodeList childs = null;
            StreamWriter file = new StreamWriter(mamePath + "roms.csv", false);
            FileStream fs = new FileStream(mamePath + "mame.xml", FileMode.Open, FileAccess.Read);
            xmldoc.Load(fs);
            XmlNodeList machineNodes = xmldoc.GetElementsByTagName("machine");

            for (int i = 0; i < machineNodes.Count; i++)
            {
                code = machineNodes[i].Attributes.GetNamedItem("name").InnerText.Trim();
                childs = machineNodes[i].ChildNodes;
                name = childs.Count > 0 ?  childs.Item(0).InnerText.Trim() : "";
                year = childs.Count > 1 ? childs.Item(1).InnerText.Trim() : "";
                corp = childs.Count > 2 ? childs.Item(2).InnerText.Trim() : "";
                line = segment(code) + ", " + segment(name)  + ", " + segment(year) + ", " + segment(corp);
                file.WriteLine(line);
                //if (i > 10) {
                //    break;
                //}
            }
            file.Close();
            fs.Close();
        }
 public bool AddLineLayerRule(Page oPage, string sFilter, string width, string linestyle, string color)
 {
     try
     {
         if (this.LayerDefXmlString != "")
         {
             this.LayerDefXml = new XmlDataDocument();
             this.LayerDefXml.LoadXml(this.LayerDefXmlString);
         }
         else if (this.LayerDefXml == null)
         {
             return false;
         }
         XmlNode pRule = this.LayerDefXml.GetElementsByTagName("LineRule")[0].Clone();
         pRule.SelectSingleNode("Filter").InnerText = sFilter;
         pRule.SelectSingleNode("LineSymbolization2D/LineStyle").InnerText = linestyle;
         pRule.SelectSingleNode("LineSymbolization2D/Thickness").InnerText = width;
         pRule.SelectSingleNode("LineSymbolization2D/Color").InnerText = color.ToUpper();
         this.LayerDefXml.GetElementsByTagName("LineTypeStyle")[0].AppendChild(pRule);
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         this.layerDefContent = new MgByteSource(Encoding.UTF8.GetBytes(this.LayerDefXml.OuterXml), this.LayerDefXml.OuterXml.Length).GetReader();
         return true;
     }
     catch
     {
         return false;
     }
 }
		public void SimpleLoad ()
		{
			string xml001 = "<root/>";
			XmlDataDocument doc = new XmlDataDocument ();
			DataSet ds = new DataSet ();
			ds.InferXmlSchema (new StringReader (xml001), null);
			doc.LoadXml (xml001);

			string xml002 = "<root><child/></root>";
			doc = new XmlDataDocument ();
			ds = new DataSet ();
			ds.InferXmlSchema (new StringReader (xml002), null);
			doc.LoadXml (xml002);

			string xml003 = "<root><col1>test</col1><col1></col1></root>";
			doc = new XmlDataDocument ();
			ds = new DataSet ();
			ds.InferXmlSchema (new StringReader (xml003), null);
			doc.LoadXml (xml003);

			string xml004 = "<set><tab1><col1>test</col1><col1>test2</col1></tab1><tab2><col2>test3</col2><col2>test4</col2></tab2></set>";
			doc = new XmlDataDocument ();
			ds = new DataSet ();
			ds.InferXmlSchema (new StringReader (xml004), null);
			doc.LoadXml (xml004);
		}
        public static DataTable RetrieveFilterData(string filterPath)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("Category", typeof(string)));
            dt.Columns.Add(new DataColumn("Name", typeof(string)));
            dt.Columns.Add(new DataColumn("Value", typeof(string)));

            DataSet ds = new DataSet();
            ds.ReadXml(filterPath);

            XmlDataDocument xmlDataDoc = new XmlDataDocument(ds);
            string strXPathQuery = "/root/filter";
            string category = string.Empty;
            string itemName = string.Empty;
            string itemValue = string.Empty;

            DataRow dr = null;

            foreach (XmlNode nodeDetail in xmlDataDoc.SelectNodes(strXPathQuery))
            {
                category = nodeDetail.ChildNodes[0].InnerText.ToString();
                itemName = nodeDetail.ChildNodes[1].InnerText.ToString();
                itemValue = nodeDetail.ChildNodes[2].InnerText.ToString();

                dr = dt.NewRow();

                dr["Category"] = category;
                dr["Name"] = itemName;
                dr["Value"] = itemValue;

                dt.Rows.Add(dr);
            }

            return dt;
        }
        /// <summary>
        /// 用xml文件初始化Modbus参数(包括其内部的寄存器)
        /// </summary>
        /// <param name="xmlPath">Modbus设备Id</param>
        /// <param name="modbusId">xml文件路径</param>
        public void InitModbusServerWithXml(int modbusId, string xmlPath)
        {
            System.Xml.XmlDataDocument xmlDoc = new System.Xml.XmlDataDocument();
            xmlDoc.Load(xmlPath);

            foreach (XmlNode node1 in xmlDoc.ChildNodes)
            {
                foreach (XmlNode node2 in node1.ChildNodes)
                {
                    //设置ModbusId
                    equIp = modbusId;

                    //设置ModbusIP
                    if (node2.Name == "Equip" && node2.Attributes["ID"].Value == Convert.ToString(modbusId))
                    {
                        modbusIP = node2.Attributes["IP"].Value;
                    }

                    //设置所有寄存器
                    if (node2.Name == "Point" && node2.Attributes["MachineID"].Value == Convert.ToString(modbusId))
                    {
                        int    resId   = Convert.ToInt32(node2.Attributes["RegID"].Value);
                        int    devId   = Convert.ToInt32(node2.Attributes["DevID"].Value);
                        int    pointId = Convert.ToInt32(node2.Attributes["PointID"].Value);
                        string strType = node2.Attributes["Type"].Value.Trim();

                        registerList.Add(new ModbusRegister(modbusId, resId, pointId, strType)
                        {
                            DevId = devId,
                        }
                                         );
                    }
                }
            }
        }
Exemple #19
0
        XmlNode root = null;//根节点
        public ConfigXML()
        {

            XmlDataDocument configXMLDocu = new XmlDataDocument();
            configXMLDocu.Load("./config.xml");
            root = configXMLDocu.DocumentElement;
            
        }
Exemple #20
0
		public void TestMultipleLoadError ()
		{
			DataSet ds = new DataSet ();
			ds.ReadXml (new XmlTextReader (xml, XmlNodeType.Document, null));
			// If there is already data element, Load() fails.
			XmlDataDocument doc = new XmlDataDocument (ds);
			doc.LoadXml (xml);
		}
		public XmlDataDocument GetXmlDataDocument ()
		{
			if (xmlDataDocument == null) {
				xmlDataDocument = new XmlDataDocument ();
				LoadXmlDataDocument (xmlDataDocument);
			}
			return xmlDataDocument;
		}
Exemple #22
0
		private XmlDataDocument ErrorResult(string error)
		{
			string xmlText = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Error>" + error + "</Error>";
			XmlTextReader xmlReader = new XmlTextReader(new StringReader(xmlText));
			XmlDataDocument xmlDataDoc = new XmlDataDocument();
			xmlDataDoc.Load(xmlReader);
			return xmlDataDoc;
		}
 /// <summary>
 /// Routines for error logging
 /// </summary>
 public static void LogError(XmlDataDocument _XmlDataDocument)
 {
     _Mutex.WaitOne();
     LogErrorXml(_XmlDataDocument);
     LogErrorHtml(_XmlDataDocument);
     LogErrorFile(_XmlDataDocument);
     _Mutex.ReleaseMutex();
 }
Exemple #24
0
        public void AppendNode(DataSet ds)
        {
            XmlDataDocument xmlDataDocument = new XmlDataDocument(ds);

            XmlNode node = xmlDataDocument.DocumentElement.FirstChild;

            AppendNode(node);
        }
Exemple #25
0
        XmlDataDocument m_XmlTemp;//为求得m_XmlResult而建立的辅助


        
        public FCVarialbes(string strtypeid, string strEventTag)
        {
            m_XmlResult = new XmlDataDocument();
            m_XmlTemp = new XmlDataDocument();

            SetInnerXml(m_XmlResult, strEventTag);
            m_strTypeId = strtypeid;
        }
Exemple #26
0
 internal DataPointer( DataPointer pointer ) {
     this.doc = pointer.doc;
     this.node = pointer.node;
     this.column = pointer.column;
     this.fOnValue = pointer.fOnValue;
     this.bNeedFoliate = false;
     this._isInUse = true;
     AssertValid();
 }
Exemple #27
0
 internal DataPointer( XmlDataDocument doc, XmlNode node ) {
     this.doc = doc;
     this.node = node;
     this.column = null;
     this.fOnValue = false;
     bNeedFoliate = false;
     this._isInUse = true;
     AssertValid();
 }
Exemple #28
0
        static void Main(string[] args)
        {
            ArrayList plcInterfaceList = new ArrayList();
            ArrayList simInterfaceList = new ArrayList();

            string filename         = "config.xml";
            var    currentDirectory = Directory.GetCurrentDirectory();
            var    configFilepath   = Path.Combine(currentDirectory, filename);

            System.Xml.XmlDataDocument xmldoc = new System.Xml.XmlDataDocument();
            XmlNodeList xmlAddresses;

            string     str = null;
            FileStream fs  = new FileStream(configFilepath, FileMode.Open, FileAccess.Read);

            xmldoc.Load(fs);
            xmlAddresses = xmldoc.GetElementsByTagName("Address");

            var numOfPlcs = xmlAddresses.Count;

            for (int i = 0; i < numOfPlcs; i++)
            {
                string amsAddress = xmlAddresses[i].ChildNodes.Item(0).InnerText.Trim();
                Console.WriteLine("AmsNetId: {0}", amsAddress);
                PlcInterface plcInterface = new PlcInterface(amsAddress);
                plcInterfaceList.Add(plcInterface);
                plcInterface.Fetch();
                SimInterface simInterface = new SimInterface(plcInterface);
                simInterfaceList.Add(simInterface);
                simInterface.Init();
            }
            Console.WriteLine("Press enter to end the program.");
            Console.WriteLine();
            while (true)
            {
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey(true);
                    if (key.Key == ConsoleKey.Enter)
                    {
                        break;
                    }
                }
            }

            Console.WriteLine("Cleaning up and exiting.");
            foreach (SimInterface simInterface in simInterfaceList)
            {
                simInterface.Dispose();
            }

            foreach (PlcInterface plcInterface in plcInterfaceList)
            {
                plcInterface.Dispose();
            }
        }
Exemple #29
0
 internal DataPointer(XmlDataDocument doc, XmlNode node)
 {
     _doc = doc;
     _node = node;
     _column = null;
     _fOnValue = false;
     _bNeedFoliate = false;
     _isInUse = true;
     AssertValid();
 }
Exemple #30
0
 internal DataPointer(DataPointer pointer)
 {
     _doc = pointer._doc;
     _node = pointer._node;
     _column = pointer._column;
     _fOnValue = pointer._fOnValue;
     _bNeedFoliate = false;
     _isInUse = true;
     AssertValid();
 }
 static void Main()
 {
     XmlDocument doc = new XmlDataDocument();
     doc.Load(@"..\..\..\Catalogue.xml");
     var albumNodes = doc.DocumentElement.ChildNodes;
     foreach (XmlNode albumNode in albumNodes)
     {
         Console.WriteLine(albumNode["catalogue:name"].InnerText);
     }
 }
Exemple #32
0
		public void TestMultipleLoadNoError ()
		{
			DataSet ds = new DataSet ();
			DataTable dt = new DataTable ();
			dt.Columns.Add ("col1");
			ds.Tables.Add (dt);

			XmlDataDocument doc = new XmlDataDocument (ds);
			doc.LoadXml (xml);
		}
Exemple #33
0
        internal void MoveTo( DataPointer pointer ) {
            AssertValid();
            // You should not move outside of this document
            Debug.Assert( node == this.doc || node.OwnerDocument == this.doc );

            this.doc = pointer.doc;
            this.node = pointer.node;
            this.column = pointer.column;
            this.fOnValue = pointer.fOnValue;
            AssertValid();
        }
 public void TestMultipleLoadError()
 {
     Assert.Throws<InvalidOperationException>(() =>
     {
         var ds = new DataSet();
         ds.ReadXml(new XmlTextReader(_xml, XmlNodeType.Document, null));
         // If there is already data element, Load() fails.
         XmlDataDocument doc = new XmlDataDocument(ds);
         doc.LoadXml(_xml);
     });
 }
Exemple #35
0
        private void LoadNpcConfig(string path, out List <string> npcNames, out List <string> controlMechanisms,
                                   out List <Microsoft.DirectX.Vector3> positions, out List <string> characterNames, out List <string> actions)
        {
            controlMechanisms = new List <string>();
            npcNames          = new List <string>();
            positions         = new List <Microsoft.DirectX.Vector3>();
            characterNames    = new List <string>();
            actions           = new List <string>();

            System.Xml.XmlDataDocument doc = new System.Xml.XmlDataDocument();
            doc.Load(path);

            XmlNode rootNode = doc.GetElementsByTagName("List")[0];

            foreach (XmlNode npcNode in rootNode.ChildNodes)
            {
                foreach (XmlNode node in npcNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                    case "Name":
                        npcNames.Add(node.InnerText);
                        break;

                    case "Script":
                        controlMechanisms.Add(node.InnerText);
                        break;

                    case "FSM":
                        controlMechanisms.Add(node.InnerText);
                        break;

                    case "Position":
                        Microsoft.DirectX.Vector3 position = new Microsoft.DirectX.Vector3();
                        int x = Convert.ToInt32(node.ChildNodes[0].InnerText);
                        int z = Convert.ToInt32(node.ChildNodes[1].InnerText);
                        position = terrain.Get3Dposition(new System.Drawing.Point(x, z));

                        positions.Add(position);
                        break;

                    case "Character":
                        characterNames.Add(node.InnerText);
                        break;

                    case "Actions":
                        actions.Add(node.InnerText);
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// 用xml文件初始化modbusList字段
        /// </summary>
        /// <param name="xmlPath">xml文件地址</param>
        public void SetModbusListWithXml(string xmlPath)
        {
            System.Xml.XmlDataDocument xmlDoc = new System.Xml.XmlDataDocument();
            xmlDoc.Load(xmlPath);

            foreach (XmlNode node1 in xmlDoc.ChildNodes)
            {
                foreach (XmlNode node2 in node1.ChildNodes)
                {
                    if (node2.Name == "Equip")
                    {
                        int modId = int.Parse(node2.Attributes["ID"].Value);
                        modbusList.Add(new TCPModBusServer(modId, xmlPath));
                    }
                }
            }
        }//end of SetModbusListWithXml
        /// <summary>
        /// Sets the application configuration setting.
        /// </summary>
        /// <param name="setting">Setting to be changed/added.</param>
        /// <param name="val">Value to change/add.</param>
        public static void SetValue(string setting, string val)
        {
            bool changed = false;

            System.Reflection.Assembly asm = System.Reflection.Assembly.GetEntryAssembly();
            System.IO.FileInfo         fi  = new System.IO.FileInfo(asm.Location + ".config");
            System.Xml.XmlDataDocument doc = new System.Xml.XmlDataDocument();
            try
            {
                //Load the XML application configuration file
                doc.Load(fi.FullName);
                //Loops through the nodes to find the target node to change
                foreach (System.Xml.XmlNode node in doc["configuration"]["appSettings"])
                {
                    if (node.Name == "add")
                    {
                        //Set the key and value attributes
                        if (node.Attributes.GetNamedItem("key").Value == setting)
                        {
                            node.Attributes.GetNamedItem("value").Value = val;
                            //Flag the change as complete
                            changed = true;
                        }
                    }
                }
                //If not changed yet then we assume it's a new key to be added
                if (!changed)
                {
                    //create the new node and append it to the collection
                    System.Xml.XmlNode      node    = doc["configuration"]["appSettings"];
                    System.Xml.XmlElement   elem    = doc.CreateElement("add");
                    System.Xml.XmlAttribute attrKey = doc.CreateAttribute("key");
                    System.Xml.XmlAttribute attrVal = doc.CreateAttribute("value");
                    elem.Attributes.SetNamedItem(attrKey).Value = setting;
                    elem.Attributes.SetNamedItem(attrVal).Value = val;
                    node.AppendChild(elem);
                }
                //Save the XML configuration file.
                doc.Save(fi.FullName);
            }
            catch
            {
                //There was an error loading or reading the config file...throw an error.
                throw new Exception("Unable to set the value.  Check that the configuration file exists and contains the appSettings element.");
            }
        }
Exemple #38
0
        public MetaDatas GetMetaData()
        {
            //Retrieve document class metadata
            MetaDatas metas = null;

            try {
                metas = new MetaDatas();
                System.Xml.XmlDataDocument xmlMeta = new System.Xml.XmlDataDocument();
                xmlMeta.DataSet.ReadXml(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "\\App_Data\\metadata.xml");
                for (int i = 0; i < xmlMeta.DataSet.Tables["MetaDataTable"].Rows.Count; i++)
                {
                    MetaData md = new MetaData(xmlMeta.DataSet.Tables["MetaDataTable"].Rows[i]["ClassName"].ToString(), xmlMeta.DataSet.Tables["MetaDataTable"].Rows[i]["Property"].ToString(), xmlMeta.DataSet.Tables["MetaDataTable"].Rows[i]["Value"].ToString());
                    metas.Add(md);
                }
            }
            catch (Exception ex) { throw new FaultException <EnterpriseFault>(new EnterpriseFault(ex.Message), "Service Error"); }
            return(metas);
        }
Exemple #39
0
        public DocumentClasses GetDocumentClasses()
        {
            //Retrieve document classes
            DocumentClasses docs = null;

            try {
                docs = new DocumentClasses();
                System.Xml.XmlDataDocument xmlDoc = new System.Xml.XmlDataDocument();
                xmlDoc.DataSet.ReadXml(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "\\App_Data\\documentclass.xml");
                for (int i = 0; i < xmlDoc.DataSet.Tables["DocumentClassTable"].Rows.Count; i++)
                {
                    DocumentClass dc = new DocumentClass(xmlDoc.DataSet.Tables["DocumentClassTable"].Rows[i]["Department"].ToString(), xmlDoc.DataSet.Tables["DocumentClassTable"].Rows[i]["ClassName"].ToString());
                    docs.Add(dc);
                }
            }
            catch (Exception ex) { throw new FaultException <EnterpriseFault>(new EnterpriseFault(ex.Message), "Service Error"); }
            return(docs);
        }
Exemple #40
0
        public DocumentClasses GetDocumentClasses()
        {
            //Retrieve document classes
            DocumentClasses docs = null;

            try {
                docs = new DocumentClasses();
                System.Xml.XmlDataDocument xmlDoc = new System.Xml.XmlDataDocument();
                xmlDoc.DataSet.ReadXml(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "\\App_Data\\documentclass.xml");
                for (int i = 0; i < xmlDoc.DataSet.Tables["DocumentClassTable"].Rows.Count; i++)
                {
                    DocumentClass dc = new DocumentClass(xmlDoc.DataSet.Tables["DocumentClassTable"].Rows[i]["Department"].ToString(), xmlDoc.DataSet.Tables["DocumentClassTable"].Rows[i]["ClassName"].ToString());
                    docs.Add(dc);
                }
            }
            catch (Exception ex) { throw new ApplicationException("Unexpected error in GetDocumentClasses().", ex); }
            return(docs);
        }
Exemple #41
0
        public MetaDatas GetMetaData()
        {
            //Retrieve document class metadata
            MetaDatas metas = null;

            try {
                metas = new MetaDatas();
                System.Xml.XmlDataDocument xmlMeta = new System.Xml.XmlDataDocument();
                xmlMeta.DataSet.ReadXml(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "\\App_Data\\metadata.xml");
                for (int i = 0; i < xmlMeta.DataSet.Tables["MetaDataTable"].Rows.Count; i++)
                {
                    MetaData md = new MetaData(xmlMeta.DataSet.Tables["MetaDataTable"].Rows[i]["ClassName"].ToString(), xmlMeta.DataSet.Tables["MetaDataTable"].Rows[i]["Property"].ToString());
                    metas.Add(md);
                }
            }
            catch (Exception ex) { throw new ApplicationException("Unexpected error in GetMetaData().", ex); }
            return(metas);
        }
        internal bool NextInitialTextLikeNodes(out string value)
        {
            Debug.Assert(CurrentNode != null);
            Debug.Assert(CurrentNode.NodeType == XmlNodeType.Element);
#if DEBUG
            // It's not OK to try to read the initial text value for sub-regions, because we do not know how to revert their initial state
            if (CurrentNode.NodeType == XmlNodeType.Element && mapper.GetTableSchemaForElement((XmlElement)(CurrentNode)) != null)
            {
                if (CurrentNode != _rowElement)
                {
                    Debug.Fail("Reading the initial text value for sub-regions.");
                }
            }
#endif

            ElementState oldState = _rowElement.ElementState;

            // We do not want to cause any foliation w/ this iterator or use this iterator once the region was defoliated
            Debug.Assert(oldState != ElementState.None);

            XmlNode?n = CurrentNode.FirstChild;
            value = GetInitialTextFromNodes(ref n);
            if (n == null)
            {
                // If we have been defoliated, we should have stayed that way
                Debug.Assert((oldState == ElementState.Defoliated) ? (_rowElement.ElementState == ElementState.Defoliated) : true);

                // Rollback eventual foliation
                _rowElement.ElementState = oldState;
                return(NextRight());
            }
            Debug.Assert(!XmlDataDocument.IsTextLikeNode(n));
            _currentNode = n;

            // If we have been defoliated, we should have stayed that way
            Debug.Assert((oldState == ElementState.Defoliated) ? (_rowElement.ElementState == ElementState.Defoliated) : true);

            // Rollback eventual foliation
            _rowElement.ElementState = oldState;
            return(true);
        }
Exemple #43
0
        private void WriteRootBoundElementTo(DataPointer dp, XmlWriter w)
        {
            Debug.Assert(dp.NodeType == XmlNodeType.Element);
            XmlDataDocument doc = (XmlDataDocument)OwnerDocument;

            w.WriteStartElement(dp.Prefix, dp.LocalName, dp.NamespaceURI);
            int  cAttr   = dp.AttributeCount;
            bool bHasXSI = false;

            if (cAttr > 0)
            {
                for (int iAttr = 0; iAttr < cAttr; iAttr++)
                {
                    dp.MoveToAttribute(iAttr);
                    if (dp.Prefix == "xmlns" && dp.LocalName == XmlDataDocument.XSI)
                    {
                        bHasXSI = true;
                    }

                    WriteTo(dp, w);
                    dp.MoveToOwnerElement();
                }
            }

            if (!bHasXSI && doc._bLoadFromDataSet && doc._bHasXSINIL)
            {
                w.WriteAttributeString("xmlns", "xsi", "http://www.w3.org/2000/xmlns/", Keywords.XSINS);
            }

            WriteBoundElementContentTo(dp, w);

            // Force long end tag when the elem is not empty, even if there are no children.
            if (dp.IsEmptyElement)
            {
                w.WriteEndElement();
            }
            else
            {
                w.WriteFullEndElement();
            }
        }
Exemple #44
0
        public void SetCmeManagerListWithXml(string xmlPath)
        {
            System.Xml.XmlDataDocument xmlDoc = new System.Xml.XmlDataDocument();
            xmlDoc.Load(xmlPath);
            int equipId;

            foreach (XmlNode node1 in xmlDoc.ChildNodes)
            {
                foreach (XmlNode node2 in node1.ChildNodes)
                {
                    if (node2.Name == "Equip")
                    {
                        equipId = int.Parse(node2.Attributes["ID"].Value.Trim());

                        CmeManager tmpCmeManager = new CmeManager(equipId, xmlPath);
                        _cmeManagerList.Add(tmpCmeManager);
                        _dicEquipIdToCmeManager.Add(equipId, tmpCmeManager);
                    }
                }
            }
        }
Exemple #45
0
 internal void SetupMapping(XmlDataDocument xd, DataSet ds)
 {
     if (this.IsMapped())
     {
         this.tableSchemaMap  = new Hashtable();
         this.columnSchemaMap = new Hashtable();
     }
     this.doc     = xd;
     this.dataSet = ds;
     foreach (DataTable table in this.dataSet.Tables)
     {
         this.AddTableSchema(table);
         foreach (DataColumn column in table.Columns)
         {
             if (!IsNotMapped(column))
             {
                 this.AddColumnSchema(column);
             }
         }
     }
 }
Exemple #46
0
    [WebMethod]    //20101110 add by Elton for Auto EDC process
    public string GetEDCData(int iServiceType, string sPath, string sLotNo, int iReadings, bool bCompare, string sOffSetArith, double dOffSetValue, int iOffSetAfterPoint, string recipeCode)
    {
        try
        {
            System.Data.DataTable dt = PubUtil.GetEDCData(iServiceType, sPath, sLotNo, iReadings, bCompare, sOffSetArith, dOffSetValue, iOffSetAfterPoint, recipeCode);
            System.Data.DataSet   ds = new System.Data.DataSet();

            if (dt != null)
            {
                ds.Tables.Add(dt);
                ds.DataSetName = "AutoEDC";
                System.Xml.XmlDataDocument xdd = new System.Xml.XmlDataDocument(ds);
                return(xdd.InnerXml);
            }
            return(null);
        }
        catch (Exception)
        {
            return(null);
        }
    }
        private static string GetInitialTextFromNodes(ref XmlNode n)
        {
            string value = null;

            if (n != null)
            {
                // don't consider whitespace
                while (n.NodeType == XmlNodeType.Whitespace)
                {
                    n = n.NextSibling;
                    if (n == null)
                    {
                        return(string.Empty);
                    }
                }

                if (XmlDataDocument.IsTextLikeNode(n) && (n.NextSibling == null || !XmlDataDocument.IsTextLikeNode(n.NextSibling)))
                {
                    // don't use string builder if only one text node exists
                    value = n.Value;
                    n     = n.NextSibling;
                }
                else
                {
                    StringBuilder sb = new StringBuilder();
                    while (n != null && XmlDataDocument.IsTextLikeNode(n))
                    {
                        // Ignore non-significant whitespace nodes
                        if (n.NodeType != XmlNodeType.Whitespace)
                        {
                            sb.Append(n.Value);
                        }
                        n = n.NextSibling;
                    }
                    value = sb.ToString();
                }
            }

            return(value ?? string.Empty);
        }
        private static string GetInitialTextFromNodes(ref XmlNode n)
        {
            string str = null;

            if (n != null)
            {
                while (n.NodeType == XmlNodeType.Whitespace)
                {
                    n = n.NextSibling;
                    if (n == null)
                    {
                        return(string.Empty);
                    }
                }
                if (XmlDataDocument.IsTextLikeNode(n) && ((n.NextSibling == null) || !XmlDataDocument.IsTextLikeNode(n.NextSibling)))
                {
                    str = n.Value;
                    n   = n.NextSibling;
                }
                else
                {
                    StringBuilder builder = new StringBuilder();
                    while ((n != null) && XmlDataDocument.IsTextLikeNode(n))
                    {
                        if (n.NodeType != XmlNodeType.Whitespace)
                        {
                            builder.Append(n.Value);
                        }
                        n = n.NextSibling;
                    }
                    str = builder.ToString();
                }
            }
            if (str == null)
            {
                str = string.Empty;
            }
            return(str);
        }
        public override bool MoveTo(XPathNavigator other)
        {
            if (other == null)
            {
                return(false);
            }
            DataDocumentXPathNavigator otherDataDocXPathNav = other as DataDocumentXPathNavigator;

            if (otherDataDocXPathNav != null)
            {
                if (_curNode.MoveTo(otherDataDocXPathNav.CurNode))
                {
                    _doc = _curNode.Document;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
Exemple #50
0
        public override XmlNode CloneNode(bool deep)
        {
            XmlDataDocument doc = (XmlDataDocument)(OwnerDocument);
            ElementState    oldAutoFoliationState = doc.AutoFoliationState;

            doc.AutoFoliationState = ElementState.WeakFoliation;
            XmlElement element;

            try
            {
                Foliate(ElementState.WeakFoliation);
                element = (XmlElement)(base.CloneNode(deep));

                // Clone should create a XmlBoundElement node
                Debug.Assert(element is XmlBoundElement);
            }
            finally
            {
                doc.AutoFoliationState = oldAutoFoliationState;
            }

            return(element);
        }
        /// <summary>
        /// Removes the application configuration setting.
        /// </summary>
        /// <param name="setting">Setting to be removed.</param>
        public static void RemoveSetting(string setting)
        {
            bool removed = false;

            System.Reflection.Assembly asm = System.Reflection.Assembly.GetEntryAssembly();
            System.IO.FileInfo         fi  = new System.IO.FileInfo(asm.Location + ".config");
            System.Xml.XmlDataDocument doc = new System.Xml.XmlDataDocument();
            try
            {
                //Load the XML configuration file.
                doc.Load(fi.FullName);
                //Loop through the nodes to find the target node to be removed.
                foreach (System.Xml.XmlNode node in doc["configuration"]["appSettings"])
                {
                    if (node.Name == "add")
                    {
                        if (node.Attributes.GetNamedItem("key").Value == setting)
                        {
                            node.ParentNode.RemoveChild(node);
                            removed = true;
                        }
                    }
                }
                //If not removed then the setting probably didn't exist...throw an error.
                if (!removed)
                {
                    throw new Exception();
                }
                //Save the results...
                doc.Save(fi.FullName);
            }
            catch
            {
                //There was an error loading or reading the config file...throw an error.
                throw new Exception("Unable to remove the value.  Check that the configuration file exists and contains the appSettings element.");
            }
        }
Exemple #52
0
        internal void SetupMapping(XmlDataDocument xd, DataSet ds)
        {
            // If are already mapped, forget about our current mapping and re-do it again.
            if (IsMapped())
            {
                this.tableSchemaMap  = new Hashtable();
                this.columnSchemaMap = new Hashtable();
            }
            doc     = xd;
            dataSet = ds;
            foreach (DataTable t in dataSet.Tables)
            {
                AddTableSchema(t);

                foreach (DataColumn c in t.Columns)
                {
                    // don't include auto-generated PK & FK to be part of mapping
                    if (!IsNotMapped(c))
                    {
                        AddColumnSchema(c);
                    }
                }
            }
        }
Exemple #53
0
        /// <summary>
        /// 加载sql文件
        /// </summary>
        /// <returns>0 成功 -1 失败</returns>
        public int LoadSql()
        {
            #region 加载SQL
            switch (mode)
            {
            case 0:
                System.Xml.XmlDataDocument doc = new System.Xml.XmlDataDocument();
                try
                {
                    doc.Load(FileName);
                }
                catch (Exception ex)
                {
                    this.Err     = ex.Message;
                    this.ErrCode = "-1";
                    this.WriteErr();
                    return(-1);
                }
                XmlNodeList nodes;
                nodes = doc.SelectNodes(@"//SQL");
                try
                {
                    foreach (XmlNode node in nodes)
                    {
                        Neusoft.FrameWork.Models.NeuObject objValue = new Neusoft.FrameWork.Models.NeuObject();
                        objValue.ID   = node.Attributes[0].Value.ToString();
                        objValue.Name = node.InnerText.ToString();
                        objValue.Name = objValue.Name.Replace("\r", " ");
                        //objValue.Name=objValue.Name.Replace("\n"," ");
                        objValue.Name = objValue.Name.Replace("\t", " ");
                        try
                        {
                            objValue.Memo = node.Attributes[1].Value.ToString();
                        }
                        catch {}
                        this.alSql.Add(objValue);
                    }
                }
                catch (Exception ex)
                {
                    this.Err     = ex.Message;
                    this.ErrCode = "-1";
                    this.WriteErr();
                    return(-1);
                }
                break;

            default:
                for (int i = 0; i < table_name.Count; i++)
                {
                    Neusoft.FrameWork.Models.NeuObject obj = table_name[i] as Neusoft.FrameWork.Models.NeuObject;
                    if (obj.ID == "1")    //开始时候加载
                    {
                        //因为要增加对不同数据库的支持,不同数据库里的SQL语句存储的字段不同, 所以才这样
                        //{476364C9-195A-4ca8-A2D7-6782088016FA}
                        string mySQL = string.Empty;
                        if (Neusoft.FrameWork.Management.Connection.DBType == Connection.EnumDBType.ORACLE)
                        {
                            mySQL = string.Format("select id,name,memo from {0}", table_name[i].ToString());
                        }
                        else if (Neusoft.FrameWork.Management.Connection.DBType == Connection.EnumDBType.DB2)
                        {
                            mySQL = string.Format("select id,db2_sql,memo from {0}", table_name[i].ToString());
                        }

                        else    //以后再用
                        {
                            mySQL = string.Format("select id,name,memo from {0}", table_name[i].ToString());
                        }
                        //end ;
                        if (this.ExecQuery(mySQL) == -1)
                        {
                            return(-1);                                //表有问题
                        }
                        while (this.Reader.Read())
                        {
                            Neusoft.FrameWork.Models.NeuObject objValue = new Neusoft.FrameWork.Models.NeuObject();
                            objValue.ID   = this.Reader[0].ToString();
                            objValue.Name = this.Reader[1].ToString();
                            objValue.Name = objValue.Name.Replace("\r", " ");
                            //objValue.Name=objValue.Name.Replace("\n"," ");
                            objValue.Name = objValue.Name.Replace("\t", " ");
                            try
                            {
                                objValue.Memo = this.Reader[2].ToString();
                            }
                            catch { }
                            this.alSql.Add(objValue);
                        }
                        this.Reader.Close();
                    }
                }
                break;
            }
            #endregion
            return(0);
        }
Exemple #54
0
        protected void Application_AuthenticateRequest(Object sender, EventArgs e)
        {
            return;

            //			获取用户名
            string     cookieName = FormsAuthentication.FormsCookieName;
            HttpCookie authCookie = Context.Request.Cookies[cookieName];

            if (null == authCookie)
            {
                Response.Redirect("http://Main.mes.clpec/clpec_main/LogonNew.aspx");
                return;
            }
            FormsAuthenticationTicket authTicket = null;

            try
            {
                authTicket = FormsAuthentication.Decrypt(authCookie.Value);
            }
            catch (Exception ex)
            {
                Response.Redirect("http://Main.mes.clpec/clpec_main/LogonNew.aspx");
                return;
            }

            if (null == authTicket)
            {
                Response.Redirect("http://Main.mes.clpec/clpec_main/LogonNew.aspx");
                return;
            }

            if (authTicket.Expired)
            {
                Response.Redirect("http://Main.mes.clpec/clpec_main/LogonNew.aspx");
                return;
            }

            string userId;

            userId = authTicket.UserData.ToString();

            int index = userId.IndexOf("|");

            userId = userId.Substring(0, index);

            if (Context.Request.HttpMethod.ToUpper() != "POST")
            {
                string strURL        = Context.Request.Path.ToString();
                string strPermission = "";
                if (strURL.EndsWith("MainFrame.aspx") || strURL.EndsWith("Left1.aspx"))
                {
                    return;
                }
                //获取权限集合
                AuditService userAuth     = new AuditService();
                string       strCategory  = System.Configuration.ConfigurationSettings.AppSettings["PermissionCategory"];
                DataSet      dsPermission = new DataSet();
                dsPermission = userAuth.ListUserPMSByCate(userId, strCategory) as DataSet;

                //读取配置文件
                System.Xml.XmlDocument document = new System.Xml.XmlDataDocument();
                document.Load(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Menu.xml");

                XmlNodeList myList = document.GetElementsByTagName("MenuItem");
                foreach (XmlNode myNode in myList)
                {
                    string strHref = myNode.Attributes["href"].Value;
                    if (strHref.EndsWith(strURL))
                    {
                        strPermission = myNode.Attributes["permission"].Value;
                    }
                }
                //check permission
                DataTable myTable;
                myTable = dsPermission.Tables[0];
                // Presuming the DataTable has a column named Date.
                string strExpr;
                strExpr = "PMS_ID= " + "'" + strPermission + "'";
                DataRow[] foundRows;
                // Use the Select method to find all rows matching the filter.
                foundRows = myTable.Select(strExpr);
                // Print column 0 of each returned row.
                if (foundRows.Length < 1)
                {
                    Response.Redirect("http://main.mes.clpec/Clpec_Main/LogonNew.aspx");
                    return;
                }
            }

            string[]      Roles = authTicket.UserData.Split('|');
            FormsIdentity id    = new FormsIdentity(authTicket);
            // This principal will flow throughout the request.
            GenericPrincipal principal = new GenericPrincipal(id, Roles);

            // Attach the new principal object to the current HttpContext object
            Context.User = principal;
            //			// Extract the forms authentication cookie
            //			string cookieName = FormsAuthentication.FormsCookieName;
            //			HttpCookie authCookie = Context.Request.Cookies[cookieName];
            //
            //			if(null == authCookie)
            //			{
            //				// There is no authentication cookie.
            //				return;
            //			}
            //
            //			FormsAuthenticationTicket authTicket = null;
            //			try
            //			{
            //				authTicket = FormsAuthentication.Decrypt(authCookie.Value);
            //			}
            //			catch (Exception ex)
            //			{
            //				// Log exception details (omitted for simplicity)
            //				return;
            //			}
            //
            //			if (null == authTicket)
            //			{
            //				// Cookie failed to decrypt.
            //				return;
            //			}
            //
            //			if(authTicket.Expired)
            //			{
            //				return;
            //			}
            //
            //			// When the ticket was created, the UserData property was assigned a
            //			// pipe delimited string of role names.
            //
            //
            //
            //			//			DataSet ds =new DataSet();
            //			//			AuditService Audit= new AuditService();
            //			//			string strCategory=System.Configuration.ConfigurationSettings.AppSettings["PMSCategory"];
            //			//			ds=Audit.ListUserPMSByCate(authTicket.UserData.ToString(),strCategory);
            //
            //			//			StringCollection myCol = new StringCollection();
            //			//
            //			//			foreach(DataRow myRow in ds.Tables[0].Rows)
            //			//			{
            //			//				myCol.Add(myRow["PMS_ID"].ToString());
            //			//			}
            //			//			String[] Roles = new String[myCol.Count];
            //			//			myCol.CopyTo( Roles, 0 );
            //
            //
            //			string[] Roles = authTicket.UserData.Split('|');
            //
            //
            //			FormsIdentity id = new FormsIdentity( authTicket );
            //
            //			// This principal will flow throughout the request.
            //			GenericPrincipal principal = new GenericPrincipal(id, Roles);
            //			// Attach the new principal object to the current HttpContext object
            //			Context.User = principal;
        }
Exemple #55
0
 internal XmlDataElement(DataRow row, string prefix, string localName, string ns, XmlDataDocument doc)
     : base(prefix, localName, ns, doc)
 {
     this.row = row;
     // Embed row ID only when the element is mapped to
     // certain DataRow.
     if (row != null)
     {
         row.DataElement = this;
         row.XmlRowID    = doc.dataRowID;
         doc.dataRowIDList.Add(row.XmlRowID);
         doc.dataRowID++;
     }
 }
 internal DataDocumentXPathNavigator(XmlDataDocument doc, XmlNode node)
 {
     this._curNode = new XPathNodePointer(this, doc, node);
     this._temp    = new XPathNodePointer(this, doc, node);
     this._doc     = doc;
 }
 private DataDocumentXPathNavigator(DataDocumentXPathNavigator other)
 {
     this._curNode = other._curNode.Clone(this);
     this._temp    = other._temp.Clone(this);
     this._doc     = other._doc;
 }
        private void SettingsButton_Click(object sender, RibbonControlEventArgs e)
        {
            Excel2007Addin.Settings settings    = Excel2007Addin.Settings.Default;
            SettingsDialog          settingsdlg = new SettingsDialog();

            settingsdlg.AutoEscapeFilter = settings.AutoEscapeFilter;
            settingsdlg.UseProxy         = settings.UseProxy;
            settingsdlg.ProxyAddress     = settings.ProxyAddress;
            settingsdlg.ProxyPort        = settings.ProxyPort;
            settingsdlg.ProxyUsername    = settings.ProxyUsername;
            settingsdlg.ProxyPassword    = DataProtectionHelper.UnProtect(settings.ProxyPassword);
            settingsdlg.RequestTimeout   = settings.RequestTimeout;
            settingsdlg.CellFormatting   = (CellFormattingEnum)settings.CellFormatting;

            if (settingsdlg.ShowDialog().GetValueOrDefault(false))
            {
                // Update metrics xml?
                if (!string.IsNullOrEmpty(settingsdlg.MetricsFileName))
                {
                    System.Xml.XmlDocument doc = new System.Xml.XmlDataDocument();
                    try
                    {
                        doc.Load(XmlReader.Create(settingsdlg.MetricsFileName,
                                                  new XmlReaderSettings()
                        {
                            Schemas        = Analytics.Data.Validation.XmlValidator.LoadSchema("metrics.xsd"),
                            ValidationType = ValidationType.Schema
                        }));
                        settings.Metrics = doc;
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error parsing metrics xml. No metrics updated.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                // Update dimensions xml?
                if (!string.IsNullOrEmpty(settingsdlg.DimensionsFileName))
                {
                    System.Xml.XmlDocument doc = new System.Xml.XmlDataDocument();
                    try
                    {
                        doc.Load(XmlReader.Create(settingsdlg.DimensionsFileName,
                                                  new XmlReaderSettings()
                        {
                            Schemas        = Analytics.Data.Validation.XmlValidator.LoadSchema("dimensions.xsd"),
                            ValidationType = ValidationType.Schema
                        }));
                        settings.Dimensions = doc;
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error parsing dimension xml. No dimensions updated.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                settings.AutoEscapeFilter = settingsdlg.AutoEscapeFilter;
                settings.UseProxy         = settingsdlg.UseProxy;
                settings.ProxyAddress     = settingsdlg.ProxyAddress;
                settings.ProxyUsername    = settingsdlg.ProxyUsername;
                settings.ProxyPassword    = DataProtectionHelper.Protect(settingsdlg.ProxyPassword);
                settings.ProxyPort        = settingsdlg.ProxyPort;
                settings.RequestTimeout   = settingsdlg.RequestTimeout;
                settings.CellFormatting   = (int)settingsdlg.CellFormatting;
                settings.Save();

                Analytics.Settings.Instance.AutoEscapeFilter = settingsdlg.AutoEscapeFilter;
                Analytics.Settings.Instance.UseProxy         = settings.UseProxy;
                Analytics.Settings.Instance.ProxyAddress     = settings.ProxyAddress;
                Analytics.Settings.Instance.ProxyPassword    = settings.ProxyPassword;
                Analytics.Settings.Instance.ProxyPort        = settings.ProxyPort;
                Analytics.Settings.Instance.ProxyUsername    = settings.ProxyUsername;

                Analytics.Settings.Instance.RequestTimeout = settings.RequestTimeout;
                Analytics.Settings.Instance.MetricsXml     = settings.Metrics;
                Analytics.Settings.Instance.DimensionsXml  = settings.Dimensions;
            }
        }
Exemple #59
0
        private void AutoFoliate()
        {
            XmlDataDocument doc = (XmlDataDocument)OwnerDocument;

            doc?.Foliate(this, doc.AutoFoliationState);
        }
Exemple #60
0
        internal void Foliate(ElementState newState)
        {
            XmlDataDocument doc = (XmlDataDocument)OwnerDocument;

            doc?.Foliate(this, newState);
        }