public static string Serialize(IEnumerable<MicroDataEntry> entries)
        {
            StringBuilder sb = new StringBuilder(3000);
            using (StringWriter sw = new StringWriter(sb))
            {
                using (XmlTextWriter xw = new XmlTextWriter(sw))
                {
                    xw.WriteStartElement("microData");

                    foreach (MicroDataEntry microDataEntry in entries)
                    {
                        xw.WriteStartElement("entry");

                        if (microDataEntry.ContentType.HasValue)
                        {
                            xw.WriteAttributeString("contentType", microDataEntry.ContentType.Value.ToString());
                        }

                        xw.WriteAttributeString("entryType", microDataEntry.Type.ToString());
                        xw.WriteAttributeString("selector", microDataEntry.Selector);
                        xw.WriteAttributeString("value", microDataEntry.Value);

                        xw.WriteEndElement();
                    }

                    xw.WriteEndElement();
                }
            }

            return sb.ToString();
        }
Example #2
1
 private void AddKey(XmlTextWriter xml, string key, string value)
 {
     xml.WriteStartElement("add");
     xml.WriteAttributeString("key", key);
     xml.WriteAttributeString("value", value);
     xml.WriteEndElement(); //add
 }
Example #3
1
        private bool SaveRegister(string RegisterKey)
        {
            try
            {
                
                Encryption enc = new Encryption();
                FileStream fs = new FileStream("reqlkd.dll", FileMode.Create);
                XmlTextWriter w = new XmlTextWriter(fs, Encoding.UTF8);

                // Khởi động tài liệu.
                w.WriteStartDocument();
                w.WriteStartElement("QLCV");

                // Ghi một product.
                w.WriteStartElement("Register");
                w.WriteAttributeString("GuiNumber", enc.EncryptData(sGuiID));
                w.WriteAttributeString("Serialnumber", enc.EncryptData(sSerial));
                w.WriteAttributeString("KeyRegister", enc.EncryptData(RegisterKey, sSerial + sGuiID));
                w.WriteEndElement();

                // Kết thúc tài liệu.
                w.WriteEndElement();
                w.WriteEndDocument();
                w.Flush();
                w.Close();
                fs.Close();
                return true;
            }
            catch (Exception ex)
            {

                return false;
            }
        }
Example #4
1
 // XmlWriterSample1/form.cs
 private void button1_Click(object sender, System.EventArgs e)
 {
     // change to match you path structure
     string fileName="booknew.xml";
     //create the XmlTextWriter
     XmlTextWriter tw=new XmlTextWriter(fileName,null);
     //set the formatting to indented
     tw.Formatting=Formatting.Indented;
     tw.WriteStartDocument();
     //Start creating elements and attributes
     tw.WriteStartElement("book");
     tw.WriteAttributeString("genre","Mystery");
     tw.WriteAttributeString("publicationdate","2001");
     tw.WriteAttributeString("ISBN","123456789");
     tw.WriteElementString("title","Case of the Missing Cookie");
     tw.WriteStartElement("author");
     tw.WriteElementString("name","Cookie Monster");
     tw.WriteEndElement();
     tw.WriteElementString("price","9.99");
     tw.WriteEndElement();
     tw.WriteEndDocument();
     //clean up
     tw.Flush();
     tw.Close();
 }
