コード例 #1
0
        public static bool InitXml()
        {
            try
            {
                //File.Create("Config.xml").Close();
                XmlDocument xmlDoc = new XmlDocument();
                //创建类型声明节点
                XmlNode node = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "");
                xmlDoc.AppendChild(node);
                //创建根节点
                XmlNode root = xmlDoc.CreateElement("root");
                xmlDoc.AppendChild(root);
                //xmlDoc.AppendChild(xmlDoc.CreateElement("/root"));
                xmlDoc.Save("Config.xml");
                string data = "connStr," + TextProcessing.SuperEncrypt("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}; Jet OLEDB:Database Password ={1}", "zjsxzsta", "zjsxzstb");

                FilesClasses.addXml("Config.xml", "root", "content", "name,value", data);
                data = "honeybee,";
                FilesClasses.addXml("Config.xml", "root", "content", "name,value", data);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #2
0
        public static bool InitXml(string connStr, string pwd)
        {
            try
            {
                //File.Create("Config.xml").Close();
                XmlDocument xmlDoc = new XmlDocument();
                //创建类型声明节点
                XmlNode node = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "");
                xmlDoc.AppendChild(node);
                //创建根节点
                XmlNode root = xmlDoc.CreateElement("root");
                xmlDoc.AppendChild(root);
                //xmlDoc.AppendChild(xmlDoc.CreateElement("/root"));
                xmlDoc.Save("Config.xml");
                string data = "connStr," + TextProcessing.SuperEncrypt(connStr, "zjsxzsta", "zjsxzstb");

                FilesClasses.addXml("Config.xml", "root", "content", "name,value", data);
                data = "honeybee," + TextProcessing.SuperEncrypt(pwd, "zjsxzsta", "zjsxzstb");
                FilesClasses.addXml("Config.xml", "root", "content", "name,value", data);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #3
0
        private static OleDbConnection con = new OleDbConnection(connStr);                                 // TODO: 在此处添加构造函数逻辑
        private static void Init()
        {
            SqlData sd   = new SqlData();
            string  data = "";

            XmlTest <SqlData> .DSerialize(ref sd, "Config.xml", ref data);

            PassWD  = TextProcessing.SuperDesDecrypt(sd.honeybee, "zjsxzsta", "zjsxzstb");
            connStr = String.Format(TextProcessing.SuperDesDecrypt(sd.connStr, "zjsxzsta", "zjsxzstb"), Flie_Path, PassWD);
            con     = new OleDbConnection(connStr);
            //SqlProcessing<SqlData>.Init(sd.connStr, sd.honeybee);
        }