Beispiel #1
0
        public OutlookTask UpdateTask(OutlookTask TargetTask, Outlook.TaskItem SourceTaskItem, ICollection <OutlookCategory> categories, OutlookCategory defaultCategory)
        {
            OutlookCategory category = categories.Where(x => x.Name.Equals(SourceTaskItem.Categories)).SingleOrDefault();

            if (category == null)
            {
                category = defaultCategory;
            }

            TargetTask.EntryId       = SourceTaskItem.EntryID;
            TargetTask.TaskName      = SourceTaskItem.Subject;
            TargetTask.Body          = SourceTaskItem.Body;
            TargetTask.IsComplete    = SourceTaskItem.Complete;
            TargetTask.Owner         = SourceTaskItem.Owner;
            TargetTask.CreationTime  = SourceTaskItem.CreationTime;
            TargetTask.DateCompleted = (SourceTaskItem.DateCompleted.Year == 4501 ? (DateTime?)null : SourceTaskItem.DateCompleted);
            TargetTask.StartDate     = (SourceTaskItem.StartDate.Year == 4501 ? (DateTime?)null : SourceTaskItem.StartDate);
            TargetTask.DueDate       = (SourceTaskItem.DueDate.Year == 4501 ? (DateTime?)null : SourceTaskItem.DueDate);
            TargetTask.ActualWork    = SourceTaskItem.ActualWork;
            TargetTask.Status        = fromOutlookStatus(SourceTaskItem.Status);
            TargetTask.Priority      = SourceTaskItem.SchedulePlusPriority;
            TargetTask.Category      = category;

            return(TargetTask);
        }
Beispiel #2
0
        /// <summary>
        /// CRUD operation for Outlook categories.
        /// </summary>
        /// <param name="exchangeService"></param>
        /// <returns></returns>
        public static async Task CreateReadUpdateOutlookCategory(ExchangeService exchangeService)
        {
            string          displayName = Guid.NewGuid().ToString();
            OutlookCategory category    = new OutlookCategory(exchangeService);

            category.Color       = CategoryColor.Preset18;
            category.DisplayName = displayName;

            await category.SaveAsync();

            FindItemResults <OutlookCategory> categories = await exchangeService.FindItems(
                new OutlookCategoryView(),
                null);

            bool found = false;

            foreach (OutlookCategory outlookCategory in categories)
            {
                if (outlookCategory.DisplayName == displayName)
                {
                    found = true;
                }
            }

            Assert.IsTrue(found);
            await category.DeleteAsync();
        }
Beispiel #3
0
        public TaskAndCategoryLoader(Outlook.Application outlookApp)
        {
            Outlook.MAPIFolder outlookTasksFolder = outlookApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks);
            outlookItems = outlookTasksFolder.Items;
            Tasks        = new List <OutlookTask>();
            Categories   = new List <OutlookCategory>();

            HashSet <OutlookCategory> cats = new HashSet <OutlookCategory>();

            DefaultCategory = new OutlookCategory()
            {
                Name = Properties.Resources.Outlook_Category_Default
            };
            cats.Add(DefaultCategory);

            foreach (Outlook.TaskItem taskitem in outlookItems)
            {
                if (!String.IsNullOrWhiteSpace(taskitem.Categories) && !cats.Any(c => c.Name == taskitem.Categories))
                {
                    cats.Add(new OutlookCategory()
                    {
                        Name = taskitem.Categories
                    });
                }

                OutlookTask newTask = new OutlookTask();
                UpdateTask(newTask, taskitem, cats, DefaultCategory);
                Tasks.Add(newTask);
            }
            cats.ToList().ForEach(Categories.Add);
        }
        public void UpdateCategory(OutlookCategory category)
        {
            IEnumerable <OutlookTask> tasksinCategory = taskAndCategoryLoader.Tasks.Where <OutlookTask>(task => task.Category != null && task.Category.Equals(category));

            foreach (OutlookTask task in tasksinCategory)
            {
                UpdateTask(task);
            }
        }
 public void MoveToCategory(OutlookTask sourceItem, OutlookCategory newCategory)
 {
     if (sourceItem.Category != newCategory)
     {
         tasks[sourceItem.Category].Remove(sourceItem);
         sourceItem.Category = newCategory;
         outlookService.UpdateTask(sourceItem);
         tasks[sourceItem.Category].Add(sourceItem);
     }
 }
        public void MoveTaskToCategory(OutlookTask task, OutlookCategory category)
        {
            OutlookTask outlookTask = task as OutlookTask;

            if (outlookTask.Category != category)
            {
                outlookTask.Category = category as OutlookCategory;
                UpdateTask(outlookTask);
            }
        }
        public OutlookCategory CreateCategory()
        {
            OutlookCategory category = new OutlookCategory()
            {
                Name = Properties.Resources.Outlook_Category_New
            };

            taskAndCategoryLoader.Categories.Add(category);
            return(category);
        }
        public List <OutlookTask> ReadAllTasksByCategory(OutlookCategory category)
        {
            List <OutlookTask> tasksInCategory = new List <OutlookTask>();

            taskAndCategoryLoader.Tasks.ForEach(item =>
            {
                if (category.Equals(item.Category))
                {
                    tasksInCategory.Add(item);
                }
            });
            return(tasksInCategory);
        }
        private ObservableCollection <OutlookTask> loadTasks(OutlookCategory category)
        {
            ObservableCollection <OutlookTask> tasksInCategory;

            if (tasks.ContainsKey(category))
            {
                tasksInCategory = tasks[category];
            }
            else
            {
                tasksInCategory = new ObservableCollection <OutlookTask>();
                tasks.Add(category, tasksInCategory);
            }

            return(tasksInCategory);
        }