Example #5
0
        public void Save(XmlTextWriter writer)
        {
            writer.WriteStartElement("State");
            writer.WriteAttributeString("name", Name);

            foreach (var command in Commands)
            {
                command.Save(writer);
            }

            if (StartOptionName != null || StartOptionVar != null)
            {
                writer.WriteStartElement("SelectOption");
                if (StartOptionName != null)
                {
                    writer.WriteAttributeString("name", StartOptionName);
                }
                if (StartOptionVar != null)
                {
                    writer.WriteAttributeString("var", StartOptionVar);
                }
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Only subscribed keys in the same namespace are saved.
        /// </summary>
        /// <param name="dict"></param>
        /// <returns>XML file</returns>
        public static MemoryStream Save(P2PDictionary dict)
        {
            MemoryStream writeStream = new MemoryStream();

            System.Xml.XmlTextWriter writer = new XmlTextWriter(writeStream,  Encoding.UTF8);
            ICollection<string> keys = dict.Keys;

            writer.WriteStartDocument();
            writer.WriteStartElement("p2pdictionary");
            writer.WriteStartElement("namespace");
            writer.WriteAttributeString("name", dict.Namespace);
            writer.WriteAttributeString("description", dict.Description);

            IFormatter formatter = new BinaryFormatter();

            foreach (string k in keys)
            {
                writer.WriteStartElement("entry");
                writer.WriteAttributeString("key", k);

                using (MemoryStream contents = new MemoryStream())
                {
                    formatter.Serialize(contents, dict[k]);
                    writer.WriteBase64(contents.GetBuffer(), 0, (int)contents.Length);
                }

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.Flush();

            return writeStream;
        }
Example #7
0
        public override void Serialize(XmlTextWriter xml)
        {
            xml.WriteStartElement("array");
            xml.WriteAttributeString("id", ID.ToString());
            xml.WriteAttributeString("type", Type.FullName);

            //int[] dimensions = new int[items.Rank];

            //foreach (ObjectBase element in Items)
            //{
            //    xml.WriteStartElement("element");
            //    element.SerializeReference(xml);
            //    xml.WriteEndElement();
            //}

            Array arr = Items;
            int rank;
            int[] dimensions;
            int[] lowerBounds;
            int[] upperBounds;
            SetupLoopData(arr, out rank, out dimensions, out lowerBounds, out upperBounds);

            do
            {
                ObjectBase element = (ObjectBase) arr.GetValue(dimensions);

                xml.WriteStartElement("element");
                xml.WriteAttributeString("index", dimensions.ToString());
                element.SerializeReference(xml);
                xml.WriteEndElement();
            } while (IncreaseDimension(dimensions, lowerBounds, upperBounds, rank - 1));

            xml.WriteEndElement();
        }
Example #8
0
        // so not cool...
        private static void TraverseAndGenerateXmlUsingXmlWriter(string targetPath, XmlTextWriter writer)
        {
            var files = Directory.GetFiles(targetPath);
            if (files.Length > 0)
            {
                foreach (var f in files)
                {
                    writer.WriteStartElement("file");
                    writer.WriteAttributeString("name", Path.GetFileNameWithoutExtension(f));
                    writer.WriteEndElement();
                }
            }

            var directories = Directory.GetDirectories(targetPath);
            if (directories.Length != 0)
            {
                foreach (var dir in directories)
                {
                    writer.WriteStartElement("dir");
                    writer.WriteAttributeString("name", new DirectoryInfo(dir).Name);

                    TraverseAndGenerateXmlUsingXmlWriter(dir, writer);
                    writer.WriteEndElement();
                }
            }
        }
		/// <summary>Serializes a graph into a file</summary>
		/// <param name="g">Graph to serialize</param>
		/// <param name="file">Target file</param>
		public static void Serialize(Graph g, string file)
		{
			using (XmlTextWriter writer = new XmlTextWriter(file, Encoding.UTF8))
			{
				writer.Formatting = Formatting.Indented;
				writer.Indentation = 1;
				writer.IndentChar = '\t';
				writer.WriteStartDocument(true);
				writer.WriteStartElement("GraphXML");
				writer.WriteStartElement("graph");
				writer.WriteAttributeString("id", "autogenerated_webgraph_10");
				writer.WriteAttributeString("meta", g.Tag.ToString());
				g.ForAllNodes(node =>
					{
						writer.WriteStartElement("node");
						writer.WriteAttributeString("name", string.Format("n{0:D4}", node.Id));
						writer.WriteElementString("label", node.Label);
						writer.WriteEndElement();	// node
					});
				g.ForAllEdges(edge =>
					{
						writer.WriteStartElement("edge");
						writer.WriteAttributeString("source", string.Format("n{0:D4}", edge.From.Id));
						writer.WriteAttributeString("target", string.Format("n{0:D4}", edge.To.Id));
						writer.WriteEndElement();	// edge
					});
				writer.WriteEndElement();	// graph
				writer.WriteEndElement();	// GraphXML
				writer.Close();
			}
		}
Example #10
0
        private void WriteFeed(IEnumerable<DonaldEpisode> episodes, Stream responseStream, string url)
        {
            XmlTextWriter objX = new XmlTextWriter(responseStream, Encoding.UTF8);
            objX.WriteStartDocument();
            objX.WriteStartElement("rss");
            objX.WriteAttributeString("version", "2.0");
            objX.WriteStartElement("channel");
            objX.WriteElementString("title", "Donald Inc.");
            objX.WriteElementString("link", url);
            objX.WriteElementString("description",
                                    "Your custom donald feed!");
            objX.WriteElementString("copyright", "(c) 2011, Chuck Norris.");
            objX.WriteElementString("ttl", "5");
            foreach (var episode in episodes)
            {
                objX.WriteStartElement("item");
                objX.WriteElementString("title", episode.Title);
                objX.WriteElementString("description", episode.Content);
                objX.WriteElementString("link",
                                        Configuration.ApiUri + "/" + episode.Id);
                objX.WriteElementString("pubDate", episode.ReleaseDate.Value.ToString("R"));
                objX.WriteStartElement("enclosure");
                objX.WriteAttributeString("url", Configuration.ApiUri + "/" + episode.Id + "/jpg");
                objX.WriteAttributeString("type", "application/jpg");
                objX.WriteEndElement();
                objX.WriteEndElement();
            }

            objX.WriteEndElement();
            objX.WriteEndElement();
            objX.WriteEndDocument();
            objX.Flush();
        }
Example #11
0
		public static void WriteSize(Size size, XmlTextWriter writer)
		{
			writer.WriteStartElement("Size");
			writer.WriteAttributeString("Width", size.Width.ToString(CultureInfo.InvariantCulture));
			writer.WriteAttributeString("Height", size.Height.ToString(CultureInfo.InvariantCulture));
			writer.WriteEndElement();
		}
 public override void ToKML(XmlTextWriter kml)
 {
     kml.WriteStartElement("SimpleArrayField");
     kml.WriteAttributeString("name", this.Name);
     kml.WriteAttributeString("type", this.FieldType.ToString());
     kml.WriteEndElement();
 }
Example #13
0
        /// <summary>
        /// Generates Burn manifest and ParameterInfo-style markup for a component search.
        /// </summary>
        /// <param name="writer"></param>
        public override void WriteXml(XmlTextWriter writer)
        {
            writer.WriteStartElement("MsiComponentSearch");
            this.WriteWixSearchAttributes(writer);

            writer.WriteAttributeString("ComponentId", this.Guid);

            if (!String.IsNullOrEmpty(this.ProductCode))
            {
                writer.WriteAttributeString("ProductCode", this.ProductCode);
            }

            if (0 != (this.Attributes & WixComponentSearchAttributes.KeyPath))
            {
                writer.WriteAttributeString("Type", "keyPath");
            }
            else if (0 != (this.Attributes & WixComponentSearchAttributes.State))
            {
                writer.WriteAttributeString("Type", "state");
            }
            else if (0 != (this.Attributes & WixComponentSearchAttributes.WantDirectory))
            {
                writer.WriteAttributeString("Type", "directory");
            }

            writer.WriteEndElement();
        }
Example #14
0
 private static void writeElement(XmlTextWriter writer, string key, string value)
 {
     writer.WriteStartElement(ADD, null);
     writer.WriteAttributeString(KEY, key);
     writer.WriteAttributeString(VALUE, value);
     writer.WriteEndElement();
 }
Example #15
0
        public void createRandomXML(XmlTextWriter writer, int NUM_SENSOR, int NUM_LINK)
        {
            writer.WriteStartElement(XmlTag.TAG_WSN);

            writer.WriteStartElement(XmlTag.TAG_DECLARATION);
            writer.WriteEndElement();

            writer.WriteStartElement(XmlTag.TAG_NETWORK);

            writer.WriteStartElement(XmlTag.TAG_PROCESS);
            writer.WriteAttributeString(XmlTag.ATTR_NAME, "Network_1");
            writer.WriteAttributeString(XmlTag.ATTR_PRO_PARAM, "");
            writer.WriteAttributeString(XmlTag.ATTR_ZOOM, "1");
            writer.WriteAttributeString("StateCounter", "9");

            //Create sensors
            writer.WriteStartElement(XmlTag.TAG_SENSORS);

            randomSensors(NUM_SENSOR, writer);
            writer.WriteEndElement(); //End sensors

            //Create links
            writer.WriteStartElement(XmlTag.TAG_CHANNELS);
            randomLinks(NUM_LINK, NUM_SENSOR, writer);
            writer.WriteEndElement(); //End <Links>

            writer.WriteEndElement(); //End <Process>
            writer.WriteEndElement(); //End <Network>
            writer.WriteEndElement(); //End <WSN>
        }
Example #16
0
 public override void ToKML(XmlTextWriter kml)
 {
     kml.WriteStartElement("Schema");
     kml.WriteAttributeString("name", Name);
     kml.WriteAttributeString("parent", Parent);
     kml.WriteEndElement();
 }
Example #17
0
		public override void writeToXml(XmlTextWriter writer)
		{
			JamaMatrix jamaMatrix = IPolyPointTransformer.PolyExps(this.polynomialDegree);
			string[] array = new string[]
			{
				"x",
				"y"
			};
			for (int i = 0; i < 2; i++)
			{
				writer.WriteStartElement("Sum");
				writer.WriteAttributeString("Name", array[i]);
				for (int j = 0; j < jamaMatrix.RowDimension; j++)
				{
					writer.WriteStartElement("Term");
					writer.WriteAttributeString("Coefficient", this.transformCoefficients.GetElement(i * jamaMatrix.RowDimension + j, 0).ToString(CultureInfo.InvariantCulture));
					for (int k = 0; k < 2; k++)
					{
						writer.WriteAttributeString(array[k] + "_power", jamaMatrix.GetElement(j, k).ToString(CultureInfo.InvariantCulture));
					}
					writer.WriteEndElement();
				}
				writer.WriteEndElement();
			}
		}
Example #18
0
        public static void AddHeaderInformation(XmlDocument xmlDoc, QMaker qMaker)
        {
            StringBuilder sbH = new StringBuilder();
            StringWriter tempWriterH = new StringWriter(sbH);
            XmlTextWriter writerH = new XmlTextWriter(tempWriterH);

            writerH.WriteStartElement("Headers");

            foreach (QField gField in qMaker.Groups)
            {
                writerH.WriteStartElement("Header");
                writerH.WriteAttributeString("Name", gField.Name);
                writerH.WriteAttributeString("Description", gField.FriendlyName);
                writerH.WriteEndElement();//Header
            }
            foreach (QField fField in qMaker.Fields)
            {
                writerH.WriteStartElement("Header");
                writerH.WriteAttributeString("Name", fField.Name);
                writerH.WriteAttributeString("Description", fField.FriendlyName);
                writerH.WriteEndElement();//Header
            }

            writerH.WriteEndElement();//Headers
            writerH.Flush();

            XmlDocumentFragment xmlHeaders = xmlDoc.CreateDocumentFragment();
            xmlHeaders.InnerXml = sbH.ToString();

            xmlDoc.SelectSingleNode("Report").AppendChild(xmlHeaders);
        }
Example #19
0
        /// <summary>
        ///     Export Products To Google Base
        /// </summary>
        /// <returns></returns>
        public byte[] ExportProductsToGoogleBase()
        {
            const string ns = "http://base.google.com/ns/1.0";
            var ms = new MemoryStream();
            var xml = new XmlTextWriter(ms, Encoding.UTF8);

            xml.WriteStartDocument();
            xml.WriteStartElement("rss");
            xml.WriteAttributeString("xmlns", "g", null, ns);
            xml.WriteAttributeString("version", "2.0");
            xml.WriteStartElement("channel");

            //GENERAL FEED INFO
            xml.WriteElementString("title", CurrentRequestData.CurrentSite.Name);
            xml.WriteElementString("link", CurrentRequestData.CurrentSite.BaseUrl);
            xml.WriteElementString("description",
                " Products from " + CurrentRequestData.CurrentSite.Name + " online store");

            IList<ProductVariant> productVariants = _productVariantService.GetAllVariantsForGoogleBase();

            foreach (ProductVariant pv in productVariants)
            {
                ExportGoogleBaseProduct(ref xml, pv, ns);
            }

            xml.WriteEndElement();
            xml.WriteEndElement();
            xml.WriteEndDocument();

            xml.Flush();
            byte[] file = ms.ToArray();
            xml.Close();

            return file;
        }
Example #20
0
 public void Save_XML(string path)
 {
     XmlTextWriter xmlTextWriter = new XmlTextWriter(path, null);
     xmlTextWriter.Formatting = Formatting.Indented;
     xmlTextWriter.WriteStartDocument(false);
     xmlTextWriter.WriteComment("Xml from Juan converter");
     xmlTextWriter.WriteStartElement("STB");
     for (int num = 0; num != this.rowcount; num++)
     {
         xmlTextWriter.WriteStartElement("Entry");
         xmlTextWriter.WriteAttributeString("id", num.ToString());
         for (int num2 = 0; num2 != this.columncount; num2++)
         {
             if (this.column[num2].selected)
             {
                 xmlTextWriter.WriteStartElement("Data");
                 xmlTextWriter.WriteAttributeString("type", this.column[num2].columntitle);
                 xmlTextWriter.WriteString(this.celldata[num, num2]);
                 xmlTextWriter.WriteEndElement();
             }
         }
         xmlTextWriter.WriteEndElement();
     }
     xmlTextWriter.WriteEndElement();
     xmlTextWriter.Flush();
     xmlTextWriter.Close();
     xmlTextWriter.Close();
 }
Example #21
0
        /// <summary>
        /// Generates Burn manifest and ParameterInfo-style markup for a product search.
        /// </summary>
        /// <param name="writer"></param>
        public override void WriteXml(XmlTextWriter writer)
        {
            writer.WriteStartElement("MsiProductSearch");
            this.WriteWixSearchAttributes(writer);

            writer.WriteAttributeString("ProductCode", this.ProductCode);

            if (0 != (this.Attributes & WixProductSearchAttributes.Version))
            {
                writer.WriteAttributeString("Type", "version");
            }
            else if (0 != (this.Attributes & WixProductSearchAttributes.Language))
            {
                writer.WriteAttributeString("Type", "language");
            }
            else if (0 != (this.Attributes & WixProductSearchAttributes.State))
            {
                writer.WriteAttributeString("Type", "state");
            }
            else if (0 != (this.Attributes & WixProductSearchAttributes.Assignment))
            {
                writer.WriteAttributeString("Type", "assignment");
            }

            writer.WriteEndElement();
        }
Example #22
0
        private void writeGPX(string filename)
        {
            System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(filename) + ".gpx", Encoding.ASCII);

            xw.WriteStartElement("gpx");

            xw.WriteStartElement("trk");

            xw.WriteStartElement("trkseg");

            foreach (CurrentState cs in flightdata)
            {
                xw.WriteStartElement("trkpt");
                xw.WriteAttributeString("lat", cs.lat.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteAttributeString("lon", cs.lng.ToString(new System.Globalization.CultureInfo("en-US")));

                xw.WriteElementString("ele", cs.alt.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteElementString("time", cs.datetime.ToString("yyyy-MM-ddTHH:mm:sszzzzzz"));
                xw.WriteElementString("course", (cs.yaw).ToString(new System.Globalization.CultureInfo("en-US")));

                xw.WriteElementString("roll", cs.roll.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteElementString("pitch", cs.pitch.ToString(new System.Globalization.CultureInfo("en-US")));
                //xw.WriteElementString("speed", mod.model.Orientation.);
                //xw.WriteElementString("fix", cs.altitude);

                xw.WriteEndElement();
            }

            xw.WriteEndElement();
            xw.WriteEndElement();
            xw.WriteEndElement();

            xw.Close();
        }
Example #23
0
        public static void CreateSalesReport()
        {
            SupermarketEntities supermarkets = new SupermarketEntities();

            var queryResult =
                from vendor in supermarkets.Vendors
                select new
                {
                    Vendor = vendor.VendorName,

                    dayToDayReprots =
                        from sale in supermarkets.Sales
                        join product in supermarkets.Products
                        on sale.ProductId equals product.ProductId
                        join report in supermarkets.Reports
                        on sale.ReportId equals report.ReportId
                        where product.VendorId == vendor.VendorId
                        group sale by report.ReportDate
                            into reportForDate
                            select new
                            {
                                Date = reportForDate.Key,
                                TotalSum = reportForDate.Sum(p => p.ProductTotalSum)
                            }
                };

            string fileName = "../../report.xml";
            Encoding encoding = Encoding.GetEncoding("windows-1251");
            using (XmlTextWriter writer = new XmlTextWriter(fileName, encoding))
            {
                writer.Formatting = Formatting.Indented;
                writer.IndentChar = '\t';
                writer.Indentation = 1;

                writer.WriteStartDocument();
                writer.WriteStartElement("sales");

                foreach (var vendor in queryResult)
                {
                    Console.WriteLine("Writing report for " + vendor.Vendor);

                    writer.WriteStartElement("sale");
                    writer.WriteAttributeString("vendor", vendor.Vendor);

                    foreach (var dayReport in vendor.dayToDayReprots)
                    {
                        writer.WriteStartElement("summary");
                        string dateString = string.Format("{0:dd-MMM-yyyy}", dayReport.Date);
                        writer.WriteAttributeString("date", dateString);
                        writer.WriteAttributeString("total-sum", dayReport.TotalSum.ToString("N2"));
                        writer.WriteEndElement();
                    }

                    writer.WriteEndElement();
                     
                }

                writer.WriteEndDocument();
            }
        }
 public void Save(XmlTextWriter xmlInfo)
 {
     xmlInfo.WriteStartElement("MapTile");
     xmlInfo.WriteAttributeString("TileID", StringType.FromInteger((int)this.m_TileID));
     xmlInfo.WriteAttributeString("AltIDMod", StringType.FromInteger((int)this.m_AltID));
     xmlInfo.WriteEndElement();
 }
        protected virtual string BuildEmptyLayout([NotNull] Database database)
        {
            var writer = new StringWriter();
            var output = new XmlTextWriter(writer)
            {
                Formatting = Formatting.Indented
            };

            output.WriteStartElement("Layout");
            output.WriteAttributeString("xmlns", "http://www.sitecore.net/pathfinder/item");

            var deviceItem = database.GetItem(ItemIDs.DevicesRoot);
            if (deviceItem != null)
            {
                foreach (Item item in deviceItem.Children)
                {
                    output.WriteStartElement("Device");
                    output.WriteAttributeString("Name", item.Name);
                    output.WriteEndElement();
                }
            }

            output.WriteEndElement();

            return writer.ToString();
        }
        public static string Serialize(UserProfileData profile)
        {
            StringWriter sw = new StringWriter();
            XmlTextWriter xtw = new XmlTextWriter(sw);
            xtw.Formatting = Formatting.Indented;
            xtw.WriteStartDocument();
            
            xtw.WriteStartElement("user_profile");
            xtw.WriteAttributeString("major_version", MAJOR_VERSION.ToString());
            xtw.WriteAttributeString("minor_version", MINOR_VERSION.ToString());
                       
            xtw.WriteElementString("name", profile.Name);
            xtw.WriteElementString("id", profile.ID.ToString());
            xtw.WriteElementString("about", profile.AboutText);
  
            // Not sure if we're storing this yet, need to take a look
//            xtw.WriteElementString("Url", profile.Url);
            // or, indeed, interests

            xtw.WriteEndElement();
            
            xtw.Close();
            sw.Close();
            
            return sw.ToString();
        }
Example #27
0
    /// <summary>
    /// Writes elements to an xml writer
    /// </summary>
    /// <param name="writer"></param>
    private void WriteElements(Xml.XmlTextWriter writer)
    {
        // iterate across all keys in this section and write them to the xml file
        IDictionaryEnumerator enumerator = this.keyTable.GetEnumerator();

        while (enumerator.MoveNext())
        {
            writer.WriteStartElement(keyName);
            writer.WriteAttributeString("name", (string)enumerator.Key);
            writer.WriteString((string)enumerator.Value);

//			System.Diagnostics.Debug.WriteLine(
//"Wrote: " + this.name + " " + (string)enumerator.Key + " = " + (string)enumerator.Value);

            writer.WriteEndElement();
        }

        // then do it for all sub sections
        foreach (XmlStorage xml in this.subsectionTable.Values)
        {
            writer.WriteStartElement(subsectionName);
            writer.WriteAttributeString("name", xml.name);

            xml.WriteElements(writer);

            writer.WriteEndElement();
        }
    }
Example #28
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            var s = new StringWriter(new StringBuilder(), CultureInfo.CurrentCulture);
            var xmlWrite = new XmlTextWriter(s);

            xmlWrite.WriteStartDocument();
            xmlWrite.WriteStartElement("userInfo");
            xmlWrite.WriteAttributeString("xmlns", "http://schemas.microsoft.com/office/Outlook/2006/OMS/serviceInfo");

            xmlWrite.WriteStartElement("error");
            xmlWrite.WriteAttributeString("code", this.Code.ToString());

            if (this.Severity != SeverityType.Unknow)
            {
                xmlWrite.WriteAttributeString("severity", this.Severity.ToString());
            }
            xmlWrite.WriteEndElement();

            if (this.Code == ErrorCode.Ok)
            {
                if (!string.IsNullOrEmpty(this.ReplyPhone))
                {
                    xmlWrite.WriteElementString("replyPhone", this.ReplyPhone);
                }
                if (!string.IsNullOrEmpty(this.ReplyPhone))
                {
                    xmlWrite.WriteElementString("smtpAddress", this.SmtpAddress);
                }
            }

            xmlWrite.WriteEndElement();
            xmlWrite.WriteEndDocument();
            return s.GetStringBuilder().ToString();
        }
Example #29
0
        /// <summary>
        /// Deletes a Category
        /// </summary>
        /// <param name="category">Which category? - The Category reference</param>
        public override void DeleteCategory(Category category)
        {
            List<Category> categories = Category.Categories;
              categories.Remove(category);
              string fileName = _Folder + "Categories.xml";

              if (File.Exists(fileName))
            File.Delete(fileName);

              if (Category.Categories.Contains(category))
            Category.Categories.Remove(category);

              using (XmlTextWriter writer = new XmlTextWriter(fileName, System.Text.Encoding.UTF8))
              {
            writer.Formatting = Formatting.Indented;
            writer.Indentation = 4;
            writer.WriteStartDocument(true);
            writer.WriteStartElement("categories");

            foreach (Category cat in categories)
            {
              writer.WriteStartElement("category");
              writer.WriteAttributeString("id", cat.Id.ToString());
              writer.WriteAttributeString("description", cat.Description);
              writer.WriteValue(cat.Title);
              writer.WriteEndElement();
              cat.MarkOld();
            }

            writer.WriteEndElement();
              }
        }
		internal void WriteXML(XmlTextWriter writer)
		{
			writer.WriteStartElement("SourceMapRenderOptions");
			writer.WriteAttributeString("MinZoom", this._minZoom.ToString(CultureInfo.InvariantCulture));
			writer.WriteAttributeString("MaxZoom", this._maxZoom.ToString(CultureInfo.InvariantCulture));
			writer.WriteEndElement();
		}
Example #31
0
        public void XMLCheck()
        {
            try
            {
                if (!File.Exists(SettingsFile))
                {
                    xwriter = new XmlTextWriter(SettingsFile, null);
                    xwriter.Formatting = Formatting.Indented;
                    xwriter.WriteStartDocument();
                    xwriter.WriteStartElement("settings");
                    xwriter.WriteStartElement("twitch_server");
                    xwriter.WriteAttributeString("value", null);
                    xwriter.WriteEndElement();
                    xwriter.WriteStartElement("twitch_name");
                    xwriter.WriteAttributeString("value", null);
                    xwriter.WriteEndElement();
                    xwriter.WriteStartElement("twitch_auth");
                    xwriter.WriteAttributeString("value", null);
                    xwriter.WriteEndElement();
                    xwriter.WriteEndDocument();
                    xwriter.Close();
                }
            }

            catch (Exception ex)
            {

            }
            finally
            {
                //Nothing yet
            }
        }
        /// <summary> 
        /// Encodes a function call to be sent to Flash. 
        /// </summary> 
        /// <param name="functionName">The name of the function to call.</param> 
        /// <param name="arguments">Zero or more parameters to pass in to the ActonScript function.</param> 
        /// <returns>The XML string representation of the function call to pass to Flash</returns> 
        public static string EncodeInvoke(string functionName, object[] arguments)
        {
            StringBuilder sb = new StringBuilder();

            XmlTextWriter writer = new XmlTextWriter(new StringWriter(sb));

            // <invoke name="functionName" returntype="xml">
            writer.WriteStartElement("invoke");
            writer.WriteAttributeString("name", functionName);
            writer.WriteAttributeString("returntype", "xml");

            if (arguments != null && arguments.Length > 0)
            {
                // <arguments>
                writer.WriteStartElement("arguments");

                // individual arguments
                foreach (object value in arguments)
                {
                    WriteElement(writer, value);
                }

                // </arguments>
                writer.WriteEndElement();
            }

            // </invoke>
            writer.WriteEndElement();

            writer.Flush();
            writer.Close();

            return sb.ToString();
        }
Example #33
0
 /// <summary>
 /// 添加元素属性
 /// </summary>
 /// <param name="p_objclsElementAttribute"></param>
 /// <param name="p_xmlWriter"></param>
 private void m_mthAddElementAttibute(clsElementAttribute p_objclsElementAttribute, ref System.Xml.XmlTextWriter p_xmlWriter)
 {
     p_xmlWriter.WriteStartElement(p_objclsElementAttribute.m_strElementName);
     p_xmlWriter.WriteAttributeString("VALUE", p_objclsElementAttribute.m_strValue);
     if (p_objclsElementAttribute.m_blnIsDST == true)
     {
         p_xmlWriter.WriteAttributeString("VALUEXML", p_objclsElementAttribute.m_strValueXML);
     }
     p_xmlWriter.WriteEndElement();
 }
Example #34
0
 public static void WriteXmlInFile(string layer, string msg)
 {
     try
     {
         //XmlDataDocument sourceXML = new XmlDataDocument();
         string xmlFile = HttpContext.Current.Server.MapPath("/log/Exception.xml");
         //create a XML file is not exist
         System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(xmlFile, null);
         //starts a new document
         writer.WriteStartDocument();
         //write comments
         writer.WriteComment("Commentss: XmlWriter Test Program");
         writer.Formatting = Formatting.Indented;
         writer.WriteStartElement("MessageList");
         writer.WriteStartElement("Exception");
         writer.WriteAttributeString("Layer", layer);
         //write some simple elements
         writer.WriteElementString("Message", msg);
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.Close();
     }
     catch (Exception ex) { throw ex; }
 }
Example #35
0
        static int vipID; // = 0;

        static void SerializeVisual(Visual visual, double width, double height, String filename)
        {
            FileStream    stream = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite);
            XmlTextWriter writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8);

            writer.Formatting  = System.Xml.Formatting.Indented;
            writer.Indentation = 4;
            writer.WriteStartElement("FixedDocument");
            writer.WriteAttributeString("xmlns", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
            writer.WriteAttributeString("xmlns:x", "http://schemas.microsoft.com/winfx/2006/xaml");

            writer.WriteStartElement("PageContent");
            writer.WriteStartElement("FixedPage");
            writer.WriteAttributeString("Width", width.ToString(CultureInfo.InvariantCulture));
            writer.WriteAttributeString("Height", height.ToString(CultureInfo.InvariantCulture));
            writer.WriteAttributeString("Background", "White");
            writer.WriteStartElement("Canvas");

            System.IO.StringWriter resString = new StringWriter(CultureInfo.InvariantCulture);

            System.Xml.XmlTextWriter resWriter = new System.Xml.XmlTextWriter(resString);
            resWriter.Formatting  = System.Xml.Formatting.Indented;
            resWriter.Indentation = 4;

            System.IO.StringWriter bodyString = new StringWriter(CultureInfo.InvariantCulture);

            System.Xml.XmlTextWriter bodyWriter = new System.Xml.XmlTextWriter(bodyString);
            bodyWriter.Formatting  = System.Xml.Formatting.Indented;
            bodyWriter.Indentation = 4;

            VisualTreeFlattener.SaveAsXml(visual, resWriter, bodyWriter, filename);

            resWriter.Close();
            bodyWriter.Close();

            writer.Flush();
            writer.WriteRaw(resString.ToString());
            writer.WriteRaw(bodyString.ToString());

            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.WriteEndElement();

            writer.WriteEndElement(); // FixedDocument
            writer.Close();
            stream.Close();
        }
Example #36
0
        public virtual void SaveToXml(System.Xml.XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("Layer");
            xmlWriter.WriteAttributeString("Id", ID.ToString());
            xmlWriter.WriteAttributeString("Type", this.GetType().FullName);
            xmlWriter.WriteAttributeString("Name", Name);
            xmlWriter.WriteAttributeString("ReferenceFrame", referenceFrame);
            xmlWriter.WriteAttributeString("Color", SavedColor.Save(color));
            xmlWriter.WriteAttributeString("Opacity", opacity.ToString());
            xmlWriter.WriteAttributeString("StartTime", StartTime.ToString());
            xmlWriter.WriteAttributeString("EndTime", EndTime.ToString());
            xmlWriter.WriteAttributeString("FadeSpan", FadeSpan.ToString());
            xmlWriter.WriteAttributeString("FadeType", FadeType.ToString());

            this.WriteLayerProperties(xmlWriter);

            xmlWriter.WriteEndElement();
        }
Example #37
0
            /// <summary>
            /// Writes the XML element.
            /// </summary>
            /// <param name="writer">The writer.</param>
            virtual protected void WriteXMLElement(System.Xml.XmlTextWriter writer)
            {
                writer.WriteAttributeString("type", this.ResourceType.Name);
                writer.WriteAttributeString("name", _name);
                writer.WriteAttributeString("id", ID.ToString());
                writer.WriteElementString("family", (Parent != null) ? Parent.QualifiedName : "");

                foreach (FieldValueList fieldValues in this.Fields.Values)
                {
                    foreach (object v in fieldValues.Values)
                    {
                        writer.WriteStartElement("field");
                        writer.WriteAttributeString("name", fieldValues.Type.Name);
                        writer.WriteValue(v.ToString());
                        writer.WriteEndElement();
                    }
                }
            }
Example #38
0
        /// <summary>
        /// creates logfile
        /// </summary>
        private void open()
        {
            if (this.opened_)
            {
                return;
            }
            try
            {
                if (theSwitch.Level > TraceLevel.Off)
                {
                    xmlwriter            = new System.Xml.XmlTextWriter(this.file_path, null);
                    xmlwriter.Formatting = System.Xml.Formatting.Indented;
                    xmlwriter.WriteStartDocument();
                    //Write the ProcessingInstruction node.
                    string PItext = theSwitch.style_instruction_pitext(string.Empty);
                    if (PItext != string.Empty)
                    {
                        xmlwriter.WriteProcessingInstruction("xml-stylesheet", PItext);
                    }

                    xmlwriter.WriteStartElement("trace");
                    xmlwriter.WriteAttributeString("timestamp", timestamp());
                    xmlwriter.WriteAttributeString("assembly", this.asm.FullName);
                    xmlwriter.WriteStartElement("switch");
                    // xmlwriter.WriteAttributeString( "displayname" , theSwitch.DisplayName) ;
                    // xmlwriter.WriteAttributeString( "description" , theSwitch.Description ) ;
                    xmlwriter.WriteAttributeString("level", theSwitch.Level.ToString());
                    xmlwriter.WriteEndElement();                     // close 'switch'
                }
                this.opened_ = true;
            }
            catch (Exception x)
            {
                evlog.internal_log.error(x); x = null;
            }
            finally
            {
                if (this.xmlwriter != null)
                {
                    xmlwriter.Close();
                }
                this.xmlwriter = null;
            }
        }
Example #39
0
        public void Save(System.Xml.XmlTextWriter tw, string localName)
        {
            tw.WriteStartElement(localName);
            tw.WriteAttributeString("Version", "1");

            tw.WriteElementString("DirectionRecentFirst", System.Xml.XmlConvert.ToString(_viewDirectionRecentIsFirst));

            tw.WriteStartElement("ColumnWidths");
            var colWidths = null != _view ? _view.ColumnWidths : new double[0];

            tw.WriteAttributeString("Count", XmlConvert.ToString(colWidths.Length));
            for (int i = 0; i < colWidths.Length; i++)
            {
                tw.WriteElementString("Width", XmlConvert.ToString(colWidths[i]));
            }
            tw.WriteEndElement(); // "ColumnWidths"

            tw.WriteEndElement(); // localName
        }
        public override void WriteLayerProperties(System.Xml.XmlTextWriter xmlWriter)
        {
            if (imageSet.WcsImage != null)
            {
                xmlWriter.WriteAttributeString("Extension", Path.GetExtension(imageSet.WcsImage.Filename));
            }

            if (imageSet.WcsImage is FitsImage)
            {
                FitsImage fi = imageSet.WcsImage as FitsImage;
                xmlWriter.WriteAttributeString("ScaleType", fi.lastScale.ToString());
                xmlWriter.WriteAttributeString("MinValue", fi.lastBitmapMin.ToString());
                xmlWriter.WriteAttributeString("MaxValue", fi.lastBitmapMax.ToString());
            }

            xmlWriter.WriteAttributeString("OverrideDefault", overrideDefaultLayer.ToString());

            ImageSetHelper.SaveToXml(xmlWriter, imageSet, "");
            base.WriteLayerProperties(xmlWriter);
        }
        public override void Save(System.Xml.XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteStartElement(typeof(WorkspacesDock).Name);
            xmlWriter.WriteAttributeString("Count", _workSpaceManager.WorkSpacesCount().ToString(CultureInfo.InvariantCulture));

            foreach (IWorkSpaceShell workSpaceShell in WorkSpaceManager())
            {
                workSpaceShell.Save(xmlWriter);
            }

            xmlWriter.WriteEndElement();
        }
Example #42
0
        /// <summary>
        /// GenerateEntityXmlFromTable generates a xml file basing on the information of the table passed in.
        /// </summary>
        public static void GenerateEntityXmlFromTable(Table table, ArrayList columns, ArrayList extSettings, string outputFile)
        {
            if (table != null && System.IO.File.Exists(outputFile))
            {
                System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(outputFile, System.Text.Encoding.UTF8);
                xtw.Formatting = System.Xml.Formatting.Indented;
                xtw.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");

                //generate entity calss
                xtw.WriteStartElement("entity");
                xtw.WriteAttributeString("tableName", table.TableName);
                xtw.WriteAttributeString("tableSchema", table.TableSchema);
                if (extSettings != null)
                {
                    foreach (ExtSetting e in extSettings)
                    {
                        xtw.WriteAttributeString(e.Name, e.Value);
                    }
                }
//					xtw.WriteAttributeString("namespace", codeNamespace);
//                    xtw.WriteAttributeString("author", Utility.GetCurrentIdentityName());
//                    xtw.WriteAttributeString("createdDateTime", System.DateTime.Now.ToString("s"));
                xtw.WriteAttributeString("BuildProject", BUILDPROJECT_VERSION);

                #region columns/properties
                //generate property node
                xtw.WriteStartElement("columns");
                for (int i = 0; i < columns.Count; i++)
                {
                    GenerateXmlElementFromColumn((Column)columns[i], xtw);
                }
                xtw.WriteEndElement();
                #endregion

                xtw.WriteEndElement();
                xtw.Flush();
                xtw.Close();
            }
        }
Example #43
0
        public void Serialize(System.Xml.XmlTextWriter xtw)
        {
            xtw.WriteStartElement(m_Property.Name.ToLower());

            foreach (Parameter param in m_Property.Parameters)
            {
                xtw.WriteAttributeString(param.Name.ToLower(), string.Join(",", param.Values.ToArray()));
            }

            xtw.WriteString(SerializeToString());

            xtw.WriteEndElement();
        }
        public static string GenerateEntityXml(string outputPath, EntityInfo entity)
        {
            string ret = String.Empty;

            if (entity == null || !Directory.Exists(outputPath))
            {
                return(ret);
            }

            Log4Helper.Write("GenerateEntityXml", String.Format("Process of entity {0} starts at {1}.", entity.ClassName, System.DateTime.Now.ToString("s")), LogSeverity.Info);

            using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(System.IO.Path.Combine(outputPath, String.Concat(entity.ClassName, ".xml")), System.Text.Encoding.UTF8))
            {
                xtw.Formatting = System.Xml.Formatting.Indented;
                xtw.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");

                //generate entity calss
                xtw.WriteStartElement("entity");
                xtw.WriteAttributeString("namespace", entity.NameSpace);
                xtw.WriteAttributeString("name", entity.ClassName);

                #region columns/properties
                //generate property node
                xtw.WriteStartElement("fields");
                foreach (FieldInfo field in entity.Fileds)
                {
                    xtw.WriteStartElement("property");
                    xtw.WriteAttributeString("type", field.Type);
                    xtw.WriteAttributeString("name", field.Name);
                    xtw.WriteAttributeString("privateFieldName", field.PrivateFieldName);
                    xtw.WriteAttributeString("paramName", field.ParamName);
                    xtw.WriteAttributeString("propetyName", field.PropertyName);
                    xtw.WriteAttributeString("csharpType", field.CSharpType);
                    xtw.WriteEndElement();
                }
                xtw.WriteEndElement();
                #endregion
                ret = xtw.ToString();
                xtw.WriteEndElement();
                xtw.Flush();
                xtw.Close();
            }

            Log4Helper.Write("GenerateEntityXmlFromTable", String.Format("Process of table {0} ends at {1}.", entity.ClassName, System.DateTime.Now.ToString("s")), LogSeverity.Info);
            return(ret);
        }
        public static void GenerateTextXmlFromTable(TableInfo table, string outputPath)
        {
            if (table == null || !Directory.Exists(outputPath))
            {
                return;
            }

            Log4Helper.Write("GenerateTextXmlFromTable", String.Format("Process of table {0} starts at {1}.", table.TableName, System.DateTime.Now.ToString("s")), LogSeverity.Info);

            string entityName = GetModelName(table.TableName);

            using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(System.IO.Path.Combine(outputPath, String.Concat(entityName, ".xml")), System.Text.Encoding.UTF8))
            {
                xtw.Formatting = System.Xml.Formatting.Indented;
                xtw.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");

                //generate entity calss
                xtw.WriteStartElement("modeltext");

                #region columns/properties
                foreach (ColumnInfo c in table.Columns)
                {
                    xtw.WriteStartElement("field");
                    xtw.WriteAttributeString("key", entityName + "_" + c.ColumnName);
                    xtw.WriteAttributeString("value", c.ColumnDescription);
                    xtw.WriteEndElement();
                }
                xtw.WriteEndElement();
                #endregion

                xtw.Flush();
                xtw.Close();
            }

            Log4Helper.Write("GenerateTextXmlFromTable", String.Format("Process of table {0} ends at {1}.", table.TableName, System.DateTime.Now.ToString("s")), LogSeverity.Info);
        }
Example #46
0
        private static void WriteStep(Xml.XmlTextWriter writer, Chunk chunk)
        {
            // First write out the chunk itself.
            writer.WriteStartElement(chunk.Name);

            // Write out any values.
            foreach (string key in chunk.Values.Keys)
            {
                writer.WriteStartElement("Value");
                writer.WriteAttributeString("Name", key);
                writer.WriteString(chunk.Values[key]);
                writer.WriteEndElement();
            }

            // Recurse children.
            foreach (Chunk c in chunk)
            {
                WriteStep(writer, c);
            }

            writer.WriteEndElement();
        }
Example #47
0
 public void Save(System.Xml.XmlTextWriter x)
 {
     x.WriteWhitespace("\t");
     x.WriteStartElement("Group");
     x.WriteAttributeString("name", Name);
     x.WriteWhitespace("\r\n");
     foreach (Timer timer in Timers)
     {
         x.WriteWhitespace("\t\t");
         x.WriteStartElement("timer");
         x.WriteAttributeString("name", timer.Name);
         x.WriteEndElement();
         x.WriteWhitespace("\r\n");
     }
     foreach (Rate rate in Rates)
     {
         x.WriteWhitespace("\t\t");
         x.WriteStartElement("rate");
         x.WriteAttributeString("value", rate.Value.ToString());
         x.WriteAttributeString("format", rate.Format);
         x.WriteEndElement();
         x.WriteWhitespace("\r\n");
     }
     foreach (Target target in Targets)
     {
         x.WriteWhitespace("\t\t");
         x.WriteStartElement("target");
         x.WriteAttributeString("value", target.Value.ToString());
         x.WriteAttributeString("period", target.Period);
         x.WriteAttributeString("exclude-weekends", target.ExcludeWeekend.ToString());
         x.WriteEndElement();
         x.WriteWhitespace("\r\n");
     }
     x.WriteWhitespace("\t");
     x.WriteEndElement();
     x.WriteWhitespace("\r\n");
 }
Example #48
0
 /// <summary>
 /// GenerateXmlElementFromColumn generate a xml element from column's definition.
 /// </summary>
 private static void GenerateXmlElementFromColumn(Column c, System.Xml.XmlTextWriter xtw)
 {
     xtw.WriteStartElement("property");
     xtw.WriteAttributeString("columnName", c.ColumnName);
     xtw.WriteAttributeString("dataType", c.DataType);
     xtw.WriteAttributeString("sqlDataType", c.SQLDataType);
     xtw.WriteAttributeString("oracleDataType", c.OracleDataType);
     xtw.WriteAttributeString("vbDataType", c.VBDataType);
     xtw.WriteAttributeString("javaDataType", c.JavaDataType);
     xtw.WriteAttributeString("oracle2DBType", c.Oracle2DBType);
     xtw.WriteAttributeString("maxLength", c.MaxLen.ToString());
     xtw.WriteAttributeString("length", c.Length.ToString());
     xtw.WriteAttributeString("scale", c.Scale);
     xtw.WriteAttributeString("ordinalPosition", c.OrdinalPosition);
     xtw.WriteAttributeString("precision", c.Precision);
     xtw.WriteAttributeString("allowNull", c.AllowNull.ToString());
     xtw.WriteAttributeString("isPK", c.IsPK.ToString());
     xtw.WriteAttributeString("isFK", c.IsFK.ToString());
     xtw.WriteAttributeString("isIdentity", c.IsIdentity.ToString());
     xtw.WriteAttributeString("refTable", c.RefTable);
     xtw.WriteAttributeString("refColumn", c.RefColumn);
     xtw.WriteEndElement();
 }
        public virtual void SaveToXml(System.Xml.XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("ReferenceFrame");
            xmlWriter.WriteAttributeString("Name", Name);
            xmlWriter.WriteAttributeString("Parent", Parent);
            xmlWriter.WriteAttributeString("ReferenceFrameType", ReferenceFrameType.ToString());
            xmlWriter.WriteAttributeString("Reference", Reference.ToString());
            xmlWriter.WriteAttributeString("ParentsRoationalBase", ParentsRoationalBase.ToString());
            xmlWriter.WriteAttributeString("MeanRadius", MeanRadius.ToString());
            xmlWriter.WriteAttributeString("Oblateness", Oblateness.ToString());
            xmlWriter.WriteAttributeString("Heading", Heading.ToString());
            xmlWriter.WriteAttributeString("Pitch", Pitch.ToString());
            xmlWriter.WriteAttributeString("Roll", Roll.ToString());
            xmlWriter.WriteAttributeString("Scale", Scale.ToString());
            xmlWriter.WriteAttributeString("Tilt", Tilt.ToString());
            xmlWriter.WriteAttributeString("Translation", Translation.ToString());
            if (ReferenceFrameType == ReferenceFrameTypes.FixedSherical)
            {
                xmlWriter.WriteAttributeString("Lat", Lat.ToString());
                xmlWriter.WriteAttributeString("Lng", Lng.ToString());
                xmlWriter.WriteAttributeString("Altitude", Altitude.ToString());
            }
            xmlWriter.WriteAttributeString("RotationalPeriod", RotationalPeriod.ToString());
            xmlWriter.WriteAttributeString("ZeroRotationDate", ZeroRotationDate.ToString());
            xmlWriter.WriteAttributeString("RepresentativeColor", SavedColor.Save(RepresentativeColor));
            xmlWriter.WriteAttributeString("ShowAsPoint", ShowAsPoint.ToString());
            xmlWriter.WriteAttributeString("ShowOrbitPath", ShowOrbitPath.ToString());

            xmlWriter.WriteAttributeString("StationKeeping", StationKeeping.ToString());

            if (ReferenceFrameType == ReferenceFrameTypes.Orbital)
            {
                xmlWriter.WriteAttributeString("SemiMajorAxis", SemiMajorAxis.ToString());
                xmlWriter.WriteAttributeString("SemiMajorAxisScale", this.SemiMajorAxisUnits.ToString());
                xmlWriter.WriteAttributeString("Eccentricity", Eccentricity.ToString());
                xmlWriter.WriteAttributeString("Inclination", Inclination.ToString());
                xmlWriter.WriteAttributeString("ArgumentOfPeriapsis", ArgumentOfPeriapsis.ToString());
                xmlWriter.WriteAttributeString("LongitudeOfAscendingNode", LongitudeOfAscendingNode.ToString());
                xmlWriter.WriteAttributeString("MeanAnomolyAtEpoch", MeanAnomolyAtEpoch.ToString());
                xmlWriter.WriteAttributeString("MeanDailyMotion", MeanDailyMotion.ToString());
                xmlWriter.WriteAttributeString("Epoch", Epoch.ToString());
            }

            if (ReferenceFrameType == ReferenceFrameTypes.Trajectory)
            {
                xmlWriter.WriteStartElement("Trajectory");

                foreach (TrajectorySample sample in Trajectory)
                {
                    string data = sample.ToString();
                    xmlWriter.WriteElementString("Sample", data);
                }
                xmlWriter.WriteEndElement();
            }

            xmlWriter.WriteEndElement();
        }
Example #50
0
        public static void writeGPX(string filename, List <CurrentState> flightdata)
        {
            System.Xml.XmlTextWriter xw =
                new System.Xml.XmlTextWriter(
                    Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar +
                    Path.GetFileNameWithoutExtension(filename) + ".gpx", Encoding.ASCII);

            xw.WriteStartElement("gpx");
            xw.WriteAttributeString("creator", MainV2.instance.Text);
            xw.WriteAttributeString("xmlns", "http://www.topografix.com/GPX/1/1");

            xw.WriteStartElement("trk");

            xw.WriteStartElement("trkseg");

            foreach (CurrentState cs in flightdata)
            {
                xw.WriteStartElement("trkpt");
                xw.WriteAttributeString("lat", cs.lat.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteAttributeString("lon", cs.lng.ToString(new System.Globalization.CultureInfo("en-US")));

                xw.WriteElementString("ele", cs.altasl.ToString(new System.Globalization.CultureInfo("en-US")));

                xw.WriteElementString("ele2", cs.alt.ToString(new System.Globalization.CultureInfo("en-US")));

                xw.WriteElementString("time", cs.datetime.ToString("yyyy-MM-ddTHH:mm:sszzzzzz"));
                xw.WriteElementString("course", (cs.yaw).ToString(new System.Globalization.CultureInfo("en-US")));

                xw.WriteElementString("roll", cs.roll.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteElementString("pitch", cs.pitch.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteElementString("mode", cs.mode.ToString(new System.Globalization.CultureInfo("en-US")));
                //xw.WriteElementString("speed", mod.model.Orientation.);
                //xw.WriteElementString("fix", cs.altitude);

                xw.WriteEndElement();
            }

            xw.WriteEndElement();
            xw.WriteEndElement();

            int      a          = 0;
            DateTime lastsample = DateTime.MinValue;

            foreach (CurrentState cs in flightdata)
            {
                if (cs.datetime.Second != lastsample.Second)
                {
                    lastsample = cs.datetime;
                }
                else
                {
                    //continue;
                }

                xw.WriteStartElement("wpt");
                xw.WriteAttributeString("lat", cs.lat.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteAttributeString("lon", cs.lng.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteElementString("name", (a++).ToString());
                xw.WriteElementString("time", cs.datetime.ToString("yyyy-MM-ddTHH:mm:sszzzzzz"));
                xw.WriteElementString("ele", cs.altasl.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteEndElement(); //wpt
            }

            xw.WriteEndElement();

            xw.Close();
        }
        private void GeneraXML(System.Xml.XmlTextWriter writer) // As System.Xml.XmlTextWriter
        {
            try
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("FacturaElectronica");

                writer.WriteAttributeString("xmlns", "https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/facturaElectronica");
                writer.WriteAttributeString("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#");
                writer.WriteAttributeString("xmlns:vc", "http://www.w3.org/2007/XMLSchema-versioning");
                writer.WriteAttributeString("xmlns:xs", "http://www.w3.org/2001/XMLSchema");

                // La clave se crea con la función CreaClave de la clase Datos
                writer.WriteElementString("Clave", _numeroClave);

                // 'El numero de secuencia es de 20 caracteres,
                // 'Se debe de crear con la función CreaNumeroSecuencia de la clase Datos
                writer.WriteElementString("NumeroConsecutivo", _numeroConsecutivo);

                // 'El formato de la fecha es yyyy-MM-ddTHH:mm:sszzz
                writer.WriteElementString("FechaEmision", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz"));

                writer.WriteStartElement("Emisor");

                writer.WriteElementString("Nombre", _emisor.Nombre);
                writer.WriteStartElement("Identificacion");
                writer.WriteElementString("Tipo", _emisor.Identificacion_Tipo);
                writer.WriteElementString("Numero", _emisor.Identificacion_Numero);
                writer.WriteEndElement(); // 'Identificacion

                // '-----------------------------------
                // 'Los datos de las ubicaciones los puede tomar de las tablas de datos,
                // 'Debe ser exacto al que hacienda tiene registrado para su compañia
                writer.WriteStartElement("Ubicacion");
                writer.WriteElementString("Provincia", _emisor.Ubicacion_Provincia);
                writer.WriteElementString("Canton", _emisor.Ubicacion_Canton);
                writer.WriteElementString("Distrito", _emisor.Ubicacion_Distrito);
                writer.WriteElementString("Barrio", _emisor.Ubicacion_Barrio);
                writer.WriteElementString("OtrasSenas", _emisor.Ubicacion_OtrasSenas);
                writer.WriteEndElement(); // 'Ubicacion

                writer.WriteStartElement("Telefono");
                writer.WriteElementString("CodigoPais", _emisor.Telefono_CodigoPais);
                writer.WriteElementString("NumTelefono", _emisor.Telefono_Numero.ToString());
                writer.WriteEndElement(); // 'Telefono

                writer.WriteElementString("CorreoElectronico", _emisor.CorreoElectronico);

                writer.WriteEndElement(); // Emisor
                                          // '------------------------------------
                                          // 'Receptor es similar con emisor, los datos opcionales siempre siempre siempre omitirlos.
                                          // 'La ubicacion para el receptor es opcional por ejemplo
                writer.WriteStartElement("Receptor");
                writer.WriteElementString("Nombre", _receptor.Nombre);
                writer.WriteStartElement("Identificacion");
                // 'Los tipos de identificacion los puede ver en la tabla de datos
                writer.WriteElementString("Tipo", _receptor.Identificacion_Tipo);
                writer.WriteElementString("Numero", _receptor.Identificacion_Numero);
                writer.WriteEndElement(); // 'Identificacion

                writer.WriteStartElement("Telefono");
                writer.WriteElementString("CodigoPais", _receptor.Telefono_CodigoPais);
                writer.WriteElementString("NumTelefono", _receptor.Telefono_Numero.ToString());
                writer.WriteEndElement(); // 'Telefono

                writer.WriteElementString("CorreoElectronico", _receptor.CorreoElectronico);

                writer.WriteEndElement(); // Receptor
                                          // '------------------------------------

                // 'Loa datos estan en la tabla correspondiente
                writer.WriteElementString("CondicionVenta", _condicionVenta);
                // '01: Contado
                // '02: Credito
                // '03: Consignación
                // '04: Apartado
                // '05: Arrendamiento con opcion de compra
                // '06: Arrendamiento con función financiera
                // '99: Otros

                // 'Este dato se muestra si la condicion venta es credito
                writer.WriteElementString("PlazoCredito", _plazoCredito);

                writer.WriteElementString("MedioPago", _medioPago);
                // '01: Efectivo
                // '02: Tarjeta
                // '03: Cheque
                // '04: Transferecia - deposito bancario
                // '05: Recaudado por terceros
                // '99: Otros

                writer.WriteStartElement("DetalleServicio");

                // '-------------------------------------
                foreach (var xt in _dsDetalle)
                {
                    writer.WriteStartElement("LineaDetalle");

                    writer.WriteElementString("NumeroLinea", xt.numeroDeLinea.ToString());

                    writer.WriteStartElement("Codigo");

                    writer.WriteElementString("Tipo", xt.tipoDeArticulo.ToString());
                    writer.WriteElementString("Codigo", xt.codigoArticulo.ToString());
                    writer.WriteEndElement(); // 'Codigo

                    writer.WriteElementString("Cantidad", xt.cantidad.ToString());
                    // 'Para las unidades de medida ver la tabla correspondiente
                    writer.WriteElementString("UnidadMedida", xt.unidadDeMedida.ToString());
                    writer.WriteElementString("Detalle", xt.detalle.ToString());
                    writer.WriteElementString("PrecioUnitario", String.Format("{0:N3}", xt.precioUnitario.ToString()));
                    writer.WriteElementString("MontoTotal", String.Format("{0:N3}", xt.montoTotal.ToString()));
                    writer.WriteElementString("MontoDescuento", String.Format("{0:N3}", xt.montoDescuento.ToString()));
                    writer.WriteElementString("NaturalezaDescuento", xt.NaturalezaDescuento.ToString());
                    writer.WriteElementString("SubTotal", String.Format("{0:N3}", xt.subtotal.ToString()));

                    writer.WriteStartElement("Impuesto");
                    writer.WriteElementString("Codigo", xt.codigoImpuesto.ToString());
                    writer.WriteElementString("Tarifa", xt.impuestoTarifa.ToString());
                    writer.WriteElementString("Monto", xt.impuestoMonto.ToString());
                    writer.WriteEndElement(); // Impuesto

                    writer.WriteElementString("MontoTotalLinea", String.Format("{0:N3}", xt.montoTotalLinea.ToString()));

                    writer.WriteEndElement(); // LineaDetalle
                }
                // '-------------------------------------

                writer.WriteEndElement(); // DetalleServicio


                writer.WriteStartElement("ResumenFactura");

                // Estos campos son opcionales, solo fin desea facturar en dólares
                writer.WriteElementString("CodigoMoneda", _codigoMoneda);
                writer.WriteElementString("TipoCambio", "1.00000");
                // =================

                //SACAR CALCULOS PARA FACTURA



                double totalComprobante = 0;

                double montoTotalImpuesto = 0;

                foreach (var y in _dsDetalle)
                {
                    montoTotalImpuesto = montoTotalImpuesto + y.impuestoMonto;
                }

                totalComprobante = 0 + montoTotalImpuesto;



                // 'En esta parte los totales se pueden ir sumando linea a linea cuando se carga el detalle
                // 'ó se pasa como parametros al inicio
                writer.WriteElementString("TotalServGravados", "0.00000");
                writer.WriteElementString("TotalServExentos", "0.00000");


                writer.WriteElementString("TotalMercanciasGravadas", "0.00000");
                writer.WriteElementString("TotalMercanciasExentas", "0.00000");

                writer.WriteElementString("TotalGravado", "0.00000");
                writer.WriteElementString("TotalExento", "0.00000");

                writer.WriteElementString("TotalVenta", "0.00000");
                writer.WriteElementString("TotalDescuentos", "0.00000");
                writer.WriteElementString("TotalVentaNeta", "0.00000");
                writer.WriteElementString("TotalImpuesto", String.Format("{0:N3}", montoTotalImpuesto.ToString()));
                writer.WriteElementString("TotalComprobante", String.Format("{0:N3}", totalComprobante.ToString()));
                writer.WriteEndElement(); // ResumenFactura

                // 'Estos datos te los tiene que brindar los encargados del area financiera
                writer.WriteStartElement("Normativa");
                writer.WriteElementString("NumeroResolucion", "DGT-R-48-2016");
                writer.WriteElementString("FechaResolucion", "07-10-2016 01:00:00");
                writer.WriteEndElement(); // Normativa

                // 'Aqui va la firma, despues la agregamos.

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void WriteHibernateMapping(System.Xml.XmlTextWriter writer, System.Type type)
        {
            writer.WriteStartElement("hibernate-mapping", "urn:nhibernate-mapping-2.2");

            if (type != null)
            {
                HibernateMappingAttribute attribute = null;
                object[] attributes = type.GetCustomAttributes(typeof(HibernateMappingAttribute), true);
                if (attributes.Length > 0)
                {
                    // If the Type has a HibernateMappingAttribute, then we use it
                    attribute = attributes[0] as HibernateMappingAttribute;

                    // Attribute: <schema>
                    if (attribute.Schema != null)
                    {
                        writer.WriteAttributeString("schema", attribute.Schema);
                    }
                    // Attribute: <default-cascade>
                    if (attribute.DefaultCascade != null)
                    {
                        writer.WriteAttributeString("default-cascade", attribute.DefaultCascade);
                    }
                    // Attribute: <default-access>
                    if (attribute.DefaultAccess != null)
                    {
                        writer.WriteAttributeString("default-access", attribute.DefaultAccess);
                    }
                    // Attribute: <auto-import>
                    if (attribute.AutoImportSpecified)
                    {
                        writer.WriteAttributeString("auto-import", attribute.AutoImport ? "true" : "false");
                    }
                    // Attribute: <namespace>
                    if (attribute.Namespace != null)
                    {
                        writer.WriteAttributeString("namespace", attribute.Namespace);
                    }
                    // Attribute: <assembly>
                    if (attribute.Assembly != null)
                    {
                        writer.WriteAttributeString("assembly", attribute.Assembly);
                    }
                    // Attribute: <default-lazy>
                    if (attribute.DefaultLazySpecified)
                    {
                        writer.WriteAttributeString("default-lazy", attribute.DefaultLazy ? "true" : "false");
                    }

                    return;
                }
            }

            // Set <hibernate-mapping> attributes using specified properties
            // Attribute: <schema>
            if (_schemaIsSpecified)
            {
                writer.WriteAttributeString("schema", _schema);
            }
            // Attribute: <default-cascade>
            if (_defaultcascadeIsSpecified)
            {
                writer.WriteAttributeString("default-cascade", _defaultcascade);
            }
            // Attribute: <default-access>
            if (_defaultaccessIsSpecified)
            {
                writer.WriteAttributeString("default-access", _defaultaccess);
            }
            // Attribute: <auto-import>
            if (_autoimportIsSpecified)
            {
                writer.WriteAttributeString("auto-import", _autoimport ? "true" : "false");
            }
            // Attribute: <namespace>
            if (_namespaceIsSpecified)
            {
                writer.WriteAttributeString("namespace", _namespace);
            }
            // Attribute: <assembly>
            if (_assemblyIsSpecified)
            {
                writer.WriteAttributeString("assembly", _assembly);
            }
            // Attribute: <default-lazy>
            if (_defaultlazyIsSpecified)
            {
                writer.WriteAttributeString("default-lazy", _defaultlazy ? "true" : "false");
            }
        }
Example #53
0
        /// <summary>
        /// 将DataTable的内容写入到XML文件中
        /// </summary>
        /// <param name="dt">数据源</param>
        /// <param name="address">XML文件地址</param>
        public static bool DBWriteToXml(System.Data.DataTable dt, string address)
        {
            try
            {
                //如果文件DataTable.xml存在则直接删除
                if (System.IO.File.Exists(address))
                {
                    System.IO.File.Delete(address);
                }

                System.Xml.XmlTextWriter writer =
                    new System.Xml.XmlTextWriter(address, Encoding.GetEncoding("GBK"));
                writer.Formatting = System.Xml.Formatting.Indented;

                //XML文档创建开始
                writer.WriteStartDocument();

                writer.WriteComment("DataTable: " + dt.TableName);

                writer.WriteStartElement("DataTable"); //DataTable开始

                writer.WriteAttributeString("TableName", dt.TableName);
                writer.WriteAttributeString("CountOfRows", dt.Rows.Count.ToString());
                writer.WriteAttributeString("CountOfColumns", dt.Columns.Count.ToString());

                writer.WriteStartElement("ClomunName", ""); //ColumnName开始

                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    writer.WriteAttributeString(
                        "Column" + i.ToString(), dt.Columns[i].ColumnName);
                }

                writer.WriteEndElement(); //ColumnName结束

                //按行各行
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    writer.WriteStartElement("Row" + j.ToString(), "");

                    //打印各列
                    for (int k = 0; k < dt.Columns.Count; k++)
                    {
                        writer.WriteAttributeString(
                            "Column" + k.ToString(), dt.Rows[j][k].ToString());
                    }

                    writer.WriteEndElement();
                }

                writer.WriteEndElement(); //DataTable结束

                writer.WriteEndDocument();
                writer.Close();

                //XML文档创建结束
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }

            return(true);
        }
        private void GeneraXML(System.Xml.XmlTextWriter writer) // As System.Xml.XmlTextWriter
        {
            try
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("FacturaElectronica");

                writer.WriteAttributeString("xmlns", "https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/facturaElectronica");
                writer.WriteAttributeString("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#");
                writer.WriteAttributeString("xmlns:vc", "http://www.w3.org/2007/XMLSchema-versioning");
                writer.WriteAttributeString("xmlns:xs", "http://www.w3.org/2001/XMLSchema");

                // La clave se crea con la función CreaClave de la clase Datos
                writer.WriteElementString("Clave", _numeroClave);

                // 'El numero de secuencia es de 20 caracteres,
                // 'Se debe de crear con la función CreaNumeroSecuencia de la clase Datos
                writer.WriteElementString("NumeroConsecutivo", _numeroConsecutivo);

                // 'El formato de la fecha es yyyy-MM-ddTHH:mm:sszzz
                writer.WriteElementString("FechaEmision", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz"));

                writer.WriteStartElement("Emisor");

                writer.WriteElementString("Nombre", _emisor.Nombre);
                writer.WriteStartElement("Identificacion");
                writer.WriteElementString("Tipo", _emisor.Tipo_Identificacion);
                writer.WriteElementString("Numero", _emisor.Numero_Identificacion);
                writer.WriteEndElement(); // 'Identificacion

                // '-----------------------------------
                // 'Los datos de las ubicaciones los puede tomar de las tablas de datos,
                // 'Debe ser exacto al que hacienda tiene registrado para su compañia
                writer.WriteStartElement("Ubicacion");
                writer.WriteElementString("Provincia", _emisor.Provincia);
                writer.WriteElementString("Canton", _emisor.Canton);
                writer.WriteElementString("Distrito", _emisor.Distrito);
                writer.WriteElementString("Barrio", _emisor.Barrio);
                writer.WriteElementString("OtrasSenas", _emisor.OtrasSenas);
                writer.WriteEndElement(); // 'Ubicacion

                writer.WriteStartElement("Telefono");
                writer.WriteElementString("CodigoPais", _emisor.CodigoPaisTel);
                writer.WriteElementString("NumTelefono", _emisor.NumTelefono.ToString());
                writer.WriteEndElement(); // 'Telefono

                writer.WriteElementString("CorreoElectronico", _emisor.CorreoElectronico);

                writer.WriteEndElement(); // Emisor
                                          // '------------------------------------
                                          // 'Receptor es similar con emisor, los datos opcionales siempre siempre siempre omitirlos.
                                          // 'La ubicacion para el receptor es opcional por ejemplo
                writer.WriteStartElement("Receptor");
                writer.WriteElementString("Nombre", _receptor.Nombre);
                writer.WriteStartElement("Identificacion");
                // 'Los tipos de identificacion los puede ver en la tabla de datos
                writer.WriteElementString("Tipo", _receptor.Tipo_Identificacion);
                writer.WriteElementString("Numero", _receptor.Numero_Identificacion);
                writer.WriteEndElement(); // 'Identificacion

                writer.WriteStartElement("Telefono");
                writer.WriteElementString("CodigoPais", _receptor.CodigoPaisTel);
                writer.WriteElementString("NumTelefono", _receptor.NumTelefono.ToString());
                writer.WriteEndElement(); // 'Telefono

                writer.WriteElementString("CorreoElectronico", _receptor.CorreoElectronico);

                writer.WriteEndElement(); // Receptor
                                          // '------------------------------------

                // 'Loa datos estan en la tabla correspondiente
                writer.WriteElementString("CondicionVenta", _condicionVenta);
                // '01: Contado
                // '02: Credito
                // '03: Consignación
                // '04: Apartado
                // '05: Arrendamiento con opcion de compra
                // '06: Arrendamiento con función financiera
                // '99: Otros

                // 'Este dato se muestra si la condicion venta es credito
                writer.WriteElementString("PlazoCredito", _plazoCredito);

                writer.WriteElementString("MedioPago", _medioPago);
                // '01: Efectivo
                // '02: Tarjeta
                // '03: Cheque
                // '04: Transferecia - deposito bancario
                // '05: Recaudado por terceros
                // '99: Otros

                writer.WriteStartElement("DetalleServicio");

                // '-------------------------------------

                /*  foreach (DataRow dr in _dsDetalle.Tables["detalle"].Rows)
                 * {
                 *    writer.WriteStartElement("LineaDetalle");
                 *
                 *    writer.WriteElementString("NumeropLinea", dr["numero_linea"].ToString());
                 *
                 *    writer.WriteStartElement("Codigo");
                 *    writer.WriteElementString("Tipo", dr["articulo_tipo"].ToString());
                 *    writer.WriteElementString("Codigo", dr["articulo_codigo"].ToString());
                 *    writer.WriteEndElement(); // 'Codigo
                 *
                 *    writer.WriteElementString("Cantidad", dr["cantidad"].ToString());
                 *    // 'Para las unidades de medida ver la tabla correspondiente
                 *    writer.WriteElementString("UnidadMedida", dr["unidad_medida"].ToString());
                 *    writer.WriteElementString("Detalle", dr["detalle_articulo"].ToString());
                 *    writer.WriteElementString("PrecioUnitario", String.Format("{0:N3}", dr["precio_unitario"].ToString()));
                 *    writer.WriteElementString("MontoTotal", String.Format("{0:N3}", dr["monto_total"].ToString()));
                 *    writer.WriteElementString("MontoDescuento", String.Format("{0:N3}", dr["nonto_descuento"].ToString()));
                 *    writer.WriteElementString("NaturalezaDescuento", dr["naturaleza_descuento"].ToString());
                 *    writer.WriteElementString("SubTotal", String.Format("{0:N3}", dr["sub_total"].ToString()));
                 *
                 *    writer.WriteStartElement("Impuesto");
                 *    writer.WriteElementString("Codigo", dr["impuesto_codigo"].ToString());
                 *    writer.WriteElementString("Tarifa", dr["impuesto_tarifa"].ToString());
                 *    writer.WriteElementString("Monto", dr["impuesto_monto"].ToString());
                 *    writer.WriteEndElement(); // Impuesto
                 *
                 *    writer.WriteElementString("MontoTotalLinea", String.Format("{0:N3}", dr["monto_linea"].ToString()));
                 *
                 *    writer.WriteEndElement(); // LineaDetalle
                 * }
                 * // '-------------------------------------
                 *
                 * writer.WriteEndElement(); // DetalleServicio*/


                writer.WriteStartElement("ResumenFactura");

                // Estos campos son opcionales, solo fin desea facturar en dólares
                //writer.WriteElementString("CodigoMoneda", _codigoMoneda);
                // writer.WriteElementString("TipoCambio", "aqui_tipo_cambio");
                // =================

                // 'En esta parte los totales se pueden ir sumando linea a linea cuando se carga el detalle
                // 'ó se pasa como parametros al inicio
                writer.WriteElementString("TotalServGravados", "");
                writer.WriteElementString("TotalServExentos", "");
                writer.WriteElementString("TotalMercanciasGravadas", "");
                writer.WriteElementString("TotalMercanciasExentas", "");

                writer.WriteElementString("TotalGravado", "");
                writer.WriteElementString("TotalExento", "");

                writer.WriteElementString("TotalVenta", "");
                writer.WriteElementString("TotalDescuentos", "");
                writer.WriteElementString("TotalVentaNeta", "");
                writer.WriteElementString("TotalImpuesto", "");
                writer.WriteElementString("TotalComprobante", "");
                writer.WriteEndElement(); // ResumenFactura

                // 'Estos datos te los tiene que brindar los encargados del area financiera
                writer.WriteStartElement("Normativa");
                writer.WriteElementString("NumeroResolucion", "");
                writer.WriteElementString("FechaResolucion", "");
                writer.WriteEndElement(); // Normativa

                // 'Aqui va la firma, despues la agregamos.

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static void GenerateEntityXmlFromTable(TableInfo table, string outputPath, string prefix, string suffix)
        {
            if (table == null || !Directory.Exists(outputPath))
            {
                return;
            }

            Log4Helper.Write("GenerateEntityXmlFromTable", String.Format("Process of table {0} starts at {1}.", table.TableName, System.DateTime.Now.ToString("s")), LogSeverity.Info);

            string entityName = GetModelName(table.TableName);

            using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(System.IO.Path.Combine(outputPath, String.Concat(entityName, ".xml")), System.Text.Encoding.UTF8))
            {
                xtw.Formatting = System.Xml.Formatting.Indented;
                xtw.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");

                //generate entity calss
                xtw.WriteStartElement("entity");
                xtw.WriteAttributeString("name", entityName);
                xtw.WriteAttributeString("modelName", string.Concat(prefix, ".OM.", suffix, ".", entityName));
                xtw.WriteAttributeString("namespaceBLL", string.Concat(prefix, ".BLL.", suffix));
                xtw.WriteAttributeString("namespaceDAL", string.Concat(prefix, ".DAL.", suffix));
                xtw.WriteAttributeString("namespaceModel", string.Concat(prefix, ".OM.", suffix));
                xtw.WriteAttributeString("author", UtilityHelper.GetCurrentIdentityName());
                xtw.WriteAttributeString("createdDateTime", System.DateTime.Now.ToString("s"));
                xtw.WriteAttributeString("schema", table.Schema);
                xtw.WriteAttributeString("tableName", table.TableName);
                xtw.WriteAttributeString("description", table.TableName);

                #region primary key
                xtw.WriteStartElement("primaryKey");
                foreach (ColumnInfo col in table.Columns)
                {
                    if (col.IsPrimaryKey)
                    {
                        xtw.WriteStartElement("column");
                        xtw.WriteAttributeString("columnName", col.ColumnName);
                        xtw.WriteAttributeString("lowerName", col.ColumnName.ToLower());
                        xtw.WriteAttributeString("sqlParameter", GetParameter(col.DataType, col.ColumnLength));
                        xtw.WriteEndElement();
                    }
                }
                xtw.WriteEndElement();
                #endregion

                #region ForeignKeys
                //xtw.WriteStartElement("foreignKeys");
                //foreach (ForeignKey fk in table.ForeignKeys)
                //{
                //    xtw.WriteStartElement("foreignKey");
                //    xtw.WriteAttributeString("name", fk.Name);
                //    xtw.WriteAttributeString("referencedTableSchema", fk.ReferencedTableSchema);
                //    xtw.WriteAttributeString("referencedTable", fk.ReferencedTable);
                //    xtw.WriteAttributeString("referencedKey", fk.ReferencedKey);
                //    foreach (ForeignKeyColumn fkCol in fk.Columns)
                //    {
                //        xtw.WriteStartElement("column");
                //        xtw.WriteAttributeString("columnName", fkCol.Name);
                //        xtw.WriteAttributeString("referencedColumn", fkCol.ReferencedColumn);
                //        xtw.WriteEndElement();
                //    }
                //    xtw.WriteEndElement();
                //}
                //xtw.WriteEndElement();

                //#endregion

                //#region indexes
                //xtw.WriteStartElement("indexes");
                //foreach (Index idx in table.Indexes)
                //{
                //    xtw.WriteStartElement("index");
                //    xtw.WriteAttributeString("name", idx.Name);
                //    xtw.WriteAttributeString("isClustered", idx.IsClustered.ToString(System.Globalization.CultureInfo.InvariantCulture));
                //    xtw.WriteAttributeString("isUnique", idx.IsUnique.ToString(System.Globalization.CultureInfo.InvariantCulture));
                //    xtw.WriteAttributeString("ignoreDuplicateKeys", idx.IgnoreDuplicateKeys.ToString(System.Globalization.CultureInfo.InvariantCulture));
                //    foreach (IndexedColumn idxcol in idx.IndexedColumns)
                //    {
                //        xtw.WriteStartElement("column");
                //        xtw.WriteAttributeString("columnName", idxcol.Name);
                //        xtw.WriteAttributeString("descending", idxcol.Descending.ToString(System.Globalization.CultureInfo.InvariantCulture));
                //        //xtw.WriteAttributeString("isIncluded", idxcol.IsIncluded.ToString(System.Globalization.CultureInfo.InvariantCulture));
                //        xtw.WriteEndElement();
                //    }
                //    xtw.WriteEndElement();
                //}
                //xtw.WriteEndElement();
                #endregion

                #region columns/properties
                xtw.WriteStartElement("columns");
                foreach (ColumnInfo c in table.Columns)
                {
                    GenerateXmlElementFromColumn(c, xtw);
                }
                xtw.WriteEndElement();
                #endregion

                xtw.WriteEndElement();
                xtw.Flush();
                xtw.Close();
            }

            Log4Helper.Write("GenerateEntityXmlFromTable", String.Format("Process of table {0} ends at {1}.", table.TableName, System.DateTime.Now.ToString("s")), LogSeverity.Info);
        }
Example #56
0
        public string CriarXmlRequisicao(string strMatricSistema, string usuarioSistema, string ipusuario, string usuariorede, string strAutenticacaoCriptografada = "", string strCaminhoCPR = "", string pSenha = "")
        {
            //Rotina que Gera a string de Requisição da Autenticação
            string        strRetorno        = "";
            string        strNomeArquivoXML = "";
            XmlTextWriter xmlRequisicao     = default(XmlTextWriter);
            XmlDocument   docXML            = default(XmlDocument);
            StreamReader  SR = default(StreamReader);

            try
            {
                if (!System.IO.Directory.Exists(ConfigurationSettings.AppSettings["CaminhoXML"].ToString() + "\\XML\\"))
                {
                    System.IO.Directory.CreateDirectory(ConfigurationSettings.AppSettings["CaminhoXML"].ToString() + "\\XML\\");
                }

                //Procura por um nome de arquivo que ainda não exista
                //strNomeArquivoXML = AppDomain.CurrentDomain.BaseDirectory + "\\XML\\XML_REQ_AUT_" + String.Format(DateTime.Now, "ddMMyyyyhhmmss") + ".xml";
                strNomeArquivoXML = ConfigurationSettings.AppSettings["CaminhoXML"].ToString() + "\\XML\\XML_REQ_AUT_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".xml";
                while (System.IO.File.Exists(strNomeArquivoXML))
                {
                    strNomeArquivoXML = AppDomain.CurrentDomain.BaseDirectory + "\\XML\\XML_REQ_AUT_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".xml";
                }

                xmlRequisicao = new System.Xml.XmlTextWriter(strNomeArquivoXML, System.Text.Encoding.UTF8);

                //INÍCIO DO DOCUMENTO XML
                xmlRequisicao.WriteStartDocument();

                //INÍCIO DA TAG 'REQUISICAO'
                xmlRequisicao.WriteStartElement("requisicao");
                xmlRequisicao.WriteAttributeString("xmlns", "http://ntconsult.com.br/webservices/");
                xmlRequisicao.WriteAttributeString("versao", "0.10");

                //Caso a Autenticação seja criptografia RSA então este elemento deverá ser criado: AutenticacaoCriptografada
                //Caso o parâmetro tenha sido informado e não esteja em branco efetua a autenticação através de RSA
                if ((strAutenticacaoCriptografada != null))
                {
                    if (!string.IsNullOrEmpty(strAutenticacaoCriptografada.Trim()))
                    {
                        xmlRequisicao.WriteElementString("AutenticacaoCriptografada", strAutenticacaoCriptografada);
                    }
                }
                else
                {
                    xmlRequisicao.WriteElementString("usr", usuarioSistema);
                    xmlRequisicao.WriteElementString("senha", pSenha);
                }
                xmlRequisicao.WriteElementString("matricsistema", strMatricSistema);
                xmlRequisicao.WriteElementString("usuariorede", usuariorede);
                xmlRequisicao.WriteElementString("ipusuario", ipusuario);



                //FIM DA TAG 'REQUISICAO'
                xmlRequisicao.WriteEndElement();

                //FIM DO DOCUMENTO XML
                xmlRequisicao.WriteEndDocument();
                xmlRequisicao.Flush();
                xmlRequisicao.Close();


                docXML = new XmlDocument();
                docXML.PreserveWhitespace = false;

                SR = File.OpenText(strNomeArquivoXML);
                docXML.LoadXml(SR.ReadToEnd());
                SR.Close();

                strRetorno = docXML.InnerXml.ToString();

                //apos usar o arquivo, apaga-lo
                File.Delete(strNomeArquivoXML);

                return(strRetorno);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #57
0
        internal void SaveToXml(System.Xml.XmlTextWriter xmlWriter, string elementName)
        {
            xmlWriter.WriteStartElement(elementName);
            xmlWriter.WriteAttributeString("Name", name);
            xmlWriter.WriteAttributeString("DataSetType", this.Type.ToString());
            if (this.Type == ImageSetType.Sky)
            {
                xmlWriter.WriteAttributeString("RA", camParams.RA.ToString());
                xmlWriter.WriteAttributeString("Dec", camParams.Dec.ToString());
            }
            else
            {
                xmlWriter.WriteAttributeString("Lat", Lat.ToString());
                xmlWriter.WriteAttributeString("Lng", Lng.ToString());
            }

            xmlWriter.WriteAttributeString("Constellation", constellation);
            xmlWriter.WriteAttributeString("Classification", Classification.ToString());
            xmlWriter.WriteAttributeString("Magnitude", magnitude.ToString());
            xmlWriter.WriteAttributeString("Distance", distnace.ToString());
            xmlWriter.WriteAttributeString("AngularSize", AngularSize.ToString());
            xmlWriter.WriteAttributeString("ZoomLevel", ZoomLevel.ToString());
            xmlWriter.WriteAttributeString("Rotation", camParams.Rotation.ToString());
            xmlWriter.WriteAttributeString("Angle", camParams.Angle.ToString());
            xmlWriter.WriteAttributeString("Opacity", camParams.Opacity.ToString());
            xmlWriter.WriteAttributeString("Target", Target.ToString());
            xmlWriter.WriteAttributeString("ViewTarget", camParams.ViewTarget.ToString());
            xmlWriter.WriteAttributeString("TargetReferenceFrame", camParams.TargetReferenceFrame);
            xmlWriter.WriteAttributeString("DomeAlt", camParams.DomeAlt.ToString());
            xmlWriter.WriteAttributeString("DomeAz", camParams.DomeAz.ToString());
            xmlWriter.WriteStartElement("Description");
            xmlWriter.WriteCData(HtmlDescription);
            xmlWriter.WriteEndElement();


            if (backgroundImageSet != null)
            {
                xmlWriter.WriteStartElement("BackgroundImageSet");
                ImageSetHelper.SaveToXml(xmlWriter, backgroundImageSet, "");
                xmlWriter.WriteEndElement();
            }

            if (studyImageset != null)
            {
                ImageSetHelper.SaveToXml(xmlWriter, studyImageset, "");
            }
            xmlWriter.WriteEndElement();
        }
        /// <summary> Writes the mapping of all mapped classes of the specified assembly in the specified stream. </summary>
        /// <param name="stream">Where the xml is written.</param>
        /// <param name="assembly">Assembly used to extract user-defined types containing a valid attribute (can be [Class] or [xSubclass]).</param>
        public virtual void Serialize(System.IO.Stream stream, System.Reflection.Assembly assembly)
        {
            if (stream == null)
            {
                throw new System.ArgumentNullException("stream");
            }
            if (assembly == null)
            {
                throw new System.ArgumentNullException("assembly");
            }

            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8);
            writer.Formatting = System.Xml.Formatting.Indented;
            writer.WriteStartDocument();
            if (WriteDateComment)
            {
                writer.WriteComment(string.Format("Generated from NHibernate.Mapping.Attributes on {0}.", System.DateTime.Now.ToString("u")));
            }
            WriteHibernateMapping(writer, null);

            // Write imports (classes decorated with the [ImportAttribute])
            foreach (System.Type type in assembly.GetTypes())
            {
                object[] imports = type.GetCustomAttributes(typeof(ImportAttribute), false);
                foreach (ImportAttribute import in imports)
                {
                    writer.WriteStartElement("import");
                    if (import.Class != null && import.Class != string.Empty)
                    {
                        writer.WriteAttributeString("class", import.Class);
                    }
                    else                     // Assume that it is the current type that must be imported
                    {
                        writer.WriteAttributeString("class", HbmWriterHelper.GetNameWithAssembly(type));
                    }
                    if (import.Rename != null && import.Rename != string.Empty)
                    {
                        writer.WriteAttributeString("rename", import.Rename);
                    }
                    writer.WriteEndElement();
                }
            }

            // Write classes and x-subclasses (classes must come first if inherited by "external" subclasses)
            int classCount = 0;

            System.Collections.ArrayList mappedClassesNames = new System.Collections.ArrayList();
            foreach (System.Type type in assembly.GetTypes())
            {
                if (!IsClass(type))
                {
                    continue;
                }
                HbmWriter.WriteClass(writer, type);
                mappedClassesNames.Add(HbmWriterHelper.GetNameWithAssembly(type));
                classCount++;
            }

            System.Collections.ArrayList subclasses = new System.Collections.ArrayList();
            System.Collections.Specialized.StringCollection extendedClassesNames = new System.Collections.Specialized.StringCollection();
            foreach (System.Type type in assembly.GetTypes())
            {
                if (!IsSubclass(type))
                {
                    continue;
                }
                bool        map = true;
                System.Type t   = type;
                while ((t = t.DeclaringType) != null)
                {
                    if (IsClass(t) || AreSameSubclass(type, t)) // If a base class is also mapped... (Note: A x-subclass can only contain x-subclasses of the same family)
                    {
                        map = false;                            // This class's mapping is already included in the mapping of the base class
                        break;
                    }
                }
                if (map)
                {
                    subclasses.Add(type);
                    if (IsSubclass(type, typeof(SubclassAttribute)))
                    {
                        extendedClassesNames.Add((type.GetCustomAttributes(typeof(SubclassAttribute), false)[0] as SubclassAttribute).Extends);
                    }
                    else if (IsSubclass(type, typeof(JoinedSubclassAttribute)))
                    {
                        extendedClassesNames.Add((type.GetCustomAttributes(typeof(JoinedSubclassAttribute), false)[0] as JoinedSubclassAttribute).Extends);
                    }
                    else if (IsSubclass(type, typeof(UnionSubclassAttribute)))
                    {
                        extendedClassesNames.Add((type.GetCustomAttributes(typeof(UnionSubclassAttribute), false)[0] as UnionSubclassAttribute).Extends);
                    }
                }
            }
            classCount += subclasses.Count;
            MapSubclasses(subclasses, extendedClassesNames, mappedClassesNames, writer);

            writer.WriteEndElement();             // </hibernate-mapping>
            writer.WriteEndDocument();
            writer.Flush();

            if (classCount == 0)
            {
                throw new MappingException("The following assembly contains no mapped classes: " + assembly.FullName);
            }
            if (!Validate)
            {
                return;
            }

            // Validate the generated XML stream
            try
            {
                writer.BaseStream.Position = 0;
                System.Xml.XmlTextReader tr = new System.Xml.XmlTextReader(writer.BaseStream);

                var reader = CreateReader(tr);

                _stop = false;
                while (reader.Read() && !_stop)                // Read to validate (stop at the first error)
                {
                    ;
                }
            }
            catch (System.Exception ex)
            {
                Error.Append(ex.ToString()).Append(System.Environment.NewLine + System.Environment.NewLine);
            }
        }
Example #59
0
        // Constructor
        public Hxc(string name, string title, string langId, string version, string copyright, string outputDirectory, Encoding encoding)
        {
            if (!Directory.Exists(outputDirectory))
            {
                try
                {
                    Directory.CreateDirectory(outputDirectory);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            try
            {
                System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Path.Combine(outputDirectory, name + ".hxc"), null);
                writer.Formatting = Formatting.Indented;
                writer.WriteStartDocument();
                writer.WriteDocType("HelpCollection", null, "MS-Help://Hx/Resources/HelpCollection.dtd", null);

                writer.WriteStartElement("HelpCollection");
                writer.WriteAttributeString("DTDVersion", "1.0");
                writer.WriteAttributeString("FileVersion", version);
                writer.WriteAttributeString("LangId", langId);
                writer.WriteAttributeString("Title", title);
                writer.WriteAttributeString("Copyright", copyright);

                writer.WriteStartElement("CompilerOptions");
                writer.WriteAttributeString("OutputFile", string.Format("{0}{1}", name, ".HxS"));
                writer.WriteAttributeString("CreateFullTextIndex", "Yes");
                writer.WriteAttributeString("CompileResult", "Hxs");
                writer.WriteAttributeString("StopWordFile", "msdnFTSstop_Unicode.stp");

                writer.WriteStartElement("IncludeFile");
                writer.WriteAttributeString("File", string.Format("{0}{1}", name, ".HxF"));
                writer.WriteEndElement();

                writer.WriteEndElement();

                writer.WriteStartElement("TOCDef");
                writer.WriteAttributeString("File", string.Format("{0}{1}", name, ".HxT"));
                writer.WriteEndElement();

                writer.WriteStartElement("KeywordIndexDef");
                writer.WriteAttributeString("File", string.Format("{0}{1}", name, "K.HxK"));
                writer.WriteEndElement();
                writer.WriteStartElement("KeywordIndexDef");
                writer.WriteAttributeString("File", string.Format("{0}{1}", name, "F.HxK"));
                writer.WriteEndElement();
                writer.WriteStartElement("KeywordIndexDef");
                writer.WriteAttributeString("File", string.Format("{0}{1}", name, "N.HxK"));
                writer.WriteEndElement();
                writer.WriteStartElement("KeywordIndexDef");
                writer.WriteAttributeString("File", string.Format("{0}{1}", name, "A.HxK"));
                writer.WriteEndElement();
                writer.WriteStartElement("KeywordIndexDef");
                writer.WriteAttributeString("File", string.Format("{0}{1}", name, "S.HxK"));
                writer.WriteEndElement();
                writer.WriteStartElement("KeywordIndexDef");
                writer.WriteAttributeString("File", string.Format("{0}{1}", name, "B.HxK"));
                writer.WriteEndElement();

                //  <ItemMoniker Name="!DefaultTOC" ProgId="HxDs.HxHierarchy" InitData="AnyString" />
                writer.WriteStartElement("ItemMoniker");
                writer.WriteAttributeString("Name", "!DefaultTOC");
                writer.WriteAttributeString("ProgId", "HxDs.HxHierarchy");
                writer.WriteAttributeString("InitData", "AnyString");
                writer.WriteEndElement();

                //  <ItemMoniker Name="!DefaultFullTextSearch" ProgId="HxDs.HxFullTextSearch" InitData="AnyString" />
                writer.WriteStartElement("ItemMoniker");
                writer.WriteAttributeString("Name", "!DefaultFullTextSearch");
                writer.WriteAttributeString("ProgId", "HxDs.HxFullTextSearch");
                writer.WriteAttributeString("InitData", "AnyString");
                writer.WriteEndElement();

                //  <ItemMoniker Name="!DefaultAssociativeIndex" ProgId="HxDs.HxIndex" InitData="A" />
                writer.WriteStartElement("ItemMoniker");
                writer.WriteAttributeString("Name", "!DefaultAssociativeIndex");
                writer.WriteAttributeString("ProgId", "HxDs.HxIndex");
                writer.WriteAttributeString("InitData", "A");
                writer.WriteEndElement();

                //  <ItemMoniker Name="!DefaultKeywordIndex" ProgId="HxDs.HxIndex" InitData="K" />
                writer.WriteStartElement("ItemMoniker");
                writer.WriteAttributeString("Name", "!DefaultKeywordIndex");
                writer.WriteAttributeString("ProgId", "HxDs.HxIndex");
                writer.WriteAttributeString("InitData", "K");
                writer.WriteEndElement();

                //  <ItemMoniker Name="!DefaultContextWindowIndex" ProgId="HxDs.HxIndex" InitData="F" />
                writer.WriteStartElement("ItemMoniker");
                writer.WriteAttributeString("Name", "!DefaultContextWindowIndex");
                writer.WriteAttributeString("ProgId", "HxDs.HxIndex");
                writer.WriteAttributeString("InitData", "F");
                writer.WriteEndElement();

                //  <ItemMoniker Name="!DefaultNamedUrlIndex" ProgId="HxDs.HxIndex" InitData="NamedUrl" />
                writer.WriteStartElement("ItemMoniker");
                writer.WriteAttributeString("Name", "!DefaultNamedUrlIndex");
                writer.WriteAttributeString("ProgId", "HxDs.HxIndex");
                writer.WriteAttributeString("InitData", "NamedUrl");
                writer.WriteEndElement();

                //  <ItemMoniker Name="!DefaultSearchWindowIndex" ProgId="HxDs.HxIndex" InitData="S" />
                writer.WriteStartElement("ItemMoniker");
                writer.WriteAttributeString("Name", "!DefaultSearchWindowIndex");
                writer.WriteAttributeString("ProgId", "HxDs.HxIndex");
                writer.WriteAttributeString("InitData", "S");
                writer.WriteEndElement();


                //  <ItemMoniker Name="!DefaultDynamicLinkIndex" ProgId="HxDs.HxIndex" InitData="B" />
                writer.WriteStartElement("ItemMoniker");
                writer.WriteAttributeString("Name", "!DefaultDynamicLinkIndex");
                writer.WriteAttributeString("ProgId", "HxDs.HxIndex");
                writer.WriteAttributeString("InitData", "B");
                writer.WriteEndElement();

                writer.WriteEndElement();
                writer.Flush();
                writer.Close();
                writer = null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// GenerateXmlElementFromColumn generate a xml element from column's definition.
        /// </summary>
        /// <param name="schema">schema name,</param>
        /// <param name="table">table name</param>
        /// <param name="c">column</param>
        /// <param name="keepSymbol">whether keep symbol when convert column anme to property name.</param>
        /// <param name="xtw">xml text writer</param>
        /// <param name="elementName">name of the xml element</param>
        /// <param name="sqlOnly">whether only generate the xml attributes that related to sql.</param>
        private static void GenerateXmlElementFromColumn(ColumnInfo column, System.Xml.XmlTextWriter xtw)
        {
            string initialValue, cSharpType, sqlDefaultValue;


            initialValue = "";
            cSharpType   = "";


            #region initial type depended attributes
            switch (GetDataType(column.DataType))
            {
            case SqlDataType.BigInt:
                cSharpType      = "long";
                initialValue    = "0";
                sqlDefaultValue = "0";
                //uiLength = Utility.SafeToString(long.MaxValue).Length + 1;
                break;

            case SqlDataType.Int:
                cSharpType      = "int";
                initialValue    = "0";
                sqlDefaultValue = "0";
                //uiLength = Utility.SafeToString(int.MaxValue).Length + 1;
                break;

            case SqlDataType.SmallInt:
                cSharpType      = "short";
                initialValue    = "0";
                sqlDefaultValue = "0";
                //uiLength = Utility.SafeToString(short.MaxValue).Length + 1;
                break;

            case SqlDataType.TinyInt:
                cSharpType      = "byte";
                initialValue    = "0";
                sqlDefaultValue = "0";
                //uiLength = Utility.SafeToString(byte.MaxValue).Length;
                break;

            case SqlDataType.Bit:
                cSharpType      = "bool";
                initialValue    = "false";
                sqlDefaultValue = "0";
                //uiLength = 5;
                break;

            case SqlDataType.Decimal:
            case SqlDataType.Numeric:
                cSharpType      = "decimal";
                initialValue    = "0M";
                sqlDefaultValue = "0";
                //uiLength = Utility.SafeToString(decimal.MaxValue).Length + 1;
                //sqlType += "(" + c.DataType.NumericPrecision.ToString() + ", " + c.DataType.NumericScale.ToString() + ")";
                break;

            case SqlDataType.Money:
            case SqlDataType.SmallMoney:
                cSharpType      = "decimal";
                initialValue    = "0M";
                sqlDefaultValue = "0";
                //uiLength = Utility.SafeToString(decimal.MaxValue).Length + 1;
                break;

            case SqlDataType.Float:
                cSharpType      = "float";
                initialValue    = "0D";
                sqlDefaultValue = "0";
                //uiLength = Utility.SafeToString(double.MaxValue).Length + 1;
                break;

            case SqlDataType.Real:
                cSharpType      = "float";
                initialValue    = "0F";
                sqlDefaultValue = "0";
                //uiLength = Utility.SafeToString(double.MaxValue).Length + 1;
                break;

            case SqlDataType.DateTime:
            case SqlDataType.SmallDateTime:
                cSharpType      = "DateTime";
                initialValue    = "System.DateTime.MinValue";
                sqlDefaultValue = "null";
                //uiLength = 10;
                break;

            case SqlDataType.UniqueIdentifier:
                cSharpType      = "System.Guid";
                initialValue    = "System.Guid.Empty";
                sqlDefaultValue = "null";
                //uiLength = 32;
                break;

            case SqlDataType.Char:
            case SqlDataType.NChar:
            case SqlDataType.VarChar:
            case SqlDataType.VarCharMax:
            case SqlDataType.NVarChar:
            case SqlDataType.NVarCharMax:
            case SqlDataType.Text:
            case SqlDataType.NText:
                cSharpType      = "string";
                initialValue    = "\"\"";
                sqlDefaultValue = "''''";
                //uiLength = c.DataType.MaximumLength;
                //if (uiLength <= 0) uiLength = 0;
                //if (c.DataType.SqlDataType != SqlDataType.Text
                //    && c.DataType.SqlDataType != SqlDataType.NText)
                //{
                //    if (c.DataType.MaximumLength > 0)
                //        sqlType += "(" + c.DataType.MaximumLength.ToString() + ")";
                //    else
                //    {
                //        sqlType = sqlType.Remove(sqlType.Length - 3) + "(max)";
                //    }
                //}
                break;

            //following SqlDataType are not processed in this version
            case SqlDataType.Binary:
            case SqlDataType.Image:
            case SqlDataType.SysName:
            case SqlDataType.Timestamp:
            case SqlDataType.VarBinary:
            case SqlDataType.VarBinaryMax:
            case SqlDataType.Variant:
            case SqlDataType.Xml:
            case SqlDataType.UserDefinedType:
            case SqlDataType.UserDefinedDataType:
                cSharpType      = "string";
                initialValue    = "\"\"";
                sqlDefaultValue = "''''";
                break;

            default:
                cSharpType      = "string";
                initialValue    = "\"\"";
                sqlDefaultValue = "''''";
                break;
            }

            #endregion

            //#region process nullable
            //if (c.Nullable)
            //{
            //    //if (!type.Equals("string", StringComparison.InvariantCultureIgnoreCase))
            //    //{
            //    //    type = string.Concat(type, "?");
            //    //}
            //    initialValue = "null";
            //    sqlDefaultValue = "null";
            //}
            //#endregion


            #region write xml element
            xtw.WriteStartElement("property");
            xtw.WriteAttributeString("sequence", column.Sequence.ToString());
            xtw.WriteAttributeString("columnName", column.ColumnName);
            xtw.WriteAttributeString("dataType", column.DataType);
            xtw.WriteAttributeString("columnLength", column.ColumnLength.ToString());
            xtw.WriteAttributeString("precisionLength", column.PrecisionLength.ToString());
            xtw.WriteAttributeString("scale", column.Scale.ToString());
            xtw.WriteAttributeString("defaultValue", column.DefaultValue);
            xtw.WriteAttributeString("columnDescription", column.ColumnDescription);
            xtw.WriteAttributeString("isIdentity", column.IsIdentity.ToString(System.Globalization.CultureInfo.InvariantCulture));
            xtw.WriteAttributeString("isPrimaryKey", column.IsPrimaryKey.ToString(System.Globalization.CultureInfo.InvariantCulture));
            xtw.WriteAttributeString("isNullable", column.IsNullable.ToString(System.Globalization.CultureInfo.InvariantCulture));
            xtw.WriteAttributeString("lowerName", column.ColumnName.ToLower());
            xtw.WriteAttributeString("field", string.Concat("_", column.ColumnName.ToLower()));
            if (column.DataType == "nvarchar" || column.DataType == "varchar")
            {
                xtw.WriteAttributeString("sqlParameter", GetParameter(column.DataType, column.PrecisionLength));
            }
            else
            {
                xtw.WriteAttributeString("sqlParameter", GetParameter(column.DataType, column.ColumnLength));
            }
            xtw.WriteAttributeString("csharptype", cSharpType);
            xtw.WriteAttributeString("getMethod", UtilityHelper.GetXxxMethod(column));
            xtw.WriteAttributeString("pattern", UtilityHelper.GetPattern(column.DataType));
            xtw.WriteAttributeString("initialValue", initialValue);
            xtw.WriteEndElement();
            #endregion
        }