Exemplo n.º 1
0
 internal static void RecursivelyUpdateResourceList(ref IResourceList list, IResource resource, bool stopOnFirst)
 {
     if (stopOnFirst && list.Count > 0)
     {
         return;
     }
     if (resource.Type == "Weblink")
     {
         list = list.Union(resource.ToResourceList(), true);
     }
     else if (resource.Type == "Folder")
     {
         IResourceList childs = resource.GetLinksTo(null, "Parent");
         foreach (IResource child in childs)
         {
             RecursivelyUpdateResourceList(ref list, child, stopOnFirst);
         }
     }
     else
     {
         resource = resource.GetLinkProp("Source");
         if (resource != null && resource.Type == "Weblink")
         {
             list = list.Union(resource.ToResourceList(), true);
         }
     }
 }
Exemplo n.º 2
0
        public void Execute(IActionContext context)
        {
            if (context.SelectedResources.Count == 0)
            {
                return;
            }

            Core.UIManager.BeginUpdateSidebar();
            Core.TabManager.CurrentTabId = Core.TabManager.Tabs [0].Id;
            Core.UIManager.EndUpdateSidebar();

            IResource     mailAccount    = context.SelectedResources[0];
            IResourceList resourceList   = mailAccount.GetLinksOfTypeLive(null, Core.ContactManager.Props.LinkEmailAcctFrom);
            IResourceList resourceListTo = mailAccount.GetLinksOfTypeLive(null, Core.ContactManager.Props.LinkEmailAcctTo);
            IResourceList resourceListCC = mailAccount.GetLinksOfTypeLive(null, Core.ContactManager.Props.LinkEmailAcctCC);

            resourceList = resourceList.Union(resourceListTo);
            resourceList = resourceList.Union(resourceListCC);

            ResourceTypeHelper.ExcludeUnloadedPluginResources(resourceList);

            ResourceListDisplayOptions options = new ResourceListDisplayOptions();

            options.Caption = "Messages for " + mailAccount.DisplayName;
            options.SetTransientContainer(Core.ResourceTreeManager.ResourceTreeRoot,
                                          StandardViewPanes.ViewsCategories);
            Core.ResourceBrowser.DisplayResourceList(null, resourceList, options);
        }
Exemplo n.º 3
0
        [Test] public void TestDirectSetCondition()
        {
            IResourceList   categories = category1.ToResourceList();
            categories = categories.Union( category2.ToResourceList() );
            categories = categories.Union( category3.ToResourceList() );
            IResource condition = _registry.RecreateStandardCondition( "Available", "DeepName", null, "Category", ConditionOp.In, categories );
            IResource available = _registry.RegisterView( "Available", new IResource[ 1 ]{ condition }, null );
            _engine.InitializeCriteria();

            IResource test1 = _storage.BeginNewResource( "Email" );
            test1.SetProp( "Name", "Email 1" );
            test1.SetProp( "Date", DateTime.Now );
            test1.SetProp( "Category", category1 );
            test1.EndUpdate();

            IResource test2 = _storage.BeginNewResource( "Email" );
            test2.SetProp( "Name", "Email 2" );
            test2.SetProp( "Date", DateTime.Now );
            test2.SetProp( "Category", category2 );
            test2.SetProp( "Category", category3 );
            test2.EndUpdate();

            IResourceList result = _engine.ExecView( available );
            Assert.AreEqual( 2, result.Count, "Illegal number of matched objects" );
        }
Exemplo n.º 4
0
        public bool MatchResource(IResource res, IActionParameterStore actionStore)
        {
            IResourceList contacts       = actionStore.ParametersAsResList();
            IResourceList linkedContacts = res.GetLinksOfType(null, Core.ContactManager.Props.LinkFrom);

            linkedContacts = linkedContacts.Union(res.GetLinksOfType(null, Core.ContactManager.Props.LinkTo), true);
            linkedContacts = linkedContacts.Union(res.GetLinksOfType(null, Core.ContactManager.Props.LinkCC), true);
            linkedContacts = linkedContacts.Intersect(contacts, true);
            return(linkedContacts.Count > 0);
        }
