Ejemplo n.º 1
0
        private void reload_Click(object sender, EventArgs e)
        {
            String firstNum, lastNum;

            // Gets the first 4 and last 4 numbers from the Selectionbox, and saves them to a variable
            firstNum = resolutionSelect.Text.Substring(0, 4);
            lastNum = resolutionSelect.Text.Substring(Math.Max(0, resolutionSelect.Text.Length - 4));

            // Removes any spaces from the above strings.
            firstNum = firstNum.Replace(" ", "");
            lastNum = lastNum.Replace(" ", "");

            // Loads the Application Settings XML file
            System.Xml.XmlDocument appConfigXML = new System.Xml.XmlDocument();
            System.Xml.XmlDocument serConfigXML = new System.Xml.XmlDocument();
            appConfigXML.Load(Game._path + "\\Content\\ApplicationSettings.xml");
            serConfigXML.Load(Game._path + "\\Content\\ServiceSettings.xml");

            // Sets the XML attributes to the current values of the editor
            appConfigXML.SelectSingleNode("//ScreenTitle").InnerText = windowTitleBox.Text;
            appConfigXML.SelectSingleNode("//FullScreen").InnerText = isFullScreen.Text;
            appConfigXML.SelectSingleNode("//ScreenWidth").InnerText = Convert.ToString(firstNum);
            appConfigXML.SelectSingleNode("//ScreenHeight").InnerText = Convert.ToString(lastNum);

            // Saves the Application Settings XML file
            appConfigXML.Save(Game._path + "\\Content\\ApplicationSettings.xml");
            serConfigXML.Save(Game._path + "\\Content\\ServiceSettings.xml");

            MessageBox.Show("Reload Application for changes to take effect");
            System.Diagnostics.Process.Start(Game._path + @"\\Devoxelation.exe");
            Application.Exit();
        }
Ejemplo n.º 2
0
        private void btnPublishFolder_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(txtFolderPath.Text))
            {
                //To Publish Folder, add Data to XML
                System.Xml.XmlDocument objXmlDocument = new System.Xml.XmlDocument();
                // Load XML
                objXmlDocument.Load(@".\Data\PublishedFolders.xml");
                System.Xml.XmlNode objXmlNode = objXmlDocument.CreateNode(System.Xml.XmlNodeType.Element,"Folder", "Folder");

                // Attribute Name
                System.Xml.XmlAttribute objXmlAttribute = objXmlDocument.CreateAttribute("Name");
                objXmlAttribute.Value = "Carpeta";
                objXmlNode.Attributes.Append(objXmlAttribute);
                // Attribute Status
                objXmlAttribute = objXmlDocument.CreateAttribute("Status");
                objXmlAttribute.Value = "Enabled";
                objXmlNode.Attributes.Append(objXmlAttribute);
                // Attribute Path
                objXmlAttribute = objXmlDocument.CreateAttribute("Path");
                objXmlAttribute.Value = txtFolderPath.Text;
                objXmlNode.Attributes.Append(objXmlAttribute);

                // Add Node
                objXmlDocument.SelectSingleNode("/PublishedFolders").AppendChild(objXmlNode);
                // Update File
                objXmlDocument.Save(@".\Data\PublishedFolders.xml");

                // Refresh List
                LoadFolders();
            }
        }
Ejemplo n.º 3
0
 public void LoadData(bool show_error)
 {
     buttonAggiorna.Enabled = numStagione.Enabled = false;
     try
     {
         Internal.Main.StatusString = "Download dell'elenco delle partite in corso...";
         string stagione = numStagione.Value.ToString();
         string url = string.Format(@"http://www.rugbymania.net/export_xml_part.php?lang=italiano&season={2}&id={0}&access_key={1}&object=calendar",
             Properties.Settings.Default.RM_Id, Properties.Settings.Default.RM_Codice, stagione);
         System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
         try
         {
             doc.Load(url);
         }
         catch (Exception ex)
         {
             if (show_error) My.Box.Errore("Impossibile scaricare i dati delle partite\r\n"+ex.Message);
             if (System.IO.File.Exists(DEFAULT_DATA)) doc.Load(DEFAULT_DATA);
         }
         Internal.Main.StatusString = "Download dell'elenco delle partite terminato!";
         ShowPartite(doc);
         if (doc.HasChildNodes) doc.Save(DEFAULT_DATA);
     }
     catch (Exception ex)
     {
         #if(DEBUG)
         My.Box.Info("TabClassifica::LoadData\r\n" + ex.Message);
         #endif
         Internal.Main.Error_on_xml();
     }
     buttonAggiorna.Enabled = numStagione.Enabled = true;
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            string applicationDirectory = System.Reflection.Assembly.GetExecutingAssembly().Location;
            applicationDirectory = applicationDirectory.Substring(0, applicationDirectory.LastIndexOf(@"\")+1);
            using (StreamReader reader = File.OpenText( FilePath ) )
            {
                string line = null;
                do
                {
                    line = reader.ReadLine();
                    if (line != null)
                    {
                        string[] items = line.Split(',');
                        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                        string url = items[XmlColumn];
                        try
                        {
                            doc.Load(url);
                            string filename = items[XmlColumn].Substring(items[XmlColumn].LastIndexOf("/") + 1);
                            string filepath = Path.Combine(applicationDirectory, SaveFolder, filename);
                            doc.Save(filepath);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("Exception: " + url + "\r\n" + e.Message);
                        }

                    }
                }
                while( line != null );
            }
            Console.Write("Press Enter key to close. ");
            while( Console.ReadKey().Key != ConsoleKey.Enter );
        }
Ejemplo n.º 5
0
 public static void ChangeDFSXMLSlaveList(string dfspath, string newSlavelist)
 {
     System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
     doc.Load(dfspath);
     System.Xml.XmlNode node = doc.SelectSingleNode("//SlaveList");
     node.InnerText = newSlavelist;
     doc.Save(dfspath);
 }
        protected void ComprobantesGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            FeaEntidades.InterFacturas.lote_comprobantes lote = new FeaEntidades.InterFacturas.lote_comprobantes();
            System.Xml.Serialization.XmlSerializer x;
            int item = Convert.ToInt32(e.CommandArgument);
            List<Entidades.Comprobante> lista = (List<Entidades.Comprobante>)ViewState["Comprobantes"];
            Entidades.Comprobante comprobante = lista[item];
            switch (e.CommandName)
            {
                case "Seleccionar":
                    Session["ComprobanteATratar"] = new Entidades.ComprobanteATratar(Entidades.Enum.TratamientoComprobante.Consulta, comprobante);
                    string script = "window.open('/ComprobanteConsulta.aspx', '');";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", script, true);
                    break;
                case "XML":
                    ////Generar Lote
                    //lote = GenerarLote(false);

                    ////Grabar en base de datos
                    //RN.Comprobante c = new RN.Comprobante();
                    //lote.cabecera_lote.DestinoComprobante = "ITF";
                    //lote.comprobante[0].cabecera.informacion_comprobante.Observacion = "";
                    //c.Registrar(lote, null, "ITF", ((Entidades.Sesion)Session["Sesion"]));

                    x = new System.Xml.Serialization.XmlSerializer(lote.GetType());
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append(comprobante.Cuit);
                    sb.Append("-");
                    sb.Append(comprobante.NroPuntoVta.ToString("0000"));
                    sb.Append("-");
                    sb.Append(comprobante.TipoComprobante.Id.ToString("00"));
                    sb.Append("-");
                    sb.Append(comprobante.Nro.ToString("00000000"));
                    sb.Append(".xml");

                    //System.IO.MemoryStream m = new System.IO.MemoryStream();
                    //System.IO.StreamWriter sw = new System.IO.StreamWriter(m);
                    //sw.Flush();
                    //System.Xml.XmlWriter writerdememoria = new System.Xml.XmlTextWriter(m, System.Text.Encoding.GetEncoding("ISO-8859-1"));

                    System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
                    xmlDoc.LoadXml(comprobante.Request);
                    xmlDoc.Save(Server.MapPath(@"~/Temp/" + sb.ToString()));

                    //x.Serialize(writerdememoria, xmlDoc);
                    //m.Seek(0, System.IO.SeekOrigin.Begin);

                    //Descarga directa del XML
                    //System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath(@"~/Temp/" + sb.ToString()), System.IO.FileMode.Create);
                    //m.WriteTo(fs);
                    //fs.Close();
                    Server.Transfer("~/DescargaTemporarios.aspx?archivo=" + sb.ToString(), false);
                    break;
                default:
                    break;
            }
        }
Ejemplo n.º 7
0
        public static void SetSetting(string path, string key, string value)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(path);

            System.Xml.XmlNode node = doc.SelectSingleNode("settings/" + key);
            node.InnerText = value;
            doc.Save(path);
        }
Ejemplo n.º 8
0
        public override bool Execute()
        {
            var originalFileXml = new System.Xml.XmlDocument();
            originalFileXml.Load(Source.ItemSpec);

            using (var xmlTransform = new XmlTransformation(Transform.ItemSpec))
            {
                if (xmlTransform.Apply(originalFileXml) == false)
                    return false;

                originalFileXml.Save(Destination.ItemSpec);
            }

            return true;
        }
Ejemplo n.º 9
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
         string strRoot = Server.MapPath("/");
         xmlDoc.LoadXml(txtEditor.Text);
         xmlDoc.Save(strRoot + "XML\\QuanLyBanner.xml");
         lbStatus.ForeColor = System.Drawing.Color.Blue;
         lbStatus.Text = "Update thành công!";
     }
     catch (Exception exp)
     {
         lbStatus.ForeColor = System.Drawing.Color.Red;
         lbStatus.Text = "Lỗi! Không thể update:";
     }
 }
Ejemplo n.º 10
0
 internal static void ChangeSetting(string name, string value)
 {
     string configFileName = System.Windows.Forms.Application.ExecutablePath + ".config";
     var doc = new System.Xml.XmlDocument();
     doc.Load(configFileName);
     string configString =
         @"configuration/applicationSettings/Script_Text_Editor.Properties.Settings/setting[@name='"
         + name + "']/value";
     System.Xml.XmlNode configNode = doc.SelectSingleNode(configString);
     if (configNode != null)
     {
         configNode.InnerText = value;
         doc.Save(configFileName);
         // 刷新应用程序设置
         Properties.Settings.Default.Reload();
     }
 }
