// // Task.cs // // Author: Kees van Spelde // // Copyright (c) 2013-2018 Magic-Sessions. (www.magic-sessions.com) // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // using System; using System.Collections.ObjectModel; using MsgReader.Helpers; using MsgReader.Localization; namespace MsgReader.Outlook { #region Enum TaskStatus /// /// The status of a task /// public enum TaskStatus { /// /// The task has not yet started /// NotStarted = 0, /// /// The task is in progress /// InProgess = 1, /// /// The task is complete /// Complete = 2, /// /// The task is waiting on someone else /// Waiting = 3 } #endregion public partial class Storage { /// /// Class used to contain all the task information. A task can also be added to an E-mail () when /// the FollowUp flag is set. /// public sealed class Task : Storage { #region Properties /// /// Returns the start datetime of the , null when not available /// public DateTime? StartDate { get; } /// /// Returns the due datetime of the , null when not available /// public DateTime? DueDate { get; } /// /// Returns the Status of the , /// null when not available /// public TaskStatus? Status { get; } /// /// Returns the Status of the as a string, /// null when not available /// public string StatusText { get; } /// /// Returns the estimated effort (in minutes) that is needed for task, /// null when not available /// public double? PercentageComplete { get; } /// /// Returns true when the has been completed, null when not available /// public bool? Complete { get; } /// /// Returns the estimated effort that is needed for the as a , /// null when no available /// public TimeSpan? EstimatedEffort { get; } /// /// Returns the estimated effort that is needed for the as a string (e.g. 11 weeks), /// null when no available /// public string EstimatedEffortText { get; } /// /// Returns the actual effort that is spent on the as a , /// null when not available /// public TimeSpan? ActualEffort { get; } /// /// Returns the actual effort that is spent on the as a string (e.g. 11 weeks), /// null when no available /// public string ActualEffortText { get; } /// /// Returns the owner of the , null when not available /// public string Owner { get; } /// /// Returns the contacts of the , null when not available /// public ReadOnlyCollection Contacts { get; } /// /// Returns the name of the company for who the task is done, /// null when not available /// public ReadOnlyCollection Companies { get; } /// /// Returns the billing information for the , null when not available /// public string BillingInformation { get; } /// /// Returns the mileage that is driven to do the , null when not available /// public string Mileage { get; } /// /// Returns the datetime when the was completed, /// only set when is true. /// Otherwise null /// public DateTime? CompleteTime { get; } #endregion #region Constructor /// /// Initializes a new instance of the class. /// /// The message. internal Task(Storage message) : base(message._rootStorage) { //GC.SuppressFinalize(message); _namedProperties = message._namedProperties; _propHeaderSize = MapiTags.PropertiesStreamHeaderTop; StartDate = GetMapiPropertyDateTime(MapiTags.TaskStartDate); DueDate = GetMapiPropertyDateTime(MapiTags.TaskDueDate); var status = GetMapiPropertyInt32(MapiTags.TaskStatus); if (status == null) Status = null; else Status = (TaskStatus)status; switch (Status) { case TaskStatus.NotStarted: StatusText = LanguageConsts.TaskStatusNotStartedText; break; case TaskStatus.InProgess: StatusText = LanguageConsts.TaskStatusInProgressText; break; case TaskStatus.Waiting: StatusText = LanguageConsts.TaskStatusWaitingText; break; case TaskStatus.Complete: StatusText = LanguageConsts.TaskStatusCompleteText; break; default: StatusText = null; break; } PercentageComplete = GetMapiPropertyDouble(MapiTags.PercentComplete); Complete = GetMapiPropertyBool(MapiTags.TaskComplete); var estimatedEffort = GetMapiPropertyInt32(MapiTags.TaskEstimatedEffort); if (estimatedEffort == null) EstimatedEffort = null; else EstimatedEffort = new TimeSpan(0, 0, (int)estimatedEffort); var now = DateTime.Now; EstimatedEffortText = (EstimatedEffort == null ? null : DateDifference.Difference(now, now + ((TimeSpan) EstimatedEffort)).ToString()); var actualEffort = GetMapiPropertyInt32(MapiTags.TaskActualEffort); if (actualEffort == null) ActualEffort = null; else ActualEffort = new TimeSpan(0, 0, (int) actualEffort); ActualEffortText = (ActualEffort == null ? null : DateDifference.Difference(now, now + ((TimeSpan) ActualEffort)).ToString()); Owner = GetMapiPropertyString(MapiTags.Owner); Contacts = GetMapiPropertyStringList(MapiTags.Contacts); Companies = GetMapiPropertyStringList(MapiTags.Companies); BillingInformation = GetMapiPropertyString(MapiTags.Billing); Mileage = GetMapiPropertyString(MapiTags.Mileage); CompleteTime = GetMapiPropertyDateTime(MapiTags.PR_FLAG_COMPLETE_TIME); } #endregion } } }