示例#1
0
 private void LoadUrl()
 {
     try
     {
         // Get syncInfo from file, written by GroupSync WebAPI
         using (var tr = new StreamReader(Path.Combine(GetFolderPath(), "OneRosterURL.txt")))
         {
             oneRosterUrl.Text = StringCipher.decrypt(tr.ReadToEnd(), StringCipher.getKey());
         }
     }
     catch (Exception)
     {
         oneRosterUrl.Text = "";
     }
 }
示例#2
0
        private void saveUrlBtn_Click(object sender, EventArgs e)
        {
            var savePath = Path.Combine(GetFolderPath(), "OneRosterURL.txt");

            try
            {
                using (TextWriter tw = new StreamWriter(savePath))
                {
                    tw.Write(StringCipher.encrypt(oneRosterUrl.Text.Trim(), StringCipher.getKey()));
                    MessageBox.Show(@"URL Saved");
                }
            }
            catch (IOException a)
            {
                // something happened?
                MessageBox.Show(a.Message);
            }
        }
示例#3
0
 private static IEnumerable <Credentials> getCredentialList()
 {
     try
     {
         // Get syncInfo from file, written by GroupSync WebAPI
         using (var tr = new StreamReader(Path.Combine(Main.GetFolderPath(), "Credentials.txt")))
         {
             return(JsonConvert.DeserializeObject <List <Credentials> >(StringCipher.decrypt(tr.ReadToEnd(), StringCipher.getKey())));
         }
     }
     catch (Exception)
     {
         return(new List <Credentials>());
     }
 }
示例#4
0
        private void saveCredentials()
        {
            var credList = (from DataGridViewRow row in credDataView.Rows
                            select new Credentials
            {
                alias = row.Cells[0].Value?.ToString(), key = row.Cells[1].Value?.ToString(), secret = row.Cells[2].Value?.ToString()
            }).ToList();
            var savePath = Path.Combine(Main.GetFolderPath(), "Credentials.txt");


            try
            {
                using (TextWriter tw = new StreamWriter(savePath))
                {
                    tw.Write(StringCipher.encrypt(JsonConvert.SerializeObject(credList), StringCipher.getKey()));
                    MessageBox.Show(@"Credentials Saved");
                    _promptSave = false;
                }
            }
            catch (IOException e)
            {
                // something happened?
                MessageBox.Show(e.Message);
            }
        }