Beispiel #1
0
        private void Window_Closed(object sender, EventArgs e)
        {
            XmlConfigUtil util = new XmlConfigUtil("config.xml");

            util.Write(BattleNetPath, "BattleNetPath");
            util.Write(HearthbuddyPath, "HearthbuddyPath");
            util.Write(BNHSInterval.ToString(), "BNHSInterval");
            util.Write(HSHBInterval.ToString(), "HSHBInterval");
            util.Write(CheckInterval.ToString(), "CheckInterval");

            util.Write(StartTime.Hour.ToString(), "StartTime");
            util.Write(EndTime.Hour.ToString(), "EndTime");

            string logDirectory = Path.Combine(this.BaseDirectory, "Logs");

            if (!Directory.Exists(logDirectory)) //防止目录不存在报错
            {
                Directory.CreateDirectory(logDirectory);
            }
            string logPath = Path.Combine(logDirectory, $"HearthbuddyHelper_{DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss")}.log");

            using (StreamWriter sw = new StreamWriter(logPath, true, System.Text.Encoding.UTF8))
            {
                sw.Write(LogTextBox.Text);
            }

            Environment.Exit(0);
        }
Beispiel #2
0
        public void SaveToXML(XmlDocument doc, IDTSInfoEvents infoEvents)
        {
            var data = doc.CreateElement("WaitForSignalData");

            data.SetAttribute("CheckInterval", CheckInterval.ToString());
            data.SetAttribute("SignalVariable", SignalVariable);
            doc.AppendChild(data);
        }
