Exemplo n.º 1
0
        public JsonResult UpdateFolders(DateTime catalogDateTime, string rootFolderId)
        {
            var tree = new Tree();
            List<Item> result = GetContainer(rootFolderId, tree);

            UpdateMailboxesModel jsonModel = new UpdateMailboxesModel();
            jsonModel.CatalogTime = catalogDateTime;
            jsonModel.Details = result;

            return Json(jsonModel);
        }
Exemplo n.º 2
0
        public JsonResult UpdateMailboxes(DateTime catalogDateTime)
        {
            UpdateMailboxesModel result = new UpdateMailboxesModel();
            result.CatalogTime = catalogDateTime;

            var tree = new Tree();
            var allMailboxes = tree.GetAllMailbox();
            List<Item> infos = new List<Item>(allMailboxes.Count);
            foreach (var mailbox in allMailboxes)
            {
                infos.Add(new Item() { Id = mailbox.RootFolderId, DisplayName = mailbox.DisplayName, ChildCount = tree.GetChildCount(mailbox.RootFolderId), ItemType = "Mailbox", OtherInformation = mailbox});
            }

            result.Details = infos;
            return Json(result);
        }
Exemplo n.º 3
0
 private List<Item> GetContainer(string folderId, Tree tree)
 {
     var allRootFolder = tree.GetDirectFolder(folderId);
     List<Item> result = new List<Item>();
     foreach (var folder in allRootFolder)
     {
         var item = new Item() { Id = folder.FolderId, ChildCount = tree.GetChildCount(folder.FolderId), DisplayName = folder.DisplayName, ItemType = "Folder" };
         item.Container = GetContainer(folder.FolderId, tree);
         result.Add(item);
     }
     return result;
 }
