Example #1
0
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext context)
        {
            // Create an Outlook Application object.
            Outlook.Application outlookApp = new Outlook.Application();
            // Create a new TaskItem.
            Outlook.TaskItem newTask = (Outlook.TaskItem)outlookApp.CreateItem(Outlook.OlItemType.olTaskItem);
            // Configure the task at hand and save it.
            newTask.Body       = "Workflow Generated Task";
            newTask.DueDate    = DateTime.Now;
            newTask.Importance = Outlook.OlImportance.olImportanceHigh;

            if (this.Parent.Parent is ParallelActivity)
            {
                newTask.Subject = (this.Parent.Parent.Parent.Activities[1] as DummyActivity).TitleProperty;
                if ((this.Parent.Parent.Parent.Activities[1] as DummyActivity).TitleProperty != "")
                {
                    MessageBox.Show("Creating Outlook Task");
                    newTask.Save();
                }
            }
            else if (this.Parent.Parent is SequentialWorkflowActivity)
            {
                newTask.Subject = (this.Parent.Parent.Activities[1] as DummyActivity).TitleProperty;
                if ((this.Parent.Parent.Activities[1] as DummyActivity).TitleProperty != "")
                {
                    MessageBox.Show("Creating Outlook Task");
                    newTask.Save();
                }
            }
            return(ActivityExecutionStatus.Closed);
        }
        public void AddTask()
        {
            Outlook.TaskItem newTaskItem = null;
            //Проверяем текущую папку CustomFolder
            if (ChekCustomFolderExists())
            {
                //Создаем задачу в этой папке.
                newTaskItem =
                    (Outlook.TaskItem)CustomFolder.Items.Add(Outlook.OlItemType.olTaskItem);

                newTaskItem.UserProperties.Add("Parent", OlUserPropertyType.olText, false, true);
                newTaskItem.UserProperties.Add("Project", OlUserPropertyType.olText, true, true);
                newTaskItem.UserProperties["Project"].Value = CustomFolder.Name;
                newTaskItem.UserProperties.Add("Parent", OlUserPropertyType.olText, false, true);
                newTaskItem.UserProperties["Parent"].Value = outlookTaskParent;


                newTaskItem.Display("True");


                if (newTaskItem.Subject != null)
                {
                    //Создаем  задачу в Redmine
                    CreateNewTaskRedmine(newTaskItem);
                    newTaskItem.Save();
                    //Добавляю в папку с текущем проектом
                    CustomFolder.Items.Add(newTaskItem);
                }
                else
                {
                    MessageBox.Show($"Отсутствует описание! {Environment.NewLine} Задача не была добавлена");
                }
            }
            else
            {
                CustomFolder = CreateCustomFolder(RedmineOutlookAddIn.Properties.Settings.Default.CurrentFolder);
                newTaskItem  =
                    (Outlook.TaskItem)CustomFolder.Items.Add(Outlook.OlItemType.olTaskItem);



                newTaskItem.Display("True");
                if (newTaskItem.Subject != null)
                {
                    //Создаем  задачу в Redmine
                    CreateNewTaskRedmine(newTaskItem);
                    newTaskItem.Save();
                    //Добавляю в папку с текущем проектом
                    CustomFolder.Items.Add(newTaskItem);
                }
                else
                {
                    MessageBox.Show($"Отсутствует описание! {Environment.NewLine} Задача не была добавлена");
                }
            }
            Marshal.ReleaseComObject(newTaskItem);
        }