Exemplo n.º 5
0
        public IResourceList  Filter(string resType)
        {
            IResourceStore store    = Core.ResourceStore;
            IResourceList  contacts = store.FindResourcesWithProp("Contact", -Core.ContactManager.Props.LinkFrom);

            contacts = contacts.Union(store.FindResourcesWithProp("Contact", -Core.ContactManager.Props.LinkTo), true);
            contacts = contacts.Union(store.FindResourcesWithProp("Contact", -Core.ContactManager.Props.LinkCC), true);

            return(contacts);
        }
Exemplo n.º 6
0
        private static IResourceList GetSubtree(IResource headCategory)
        {
            IResourceList result = Core.ResourceStore.EmptyResourceList;
            IResourceList childs = headCategory.GetLinksTo("Category", Core.Props.Parent);

            foreach (IResource category in childs)
            {
                result = result.Union(GetSubtree(category));
            }
            result = result.Union(headCategory.ToResourceList());
            return(result);
        }
Exemplo n.º 7
0
        private void buttonAddContact_Click(object sender, EventArgs e)
        {
            IResourceList sel = _suggestedContacts.GetSelectedResources();

            for (int i = 0; i < sel.Count; i++)
            {
                _contactsToMergeList  = _contactsToMergeList.Union(sel[i].ToResourceList());
                _suggestedContactList = _suggestedContactList.Minus(sel[i].ToResourceList());
                _contactsToMerge.JetListView.Nodes.Add(sel[i]);
                _suggestedContacts.JetListView.Nodes.Remove(sel[i]);
            }
            VerifyButtonsCondition();
        }
Exemplo n.º 8
0
        private void CollectResources(IResource res, IResource wsp,
                                      out IResourceList inThis, out IResourceList total)
        {
            inThis = GetPureList(res, wsp);
            total  = Core.ResourceStore.EmptyResourceList;
            IResourceList sub = res.GetLinksTo("Category", Core.Props.Parent);

            foreach (IResource subCat in sub)
            {
                total = total.Union(CollectResources(subCat, wsp));
            }
            total = total.Union(inThis);
        }
Exemplo n.º 9
0
            public IResourceList GetFilterList(bool live, bool includeFragments)
            {
                if (_resTypes == null)
                {
                    return(null);
                }

                IResourceList list = live
                                        ? Core.ResourceStore.GetAllResourcesLive(_resTypes)
                                        : Core.ResourceStore.GetAllResources(_resTypes);
                IResourceList fragmentList = null;
                SelectionType selType      = live ? SelectionType.Live : SelectionType.Normal;

                if (includeFragments)
                {
                    for (int i = 0; i < _resTypes.Length; i++)
                    {
                        IResourceList foundList = Core.ResourceStore.FindResources(selType, null,
                                                                                   "ContentType", _resTypes[i]);
                        if (fragmentList == null)
                        {
                            fragmentList = foundList;
                        }
                        else
                        {
                            fragmentList = fragmentList.Union(foundList, true);
                        }
                    }
                    if (fragmentList != null)
                    {
                        fragmentList = fragmentList.Intersect(Core.ResourceStore.GetAllResources("Fragment"), true);
                    }
                    list = list.Union(fragmentList);
                }

                if (_linkPropId != -1)
                {
                    IResourceList fileResourceTypes = Core.ResourceStore.GetAllResources(ResourceTypeHelper.GetFileResourceTypes());
                    fileResourceTypes = fileResourceTypes.Intersect(
                        Core.ResourceStore.FindResourcesWithProp(selType, null, _linkPropId), true);
                    list = list.Union(fileResourceTypes, true);

                    if (includeFragments)
                    {
                        list = list.Union(Core.ResourceStore.FindResources("Fragment", "ContentLinks",
                                                                           Core.ResourceStore.PropTypes[_linkPropId].Name), true);
                    }
                }
                return(list);
            }
