Exemplo n.º 1
0
        [Test] public void ImportAIMWithExistingAccount()
        {
            Core.ContactManager.FindOrCreateMySelfContact(null, "test");

            IContact  contact    = Core.ContactManager.FindOrCreateContact(null, "Dmitry Jemerov");
            IResource aimAccount = _storage.NewResource(ResourceTypes.MirandaAIMAccount);

            aimAccount.SetProp(Props.ScreenName, "intelliyole");
            aimAccount.AddLink(Props.MirandaAcct, contact.Resource);

            MockMirandaDB      db           = new MockMirandaDB();
            MockMirandaContact ownerContact = (MockMirandaContact)db.UserContact;

            ownerContact.AddSetting("AIM", "SN", "test");
            ownerContact.AddSetting("AIM", "Nick", "test");

            MockMirandaContact otherContact = db.AddContact();

            otherContact.AddSetting("AIM", "SN", "intelliyole");
            ownerContact.AddSetting("AIM", "Nick", "intelliyole");
            otherContact.AddEvent("AIM", 0, DateTime.Now, 0, "Hello");

            DoImportDB(db);

            IResourceList contacts = Core.ResourceStore.GetAllResources("Contact");

            contacts.Sort(new SortSettings(ResourceProps.DisplayName, true));
            Assert.AreEqual(2, contacts.Count);
            Assert.AreEqual("Dmitry Jemerov", contacts [0].DisplayName);
            Assert.AreEqual("test", contacts [1].DisplayName);
        }
Exemplo n.º 2
0
        public IResourceList GetChildResources(IResource parent)
        {
            IResourceList result = null;

            if (parent == _treeRoot)
            {
                return(_workspaceContentsList);
            }
            WorkspaceResourceType wrType = Core.WorkspaceManager.GetWorkspaceResourceType(parent.Type);

            if (wrType == WorkspaceResourceType.Container && parent.HasLink(_workspaceManager.Props.InWorkspace, _workspace))
            {
                // if it's a container that is not linked recursively - do not show children
                return(Core.ResourceStore.EmptyResourceList);
            }

            result = parent.GetLinksToLive(null, _dataProvider.ParentProperty);
            result = result.Minus(_workspace.GetLinksToLive(null, _workspaceManager.Props.ExcludeFromWorkspace));
            string sortProps = Core.ResourceTreeManager.GetResourceNodeSort(parent);

            if (sortProps != null)
            {
                result.Sort(sortProps);
            }
            return(result);
        }
Exemplo n.º 3
0
        public void ResourceNodeSelected(IResource res)
        {
            bool categoryListRecursive = res.HasProp(_categoryManager.PropShowContentsRecursively);

            if (res != _lastCategory || categoryListRecursive != _lastCategoryListRecursive)
            {
                _lastCategory = res;
                _lastCategoryListRecursive = categoryListRecursive;
                if (_lastCategoryListRecursive)
                {
                    _lastCategoryList = BuildRecursiveContentsList(res);
                }
                else
                {
                    _lastCategoryList = res.GetLinksOfTypeLive(null, _categoryManager.PropCategory);
                }
                _lastCategoryList = ResourceTypeHelper.ExcludeUnloadedPluginResources(_lastCategoryList);
                _lastCategoryList.Sort(new SortSettings(Core.Props.Date, true));
            }
            ResourceListDisplayOptions options = new ResourceListDisplayOptions();

            options.Caption = "Resources in category " + res.DisplayName;
            if (_lastCategoryListRecursive)
            {
                options.Caption += " and subcategories";
            }
            options.SeeAlsoBar = true;

            Core.ResourceBrowser.DisplayConfigurableResourceList(res, _lastCategoryList, options);
        }
