Ejemplo n.º 1
0
        internal static Unit createNewTask(Types.Outlook.OutlookTask muster)
        {
            var idItemCreated = String.Empty;
            var myItem        = stor.application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olTaskItem) as Outlook.TaskItem;

            myItem.Subject  = muster.Subject;
            myItem.Complete = muster.Completed;
            myItem.Body     = muster.Body;
            myItem.Save();

            idItemCreated = myItem.EntryID;

            Marshal.ReleaseComObject(myItem);

            var s    = Settings.Default;
            var keys = new List <string>(s._KeysProcessed ?? (new string[] { }));
            var ids  = new List <string>(s._IdsCreated ?? (new string[] { }));

            keys.Add(muster.Key);
            ids.Add(idItemCreated);
            s._KeysProcessed = keys.ToArray();
            s._IdsCreated    = ids.ToArray();
            s.Save();

            return((Unit)Activator.CreateInstance(typeof(Unit), true));
        }
Ejemplo n.º 2
0
        internal static Unit updateExistingTask(Types.Outlook.OutlookTask corresponding)
        {
            var s = Settings.Default;

            if (s._KeysProcessed == null)
            {
                throw new ArgumentNullException("KeysProcessed");
            }
            if (s._IdsCreated == null)
            {
                throw new ArgumentNullException("IdsCreated");
            }
            if (s._KeysProcessed.Length != s._IdsCreated.Length)
            {
                throw new ArgumentOutOfRangeException(
                          String.Format("KeysProcessed.Length ({0}) != IdsCreated.Length ({1})", s._KeysProcessed.Length, s._IdsCreated.Length)
                          );
            }

            var keysAndIds = new Hashtable();

            for (var i = 0; i < s._KeysProcessed.Length; i++)
            {
                var key = s._KeysProcessed[i];
                if (keysAndIds.ContainsKey(key))
                {
                    continue;
                }

                keysAndIds.Add(key, s._IdsCreated[i]);
            }

            var ns      = stor.application.Session;
            var entryID = keysAndIds[corresponding.Key] as string;
            var myItem  = ns.GetItemFromID(entryID) as Outlook.TaskItem;

            myItem.Subject  = corresponding.Subject;
            myItem.Complete = corresponding.Completed;
            myItem.Body     = corresponding.Body;
            myItem.Save();

            Marshal.ReleaseComObject(myItem);

            return((Unit)Activator.CreateInstance(typeof(Unit), true));
        }