Ejemplo n.º 1
0
        public void AddMailMessage(string msgorillaMessageID,
                                   int size,
                                   int importance,
                                   int mailboxID,
                                   MSGorillaMailEntities ctx)
        {
            MailBox mailbox = ctx.MailBoxes.Find(mailboxID);

            MailMessage message = new MailMessage();

            message.MailboxID          = mailbox.MailboxID;
            message.MSGorillaMessageID = msgorillaMessageID;
            message.Recent             = true;
            message.Seen           = false;
            message.Deleted        = false;
            message.SequenceNumber = mailbox.Exist + 1;
            message.Uid            = mailbox.UidNext;
            message.Important      = importance;
            message.Timestamp      = DateTime.UtcNow;
            message.Size           = size;

            ctx.MailMessages.Add(message);

            mailbox.UidNext++;
            mailbox.Recent++;
            mailbox.Exist++;
            ctx.SaveChanges();
        }
Ejemplo n.º 2
0
        public MailBox CreateMailboxIfNotExist(string path, MSGorillaMailEntities ctx)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new Exception("Path can't be null");
            }
            if (path.Length > 256)
            {
                throw new Exception("Folder path too long. No more than 256 chars");
            }

            MailBox box = null;

            string[] split   = path.Split('/');
            string   curPath = "";

            foreach (string str in split)
            {
                if (!string.IsNullOrEmpty(str))
                {
                    curPath += str;
                    box      = CreateSingleMailboxIfNotExist(curPath, ctx);
                    curPath += '/';
                }
            }
            ctx.SaveChanges();
            return(box);
        }
Ejemplo n.º 3
0
 public void DeleteMailboxIfExist(string path)
 {
     using (var ctx = new MSGorillaMailEntities())
     {
         DeleteMailboxIfExist(path, ctx);
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 public MailBox CreateMailboxIfNotExist(string path)
 {
     using (var ctx = new MSGorillaMailEntities())
     {
         MailBox mailbox = CreateMailboxIfNotExist(path, ctx);
         ctx.SaveChanges();
         return(mailbox);
     }
 }