Exemplo n.º 1
0
 protected override void WriteImpl(object value)
 {
     if (value != null && value.Equals(string.Empty) && _deletePropIfStringEmpty)
     {
         ResourceProxy proxy = new ResourceProxy(Resource);
         proxy.AsyncPriority = JobPriority.Immediate;
         proxy.DeleteProp(PropId);
     }
     else
     {
         base.WriteImpl(value);
     }
 }
Exemplo n.º 2
0
        private static void  SetCommonProps(IResource rule, string fullName, int restictionCount)
        {
            ResourceProxy proxy = new ResourceProxy(rule);

            proxy.BeginUpdate();
            proxy.SetProp("DeepName", fullName);
            proxy.SetProp("IsExpirationFilter", true);

            //  Remove default property so that rule of this type are not recognized
            //  as Action Rules, and thus are not activated in the inproper moment.
            proxy.DeleteProp("IsActionFilter");
            if (restictionCount > 0)
            {
                proxy.SetProp("CountRestriction", restictionCount);
            }
            else
            {
                proxy.DeleteProp("CountRestriction");
            }

            proxy.EndUpdate();
        }
Exemplo n.º 3
0
        public static void RemoveFromSync(IResource contact, bool removeEntryID)
        {
            ResourceProxy proxy = new ResourceProxy(contact);

            proxy.AsyncPriority = JobPriority.Immediate;
            proxy.BeginUpdate();
            if (removeEntryID)
            {
                proxy.DeleteProp(PROP.EntryID);
            }
            proxy.SetProp("UserCreated", true);
            proxy.EndUpdateAsync();
        }
Exemplo n.º 4
0
        public static void PlanToDownload(IResource feedItem, string folder)
        {
            if (feedItem.GetPropText(Props.EnclosureURL).Trim().Length > 0)
            {
                ResourceProxy proxy = new ResourceProxy(feedItem);
                proxy.BeginUpdate();
                proxy.SetProp(Props.EnclosureDownloadingState, DownloadState.Planned);
                proxy.DeleteProp(Props.EnclosureFailureReason);
                proxy.DeleteProp(Props.EnclosureTempFile);
                proxy.DeleteProp(Props.EnclosureDownloadedSize);

                if (!string.IsNullOrEmpty(folder))
                {
                    proxy.SetProp(Props.EnclosurePath, folder);
                }
                else
                {
                    proxy.DeleteProp(Props.EnclosurePath);
                }

                proxy.EndUpdate();
                DownloadNextEnclosure();
            }
        }
Exemplo n.º 5
0
        public void   Exec(IResource res, IActionParameterStore actionStore)
        {
            string        val   = actionStore.ParameterAsString().ToLower();
            ResourceProxy proxy = new ResourceProxy(res);

            proxy.BeginUpdate();
            if (val == "1" || val == "-1")
            {
                proxy.SetProp(STR.Importance, Int32.Parse(val));
            }
            else
            {
                proxy.DeleteProp(STR.Importance);
            }
            proxy.EndUpdate();
        }
Exemplo n.º 6
0
        public void SetResourceNodeSort(IResource node, string sortProps)
        {
            if (node.GetStringProp("SortPropStr") != sortProps)
            {
                ResourceProxy proxy = new ResourceProxy(node);
                proxy.BeginUpdate();
                proxy.DeleteProp("SortProp");
                proxy.SetProp("SortPropStr", sortProps);
                proxy.EndUpdate();
            }

            lock ( _sortPropCache )
            {
                _sortPropCache [node.Id] = sortProps;
            }
        }
Exemplo n.º 7
0
 public override void Execute(IActionContext context)
 {
     if (context.SelectedResources.Count > 0)
     {
         IResource     resource = context.SelectedResources[0];
         ResourceProxy proxy    = new ResourceProxy(resource);
         if (resource.HasProp("NoFormat"))
         {
             proxy.DeleteProp("NoFormat");
         }
         else
         {
             proxy.SetProp("NoFormat", true);
         }
     }
     Core.ResourceBrowser.RedisplaySelectedResource();
 }
Exemplo n.º 8
0
 public void Execute(IActionContext context)
 {
     foreach (IResource res in context.SelectedResources)
     {
         ResourceProxy proxy = new ResourceProxy(res);
         proxy.BeginUpdate();
         if (res.HasProp(Core.Props.ShowTotalCount))
         {
             proxy.DeleteProp(Core.Props.ShowTotalCount);
         }
         else
         {
             proxy.SetProp(Core.Props.ShowTotalCount, true);
         }
         proxy.EndUpdate();
     }
 }
