示例#1
0
 public void SaveGroup(List <AccountUC> accounts, string groupname)
 {
     //m_GroupAccounts.Clear();
     //foreach (AccountUC bot in accounts)
     //{
     //    bot.AccountPassword = CryptageBS.EncryptBS(bot.AccountPassword);
     //    m_GroupAccounts.Add(bot);
     //}
     if (!Directory.Exists(m_SavingGroupDirectoryPath))
     {
         Directory.CreateDirectory(m_SavingGroupDirectoryPath);
     }
     //if (!File.Exists(m_SavingDirectoryPath + @"\" + groupname))
     // File.Create(m_SavingDirectoryPath + @"\" + groupname);
     using (BigEndianWriter writer = new BigEndianWriter())
     {
         writer.WriteInt(m_Accounts.Count);
         foreach (Account accountObject in m_Accounts)
         {
             writer.WriteUTF(accountObject.Name);
             writer.WriteUTF(CryptageBS.EncryptBS(accountObject.Password));
         }
         //IFormatter binaryFormatter = new BinaryFormatter();
         //using (Stream stream = new FileStream(m_SavingGroupDirectoryPath + @"\" + groupname, FileMode.Create, FileAccess.Write))
         //{
         //    binaryFormatter.Serialize(stream, writer);
         //}
     }
     //foreach (AccountUC bot in accounts)
     //    bot.AccountPassword = CryptageBS.DecryptBS(bot.AccountPassword);
 }
示例#2
0
 public void SaveAccountsInfos(List <Bot> bots)
 {
     foreach (Bot bot in bots)
     {
         bot.Account.Password = CryptageBS.EncryptBS(bot.Account.Password);
         m_Accounts.Add(bot.Account);
     }
     if (!Directory.Exists(m_SavingDirectoryPath))
     {
         Directory.CreateDirectory(m_SavingDirectoryPath);
     }
     using (BigEndianWriter writer = new BigEndianWriter())
     {
         writer.WriteInt(m_Accounts.Count);
         foreach (Account accountObject in m_Accounts)
         {
             writer.WriteUTF(accountObject.Name);
             writer.WriteUTF(accountObject.Password);
         }
         IFormatter binaryFormatter = new BinaryFormatter();
         using (Stream stream = new FileStream(m_SavingFilePath, FileMode.Create, FileAccess.Write))
         {
             binaryFormatter.Serialize(stream, writer);
         }
     }
     foreach (Bot bot in bots)
     {
         bot.Account.Password = CryptageBS.DecryptBS(bot.Account.Password);
     }
 }
示例#3
0
 public void RecoverAccountsInfos()
 {
     if (File.Exists(m_SavingFilePath))
     {
         IFormatter binaryFormatter = new BinaryFormatter();
         using (Stream stream = new FileStream(m_SavingFilePath, FileMode.Open, FileAccess.Read))
         {
             BigEndianWriter writer = (BigEndianWriter)binaryFormatter.Deserialize(stream);
             using (BigEndianReader reader = new BigEndianReader(writer.Content))
             {
                 int limite = reader.ReadInt();
                 m_Accounts = new List <Account>();
                 for (int index = 0; index < limite; index++)
                 {
                     m_Accounts.Add(new Account(reader.ReadUTF(), reader.ReadUTF()));
                 }
             }
             writer.Dispose();
             stream.Close();
         }
     }
     foreach (Account accountObject in m_Accounts)
     {
         accountObject.Password = CryptageBS.DecryptBS(accountObject.Password);
     }
 }
示例#4
0
 public void RecoverGroups()
 {
     foreach (FileInfo file in new DirectoryInfo(m_SavingGroupDirectoryPath).GetFiles())
     {
         //IFormatter binaryFormatter = new BinaryFormatter();
         //using (Stream stream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read))
         //{
         //    BigEndianWriter writer = (BigEndianWriter)binaryFormatter.Deserialize(stream);
         //    using (BigEndianReader reader = new BigEndianReader(writer.Content))
         //    {
         //        int limite = reader.ReadInt();
         //        m_GroupAccounts = new List<AccountUC>();
         //        for (int index = 0; index < limite; index++)
         //            m_GroupAccounts.Add(new AccountUC(reader.ReadUTF(), reader.ReadUTF(), false));
         //        Groups.Add(new Group(m_GroupAccounts, file.Name.Remove((int)file.Name.Length - 3)));
         //        foreach (Account accountObject in m_Accounts)
         //            accountObject.Password = CryptageBS.DecryptBS(accountObject.Password);
         //    }
         //    writer.Dispose();
         //    stream.Close();
         //}
         byte[] content = File.ReadAllBytes(file.FullName);
         using (BigEndianReader reader = new BigEndianReader(content))
         {
             int limite = reader.ReadInt();
             m_GroupAccounts = new List <AccountUC>();
             for (int index = 0; index < limite; index++)
             {
                 m_GroupAccounts.Add(new AccountUC(reader.ReadUTF(), reader.ReadUTF(), false));
             }
             Groups.Add(new Group(m_GroupAccounts, file.Name.Remove((int)file.Name.Length - 3)));
             foreach (Account accountObject in m_Accounts)
             {
                 accountObject.Password = CryptageBS.DecryptBS(accountObject.Password);
             }
         }
     }
 }