Exemplo n.º 10
0
        //---------------------------------------------------------------------
        //  Show only those address books which have their "responsible"
        //  plugins loaded.
        //---------------------------------------------------------------------
        private void  LoadAddressBooks()
        {
            _addressBooks = Core.ResourceStore.EmptyResourceList;
            IResourceList abList = Core.ResourceStore.GetAllResourcesLive("AddressBook");

            foreach (IResource ab in abList)
            {
                string ownerType = ab.GetStringProp(Core.Props.ContentType);
                if (ResourceTypeHelper.IsResourceTypeActive(ownerType))
                {
                    _addressBooks = _addressBooks.Union(ab.ToResourceList());
                }
            }
            _addressBooks.Sort(new SortSettings(Core.Props.Name, false));

            lock ( _addressBooks )
            {
                foreach (IResource res in _addressBooks)
                {
                    _cmbCategory.Items.Add(res);
                }
            }

            _addressBooks.ResourceAdded    += _addressBooks_ResourceAdded;
            _addressBooks.ResourceDeleting += _addressBooks_ResourceDeleted;
        }
Exemplo n.º 11
0
        /// <summary>
        /// Returns the list of all resources linked to the specified resource
        /// with links marked as CountUnread.
        /// </summary>
        private static IResourceList GetUnreadCountedLinks(IResource res, out int count)
        {
            IResourceList unreadCountedLinks = null;

            count = 0;
            foreach (IPropType propType in Core.ResourceStore.PropTypes)
            {
                if (propType.HasFlag(PropTypeFlags.CountUnread))
                {
                    bool hasLink = res.HasProp(propType.Id);
                    if (!hasLink && propType.HasFlag(PropTypeFlags.DirectedLink))
                    {
                        hasLink = res.HasProp(-propType.Id);
                    }
                    if (hasLink)
                    {
                        IResourceList linkList = res.GetLinksOfType(null, propType.Id);
                        count += linkList.Count;
                        unreadCountedLinks = linkList.Union(unreadCountedLinks, true);
                    }
                }
            }

            return(unreadCountedLinks);
        }
Exemplo n.º 12
0
        private static void CheckMyselfLinkageWithAccounts()
        {
            IResource     res           = Core.ContactManager.MySelf.Resource;
            IResourceList accounts      = res.GetLinksOfType("EmailAccount", Core.ContactManager.Props.LinkEmailAcct);
            IResourceList cNames        = res.GetLinksOfType("ContactName", Core.ContactManager.Props.LinkBaseContact);
            IResourceList namesAccounts = Core.ResourceStore.EmptyResourceList;

            foreach (IResource cName in cNames)
            {
                namesAccounts = namesAccounts.Union(cName.GetLinksOfType("EmailAccount", Core.ContactManager.Props.LinkEmailAcct), true);
            }

            Trace.WriteLine("ContactsUpgrade - " + accounts.Count + " normal accounts found: ");
            foreach (IResource acc in accounts)
            {
                Trace.WriteLine("              " + acc.DisplayName);
            }

            Trace.WriteLine("ContactsUpgrade - " + namesAccounts.Count + " ContactName accounts found: ");
            foreach (IResource acc in namesAccounts)
            {
                Trace.WriteLine("              " + acc.DisplayName);
            }

            accounts = namesAccounts.Minus(accounts);

            Trace.WriteLine("ContactsUpgrade - found " + accounts.Count + " hanged accounts.");
            foreach (IResource acc in accounts)
            {
                Trace.WriteLine("          " + acc.DisplayName);
                res.AddLink(Core.ContactManager.Props.LinkEmailAcct, acc);
            }
        }
Exemplo n.º 13
0
        private static void DeleteCustomPropCondition(int propID)
        {
            IPropType propType = Core.ResourceStore.PropTypes [propID];

            //  remove condition template which is made from this property
            string resTypeName = (propType.DataType != PropDataType.Bool) ? FilterManagerProps.ConditionTemplateResName :
                                 FilterManagerProps.ConditionResName;
            IResourceList conditions = Core.ResourceStore.FindResources(resTypeName, Core.Props.Name, GetConditionName(propType));

            if (conditions.Count == 1)
            {
                conditions[0].Delete();
            }

            //  remove views which use conditions based on condition templates
            conditions = Core.ResourceStore.FindResources(SelectionType.Normal, FilterManagerProps.ConditionResName,
                                                          "ApplicableToProp", propType.Name);
            IResourceList views = Core.ResourceStore.EmptyResourceList;

            foreach (IResource res in conditions)
            {
                views = views.Union(res.GetLinksOfType(FilterManagerProps.ViewResName, "LinkedCondition"));
            }
            foreach (IResource res in views)
            {
                Core.FilterRegistry.DeleteView(res);
            }
        }