Exemplo n.º 9
0
        public override void Save()
        {
            ResourceProxy proxy = new ResourceProxy(_fragment);

            proxy.BeginUpdate();
            proxy.SetProp(Core.Props.Subject, _edtName.Text);
            if (_edtAnnotation.Text.Trim().Length > 0)
            {
                proxy.SetProp(Core.Props.Annotation, _edtAnnotation.Text);
            }
            else
            {
                proxy.DeleteProp(Core.Props.Annotation);
            }
            proxy.EndUpdateAsync();

            // Save size
            Core.SettingStore.WriteInt("Clippings", "AnnotationEditWindowHeight", _panelAnnotation.Height);
            Core.SettingStore.WriteBool("Clippings", "OpenAfterSave", _chkOpenAfterSave.Checked);
        }
Exemplo n.º 10
0
        public override void Execute(IActionContext context)
        {
            IResource     view  = context.SelectedResources[0];
            ResourceProxy proxy = new ResourceProxy(view);

            proxy.BeginUpdate();
            if (!view.HasProp(Core.Props.ShowDeletedItems))
            {
                proxy.SetProp(Core.Props.ShowDeletedItems, true);
            }
            else
            {
                proxy.DeleteProp(Core.Props.ShowDeletedItems);
            }
            Core.SettingStore.WriteBool("Search", "ShowDeletedItems", !view.HasProp(Core.Props.ShowDeletedItems));
            proxy.SetProp("ForceExec", true);
            proxy.EndUpdate();

            Core.UnreadManager.InvalidateUnreadCounter(view);
            Core.LeftSidebar.DefaultViewPane.SelectResource(view);
        }
Exemplo n.º 11
0
        public ExportTaskDescriptor(IResource task)
        {
            Guard.NullArgument(task, "task");
            _task      = task;
            _createNew = !_task.HasProp(PROP.EntryID);
            if (_exportedTasks.Contains(_task.Id))
            {
                _abort = true;
                return;
            }
            _exportedTasks.Add(_task.Id);
            ResourceProxy proxy = new ResourceProxy(_task);

            if (!_createNew)
            {
                proxy.DeleteProp(PROP.OMTaskId);
            }
            else
            {
                _OMTaskId = DateTime.Now.Ticks.ToString();
                proxy.SetProp(PROP.OMTaskId, _OMTaskId);
            }
        }
Exemplo n.º 12
0
        private void OnRSSParseDone(object sender, EventArgs e)
        {
            RSSUnitOfWork uow = (RSSUnitOfWork)sender;

            uow.ParseDone -= new EventHandler(OnRSSParseDone);

            if (uow.Status == RSSWorkStatus.FeedDeleted)
            {
                return;
            }

            ResourceProxy proxy = new ResourceProxy(uow.Feed);

            proxy.BeginUpdate();
            proxy.SetProp(Props.LastUpdateTime, DateTime.Now);
            if (!uow.Feed.HasProp(Core.Props.Parent) && !uow.Feed.HasProp(Props.ItemCommentFeed))
            {
                proxy.SetProp(Core.Props.Parent, RSSPlugin.RootFeedGroup);
            }
            if (uow.Status == RSSWorkStatus.HTTPError || uow.Status == RSSWorkStatus.XMLError)
            {
                proxy.SetProp(Props.UpdateStatus, "(error)");
                proxy.SetProp(Core.Props.LastError, uow.LastException.Message);
            }
            else
            {
                proxy.DeleteProp(Props.UpdateStatus);
                proxy.DeleteProp(Core.Props.LastError);
            }
            if (uow.LastException is HttpDecompressException)
            {
                proxy.SetProp(Props.DisableCompression, true);
            }

            if (uow.Status == RSSWorkStatus.HTTPError && uow.HttpStatus == HttpStatusCode.Gone)
            {
                proxy.SetProp(Props.UpdateFrequency, -1);
            }
            else if (!uow.Feed.HasProp(Props.UpdateFrequency))
            {
                proxy.SetProp(Props.UpdateFrequency, (int)Settings.UpdateFrequency);
            }
            if (!uow.Feed.HasProp(Props.UpdatePeriod))
            {
                proxy.SetProp(Props.UpdatePeriod, (string)Settings.UpdatePeriod);
            }

            proxy.EndUpdate();

            if (uow.Status == RSSWorkStatus.HTTPError && uow.Attempts < 3)
            {
                Core.NetworkAP.QueueJobAt(
                    DateTime.Now.AddMinutes(5),
                    new QueueFeedUpdateDelegate(QueueFeedUpdate), uow.Feed, uow.Attempts + 1);
            }

            if (uow.Status == RSSWorkStatus.Success && uow.Feed.HasProp(Props.AutoDownloadEnclosure))
            {
                ScheduleEnclosures(uow.Feed);
            }

            CleanupCommentFeed(uow);
            ScheduleFeedUpdate(uow.Feed);

            if (FeedUpdated != null)
            {
                FeedUpdated(this, new ResourceEventArgs(uow.Feed));
            }

            lock (this)
            {
                _updatingCount--;
                while (_pendingFeeds.Count > 0)
                {
                    PendingFeed feed = (PendingFeed)_pendingFeeds.Pop();
                    if (feed.Feed.IsDeleted)
                    {
                        continue;
                    }
                    QueueFeedUpdate(feed.Feed, feed.Attempt);
                    break;
                }
                // Has queue gotten empty?
                if ((_pendingFeeds.Count == 0) && (_updatingCount == 0))
                {
                    Core.UserInterfaceAP.QueueJob("Feeds Update Queue has Gotten Empty.", new MethodInvoker(FireQueueGotEmpty));
                }
            }
        }