Ejemplo n.º 11
0
        public bool Patch() {
            string home = System.Web.HttpRuntime.AppDomainAppPath;
            System.IO.DirectoryInfo folder = new System.IO.DirectoryInfo(home);
            if (folder.Exists) 
            {
                string wildcard = "config." + this.GetEnvironment().ToString() + ".*.xml";
                System.IO.FileInfo[] files = folder.GetFiles(wildcard);
                System.Collections.Generic.List<string> section = new System.Collections.Generic.List<string>();

                string webConfigFilename = System.IO.Path.Combine(home, "Web.config");
                System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
                xmlDoc.Load(webConfigFilename);

                bool changed = false;

                foreach (System.IO.FileInfo file in files)
                {
                    string webConfigSectionFilename = System.IO.Path.Combine(home, file.Name);

                    string[] filename = file.Name.Split('.');
                    for (int i = 2; i < filename.Length-1; i++)
                    {
                        section.Add(filename[i]);
                    }

                    System.Xml.XmlDocument xmlDocSection = new System.Xml.XmlDocument();

                    xmlDocSection.Load(webConfigSectionFilename);

                    string xPath = System.String.Join("/", section);
                    System.Xml.XmlNode node = xmlDoc.SelectSingleNode(xPath);

                    if (node != null && node.InnerXml != xmlDocSection.ChildNodes[1].InnerXml) {
                        node.InnerXml = xmlDocSection.ChildNodes[1].InnerXml;
                        changed = true;
                    }
                }
                if (changed)
                {
                    xmlDoc.Save(webConfigFilename);
                }
            }
            return true;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// WinForm更新App.config中,key对应的value,没有则添加
        /// </summary>
        /// <param name="appKey">key</param>
        /// <param name="appValue">value</param>
        public static void AddOrUpdate(string appKey, string appValue)
        {
            var xDoc = new System.Xml.XmlDocument();
            xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");

            var xNode = xDoc.SelectSingleNode("//appSettings");
            if (xNode != null)
            {
                var xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + appKey + "']");
                if (xElem1 != null) xElem1.SetAttribute("value", appValue);
                else
                {
                    var xElem2 = xDoc.CreateElement("add");
                    xElem2.SetAttribute("key", appKey);
                    xElem2.SetAttribute("value", appValue);
                    xNode.AppendChild(xElem2);
                }
            }
            xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 根据Key修改Value
        /// </summary>
        /// <param name="key">要修改的Key</param>
        /// <param name="value">要修改为的值</param>
        public static void SetValue(string key, string value)
        {
            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
            xDoc.Load(HttpContext.Current.Server.MapPath("/XmlConfig/Config.xml"));
            System.Xml.XmlNode xNode;
            System.Xml.XmlElement xElem1;
            System.Xml.XmlElement xElem2;
            xNode = xDoc.SelectSingleNode("//appSettings");

            xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
            if (xElem1 != null) xElem1.SetAttribute("value", value);
            else
            {
                xElem2 = xDoc.CreateElement("add");
                xElem2.SetAttribute("key", key);
                xElem2.SetAttribute("value", value);
                xNode.AppendChild(xElem2);
            }
            xDoc.Save(HttpContext.Current.Server.MapPath("/XmlConfig/Config.xml"));
        }
Ejemplo n.º 14
0
        public static void SaveDocument(System.Xml.XmlDocument origDoc, System.IO.Stream strm, bool bDoReplace)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            if (bDoReplace)
                doc.LoadXml(origDoc.OuterXml.Replace("xmlns=\"\"", ""));

            using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(strm, System.Text.Encoding.UTF8))
            {
                xtw.Formatting = System.Xml.Formatting.Indented; // if you want it indented
                xtw.Indentation = 4;
                xtw.IndentChar = ' ';

                doc.Save(xtw);
                xtw.Flush();
                xtw.Close();
            } // End Using xtw

            doc = null;
        }
Ejemplo n.º 15
0
        public void SetValue(string AppKey, string AppValue)
        {
            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
            xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");

            System.Xml.XmlNode xNode;
            System.Xml.XmlElement xElem1;
            System.Xml.XmlElement xElem2;
            xNode = xDoc.SelectSingleNode("//appSettings");

            xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
            if (xElem1 != null) xElem1.SetAttribute("value", AppValue);
            else
            {
                xElem2 = xDoc.CreateElement("add");
                xElem2.SetAttribute("key", AppKey);
                xElem2.SetAttribute("value", AppValue);
                xNode.AppendChild(xElem2);
            }
            xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
        }
Ejemplo n.º 16
0
        internal static void CreateXMLFile()
        {
            xDoc = new System.Xml.XmlDocument();

            xDoc.AppendChild(xDoc.CreateXmlDeclaration("1.0", "UTF-8", null));
            System.Xml.XmlElement root = xDoc.CreateElement("FolderMonitor");
            Console.WriteLine("creating file");
            try
            {
                XMLDataListEntry current = head;
                while (current != null)
                {
                    root.AppendChild(CreateXMLNodes(current.Data));
                    current = current.Next;
                }
                xDoc.AppendChild(root);
                xDoc.Save(srcFileName);
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine(e.ToString());
            }
        }
Ejemplo n.º 17
0
        private void PageLoad()
        {
            var xmlDoc     = new System.Xml.XmlDocument();
            var strXslPath = Server.MapPath(ControlAdminPath) + "menu\\ControlTabMenu.xsl";

            try
            {
                xmlDoc.Load(strXslPath);

                if (DebugMode)
                {
                    var xmlDocData = new System.Xml.XmlDocument();
                    xmlDocData.LoadXml(GetActionXml().Trim());
                    xmlDocData.Save(Server.MapPath(ControlAdminPath) + "menu\\menu.xml");
                }

                this.Controls.Add(new LiteralControl(XslUtils.XslTransInMemory(GetActionXml().Trim(), xmlDoc.OuterXml)));
            }
            catch (Exception)
            {
                this.Controls.Add(new LiteralControl("CANNOT READ XSL : " + strXslPath));
            }
        }