Exemplo n.º 14
0
        [Test] public void LiveTransientList()
        {
            IResource     email  = _storage.NewResource("Email");
            IResourceList emails = _storage.GetAllResourcesLive("Email");

            TransientResourceList trans  = new TransientResourceList();
            IResource             person = _storage.NewResourceTransient("Person");

            person.SetProp("FirstName", "Dmitry");
            trans.Add(person);

            IResource person2 = _storage.NewResourceTransient("Person");

            person2.SetProp("FirstName", "Sergey");
            trans.Add(person2);

            IResourceList union = emails.Union(trans);

            union.Sort("ID");
            Assert.AreEqual(3, union.Count);

            person2.Delete();
            Assert.AreEqual(2, union.Count);

            person.Delete();
            Assert.AreEqual(1, union.Count);
        }
Exemplo n.º 15
0
        //---------------------------------------------------------------------
        private void CreateNecessaryResources()
        {
            _storage.ResourceTypes.Register("Email", "", ResourceTypeFlags.Normal);
            _storage.ResourceTypes.Register("NewsArticle", "", ResourceTypeFlags.Normal);
            _storage.ResourceTypes.Register("RSSFeed", "", ResourceTypeFlags.Normal);
            _storage.ResourceTypes.Register("Category", "", ResourceTypeFlags.Normal);
            _storage.ResourceTypes.Register("HtmlFile", "", ResourceTypeFlags.Normal | ResourceTypeFlags.FileFormat);
            _storage.ResourceTypes.Register("TextFile", "", ResourceTypeFlags.Normal | ResourceTypeFlags.FileFormat);

            _storage.PropTypes.Register("ContentType", PropDataType.String, PropTypeFlags.Internal);
            _storage.PropTypes.Register("Subject", PropDataType.String, PropTypeFlags.Normal);
            _storage.PropTypes.Register("IsUnread", PropDataType.Bool, PropTypeFlags.Normal);
            _storage.PropTypes.Register("Date", PropDataType.Date, PropTypeFlags.Normal);
            _storage.PropTypes.Register("UnreadCount", PropDataType.Int, PropTypeFlags.Normal);
            _storage.PropTypes.Register("Category", PropDataType.Link, PropTypeFlags.Normal);
            _storage.PropTypes.Register("Name", PropDataType.String, PropTypeFlags.Normal);
            _storage.PropTypes.Register("DeepName", PropDataType.String, PropTypeFlags.Normal);
            _storage.PropTypes.Register("Counter", PropDataType.Int, PropTypeFlags.Normal);
            _storage.PropTypes.Register("Attachment", PropDataType.Link, PropTypeFlags.Normal | PropTypeFlags.SourceLink | PropTypeFlags.DirectedLink);
            _storage.PropTypes.Register("NewsAttachment", PropDataType.Link, PropTypeFlags.Normal | PropTypeFlags.SourceLink | PropTypeFlags.DirectedLink);

            //  Prepare a list of abstract resources for CreateStandardConditions pool parameters.
            oneResourceTypeList = Core.ResourceStore.EmptyResourceList;
            for (int i = 0; i < 10; i++)
            {
                IResource emailRes = _storage.BeginNewResource("Email");
                emailRes.SetProp("IsUnread", true);
                emailRes.SetProp("Date", DateTime.Now);
                emailRes.SetProp("Counter", i);
                emailRes.EndUpdate();

                oneResourceTypeList = oneResourceTypeList.Union(emailRes.ToResourceList());
            }
        }