Exemplo n.º 13
0
        private void PerformSearch()
        {
            string query = _editHeading.Text.Trim();

            IResource[][] conditions = Controls2Resources(panelConditions.Controls);
            if (query.Length > 0)
            {
                IResource queryCondition = ((FilterRegistry)FMgr).CreateQueryConditionAux(null, query, comboSection.Text);
                FilterRegistry.ReferCondition2Template(queryCondition, FMgr.Std.BodyMatchesSearchQueryXName);

                //  Copy query condition to every subgroup or create the single one.
                if (conditions != null && conditions.Length > 0)
                {
                    for (int i = 0; i < conditions.Length; i++)
                    {
                        IResource[] group    = conditions[i];
                        IResource[] newGroup = new IResource[group.Length + 1];

                        for (int j = 0; j < group.Length; j++)
                        {
                            newGroup[j] = group[j];
                        }
                        newGroup[newGroup.Length - 1] = queryCondition;

                        conditions[i] = newGroup;
                    }
                }
                else
                {
                    conditions = FilterRegistry.Convert2Group(queryCondition);
                }
                UpdateStoredQueriesList(query);
            }

            IResource[] exceptions = ConvertTemplates2Conditions(panelExceptions.Controls);

            //-----------------------------------------------------------------
            //  need to remove existing basic View?
            //  NB: it removes all underlying AUX conditions including query search
            //-----------------------------------------------------------------
            IResource view = RStore.FindUniqueResource(FilterManagerProps.ViewResName, "DeepName", FMgr.ViewNameForSearchResults);

            string[] formTypes = ReformatTypes(CurrentResTypeDeep);
            if (view != null)
            {
                BaseResource = view;
                FMgr.ReregisterView(view, FMgr.ViewNameForSearchResults, formTypes, conditions, exceptions);
            }
            else
            {
                BaseResource = FMgr.RegisterView(FMgr.ViewNameForSearchResults, formTypes, conditions, exceptions);
            }

            //-----------------------------------------------------------------
            bool          showContext = (query.Length > 0) && Core.SettingStore.ReadBool("Resources", "ShowSearchContext", true);
            ResourceProxy proxy       = new ResourceProxy(BaseResource);

            proxy.BeginUpdate();
            proxy.SetProp(Core.Props.Name, SearchViewPrefix + query);
            proxy.SetProp(Core.Props.ShowDeletedItems, true);
            proxy.SetProp("ForceExec", true);
            proxy.SetProp("ShowContexts", showContext);
            if (BaseResource.HasProp(Core.Props.ContentType) || BaseResource.HasProp("ContentLinks"))
            {
                proxy.DeleteProp("ShowInAllTabs");
            }
            else
            {
                proxy.SetProp("ShowInAllTabs", true);
            }
            proxy.EndUpdate();

            //  if search is done specifically for the particular resource
            //  type - set the focus onto that tab.
            Core.ResourceTreeManager.LinkToResourceRoot(BaseResource, 1);
            if ((CurrentResTypeDeep != null) &&
                (CurrentResTypeDeep.IndexOf('|') == -1) && (CurrentResTypeDeep.IndexOf('#') == -1))
            {
                Core.TabManager.SelectResourceTypeTab(CurrentResTypeDeep);
            }
            else
            {
                Core.TabManager.SelectResourceTypeTab("");
            }

            Core.UIManager.BeginUpdateSidebar();
            Core.LeftSidebar.ActivateViewPane(StandardViewPanes.ViewsCategories);
            Core.UIManager.EndUpdateSidebar();
            Core.LeftSidebar.DefaultViewPane.SelectResource(BaseResource);
            BringToFront();
        }