Beispiel #10
0
        public void TestRoundtrip1To2(OlCategoryColor outlookColor)
        {
            var originalCategory = "cat1";

            _outlookCategories[originalCategory] = new OutlookCategory(originalCategory, outlookColor, OlCategoryShortcutKey.olCategoryShortcutKeyNone);
            CreateMapper();

            var htmlColor            = _mapper.MapCategoryToHtmlColorOrNull(originalCategory);
            var roundTrippedCategory = _mapper.MapHtmlColorToCategoryOrNull(htmlColor, NullEntityMappingLogger.Instance);

            Assert.That(roundTrippedCategory, Is.EqualTo(originalCategory));

            // try a second roundtrip
            htmlColor            = _mapper.MapCategoryToHtmlColorOrNull(originalCategory);
            roundTrippedCategory = _mapper.MapHtmlColorToCategoryOrNull(htmlColor, NullEntityMappingLogger.Instance);
            Assert.That(roundTrippedCategory, Is.EqualTo(originalCategory));
        }
        public ObservableCollection <OutlookTask> ReadByCategory(OutlookCategory category)
        {
            ObservableCollection <OutlookTask> tasksInCategory = loadTasks(category);

            tasksInCategory.Clear();
            List <OutlookTask> taskList = outlookService.ReadAllTasksByCategory(category);

            taskList.ForEach(item =>
            {
                if (filter(item) && (category == null || category.Equals(item.Category)))
                {
                    tasksInCategory.Add(item);
                }
            });

            return(tasksInCategory);
        }
        public OutlookTask CreateTaskInCategory(OutlookCategory category)
        {
            OutlookTask task = new OutlookTask()
            {
                Category     = category,
                TaskName     = Properties.Resources.Outlook_Task_New,
                IsComplete   = false,
                CreationTime = DateTime.Now,
                ActualWork   = 0,
                Status       = TaskStatus.TaskNotStarted
            };

            Outlook.TaskItem taskitem = outlookApp.CreateItem(Outlook.OlItemType.olTaskItem) as Outlook.TaskItem;
            taskitem = taskAndCategoryLoader.UpdateOutlookTaskItem(taskitem, task);
            taskitem.Save();

            return(task);
        }
        /// <summary>
        /// Update the navigation property masterCategories in users
        /// <param name="body"></param>
        /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
        /// </summary>
        public RequestInformation CreatePatchRequestInformation(OutlookCategory body, Action <OutlookCategoryItemRequestBuilderPatchRequestConfiguration> requestConfiguration = default)
        {
            _ = body ?? throw new ArgumentNullException(nameof(body));
            var requestInfo = new RequestInformation {
                HttpMethod     = Method.PATCH,
                UrlTemplate    = UrlTemplate,
                PathParameters = PathParameters,
            };

            requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
            if (requestConfiguration != null)
            {
                var requestConfig = new OutlookCategoryItemRequestBuilderPatchRequestConfiguration();
                requestConfiguration.Invoke(requestConfig);
                requestInfo.AddRequestOptions(requestConfig.Options);
                requestInfo.AddHeaders(requestConfig.Headers);
            }
            return(requestInfo);
        }
        public OutlookTask CreateNewTask(OutlookCategory category)
        {
            OutlookTask task = outlookService.CreateTaskInCategory(category);

            return(task);
        }
 public void DeleteCategory(OutlookCategory category)
 {
     throw new NotImplementedException();
 }
 public void Update(OutlookCategory category)
 {
     outlookService.UpdateCategory(category);
 }