private void ParseNextCandidate() { PriorityQueue.QueueEntry qEntry = _candidateURLs.PopEntry(); if (qEntry == null) { OnDiscoverDone(); return; } if (_lastPriority != -1 && qEntry.Priority != _lastPriority && qEntry.Priority < 9 && _results.Count > 0) { OnDiscoverDone(); return; } _lastPriority = qEntry.Priority; ResourceProxy newFeedProxy = ResourceProxy.BeginNewResource("RSSFeed"); newFeedProxy.SetProp("Transient", 1); newFeedProxy.SetProp("URL", (string)qEntry.Value); newFeedProxy.EndUpdate(); _lastFeed = newFeedProxy.Resource; _lastUnitOfWork = new RSSUnitOfWork(_lastFeed, false, true); _lastUnitOfWork.DownloadProgress += new DownloadProgressEventHandler(RSSDownloadProgress); _lastUnitOfWork.ParseDone += new EventHandler(RSSParseDone); Core.NetworkAP.QueueJob(_lastUnitOfWork); }
public ResourceFlag(string flagID, string name, string iconAssembly, string iconName) { if (!_typesRegistered) { Core.ResourceAP.RunJob(new MethodInvoker(RegisterTypes)); } _resource = Core.ResourceStore.FindUniqueResource("Flag", "FlagId", flagID); if (_resource == null) { ResourceProxy proxy = ResourceProxy.BeginNewResource("Flag"); proxy.SetProp(Core.Props.Name, name); proxy.SetProp(_propFlagId, flagID); proxy.SetProp(_propIconAssembly, iconAssembly); proxy.SetProp(_propIconName, iconName); proxy.EndUpdate(); _resource = proxy.Resource; } else { ResourceProxy proxy = new ResourceProxy(_resource); proxy.SetProp(_propIconAssembly, iconAssembly); proxy.SetProp(_propIconName, iconName); } }
private IResource RegisterDocumentSection(string sectionName, string description, string shortName) { int sectionNum; IResource section = Core.ResourceStore.FindUniqueResource(DocumentSectionResource.DocSectionResName, Core.Props.Name, sectionName); if (section == null) { sectionNum = Core.ResourceStore.GetAllResources(DocumentSectionResource.DocSectionResName).Count; ResourceProxy proxy = ResourceProxy.BeginNewResource(DocumentSectionResource.DocSectionResName); proxy.BeginUpdate(); proxy.SetProp("Name", sectionName); proxy.SetProp("SectionOrder", sectionNum); if (String.IsNullOrEmpty(description)) { proxy.SetProp("SectionHelpDescription", description); } if (String.IsNullOrEmpty(shortName)) { proxy.SetProp("SectionShortName", shortName); } proxy.EndUpdate(); section = proxy.Resource; } else { sectionNum = section.GetIntProp("SectionOrder"); } _sectionsMapping[sectionName] = sectionNum; return(section); }
public override AbstractJob GetNextJob() { RSSUnitOfWork nextJob = null; if (_currentFeed != _feedUrls.Length) { string status = "Processing: " + _feedNames[_currentFeed]; Trace.WriteLine("MultipleFeedsJob -- Processing: " + _feedNames[_currentFeed]); if (DownloadTitleProgress != null) { DownloadTitleProgress(this, new DownloadProgressEventArgs(status)); } ResourceProxy proxy = ResourceProxy.BeginNewResource("RSSFeed"); proxy.SetProp(Props.Transient, 1); proxy.SetProp(Props.URL, _feedUrls[_currentFeed] + _query); proxy.SetProp(Props.RSSSearchPhrase, _searchPhrase); proxy.SetProp(Core.Props.Name, _feedNames[_currentFeed++] + ": \"" + _query + "\""); proxy.EndUpdate(); _feedProxies.Add(proxy); nextJob = new RSSUnitOfWork(proxy.Resource, false, true); nextJob.DownloadProgress += DownloadProgress; nextJob.ParseDone += JobParseDone; } return(nextJob); }
private void DoAddRepository(object sender, EventArgs e) { string repTypeId = null; MenuItem senderItem = (MenuItem)sender; foreach (RepositoryType repType in SccPlugin.RepositoryTypes) { if (repType.Name == senderItem.Text) { repTypeId = repType.Id; break; } } if (repTypeId == null) { return; } ResourceProxy proxy = ResourceProxy.BeginNewResource(Props.RepositoryResource); proxy.SetProp(Core.Props.Name, "<unnamed>"); proxy.SetProp(Props.RepositoryType, repTypeId); proxy.AddLink(Core.Props.Parent, Core.ResourceTreeManager.GetRootForType(Props.RepositoryResource)); proxy.EndUpdate(); SccPlugin.GetRepositoryType(repTypeId).EditRepository(this, proxy.Resource); RefreshRepositoryList(proxy.Resource); }
/// <summary> /// Adds a shortcut to the specified resource to the shortcut bar. /// </summary> public void AddShortcutToResource(IResource newShortcut) { ITabManager tabManager = Core.TabManager; IResource activeWorkspace = Core.WorkspaceManager.ActiveWorkspace; IResourceList shortcutTargets = newShortcut.GetLinksOfType("Shortcut", ShortcutProps.Target); if (newShortcut.Type == "SearchView") { foreach (IResource res in shortcutTargets) { if (res.GetStringProp(ShortcutProps.TabID) == tabManager.CurrentTabId && res.GetLinkProp(ShortcutProps.Workspace) == activeWorkspace) { return; } } } else { if (shortcutTargets.Count > 0) { return; } } ResourceProxy proxy = ResourceProxy.BeginNewResource("Shortcut"); proxy.SetProp(ShortcutProps.Order, _maxOrder + 1); proxy.AddLink(ShortcutProps.Target, newShortcut); if (activeWorkspace != null) { proxy.AddLink(ShortcutProps.Workspace, activeWorkspace); } if (newShortcut.Type == "SearchView") { proxy.SetProp(ShortcutProps.TabID, tabManager.CurrentTabId); string wsName = ""; if (activeWorkspace != null) { wsName = " in " + activeWorkspace.GetStringProp(Core.Props.Name); } proxy.SetProp(Core.Props.Name, tabManager.CurrentTab.Name + wsName + ": " + newShortcut.DisplayName); } else if (newShortcut.DisplayName.Length > 20) { proxy.SetProp(Core.Props.Name, newShortcut.DisplayName.Substring(0, 20) + "..."); } proxy.EndUpdate(); RebuildShortcutBar(); }
private void _btnNewGroup_Click(object sender, System.EventArgs e) { ResourceProxy proxy = ResourceProxy.BeginNewResource("RSSFeedGroup"); proxy.SetProp(Core.Props.Name, "<new folder>"); proxy.SetProp(Core.Props.Parent, SelectedGroup); proxy.EndUpdate(); _lastNewGroup = proxy.Resource; _feedGroupTree.EditResourceLabel(_lastNewGroup); }
public override void Execute(IActionContext context) { ResourceProxy proxy = ResourceProxy.BeginNewResource("Note"); proxy.SetProp(Core.Props.Subject, "New note"); proxy.EndUpdate(); NoteEditor editor = new NoteEditor(); Core.UIManager.OpenResourceEditWindow(editor, proxy.Resource, true); }
private TResourceObject CreateNewResource(TJira itemJira) { ResourceProxy proxy = ResourceProxy.BeginNewResource(_restype); proxy.SetProp(Props.JiraId, itemJira.id); proxy.AddLink(Core.Props.Parent, _server.Resource); proxy.EndUpdate(); return(CreateResourceObject(proxy.Resource)); }
/// <summary> /// Creates a new JIRA server resource. /// </summary> public static JiraServer CreateNew() { ResourceProxy proxy = ResourceProxy.BeginNewResource(Type); proxy.AddLink(Core.Props.Parent, RootResource); proxy.EndUpdate(); JiraServer retval = new JiraServer(proxy.Resource); retval.Name = Jiffa.GetRandomName(); return(retval); }
/// <summary> /// While syncing to JIRA, creates a new Omea resource for the locally-missing project. /// </summary> /// <returns></returns> protected JiraProject CreateProject(RemoteProject projectJira) { ResourceProxy proxy = ResourceProxy.BeginNewResource(Types.JiraProject); proxy.AsyncPriority = JobPriority.Normal; proxy.SetProp(Props.JiraId, projectJira.id); proxy.AddLink(Core.Props.Parent, Resource); proxy.EndUpdate(); return(GetProject(proxy.Resource)); }
private JiraComponent CreateComponent(RemoteComponent componentJira) { ResourceProxy proxy = ResourceProxy.BeginNewResource(Types.JiraComponent); proxy.AsyncPriority = JobPriority.Normal; proxy.SetProp(Props.JiraId, componentJira.id); proxy.AddLink(Core.Props.Parent, Resource); proxy.EndUpdate(); return(GetComponent(proxy.Resource)); }
private void EnumerateMailsImpl() { _tracer.Trace("prepare EnumerateMailsImpl"); try { if (SyncVersion < 10) { UpdateAttachments(); } if (SyncVersion < 9 && Settings.CreateAnnotationFromFollowup) { UpdateAnnotation(); } DateTime dtRestriction = Settings.IndexStartDate; if (!IsInitialStart()) { _tracer.Trace("Light enumeration is started"); if (Settings.SyncMode == MailSyncMode.None) { PrepareBackgroundWork(); } else if (Settings.SyncMode == MailSyncMode.All) { new MailSyncDescriptor(true, dtRestriction, false).NextMethod(); } else { new FreshMailEnumerator().NextMethod(); PrepareBackgroundWork(); } } else { ResourceProxy.BeginNewResource(STR.InitialEmailEnum).EndUpdateAsync(); _tracer.Trace("Heavy enumeration is started"); new MailSyncDescriptor(true, dtRestriction, false).NextMethod(); if (dtRestriction == DateTime.MinValue) { SetSyncComplete(); } } } finally { _tracer.Trace("fire FinishInitialIndexingJob"); Core.ResourceAP.QueueJob(new MethodInvoker(OutlookPlugin.FinishInitialIndexingJob)); } }
private static ResourceProxy GetRuleProxy(IResource rule) { ResourceProxy proxy; if (rule != null) { proxy = new ResourceProxy(rule); proxy.BeginUpdate(); } else { proxy = ResourceProxy.BeginNewResource(FilterManagerProps.ViewCompositeResName); } return(proxy); }
/// <summary> /// Creates a workspace with the specified name. /// </summary> public IResource CreateWorkspace(string name) { ResourceProxy proxy = ResourceProxy.BeginNewResource(_props.WorkspaceResourceType); proxy.SetProp("Name", name); proxy.EndUpdate(); ResourceProxy otherViewProxy = ResourceProxy.BeginNewResource("WorkspaceOtherView"); otherViewProxy.SetProp("Name", "Other"); otherViewProxy.AddLink(_props.InWorkspace, proxy.Resource); otherViewProxy.EndUpdate(); _resourceTreeManager.SetResourceNodeSort(proxy.Resource, "Type Name"); return(proxy.Resource); }
public IResource GetRootForType(string resType) { IResourceList resList = _store.FindResources(_resTreeRoot, _propRootResType, resType); if (resList.Count > 0) { return(resList [0]); } ResourceProxy proxy = ResourceProxy.BeginNewResource(_resTreeRoot); proxy.SetProp(_propRootResType, resType); proxy.EndUpdate(); return(proxy.Resource); }
private ResourceProxy CreateFeedProxy(string url, string name) { ResourceProxy proxy = ResourceProxy.BeginNewResource("RSSFeed"); proxy.SetProp(Props.Transient, 1); proxy.SetProp(Props.URL, url); if (name != null) { proxy.SetProp(Core.Props.Name, name); } if (_feedAddressPane.RequiresAuthentication) { proxy.SetProp(Props.HttpUserName, _feedAddressPane.UserName); proxy.SetProp(Props.HttpPassword, _feedAddressPane.Password); } proxy.EndUpdate(); return(proxy); }
protected static void SaveProtocolSettings(string protocol, string friendlyName, Default defProtocol) { CheckRegistration(); IResource resProtocol = Core.ResourceStore.FindUniqueResource(PROTOCOL_HANDLER, _propProtocol, protocol); ResourceProxy proxy = null; if (resProtocol == null) { proxy = ResourceProxy.BeginNewResource(PROTOCOL_HANDLER); proxy.SetProp(_propCheck, true); } else { proxy = new ResourceProxy(resProtocol); proxy.BeginUpdate(); } proxy.SetProp(_propProtocol, protocol); SaveProtocolSettings(proxy, friendlyName, defProtocol); }
public void Execute(IActionContext context) { ResourceProxy proxy = ResourceProxy.BeginNewResource(FilterManagerProps.ViewFolderResName); proxy.BeginUpdate(); string newName = CreateNewName(); proxy.SetProp(Core.Props.Name, newName); proxy.SetProp("DeepName", newName); // Link as subfolder? if (IsSingleViewFolder(context)) { proxy.SetProp(Core.Props.Parent, context.SelectedResources[0]); } // Set content type if we are in the tab for "exclusive" // resource type, e.g. Contact or Task string[] currTabResTypes = Core.TabManager.CurrentTab.GetResourceTypes(); if (currTabResTypes != null) { bool isViewExclusive = false; foreach (string resType in currTabResTypes) { isViewExclusive = isViewExclusive || Core.ResourceTreeManager.AreViewsExclusive(resType); } if (isViewExclusive) { proxy.SetProp(Core.Props.ContentType, currTabResTypes[0]); } } proxy.EndUpdate(); //----------------------------------------------------------------- if (!IsSingleViewFolder(context)) { Core.ResourceTreeManager.LinkToResourceRoot(proxy.Resource, 1); } Core.LeftSidebar.ActivateViewPane(StandardViewPanes.ViewsCategories); Core.LeftSidebar.DefaultViewPane.EditResourceLabel(proxy.Resource); }
private void DoImport() { if (_importRoot != null) { return; } ResourceProxy p = ResourceProxy.BeginNewResource("RSSFeedGroup"); p.EndUpdate(); _importRoot = p.Resource; Core.UIManager.RunWithProgressWindow(ImportManager.ImportPaneName, delegate { _manager.DoImport(_importRoot, false); }); Core.ResourceTreeManager.SetResourceNodeSort(_importRoot, "Type- Name"); _tvFeeds.RootResource = _importRoot; _tvFeeds.CheckedProperty = Props.Transient; _tvFeeds.CheckedSetValue = 0; _tvFeeds.CheckedUnsetValue = 1; _tvFeeds.ParentProperty = Core.Props.Parent; _tvFeeds.OpenProperty = Core.Props.Open; }
public IResource CloneRule(IResource sourceRule, string newName) { #region Preconditions if (!sourceRule.HasProp("IsFormattingFilter")) { throw new InvalidOperationException("FormattingRuleManager -- input resource is not a Formatting rule."); } IResource res = FindRule(newName); if (res != null) { throw new AmbiguousMatchException("FormattingRuleManager -- A Formatting rule with such name already exists."); } #endregion Preconditions ResourceProxy newRule = ResourceProxy.BeginNewResource(FilterManagerProps.ViewCompositeResName); FilterRegistry.CloneView(sourceRule, newRule, newName); CloneFormatting(sourceRule, newRule.Resource); return(newRule.Resource); }
/// <summary> /// Creates resources from the specified array of change set descriptors. /// </summary> /// <param name="changeSets">The change sets to be converted to resources.</param> private void CreateChangeSetResources(IResource repository, ChangeSetSummary[] changeSets) { string[] ignoredClients = repository.GetProp(Props.P4IgnoreChanges).Split(';'); foreach (ChangeSetSummary changeSet in changeSets) { if (Array.IndexOf(ignoredClients, changeSet.Client) >= 0) { continue; } if (FindChangeSet(repository, changeSet.Number) != null) { continue; } ResourceProxy proxy = ResourceProxy.BeginNewResource(Props.ChangeSetResource); proxy.SetProp(Props.ChangeSetNumber, changeSet.Number); proxy.SetProp(Core.Props.Date, changeSet.Date); proxy.SetProp(Props.P4Client, changeSet.Client); proxy.SetProp(Core.Props.IsUnread, true); proxy.AddLink(Props.ChangeSetRepository, repository); proxy.EndUpdate(); LinkChangeSetToContact(repository, proxy.Resource, changeSet.User); // Execute rules for the new changeset Core.FilterEngine.ExecRules(StandardEvents.ResourceReceived, proxy.Resource); // Request text indexing of the changeset Core.TextIndexManager.QueryIndexing(proxy.Resource.Id); if (changeSet.Number > repository.GetProp(Props.LastRevision)) { new ResourceProxy(repository).SetPropAsync(Props.LastRevision, changeSet.Number); } } }
private void ParseSvnLog(IResource repository, int startRevision, int lastRevision) { string log; try { log = GetRunner(repository).GetXmlLog(startRevision, lastRevision); ClearLastError(repository); } catch (RunnerException ex) { SetLastError(repository, ex); return; } XmlDocument doc = new XmlDocument(); doc.Load(new StringReader(log)); foreach (XmlElement node in doc.SelectNodes("//logentry")) { int revision = Int32.Parse(node.GetAttribute("revision")); if (FindChangeSet(repository, revision) != null) { continue; } string author = "", description = ""; DateTime date = DateTime.Now; XmlNode childNode = node.SelectSingleNode("author"); if (childNode != null) { author = childNode.InnerText; } childNode = node.SelectSingleNode("msg"); if (childNode != null) { description = childNode.InnerText; } childNode = node.SelectSingleNode("date"); if (childNode != null) { date = DateTime.Parse(childNode.InnerText); } ResourceProxy proxy = ResourceProxy.BeginNewResource(Props.ChangeSetResource); proxy.SetProp(Props.ChangeSetNumber, revision); proxy.SetProp(Core.Props.Date, date); proxy.SetProp(Core.Props.IsUnread, true); SetChangeSetDescription(proxy, description); proxy.AddLink(Props.ChangeSetRepository, repository); ProcessFileChanges(repository, proxy, node, revision); proxy.EndUpdate(); LinkChangeSetToContact(repository, proxy.Resource, author); // Execute rules for the new changeset Core.FilterEngine.ExecRules(StandardEvents.ResourceReceived, proxy.Resource); // Request text indexing of the changeset Core.TextIndexManager.QueryIndexing(proxy.Resource.Id); if (revision > repository.GetProp(Props.LastRevision)) { new ResourceProxy(repository).SetPropAsync(Props.LastRevision, revision); } } }
private void ImportFreinds(string UserName, string Password, int UpdateFreq, string UpdatePeriod) { Hashtable answer; Hashtable friends = new Hashtable(); string[] chrsp; string fullName = ""; try { chrsp = ChallengeResponse(Password); answer = FlatRequest("login", "user", UserName, "auth_method", "challenge", "auth_challenge", chrsp[0], "auth_response", chrsp[1]); fullName = answer.ContainsKey("name") ? answer["name"] as string : UserName; chrsp = ChallengeResponse(Password); answer = FlatRequest("getfriends", "user", UserName, "auth_method", "challenge", "auth_challenge", chrsp[0], "auth_response", chrsp[1]); if (!answer.ContainsKey("friend_count")) { throw new Exception("Answer format error: no number of friends provided"); } int friendsCount = 0; try { friendsCount = Int32.Parse(answer["friend_count"] as string); } catch { throw new Exception("Answer format error: number of friends is not numeric"); } for (int i = 1; i <= friendsCount; ++i) { string key; string friend; key = String.Format("friend_{0}_user", i); if (!answer.ContainsKey(key)) { throw new Exception(String.Format("Answer format error: no friend {0} provided", i)); } friend = answer[key] as string; key = String.Format("friend_{0}_name", i); if (!answer.ContainsKey(key)) { throw new Exception(String.Format("Answer format error: no name for friend {0} provided", i)); } friends.Add(friend, answer[key] as string); } } catch (Exception ex) { Core.UIManager.QueueUIJob(new StatusReportJob(ReportStatus), new object[] { "Protocol error:\n" + ex.Message, MessageBoxIcon.Error }); return; } // Make group fullName = String.Format(_groupNameTemplate, UserName, fullName); IResource feedGroup = Core.ResourceStore.FindUniqueResource("RSSFeedGroup", "Name", fullName); if (null == feedGroup) { IResource parentGroup = null; parentGroup = Core.ResourceStore.FindUniqueResource("ResourceTreeRoot", "RootResourceType", "RSSFeed"); ResourceProxy proxy = ResourceProxy.BeginNewResource("RSSFeedGroup"); try { proxy.SetProp("Name", fullName); if (null != parentGroup) { proxy.SetProp("Parent", parentGroup); } } finally { proxy.EndUpdate(); feedGroup = proxy.Resource; } if (null == feedGroup) { Core.UIManager.QueueUIJob(new StatusReportJob(ReportStatus), new object[] { "Can not add group for new feeds", MessageBoxIcon.Error }); return; } } // Ok, friends list is populated bool added = false; foreach (string friend in friends.Keys) { string URL = String.Format(_urlTemplate, friend); IResource feed = null; feed = Core.ResourceStore.FindUniqueResource("RSSFeed", "URL", URL); if (null != feed) { continue; } ResourceProxy proxy = ResourceProxy.BeginNewResource("RSSFeed"); try { proxy.SetProp("Name", String.Format(_feedNameTemplate, friend, friends[friend] as string)); proxy.SetProp("Description", String.Format(_feedDescTemplate, friend, friends[friend] as string)); proxy.SetProp("URL", URL); proxy.SetProp("Parent", feedGroup); proxy.SetProp("HttpUserName", UserName); proxy.SetProp("HttpPassword", Password); proxy.SetProp("UpdateFrequency", UpdateFreq); proxy.SetProp("UpdatePeriod", UpdatePeriod); } finally { proxy.EndUpdate(); feed = proxy.Resource; } if (null != feed) { added = true; LiveJournalPlugin.RSSService.QueueFeedUpdate(feed); } } if (added) { Core.WorkspaceManager.AddToActiveWorkspace(feedGroup); } else { Core.UIManager.QueueUIJob(new StatusReportJob(ReportStatus), new object[] { "No new friends were added", MessageBoxIcon.Information }); } }