Ejemplo n.º 1
0
        public SysSecurityConfig()
        {
            FileEncryptHelper encrypt = new FileEncryptHelper();

            if (File.Exists(CONFIG_FILE))
            {
                //byte[] buff = encrypt.DecryptFile( CONFIG_FILE );
                // this.LoadConfig( buff );
                this.m_Root = XElement.Load(CONFIG_FILE);
                this.LoadConfig(null);
            }
        }
Ejemplo n.º 2
0
        public void Save()
        {
            var first_eles = this.m_Root.Elements();

            foreach (XElement first_ele in first_eles)
            {
                var second_eles = first_ele.Elements();
                foreach (XElement second_ele in second_eles)
                {
                    if (second_ele.Name.LocalName.Equals("sqlserver"))
                    {
                        second_ele.Value = this.SqlServerConnectionString;
                    }
                    else if (second_ele.Name.LocalName.Equals("sqlite"))
                    {
                        second_ele.Value = this.SqliteConnectionString;
                    }
                    else if (second_ele.Name.LocalName.Equals("table"))
                    {
                        second_ele.Value = this.LogTableName;
                    }
                    else if (second_ele.Name.LocalName.Equals("text"))
                    {
                        second_ele.Value = this.LogTextFilePath;
                    }
                    else if (second_ele.Name.LocalName.Equals("default"))
                    {
                        second_ele.Value = this.DefaultDatabase;
                    }
                }
            }

            MemoryStream ms = new MemoryStream();

            this.m_Root.Save(ms, SaveOptions.DisableFormatting);
            FileEncryptHelper encrypt = new FileEncryptHelper();

            encrypt.EncryptFile(ms.ToArray(), CONFIG_FILE);
            ms.Close();
        }