Exemplo n.º 4
0
        //public JsonResult UpdateFolders(DateTime catalogDateTime, string rootFolderId)
        //{
        //    UpdateMailboxesModel result = new UpdateMailboxesModel();
        //    result.CatalogTime = catalogDateTime;
        //    List<Item> infos = new List<Item>(24);
        //    string i = "0";
        //    var mailboxInfo0 = new FolderInfo()
        //    {
        //        DisplayName = string.Format("Folder-DisplayName-{0}", i),
        //        MailboxAddress = string.Format("*****@*****.**", i),
        //        FolderId = i.ToString(),
        //        ChildFolderCount = 2,
        //        ChildItemCount = 4
        //    };
        //    var mailboxInfo = mailboxInfo0;
        //    var item0 = new Item() { Id = mailboxInfo.FolderId, DisplayName = mailboxInfo.DisplayName, Count = mailboxInfo.ChildItemCount, OtherInformation = mailboxInfo };
        //    i = "01";
        //    var mailboxInfo01 = new FolderInfo()
        //    {
        //        DisplayName = string.Format("Folder-DisplayName-{0}", i),
        //        MailboxAddress = string.Format("*****@*****.**", i),
        //        FolderId = i.ToString(),
        //        ChildFolderCount = 0,
        //        ChildItemCount = 2,
        //        ParentFolderId = "0"
        //    };
        //    mailboxInfo = mailboxInfo01;
        //    var item01 = new Item() { Id = mailboxInfo.FolderId, DisplayName = mailboxInfo.DisplayName, Count = mailboxInfo.ChildItemCount, OtherInformation = mailboxInfo };
        //    i = "02";
        //    var mailboxInfo02 = new FolderInfo()
        //    {
        //        DisplayName = string.Format("Folder-DisplayName-{0}", i),
        //        MailboxAddress = string.Format("*****@*****.**", i),
        //        FolderId = i.ToString(),
        //        ChildFolderCount = 0,
        //        ChildItemCount = 2,
        //        ParentFolderId = "0"
        //    };
        //    mailboxInfo = mailboxInfo02;
        //    var item02 = new Item() { Id = mailboxInfo.FolderId, DisplayName = mailboxInfo.DisplayName, Count = mailboxInfo.ChildItemCount, OtherInformation = mailboxInfo };
        //    item0.Children = new List<Item>() { item01, item02 };
        //    i = "1";
        //    var mailboxInfo1 = new FolderInfo()
        //    {
        //        DisplayName = string.Format("Folder-DisplayName-{0}", i),
        //        MailboxAddress = string.Format("*****@*****.**", i),
        //        FolderId = i.ToString(),
        //        ChildFolderCount = 0,
        //        ChildItemCount = 1
        //    };
        //    mailboxInfo = mailboxInfo1;
        //    var item1 = new Item() { Id = mailboxInfo.FolderId, DisplayName = mailboxInfo.DisplayName, Count = mailboxInfo.ChildItemCount, OtherInformation = mailboxInfo };
        //    i = "2";
        //    var mailboxInfo2 = new FolderInfo()
        //    {
        //        DisplayName = string.Format("Folder-DisplayName-{0}", i),
        //        MailboxAddress = string.Format("*****@*****.**", i),
        //        FolderId = i.ToString(),
        //        ChildFolderCount = 1,
        //        ChildItemCount = 2,
        //    };
        //    mailboxInfo = mailboxInfo2;
        //    var item2 = new Item() { Id = mailboxInfo.FolderId, DisplayName = mailboxInfo.DisplayName, Count = mailboxInfo.ChildItemCount, OtherInformation = mailboxInfo };
        //    i = "21";
        //    var mailboxInfo21 = new FolderInfo()
        //    {
        //        DisplayName = string.Format("Folder-DisplayName-{0}", i),
        //        MailboxAddress = string.Format("*****@*****.**", i),
        //        FolderId = i.ToString(),
        //        ChildFolderCount = 2,
        //        ChildItemCount = 2,
        //        ParentFolderId = "2"
        //    };
        //    mailboxInfo = mailboxInfo21;
        //    var item21 = new Item() { Id = mailboxInfo.FolderId, DisplayName = mailboxInfo.DisplayName, Count = mailboxInfo.ChildItemCount, OtherInformation = mailboxInfo };
        //    item2.Children = new List<Item>() { item21 };
        //    i = "211";
        //    var mailboxInfo211 = new FolderInfo()
        //    {
        //        DisplayName = string.Format("Folder-DisplayName-{0}", i),
        //        MailboxAddress = string.Format("*****@*****.**", i),
        //        FolderId = i.ToString(),
        //        ChildFolderCount = 0,
        //        ChildItemCount = 1000,
        //        ParentFolderId = "21"
        //    };
        //    mailboxInfo = mailboxInfo211;
        //    var item211 = new Item() { Id = mailboxInfo.FolderId, DisplayName = mailboxInfo.DisplayName, Count = mailboxInfo.ChildItemCount, OtherInformation = mailboxInfo };
        //    i = "212";
        //    var mailboxInfo212 = new FolderInfo()
        //    {
        //        DisplayName = string.Format("Folder-DisplayName-{0}", i),
        //        MailboxAddress = string.Format("*****@*****.**", i),
        //        FolderId = i.ToString(),
        //        ChildFolderCount = 0,
        //        ChildItemCount = 2,
        //        ParentFolderId = "21"
        //    };
        //    mailboxInfo = mailboxInfo212;
        //    var item212 = new Item() { Id = mailboxInfo.FolderId, DisplayName = mailboxInfo.DisplayName, Count = mailboxInfo.ChildItemCount, OtherInformation = mailboxInfo };
        //    item21.Children = new List<Item>() { item211, item212 };
        //    infos.Add(item0);
        //    infos.Add(item1);
        //    infos.Add(item2);
        //    result.Details = infos;
        //    return Json(result);
        //}
        public JsonResult UpdateMails(string folderId, int pageIndex, int pageCount)
        {
            var tree = new Tree();
            var mails = tree.GetMails(folderId);
            int startIndex = pageIndex * pageCount;
            int endIndex = startIndex + pageCount;
            List<Item> result = new List<Item>(pageCount);
            while (startIndex < endIndex && startIndex < mails.Count)
            {
                var mailItem = mails[startIndex];
                var item = new Item() { Id = mailItem.ItemId, ChildCount = 0, DisplayName = mailItem.DisplayName, OtherInformation = mailItem };

                result.Add(item);

                startIndex++;
            }
            return Json(new MailResult() { Mails = result, TotalCount = mails.Count });
        }