Exemplo n.º 16
0
        //---------------------------------------------------------------------
        private void CreateNecessaryResources()
        {
            _storage.ResourceTypes.Register("Email", "", ResourceTypeFlags.Normal);
            _storage.ResourceTypes.Register("ViewFolder", "", ResourceTypeFlags.Normal);

            _storage.PropTypes.Register("IsUnread", PropDataType.Bool, PropTypeFlags.Normal);
            _storage.PropTypes.Register("Date", PropDataType.Date, PropTypeFlags.Normal);
            _storage.PropTypes.Register("UnreadCount", PropDataType.Int, PropTypeFlags.Normal);
            _storage.PropTypes.Register("Category", PropDataType.Link, PropTypeFlags.Normal);
            _storage.PropTypes.Register("Name", PropDataType.String, PropTypeFlags.Normal);
            _storage.PropTypes.Register("ContentType", PropDataType.String, PropTypeFlags.Internal);
            _storage.PropTypes.Register("DeepName", PropDataType.String, PropTypeFlags.Normal);

            //  Prepare a list of abstract resources for CreateStandardConditions pool parameters.
            emptyParamsList = Core.ResourceStore.EmptyResourceList;
            paramsList      = Core.ResourceStore.EmptyResourceList;
            for (int i = 0; i < 5; i++)
            {
                IResource emailRes = _storage.BeginNewResource("Email");
                emailRes.SetProp("IsUnread", true);
                emailRes.SetProp("Date", DateTime.Now);
                emailRes.EndUpdate();

                paramsList = paramsList.Union(emailRes.ToResourceList());
            }

            //-----------------------------------------------------------------
            filterObject1 = new SentOnly2MeCondition();
        }
Exemplo n.º 17
0
        private void  removeButton_Click(object sender, EventArgs e)
        {
            IResourceList list    = viewsTree.GetSelectedResources();
            IResourceList views   = Core.ResourceStore.EmptyResourceList,
                          folders = Core.ResourceStore.EmptyResourceList;

            foreach (IResource res in list)
            {
                if (res.Type == FilterManagerProps.ViewResName)
                {
                    views = views.Union(res.ToResourceList());
                }
                else
                {
                    folders = folders.Union(res.ToResourceList());
                }
            }

            EnableButtons(false);
            if (views.Count > 0)
            {
                RemoveViewsImpl(views);
            }
            if (folders.Count > 0)
            {
                RemoveFoldersImpl(folders);
            }
            EnableButtons(true);
            UpdateButtonsState();
        }
Exemplo n.º 18
0
            public IResource ParseTokenStream(string stream)
            {
                IResource     condition  = null;
                IResourceList candidates = Core.ResourceStore.EmptyResourceList;

                stream = stream.ToLower().Trim();
                if (stream == "me" || stream == "myself")
                {
                    candidates = candidates.Union(Core.ContactManager.MySelf.Resource.ToResourceList());
                }
                else
                {
                    string[] tokens = stream.Split(' ');
                    foreach (string token in tokens)
                    {
                        IResourceList list = Core.ResourceStore.FindResources("Contact", ContactManager._propFirstName, token);
                        list = list.Union(Core.ResourceStore.FindResources("Contact", ContactManager._propLastName, token));

                        candidates = (candidates.Count == 0) ? list : candidates.Intersect(list);
                    }
                }

                if (candidates.Count > 0)
                {
                    IResource template = Core.FilterRegistry.Std.FromContactX;
                    if (template != null)  //  Everything is possible :-(
                    {
                        condition = Core.FilterRegistry.InstantiateConditionTemplate(template, candidates, null);
                    }
                }

                return(condition);
            }