Ejemplo n.º 18
0
        private void TransformNewRelicConfig(string newRelicConfigPath)
        {
            var xml = new System.Xml.XmlDocument();

            // Update the 'newrelic.config' file
            xml.Load(newRelicConfigPath);
            var ns = new System.Xml.XmlNamespaceManager(xml.NameTable);

            ns.AddNamespace("x", "urn:newrelic-config");

            // Remove the 'application' element
            var node = xml.SelectSingleNode("//x:configuration/x:application", ns);

            node.ParentNode.RemoveChild(node);

            // Re-create the 'application' element
            var nodeLog = (System.Xml.XmlElement)xml.SelectSingleNode("//x:configuration/x:log", ns);
            var app     = xml.CreateElement("application", "urn:newrelic-config");

            xml.DocumentElement.InsertBefore(app, nodeLog);

            xml.Save(newRelicConfigPath);
        }
        public bool Save()
        {
            bool retVal = false;

            if (string.IsNullOrEmpty(WorkFile))
            {
                return(SaveAs());
            }
            System.Xml.XmlDocument doc = XmlConverter.ToXmlDocument(Data, true);
            try
            {
                fsw.EnableRaisingEvents = false;
                doc.Save(WorkFile);
                SetWatcher(WorkFile);
                Data.AcceptChanges();
                retVal = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to save file. \r\n\r\nError from Windows:\r\n\r\n" + ex.Message, "DMX Commander", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            return(retVal);
        }
        public void Save()
        {
            var xmd     = new System.Xml.XmlDocument();
            var xmeRoot = xmd.CreateElement("RedirectRules");

            xmd.AppendChild(xmeRoot);

            foreach (var redirectRule in _redirectRules)
            {
                var xme = xmd.CreateElement("RedirectRule");
                xmeRoot.AppendChild(xme);

                //xme.SetAttribute("CallingClient", redirectRule.CallingClient.Address.ToString(CultureInfo.InvariantCulture));
                xme.SetAttribute("RequestHost", redirectRule.PublicRequestHost);
                xme.SetAttribute("RequestPort", redirectRule.PublicRequestPort.ToString(CultureInfo.InvariantCulture));
                xme.SetAttribute("TargetAddress", redirectRule.InternalTargetAddress.ToString());
                xme.SetAttribute("TargetPort", redirectRule.InternalTargetPort.ToString(CultureInfo.InvariantCulture));
            }

            var redirectRuleConfigFile = System.Configuration.ConfigurationManager.AppSettings["RedirectRuleConfigFile"];

            xmd.Save(redirectRuleConfigFile);
        }
Ejemplo n.º 21
0
        public static void PackBitmapFiles(string[] files, string outputFile)
        {
            ArrayList bmps = new ArrayList();

            foreach (string file in files)
            {
                Bitmap bmp = (Bitmap)Bitmap.FromFile(file);
                bmps.Add(bmp);
            }
            Node   infoNode;
            Bitmap large = PackBitmapsIntoOneLarge(bmps, null, out infoNode);

            //string sFormat = outputFile.Remove(0,outputFile.LastIndexOf(".")+1).ToUpper();
            large.Save(outputFile);             //, GetEncoderInfo(sFormat), null);

            int nIndex = outputFile.LastIndexOf(".");

            outputFile = outputFile.Substring(0, nIndex) + ".xml";

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            infoNode.AddToXml(doc);
            doc.Save(outputFile);
        }
Ejemplo n.º 22
0
        internal void resetDbContextPath(string dbConnectionString, string dbProviderName)
        {
            System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
            string appConfigPath;

            appConfigPath = System.IO.Path.GetDirectoryName(asm.Location) + @"\WordConverter_v2.exe.config";
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(appConfigPath);
            System.Xml.XmlNode node = doc["configuration"]["connectionStrings"];
            foreach (System.Xml.XmlNode n in doc["configuration"]["connectionStrings"])
            {
                if (n.Name == "add")
                {
                    if (n.Attributes.GetNamedItem("name").Value == "MyContext")
                    {
                        n.Attributes.GetNamedItem("connectionString").Value = dbConnectionString;
                        n.Attributes.GetNamedItem("providerName").Value     = dbProviderName;
                        break;
                    }
                }
            }
            doc.Save(appConfigPath);
        }
Ejemplo n.º 23
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            if (listViewProdukter.SelectedItems.Count > 1)
            {
                MessageBox.Show("Välj en produkt");
            }
            else if (listViewProdukter.SelectedItems.Count == 1)
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.Load(this.produkterF);

                //Use an XPath query to find a XmlNode
                System.Xml.XmlNode deleteContact =
                    doc.SelectSingleNode("descendant::produkt[pnamn='" + listViewProdukter.SelectedItems[0].Text + "']");

                //Remove the XmlNode from the Document
                doc.DocumentElement.RemoveChild(deleteContact);
                //Save the Document

                doc.Save(this.produkterF);
                listViewProdukter.SelectedItems[0].Remove();
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 根据Key修改Value
        /// </summary>
        /// <param name="key">要修改的Key</param>
        /// <param name="value">要修改为的值</param>
        public static void SetValue(string key, string value)
        {
            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
            xDoc.Load(HttpContext.Current.Server.MapPath("~/Configs/system.config"));
            System.Xml.XmlNode    xNode;
            System.Xml.XmlElement xElem1;
            System.Xml.XmlElement xElem2;
            xNode = xDoc.SelectSingleNode("//appSettings");

            xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
            if (xElem1 != null)
            {
                xElem1.SetAttribute("value", value);
            }
            else
            {
                xElem2 = xDoc.CreateElement("add");
                xElem2.SetAttribute("key", key);
                xElem2.SetAttribute("value", value);
                xNode.AppendChild(xElem2);
            }
            xDoc.Save(HttpContext.Current.Server.MapPath("~/Configs/system.config"));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 根据Key修改Value
        /// </summary>
        /// <param name="key">要修改的Key</param>
        /// <param name="value">要修改为的值</param>
        public static void SetValue(string key, string value)
        {
            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
            xDoc.Load(NSWebPath.GetServerPath("/XmlConfig/Config.xml"));
            System.Xml.XmlNode    xNode;
            System.Xml.XmlElement xElem1;
            System.Xml.XmlElement xElem2;
            xNode = xDoc.SelectSingleNode("//appSettings");

            xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
            if (xElem1 != null)
            {
                xElem1.SetAttribute("value", value);
            }
            else
            {
                xElem2 = xDoc.CreateElement("add");
                xElem2.SetAttribute("key", key);
                xElem2.SetAttribute("value", value);
                xNode.AppendChild(xElem2);
            }
            xDoc.Save(NSWebPath.GetServerPath("/XmlConfig/Config.xml"));
        }
Ejemplo n.º 26
0
        }        //ReadParameter

        /// <summary>
        /// 設定値をXMLファイルに書き出す。
        /// </summary>
        private void WriteParameter()
        {
            try
            {
                System.Xml.XmlDocument doc  = new System.Xml.XmlDocument();
                System.Xml.XmlElement  root = doc.CreateElement(parameter_file);
                System.Xml.XmlElement  elem;

                doc.AppendChild(root);

                elem           = doc.CreateElement("Width");
                elem.InnerText = this.Width.ToString();
                root.AppendChild(elem);

                elem           = doc.CreateElement("Height");
                elem.InnerText = this.Height.ToString();
                root.AppendChild(elem);

                elem           = doc.CreateElement("Lines");
                elem.InnerText = this.lines.ToString();
                root.AppendChild(elem);

                elem           = doc.CreateElement("Vertex");
                elem.InnerText = this.vertex.ToString();
                root.AppendChild(elem);

                elem           = doc.CreateElement("WaitTime");
                elem.InnerText = this.wait_time.ToString();
                root.AppendChild(elem);

                doc.Save("parameter.xml");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        } //WriteParameter
Ejemplo n.º 27
0
        /// <summary>
        /// 写入,更新配置文件节点
        /// </summary>
        /// <param name="SectionName">节点名称</param>
        /// <parma name="key">键名</param>
        /// <parma name="value">键值</param>
        public static void SetConfigKeyValue(string SectionName, string key, string keyvalue)
        {
            //导入配置文件
            System.Xml.XmlDocument doc = loadConfigDocument();
            //重新取得 节点名
            System.Xml.XmlNode node = doc.SelectSingleNode("//" + SectionName);
            if (node == null)
            {
                throw new InvalidOperationException(SectionName + " section not found in config file.");
            }

            try
            {
                // 用 'add'元件 格式化是否包含键名
                // select the 'add' element that contains the key
                System.Xml.XmlElement elem = (System.Xml.XmlElement)node.SelectSingleNode(string.Format("//add[@key='{0}']", key));

                if (elem != null)
                {
                    //修改或添加键值
                    elem.SetAttribute("value", keyvalue);
                }
                else
                {
                    //如果没有发现键名则进行添加设置键名和键值
                    elem = doc.CreateElement("add");
                    elem.SetAttribute("key", key);
                    elem.SetAttribute("value", keyvalue);
                    node.AppendChild(elem);
                }
                doc.Save(getConfigFilePath());
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 28
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                dtConfig.AcceptChanges();

                string path = Application.ExecutablePath + ".config";
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                if (File.Exists(path))
                {
                    doc.Load(path);

                    foreach (DataRow row in dtConfig.Rows)
                    {
                        string configString = @"configuration/applicationSettings/" + DoService.pubService
                                              + ".Properties.Settings/setting[@name='" + row["ColumnTitle"].ToString() + "']/value";

                        System.Xml.XmlNode configNode = doc.SelectSingleNode(configString);
                        if (configNode != null)
                        {
                            configNode.InnerText = row["ColumnValue"].ToString();
                        }
                    }
                    doc.Save(path);
                    Properties.Settings.Default.Reload();
                }

                DoService.WriteEventLog(DoService.pubService + " Save Config Success!");
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                DoService.WriteEventLog(DoService.pubService + " Save Config Failed!" + ex.Message);
                this.DialogResult = DialogResult.Cancel;
            }
        }
Ejemplo n.º 29
0
        public static int Main(params string[] args)
        {
            var sourceParm    = args.FirstOrDefault(x => x.StartsWith("-src", StringComparison.OrdinalIgnoreCase));
            var transformParm = args.FirstOrDefault(x => x.StartsWith("-transform", StringComparison.OrdinalIgnoreCase) || x.StartsWith("-trans", StringComparison.OrdinalIgnoreCase));
            var destParm      = args.FirstOrDefault(x => x.StartsWith("-dest", StringComparison.OrdinalIgnoreCase));

            try
            {
                ValidateParm(sourceParm, nameof(sourceParm));

                var sourceFile = GetOptionValue(sourceParm);
                var transFile  = GetOptionValue(transformParm);
                var destFile   = GetOptionValue(destParm);

                Console.WriteLine($"start application config transform");
                var originalFileXml = new System.Xml.XmlDocument();
                originalFileXml.Load(sourceFile);

                using (var xmlTransform = new XmlTransformation(transFile))
                {
                    if (xmlTransform.Apply(originalFileXml) == false)
                    {
                        throw new Exception("Configuration file transform failure, please confirm the transform file");
                    }

                    // originalFileXml is now transformed
                    originalFileXml.Save(destFile);
                    Console.WriteLine("Transform success");
                    return(0);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(-1);
            }
        }
Ejemplo n.º 30
0
        static public void SaveOption()
        {
            var path = System.IO.Path.Combine(GetEntryDirectory(), OptionFilePath);

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            var optionElement     = Data.IO.SaveObjectToElement(doc, "Option", Option, false);
            var postEffectElement = Data.IO.SaveObjectToElement(doc, "PostEffect", PostEffect, false);

            System.Xml.XmlElement project_root = doc.CreateElement("EffekseerProject");
            if (optionElement != null)
            {
                project_root.AppendChild(optionElement);
            }
            if (postEffectElement != null)
            {
                project_root.AppendChild(postEffectElement);
            }

            // recording option (this option is stored in local or global)
            if (recording.RecordingStorageTarget.Value == Data.RecordingStorageTargetTyoe.Global)
            {
                var recordingElement = Data.IO.SaveObjectToElement(doc, "Recording", Recording, false);
                if (recordingElement != null)
                {
                    project_root.AppendChild(recordingElement);
                }
            }

            doc.AppendChild(project_root);

            var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);

            doc.InsertBefore(dec, project_root);
            doc.Save(path);
            IsChanged = false;
        }
 private void LoadConfig()
 {
     try
     {
         if (!File.Exists(InstallActions.AppData + "\\data.xml"))
         {
             InstallActions.InitConfig();
         }
         System.Xml.XmlDocument xmlConfigDoc = new System.Xml.XmlDocument();
         xmlConfigDoc.PreserveWhitespace = true;
         xmlConfigDoc.Load(AppData + "\\data.xml");
         xplaneDirTextBox.Text = xmlConfigDoc.SelectSingleNode("installer/configuration/xplanePath").InnerText;
         //audioBirdCheck.Checked = Convert.ToBoolean(xmlConfigDoc.SelectSingleNode("installer/configuration/audiobirdxp").InnerText);
         //RGModCheckbox.Checked = Convert.ToBoolean(xmlConfigDoc.SelectSingleNode("installer/configuration/texturemod").InnerText);
         installedZibo = xmlConfigDoc.SelectSingleNode("installer/data/ziboVer").InnerText;
         //installedAudioB = xmlConfigDoc.SelectSingleNode("installer/data/fmodVer").InnerText;
         dropdownbox.SelectedIndex = Convert.ToInt32(xmlConfigDoc.SelectSingleNode("installer/configuration/textureres").InnerText);
         //texturemodInstalled = Convert.ToBoolean(xmlConfigDoc.SelectSingleNode("installer/data/texturemodinstalled").InnerText);
         xmlConfigDoc.Save(AppData + "\\data.xml");
     } catch (Exception ex)
     {
         if (ex is NullReferenceException || ex is System.Xml.XmlException || ex is System.ArgumentOutOfRangeException)
         {
             InstallActions.ResetConfig();
             LoadConfig();
             MessageBox.Show("Corrupt or old configuration detected. Configuration reset to default values.");
             InstallActions.AppendLogText("Couldn't load configuration! Corrupt or old configuration detected. Configuration reset to default values.");
             return;
         }
         if (ex is FileNotFoundException || ex is DirectoryNotFoundException)
         {
             InstallActions.AppendLogText("The configuration or configuration folder couldn't be found.");
             return;
         }
         throw ex;
     }
 }
Ejemplo n.º 32
0
 public void LoadData(bool show_error)
 {
     buttonAggiorna.Enabled = numStagione.Enabled = false;
     try
     {
         Internal.Main.StatusString = T("Download della classifica in corso...");
         string stagione = numStagione.Value.ToString();
         string url = string.Format(@"http://www.rugbymania.net/export_xml_part.php?lang=italiano&season={2}&id={0}&access_key={1}&object=standings",
             Properties.Settings.Default.RM_Id, Properties.Settings.Default.RM_Codice,stagione);
         System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
         try
         {
             doc.Load(url);
         }
         catch (Exception ex)
         {
             if (show_error) My.Box.Errore(T("Impossibile scaricare i dati della classifica")+"\r\n" + ex.Message);
             if (System.IO.File.Exists(DEFAULT_DATA)) doc.Load(DEFAULT_DATA);
         }
         Internal.Main.StatusString = T("Download della classifica terminato!");
         ShowClassifica(doc);
         doc.Save(DEFAULT_DATA);
     }
     catch (Exception ex)
     {
         #if(DEBUG)
         My.Box.Info("TabClassifica::LoadData\r\n"+ex.Message);
         #endif
         if (Properties.Settings.Default.RM_Id.Length == 0)
             My.Box.Errore(T("E' necessario inserire l'ID della tua squadra!"));
         if (Properties.Settings.Default.RM_Codice.Length == 0)
             My.Box.Errore(T("E' necessario inserire il Codice per il download dei dati da RM!"));
         Internal.Main.Error_on_xml();
     }
     buttonAggiorna.Enabled = numStagione.Enabled = true;
 }
Ejemplo n.º 33
0
        internal static void SaveConfig()
        {
            {
                RecentFiles.SaveRecentConfig();
            }

            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                System.Xml.XmlElement project_root = doc.CreateElement("GUI");

                if (MainForm.WindowState == FormWindowState.Normal)
                {
                    project_root.AppendChild(doc.CreateTextElement("X", MainForm.Location.X.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Y", MainForm.Location.Y.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Width", MainForm.Width.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Height", MainForm.Height.ToString()));
                }
                else                 // 最小化、最大化中はその前の位置とサイズを保存
                {
                    project_root.AppendChild(doc.CreateTextElement("X", MainForm.BeforeResizeLocation.X.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Y", MainForm.BeforeResizeLocation.Y.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Width", MainForm.BeforeResizeWidth.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Height", MainForm.BeforeResizeHeight.ToString()));
                }
                doc.AppendChild(project_root);

                var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
                doc.InsertBefore(dec, project_root);
                doc.Save(configGuiPath);
            }

            MainForm.Panel.SaveAsXml(configGuiPanelPath, Encoding.UTF8);

            Network.Save(configNetworkPath);
        }
Ejemplo n.º 34
0
        static void Main(string[] args)
        {
            string applicationDirectory = System.Reflection.Assembly.GetExecutingAssembly().Location;

            applicationDirectory = applicationDirectory.Substring(0, applicationDirectory.LastIndexOf(@"\") + 1);
            using (StreamReader reader = File.OpenText(FilePath))
            {
                string line = null;
                do
                {
                    line = reader.ReadLine();
                    if (line != null)
                    {
                        string[] items             = line.Split(',');
                        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                        string url = items[XmlColumn];
                        try
                        {
                            doc.Load(url);
                            string filename = items[XmlColumn].Substring(items[XmlColumn].LastIndexOf("/") + 1);
                            string filepath = Path.Combine(applicationDirectory, SaveFolder, filename);
                            doc.Save(filepath);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("Exception: " + url + "\r\n" + e.Message);
                        }
                    }
                }while(line != null);
            }
            Console.Write("Press Enter key to close. ");
            while (Console.ReadKey().Key != ConsoleKey.Enter)
            {
                ;
            }
        }
Ejemplo n.º 35
0
        public void ChangeConfigControl(string cartName, string softwareVersion, string instanceType)
        {
            try
            {
                string configPath             = Path.Combine(this.container.ContainerDir, cartName, "bin", "control.exe.config");
                System.Xml.XmlDocument config = new System.Xml.XmlDocument();
                config.Load(configPath);

                foreach (System.Xml.XmlElement item in config.DocumentElement)
                {
                    if (item.Name == "appSettings")
                    {
                        item.ChildNodes[0].Attributes[1].Value = softwareVersion;
                        item.ChildNodes[1].Attributes[1].Value = instanceType;
                    }
                }

                config.Save(configPath);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.ToString());
            }
        }
Ejemplo n.º 36
0
        /// <summary>
        /// 修改web.config的连接数据库的字符串
        /// </summary>
        /// <param name="dbserver"></param>
        /// <param name="dbname"></param>
        /// <param name="dbuser"></param>
        /// <param name="dbpwd"></param>
        public static string WriteSqlConfig(string namevalue, string dbserver, string dbname, string dbuser, string dbpwd)
        {
            //加载配置文件
            string webconfigpath = HttpContext.Current.Server.MapPath("~/web.config");
            string cs            = "";

            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
            xmlDocument.Load(webconfigpath);
            //修改连接字符串
            foreach (System.Xml.XmlNode Node in xmlDocument["configuration"]["connectionStrings"])
            {
                if (Node.Name == "add")
                {
                    if (Node.Attributes.GetNamedItem("name").Value == namevalue)
                    {
                        //参考Data Source=SSS-D4E6A63DAE8;Initial Catalog=LearnSiteDb;uid=sa;pwd=12345;
                        cs = String.Format("Data Source={0};Initial Catalog={1};uid={2};pwd={3};", dbserver, dbname, dbuser, dbpwd);
                        Node.Attributes.GetNamedItem("connectionString").Value = cs;
                    }
                }
            }
            xmlDocument.Save(webconfigpath);
            return(cs);
        }
Ejemplo n.º 37
0
 /// <summary>
 /// Multiplication of XAML
 /// </summary>
 /// <param name="filename">XAML filename</param>
 /// <param name="scale">Multiplication scale</param>
 public static void Multiply(string filename, double scale)
 {
     char[] sep = " ".ToCharArray();
     char[] sep1 = ",".ToCharArray();
     System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
     doc.Load(filename);
     System.Xml.XmlNodeList nl = doc.GetElementsByTagName("MeshGeometry3D");
     foreach (System.Xml.XmlElement e in nl)
     {
         string s = "";
         string pos = e.GetAttribute("Positions");
         string[] pp = pos.Split(sep);
         foreach (string spp in pp)
         {
             if (spp.Length == 0)
             {
                 continue;
             }
             string[] ppp = spp.Split(sep1);
             int i = 0;
             foreach (string sppp in ppp)
             {
                 s += ((Double.Parse(sppp.Replace(".", ",")) * scale) + "").Replace(",", ".");
                 if (i < 2)
                 {
                     s += ",";
                 }
                 ++i;
             }
             s += " ";
         }
         e.SetAttribute("Positions", s);
     }
     System.IO.File.Delete(filename);
     doc.Save(filename);
 }
Ejemplo n.º 38
0
        public static void SetValue(string AppKey, string AppValue)
        {
            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
            xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");

            System.Xml.XmlNode    xNode;
            System.Xml.XmlElement xElem1;
            System.Xml.XmlElement xElem2;
            xNode = xDoc.SelectSingleNode("//appSettings");

            xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
            if (xElem1 != null)
            {
                xElem1.SetAttribute("value", AppValue);
            }
            else
            {
                xElem2 = xDoc.CreateElement("add");
                xElem2.SetAttribute("key", AppKey);
                xElem2.SetAttribute("value", AppValue);
                xNode.AppendChild(xElem2);
            }
            xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
        }
Ejemplo n.º 39
0
        private void myCallback(object obj)
        {
            System.Threading.Thread.CurrentThread.IsBackground = false;

            lock (syncLock)
            {
                if (flag)
                    return;

                i++;
                if (i > 10)
                {
                    flag = true;
                    timer.Dispose();
                }

                var path=AppDomain.CurrentDomain.BaseDirectory + "Config\\Data.xml";
                var doc = new System.Xml.XmlDocument();
                doc.Load(path);

                var node = doc.SelectSingleNode("/Thread/Time");
                node.InnerText = DateTime.Now.ToString();
                node = doc.SelectSingleNode("/Thread/ThreadId");
                node.InnerText = System.Threading.Thread.CurrentThread.ManagedThreadId.ToString();
                node = doc.SelectSingleNode("/Thread/Counter");
                var counter = Int32.Parse(node.InnerText);
                node.InnerText = (++counter).ToString();

                doc.Save(path);

                Console.WriteLine(string.Format("Outer Now:i={0},Current Thread:{1}",
                    i, System.Threading.Thread.CurrentThread.ManagedThreadId));
            }
            //sleep current thread
            System.Threading.Thread.Sleep(500);
        }
Ejemplo n.º 40
0
        public bool SaveComprobante()
        {
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();

            ns.Add("cfdi", "http://www.sat.gob.mx/cfd/3");
            ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            ns.Add("ecb", "http://www.sat.gob.mx/ecb");
            ns.Add("valesdedespensa", "http://www.sat.gob.mx/valesdedespensa");
            string strXML = XmlSerializerHelper.ToXmlString <Comprobante>(_comprobante, ns, System.Text.Encoding.UTF8);

            strXML = strXML.Replace("xmlns:ecb=\"http://www.sat.gob.mx/ecb\">", ">");

            //strXML = strXML.Replace("UTF-16", "UTF-8");
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(strXML);
            //doc.Save(System.IO.Path.Combine(filesGenerated, "CFDI" + _comprobante.serie + _comprobante.folio + ".xml"));

            using (TextWriter sw = new StreamWriter(System.IO.Path.Combine(filesGenerated, "CFDI" + _comprobante.serie + _comprobante.folio + ".xml"), false, Encoding.UTF8)) //Set encoding
            {
                doc.Save(sw);
            }

            return(true);
        }
Ejemplo n.º 41
0
        private void onXMLSent(string xml, long socketId)
        {
            try
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.LoadXml(xml);

                System.IO.StringWriter sw = new System.IO.StringWriter();
                System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(sw);
                w.Formatting = System.Xml.Formatting.Indented;
                w.Indentation = 4;

                doc.Save(w);
                w.Flush();
                w.Close();

                string s = sw.ToString();
                int lineEnd = s.IndexOf("<", 2);
                s = s.Substring(lineEnd);

                string t = String.Format("{2}Sent at {0}: {2}{1}{2}", DateTime.Now.ToShortTimeString(), s, "\r\n");
                AppendTextThreadSafe(t);
            }
            catch(Exception)
            {
            }
        }
Ejemplo n.º 42
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg  = e.CommandArgument.ToString();
            var param = new string[3];

            var navigationData = new NavigationData(PortalId, "CategoryAdmin");

            switch (e.CommandName.ToLower())
            {
            case "entrydetail":
                SaveAll();
                param[1] = "eid=" + cArg;
                param[2] = "catid=" + _openid;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "return":
                param[1] = "";
                param[2] = "catid=" + _openid;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "search":
                var strXml = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                navigationData.XmlData = strXml;
                if (StoreSettings.Current.DebugModeFileOut)
                {
                    strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>";
                    var xmlDoc = new System.Xml.XmlDocument();
                    xmlDoc.LoadXml(strXml);
                    xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml");
                }
                navigationData.Save();
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "resetsearch":
                // clear cookie info
                navigationData.Delete();
                param[2] = "catid=0";
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "addnew":
                var strXml2 = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                navigationData.XmlData = strXml2;
                navigationData.Save();
                var categoryData = CategoryUtils.GetCategoryData(-1, EditLanguage);
                if (!String.IsNullOrEmpty(Edittype) && Edittype.ToLower() == "group")
                {
                    categoryData.GroupType = GenXmlFunctions.GetGenXmlValue(navigationData.XmlData, "genxml/dropdownlist/groupsel");
                    if (categoryData.GroupType == "")
                    {
                        categoryData.GroupType = "cat";
                    }
                    var grpCtrl = new GrpCatController(Utils.GetCurrentCulture());
                    var grp     = grpCtrl.GetGrpCategoryByRef(categoryData.GroupType);
                    if (grp != null)
                    {
                        categoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", grp.categoryid.ToString(""));
                    }
                    categoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", "False");     // don't hide property groups by default
                }
                categoryData.ParentItemId = _openid;
                categoryData.Save();
                NBrightBuyUtils.RemoveModCachePortalWide(PortalId);

                param[2] = "catid=" + _openid;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "delete":
                if (Utils.IsNumeric(cArg))
                {
                    var catid = Convert.ToInt32(cArg);
                    if (catid > 0)
                    {
                        var delCatData = CategoryUtils.GetCategoryData(catid, EditLanguage);
                        if (delCatData.Exists && delCatData.GetDirectChildren().Count == 0)     // only delete end leaf
                        {
                            var productidlist = new ArrayList();
                            foreach (var dc in delCatData.GetDirectArticles())
                            {
                                productidlist.Add(dc.ParentItemId);
                            }

                            var parentCatList = new List <CategoryData>();
                            var loopCat       = CategoryUtils.GetCategoryData(catid, EditLanguage);
                            while (loopCat.Exists && loopCat.ParentItemId > 0)
                            {
                                loopCat = CategoryUtils.GetCategoryData(loopCat.ParentItemId, EditLanguage);
                                parentCatList.Add(loopCat);
                            }

                            foreach (var pCat in parentCatList)
                            {
                                foreach (var prodxref in pCat.GetCascadeArticles())
                                {
                                    if (productidlist.Contains(prodxref.ParentItemId))
                                    {
                                        // delete CATCASCADE record
                                        if (prodxref.TypeCode == "CATCASCADE")     // just check we have correct record. (stop nasty surprises)
                                        {
                                            ModCtrl.Delete(prodxref.ItemID);
                                        }
                                    }
                                }
                            }

                            foreach (var dc in delCatData.GetDirectArticles())
                            {
                                // delete CATXREF record
                                if (dc.TypeCode == "CATXREF")     // just check we have correct record. (stop nasty surprises)
                                {
                                    ModCtrl.Delete(dc.ItemID);
                                }
                            }
                            // delete CATEGORY record (constrants remove LANG records.)
                            ModCtrl.Delete(catid);
                        }
                        else
                        {
                            NBrightBuyUtils.SetNotfiyMessage(ModuleId, "onlyleafcat", NotifyCode.fail);
                        }
                    }
                }
                param[2] = "catid=" + _openid;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "saveall":
                SaveAll();
                NBrightBuyUtils.RemoveModCachePortalWide(PortalId);     //clear any cache
                param[2] = "catid=" + _openid;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "move":
                SaveAll();
                if (Utils.IsNumeric(cArg))
                {
                    MoveRecord(Convert.ToInt32(cArg));
                }
                param[2] = "catid=" + _openid;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "open":
                param[1] = "catid=" + cArg;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "close":
                var catData = CategoryUtils.GetCategoryData(_openid, EditLanguage);
                if (catData.DataRecord == null)
                {
                    param[1] = "catid=0";
                }
                else
                {
                    param[1] = "catid=" + catData.DataRecord.ParentItemId.ToString("");
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "save":
                UpdateRecord();
                param[1] = "eid=" + cArg;
                param[2] = "catid=" + _openid;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "saveexit":
                UpdateRecord();
                param[2] = "catid=" + _openid;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;
            }
        }
Ejemplo n.º 43
0
        private void cxBtnOk_Click(object sender, EventArgs e)
        {
            string sSQLServOldPwd, sSQLServNewPwd;

            if (cxTextEditOldPwd.EditValue == null || Convert.ToString(cxTextEditOldPwd.EditValue).Trim() == "")
            {
                oSecMainFrm.MessageDlg("Old Password cannot be blank...", "mtWarning", "mbOk", 0);
                return;
            }
            if (cxTextEditNewPwd.EditValue == null || Convert.ToString(cxTextEditNewPwd.EditValue).Trim() == "")
            {
                oSecMainFrm.MessageDlg("Please enter the new password.", "mtWarning", "mbOk", 0);
                return;
            }
            if (cxTextEditConfirmPwd.EditValue == null || Convert.ToString(cxTextEditConfirmPwd.EditValue).Trim() == "")
            {
                oSecMainFrm.MessageDlg("Please enter the confirm password.", "mtWarning", "mbOk", 0);
                return;
            }

            try
            {
                sSQLServOldPwd = XpedeonCrypto.XpedeonServerDecrypt(PCFSecurity.oSecDM.sSuperUserPassword);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            if (!Convert.ToString(cxTextEditOldPwd.EditValue).Equals(sSQLServOldPwd, StringComparison.InvariantCulture))
            {
                oSecMainFrm.MessageDlg("Old Password does not match.", "mtWarning", "mbOk", 0);
                return;
            }
            if (Convert.ToString(cxTextEditNewPwd.EditValue) != Convert.ToString(cxTextEditConfirmPwd.EditValue))
            {
                oSecMainFrm.MessageDlg("New Password and Confirm Password dont match.", "mtWarning", "mbOk", 0);
                return;
            }

            try
            {
                sSQLServNewPwd = XpedeonCrypto.XpedeonServerEncrypt(Convert.ToString(cxTextEditNewPwd.EditValue));
                UpdateSQLServPassword(Convert.ToString(cxTextEditUserName.EditValue), Convert.ToString(cxTextEditNewPwd.EditValue), Convert.ToString(cxTextEditOldPwd.EditValue));

                string sAppPath = Application.StartupPath.ToString();
                System.Xml.XmlDocument xdDataBaseConnection = new System.Xml.XmlDocument();
                xdDataBaseConnection.Load(@sAppPath + "\\PCFSecurityAccessInfo.xml");
                if (xdDataBaseConnection.GetElementsByTagName("PASSWORD").Count > 0)
                {
                    // Get the target node using XPath
                    System.Xml.XmlNode xnOldPwd = xdDataBaseConnection.SelectSingleNode("//PASSWORD");
                    // Create a new comment node with XML content of the target node
                    System.Xml.XmlComment xcOldPwd = xdDataBaseConnection.CreateComment(xnOldPwd.OuterXml);
                    // Replace the target node with the comment
                    xdDataBaseConnection.DocumentElement.ReplaceChild(xcOldPwd, xnOldPwd);

                    // Create a new node
                    System.Xml.XmlElement xeNewPwd = xdDataBaseConnection.CreateElement("PASSWORD");
                    xeNewPwd.InnerText = sSQLServNewPwd;
                    // Add the node to the document
                    xdDataBaseConnection.DocumentElement.AppendChild(xeNewPwd);
                }
                xdDataBaseConnection.Save(@sAppPath + "\\PCFSecurityAccessInfo.xml");

                PCFSecurity.oSecDM.DataModuleCreate();

                oSecMainFrm.MessageDlg("Password Changed Successfully.", "mtConfirmation", "mbOk", 0);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 44
0
		public bool SaveXML(string fileName)
		{
			var document = new System.Xml.XmlDocument();
			document.LoadXml(this.ToXML());
			document.Save(fileName);
			return true;
		}
Ejemplo n.º 45
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var param = new string[2];
            var targlist = _targetModuleKey.Split(',');
                switch (e.CommandName.ToLower())
                {
                    case "search":
                        foreach (var targ in targlist)
                        {
                            var strXml = GenXmlFunctions.GetGenXml(rpData, "", "");
                            var navigationData = new NavigationData(PortalId, targ);
                            navigationData.Build(strXml, _templD);
                            navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpData);
                            navigationData.XmlData = GenXmlFunctions.GetGenXml(rpData);
                            navigationData.Mode = GenXmlFunctions.GetField(rpData, "navigationmode").ToLower();
                            navigationData.Save();

                            if (StoreSettings.Current.DebugModeFileOut)
                            {
                                strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>";
                                var xmlDoc = new System.Xml.XmlDocument();
                                xmlDoc.LoadXml(strXml);
                                xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml");
                            }

                        }

                        Response.Redirect(Globals.NavigateURL(_redirecttabid, "", param), true);
                        break;
                    case "resetsearch":
                        // clear cookie info
                        foreach (var targ in targlist)
                        {
                            var navigationData = new NavigationData(PortalId, targ);
                            navigationData.Delete();
                        }
                        Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                        break;
                    case "orderby":
                        foreach (var targ in targlist)
                        {
                            var navigationData = new NavigationData(PortalId, targ);
                            navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpData);
                            navigationData.Save();
                        }
                        break;
                }
        }
Ejemplo n.º 46
0
 static void UpdateSysTables_unlocked(System.Xml.XmlDocument xd)
 {
     System.IO.MemoryStream ms = new System.IO.MemoryStream();
     xd.Save(ms);
     dfsclient.SetFileContent(SYSTABLES_FILENAME, "zd", ms.ToArray());
 }
Ejemplo n.º 47
0
        public void Extract_AfterSaveNoDispose()
        {
            string zipFileToCreate = Path.Combine(TopLevelDir, "Extract_AfterSaveNoDispose.zip");
            string inputString = "<AAA><bob><YourUncle/></bob><w00t/></AAA>";

            using (ZipFile zip1 = new ZipFile())
            {
                MemoryStream ms1 = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(inputString));
                zip1.AddEntry("woo\\Test.xml", ms1);
                zip1.Save(zipFileToCreate);

                MemoryStream ms2 = new MemoryStream();
                zip1["Woo/Test.xml"].Extract(ms2);
                ms2.Seek(0, SeekOrigin.Begin);

                var sw1 = new StringWriter();
                var w1 = new XTWFND(sw1);

                var d1 = new System.Xml.XmlDocument();
                d1.Load(ms2);
                d1.Save(w1);

                var sw2 = new StringWriter();
                var w2 = new XTWFND(sw2);
                var d2 = new System.Xml.XmlDocument();
                d2.Load(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(inputString)));
                d2.Save(w2);

                Assert.AreEqual<String>(sw2.ToString(), sw1.ToString(), "Unexpected value on extract ({0}).", sw1.ToString());
            }
        }
Ejemplo n.º 48
0
        private void SaveFile()
        {
            //Save the values to an XML file
            //Could save to data source, Message Queue etc.
            System.Xml.XmlDocument aDOM = new System.Xml.XmlDocument();
            System.Xml.XmlAttribute aAttribute;

            aDOM.LoadXml("<UserData/>");

            //Add the First Name attribute to XML
            aAttribute = aDOM.CreateAttribute("FirstName");
            aAttribute.Value = txtFName.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Add the Last Name attribute to XML
            aAttribute = aDOM.CreateAttribute("LastName");
            aAttribute.Value = txtLName.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Add the SSN attribute to XML
            aAttribute = aDOM.CreateAttribute("SSN");
            aAttribute.Value = txtSSN.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Save the file to the file system
            aDOM.Save("../../UserData.xml");
        }
Ejemplo n.º 49
0
 void DeleteHeightAndWidthFromSVGFile(string svgFile) {
     var fullpath = Path.Combine(workingDir, svgFile);
     var xml = new System.Xml.XmlDocument();
     xml.XmlResolver = null;
     xml.Load(fullpath);
     foreach (System.Xml.XmlNode node in xml.GetElementsByTagName("svg")) {
         var attr = node.Attributes["width"];
         if (attr != null) node.Attributes.Remove(attr);
         attr = node.Attributes["height"];
         if (attr != null) node.Attributes.Remove(attr);
     }
     xml.Save(fullpath);
 }
Ejemplo n.º 50
0
        public void SaveClassListXML(string filename)
        {
            System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
            System.Xml.XmlDeclaration xdec = xdoc.CreateXmlDeclaration("1.0", "utf-8", null);
            xdoc.AppendChild(xdec);
            System.Xml.XmlElement root = xdoc.CreateElement("ClassesList");
            for (int i = 0; i < classList.Count; i++)
            {
                System.Xml.XmlElement classNode = xdoc.CreateElement("Class");
                classNode.Attributes.Append(CreateAttribute("Title", classList[i].Title, xdoc));
                classNode.Attributes.Append(CreateAttribute("Subject", classList[i].Subject.ToString(), xdoc));
                classNode.Attributes.Append(CreateAttribute("Sch", classList[i].Sch.ToString(), xdoc));
                classNode.Attributes.Append(CreateAttribute("Index", classList[i].Index.ToString(), xdoc));
                classNode.Attributes.Append(CreateAttribute("Credits", classList[i].Credits.ToString(), xdoc));
                foreach (ClassSection cs in classList[i].Sections)
                {
                    System.Xml.XmlElement sectionNode = xdoc.CreateElement("Section");
                    sectionNode.Attributes.Append(CreateAttribute("SectionCode", cs.Section, xdoc));
                    sectionNode.Attributes.Append(CreateAttribute("RegistrationIndex", cs.RegistrationIndex, xdoc));

                    foreach (TimeFrame tf in cs.Times)
                    {
                        System.Xml.XmlElement timeframNode = xdoc.CreateElement("TimeFrame");
                        timeframNode.Attributes.Append(CreateAttribute("startDay", Enum.GetName(typeof(DayOfWeek), tf.StartTime.Day), xdoc));
                        timeframNode.Attributes.Append(CreateAttribute("startHour", tf.StartTime.Hour.ToString(), xdoc));
                        timeframNode.Attributes.Append(CreateAttribute("startMin", tf.StartTime.Minute.ToString(), xdoc));

                        timeframNode.Attributes.Append(CreateAttribute("endDay", Enum.GetName(typeof(DayOfWeek), tf.EndTime.Day), xdoc));
                        timeframNode.Attributes.Append(CreateAttribute("endHour", tf.EndTime.Hour.ToString(), xdoc));
                        timeframNode.Attributes.Append(CreateAttribute("endMin", tf.EndTime.Minute.ToString(), xdoc));
                        sectionNode.AppendChild(timeframNode);
                    }

                    classNode.AppendChild(sectionNode);
                }
                root.AppendChild(classNode);
            }
            xdoc.AppendChild(root);
            xdoc.Save(filename);
        }
Ejemplo n.º 51
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            //Save the values to an XML file
            //Could save to data source, Message Queue, etc.
            System.Xml.XmlDocument aDOM = new System.Xml.XmlDocument();
            System.Xml.XmlAttribute aAttribute;

            aDOM.LoadXml("<PersonnelData/>");

            //Add the First Name attribute to XML
            aAttribute = aDOM.CreateAttribute("FirstName");
            aAttribute.Value = txtFName.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the Last Name attribute to XML
            aAttribute = aDOM.CreateAttribute("LastName");
            aAttribute.Value = txtLName.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the DOB attribute to XML
            aAttribute = aDOM.CreateAttribute("DOB");
            aAttribute.Value = txtDOB.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the SSN attribute to XML
            aAttribute = aDOM.CreateAttribute("SSN");
            aAttribute.Value = txtSSN.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Save file to the file system
            aDOM.Save("PersonnelData.xml");
        }
Ejemplo n.º 52
0
        private static void DeleteRIndexes(string[] args)
        {
            string[] hosts = Utils.GetQizmtHosts();

            if (hosts.Length == 0)
            {
                Console.Error.WriteLine("No Qizmt host is found.");
                return;
            }

            const int MAX_TRIES = 10;
            Dictionary<string, StringBuilder> errs = new Dictionary<string, StringBuilder>(hosts.Length);
            string currentdir = CurrentDir.Replace(':', '$');
            int threadcount = hosts.Length;
            if (threadcount > 15)
            {
                threadcount = 15;
            }

            RDBMS_Admin.ThreadTools<string>.Parallel(
                new Action<string>(
                delegate(string host)
                {
                    int triesremain = MAX_TRIES;
                    string root = @"\\" + host + @"\" + currentdir + @"\";
                    string[] indfiles = System.IO.Directory.GetFiles(root, "ind.*.ind");

                    foreach (string indfile in indfiles)
                    {
                        for (; ; )
                        {
                            try
                            {
                                System.IO.File.Delete(indfile);
                                lock (hosts)
                                {
                                    Console.Write('.');
                                }
                                break;
                            }
                            catch (Exception e)
                            {
                                if (--triesremain <= 0)
                                {
                                    lock (hosts)
                                    {
                                        if (!errs.ContainsKey(host))
                                        {
                                            errs.Add(host, new StringBuilder(1024));
                                        }
                                        StringBuilder sb = errs[host];
                                        sb.Append(Environment.NewLine).Append("File: ").
                                        Append(indfile).Append("; Delete error: ").Append(e.ToString());
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    
                    string sysindex = root + "sys.indexes";
                    if (System.IO.File.Exists(sysindex))
                    {
                        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                        doc.Load(sysindex);
                        System.Xml.XmlNodeList indexes = doc.SelectNodes("//index");
                        for (int i = 0; i < indexes.Count; i++)
                        {
                            indexes[i].ParentNode.RemoveChild(indexes[i]);
                        }

                        triesremain = MAX_TRIES;
                        for (; ; )
                        {
                            try
                            {
                                doc.Save(sysindex);
                                lock (hosts)
                                {
                                    Console.Write('.');
                                }
                                break;
                            }
                            catch (Exception e)
                            {
                                if (--triesremain <= 0)
                                {
                                    lock (hosts)
                                    {
                                        if (!errs.ContainsKey(host))
                                        {
                                            errs.Add(host, new StringBuilder(1024));
                                        }
                                        StringBuilder sb = errs[host];
                                        sb.Append(Environment.NewLine).Append("File: ").
                                        Append(sysindex).Append("; Save error: ").Append(e.ToString());
                                    }
                                    break;
                                }
                            }
                        }
                    }    
                }
            ), hosts, threadcount);

            Console.WriteLine();

            if (errs.Count > 0)
            {
                Console.WriteLine("Errors encountered while trying to delete rindexes from these machines:");
                foreach (string host in errs.Keys)
                {
                    Console.WriteLine(host);
                    Console.WriteLine(errs[host].ToString());
                }
            }
            else
            {
                Console.WriteLine("Done");
            }
        }
Ejemplo n.º 53
0
        public bool Build(string exeFilename, params IMapItem[] items)
        {
            var location = GetLocation();

            CopyTemplateToTempFolder(location);

            var project     = new System.Xml.XmlDocument();
            var projectPath = Path.Combine(TempDir, "JoystickMerger.Feeder", "JoystickMerger.Feeder.csproj");

            project.Load(projectPath);
            foreach (System.Xml.XmlNode node in project.DocumentElement)
            {
                if (node.Name == "PropertyGroup" /*&& node.GetAttribute("Condition") == "'$(Configuration)|$(Platform)' == 'Release|x64'"*/)
                {
                    foreach (System.Xml.XmlNode propNode in node.ChildNodes)
                    {
                        if (propNode.Name == "OutputPath")
                        {
                            propNode.InnerText = Path.GetDirectoryName(exeFilename);
                        }
                        else if (propNode.Name == "AssemblyName")
                        {
                            propNode.InnerText = Path.GetFileNameWithoutExtension(exeFilename);
                        }
                    }
                }
            }
            project.Save(projectPath);

            var feederPath = Path.Combine(TempDir, "JoystickMerger.Feeder", "JoystickMerger.xml");


            var info = new CompileInfo();

            foreach (var item in items)
            {
                item.Initialize(info);
            }
            info.EndInitialization();

            using (var file = File.CreateText(System.IO.Path.Combine(TempDir, "JoystickMerger.Feeder", "GameDevPoller.Generated.cs")))
            {
                file.WriteLine("using System;");
                file.WriteLine("using System.Collections.Generic;");
                file.WriteLine("using System.Linq;");
                file.WriteLine("using System.Text;");
                file.WriteLine("using SharpDX;");
                file.WriteLine("using SharpDX.DirectInput;");
                file.WriteLine("using System.Windows.Forms;");
                file.WriteLine("using vJoyInterfaceWrap;");
                file.WriteLine();
                file.WriteLine("// This file is generated with JoystickMerger.Generator. Do not edit.");
                file.WriteLine("namespace JoystickMerger.Feeder");
                file.WriteLine("{");
                file.WriteLine("    partial class GameDevPoller");
                file.WriteLine("    {");
                file.WriteLine("        // vJoy device number.");
                file.WriteLine("        const uint id = 1;");

                foreach (var item in items)
                {
                    item.Declaration(info, file);
                }
                file.WriteLine();

                ValidateVJoyConfiguration(info, file);

                foreach (var item in items)
                {
                    item.PreFeed(info, file);
                }
                file.WriteLine("        private void Feed()");
                file.WriteLine("        {");
                foreach (var item in items)
                {
                    item.Feed(info, file);
                }
                file.WriteLine("        }");
                file.WriteLine();

                foreach (var item in items)
                {
                    item.PostFeed(info, file);
                }

                file.WriteLine("    }");
                file.WriteLine("}");
            }


            return(RunCompiler());
        }
Ejemplo n.º 54
0
		/// <summary>
		/// Example showing:
		///  - how to find a MessagePart with a specified MediaType
		///  - how to get the body of a MessagePart as a string
		/// </summary>
		/// <param name="message">The message to examine for xml</param>
		public static void FindXmlInMessage(Message message)
		{
			MessagePart xml = message.FindFirstMessagePartWithMediaType("text/xml");
			if (xml != null)
			{
				// Get out the XML string from the email
				string xmlString = xml.GetBodyAsText();

				System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

				// Load in the XML read from the email
				doc.LoadXml(xmlString);

				// Save the xml to the filesystem
				doc.Save("test.xml");
			}
		}
Ejemplo n.º 55
0
        private void saveResultsMenuItem_Click(object sender, System.EventArgs e)
        {
            DialogResult r = saveResultFileDialog.ShowDialog(this);
            if (r == DialogResult.OK && saveResultFileDialog.FileName != null)
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                System.Xml.XmlElement topElement =
                    SaveRootNodeToXmlElement(doc, UPnpTestRoot);

                doc.LoadXml("<ValidatorData></ValidatorData>");
                doc.DocumentElement.AppendChild(topElement);

                System.Xml.XmlTextWriter textWriter =
                    new System.Xml.XmlTextWriter(saveResultFileDialog.FileName, null);
                textWriter.Formatting = System.Xml.Formatting.Indented;
                doc.Save(textWriter);

                #region Old code that is commented out and thus no longer used
                /* This has been commented out because we don't really want to
                 * completely serialize the plugins anymore.  The way we really
                 * want to save is just the log, results and packet trace to XML as
                 * done after this commented out region.
                 *
                 * Hashtable table = new Hashtable();
                StoreNodeTagsToTable(UPnpTestRoot,table);

                foreach (IUPnPTestGroup test in table.Values)
                {
                    test.OnPacketTraceChanged -= new PacketTraceHandler(OnPacketTraceChangedSink);
                    test.OnProgressChanged -= new System.EventHandler(OnProgressChangedSink);
                    test.OnStateChanged -= new System.EventHandler(OnStateChangedSink);
                    //test.OnLogChanged -= new System.EventHandler(OnLogChangedSink);
                }

                IFormatter formatter = new BinaryFormatter();
                Stream stream = new FileStream(saveResultFileDialog.FileName, FileMode.Create, FileAccess.Write, FileShare.None);
                formatter.Serialize(stream, table);
                stream.Close();

                foreach (IUPnPTestGroup test in table.Values)
                {
                    test.OnPacketTraceChanged += new PacketTraceHandler(OnPacketTraceChangedSink);
                    test.OnProgressChanged += new System.EventHandler(OnProgressChangedSink);
                    test.OnStateChanged += new System.EventHandler(OnStateChangedSink);
                    //test.OnLogChanged += new System.EventHandler(OnLogChangedSink);
                }
                */
                #endregion

            }
        }
Ejemplo n.º 56
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            //Save the values to an XML file
            //Could save to data source, Message Queue, etc.
            System.Xml.XmlDocument aDOM = new System.Xml.XmlDocument();
            System.Xml.XmlAttribute aAttribute;

            aDOM.LoadXml("<AutomobileData/>");

            //Add the First Name attribute to XML
            aAttribute = aDOM.CreateAttribute("Manufacturer");
            aAttribute.Value = txtManufact.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the Last Name attribute to XML
            aAttribute = aDOM.CreateAttribute("Model");
            aAttribute.Value = txtModel.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the DOB attribute to XML
            aAttribute = aDOM.CreateAttribute("Year");
            aAttribute.Value = txtYear.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the SSN attribute to XML
            aAttribute = aDOM.CreateAttribute("Color");
            aAttribute.Value = txtColor.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Save file to the file system
            aDOM.Save("AutomobileData.xml");
        }
Ejemplo n.º 57
0
 bool svgconcat(List<string> files, string output, uint delay, uint loop) {
     if (controller_ != null) controller_.appendOutput("TeX2img: Making animation svg...");
     try {
         var outxml = new System.Xml.XmlDocument();
         outxml.XmlResolver = null;
         outxml.AppendChild(outxml.CreateXmlDeclaration("1.0", "utf-8", "no"));
         outxml.AppendChild(outxml.CreateDocumentType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", null));
         var svg = outxml.CreateElement("svg", "http://www.w3.org/2000/svg");
         var attr = outxml.CreateAttribute("xmlns:xlink");
         attr.Value = "http://www.w3.org/1999/xlink";
         svg.Attributes.Append(attr);
         attr = outxml.CreateAttribute("version");
         attr.Value = "1.1";
         svg.Attributes.Append(attr);
         outxml.AppendChild(svg);
         var defs = outxml.CreateElement("defs", "http://www.w3.org/2000/svg");
         svg.AppendChild(defs);
         var idreg = new System.Text.RegularExpressions.Regex(@"(?<!\&)#");
         foreach (var f in files) {
             var id = Path.GetFileNameWithoutExtension(f);
             var xml = new System.Xml.XmlDocument();
             xml.XmlResolver = null;
             xml.Load(Path.Combine(workingDir, f));
             foreach (System.Xml.XmlNode tag in xml.GetElementsByTagName("*")) {
                 foreach (System.Xml.XmlAttribute a in tag.Attributes) {
                     if (a.Name.ToLower() == "id") a.Value = id + "-" + a.Value;
                     else a.Value = idreg.Replace(a.Value, "#" + id + "-");
                 }
             }
             foreach (System.Xml.XmlNode tag in xml.GetElementsByTagName("svg")) {
                 var idattr = xml.CreateAttribute("id");
                 idattr.Value = id;
                 tag.Attributes.Append(idattr);
             }
             foreach (System.Xml.XmlNode n in xml.ChildNodes) {
                 if (n.NodeType != System.Xml.XmlNodeType.DocumentType && n.NodeType != System.Xml.XmlNodeType.XmlDeclaration) {
                     defs.AppendChild(outxml.ImportNode(n, true));
                 }
             }
         }
         var use = outxml.CreateElement("use", "http://www.w3.org/2000/svg");
         svg.AppendChild(use);
         var animate = outxml.CreateElement("animate", "http://www.w3.org/2000/svg");
         use.AppendChild(animate);
         attr = outxml.CreateAttribute("attributeName");
         attr.Value = "xlink:href"; animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("begin");
         attr.Value = "0s"; animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("dur");
         attr.Value = ((decimal)(delay * files.Count) / 100).ToString() + "s";
         animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("repeatCount");
         attr.Value = loop > 0 ? loop.ToString() : "indefinite";
         animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("values");
         attr.Value = String.Join(";", files.Select(d => "#" + Path.GetFileNameWithoutExtension(d)).ToArray());
         animate.Attributes.Append(attr);
         outxml.Save(Path.Combine(workingDir, output));
         if (controller_ != null) controller_.appendOutput(" done\n");
         return true;
     }
     catch (Exception) { return false; }
 }
Ejemplo n.º 58
0
        /// <summary>
        /// This method splits a k2 project in to multiple files.  One for each artifac.  The artifacts must be flagged as included in the original project, else they are omitted
        /// </summary>
        /// <param name="k2DeploymentFolder">The current temporary location of the files</param>
        /// <param name="k2ProjectFilePath">The current path to the original file to use</param>
        /// <returns></returns>
        private Dictionary <string, string> CreateProjectForEachProjectArtifact(string k2DeploymentFolder, string k2ProjectFilePath)
        {
            //stores a key value pair,  The key will be the name of the artifact and the value is the path to its k2project.
            Dictionary <string, string> dictFileNames = new Dictionary <string, string>();

            //stores the list of folders in the solution
            List <String> folders = new List <string>();
            //stores the list of artifacts in the solution.  The artifacts must be "included"
            List <String> k2Artifacts = new List <string>();

            //stores the list of un-necessary nodes "ItemGroup" that need to be removed.  For this solution we only need 2, one for the folders and one for the artifacts.
            List <System.Xml.XmlNode> oldNodes = new List <System.Xml.XmlNode>();

            //use xml to create each file.
            //Load the original file for manipulation
            System.Xml.XmlDocument origK2ProjXML = new System.Xml.XmlDocument();
            origK2ProjXML.Load(k2ProjectFilePath);


            //counter to track the number of ItemGroup nodes encountered
            int countItemGroups = 1;

            //loop through all of the notes in the Project document
            foreach (System.Xml.XmlNode child in origK2ProjXML.FirstChild.ChildNodes)
            {
                //especifically we are looking for the ItemGroup node.
                if (child.Name == "ItemGroup")
                {
                    if (countItemGroups > 2)
                    {
                        //we only need two
                        //add it to the list of oldNodes that will be removed.
                        oldNodes.Add(child);
                    }

                    //We need to get the list of folders and process that have been included by default
                    FillFolderAndProcessList(child, ref folders, ref k2Artifacts);
                    countItemGroups += 1;
                }
            }

            //remove any ItemGroup reference above the ones that are necessary
            foreach (System.Xml.XmlNode oldNode in oldNodes)
            {
                origK2ProjXML.FirstChild.RemoveChild(oldNode);
            }

            //For each k2Artifact included in the original project, we need to create its own project file.
            foreach (string artifact in k2Artifacts)
            {
                //this will be the new file name for this solution
                string fileName = string.Empty;
                //Get a cleansed name to be use as a subfolder later on.
                //Todo:Not sure if artifacts w/ the same name will cause problems
                string artifactName = GetProjectNameFromArtifactName(artifact);

                //Generate new ItemGroup Nodes, with the setting that we need.
                System.Xml.XmlElement foldersItemGroupNode  = CreateItemGroupFolderNode(folders, origK2ProjXML);
                System.Xml.XmlElement artifactItemGroupNode = CreateItemGroupContentNode(artifact, origK2ProjXML);

                //again, we have to count the ItemGroup nodes.
                //I couldn't get this to work otherwise. Creating a new document create other sideaffects.  Mainly each node is saved with an empty xmlns (namespace), which MSBuild did not like
                int itemCount = 1;

                //for each of the 2 nodes in the project file - reset the inner xml to the values we need.
                //Todo: look in to storing these nodes in a list in previous steps, then reset them here and just do a replace child node.
                foreach (System.Xml.XmlNode child in origK2ProjXML.FirstChild.ChildNodes)
                {
                    //especifically we are looking for the ItemGroup node.
                    if (child.Name == "ItemGroup")
                    {
                        if (itemCount == 1)
                        {
                            child.InnerXml = foldersItemGroupNode.InnerXml;
                        }
                        else
                        {
                            child.InnerXml = artifactItemGroupNode.InnerXml;
                        }
                        itemCount += 1;
                    }
                }

                //create a new file name for this artifact.
                fileName = k2DeploymentFolder + @"\" + artifactName + ".k2proj";

                //Save the project
                origK2ProjXML.Save(fileName);

                //track the name of the artifact and its corresponding project file
                dictFileNames.Add(artifactName, fileName);
            }

            return(dictFileNames);
        }
Ejemplo n.º 59
0
    // Set SoundBank-related bool settings in the wproj file.
    public static bool EnableBoolSoundbankSettingInWproj(string SettingName, string WwiseProjectPath)
    {
        try
        {
            if (WwiseProjectPath.Length == 0)
            {
                return(true);
            }

            var doc = new System.Xml.XmlDocument {
                PreserveWhitespace = true
            };
            doc.Load(WwiseProjectPath);
            var Navigator = doc.CreateNavigator();

            // Navigate the wproj file (XML format) to where our setting should be
            var pathInXml  = string.Format("/WwiseDocument/ProjectInfo/Project/PropertyList/Property[@Name='{0}']", SettingName);
            var expression = System.Xml.XPath.XPathExpression.Compile(pathInXml);
            var node       = Navigator.SelectSingleNode(expression);
            if (node == null)
            {
                // Setting isn't in the wproj, add it
                // Navigate to the SoundBankHeaderFilePath property (it is always there)
                expression =
                    System.Xml.XPath.XPathExpression.Compile(
                        "/WwiseDocument/ProjectInfo/Project/PropertyList/Property[@Name='SoundBankHeaderFilePath']");
                node = Navigator.SelectSingleNode(expression);
                if (node == null)
                {
                    // SoundBankHeaderFilePath not in wproj, invalid wproj file
                    UnityEngine.Debug.LogError(
                        "WwiseUnity: Could not find SoundBankHeaderFilePath property in Wwise project file. File is invalid.");
                    return(false);
                }

                // Add the setting right above SoundBankHeaderFilePath
                var propertyToInsert = string.Format("<Property Name=\"{0}\" Type=\"bool\" Value=\"True\"/>", SettingName);
                node.InsertBefore(propertyToInsert);
            }
            else if (node.GetAttribute("Value", "") == "False")
            {
                // Value is present, we simply have to modify it.
                if (!node.MoveToAttribute("Value", ""))
                {
                    return(false);
                }

                // Modify the value to true
                node.SetValue("True");
            }
            else
            {
                // Parameter already set, nothing to do!
                return(true);
            }

            doc.Save(WwiseProjectPath);
            return(true);
        }
        catch
        {
            return(false);
        }
    }
        /// <summary>
        /// Implements IComponent.Execute method.
        /// </summary>
        /// <param name="pc">Pipeline context</param>
        /// <param name="inmsg">Input message</param>
        /// <returns>Original input message</returns>
        /// <remarks>
        /// IComponent.Execute method is used to initiate
        /// the processing of the message in this pipeline component.
        /// </remarks>
        public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pipelineContext,
                                                                      Microsoft.BizTalk.Message.Interop.IBaseMessage inputMsg)
        {
            System.Diagnostics.Debug.WriteLine("At top of Execute method for DBASE pipeline");
            IBaseMessagePart bodyPart = inputMsg.BodyPart;

            if (bodyPart != null)
            {
                try
                {
                    // First write the ODBC file to disk so can query it.
                    BinaryReader binaryReader = new BinaryReader(bodyPart.Data);
                    string       folderName   = this.TempDropFolderLocation;
                    if (folderName.Substring(folderName.Length - 1, 1) != "\\")
                    {
                        folderName += "\\";
                    }
                    string extension = (this.TypeToProcess == odbcType.Excel) ? ".xls" : ".dbf";
                    string filename  = System.IO.Path.GetRandomFileName();
                    filename  = filename.Remove(8);
                    filename += extension;
                    string       folderNameAndFileName = folderName + filename;
                    FileStream   fileStream            = new FileStream(folderNameAndFileName, FileMode.CreateNew);
                    BinaryWriter binaryWriter          = new BinaryWriter(fileStream);
                    binaryWriter.Write(binaryReader.ReadBytes(Convert.ToInt32(binaryReader.BaseStream.Length)));
                    binaryWriter.Close();
                    binaryReader.Close();

                    // Create the Connection String for the ODBC File
                    string dataSource;
                    if (this.TypeToProcess == odbcType.Excel)
                    {
                        dataSource = "Data Source=" + folderNameAndFileName + ";";
                    }
                    else // dbf
                    {
                        dataSource = "Data Source=" + folderName + ";";
                    }
                    string odbcConnectionString = this.connectionString;
                    if (odbcConnectionString.Substring(odbcConnectionString.Length - 1, 1) != ";")
                    {
                        odbcConnectionString += ";";
                    }
                    odbcConnectionString += dataSource;
                    OleDbConnection oConn = new OleDbConnection();
                    oConn.ConnectionString = odbcConnectionString;

                    // Create the Select Statement for the ODBC File
                    OleDbDataAdapter oCmd;
                    // Get the filter if there is one
                    string whereClause = "";
                    if (Filter.Trim() != "")
                    {
                        whereClause = " Where " + Filter.Trim();
                    }
                    if (this.TypeToProcess == odbcType.Excel)
                    {
                        oCmd = new OleDbDataAdapter(this.SqlStatement.Trim() + whereClause, oConn);
                    }
                    else // dbf
                    {
                        oCmd = new OleDbDataAdapter(this.SqlStatement.Trim() + " From " + filename + whereClause, oConn);
                    }
                    oConn.Open();
                    // Perform the Select statement from above into a dataset, into a DataSet.
                    DataSet odbcDataSet = new DataSet();
                    oCmd.Fill(odbcDataSet, this.DataNodeName);
                    oConn.Close();
                    // Delete the message
                    if (this.DeleteTempMessages)
                    {
                        System.IO.File.Delete(folderNameAndFileName);
                    }

                    // Write the XML From this DataSet into a String Builder
                    System.Text.StringBuilder stringBuilder = new StringBuilder();
                    System.IO.StringWriter    stringWriter  = new System.IO.StringWriter(stringBuilder);
                    odbcDataSet.Tables[0].WriteXml(stringWriter);

                    System.Xml.XmlDocument fromDataSetXMLDom = new System.Xml.XmlDocument();
                    fromDataSetXMLDom.LoadXml(stringBuilder.ToString());

                    // Create the Final XML Document. Root Node Name and Target Namespace
                    // come from properties set on the pipeline
                    System.Xml.XmlDocument finalMsgXmlDom = new System.Xml.XmlDocument();
                    System.Xml.XmlElement  xmlElement;
                    xmlElement = finalMsgXmlDom.CreateElement("ns0", this.RootNodeName, this.NameSpace);
                    finalMsgXmlDom.AppendChild(xmlElement);

                    // Add the XML to the finalMsgXmlDom from the DataSet XML,
                    // After this the XML Message will be complete
                    finalMsgXmlDom.FirstChild.InnerXml = fromDataSetXMLDom.FirstChild.InnerXml;

                    Stream strm = new MemoryStream();
                    // Save final XML Document to Stream
                    finalMsgXmlDom.Save(strm);
                    strm.Position = 0;
                    bodyPart.Data = strm;
                    pipelineContext.ResourceTracker.AddResource(strm);
                }
                catch (System.Exception ex)
                {
                    throw ex;
                }
            }
            return(inputMsg);
        }