public XmlNode ToSpml() { XmlDataDocument doc = new XmlDataDocument(); XmlElement conn = doc.CreateElement("Connection"); XmlAttribute url = doc.CreateAttribute("Url"); url.Value = Url.ToString(); conn.Attributes.Append(url); if (CustomAuthentication) { XmlAttribute user = doc.CreateAttribute("User"); user.Value = User ?? ""; conn.Attributes.Append(user); XmlAttribute password = doc.CreateAttribute("Password"); password.Value = Password ?? ""; conn.Attributes.Append(password); if (Domain != null) { XmlAttribute domain = doc.CreateAttribute("Domain"); domain.Value = Domain; conn.Attributes.Append(domain); } } return(conn); }
private static void AddDebugText(string message, string style) { XmlElement table = dbgDoc.CreateElement("table"); XmlElement tr = dbgDoc.CreateElement("tr"); XmlElement tdTime = dbgDoc.CreateElement("td"); XmlAttribute aTime = dbgDoc.CreateAttribute("class"); aTime.InnerText = "time"; tdTime.Attributes.Append(aTime); tdTime.InnerText = AppTime.ToString(); XmlElement tdText = dbgDoc.CreateElement("td"); XmlAttribute aclass = dbgDoc.CreateAttribute("class"); aclass.InnerText = style; tdText.Attributes.Append(aclass); string encodedMessage = System.Web.HttpUtility.HtmlEncode(message); try { tdText.InnerXml = encodedMessage; } catch (Exception ex) { tdText.InnerText = "!!! Chyba pri zaznamenavani debug zpravy!!!!"; AddError("Chyba pri vkladani zpravy do logu! delka=" + message.Length + " - " + ex.ToString()); } table.AppendChild(tr); tr.AppendChild(tdTime); tr.AppendChild(tdText); dbgBodyNode.AppendChild(table); }
private void _Mtd_CrearArchivoISLR(string _P_Str_ID_Archivo) { System.IO.DirectoryInfo _DirInf = new System.IO.DirectoryInfo("c:\\seniat"); if (!_DirInf.Exists) { _DirInf.Create(); } string _Str_Cadena = "SELECT REPLACE(crifagenretencion,'-','') AS crifagenretencion,cfecha FROM TARCHIVOISLRD WHERE cgroupcomp='" + Frm_Padre._Str_GroupComp + "' AND ccompany='" + Frm_Padre._Str_Comp + "' AND cidarchivoislr='" + _P_Str_ID_Archivo + "'"; DataSet _Ds = Program._MyClsCnn._mtd_conexion._Mtd_RetornarDataset(_Str_Cadena); if (_Ds.Tables[0].Rows.Count > 0) { string _Str_RifAgente = _Ds.Tables[0].Rows[0]["crifagenretencion"].ToString().Trim(); string _Str_Periodo = _Ds.Tables[0].Rows[0]["cfecha"].ToString().Trim(); _Str_Cadena = "SELECT REPLACE(crifprovee,'-','') AS RifRetenido,REPLACE(cnumfact,'-','') AS NumeroFactura, REPLACE(cnumcont,'-','') AS NumeroControl,CONVERT(VARCHAR,cfechaoperacion,103) AS FechaOperacion,ccodigoconcepto AS CodigoConcepto,REPLACE(cmontdocu,',','.') AS MontoOperacion,REPLACE(cporcenreten,',','.') AS PorcentajeRetencion FROM TARCHIVOISLRD WHERE cgroupcomp='" + Frm_Padre._Str_GroupComp + "' AND ccompany='" + Frm_Padre._Str_Comp + "' AND cidarchivoislr='" + _P_Str_ID_Archivo + "'"; _Ds = Program._MyClsCnn._mtd_conexion._Mtd_RetornarDataset(_Str_Cadena); _Ds.Tables[0].TableName = "DetalleRetencion"; //const string _Str_Comillas = "\""; //_Ds.DataSetName = "RelacionRetencionesISLR RifAgente=" + _Str_Comillas + _Str_RifAgente + _Str_Comillas + " Periodo=" + _Str_Periodo; _Ds.DataSetName = "RelacionRetencionesISLR"; _Ds.EnforceConstraints = false; XmlDataDocument _Xml_d = new XmlDataDocument(_Ds); XmlDeclaration _Xml_Decl = _Xml_d.CreateXmlDeclaration("1.0", "ISO-8859-1", null); XmlElement _Xml_Elem = _Xml_d.DocumentElement; _Xml_d.InsertBefore(_Xml_Decl, _Xml_Elem); XmlAttribute _Xml_a = _Xml_d.CreateAttribute("RifAgente"); _Xml_a.Value = _Str_RifAgente; _Xml_d["RelacionRetencionesISLR"].Attributes.Append(_Xml_a); _Xml_a = _Xml_d.CreateAttribute("Periodo"); _Xml_a.Value = _Str_Periodo; _Xml_d["RelacionRetencionesISLR"].Attributes.Append(_Xml_a); _Xml_d.Save("c:\\seniat\\XML_relacionRetencionesISLR_.xml"); } }
private void ToolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) { switch (e.Button.Tag as string) { case "save": try { string provider = ProviderComboBox.SelectedItem.ToString(); // First Lets Remove the current node for this entire database XmlNode node = settings.SelectSingleNode(string.Format("Languages/Language[@From='{0}']", provider)); node.ParentNode.RemoveChild(node); // Grab the parent node of the entire xml file XmlNode parentNode = settings.SelectSingleNode(@"//Languages"); // Create our new Language Node entry for this database XmlNode langNode = settings.CreateNode(XmlNodeType.Element, "Language", null); parentNode.AppendChild(langNode); // Fill in it's To/From Attributes XmlAttribute attr = settings.CreateAttribute("From"); attr.Value = provider; langNode.Attributes.Append(attr); attr = settings.CreateAttribute("To"); attr.Value = "C#"; langNode.Attributes.Append(attr); // Lets sort them in order of the database column type DataTable dt = (DataTable)MappingsDataGridView.DataSource; dt.DefaultView.Sort = "Database ASC"; // Now let's add all of the mappings foreach (DataRowView row in dt.DefaultView) { XmlNode typeNode = settings.CreateNode(XmlNodeType.Element, "Type", null); langNode.AppendChild(typeNode); attr = settings.CreateAttribute("From"); attr.Value = (string)row.Row["Database"]; typeNode.Attributes.Append(attr); attr = settings.CreateAttribute("To"); attr.Value = (string)row.Row[".NET"]; typeNode.Attributes.Append(attr); } settings.Save(this.Settings.LanguageMappingFile); } catch (Exception ex) { this.MainWindow.ShowError(ex); } break; } }
public static void InitLogger() { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); startTime = DateTime.Now; times = new List <DateTime>(); fpss = new List <int>(1000); stopwatches = new List <Stopwatch>(); doc = new XmlDataDocument(); doc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); dbgDoc = new XmlDataDocument(); dbgDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); XmlElement html = doc.CreateElement("html"); XmlElement head = doc.CreateElement("head"); XmlElement link = doc.CreateElement("link"); XmlAttribute type = doc.CreateAttribute("type"); type.InnerText = "text/css"; link.Attributes.Append(type); XmlAttribute rel = doc.CreateAttribute("rel"); rel.InnerText = "Stylesheet"; link.Attributes.Append(rel); XmlAttribute href = doc.CreateAttribute("href"); href.InnerText = "logging.css"; link.Attributes.Append(href); head.AppendChild(link); html.AppendChild(head); XmlElement body = doc.CreateElement("body"); XmlElement text = doc.CreateElement("div"); text.InnerXml = "Logger verze 0.3; cas zacatku: " + startTime.ToString(); body.AppendChild(text); html.AppendChild(body); doc.AppendChild(html); dbgDoc = (XmlDataDocument)doc.CloneNode(true); bodyNode = doc.GetElementsByTagName("body")[0]; dbgBodyNode = dbgDoc.GetElementsByTagName("body")[0]; //Save(); bInitialized = true; Console.WriteLine("Logger spusten"); AddError("test"); }
private static void ReplaceIdWithUid <T>(XmlDataDocument doc, ref bool isModified, string oldName, string newName, Dictionary <int, T> entitiesById) where T : EntityObject { XmlNode organization = doc.SelectSingleNode("/IncidentBoxDocument/Block/Param[@Name='" + oldName + "']"); if (organization != null) { string newValue = Guid.Empty.ToString("D"); XmlAttribute valueAttribute = organization.Attributes["Value"]; if (valueAttribute != null) { string oldValue = valueAttribute.Value; if (!string.IsNullOrEmpty(oldValue)) { XmlDocument docValue = new XmlDocument(); docValue.LoadXml(oldValue); XmlNode valueNode = docValue.SelectSingleNode("/int"); if (valueNode != null) { string valueString = valueNode.InnerText; if (!string.IsNullOrEmpty(valueString)) { int id; if (int.TryParse(valueString, out id)) { if (id > 0 && entitiesById.ContainsKey(id)) { newValue = entitiesById[id].PrimaryKeyId.Value.ToString(); } } } } } } XmlNode parentNode = organization.ParentNode; parentNode.RemoveChild(organization); XmlNode newParamNode = parentNode.AppendChild(doc.CreateElement("Param")); newParamNode.Attributes.Append(doc.CreateAttribute("Name")).Value = newName; newParamNode.Attributes.Append(doc.CreateAttribute("Value")).Value = newValue; isModified = true; } }
private static void AddText(string message, string style, bool isProblem) { XmlElement table = doc.CreateElement("table"); XmlElement tr = doc.CreateElement("tr"); XmlElement tdTime = doc.CreateElement("td"); XmlAttribute aTime = doc.CreateAttribute("class"); aTime.InnerText = "time"; tdTime.Attributes.Append(aTime); tdTime.InnerText = AppTime.ToString(); XmlElement tdText = doc.CreateElement("td"); XmlAttribute aclass = doc.CreateAttribute("class"); aclass.InnerText = style; tdText.Attributes.Append(aclass); string encodedMessage = System.Web.HttpUtility.HtmlEncode(message); try { tdText.InnerXml = encodedMessage; } catch (Exception ex) { tdText.InnerText = "!!! Chyba pri zaznamenavani zpravy!!!!"; AddError("Chyba pri vkladani zpravy do logu! delka=" + message.Length + " - " + ex.ToString()); } table.AppendChild(tr); tr.AppendChild(tdTime); tr.AppendChild(tdText); bodyNode.AppendChild(table); if (bWriteToOutput) { System.Diagnostics.Debug.WriteLine(message); //System.Console.WriteLine(message); } if (isProblem) { AddDebugText(message, style); } }
private void save() { XmlDataDocument xml_doc = new XmlDataDocument(); XmlNode root = xml_doc.CreateElement("vocab"); foreach (LessonNode l in LessonStore) { XmlNode lesson = xml_doc.CreateElement("lesson"); XmlAttribute a_id = xml_doc.CreateAttribute("id"); XmlAttribute a_description = xml_doc.CreateAttribute("description"); a_id.Value = l.Id.ToString(); a_description.Value = l.Description; lesson.Attributes.Append(a_id); lesson.Attributes.Append(a_description); foreach (PairNode p in l.PairStore) { XmlNode pair = xml_doc.CreateElement("pair"); XmlNode en = xml_doc.CreateElement("en"); XmlNode de = xml_doc.CreateElement("de"); en.InnerText = p.En; de.InnerText = p.De; pair.AppendChild(en); pair.AppendChild(de); lesson.AppendChild(pair); } root.AppendChild(lesson); } xml_doc.AppendChild(root); xml_doc.Save(xml_path); }