// Constructor public MailboxIterator(int tenant = -1, string userId = null, bool?isRemoved = false, ILog log = null) { if (!string.IsNullOrEmpty(userId) && tenant < 0) { throw new ArgumentException("Tenant must be initialized if user not empty"); } var engine = new EngineFactory(tenant, userId, log); MailboxEngine = engine.MailboxEngine; Tenant = tenant; UserId = userId; IsRemoved = isRemoved; Log = log ?? new NullLog(); var result = MailboxEngine.GetRangeMailboxes(GetMailboxExp(Tenant, UserId, IsRemoved)); if (result == null) { return; } MinMailboxId = result.Item1; MaxMailboxId = result.Item2; Current = null; }
private MailBoxData GetNextMailbox(int id) { do { if (id < MinMailboxId || id >= MaxMailboxId) { return(null); } MailBoxData mailbox; var exp = GetNextMailboxExp(id, Tenant, UserId, IsRemoved); int failedId; if (!MailboxEngine.TryGetNextMailboxData(exp, out mailbox, out failedId)) { if (failedId > 0) { id = failedId; Log.ErrorFormat("MailboxEngine.GetNextMailboxData(Mailbox id = {0}) failed. Skip it.", id); id++; } else { Log.ErrorFormat("MailboxEngine.GetNextMailboxData(Mailbox id = {0}) failed. End seek next.", id); return(null); } } else { return(mailbox); } } while (id <= MaxMailboxId); return(null); }