Close() public method

public Close ( ) : void
return void
 //�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ�
 public bool isSuper(FileInfo obFile, FileInfo obExtends)
 {
     string infoPath = m_obFinder.getClassPath(obExtends.Name.Replace(".as", ""));
     if (File.Exists(infoPath))
     {
         XmlDocument xml = new XmlDocument();
         xml.Load(infoPath);
         XmlNodeReader reader = new XmlNodeReader(xml);
         while (reader.Read())
         {
             if (reader.NodeType == XmlNodeType.Element)
             {
                 if (reader.Name == "item")
                 {
                     string className = reader.GetAttribute("name");
                     string superSign = reader.GetAttribute("super");
                     if (className == obFile.Name.Replace(".as", ""))
                     {
                         if (superSign != null)
                         {
                             reader.Close();
                             //ErrorBox.Show(obExtends.Name + " extends " + obFile.Name,"ClassRelationsFinderError");
                             return true;
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
示例#2
0
 public WMIBMySQL()
 {
     string file = Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + "unwrittensql.xml";
     Core.RecoverFile(file);
     if (File.Exists(file))
     {
         Syslog.WarningLog("There is a mysql dump file from previous run containing mysql rows that were never successfuly inserted, trying to recover them");
         XmlDocument document = new XmlDocument();
         TextReader sr = new StreamReader(file);
         document.Load(sr);
         XmlNodeReader reader = new XmlNodeReader(document.DocumentElement);
         XmlSerializer xs = new XmlSerializer(typeof(Unwritten));
         Unwritten un = (Unwritten)xs.Deserialize(reader);
         reader.Close();
         sr.Close();
         lock (unwritten.PendingRows)
         {
             unwritten.PendingRows.AddRange(un.PendingRows);
         }
     }
     reco = new Thread(Exec);
     reco.Name = "Recovery";
     Core.ThreadManager.RegisterThread(reco);
     reco.Start();
 }
 /// <summary>
 /// Deserializes this xml document and convert it to a ChmProject object.
 /// </summary>
 /// <returns>The ChmProject object readed from the xml.</returns>
 public ChmProject Deserialize()
 {
     XmlReader reader = new XmlNodeReader(this);
     XmlSerializer serializer = new XmlSerializer(typeof(ChmProject));
     ChmProject cfg = (ChmProject)serializer.Deserialize(reader);
     reader.Close();
     return cfg;
 }
示例#4
0
        /// <summary>
        /// Converts an XML file to CSV
        /// </summary>
        /// <param name="xmlDoc">An XML file</param>
        /// <returns></returns>
        public static String XMLToCSV(System.Xml.XmlDocument xmlDoc)
        {
            DataSet dataSet = new DataSet();
            using( XmlNodeReader xmlReader = new XmlNodeReader(xmlDoc) )
            {
                dataSet.ReadXml(xmlReader);
                xmlReader.Close();
            }

            return dtToCSV(dataSet.Tables[0]);
        }
        public object Create(object parent, object configContext, XmlNode section)
        {
            XmlSerializer ser = new XmlSerializer(typeof(MinecraftConfig));
            MinecraftConfig config = null;

            using (XmlNodeReader reader = new XmlNodeReader(section))
            {
                config = ser.Deserialize(reader) as MinecraftConfig;
                reader.Close();
            }

            return config;
        }
示例#6
0
        /// <summary>
        /// 获取XML
        /// </summary>
        /// <param name="xmlFile"></param>
        /// <returns></returns>
        // xmlFile = HttpContext.Server.MapPath("~/Student.xml")
        public string GetXml(string xmlFile)
        {
            string id = "";
            string Info = "";

            if (XmlDoc == null)
            {
                lock (DocLock)
                {
                    if (XmlDoc == null)
                    {
                        XmlDoc = new XmlDocument();
                        XmlDoc.Load(xmlFile);
                    }
                }
            }

            string Name = string.Empty;
            string _id = string.Empty;
            XmlElement root = XmlDoc.DocumentElement;
            XmlNodeList personNodes = root.GetElementsByTagName("person");
            foreach (XmlNode node in personNodes)
            {
                if (((XmlElement)node).GetAttribute("id") == "2" || ((XmlElement)node).GetAttribute("id") == "4")
                {
                    Name += ((XmlElement)node).InnerText;
                    _id += ((XmlElement)node).GetAttribute("id");
                    var str = node.GetEnumerator();
                }
            }

            XmlNodeReader ParaReader = new XmlNodeReader(XmlDoc);
            while (ParaReader.Read())
            {
                if (ParaReader.NodeType == XmlNodeType.Element && ParaReader.Name == "person")
                {
                    if (!string.IsNullOrEmpty(ParaReader.GetAttribute("id")))
                    {
                        id += ParaReader.GetAttribute("id") + "+";
                        Info += ParaReader.ReadInnerXml() + "+";

                    }
                    //if (f == "PaymentDate" && f == ParaReader.GetAttribute(0)) Info = ParaReader.GetAttribute(1);//Info = ParaReader.GetAttribute(1).Replace("{2}", Member.ValidBeginDate + "");//缴费
                    //if (f == "ReplacementDate" && f == ParaReader.GetAttribute(0)) Info = ParaReader.GetAttribute("value");//Info = ParaReader.GetAttribute("value").Replace("{2}", Member.ValidBeginDate + "").Replace("{3}", Member.ReplacementDate + "");  //换证 
                    //if (f == "ContributionsDate" && f == ParaReader.GetAttribute(0)) Info = ParaReader.GetAttribute("value"); //体检 
                }
                string str = ParaReader.GetAttribute("id") + ParaReader.GetAttribute("sex") + ParaReader.ReadInnerXml();
            }
            ParaReader.Close();
            return System.Text.Encoding.GetEncoding("gb2312").GetString(System.Text.Encoding.Default.GetBytes(id + "\n" + Info));
        }
示例#7
0
		///<summary></summary>
		private string GetOpenDentalConnStr() {
			XmlDocument document=new XmlDocument();
			string path=ODFileUtils.CombinePaths(Application.StartupPath,"FreeDentalConfig.xml");
			if(!File.Exists(path)) {
				return "";
			}
			string computerName="";
			string database="";
			string user="";
			string password="";
			try {
				document.Load(path);
				XmlNodeReader reader=new XmlNodeReader(document);
				string currentElement="";
				while(reader.Read()) {
					if(reader.NodeType==XmlNodeType.Element) {
						currentElement=reader.Name;
					}
					else if(reader.NodeType==XmlNodeType.Text) {
						switch(currentElement) {
							case "ComputerName":
								computerName=reader.Value;
								break;
							case "Database":
								database=reader.Value;
								break;
							case "User":
								user=reader.Value;
								break;
							case "Password":
								password=reader.Value;
								break;
						}
					}
				}
				reader.Close();
			}
			catch {
				return "";
			}
			//example:
			//Server=localhost;Database=opendental;User ID=root;Password=;CharSet=utf8
			return "Server="+computerName
				+";Database="+database
				+";User ID="+user
				+";Password="******";CharSet=utf8";
		}
		private void FormDatabaseCheck_Load(object sender,EventArgs e) {
			XmlDocument document=new XmlDocument();
			if(!File.Exists("FreeDentalConfig.xml")) {
				textComputerName.Text="localhost";
				#if(TRIALONLY)
					textDatabase.Text="demo";
				#else
					textDatabase.Text="opendental";
				#endif
				textUser.Text="root";
				return;
			}
			try {
				document.Load("FreeDentalConfig.xml");
				XmlNodeReader reader=new XmlNodeReader(document);
				string currentElement="";
				while(reader.Read()) {
					if(reader.NodeType==XmlNodeType.Element) {
						currentElement=reader.Name;
					}
					else if(reader.NodeType==XmlNodeType.Text) {
						switch(currentElement) {
							case "ComputerName":
								textComputerName.Text=reader.Value;
								break;
							case "Database":
								textDatabase.Text=reader.Value;
								break;
							case "User":
								textUser.Text=reader.Value;
								break;
							case "Password":
								textPassword.Text=reader.Value;
								break;
						}
					}
				}
				reader.Close();
			}
			catch {//Exception e) {
				//MessageBox.Show(e.Message);
				textComputerName.Text="localhost";
				textDatabase.Text="opendental";
				textUser.Text="root";
			}
		}
        /// <summary>
        /// Validates <paramref name="xmlString"/> using the XSD schema stored at <paramref name="xsdPath"/>.
        /// </summary>
        /// <param name="xmlString">The Xml string to validate.</param>
        /// <param name="xsdPath">The path of the XSD schema file.</param>
        /// <returns>True when <paramref name="xmlString"/> is valid according to xsd schema at <paramref name="xsdPath"/> or false otherwise.</returns>
        /// <exception cref="System.NullReferenceException">Thrown when <paramref name="xmlString"/> or <paramref name="xsdPath"/> is null.</exception>
        public bool Validate(string xmlString, string xsdPath)
        {
            if (string.IsNullOrEmpty(xmlString))
                throw new System.ArgumentNullException("Xml string is null or empty.");
            if (string.IsNullOrEmpty(xsdPath))
                throw new System.ArgumentNullException("Xsd path is null or empty.");

            xsdPath = System.AppDomain.CurrentDomain.BaseDirectory + xsdPath;
            System.Xml.XmlDocument document = new XmlDocument();
            document.LoadXml(xmlString);
            System.Xml.XmlDocument schema = new XmlDocument();

            schema.Load(xsdPath);
            using (System.Xml.XmlNodeReader nrDocument = new System.Xml.XmlNodeReader(document))
            {
                using (System.Xml.XmlNodeReader nrSchema = new System.Xml.XmlNodeReader(schema))
                {
                    System.Xml.XmlReaderSettings rsDocument = new System.Xml.XmlReaderSettings();
                    rsDocument.Schemas.Add(null, nrSchema);
                    rsDocument.ValidationType = System.Xml.ValidationType.Schema;
                    rsDocument.ValidationEventHandler +=
                     new System.Xml.Schema.ValidationEventHandler(ValidationEventHandler);

                    using (System.Xml.XmlReader rDocument = System.Xml.XmlReader.Create(nrDocument, rsDocument))
                    {
                        try
                        {
                            while (rDocument.Read()) ;
                        }
                        catch (System.Xml.Schema.XmlSchemaException eCurrent)
                        {
                            throw new System.Exception("Xml inputed is invalid. " + eCurrent.Message);
                        }

                        rDocument.Close();
                    }

                    nrSchema.Close();
                }

                nrDocument.Close();
            }

            return true;
        }
示例#10
0
		///<summary></summary>
		private string GetConnectionString(){
			XmlDocument document=new XmlDocument();
			string configFile=ODFileUtils.CombinePaths(new string[] {"..","..","..","OpenDental","bin","Release","FreeDentalConfig.xml"} );
			if(!File.Exists(configFile)){
				MessageBox.Show(configFile+" does not exist.");
				Application.Exit();
				return "";
			}
			document.Load(configFile);
			XmlNodeReader reader=new XmlNodeReader(document);
			string currentElement="";
			string ComputerName="";
			string Database="";
			string DbUser="";
			string Password="";
			while(reader.Read()) {
				if(reader.NodeType==XmlNodeType.Element) {
					currentElement=reader.Name;
				}
				else if(reader.NodeType==XmlNodeType.Text) {
					switch(currentElement) {
						case "ComputerName":
							ComputerName=reader.Value;
							break;
						case "Database":
							Database=reader.Value;
							break;
						case "User":
							DbUser=reader.Value;
							break;
						case "Password":
							Password=reader.Value;
							break;
					}
				}
			}
			reader.Close();
			return "Server="+ComputerName
				+";Database="+Database
				+";User ID="+DbUser
				+";Password="******";CharSet=utf8";
		}
示例#11
0
        public static string ConvertToXmlString(XmlDocument XmlDocument, XslCompiledTransform XslTransformer)
        {
            string strConvertedXml = string.Empty;

            StringWriter objStringWriter = new StringWriter();
            XmlNodeReader objXmlReader = new XmlNodeReader(XmlDocument);

            try
            {
                XslTransformer.Transform(objXmlReader, null, objStringWriter);
                strConvertedXml = objStringWriter.ToString();
            }
            finally
            {
                objXmlReader.Close();
                objStringWriter.Close();
            }

            return strConvertedXml;
        }
示例#12
0
        internal XssFilterInfo(string schemaLocation)
        {
            XmlDocument schemaDoc = GetSchemaDoc(schemaLocation);
            XmlReader schemaReader = new XmlNodeReader(schemaDoc);
            try
            {
                Schema = XmlSchema.Read(schemaReader, null);
            }
            finally
            {
                schemaReader.Close();
            }

            Schema.Compile(null);
            if (Type.GetType("Mono.Runtime", false) != null)
            {
                UriAndStyleValidator = new AttributeValueValidator();
                UriAndStyleValidator.Add(schemaDoc, Schema, "URI", Schema.TargetNamespace);
                UriAndStyleValidator.Add(schemaDoc, Schema, "InlineStyle", Schema.TargetNamespace);
                // NOTE: We don't bother with attributes of type "URIs" (plural) because only <object> has such an
                // attribute and we don't allow that element.
            }
        }
示例#13
0
        public string PrintToString(XmlNode myXmlNode)
        {
            // write the step node to a stream so that we can get the nice indented formatting for free
            XmlNodeReader xnr = new XmlNodeReader(myXmlNode);
            MemoryStream myStream = new MemoryStream();
            XmlTextWriter xtw = new XmlTextWriter(myStream, System.Text.Encoding.UTF8);
            xtw.Formatting = Formatting.Indented;
            xtw.WriteNode(xnr, true);
            xtw.Flush();
            myStream.Position = 0;
            StreamReader sr = new StreamReader(myStream, System.Text.Encoding.UTF8);

            // copy the new xml to the other box
            string myTabbedXmlString = sr.ReadToEnd();

            // clean up
            sr.Close();
            xtw = null;
            myStream.Close();
            xnr.Close();

            return myTabbedXmlString;
        }
示例#14
0
        private Boolean validate(IController controller, XmlDocument document)
        {
            XmlNodeReader nodeReader = new XmlNodeReader(document);

            Boolean isValid = false;
            XmlReader schemaDatabase = controller.GetXSD("database.xsd");

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ValidationType = ValidationType.Schema;
            settings.Schemas.Add(null, schemaDatabase);
            //settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema;
            //settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;
            settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
            settings.ValidationEventHandler += new ValidationEventHandler(validationEventHandler);

            XmlReader reader = XmlReader.Create(nodeReader, settings);

            try
            {
                while (reader.Read()) ;
                isValid = true;
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message, "Validation Error");
            }
            finally
            {
                schemaDatabase.Close();
                nodeReader.Close();
                reader.Close();
            }
            return isValid;
        }
示例#15
0
        /// <summary>
        /// Writes the body of an ExtensionObject to the stream.
        /// </summary>
        public void WriteExtensionObjectBody(object body)
        {            
            // nothing to do for null bodies.
            if (body == null)
            {
                return;
            }

            // encode byte body.
            byte[] bytes = body as byte[];

            if (bytes != null)
            {
                m_writer.WriteStartElement("ByteString", Namespaces.OpcUaXsd);
                m_writer.WriteString(Convert.ToBase64String(bytes));                                        
                m_writer.WriteEndElement();
                return;
            }
            
            // encode xml body.
            XmlElement xml = body as XmlElement;

            if (xml != null)
            {
                #if !SILVERLIGHT
                XmlNodeReader reader = new XmlNodeReader(xml);
                m_writer.WriteNode(reader, false);
                reader.Close();
                #endif
                return;
            }

            IEncodeable encodeable = body as IEncodeable;

            if (encodeable == null)
            {
                throw new ServiceResultException(
                    StatusCodes.BadEncodingError,
                    Utils.Format("Don't know how to encode extension object body with type '{0}'.", body.GetType().FullName));
            }
            
            // encode extension object in xml.
            XmlQualifiedName xmlName = EncodeableFactory.GetXmlName(encodeable.GetType());
            m_writer.WriteStartElement(xmlName.Name, xmlName.Namespace);
            encodeable.Encode(this);
            m_writer.WriteEndElement();
        }
        /// <summary> Reads metadata from an existing metadata file and saves to the provided item/package </summary>
        /// <param name="MetadataFilePathName"> Path and name of the metadata file to read </param>
        /// <param name="Return_Package"> Package into which to read the metadata </param>
        /// <param name="Options"> Dictionary of any options which this metadata reader/writer may utilize </param>
        /// <param name="Error_Message">[OUTPUT] Explanation of the error, if an error occurs during reading </param>
        /// <returns>TRUE if successful, otherwise FALSE </returns>
        public bool Read_Metadata(string MetadataFilePathName, SobekCM_Item Return_Package, Dictionary<string, object> Options, out string Error_Message)
        {
            // Set default error outpt message
            Error_Message = String.Empty;

            // Old MXF files will not have a VID, so assign 00001
            if (Return_Package.VID.Length == 0)
            {
                Return_Package.VID = "00001";
            }

            // Load this MXF File
            XmlDocument mxfXML = new XmlDocument();
            mxfXML.Load(MetadataFilePathName);

            // Set the source directory correctly
            Return_Package.Source_Directory = (new FileInfo(MetadataFilePathName)).DirectoryName;

            // create the node reader
            XmlNodeReader nodeReader = new XmlNodeReader(mxfXML);

            // Read through all the nodes until the package tag is found
            move_to_node(nodeReader, "package");

            // Get the package attribute
            process_package_tag(nodeReader, Return_Package);

            // Read through all the nodes until the packageDesc section is found
            move_to_node(nodeReader, "packageDesc");

            // Process all of the packageDesc sections
            process_packageDesc(nodeReader, Return_Package);

            // Read through to the beginning of the entity description
            move_to_node(nodeReader, "entityDesc");

            // Process the entire entity tag and the projects tag
            process_entity_tag_and_project(nodeReader, Return_Package);

            // Set the object id and some other METS values not in the MXF
            Return_Package.METS_Header.ObjectID = Return_Package.BibID + "_" + Return_Package.VID;

            // Move to the bibDesc
            move_to_node(nodeReader, "bibDesc");

            // Process the bib desc section
            process_bib_desc(nodeReader, Return_Package);

            // Will just use a text reader to step through all of the division information
            process_divisions(MetadataFilePathName, Return_Package);

            nodeReader.Close();

            return true;
        }
示例#17
0
 public static void get_XmlValue_dt(string xml_string, ref DataTable dt, string table_name)
 {
     DataSet dataSet = new DataSet();
     XmlDocument xmlDocument = new XmlDocument();
     xmlDocument.LoadXml(xml_string);
     XmlNodeReader xmlNodeReader = new XmlNodeReader(xmlDocument);
     dataSet.ReadXml(xmlNodeReader);
     xmlNodeReader.Close();
     dt = dataSet.Tables[table_name];
 }
示例#18
0
 /// <summary>
 /// 获取一个字符串xml文档中的ds
 /// </summary>
 /// <param name="xml_string">含有xml信息的字符串</param>
 public static void get_XmlValue_ds(string xml_string, ref DataSet ds)
 {
     System.Xml.XmlDocument xd = new XmlDocument();
     xd.LoadXml(xml_string);
     XmlNodeReader xnr = new XmlNodeReader(xd);
     ds.ReadXml(xnr);
     xnr.Close();
     int a = ds.Tables.Count;
 }
示例#19
0
 public static void get_XmlValue_ds(string xml_string, ref DataSet ds)
 {
     XmlDocument xmlDocument = new XmlDocument();
     xmlDocument.LoadXml(xml_string);
     XmlNodeReader xmlNodeReader = new XmlNodeReader(xmlDocument);
     ds.ReadXml(xmlNodeReader);
     xmlNodeReader.Close();
     int count = ds.Tables.Count;
 }
示例#20
0
 public static void mergeChildNodes(XmlDocument nolisExtDoc, XmlNode extNode, XmlNode rootNode, String uniqueIdAttribute)
 {
     IList itemList = new ArrayList();
     foreach (XmlNode itemNode in rootNode.ChildNodes)
     {
         if (itemNode.NodeType == XmlNodeType.Element)
         {
             XmlNodeReader reader = new XmlNodeReader(itemNode);
             reader.Read();
             String idAttributeValue = reader.GetAttribute(uniqueIdAttribute);
             //Console.WriteLine("idAttributeValue = " + idAttributeValue);
             reader.Close();
             Boolean isIdExist = false;
             foreach (XmlNode extItemNode in extNode.ChildNodes)
             {
                 if (extItemNode.NodeType == XmlNodeType.Element)
                 {
                     XmlNodeReader localReader = new XmlNodeReader(extItemNode);
                     localReader.Read();
                     String extIdAttributeValue = localReader.GetAttribute(uniqueIdAttribute);
                     Console.WriteLine("extIdAttributeValue = " + extIdAttributeValue);
                     localReader.Close();
                     if (extIdAttributeValue.Equals(idAttributeValue))
                     {
                         isIdExist = true;
                         break;
                     }
                 }
             }
             if (isIdExist)
             {
                 continue;
             }
             else
             {
                 itemList.Add(itemNode);
             }
         }
     }
     Console.WriteLine("size of itemList  = " + itemList.Count);
     foreach (Object objXmlNode in itemList)
     {
         XmlNode newNode = nolisExtDoc.ImportNode((XmlNode)objXmlNode, true);
         extNode.AppendChild(newNode);
     }
 }
示例#21
0
 /// <summary>
 /// Writes an XmlElement to the stream.
 /// </summary>
 public void WriteXmlElement(string fieldName, XmlElement value)
 {            
     if (BeginField(fieldName, value == null, true))
     {
         #if !SILVERLIGHT
         XmlNodeReader reader = new XmlNodeReader(value);
         m_writer.WriteNode(reader, false);
         reader.Close();
         #else
         // TBD
         #endif
         EndField(fieldName);
     }
 }
        /// <summary>
        /// Validates a Kerberos WSS user token.
        /// </summary>
        private SecurityToken ParseAndVerifyKerberosToken(byte[] tokenData)
        {
            XmlDocument document = new XmlDocument();
            XmlNodeReader reader = null;

            try
            {
                document.InnerXml = new UTF8Encoding().GetString(tokenData).Trim();
                reader = new XmlNodeReader(document.DocumentElement);

                SecurityToken securityToken = new WSSecurityTokenSerializer().ReadToken(reader, null);
                System.IdentityModel.Tokens.KerberosReceiverSecurityToken receiver = securityToken as KerberosReceiverSecurityToken;

                KerberosSecurityTokenAuthenticator authenticator = new KerberosSecurityTokenAuthenticator();

                if (authenticator.CanValidateToken(receiver))
                {
                    authenticator.ValidateToken(receiver);
                }

                return securityToken;
            }
            catch (Exception e)
            {
                // construct translation object with default text.
                TranslationInfo info = new TranslationInfo(
                    "InvalidKerberosToken",
                    "en-US",
                    "'{0}' is not a valid Kerberos token.",
                    document.DocumentElement.LocalName);

                // create an exception with a vendor defined sub-code.
                throw new ServiceResultException(new ServiceResult(
                    e,
                    StatusCodes.BadIdentityTokenRejected,
                    "InvalidKerberosToken",
                    Namespaces.UserAuthentication,
                    new LocalizedText(info)));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
示例#23
0
文件: DataSource.cs 项目: mnisl/OD
		///<summary></summary>
		private static string GetOpenDentalConnStr(){
			XmlDocument document=new XmlDocument();
			string path=Application.StartupPath+"\\"+"FreeDentalConfig.xml";
			//MessageBox.Show(path);
			if(!File.Exists(path)){
				return "";
			}
			string computerName="";
			string database="";
			string user="";
			string password="";
			try{
				document.Load(path);
				XmlNodeReader reader=new XmlNodeReader(document);
				string currentElement="";
				while(reader.Read()){
					if(reader.NodeType==XmlNodeType.Element){
						currentElement=reader.Name;
					}
					else if(reader.NodeType==XmlNodeType.Text){
						switch(currentElement){
							case "ComputerName":
								computerName=reader.Value;
								break;
							case "Database":
								database=reader.Value;
								break;
							case "User":
								user=reader.Value;
								break;
							case "Password":
								password=reader.Value;
								break;
						}
					}
				}
				reader.Close();
			}
			catch{
				return "";
			}
			return "Server="+computerName
				+";Database="+database
				+";User ID="+user
				+";Password="******";CharSet=utf8";
		}
示例#24
0
 //�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡνڵ��ȡ����
 private static ArrayList getList(XmlNode subX)
 {
     ArrayList arr = new ArrayList();
     XmlNodeReader reader = new XmlNodeReader(subX);
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             ArrayList subArr = null;
             if (reader.Name == "item")
             {
                 subArr = new ArrayList();
                 string stName = reader.GetAttribute("name");
                 subArr.Add(stName);
                 arr.Add(subArr);
             }
             if (reader.Name == "str")
             {
                 subArr = arr[arr.Count - 1] as ArrayList;
                 string stName = reader.GetAttribute("name");
                 subArr.Add(stName);
             }
             if (reader.Name == "chat")
             {
                 subArr = arr[arr.Count - 1] as ArrayList;
                 string stName = reader.GetAttribute("name");
                 string stPrefix = reader.GetAttribute("prefix");
                 ArrayList arrLink = new ArrayList();
                 arrLink.Add(stPrefix);
                 arrLink.Add(stName);
                 subArr.Add(arrLink);
             }
         }
     }
     reader.Close();
     return arr;
 }
示例#25
0
 private static NetworkInfo DeserializeNetwork(string file)
 {
     XmlDocument document = new XmlDocument();
     TextReader sr = new StreamReader(file);
     document.Load(sr);
     XmlNodeReader reader = new XmlNodeReader(document.DocumentElement);
     XmlSerializer xs = new XmlSerializer(typeof(NetworkInfo));
     NetworkInfo info = (NetworkInfo)xs.Deserialize(reader);
     reader.Close();
     sr.Close();
     return info;
 }
        /// <summary>
        ///  Loads the configuration from the application configuration file.
        /// </summary>
        public static ServerTestConfiguration Load(XmlElementCollection extensions)
        {
            if (extensions == null || extensions.Count == 0)
            {
                return new ServerTestConfiguration();
            }

            foreach (XmlElement element in extensions)
            {
                if (element.NamespaceURI != "http://opcfoundation.org/UA/SDK/ServerTest/Configuration.xsd")
                {
                    continue;
                }

			    XmlNodeReader reader = new XmlNodeReader(element);

                try
                {
                    DataContractSerializer serializer = new DataContractSerializer(typeof(ServerTestConfiguration));
                    ServerTestConfiguration configuration = serializer.ReadObject(reader) as ServerTestConfiguration;
                    
                    if (configuration.Iterations <= 0)
                    {
                        configuration.Iterations = 1;
                    }

                    return configuration;
                }
                finally
                {
                    reader.Close();
                }
            }
                        
            return new ServerTestConfiguration();
        }
示例#27
0
        /// <summary>
        /// Loads the image editors into the application from the editors.xml file.
        /// </summary>
        public static void Load()
        {
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + XML_FILE))
            {
                XmlDocument xdoc = new XmlDocument();
                xdoc.Load(AppDomain.CurrentDomain.BaseDirectory + XML_FILE);

                XmlNodeList xeditors = xdoc.SelectNodes(EDITOR_XPATH);

                foreach (XmlNode xeditor in xeditors)
                {
                    Editor editor = new Editor();
                    XmlNodeReader xreader = new XmlNodeReader(xeditor);

                    while (xreader.Read())
                    {
                        if (xreader.IsStartElement())
                        {
                            switch (xreader.Name)
                            {
                                case EDITOR_NAME:
                                    xreader.Read();
                                    editor.Name = xreader.Value;
                                    break;

                                case EDITOR_APPLICATION:
                                    xreader.Read();
                                    editor.Application = xreader.Value;
                                    break;

                                case EDITOR_ARGUMENTS:
                                    xreader.Read();
                                    editor.Arguments = xreader.Value;
                                    break;
                            }
                        }
                    }

                    xreader.Close();

                    if (!string.IsNullOrEmpty(editor.Name) &&
                        !string.IsNullOrEmpty(editor.Application) &&
                        !string.IsNullOrEmpty(editor.Arguments))
                    {
                        EditorCollection.Add(editor);
                    }
                }
            }
        }
        /// <summary>
        /// Reads an object from the body of an XML element.
        /// </summary>
        private static object GetObject(Type type, XmlNode element)
        {
            XmlNodeReader reader = new XmlNodeReader(element);

            try
            {
                DataContractSerializer serializer = new DataContractSerializer(type);
                return serializer.ReadObject(reader, false);
            }
            finally
            {
                reader.Close();
            }
        }
示例#29
0
        //Add:1.0.1.0
        public EventInfo[] LoadXML(string path)
        {
            System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
            SavePath = path;
            xd.Load(SavePath);
            System.Xml.XmlNodeReader xnr = new System.Xml.XmlNodeReader(xd);
            string           Time        = "";
            string           element     = "";
            bool             IsEvent     = false;
            EventInfo        temp        = new EventInfo();
            string           start       = "";
            string           week        = "";
            List <EventInfo> output      = new List <EventInfo>();

            while (xnr.Read())
            {
                switch (xnr.NodeType)
                {
                case (XmlNodeType.Element):
                    element = xnr.Name;
                    switch (element)
                    {
                    case ("Timetable"):
                        start = xnr.GetAttribute("start");
                        string[] split = System.Text.RegularExpressions.Regex.Split(start, ",");
                        dateSelecter1.Year  = Convert.ToInt32(split[0]);
                        dateSelecter1.Month = Convert.ToInt32(split[1]);
                        dateSelecter1.Day   = Convert.ToInt32(split[2]);
                        break;

                    case ("Event"):
                        IsEvent = true;
                        week    = "";
                        start   = "";
                        temp    = new EventInfo();
                        break;

                    case ("Time"):
                        Time = xnr.GetAttribute("time");
                        break;

                    case ("Repeat"):
                        week = xnr.GetAttribute("week");

                        break;
                    }
                    break;

                case (XmlNodeType.Text):
                    if (IsEvent)
                    {
                        if (element == "Name")
                        {
                            temp.starttime = new Time(Time);
                            temp.EventName = xnr.Value;
                        }
                        else if (element == "Repeat")
                        {
                            string[] Split = System.Text.RegularExpressions.Regex.Split(xnr.Value, ":");
                            int[]    w_    = Array.ConvertAll(Split, item => Convert.ToInt32(item));
                            if (week == "" || week == null)
                            {
                                temp.Repeat_OneWeek  = w_;
                                temp.Repeat_Biweekly = temp.Repeat_OneWeek;
                            }
                            if (week == "1")
                            {
                                temp.Repeat_OneWeek = w_;
                            }
                            if (week == "2")
                            {
                                temp.Repeat_Biweekly = w_;
                            }
                        }
                    }
                    break;

                case (XmlNodeType.EndElement):
                    switch (xnr.Name)
                    {
                    case ("Event"):
                        IsEvent = false;
                        output.Add(temp);
                        temp = new EventInfo();
                        break;
                    }
                    break;
                }
            }
            xnr.Close();
            return(output.ToArray());
        }
 /// <summary>
 /// This removes namespaces from an XML Element (Scott)
 /// </summary>
 /// <param name="xeElement"></param>
 /// <returns></returns>
 protected string RemoveNamespaces(XmlNode xeElement)
 {
     StringWriter swOutput = new System.IO.StringWriter();
     XmlTextWriter xtwWriter = new XmlTextWriter(swOutput);
     //xtwWriter.WriteStartDocument();
     XmlNodeReader xnrReader = new XmlNodeReader(xeElement);
     while (xnrReader.Read())
     {
         switch (xnrReader.NodeType)
         {
             case XmlNodeType.Element:
                 xtwWriter.WriteStartElement(xnrReader.Name);
                 if (xnrReader.HasAttributes)
                 {
                     while (xnrReader.MoveToNextAttribute())
                     {
                         if (xnrReader.Name != "xmlns")
                         {
                             xtwWriter.WriteAttributeString(xnrReader.Name, xnrReader.Value);
                         }
                     }
                     xnrReader.MoveToElement();
                 }
                 if (xnrReader.IsEmptyElement)
                 {
                     xtwWriter.WriteEndElement();
                 }
                 break;
             case XmlNodeType.Text:
                 xtwWriter.WriteString(xnrReader.Value);
                 break;
             case XmlNodeType.CDATA:
                 xtwWriter.WriteCData(xnrReader.Value);
                 break;
             case XmlNodeType.ProcessingInstruction:
                 xtwWriter.WriteProcessingInstruction(xnrReader.Name, xnrReader.Value);
                 break;
             case XmlNodeType.Comment:
                 xtwWriter.WriteComment(xnrReader.Value);
                 break;
             case XmlNodeType.EntityReference:
                 xtwWriter.WriteEntityRef(xnrReader.Name);
                 break;
             case XmlNodeType.EndElement:
                 xtwWriter.WriteEndElement();
                 break;
         }
     }
     //xtwWriter.WriteEndDocument();
     xtwWriter.Flush();
     xtwWriter.Close();
     xnrReader.Close();
     string sOutput = swOutput.ToString();
     return sOutput;
 }
示例#31
0
        /// <summary>
        ///  Transform the resposexml into formated xml.
        /// </summary>
        /// <param name="XmlDocument">The Search Respose xml for Rad Control</param>
        /// <param name="XmlTextReader">The TextReader object which contains XSl file  </param>
        private DataSet GetRadDataSource(XmlDocument objResponseXml, XmlTextReader objXmlTextReader, string fieldName)
        {
            XmlDocument xmlDocForXSL = new XmlDocument();
            StringWriter objStringWriter = new StringWriter();
            XslCompiledTransform objCompiledTransform = new XslCompiledTransform();
            XsltArgumentList xsltArgsList = new XsltArgumentList();
            DataSet dsOutput = new DataSet();
            XmlNodeReader xmlNodeReader = null;
            switch(fieldName)
            {
                case FIELD:
                    {
                        xsltArgsList.AddParam("PARAM1", string.Empty, "Field Name");
                        xsltArgsList.AddParam("PARAM2", string.Empty, "Field Identifier");
                        break;
                    }
                case FIELDOPERATOR:
                    {
                        xsltArgsList.AddParam("PARAM1", string.Empty, "Operator");
                        break;
                    }
                //Added in DREAM 4.0 for R5K changes
                //starts
                case BASINLIST:
                    {
                        xsltArgsList.AddParam("PARAM1", string.Empty, BASINNAME);
                        break;
                    }
                //Ends
            }
            //Commented in DREAM 4.0 for R5K Changes
            xmlDocForXSL.Load(objXmlTextReader);
            objCompiledTransform.Load(xmlDocForXSL);
            objCompiledTransform.Transform(objResponseXml, xsltArgsList, objStringWriter);
            objResponseXml.LoadXml(objStringWriter.ToString());
            xmlNodeReader = new XmlNodeReader(objResponseXml);
            dsOutput.ReadXml(xmlNodeReader);

            //Closing and disposing objects
            objXmlTextReader.Close();
            xmlNodeReader.Close();
            objStringWriter.Flush();
            objStringWriter.Close();
            objStringWriter.Dispose();
            return dsOutput;
        }