Beispiel #3
0
        /// <summary>
        /// Serializes the WaitForFile settings into XML
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="infoEvents"></param>
        void IDTSComponentPersist.SaveToXML(System.Xml.XmlDocument doc, IDTSInfoEvents infoEvents)
        {
            XmlElement data = doc.CreateElement("WaitForFilesData");

            doc.AppendChild(data);

            data.SetAttribute("checkType", CheckType.ToString());
            data.SetAttribute("existenceType", ExistenceType.ToString());
            data.SetAttribute("checkTimeoutInterval", CheckTimeoutInterval.ToString());
            data.SetAttribute("checkTimeoutTime", checkTimeoutTime.ToString());
            data.SetAttribute("checkInterval", CheckInterval.ToString());
            data.SetAttribute("timeoutNextDayIfTimePassed", TimeoutNextDayIfTimePassed.ToString());

            XmlElement filesNode = doc.CreateElement("checkFiles");

            data.AppendChild(filesNode);

            foreach (string file in files)
            {
                XmlElement fileNode = doc.CreateElement("file");
                fileNode.SetAttribute("name", file);
                filesNode.AppendChild(fileNode);
            }
        }
        public XmlDocument ExportConfigurationToXml()
        {
            string xemailNS = "http://www.siprod.net/namespaces/XEMail/ClientConfig";
            string emptyNS  = string.Empty;

            XmlDocument doc  = new XmlDocument();
            XmlNode     root = doc.CreateNode(XmlNodeType.Element, "XEMailClientConfig", xemailNS);

            doc.AppendChild(root);

            XmlNode clientNode = doc.CreateNode(XmlNodeType.Element, "ClientConfig", xemailNS);

            root.AppendChild(clientNode);
            GenerateChildNode(clientNode, xemailNS, "AutoCheckEnabled", AutoCheckEnabled.ToString(), ref doc);
            GenerateChildNode(clientNode, xemailNS, "CheckInterval", CheckInterval.ToString(), ref doc);
            GenerateChildNode(clientNode, xemailNS, "WebserviceUrl", WebserviceUrl, ref doc);

            XmlNode netProxyNode = doc.CreateNode(XmlNodeType.Element, "NetworkProxy", xemailNS);

            clientNode.AppendChild(netProxyNode);
            GenerateChildNode(netProxyNode, xemailNS, "Enabled", networkProxy.Enabled.ToString(), ref doc);
            GenerateChildNode(netProxyNode, xemailNS, "Url", networkProxy.Url, ref doc);
            GenerateChildNode(netProxyNode, xemailNS, "Port", networkProxy.Port.ToString(), ref doc);
            GenerateChildNode(netProxyNode, xemailNS, "User", networkProxy.User, ref doc);
            GenerateChildNode(netProxyNode, xemailNS, "Password", EncryptedDataHelper.ConvertToNumbersString(MachineBasedRijndaelEncryptor.Encrypt(networkProxy.Password)), ref doc);
            GenerateChildNode(netProxyNode, xemailNS, "Domain", networkProxy.Domain, ref doc);

            XmlNode accountsNode = doc.CreateNode(XmlNodeType.Element, "Accounts", xemailNS);

            clientNode.AppendChild(accountsNode);
            XmlNode accountNode;

            foreach (string key in accounts.Keys)
            {
                XEMailAccount account = accounts[key];
                accountNode = doc.CreateNode(XmlNodeType.Element, "Account", xemailNS);

                GenerateChildNode(accountNode, xemailNS, "AccountName", account.AccountName, ref doc);
                GenerateChildNode(accountNode, xemailNS, "UseSameCredentials", account.UseSameCredentialsToSend.ToString(), ref doc);

                XmlNode incomingServerNode = doc.CreateNode(XmlNodeType.Element, "IncomingServer", xemailNS);
                accountNode.AppendChild(incomingServerNode);
                GenerateChildNode(incomingServerNode, xemailNS, "ServerEnabled", account.IncomingServer.ServerEnabled.ToString(), ref doc);
                GenerateChildNode(incomingServerNode, xemailNS, "ServerProtocol", account.IncomingServer.ServerProtocol.ToString(), ref doc);
                GenerateChildNode(incomingServerNode, xemailNS, "ServerName", account.IncomingServer.ServerName, ref doc);
                GenerateChildNode(incomingServerNode, xemailNS, "ServerPort", account.IncomingServer.ServerPort.ToString(), ref doc);
                GenerateChildNode(incomingServerNode, xemailNS, "UserName", account.IncomingServer.Username, ref doc);
                GenerateChildNode(incomingServerNode, xemailNS, "UserPassword", EncryptedDataHelper.ConvertToNumbersString(MachineBasedRijndaelEncryptor.Encrypt(account.IncomingServer.UserPassword)), ref doc);
                GenerateChildNode(incomingServerNode, xemailNS, "SslEnabled", account.IncomingServer.SslEnabled.ToString(), ref doc);

                XmlNode outgoingServerNode = doc.CreateNode(XmlNodeType.Element, "OutgoingServer", xemailNS);
                accountNode.AppendChild(outgoingServerNode);
                GenerateChildNode(outgoingServerNode, xemailNS, "ServerEnabled", account.OutgoingServer.ServerEnabled.ToString(), ref doc);
                GenerateChildNode(outgoingServerNode, xemailNS, "ServerProtocol", account.OutgoingServer.ServerProtocol.ToString(), ref doc);
                GenerateChildNode(outgoingServerNode, xemailNS, "ServerName", account.OutgoingServer.ServerName, ref doc);
                GenerateChildNode(outgoingServerNode, xemailNS, "ServerPort", account.OutgoingServer.ServerPort.ToString(), ref doc);
                GenerateChildNode(outgoingServerNode, xemailNS, "UserName", account.OutgoingServer.Username, ref doc);
                GenerateChildNode(outgoingServerNode, xemailNS, "UserPassword", EncryptedDataHelper.ConvertToNumbersString(MachineBasedRijndaelEncryptor.Encrypt(account.OutgoingServer.UserPassword)), ref doc);
                GenerateChildNode(outgoingServerNode, xemailNS, "SslEnabled", account.OutgoingServer.SslEnabled.ToString(), ref doc);

                accountsNode.AppendChild(accountNode);
            }

            clientNode.AppendChild(accountsNode);

            return(doc);
        }