Example #3
0
 public static void CreateToDo(XLVirtualCabinet.FileInfo file)
 {
     try
     {
         if (ToDoFolder == null)
         {
             SetToDoFolder();
         }
         Outlook.TaskItem toDo = Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olTaskItem) as Outlook.TaskItem;
         string           desc = file.ClientString;
         desc           = desc + " - " + file.Description;
         toDo.Subject   = desc;
         toDo.StartDate = DateTime.Now;
         toDo.DueDate   = DateTime.Now.AddDays(1);
         //toDo.Body = file.FileID;
         XLOutlook.UpdateParameter(fileIdName, file.FileID, toDo);
         toDo.Move(ToDoFolder);
         toDo.Save();
     }
     catch (Exception ex)
     {
         XLant.XLtools.LogException("CreateToDo", ex.ToString());
         MessageBox.Show("Could not add To Do", "Add To Do", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 public void Save(IToDo t)
 {
     Outlook.TaskItem item = ((OutlookToDo)t).TaskItem;
     item.Assign();
     item.Save();
     sync();
 }
        public void UpdateTask(OutlookTask task)
        {
            OutlookTask outlookTask = task as OutlookTask;

            Outlook.TaskItem taskitem = outlookApp.Session.GetItemFromID(outlookTask.EntryId) as Outlook.TaskItem;
            taskitem = taskAndCategoryLoader.UpdateOutlookTaskItem(taskitem, task as OutlookTask);
            taskitem.Save();
        }
        private void TasksUpdates()
        {
            Outlook.NameSpace   namespce = null;
            Outlook.Items       tasks    = null;
            Outlook.Application oApp     = new Outlook.Application();
            namespce = oApp.GetNamespace("MAPI");
            tasks    = namespce.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks).Items;
            string temp    = string.Empty;
            string tmpRedm = string.Empty;
            bool   isExist = false;
            string AddedTastFromOutlook = string.Empty;

            foreach (Issue issue in manager.GetObjectList <Issue>(new NameValueCollection()))
            {
                foreach (Outlook.TaskItem task in tasks)
                {
                    if (task.Subject == issue.Subject)
                    {
                        if ((DateTime)issue.UpdatedOn > task.LastModificationTime)
                        {
                            UpdateOneTask(task, issue);
                        }
                        isExist = true;
                        continue;
                    }

                    temp += $"{task.Body}+{Environment.NewLine}";
                    bool isCompleeted = task.Complete;                    //Check if your task is compleeted in your application you could use EntryID property to identify a task
                    if (isCompleeted == true && task.Status != OlTaskStatus.olTaskComplete)
                    {
                        task.MarkComplete();
                        task.Save();
                    }

                    isExist = false;
                }
                if (isExist)
                {
                    Outlook.TaskItem task = null;

                    task           = (Outlook.TaskItem) this.Application.CreateItem(Outlook.OlItemType.olTaskItem);
                    task.Subject   = "Review site design";
                    task.StartDate = DateTime.Now;
                    task.DueDate   = DateTime.Now.AddDays(2);
                    task.Status    = Outlook.OlTaskStatus.olTaskNotStarted;
                    task.Save();
                    //newTaskItem.StartDate = (DateTime)issue.StartDate;
                    //newTaskItem.DueDate = (DateTime)issue.DueDate;
                    //AddedTastFromOutlook += $"{newTaskItem.Subject}+{Environment.NewLine}";

                    //Create a issue.
                }
            }

            MessageBox.Show("NewTAsk  " + AddedTastFromOutlook);
        }
Example #7
0
 private void CreateRecurringTask()
 {
     Outlook.TaskItem task = Application.CreateItem(
         Outlook.OlItemType.olTaskItem) as Outlook.TaskItem;
     task.Subject   = "Tax Preparation";
     task.StartDate = DateTime.Parse("4/1/2007 8:00 AM");
     task.DueDate   = DateTime.Parse("4/15/2007 8:00 AM");
     Outlook.RecurrencePattern pattern =
         task.GetRecurrencePattern();
     pattern.RecurrenceType   = Outlook.OlRecurrenceType.olRecursYearly;
     pattern.PatternStartDate = DateTime.Parse("4/1/2007");
     pattern.NoEndDate        = true;
     task.ReminderSet         = true;
     task.ReminderTime        = DateTime.Parse("4/1/2007 8:00 AM");
     task.Save();
 }
Example #8
0
        void items_ItemAdd(object item)
        {
            var mail = (Outlook.MailItem)item;

            if (mail.Body.Contains("Sunil"))
            {
                Outlook.TaskItem oTask = this.Application.CreateItem(Outlook.OlItemType.olTaskItem);
                oTask.Subject              = mail.Subject;
                oTask.DueDate              = mail.ReceivedTime.AddHours(6);
                oTask.StartDate            = mail.ReceivedTime;
                oTask.ReminderSet          = true;
                oTask.ReminderTime         = mail.ReceivedTime.AddMinutes(30);
                oTask.Body                 = mail.Body;
                oTask.SchedulePlusPriority = "High";
                oTask.Status               = Outlook.OlTaskStatus.olTaskInProgress;
                oTask.Save();
            }
        }
        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);
        }
        internal void AddTask()
        {
            try
            {
                Outlook.TaskItem newTaskItem =
                    (Outlook.TaskItem) this.Application.CreateItem(Outlook.OlItemType.olTaskItem);
                newTaskItem.StartDate = DateTime.Now.AddHours(2);


                newTaskItem.Body = "Try to create a task";
                //Create a issue.

                newTaskItem.Save();
                newTaskItem.Display("True");

                var newIssue = new Issue
                {
                    Subject = newTaskItem.Subject,
                    Project = new IdentifiableName {
                        Id = 1
                    },
                    Description = newTaskItem.Body,
                    StartDate   = newTaskItem.StartDate,
                    DueDate     = newTaskItem.DueDate,
                };
                manager.CreateObject(newIssue);


                string str = string.Empty;
                manager.GetObjectList <Issue>(new NameValueCollection());
                foreach (var item in manager.GetObjectList <Issue>(new NameValueCollection()))
                {
                    str += item.Description + $"{Environment.NewLine}";
                }
                string task_list = string.Empty;

                MessageBox.Show(manager.ToString() + $"{Environment.NewLine}" + str);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("The following error occurred: " + ex.Message); throw;
            }
        }
        /// <summary>
        /// Метод - создает задачу в Outlook при обновлении
        /// </summary>
        /// <param name="issue"></param>
        private Outlook.TaskItem CreateNewTaskOutlook(Issue issue)
        {
            Outlook.TaskItem            task         = null;
            Dictionary <string, string> OutlookTasks = GetTasksFromCurrentFolder();

            //To Do чтобы сохраняла в текущий фолдер !!!!!
            task         = (Outlook.TaskItem)CustomFolder.Items.Add(Outlook.OlItemType.olTaskItem);
            task.Subject = issue.Subject;
            Issue parentRedmine           = null;
            bool  flagEistParentInOutlook = false;

            if (issue.ParentIssue != null)
            {
                parentRedmine = manager.GetObject <Issue>(issue.ParentIssue.Id.ToString(), new NameValueCollection());
                foreach (var taskID in OutlookTasks)
                {
                    //если есть такая задача в текущей папке, то просто в свойстве добавляем ее ид
                    if (taskID.Key == parentRedmine.Subject)
                    {
                        outlookTaskParent = taskID.Value;
                        task.UserProperties.Add("Parent", OlUserPropertyType.olText, false, true);
                        task.UserProperties["Parent"].Value = outlookTaskParent;
                        MessageBox.Show($"В задачу ***{task.Subject}*** добавлен родитель ***{parentRedmine.Subject}***");
                        flagEistParentInOutlook = true;
                    }
                }
                //если нет то создаем ее в текущей папке и добавляем ее ид в свойства
                if (!flagEistParentInOutlook)
                {
                    Outlook.TaskItem parentItemOutlook = CreateNewTaskOutlook(parentRedmine);
                    outlookTaskParent = parentItemOutlook.EntryID;
                    task.UserProperties.Add("Parent", OlUserPropertyType.olText, false, true);
                    task.UserProperties["Parent"].Value = outlookTaskParent;
                    task.UserProperties.Add("Parent", OlUserPropertyType.olText, false, true);
                    task.UserProperties["Parent"].Value = outlookTaskParent;
                    MessageBox.Show($"В задачу ***{task.Subject}*** создан и добавлен ***{parentItemOutlook.Subject}***");
                }
            }
            if (issue.Children != null)
            {
                MessageBox.Show("ребенок есть");
                Issue childrenRedmine = null;
                flagEistParentInOutlook = false;

                childrenRedmine = manager.GetObject <Issue>(issue.Children.ToString(), new NameValueCollection());
                foreach (var taskID in OutlookTasks)
                {
                    //если есть такая задача в текущей папке, то просто в свойстве добавляем ее ид
                    if (taskID.Key == childrenRedmine.Subject)
                    {
                        Outlook.NameSpace ns = Globals.ThisAddIn.Application.Session;


                        Outlook.TaskItem chiledrenOutlook = (Outlook.TaskItem)ns.GetItemFromID(taskID.Value);
                        outlookTaskParent = task.EntryID;
                        chiledrenOutlook.UserProperties.Add("Parent", OlUserPropertyType.olText, false, true);
                        chiledrenOutlook.UserProperties["Parent"].Value = outlookTaskParent;
                        MessageBox.Show($"В задачу ***{chiledrenOutlook.Subject}*** добавлен родитель ***{task.Subject}***");
                        flagEistParentInOutlook = true;
                    }
                }
                //если нет то создаем ее в текущей папке и добавляем ее ид в свойства
                if (!flagEistParentInOutlook)
                {
                    Outlook.TaskItem childernItemOutlook = CreateNewTaskOutlook(childrenRedmine);
                    outlookTaskParent = task.EntryID;
                    childernItemOutlook.UserProperties.Add("Parent", OlUserPropertyType.olText, false, true);
                    childernItemOutlook.UserProperties["Parent"].Value = outlookTaskParent;
                    childernItemOutlook.UserProperties.Add("InCalendar", OlUserPropertyType.olText, false, true);
                    childernItemOutlook.UserProperties["InCalendar"].Value = "false";
                    MessageBox.Show($"В задачу ***{childernItemOutlook.Subject}*** создан и добавлен ***{task.Subject}***");
                }
            }
            task.StartDate = (DateTime)issue.StartDate;
            if (issue.DueDate != null)
            {
                task.DueDate = (DateTime)issue.DueDate;
            }
            task.StartDate       = (DateTime)issue.StartDate;
            task.PercentComplete = (int)issue.DoneRatio;
            task.Body            = issue.Description;

            task.Save();

            return(task);
        }
Example #12
0
 protected override void SaveWrapper()
 {
     _item.Save();
 }