Exemplo n.º 4
0
        private void InitList(ref CheckedPlainListBox list, string name, IResourceList rules)
        {
            list                   = new CheckedPlainListBox();
            list.Name              = name;
            list.TabIndex          = 1;
            list.Location          = new Point(0, 0);
            list.Size              = new Size(300, 246);
            list.DoubleClick      += list_DoubleClick;
            list.SelectionChanged += list_SelectionChanged;

            list.AddDecorator(_decorator);

            int propId = Core.ResourceStore.PropTypes["Order"].Id;

            rules.Sort(new SortSettings(propId, true));

            list.Resources = rules;

            foreach (IResource res in rules)
            {
                list.SetCheckState(res, res.HasProp("RuleTurnedOff") ? CheckBoxState.Unchecked : CheckBoxState.Checked);
            }
            if (rules.Count > 0)
            {
                list.SelectSingleItem(rules[0]);
            }
        }
Exemplo n.º 5
0
        [Test] public void ContactWithSameEntryIDAndUpdateFieldsTest()
        {
            string   email   = "*****@*****.**";
            IContact contact = Core.ContactManager.CreateContact("Сергей Жулин");
            int      id      = contact.Resource.Id;

            Assert.IsNotNull(contact);
            contact.AddAccount(email);
            contact.Resource.SetProp(PROP.EntryID, "123");
            ContactNames contactNames = new ContactNames();

            contactNames.EmailAddress = "*****@*****.**";
            contact = contactNames.FindOrCreateContact("123");
            Assert.IsNull(contact);

            contactNames.FullName = "Sergey Zhulin";
            contact = contactNames.FindOrCreateContact("123");
            Assert.IsNotNull(contact);
            Assert.AreEqual(id, contact.Resource.Id);
            Assert.AreEqual("Sergey", contact.FirstName);
            Assert.AreEqual("Zhulin", contact.LastName);
            IResourceList accounts = contact.Resource.GetLinksOfType(STR.EmailAccount, "EmailAcct");

            accounts.Sort(new SortSettings(Core.ContactManager.Props.EmailAddress, false));
            Assert.AreEqual(2, accounts.Count);
        }
Exemplo n.º 6
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.º 7
0
        protected void RunSortTest(int count)
        {
            IResourceList testList = _storage.FindResourcesInRange("Test", "Index", 0, count);

            testList.Sort("Date");
            Console.WriteLine(testList.Count);
        }
Exemplo n.º 8
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.º 9
0
        public IResource SelectResource(IWin32Window ownerWindow, string type, string dialogCaption,
                                        IResource initialSelection, string helpTopic)
        {
            string[] types = (type == null) ? null : new string[] { type };
            type = InitDialog(dialogCaption, types,
                              (initialSelection == null) ? null : initialSelection.ToResourceList(),
                              helpTopic);

            IResourceList resList = Core.ResourceStore.GetAllResourcesLive(type);

            resList.Sort(new SortSettings(ResourceProps.DisplayName, true));
            _selectPane.SelectResource(new string[] { type }, resList, initialSelection);

            if (ShowDialog(ownerWindow) != DialogResult.OK)
            {
                return(null);
            }

            resList = _selectPane.GetSelection();
            if (resList == null || resList.Count == 0)
            {
                return(null);
            }

            return(resList [0]);
        }
Exemplo n.º 10
0
        internal static ResourceListState FromResource(IResource res)
        {
            DisplayColumnProps props = (Core.DisplayColumnManager as DisplayColumnManager).Props;

            IResourceList columnDescriptorResources = res.GetLinksOfType("ColumnDescriptor", props.ColumnDescriptor);

            columnDescriptorResources.Sort(new int[] { props.ColumnOrder }, true);
            ColumnDescriptor[] columns = new ColumnDescriptor [columnDescriptorResources.Count];
            for (int i = 0; i < columnDescriptorResources.Count; i++)
            {
                columns [i] = LoadColumnDescriptor(columnDescriptorResources [i]);
            }

            SortSettings sortSettings = LoadSortSettings(res, props);

            ResourceListState result = new ResourceListState(columns, sortSettings,
                                                             res.HasProp(props.GroupItems));

            result._columnSchemeResource = res;

            if (res.HasProp(props.ColumnKeyTypes))
            {
                result.KeyTypes = res.GetPropText(props.ColumnKeyTypes).Split(';');
            }
            if (res.HasProp(props.ColumnSchemeOwner))
            {
                result.SetOwner(res.GetLinkProp(props.ColumnSchemeOwner),
                                res.GetStringProp(props.ColumnSchemeTab));
            }

            return(result);
        }