Exemplo n.º 19
0
        private void  CollectResourceTypesNames(IResourceList validResTypes)
        {
            MajorTypes = FormattedTypes = LinkTypes = Core.ResourceStore.EmptyResourceList;

            ArrayList validNames = new ArrayList();

            if (validResTypes != null)
            {
                foreach (IResource res in validResTypes)
                {
                    validNames.Add(res.GetStringProp(Core.Props.Name));
                }
            }

            //-----------------------------------------------------------------
            foreach (IResourceType rt in Store.ResourceTypes)
            {
                IResource resForType = Core.ResourceStore.FindUniqueResource("ResourceType", Core.Props.Name, rt.Name);

                //  possible when resource types are deleted via DebugPlugin.
                if (resForType != null)
                {
                    if (rt.HasFlag(ResourceTypeFlags.FileFormat))
                    {
                        if (IsFeasibleRT(rt, validNames, ResourceTypeFlags.Internal))
                        {
                            FormattedTypes = FormattedTypes.Union(resForType.ToResourceList());
                        }
                    }
                    else
                    {
                        if (IsFeasibleRT(rt, validNames, ResourceTypeFlags.NoIndex))
                        {
                            MajorTypes = MajorTypes.Union(resForType.ToResourceList());
                        }
                    }
                }
            }
            //  Resource "Clipping" is a special resource since it is semantically
            //  subsumed to be the part of other resource (and thus indirectly
            //  inherits its type)
//            temp1.Remove( "Clipping" );
            //  end hack

            //-----------------------------------------------------------------
            foreach (IPropType pt in Store.PropTypes)
            {
                if (pt.HasFlag(PropTypeFlags.SourceLink) && (pt.DisplayName != null) && pt.OwnerPluginLoaded)
                {
                    if (validResTypes == null || validNames.IndexOf(pt.Name) != -1)
                    {
                        IResource resForProp = Core.ResourceStore.FindUniqueResource("PropType", "Name", pt.Name);
                        LinkTypes = LinkTypes.Union(resForProp.ToResourceList());
                    }
                }
            }
        }
Exemplo n.º 20
0
 private static IResourceList GatherContentsOfSubfolders(IResource folder, IResourceList changesets)
 {
     changesets = changesets.Union(folder.GetLinksOfType(Props.ChangeSetResource, Props.AffectsFolder), true);
     foreach (IResource subfolder in folder.GetLinksTo(Props.FolderResource, Core.Props.Parent))
     {
         changesets = GatherContentsOfSubfolders(subfolder, changesets);
     }
     return(changesets);
 }
Exemplo n.º 21
0
        private static IResourceList  CategoriesTree(IResourceList heads)
        {
            IResourceList result = Core.ResourceStore.EmptyResourceList;

            foreach (IResource category in heads)
            {
                result = result.Union(GetSubtree(category));
            }
            return(result);
        }
Exemplo n.º 22
0
        private void InitSpyResourceList(IResource task)
        {
            IResourceStore store     = Core.ResourceStore;
            IResourceList  currTasks = Core.ResourceStore.EmptyResourceList;

            //  In order to correctly form a new live list we have to reconstruct
            //  it from scratch - first, form a "plain" (Union with merge) list
            //  and only then add minus and intersection.
            foreach (IResource res in _taskLive)
            {
                currTasks = currTasks.Union(res.ToResourceListLive(), true);
            }
            _taskLive = currTasks.Union(task.ToResourceListLive(), true);

            _taskLive = _taskLive.Minus(store.FindResources(null, TasksPlugin._propStatus, (int)TaskStatuses.Completed));
            _taskLive = _taskLive.Intersect(store.FindResourcesInRange(null, TasksPlugin._propRemindDate,
                                                                       DateTime.MinValue.AddSeconds(1), DateTime.Now), true);
            _taskLive.ResourceDeleting += new ResourceIndexEventHandler(_taskLive_ResourceDeleting);
        }
Exemplo n.º 23
0
        private IResourceList BuildRecursiveContentsList(IResource res)
        {
            IResourceList result = res.GetLinksOfTypeLive(null, _categoryManager.PropCategory);

            foreach (IResource child in res.GetLinksTo("Category", Core.Props.Parent))
            {
                result = result.Union(BuildRecursiveContentsList(child), true);
            }
            return(result);
        }
Exemplo n.º 24
0
        public static IResourceList GetBookmarks(IResource parent)
        {
            IResourceList result  = SubNodes("Weblink", parent);
            IResourceList folders = SubNodes("Folder", parent);

            foreach (IResource folder in folders)
            {
                result = result.Union(GetBookmarks(folder), true);
            }
            return(result);
        }
Exemplo n.º 25
0
            /**
             * Returns the list of mails that have attachments of one of the types
             * listed in the group.
             */

            public IResourceList GetMails()
            {
                IResourceList mails = null;

                foreach (IResource res in _foundExts)
                {
                    IResourceList rlist = res.GetLinksOfTypeLive(null, STR.AttachmentType);
                    mails = rlist.Union(mails, true);
                }
                return(mails);
            }
