コード例 #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     Authentication.username = Login.Text;
     Authentication.password = Passworld.Text;
     try
     {
         Mystat.Authorization(new Uri("https://msapi.itstep.org/api/v1/auth/login"), ref Token, Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(Authentication)));
         File.WriteAllText("../../JsonFile/AuthUser.txt", Mystat.Encrypt(Newtonsoft.Json.JsonConvert.SerializeObject(Authentication)));
         this.Hide();
         MystatForm = new MystatForm(Token);
         MystatForm.ShowDialog();
         if (MystatForm.DialogResult == DialogResult.OK)
         {
             this.Show();
             Authentication = Newtonsoft.Json.JsonConvert.DeserializeObject <Authentication>(Newtonsoft.Json.JsonConvert.SerializeObject(Authentication));
             Login.Text     = Authentication.username;
             Passworld.Text = Authentication.password;
         }
         else
         {
             this.Close();
         }
     }
     catch (System.Net.WebException)
     {
         MessageBox.Show("Username Passworld is corrent!");
     }
 }
コード例 #2
0
 private void LoginForm_Load(object sender, EventArgs e)
 {
     try
     {
         Token = Newtonsoft.Json.JsonConvert.DeserializeObject <Token>(Mystat.Decrypt(File.ReadAllText("../../JsonFile/Token.txt")));
     }
     catch (FileNotFoundException ex)
     {
         MessageBox.Show("Token File Not Found", ex.FileName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     try
     {
         Mystat.Refresh(ref Token);
         MystatForm = new MystatForm(Token);
         MystatForm.ShowDialog();
         if (MystatForm.DialogResult == DialogResult.OK)
         {
             pictureBox1.BackColor = Color.Transparent;
             LoadAuth();
             Login.Text     = Authentication.username;
             Passworld.Text = Authentication.password;
         }
         else
         {
             this.Close();
         }
     }
     catch (System.Net.WebException)
     {
         LoadAuth();
         try
         {
             Mystat.Authorization(new Uri("https://msapi.itstep.org/api/v1/auth/login"), ref Token, Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(Authentication)));
             MystatForm = new MystatForm(Token);
             MystatForm.ShowDialog();
             if (MystatForm.DialogResult == DialogResult.OK)
             {
                 pictureBox1.BackColor = Color.Transparent;
                 LoadAuth();
                 Login.Text     = Authentication.username;
                 Passworld.Text = Authentication.password;
             }
             else
             {
                 this.Close();
             }
         }
         catch (System.Net.WebException)
         {
             pictureBox1.BackColor = Color.Transparent;
             LoadAuth();
             Login.Text     = Authentication.username;
             Passworld.Text = Authentication.password;
         }
     }
 }