Beispiel #1
0
Datei: Api.cs Projekt: baiy/login
        /// <summary>
        /// 获取账号信息
        /// </summary>
        /// <returns>返回解密后的json格式内容</returns>
        public string GetDb()
        {
            Config con = new Config();
            con.ReaderConfig();
            string db = "";
            if(IsNet())
            {
                WebClient MyWebClient = new WebClient();
                MyWebClient.Credentials = CredentialCache.DefaultCredentials;
                Byte[] pageData = MyWebClient.DownloadData(con.config.ApiUrl);
                db = Encoding.UTF8.GetString(pageData);
                StreamWriter sw = new StreamWriter(db_path, false);
                sw.WriteLine(db);
                sw.Close();
            }
            else
            {
                if (!ExistsDb())
                {
                    throw new Exception("请先连接网络 获取账号数据文件");
                }
                string[] str = File.ReadAllLines(db_path, System.Text.Encoding.Default);
                db = string.Join("",str);
            }

            return Encrypt.decode(db, con.config.EncryptKey);
        }
Beispiel #2
0
 private void SetConfig_Click(object sender, EventArgs e)
 {
     Config config = new Config();
     string url = textapiurl.Text;
     string key = Textencryptkey.Text;
     string ftp = textBoxftppath.Text;
     string ssh = textBoxsshpath.Text;
     string ftpcmd = textBoxftpcmd.Text;
     string sshcmd = textBoxsshcmd.Text;
     config.WriteConfig(url, key, ftp, ssh, ftpcmd, sshcmd);
     MessageBox.Show("配置写入成功 程序将自动重启");
     Application.Restart();
 }
Beispiel #3
0
 private void SetConfig()
 {
     Config con = new Config();
     con.ReaderConfig();
     textapiurl.Text = con.config.ApiUrl;
     textBoxftppath.Text = con.config.FtpPath;
     textBoxsshpath.Text = con.config.SshPath;
     textBoxftpcmd.Text = con.config.FtpCmd;
     textBoxsshcmd.Text = con.config.SshCmd;
 }
Beispiel #4
0
 private static DataConfig GetPath()
 {
     Config con = new Config();
     con.ReaderConfig();
     return con.config;
 }