Exemplo n.º 26
0
        private static IResourceList UnrollConversationRecursive(IResourceList conv, IResource res,
                                                                 IResourceThreadingHandler handler)
        {
            IResourceList replies = handler.GetThreadChildren(res);

            conv = replies.Union(conv);
            foreach (IResource replyRes in replies)
            {
                conv = UnrollConversationRecursive(conv, replyRes, handler);
            }
            return(conv);
        }
Exemplo n.º 27
0
        private IResourceList CollectResources(IResource res, IResource wsp)
        {
            IResourceList total = GetPureList(res, wsp);
            IResourceList sub   = res.GetLinksTo("Category", Core.Props.Parent);

            foreach (IResource subCat in sub)
            {
                total = total.Union(CollectResources(subCat, wsp));
            }

            return(total);
        }
Exemplo n.º 28
0
        private void buttonOneToSplitted_Click(object sender, System.EventArgs e)
        {
            Debug.Assert(listLeavedContacts.SelectedIndex != -1);
            if (buttonOneToSplitted.Enabled)
            {
                ListBox.SelectedObjectCollection coll = listLeavedContacts.SelectedItems;
                foreach (IResource res in coll)
                {
                    listSplittedContacts.Items.Add(res);
                    AccumulatedContactsToSplit = AccumulatedContactsToSplit.Union(res.ToResourceList());
                }

                IResource[] list = new IResource[coll.Count];
                coll.CopyTo(list, 0);
                foreach (IResource res in list)
                {
                    listLeavedContacts.Items.Remove(res);
                }

                VerifyButtonsAccessibility();
            }
        }
Exemplo n.º 29
0
        private static void  UpdateFolder(IResource rule, IResource folder)
        {
            IResourceList list = Core.UIManager.GetResourcesInLocation(folder);

            //  Phase 1. Collect a set of resources from the folder which
            //           match conditions from the rule.
            IResourceList matched = Core.FilterEngine.ExecView(rule, list);

            //  Phase 2. If we have resource-count restriction on the rule,
            //           reduce the amount of matched resources to this count.
            if (rule.HasProp("CountRestriction"))
            {
                int countMargin = rule.GetIntProp("CountRestriction");
                if (countMargin > 0 && matched.Count > countMargin)
                {
                    matched.Sort(new SortSettings(Core.Props.Date, false));

                    List <int> ids = new List <int>(matched.Count - countMargin);
                    for (int i = countMargin; i < matched.Count; i++)
                    {
                        ids.Add(matched[i].Id);
                    }
                    matched = Core.ResourceStore.ListFromIds(ids, false);
                }
            }

            //  Phase 3. Collect authors of the matched resources if necessary.
            int           propDelContact = Core.ResourceStore.PropTypes["DeleteRelatedContact"].Id;
            IResourceList contacts       = Core.ResourceStore.EmptyResourceList;

            if (rule.HasProp(propDelContact))
            {
                foreach (IResource res in matched)
                {
                    IResourceList froms = res.GetLinksOfType("Contact", Core.ContactManager.Props.LinkFrom);
                    contacts = contacts.Union(froms, true);
                }
            }

            //  Phase 4. Apply actions to the matched resources. If necessary,
            //           remove their authors
            for (int i = matched.Count - 1; i >= 0; i--)
            {
                Core.FilterEngine.ApplyActions(rule, matched[i]);
            }

            if (rule.HasProp(propDelContact))
            {
                Core.ContactManager.DeleteUnusedContacts(contacts);
            }
        }
Exemplo n.º 30
0
        private static IResourceList FilterOutRulesByLoadedPluginType(IResourceList allRules)
        {
            IResourceList result = Core.ResourceStore.EmptyResourceList;

            foreach (IResource rule in allRules)
            {
                string type = rule.GetStringProp(Core.Props.ContentType);
                if (!ResourceTypeHelper.IsResourceTypePassive(type))
                {
                    result = result.Union(rule.ToResourceList());
                }
            }
            return(result);
        }