Esempio n. 1
0
 public static void RestoreFromRecycleBin(string messageID, IMailServerManagementApi api)
 {
     using (FileStream file = RecycleBinManager.GetFile())
     {
         int num = 0;
         StreamLineReader streamLineReader = new StreamLineReader(file);
         long             position         = file.Position;
         for (string text = streamLineReader.ReadLineString(); text != null; text = streamLineReader.ReadLineString())
         {
             if (!text.StartsWith("#"))
             {
                 if (text.StartsWith("\0"))
                 {
                     num++;
                 }
                 else
                 {
                     string[] array = TextUtils.SplitQuotedString(text, ' ');
                     if (array[0] == messageID)
                     {
                         string text2 = array[2];
                         string text3 = TextUtils.UnQuoteString(array[3]);
                         using (FileStream fileStream = File.OpenRead(RecycleBinManager.m_RecycleBinPath + messageID + ".eml"))
                         {
                             if (!api.FolderExists(text2 + "/" + text3))
                             {
                                 api.CreateFolder("system", text2, text3);
                             }
                             api.StoreMessage("system", text2, text3, fileStream, DateTime.Now, new string[]
                             {
                                 "Recent"
                             });
                         }
                         byte[] array2 = new byte[file.Position - position - 2L];
                         file.Position = position;
                         file.Write(array2, 0, array2.Length);
                         file.Position += 2L;
                         num++;
                         File.Delete(RecycleBinManager.m_RecycleBinPath + messageID + ".eml");
                         break;
                     }
                 }
             }
             position = file.Position;
         }
         if (num > 500)
         {
             RecycleBinManager.Vacuum(file);
         }
     }
 }
Esempio n. 2
0
 public static void DeleteRecycleBinMessage(string messageID)
 {
     using (FileStream file = RecycleBinManager.GetFile())
     {
         int num = 0;
         StreamLineReader streamLineReader = new StreamLineReader(file);
         long             position         = file.Position;
         for (string text = streamLineReader.ReadLineString(); text != null; text = streamLineReader.ReadLineString())
         {
             if (!text.StartsWith("#"))
             {
                 if (text.StartsWith("\0"))
                 {
                     num++;
                 }
                 else
                 {
                     string[] array = TextUtils.SplitQuotedString(text, ' ');
                     if (array[0] == messageID)
                     {
                         string arg_63_0 = array[2];
                         TextUtils.UnQuoteString(array[3]);
                         File.Delete(RecycleBinManager.m_RecycleBinPath + messageID + ".eml");
                         byte[] array2 = new byte[file.Position - position - 2L];
                         file.Position = position;
                         file.Write(array2, 0, array2.Length);
                         file.Position += 2L;
                         num++;
                         break;
                     }
                 }
             }
             position = file.Position;
         }
         if (num > 500)
         {
             RecycleBinManager.Vacuum(file);
         }
     }
 }