Exemplo n.º 1
0
Arquivo: Config.cs Projeto: baiy/login
 /// <summary>
 /// 读取配置文件
 /// </summary>
 public void ReaderConfig()
 {
     if (ExistsConfig())
     {
         string[] str = File.ReadAllLines(path, System.Text.Encoding.Default);
         string data = string.Join("", str);
         JavaScriptSerializer js = new JavaScriptSerializer();
         config = js.Deserialize<DataConfig>(data);
         config.EncryptKey = Encrypt.decode(config.EncryptKey, configkey);
     }
     else
     {
         throw new Exception("没有获取到程序配置 请先在程序下方写入程序配置");
     }
 }
Exemplo n.º 2
0
Arquivo: Config.cs Projeto: baiy/login
 /// <summary>
 /// 读取配置文件
 /// </summary>
 public void ReaderConfig()
 {
     if (ExistsConfig())
     {
         string[]             str  = File.ReadAllLines(path, System.Text.Encoding.Default);
         string               data = string.Join("", str);
         JavaScriptSerializer js   = new JavaScriptSerializer();
         config            = js.Deserialize <DataConfig>(data);
         config.EncryptKey = Encrypt.decode(config.EncryptKey, configkey);
     }
     else
     {
         throw new Exception("没有获取到程序配置 请先在程序下方写入程序配置");
     }
 }
Exemplo n.º 3
0
Arquivo: Config.cs Projeto: baiy/login
 /// <summary>
 /// 写入配置文件
 /// </summary>
 /// <param name="ApiUrl">api url</param>
 /// <param name="EncryptKey">通讯秘钥</param>
 public void WriteConfig(string ApiUrl, string EncryptKey, string FtpPath, string SshPath,string FtpCmd,string SshCmd)
 {
     JavaScriptSerializer js = new JavaScriptSerializer();
     DataConfig team = new DataConfig()
     {
        ApiUrl = ApiUrl,
        FtpPath = FtpPath,
        SshPath = SshPath,
        FtpCmd  = FtpCmd,
        SshCmd = SshCmd,
        EncryptKey = Encrypt.encode(EncryptKey, configkey)//通讯秘钥二次加密
     };
     string json = js.Serialize(team);
     StreamWriter sw = new StreamWriter(path, false);
     sw.WriteLine(json);
     sw.Close();
 }
Exemplo n.º 4
0
Arquivo: Config.cs Projeto: baiy/login
        /// <summary>
        /// 写入配置文件
        /// </summary>
        /// <param name="ApiUrl">api url</param>
        /// <param name="EncryptKey">通讯秘钥</param>
        public void WriteConfig(string ApiUrl, string EncryptKey, string FtpPath, string SshPath, string FtpCmd, string SshCmd)
        {
            JavaScriptSerializer js   = new JavaScriptSerializer();
            DataConfig           team = new DataConfig()
            {
                ApiUrl     = ApiUrl,
                FtpPath    = FtpPath,
                SshPath    = SshPath,
                FtpCmd     = FtpCmd,
                SshCmd     = SshCmd,
                EncryptKey = Encrypt.encode(EncryptKey, configkey)//通讯秘钥二次加密
            };
            string       json = js.Serialize(team);
            StreamWriter sw   = new StreamWriter(path, false);

            sw.WriteLine(json);
            sw.Close();
        }