Exemplo n.º 1
0
        public static void ExportEmailFile()
        {
            int saveCount = 0;
            int fileCount = 0;

            Log.Append("Syncing email cache to server...");

            // Remove all original files
            foreach (string path in Directory.GetFiles(cacheDirectoryPath, "*.cfg*"))
            {
                if (File.Exists(cacheDirectoryPath + "CacheDump/" + Path.GetFileName(path)))
                {
                    File.Delete(cacheDirectoryPath + "CacheDump/" + Path.GetFileName(path));
                }
                File.Move(path, cacheDirectoryPath + "CacheDump/" + Path.GetFileName(path));
            }

            StringBuilder str = new StringBuilder();

            foreach (Email email in EmailList)
            {
                str.Append("[EM_ID_]=" + email.ID);
                str.Append("||[EM_UI_]=" + email.UID);
                str.Append("||[EM_TO_]=" + email.To);
                str.Append("||[EM_FR_]=" + email.From);
                str.Append("||[EM_SU_]=" + email.Subject);
                str.Append("||[EM_MD_]=" + email.MailDate + Environment.NewLine);

                saveCount++;

                if (saveCount % MAX_EMAIL_COUNT == 0)
                {
                    Saver.Save(AESGCM.SimpleEncryptWithPassword(str.ToString(), AESGCM.AES256Key), cacheDirectoryPath + "emailMaster_" + (++fileCount) + ".cfg");
                    str = new StringBuilder();
                }
            }

            // Get remainder
            if (saveCount % MAX_EMAIL_COUNT != 0 && str.Length > 0)
            {
                Saver.Save(AESGCM.SimpleEncryptWithPassword(str.ToString(), AESGCM.AES256Key), cacheDirectoryPath + "emailMaster_" + (++fileCount) + ".cfg");
            }

            GetEmailCounts();

            Log.Append("Sync complete!");
        }
Exemplo n.º 2
0
        public static void SaveSettings()
        {
            StringBuilder str = new StringBuilder();

            // Save user data
            foreach (User user in UserList)
            {
                str.Append("[US_NA_]=" + user.Name);
                str.Append("||[US_DE_]=" + user.Department);
                str.Append("||[US_ID_]=" + user.UserID);
                str.Append("||[US_LP_]=" + user.LoginPassword);
                str.Append("||[US_PR_]=" + user.Privilege);
                str.Append("||[US_SE_]=" + (user.SyncEmails ? "1" : "0"));
                str.Append("||[US_LU_]=" + user.LastUpdateTime);
                str.Append("||[US_PT_]=" + user.ReceivingProtocol);
                str.Append("||[US_PO_]=" + user.ReceivingPort);
                str.Append("||[US_EM_]=" + user.Email);
                str.Append("||[US_PW_]=" + user.Password + Environment.NewLine);
            }

            str.Append(Settings.GetSaveSettingsStr());

            Saver.Save(AESGCM.SimpleEncryptWithPassword(str.ToString(), AESGCM.AES256Key), settingsFilePath);
        }