예제 #1
0
파일: Config.cs 프로젝트: 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("没有获取到程序配置 请先在程序下方写入程序配置");
     }
 }
예제 #2
0
파일: Config.cs 프로젝트: 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("没有获取到程序配置 请先在程序下方写入程序配置");
     }
 }
예제 #3
0
파일: Config.cs 프로젝트: 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();
 }
예제 #4
0
파일: Config.cs 프로젝트: 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();
        }