WriteRaw() public method

public WriteRaw ( Char buffer, int index, int count ) : void
buffer Char
index int
count int
return void
Example #1
0
        public XmlTextWriter WriteRSSClosing(XmlTextWriter writer)
        {
            /*
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndDocument();
            */

            writer.WriteRaw("\t</channel>" + en);
            writer.WriteRaw("</rss>");

            return writer;
        }
        public void ProcessRequest(HttpContext context)
        {
            string configName = context.Request.QueryString["configuration"];

            _configuration = CodeGenerationSettings.Instance.GetConfiguration(configName);
            context.Response.ContentType = "text/plain";
            using (XmlTextWriter writer = new XmlTextWriter(context.Response.OutputStream, Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                writer.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
                writer.WriteStartElement("namespaces");
                _templates = _configuration.GetTemplateSettings().ToDictionary(t => t.Path);

                foreach (var nameSpace in _templates.Values.GroupBy(c => c.NameSpace))
                {
                    writer.WriteStartElement("namespace");
                    writer.WriteAttributeString("name", nameSpace.Key);

                    foreach (var template in nameSpace)
                        WriteTemplate(template, writer);

                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
        }
Example #3
0
        public void Save(string fileName)
        {
            if (this.Messages.Count == 0 || string.IsNullOrEmpty(fileName)) return;
            if (File.Exists(fileName)) File.Delete(fileName);

            var xml = new XmlDocument();
            xml.AppendChild(xml.CreateXmlDeclaration(this.Declaration.Version, this.Declaration.Encoding, this.Declaration.Standalone));
            xml.AppendChild(xml.CreateProcessingInstruction(this.Xsl.Target, this.Xsl.Data));

            var root = xml.CreateElement("Log");
            root.SetAttribute("FirstSessionID", this.Messages[0].SessionID.ToString());
            root.SetAttribute("LastSessionID", this.Messages[this.Messages.Count - 1].SessionID.ToString());

            xml.AppendChild(root);
            this.Messages.ForEach(messageNode =>
                {
                    var nodeName = messageNode.GetType().Name.Replace("Msn", string.Empty);
                    var newNode = xml.CreateElement(nodeName);
                    root.AppendChild(messageNode.GenerateXmlNode(newNode));
                });

            var writer = new XmlTextWriter(fileName, Encoding.UTF8);
            writer.WriteRaw(xml.OuterXml);
            writer.Flush();
            writer.Close();
        }
Example #4
0
        private void GenerateDescription(string host = null)
        {
            MemoryStream memStream = new MemoryStream();
            using (XmlTextWriter descWriter = new XmlTextWriter(memStream, new UTF8Encoding(false)))
            {
                descWriter.Formatting = Formatting.Indented;
                descWriter.WriteRaw("<?xml version=\"1.0\"?>");

                descWriter.WriteStartElement("root", "urn:schemas-upnp-org:device-1-0");

                descWriter.WriteStartElement("specVersion");
                descWriter.WriteElementString("major", "1");
                descWriter.WriteElementString("minor", "0");
                descWriter.WriteEndElement();

                descWriter.WriteStartElement("device");
                rootDevice.WriteDescription(descWriter, host);
                descWriter.WriteEndElement();

                descWriter.WriteEndElement();

                descWriter.Flush();
                descArray = memStream.ToArray();
            }
        }
Example #5
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();
        }
 public void WriteSalesReports(string reports)
 {
     using (var writer = new XmlTextWriter(this.Path, null))
     {
         writer.WriteStartDocument();
         writer.WriteRaw(Environment.NewLine + reports);
     }
 }
Example #7
0
 internal void StartLog(string logFile, string xslPath)
 {
     m_logFile = logFile;
     m_xmlWriter = new XmlTextWriter(logFile, Encoding.UTF8);
     m_xmlWriter.Formatting = Formatting.Indented;
     m_xmlWriter.WriteStartDocument();
     m_xmlWriter.WriteRaw("<?xml-stylesheet type=\"text/xsl\" href=\"" + xslPath + "\"?>");
     m_xmlWriter.WriteStartElement("SPOT_Platform_Test");
 }
Example #8
0
        public static void Cut()
        {
            var xml = "";
            using (var reader = XmlReader.Create("company.xml"))
            {
                while (reader.Read())
                {
                    if (!String.IsNullOrEmpty(reader.Name))
                    {
                        var el = @"<";
                        switch (reader.NodeType)
                        {
                            case XmlNodeType.EndElement:
                                el += @"/" + reader.Name;
                                break;
                            case XmlNodeType.Element:
                            case XmlNodeType.XmlDeclaration:
                                el += reader.Name;
                                break;
                        }

                        if (reader.AttributeCount > 0)
                        {
                            el += " ";
                            while (reader.MoveToNextAttribute())
                            {
                                var a = string.Format("{0}={1}", reader.Name, reader.Value);
                                el += a;
                            }
                            xml += el + @">";
                        }
                        else
                        {
                            xml += el + reader.Value + @">";
                        }
                        if (reader.Name == "Salary")
                        {
                            if (reader.Read())
                            {
                                var s = reader.ReadContentAsDecimal() / 2;
                                xml += s + @"</Salary>";
                            }
                        }
                    }
                    else
                    {
                        xml += reader.Value;
                    }
                }
            }

            using (var tw = new XmlTextWriter("company1.xml", Encoding.UTF8))
            {
                tw.WriteRaw(xml);
            }
        }
        public void OpenMetadataDoc(string urlMetadataDoc)
        {
            string tmpInput = GenerateTempFilename("Meta", "xml");
            XmlWriter pXWriter = new XmlTextWriter(tmpInput, Encoding.UTF8);
            pXWriter.WriteRaw(GetMetadataDoc(urlMetadataDoc));
            pXWriter.Close();

            string tmpOutput = XmlTransform(tmpInput);
            webBrowserMetadata.Navigate(tmpOutput);
        }
        private void WriteBody(XmlTextWriter xml)
        {
            xml.WriteStartElement("Body");

            xml.WriteStartElement("Content");
            xml.WriteRaw(this.Definition.Body);
            xml.WriteEndElement();

            this.WriteGridViews(xml);
            xml.WriteEndElement();
        }
        /// <summary>
        /// Dump layout and visual tree starting from specified root.
        /// </summary>
        /// <param name="writer">Stream for dump output.</param>
        /// <param name="tagName">Name of the root XML element.</param>
        /// <param name="root">Root of the visual subtree.</param>
        internal static void DumpLayoutAndVisualTree(XmlTextWriter writer, string tagName, Visual root)
        {
            // Write root element
            writer.WriteStartElement(tagName);

            // Dump layout tree including all visuals
            DumpVisual(writer, root, root);

            // Write end root
            writer.WriteEndElement();
            writer.WriteRaw("\r\n");  // required for bbpack
        }
Example #12
0
		public string RenderAsHtml ()
		{
			StringWriter sw = new StringWriter ();
			XmlWriter w = new XmlTextWriter (sw);
			if (HelpSource.use_css)
				w.WriteRaw ("<div class=\"header\" id=\"error_ref\">" +
				"	<div class=\"subtitle\">Compiler Error Reference</div> " +
				"	<div class=\"title\">Error " + ErrorName + " </div></div>");
			else
			w.WriteRaw (@"
				
				<table width='100%'>
					<tr bgcolor='#b0c4de'><td>
					<i>Compiler Error Reference</i>
					<h3>Error " + ErrorName + @"</h2>
					</td></tr>
				</table><br />");
			
			
			if (Details != null) {
				if (HelpSource.use_css)
					w.WriteRaw ("<div class=\"summary\">Summary</div>");
				else
				w.WriteRaw (@"<h3>Summary</h3>");
				Details.Summary.WriteTo (w);
				
				if (HelpSource.use_css)
					w.WriteRaw ("<div class=\"details\">Details</div>");
				else
				w.WriteRaw (@"<h3>Details</h3>");

				Details.Details.WriteTo (w);
			}
			
			foreach (string xmp in Examples) {
				if (HelpSource.use_css)
					w.WriteRaw ("<div class=\"code_example\">" +
						"<div class=\"code_ex_title\">Example</div>");
				else
				w.WriteRaw (@"<table bgcolor='#f5f5dd' border='1'>
						<tr><td><b><font size='-1'>Example</font></b></td></tr>
						<tr><td><font size='-1'><pre>");
				w.WriteRaw (Mono.Utilities.Colorizer.Colorize (xmp, "c#"));
				if (HelpSource.use_css)
					w.WriteRaw ("</div>");
				else
				w.WriteRaw (@"</pre></font></td></tr></table>");
			}
			
			w.Close ();
			
			return sw.ToString ();
		}
Example #13
0
        public XmlTextWriter WriteRSSPrologue(XmlTextWriter writer, pages.ForumPage page)
        {
            /*
                writer.WriteStartDocument();
                writer.WriteStartElement("rss");
                writer.WriteAttributeString("version", "2.0");
                writer.WriteStartElement("channel");
                writer.WriteElementString("title", "RSS File for " + page.ForumURL);
                writer.WriteElementString("link", page.ForumURL);
                writer.WriteElementString("description", "Yet Another Forum Web Application");
                writer.WriteElementString("copyright", "Copyright 2002-2004 Bjørnar Henden");
            */

            writer.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + en);
            writer.WriteRaw("<?xml-stylesheet type=\"text/xsl\" href=\"rss.xsl\" media=\"screen\"?>");
            writer.WriteRaw("<rss version=\"2.0\">" + en);
            writer.WriteRaw("\t<channel>" + en);
            writer.WriteRaw("\t\t<title>RSS Feed for " + page.ServerURL + "</title>" + en);
            writer.WriteRaw("\t\t<link>" + Encode(page.ForumURL) + "</link>" + en);
            writer.WriteRaw("\t\t<description>Yet Another Forum Web Application RSS Feed</description>" + en);
            writer.WriteRaw("\t\t<copyright>Copyright 2002 - 2005 Bjørnar Henden</copyright>" + en);

            return writer;
        }
Example #14
0
        public String ToXML()
        {
            System.IO.StringWriter XMLsw = new System.IO.StringWriter();
            XmlTextWriter XMLtw = new XmlTextWriter(XMLsw);

            XMLtw.Formatting = Formatting.Indented;
            XMLtw.WriteStartElement("hackset");
            XMLtw.WriteStartElement("hackvalues");
            for (int x=0; x < HackValues.Length; x++)
            {
                XMLtw.WriteRaw(HackValues[x].ToXML());
            }
            XMLtw.WriteEndElement();
            XMLtw.WriteEndElement();
            return XMLsw.ToString();
        }
Example #15
0
        private void WriteXML()
        {
            string xml = "<?xml version=\"1.0\" standalone=\"yes\"?>"+ Environment.NewLine +"<users>" + Environment.NewLine;
            foreach (XmlUser user in users)
            {
                xml += "<user>" + Environment.NewLine;
                xml += "<name>" + user.Name + "</name>" + Environment.NewLine;
                xml += "<email>" + user.Email + "</email>" + Environment.NewLine;
                xml += "</user>" + Environment.NewLine;
            }
            xml += "</users>" +Environment.NewLine;

            XmlTextWriter writer = new XmlTextWriter(Server.MapPath("/App_Data/XmlInjectionUsers.xml"), Encoding.UTF8);
            writer.WriteRaw(xml);
            writer.Close();
        }
Example #16
0
 public static void CreatXml(string XmlFileName)
 {
     try
     {
         System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(XmlFileName, System.Text.Encoding.GetEncoding("utf-8"));
         writer.Formatting = System.Xml.Formatting.Indented;
         writer.WriteRaw("<System Parameter Save>");
         writer.WriteStartElement("Config");
         //writer.WriteEndElement()
         writer.WriteFullEndElement();
         writer.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
     }
 }
Example #17
0
        public static string ToXML(string path)
        {
            DirectoryInfo di = new DirectoryInfo(path);
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);

            XmlTextWriter writer = new XmlTextWriter(sw);
            writer.Formatting = Formatting.Indented;
            writer.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            writer.WriteStartElement("theme");

            DirectoryToXML(di,writer);

            writer.WriteEndElement();

            return sb.ToString();
        }
Example #18
0
 public override string ToString()
 {
     var sw = new System.IO.StringWriter();
     using (XmlTextWriter writer = new XmlTextWriter(sw))
     {
         writer.Formatting = Formatting.Indented;
         writer.Indentation = 4;
         writer.WriteStartElement("Step");
         writer.WriteElementString("Enable", Enable.ToString());
         writer.WriteElementString("Comment", Comment);
         writer.WriteElementString("OnFailureLable", OnFailureLabel);
         writer.WriteRaw(Action.ToString());
         writer.WriteEndElement();
     }
     string retval = sw.ToString();
     sw.Close();
     sw.Dispose();
     return retval;
 }
        public string GetXml()
        {
            using (var strXML = new StringWriter())
            {
                using (var xmlWriter = new XmlTextWriter(strXML))
                {
                    xmlWriter.Formatting = Formatting.Indented;
                    xmlWriter.WriteStartElement("moduletemplate");
                    xmlWriter.WriteAttributeString("title", Name);
                    xmlWriter.WriteAttributeString("description", Description);
                    xmlWriter.WriteAttributeString("xmlns", "ask", null, "DotNetNuke/ModuleTemplate");
                    xmlWriter.WriteRaw(ExportContent);
                    xmlWriter.WriteEndElement();
                    xmlWriter.Close();
                }

                return strXML.ToString();
            }
        }
 private void CopyXmlTree(XmlNode node, XmlTextWriter writer)
 {
     if (node.NodeType == XmlNodeType.Element)
     {
         writer.WriteStartElement(node.LocalName, "urn:oasis:names:tc:DSML:2:0:core");
         foreach (XmlAttribute attribute in node.Attributes)
         {
             writer.WriteAttributeString(attribute.LocalName, attribute.Value);
         }
         for (XmlNode node2 = node.FirstChild; node2 != null; node2 = node2.NextSibling)
         {
             this.CopyXmlTree(node2, writer);
         }
         writer.WriteEndElement();
     }
     else
     {
         writer.WriteRaw(node.OuterXml);
     }
 }
        //  The track method is called whenever the workflow runtime emits a tracking record
        protected override void Track(TrackingRecord record, TimeSpan timeout)
        {
            try
            {

                using (FileStream fs = new FileStream(Environment.ExpandEnvironmentVariables(Path), FileMode.Append))
                {
                    XmlTextWriter writer = new XmlTextWriter(fs, ASCIIEncoding.ASCII) { Formatting = Formatting.Indented };
                    DataContractSerializer serializer = new DataContractSerializer(record.GetType());
                    serializer.WriteObject(writer, record);
                    writer.WriteRaw(Environment.NewLine);
                    writer.Flush();
                    fs.Flush();
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(String.Format(CultureInfo.InvariantCulture, "Exception in track method {0}", e.Message));
            }
        }
Example #22
0
	private void WriteClasses () {
		string fileName = Path.Combine (DestinationDir, "output.xml");
		writer = new XmlTextWriter (fileName, Encoding.ASCII);
		writer.Formatting = Formatting.Indented;
		writer.WriteStartDocument ();
		WriteStyleSheet ();
		
		writer.WriteStartElement ("classes");
		foreach (ClassCoverageItem item in model.Classes.Values) 
		{
			if (!item.filtered || !(item.hit + item.missed == 0))
			{
				WriteClass (item);
			}
		}
		writer.WriteEndElement();

		writer.WriteEndDocument ();
		writer.WriteRaw ("\n");
		writer.Close ();
	}
Example #23
0
 public override string ToString()
 {
     var sw = new System.IO.StringWriter();
     using (XmlTextWriter writer = new XmlTextWriter(sw))
     {
         writer.Formatting = Formatting.Indented;
         writer.Indentation = 4;
         writer.WriteStartDocument();
         writer.WriteStartElement("Test");
         //writer.WriteElementString("Enable", Enable.ToString());
         writer.WriteElementString("Description", Description);
         writer.WriteStartElement("Scripts");
         foreach (TestEntity entity in Entities)
             writer.WriteRaw(entity.ToString());
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.WriteEndDocument();
     }
     string retval = sw.ToString().Replace("utf-16", "utf-8"); ;
     sw.Close();
     sw.Dispose();
     return retval;
 }
Example #24
0
		private StreamReader TransformHtmlToXml()
		{
			XmlTextWriter writer = null; 
			TextReader reader = null;

			try
			{
				reader = new StreamReader( File.OpenRead( _hhcPath ) );

				Stream xml = new MemoryStream();
				writer = new XmlTextWriter( xml, Encoding.UTF8 );

				writer.WriteStartDocument();

				string line = reader.ReadLine();
				while ( line != null )
				{
					string newLine = TransformLine( line );

					if ( newLine.Length > 0 )
						writer.WriteRaw( newLine );

					line = reader.ReadLine();
				}

				writer.Flush();

				xml.Seek( 0, SeekOrigin.Begin );
			
				return new StreamReader( xml );
			}
			finally
			{
				if ( reader != null )
					reader.Close();
			}
		}
        private void DoCreateXSD()
        {
            string xsdOutput = string.Empty;
            try
            {
                Xml2Xsd xsd = new Xml2Xsd(_xmlDoc.NameTable);
                xsdOutput = xsd.BuildXSD(_xmlDoc.OuterXml, NestingType.SeparateComplexTypes);

                // create XSD file from string
                System.Xml.XmlTextWriter xw = new XmlTextWriter(_fileName, System.Text.Encoding.UTF8);
                xw.WriteRaw(xsdOutput);
                xw.Close();
            }
            catch (Exception ex)
            {
                logger.Error(SQLSchemaTool.ERRORFORMAT, ex.Message, ex.Source, ex.StackTrace);
            }

            // Stop if cancellation was requested
            if (!CancelRequested)
            {
                OnCreateXSD(_fileName);
            }
        }
Example #26
0
        public XmlTextWriter AddRSSItem(XmlTextWriter writer, string sItemTitle, string sItemLink, string sItemDescription, string sPubDate)
        {
            /*
                writer.WriteStartElement("item");
                writer.WriteElementString("title", sItemTitle);
                writer.WriteElementString("link", sItemLink);
                writer.WriteElementString("description", sItemDescription);
                writer.WriteElementString("pubDate", DateTime.Now.ToString("r"));
                writer.WriteEndElement();
            */

            writer.WriteRaw("\t\t<item>" + en);
            writer.WriteRaw("\t\t\t<title>" + Encode(sItemTitle) + "</title>" + en);
            writer.WriteRaw("\t\t\t<link>" + Encode(sItemLink) + "</link>" + en);
            writer.WriteRaw("\t\t\t<description><![CDATA[" + sItemDescription + "]]></description>" + en);
            writer.WriteRaw("\t\t\t<pubDate>" + sPubDate + "</pubDate>" + en);
            writer.WriteRaw("\t\t</item>" + en);

            return writer;
        }
        //Marked for deletion
        public void SaveScriptedState(XmlTextWriter writer)
        {
            XmlDocument doc = new XmlDocument();
            Dictionary<UUID,string> states = new Dictionary<UUID,string>();

            // Capture script state while holding the lock
            lock (m_partsLock)
            {
                foreach (SceneObjectPart part in m_partsList)
                {
                    Dictionary<UUID,string> pstates = part.Inventory.GetScriptStates();
                    foreach (UUID itemid in pstates.Keys)
                    {
                        states.Add(itemid, pstates[itemid]);
                    }
                }
            }

            if (states.Count > 0)
            {
                // Now generate the necessary XML wrappings
                writer.WriteStartElement(String.Empty, "GroupScriptStates", String.Empty);
                foreach (UUID itemid in states.Keys)
                {
                    doc.LoadXml(states[itemid]);
                    writer.WriteStartElement(String.Empty, "SavedScriptState", String.Empty);
                    writer.WriteAttributeString(String.Empty, "UUID", String.Empty, itemid.ToString());
                    writer.WriteRaw(doc.DocumentElement.OuterXml); // Writes ScriptState element
                    writer.WriteEndElement(); // End of SavedScriptState
                }
                writer.WriteEndElement(); // End of GroupScriptStates
            }
        }
        private void WriteCondition(TrackingCondition condition, XmlTextWriter writer)
        {
            if (null == condition)
                return;

            writer.WriteStartElement(condition.GetType().Name);

            writer.WriteElementString("Operator", condition.Operator.ToString());

            if ((null == condition.Member) || (0 == condition.Member.Trim().Length))
                throw new ArgumentException(ExecutionStringManager.MissingMemberName);

            writer.WriteElementString("Member", condition.Member);

            if (null != condition.Value)
            {
                if (string.Empty == condition.Value)
                {
                    writer.WriteStartElement("Value");
                    writer.WriteRaw(string.Empty);
                    writer.WriteEndElement();
                }
                else
                    writer.WriteElementString("Value", condition.Value);
            }

            writer.WriteEndElement();
        }
Example #29
0
        private void CreateReportFiles(Dictionary<string, PictureInformation> listPhotosWithInfo, string dirWithImages, float offset)
        {
            // Write report files
            Document kml = new Document();

            // Clear Stations IDs
            JXL_StationIDs.Clear();

            using (StreamWriter swlogloccsv = new StreamWriter(dirWithImages + Path.DirectorySeparatorChar + "loglocation.csv")) 
            using (StreamWriter swlockml = new StreamWriter(dirWithImages + Path.DirectorySeparatorChar + "location.kml"))
            using (StreamWriter swloctxt = new StreamWriter(dirWithImages + Path.DirectorySeparatorChar + "location.txt"))
            using (StreamWriter swloctel = new StreamWriter(dirWithImages + Path.DirectorySeparatorChar + "location.tel"))
            using (XmlTextWriter swloctrim = new XmlTextWriter(dirWithImages + Path.DirectorySeparatorChar + "location.jxl", Encoding.ASCII))
            {
                swloctrim.Formatting = Formatting.Indented;
                swloctrim.WriteStartDocument(false);
                swloctrim.WriteStartElement("JOBFile");
                swloctrim.WriteAttributeString("jobName", "MPGeoRef");
                swloctrim.WriteAttributeString("product", "Gatewing");
                swloctrim.WriteAttributeString("productVersion", "1.0");
                swloctrim.WriteAttributeString("version", "5.6");
                // enviro
                swloctrim.WriteStartElement("Environment");
                swloctrim.WriteStartElement("CoordinateSystem");
                swloctrim.WriteElementString("SystemName", "Default");
                swloctrim.WriteElementString("ZoneName", "Default");
                swloctrim.WriteElementString("DatumName", "WGS 1984");
                swloctrim.WriteStartElement("Ellipsoid");
                swloctrim.WriteElementString("EarthRadius", "6378137");
                swloctrim.WriteElementString("Flattening", "0.00335281067183");
                swloctrim.WriteEndElement();
                swloctrim.WriteStartElement("Projection");
                swloctrim.WriteElementString("Type", "NoProjection");
                swloctrim.WriteElementString("Scale", "1");
                swloctrim.WriteElementString("GridOrientation", "IncreasingNorthEast");
                swloctrim.WriteElementString("SouthAzimuth", "false");
                swloctrim.WriteElementString("ApplySeaLevelCorrection", "true");
                swloctrim.WriteEndElement();
                swloctrim.WriteStartElement("LocalSite");
                swloctrim.WriteElementString("Type", "Grid");
                swloctrim.WriteElementString("ProjectLocationLatitude", "");
                swloctrim.WriteElementString("ProjectLocationLongitude", "");
                swloctrim.WriteElementString("ProjectLocationHeight", "");
                swloctrim.WriteEndElement();
                swloctrim.WriteStartElement("Datum");
                swloctrim.WriteElementString("Type", "ThreeParameter");
                swloctrim.WriteElementString("GridName", "WGS 1984");
                swloctrim.WriteElementString("Direction", "WGS84ToLocal");
                swloctrim.WriteElementString("EarthRadius", "6378137");
                swloctrim.WriteElementString("Flattening", "0.00335281067183");
                swloctrim.WriteElementString("TranslationX", "0");
                swloctrim.WriteElementString("TranslationY", "0");
                swloctrim.WriteElementString("TranslationZ", "0");
                swloctrim.WriteEndElement();
                swloctrim.WriteStartElement("HorizontalAdjustment");
                swloctrim.WriteElementString("Type", "NoAdjustment");
                swloctrim.WriteEndElement();
                swloctrim.WriteStartElement("VerticalAdjustment");
                swloctrim.WriteElementString("Type", "NoAdjustment");
                swloctrim.WriteEndElement();
                swloctrim.WriteStartElement("CombinedScaleFactor");
                swloctrim.WriteStartElement("Location");
                swloctrim.WriteElementString("Latitude", "");
                swloctrim.WriteElementString("Longitude", "");
                swloctrim.WriteElementString("Height", "");
                swloctrim.WriteEndElement();
                swloctrim.WriteElementString("Scale", "");
                swloctrim.WriteEndElement();

                swloctrim.WriteEndElement();
                swloctrim.WriteEndElement();

                // fieldbook
                swloctrim.WriteStartElement("FieldBook");

                swloctrim.WriteRaw(@"   <CameraDesignRecord ID='00000001'>
                                      <Type>GoPro   </Type>
                                      <HeightPixels>2400</HeightPixels>
                                      <WidthPixels>3200</WidthPixels>
                                      <PixelSize>0.0000022</PixelSize>
                                      <LensModel>Rectilinear</LensModel>
                                      <NominalFocalLength>0.002</NominalFocalLength>
                                    </CameraDesignRecord>
                                    <CameraRecord2 ID='00000002'>
                                      <CameraDesignID>00000001</CameraDesignID>
                                      <CameraPosition>01</CameraPosition>
                                      <Optics>
                                        <IdealAngularMagnification>1.0</IdealAngularMagnification>
                                        <AngleSymmetricDistortion>
                                          <Order3>-0.35</Order3>
                                          <Order5>0.15</Order5>
                                          <Order7>-0.033</Order7>
                                          <Order9> 0</Order9>
                                        </AngleSymmetricDistortion>
                                        <AngleDecenteringDistortion>
                                          <Column>0</Column>
                                          <Row>0</Row>
                                        </AngleDecenteringDistortion>
                                      </Optics>
                                      <Geometry>
                                        <PerspectiveCenterPixels>
                                          <PrincipalPointColumn>-1615.5</PrincipalPointColumn>
                                          <PrincipalPointRow>-1187.5</PrincipalPointRow>
                                          <PrincipalDistance>-2102</PrincipalDistance>
                                        </PerspectiveCenterPixels>
                                        <VectorOffset>
                                          <X>0</X>
                                          <Y>0</Y>
                                          <Z>0</Z>
                                        </VectorOffset>
                                        <BiVectorAngle>
                                          <XX>0</XX>
                                          <YY>0</YY>
                                          <ZZ>-1.5707963268</ZZ>
                                        </BiVectorAngle>
                                      </Geometry>
                                    </CameraRecord2>");

                // 2mm fl
                // res 2400 * 3200 = 7,680,000
                // sensor size = 1/2.5" - 5.70 × 4.28 mm
                // 2.2 μm
                // fl in pixels = fl in mm * res / sensor size

                swloctrim.WriteStartElement("PhotoInstrumentRecord");
                swloctrim.WriteAttributeString("ID", "0000000E");
                swloctrim.WriteElementString("Type", "Aerial");
                swloctrim.WriteElementString("Model", "X100");
                swloctrim.WriteElementString("Serial", "000-000");
                swloctrim.WriteElementString("FirmwareVersion", "v0.0");
                swloctrim.WriteElementString("UserDefinedName", "Prototype");
                swloctrim.WriteEndElement();

                swloctrim.WriteStartElement("AtmosphereRecord");
                swloctrim.WriteAttributeString("ID", "0000000F");
                swloctrim.WriteElementString("Pressure", "");
                swloctrim.WriteElementString("Temperature", "");
                swloctrim.WriteElementString("PPM", "");
                swloctrim.WriteElementString("ApplyEarthCurvatureCorrection", "false");
                swloctrim.WriteElementString("ApplyRefractionCorrection", "false");
                swloctrim.WriteElementString("RefractionCoefficient", "0");
                swloctrim.WriteElementString("PressureInputMethod", "ReadFromInstrument");
                swloctrim.WriteEndElement();

                swloctel.WriteLine("version=1");

                swloctel.WriteLine("#seconds offset - " + offset);
                swloctel.WriteLine("#longitude and latitude - in degrees");
                swloctel.WriteLine("#name	utc	longitude	latitude	height");

                swloctxt.WriteLine("#name longitude/X latitude/Y height/Z yaw pitch roll");

                TXT_outputlog.AppendText("Start Processing\n");

                // Dont know why but it was 10 in the past so let it be. Used to generate jxl file simulating x100 from trimble
                int lastRecordN = JXL_ID_OFFSET;

                // path
                CoordinateCollection coords = new CoordinateCollection();

                foreach (var item in vehicleLocations.Values)
                {
                    coords.Add(new SharpKml.Base.Vector(item.Lat, item.Lon, item.AltAMSL));
                }

                var ls = new LineString() { Coordinates = coords, AltitudeMode = AltitudeMode.Absolute };

                SharpKml.Dom.Placemark pm = new SharpKml.Dom.Placemark() { Geometry = ls, Name = "path" };

                kml.AddFeature(pm);


                foreach (PictureInformation picInfo in listPhotosWithInfo.Values)
                {
                    string filename = Path.GetFileName(picInfo.Path);
                    string filenameWithoutExt = Path.GetFileNameWithoutExtension(picInfo.Path);

                    SharpKml.Dom.Timestamp tstamp = new SharpKml.Dom.Timestamp();

                    tstamp.When = picInfo.Time;

                    kml.AddFeature(

                        new Placemark()
                        {
                            Time = tstamp,
                            Visibility = true,
                            Name = filenameWithoutExt,
                            Geometry = new SharpKml.Dom.Point()
                            {
                                Coordinate = new Vector(picInfo.Lat, picInfo.Lon, picInfo.AltAMSL),
                                 AltitudeMode = AltitudeMode.Absolute
                            },
                            Description = new Description()
                            {
                                Text = "<table><tr><td><img src=\"" + filename.ToLower() + "\" width=500 /></td></tr></table>"
                            },
                            StyleSelector = new Style()
                            {
                                Balloon = new BalloonStyle() { Text = "$[name]<br>$[description]" }
                            }
                        }
                    );

                    double lat = picInfo.Lat;
                    double lng = picInfo.Lon;
                    double alpha = picInfo.Yaw + (double)num_camerarotation.Value;;

                    RectangleF rect = getboundingbox(lat, lng, alpha, (double)num_hfov.Value, (double)num_vfov.Value);

                    Console.WriteLine(rect);

                    //http://en.wikipedia.org/wiki/World_file
                    /* using (StreamWriter swjpw = new StreamWriter(dirWithImages + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(filename) + ".jgw"))
                        {
                            swjpw.WriteLine((rect.Height / 2448.0).ToString("0.00000000000000000"));
                            swjpw.WriteLine((0).ToString("0.00000000000000000")); // 
                            swjpw.WriteLine((0).ToString("0.00000000000000000")); //
                            swjpw.WriteLine((rect.Width / -3264.0).ToString("0.00000000000000000")); // distance per pixel
                            swjpw.WriteLine((rect.Left).ToString("0.00000000000000000"));
                            swjpw.WriteLine((rect.Top).ToString("0.00000000000000000"));

                            swjpw.Close();
                        }*/
                    
                    kml.AddFeature(
                        new GroundOverlay()
                        {
                            Name = filenameWithoutExt,
                            Visibility = false,
                            Time = tstamp,
                            AltitudeMode = AltitudeMode.ClampToGround,
                            Bounds = new LatLonBox()
                            {
                                Rotation = -alpha % 360,
                                North = rect.Bottom,
                                East = rect.Right,
                                West = rect.Left,
                                South = rect.Top,
                            },
                            Icon = new SharpKml.Dom.Icon()
                            {
                                Href = new Uri(filename.ToLower(), UriKind.Relative),
                            },
                        }
                    );

                    swloctxt.WriteLine(filename + " " + picInfo.Lat + " " + picInfo.Lon + " " + picInfo.getAltitude(useAMSLAlt) + " " + picInfo.Yaw + " " + picInfo.Pitch + " " + picInfo.Roll);


                    swloctel.WriteLine(filename + "\t" + picInfo.Time.ToString("yyyy:MM:dd HH:mm:ss") + "\t" + picInfo.Lon + "\t" + picInfo.Lat + "\t" + picInfo.getAltitude(useAMSLAlt));
                    swloctel.Flush();
                    swloctxt.Flush();

                    lastRecordN = GenPhotoStationRecord(swloctrim, picInfo.Path, picInfo.Lat, picInfo.Lon, picInfo.getAltitude(useAMSLAlt), 0, 0, picInfo.Yaw, picInfo.Width, picInfo.Height, lastRecordN);

                    log.InfoFormat(filename + " " + picInfo.Lon + " " + picInfo.Lat + " " + picInfo.getAltitude(useAMSLAlt) + "           ");
                }

                Serializer serializer = new Serializer();
                serializer.Serialize(kml);
                swlockml.Write(serializer.Xml);

                Utilities.httpserver.georefkml = serializer.Xml;
                Utilities.httpserver.georefimagepath = dirWithImages + Path.DirectorySeparatorChar;

                writeGPX(dirWithImages + Path.DirectorySeparatorChar + "location.gpx", listPhotosWithInfo);

                // flightmission
                GenFlightMission(swloctrim, lastRecordN);

                swloctrim.WriteEndElement(); // fieldbook
                swloctrim.WriteEndElement(); // job
                swloctrim.WriteEndDocument();

                TXT_outputlog.AppendText("Done \n\n");

            }
        }
        /// <summary>
        /// Create and configure the organization service proxy.        
        /// Download the report definition.        
        /// Optionally delete any entity records that were created for this sample.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig, bool promptForDelete)
        {
            try
            {

                // Connect to the Organization service. 
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();

                    // Call the method to create any data that this sample requires.
                    CreateRequiredRecords();

                    //<snippetDownloadReportDefinition1>

                    // Query for an an existing report: Account Overview. This is a default report in Microsoft Dynamics CRM.				    
                    QueryByAttribute reportQuery = new QueryByAttribute(Report.EntityLogicalName);
                    reportQuery.AddAttributeValue("name", "Account Overview");
                    reportQuery.ColumnSet = new ColumnSet("reportid");
                    
				    // Get the report.
				    EntityCollection retrieveReports = _serviceProxy.RetrieveMultiple(reportQuery);
				
				    // Convert retrieved Entity to a report
				    Report retrievedReport = (Report)retrieveReports.Entities[0];
                    Console.WriteLine("Retrieved the 'Account Overview' report.");
				
				    // Use the Download Report Definition message.
				    DownloadReportDefinitionRequest rdlRequest = new DownloadReportDefinitionRequest
				    {
                        ReportId = retrievedReport.ReportId.Value
                    };

				    DownloadReportDefinitionResponse rdlResponse = (DownloadReportDefinitionResponse)_serviceProxy.Execute(rdlRequest);

                    // Get the current directory path.
                    _currentDirectoryPath = Directory.GetCurrentDirectory();

				    // Access the xml data and save to disk
				    XmlTextWriter reportDefinitionFile = new XmlTextWriter( _currentDirectoryPath + "\\NewReport.rdl", System.Text.Encoding.UTF8);
				    reportDefinitionFile.WriteRaw(rdlResponse.BodyText);
				    reportDefinitionFile.Close();

                    if (File.Exists(_currentDirectoryPath + "\\NewReport.rdl"))
				    {
                        Console.WriteLine("Downloaded the report definition (NewReport.rdl) to '{0}'.", _currentDirectoryPath.ToString());
				    }				

                    //</snippetDownloadReportDefinition1>

                    DeleteRequiredRecords(promptForDelete);
                }
            }
            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
Example #31
0
        /// <summary>
        /// Returns byte[] representation of xml table.
        /// </summary>
        /// <returns>Returns byte[] representation of xml table.</returns>
        public byte[] ToByteData()
        {
            MemoryStream ms = new MemoryStream();
            XmlTextWriter wr = new XmlTextWriter(ms,Encoding.UTF8);

            // Write table start
            wr.WriteStartElement(m_TableName);
            wr.WriteRaw("\r\n");

            // Write elements
            foreach(DictionaryEntry entry in m_pValues){
                wr.WriteRaw("\t");
                wr.WriteStartElement(entry.Key.ToString());

                wr.WriteValue(entry.Value.ToString());

                wr.WriteEndElement();
                wr.WriteRaw("\r\n");
            }

            // Write table end
            wr.WriteEndElement();
            wr.Flush();

            return ms.ToArray();
        }
Example #32
0
		void Save (Stream stream, ConfigurationSaveMode mode, bool forceUpdateAll)
		{
			XmlTextWriter tw = new XmlTextWriter (new StreamWriter (stream));
			tw.Formatting = Formatting.Indented;
			try {
				tw.WriteStartDocument ();
				if (rootNamespace != null)
					tw.WriteStartElement ("configuration", rootNamespace);
				else
					tw.WriteStartElement ("configuration");
				if (rootGroup.HasConfigContent (this)) {
					rootGroup.WriteConfig (this, tw, mode);
				}
				
				foreach (ConfigurationLocation loc in Locations) {
					if (loc.OpenedConfiguration == null) {
						tw.WriteRaw ("\n");
						tw.WriteRaw (loc.XmlContent);
					}
					else {
						tw.WriteStartElement ("location");
						tw.WriteAttributeString ("path", loc.Path); 
						if (!loc.AllowOverride)
							tw.WriteAttributeString ("allowOverride", "false");
						loc.OpenedConfiguration.SaveData (tw, mode, forceUpdateAll);
						tw.WriteEndElement ();
					}
				}
				
				SaveData (tw, mode, forceUpdateAll);
				tw.WriteEndElement ();
				ResetModified ();
			}
			finally {
				tw.Flush ();
				tw.Close ();
			}
		}