Exemplo n.º 14
0
        public void  ProcessQuery(string query)
        {
            //-----------------------------------------------------------------
            //  Avoid perform any UI (and other, generally) work if we are
            //  shutting down - some components (like DefaultViewPane) may
            //  already be disposed.
            //-----------------------------------------------------------------
            if (Core.State != CoreState.Running)
            {
                return;
            }

            //-----------------------------------------------------------------
            //  Extract Search Extension subphrases, extract them out of the
            //  query and convert them into the list of conditions.
            //-----------------------------------------------------------------
            int anchorPos;

            string[]  resTypes        = null;
            bool      parseSuccessful = false;
            ArrayList conditions      = new ArrayList();

            do
            {
                string anchor;
                FindSearchExtension(query, out anchor, out anchorPos);
                if (anchorPos != -1)
                {
                    parseSuccessful = ParseSearchExtension(anchor, anchorPos, ref query, out resTypes, conditions);
                }
            }while((anchorPos != -1) && parseSuccessful);

            //-----------------------------------------------------------------
            //  Create condition from the query
            //-----------------------------------------------------------------
            IFilterRegistry fMgr           = Core.FilterRegistry;
            IResource       queryCondition = ((FilterRegistry)fMgr).CreateStandardConditionAux(null, query, ConditionOp.QueryMatch);

            FilterRegistry.ReferCondition2Template(queryCondition, fMgr.Std.BodyMatchesSearchQueryXName);

            conditions.Add(queryCondition);

            //-----------------------------------------------------------------
            bool showContexts = Core.SettingStore.ReadBool("Resources", "ShowSearchContext", true);
            bool showDelItems = Core.SettingStore.ReadBool("Search", "ShowDeletedItems", true);

            IResource[] condsList = (IResource[])conditions.ToArray(typeof(IResource));
            IResource   view      = Core.ResourceStore.FindUniqueResource(FilterManagerProps.ViewResName, "DeepName", Core.FilterRegistry.ViewNameForSearchResults);

            if (view != null)
            {
                fMgr.ReregisterView(view, fMgr.ViewNameForSearchResults, resTypes, condsList, null);
            }
            else
            {
                view = fMgr.RegisterView(fMgr.ViewNameForSearchResults, resTypes, condsList, null);
            }
            Core.FilterRegistry.SetVisibleInAllTabs(view);

            //-----------------------------------------------------------------
            //  Set additional properties characteristic only for "Search Results"
            //  view.
            //-----------------------------------------------------------------
            ResourceProxy proxy = new ResourceProxy(view);

            proxy.BeginUpdate();
            proxy.SetProp(Core.Props.Name, AdvancedSearchForm.SearchViewPrefix + query);
            proxy.SetProp("_DisplayName", AdvancedSearchForm.SearchViewPrefix + query);
            proxy.SetProp(Core.Props.ShowDeletedItems, showDelItems);
            proxy.SetProp("ShowContexts", showContexts);
            proxy.SetProp("ForceExec", true);
            if (Core.SettingStore.ReadBool("Search", "AutoSwitchToResults", true))
            {
                proxy.SetProp("RunToTabIfSingleTyped", true);
            }
            else
            {
                proxy.DeleteProp("RunToTabIfSingleTyped");
            }
            proxy.EndUpdate();

            //-----------------------------------------------------------------
            //  Add new view to the panel
            //  Some steps to specify the correct user-ordering for the new view.
            //-----------------------------------------------------------------
            Core.ResourceTreeManager.LinkToResourceRoot(view, int.MinValue);

            new UserResourceOrder(Core.ResourceTreeManager.ResourceTreeRoot).Insert(0, new int[] { view.Id }, false, null);

            //-----------------------------------------------------------------
            //  If we still in the Running mode we can do some UI work...
            //-----------------------------------------------------------------
            if (Core.State == CoreState.Running)
            {
                Core.UIManager.BeginUpdateSidebar();
                Core.LeftSidebar.ActivateViewPane(StandardViewPanes.ViewsCategories);
                Core.UIManager.EndUpdateSidebar();
                Core.LeftSidebar.DefaultViewPane.SelectResource(view);
            }
        }