Exemplo n.º 11
0
        public IResourceList GetChildResources(ResourceTreeView resourceTree, IResource parent)
        {
            IResourceList result = null;

            if (parent.Type == "Workspace")
            {
                result = parent.GetLinksToLive(null, "InWorkspace").Union(
                    parent.GetLinksToLive(null, "InWorkspaceRecursive"));
                result.Sort(new SortSettings(Core.Props.Name, true));
            }
            else
            {
                // if any of our parents has been added recursively, return our children
                // as the child list
                IResource nextParent = parent;
                while (nextParent != null)
                {
                    if (nextParent.HasLink("InWorkspaceRecursive", _currentWorkspace))
                    {
                        IResourceList excludedResources = _currentWorkspace.GetLinksOfTypeLive(null, "ExcludeFromWorkspace");
                        result = parent.GetLinksToLive(null, _tvInWorkspace.ParentProperty).Minus(excludedResources);
                        string sortProps = Core.ResourceTreeManager.GetResourceNodeSort(parent);
                        if (sortProps != null)
                        {
                            result.Sort(sortProps);
                        }
                        break;
                    }
                    nextParent = nextParent.GetLinkProp(_tvInWorkspace.ParentProperty);
                }
            }

            if (result != null)
            {
                IResourceList filterList = null;
                foreach (string resType in _resourceTypes)
                {
                    if (_workspaceManager.GetWorkspaceResourceType(resType) != WorkspaceResourceType.None)
                    {
                        filterList = Core.ResourceStore.GetAllResourcesLive(resType).Union(filterList, true);
                    }
                }
                result = result.Intersect(filterList, true);
                return(result);
            }
            return(Core.ResourceStore.EmptyResourceList);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Called to fill the pane with initial contents.
 /// </summary>
 public override void Populate()
 {
     _lvDevelopers.SmallImageList = Core.ResourceIconManager.ImageList;
     _developerList = Core.ResourceStore.FindResourcesWithPropLive("Contact", Props.UserContact);
     _developerList.Sort(new SortSettings(ResourceProps.DisplayName, true));
     _developerList.ResourceAdded    += new ResourceIndexEventHandler(HandleDeveloperListChanged);
     _developerList.ResourceDeleting += new ResourceIndexEventHandler(HandleDeveloperListChanged);
     RefreshDeveloperList();
 }
Exemplo n.º 13
0
        public static IResourceList GetVisibleResourceTypes()
        {
            IResourceList resTypes = Core.ResourceStore.GetAllResources("ResourceType");

            resTypes = resTypes.Minus(Core.ResourceStore.FindResources("ResourceType", "Internal", 1));

            resTypes.Sort(new SortSettings(ResourceProps.DisplayName, true));

            return(resTypes);
        }
Exemplo n.º 14
0
 protected override void RunTests()
 {
     for (int i = 0; i < 1000; i++)
     {
         IResourceList allEmails = _store.GetAllResources("Email");
         allEmails.Sort("Received");
         int cnt = allEmails.Count;  // ensures that the list is instantiated
         cnt = cnt;
     }
 }
Exemplo n.º 15
0
        private void SetupFormattingRules()
        {
            _formattingRuleList = Core.ResourceStore.FindResourcesWithPropLive(FilterManagerProps.ViewCompositeResName, "IsFormattingFilter");
            _formattingRuleList.ResourceAdded    += OnFormattingRuleAdded;
            _formattingRuleList.ResourceChanged  += OnFormattingRuleChanged;
            _formattingRuleList.ResourceDeleting += OnFormattingRuleDeleting;

            _formattingRuleList.Sort(new int[]  { Core.FilterRegistry.Props.Invisible, Core.Props.Date, Core.Props.Order },
                                     new bool[] { false, false, true });
            ReloadFormattingRules(null);
        }
Exemplo n.º 16
0
 private void OnSelectedResourceTypeChanged(object sender, EventArgs e)
 {
     if (_selectPane != null)
     {
         IResource     selResType   = (IResource)_resourceTypeCombo.SelectedItem;
         string        resType      = selResType.GetStringProp(Core.Props.Name);
         IResourceList allResources = Core.ResourceStore.GetAllResourcesLive(resType);
         allResources.Sort(new SortSettings(ResourceProps.DisplayName, true));
         _selectPane.SelectResources(new string[] { resType }, allResources, null);
     }
 }
Exemplo n.º 17
0
        private void CollectEngines()
        {
            IResourceList list = Core.ResourceStore.GetAllResources(Props.RSSSearchEngineResource);

            list.Sort(new int[] { Core.Props.Name }, true);
            foreach (IResource engine in list)
            {
                string name = engine.GetPropText(Core.Props.Name);
                _searchEngines.Nodes.Add(name);
                _urls[name] = engine.GetPropText(Props.URL);
            }
        }
Exemplo n.º 18
0
        public override void EditResource(IResource res)
        {
            IResourceList accounts = res.GetLinksOfType(null, Props.MirandaAcct);

            accounts.Sort(new SortSettings(ResourceProps.Type, true));
            int curY = 4;

            _typeLabelPool.MoveControlsToPool();
            _valueLabelPool.MoveControlsToPool();

            foreach (IResource acct in accounts)
            {
                string acctType;
                switch (acct.Type)
                {
                case ResourceTypes.MirandaICQAccount:    acctType = "ICQ";    break;

                case ResourceTypes.MirandaAIMAccount:    acctType = "AIM";    break;

                case ResourceTypes.MirandaJabberAccount: acctType = "Jabber"; break;

                case ResourceTypes.MirandaYahooAccount:  acctType = "Yahoo";  break;

                default: acctType = "Other"; break;
                }

                Label lblType = (Label)_typeLabelPool.GetControl();
                lblType.Text     = acctType + ":";
                lblType.Location = new Point(4, curY);

                JetTextBox lblValue = (JetTextBox)_valueLabelPool.GetControl();
                if (acct.Type == ResourceTypes.MirandaICQAccount)
                {
                    lblValue.Text = acct.GetPropText("UIN");
                }
                else
                {
                    lblValue.Text = acct.DisplayName;
                }

                lblValue.Location = new Point(88, curY);
                lblValue.Width    = Width - 96;

                curY += 20;
            }

            _typeLabelPool.RemovePooledControls();
            _valueLabelPool.RemovePooledControls();

            Height = curY + 4;
        }
Exemplo n.º 19
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.º 20
0
        [Test] public void TestIndexChange()
        {
            _resList.Sort("Subject");
            IResource email1 = _storage.BeginNewResource("Email");

            email1.SetProp("Subject", "A");
            email1.EndUpdate();

            IResource email2 = _storage.BeginNewResource("Email");

            email2.SetProp("Subject", "B");
            email2.EndUpdate();

            DiscardEvents();

            email1.SetProp("Subject", "Z");
            VerifyNextEvent(EventType.Remove, email1.Id, 0, 0);
            VerifyNextEvent(EventType.Add, email1.Id, 1, 1);
        }
Exemplo n.º 21
0
        protected override void RunTests()
        {
            for (int i = 0; i < 100; i++)
            {
                IResourceList allEmails = _store.GetAllResourcesLive("Email");
                allEmails.Sort("Subject");
                int cnt = allEmails.Count;  // ensures that the list is instantiated
                cnt = cnt;

                IResource newEmail = _store.BeginNewResource("Email");
                newEmail.SetProp("Subject", i.ToString());
                newEmail.EndUpdate();
            }
        }
Exemplo n.º 22
0
 void LoadResourceList(IResourceList resourceList)
 {
     _resourcesView.SuspendLayout();
     _resourcesView.Items.Clear();
     resourceList.Sort(new SortSettings(ResourceProps.Id, true));
     foreach (IResource resource in resourceList)
     {
         ListViewItem item = new ListViewItem(resource.Id.ToString());
         item.Tag = resource;
         item.SubItems.Add(resource.DisplayName);
         _resourcesView.Items.Add(item);
     }
     _count.Text = _resourcesView.Items.Count.ToString();
     _resourcesView.ResumeLayout();
 }
Exemplo n.º 23
0
        public void ResourceNodeSelected(IResource res)
        {
            if (res != _lastAB)
            {
                _lastAB     = res;
                _lastABList = _lastAB.GetLinksToLive(null, "InAddressBook");

                _lastABList.Sort(new SortSettings(ResourceProps.DisplayName, true));
            }

            ResourceListDisplayOptions options = new ResourceListDisplayOptions();

            options.DefaultGroupItems = false;
            options.CaptionTemplate   = "Address Book: %OWNER%";
            Core.ResourceBrowser.DisplayResourceList(res, _lastABList, options);
        }
Exemplo n.º 24
0
        public override void UpdateSelection()
        {
            if (_selectorMode)
            {
                return;
            }

            IResourceList selection = _listContacts.GetSelectedResources();

            if (selection == null || selection.Count == 0)
            {
                Core.UserInterfaceAP.RunJob(new DisplayResDlgt(DisplayResourcesInUI),
                                            null, Core.ResourceStore.EmptyResourceList, string.Empty);
            }
            else
            {
                string caption = "Correspondence with " + selection[0].DisplayName;
                if (selection.Count == 1)
                {
                    //---------------------------------------------------------
                    //  Keep the optimization for the case of repeatable selection
                    //  of single items - when the selection is not changed,
                    //  give previous result.
                    //---------------------------------------------------------
                    if (_lastCorrespondent == null || selection[0].Id != _lastCorrespondent.Id)
                    {
                        _lastCorrespondent = selection[0];
                        _lastResourceList  = ContactManager.LinkedCorrespondence(selection[0]);
                        _lastResourceList.Sort(new SortSettings(Core.Props.Date, true));
                    }
                }
                else
                {
                    _lastResourceList = ContactManager.LinkedCorrespondence(selection[0]);
                    for (int i = 1; i < selection.Count; i++)
                    {
                        _lastResourceList = _lastResourceList.Union(ContactManager.LinkedCorrespondence(selection[i]), true);
                        caption           = caption + ", " + selection[i].DisplayName;
                    }
                    _lastResourceList.Sort(new SortSettings(Core.Props.Date, true));
                    _lastCorrespondent = null;
                }
                Core.UserInterfaceAP.RunJob(new DisplayResDlgt(DisplayResourcesInUI),
                                            selection[0], _lastResourceList, caption);
            }
        }
Exemplo n.º 25
0
        private void  LoadCategories()
        {
            _categories = Core.ResourceStore.FindResourcesLive("Category", Core.Props.ContentType, "Contact");
            _categories.Sort(new SortSettings(Core.Props.Name, false));

            lock ( _categories )
            {
                foreach (IResource res in _categories)
                {
                    _cmbCategory.Items.Add(res);
                }
                if (_categories.Count > 0)
                {
                    _cmbCategory.Items.Add("Not categorized");
                }
            }
        }
Exemplo n.º 26
0
        public JetWorkspaceResourcesProvider(ResourceTreeDataProvider dataProvider, IResource workspace,
                                             string[] workspaceFilterTypes, IResource treeRoot)
        {
            _workspaceManager     = Core.WorkspaceManager as WorkspaceManager;
            _workspace            = workspace;
            _dataProvider         = dataProvider;
            _workspaceFilterTypes = workspaceFilterTypes;
            _treeRoot             = treeRoot;

            _workspaceContentsList = _workspace.GetLinksToLive(null, _workspaceManager.Props.InWorkspace);
            _workspaceContentsList = _workspaceContentsList.Union(_workspace.GetLinksToLive(null, _workspaceManager.Props.InWorkspaceRecursive));
            _workspaceContentsList = _workspaceContentsList.Union(Core.ResourceStore.FindResourcesWithProp(null, _workspaceManager.Props.VisibleInAllWorkspaces));
            _workspaceContentsList.Sort(new SortSettings(Core.Props.Name, true));

            _workspaceContentsList.ResourceAdded    += OnWorkspaceContentsChanged;
            _workspaceContentsList.ResourceDeleting += OnWorkspaceContentsChanged;
        }
Exemplo n.º 27
0
        public IResourceList SelectResources(IWin32Window ownerWindow, string[] types, string dialogCaption,
                                             IResourceList initialSelection, string helpTopic)
        {
            string type = InitDialog(dialogCaption, types, initialSelection, helpTopic);

            IResourceList resList = Core.ResourceStore.GetAllResourcesLive(type);

            resList.Sort(new SortSettings(ResourceProps.DisplayName, true));
            _selectPane.SelectResources(types, resList, initialSelection);

            if (ShowDialog(ownerWindow) != DialogResult.OK)
            {
                return(null);
            }

            return(_selectPane.GetSelection());
        }
Exemplo n.º 28
0
        private void Populate()
        {
            _resourceTypes.SuspendLayout();
            IResourceList resourceTypes = _resourceStore.GetAllResources("ResourceType");

            resourceTypes.Sort(new SortSettings(Core.Props.Name, true));
            foreach (IResource resourceType in resourceTypes)
            {
                string name = resourceType.GetStringProp(Core.Props.Name);
                if (name != null)
                {
                    IResourceList resources = _resourceStore.GetAllResources(name);
                    _resourceTypes.Items.Add(new ResourceItem(resourceType, resources.Count));
                }
            }
            _resourceTypes.ResumeLayout();
        }
Exemplo n.º 29
0
        public override void ShowPane()
        {
            _wereChanges = false;
            _statusBox.Items.AddRange(new string[] { "Immediately", "On Startup", "Never" });
            _statusBox.SelectedIndex = 1;

            _folders = Core.ResourceStore.FindResourcesWithPropLive(
                FileProxy._folderResourceType, FileProxy._propStatus);
            _folders = _folders.Minus(Core.ResourceStore.FindResourcesWithPropLive(
                                          FileProxy._folderResourceType, FileProxy._propDeleted));

            ArrayList garbage = new ArrayList();

            foreach (IResource folder in _folders)
            {
                if (!folder.HasLink(FileProxy._propParentFolder, FoldersCollection.Instance.FilesRoot))
                {
                    garbage.Add(folder);
                }
            }
            foreach (IResource folder in garbage)
            {
                FoldersCollection.Instance.DeleteResource(folder);
            }

            // force monitoring of my documents if list is empty and we are in Startup Wizard
            if (IsStartupPane)
            {
                _statusColumn.Width = 0;
                _statusBox.Visible  = false;
                if (_folders.Count == 0)
                {
                    _wereChanges = true;
                    Core.ResourceAP.RunUniqueJob(new MethodInvoker(CreateMyDocumentsFolder));
                }
            }

            foreach (IResource folder in _folders)
            {
                _initialStatuses[folder.GetPropText(FileProxy._propDirectory)] =
                    folder.GetIntProp(FileProxy._propStatus);
            }
            _folders.Sort(new int[] { Core.Props.Name }, true);
            _folderList.DataProvider = new ResourceListDataProvider(_folders);
        }
Exemplo n.º 30
0
        private bool NeedUpdate(IResource commentFeed)
        {
            Guard.NullArgument(commentFeed, "commentFeed");
            IResourceList rssItems = commentFeed.GetLinksOfType("RSSItem", Props.RSSItem);

            rssItems.Sort(new SortSettings(Core.Props.Date, false));

            IResource lastItem;

            if (rssItems.Count == 0)
            {
                lastItem = commentFeed.GetLinkProp(Props.ItemCommentFeed);
            }
            else
            {
                lastItem = rssItems[0];
            }
            DateTime dt = lastItem.GetDateProp(Core.Props.Date);

            string updatePeriod    = Settings.StopUpdatePeriod;
            int    updateFrequency = Settings.StopUpdateFrequency;

            if (updateFrequency > 0)
            {
                switch (updatePeriod)
                {
                case UpdatePeriods.Daily:
                    dt = dt.AddDays(updateFrequency);
                    break;

                case UpdatePeriods.Weekly:
                    dt = dt.AddDays(7 * updateFrequency);
                    break;

                case UpdatePeriods.Minutely:
                    dt = dt.AddMinutes(updateFrequency);
                    break;

                default:
                    dt = dt.AddHours(updateFrequency);
                    break;
                }
            }
            return(DateTime.Now < dt);
        }