private void getArticleUnit_Finished(AsciiProtocolUnit unit) { if (_articleAvailable) { IAsyncProcessor ap = Core.ResourceAP; if (_group == null) { ap.RunUniqueJob("Creating news article", new CreateArticleByProtocolHandlerDelegate(NewsArticleParser.CreateArticleByProtocolHandler), _lines.ToArray(typeof(string)), _article); } else { ap.QueueJob(_priority, "Creating news article", new CreateArticleDelegate(NewsArticleParser.CreateArticle), _lines.ToArray(typeof(string)), _group, _articleId); } } _getArticleUnit = null; FireFinished(); }
/** * IResource article can be null, in that case the new article is created */ public static IResource PlaceArticle(IResource article, IResource folder, IResourceList groups, string from, string subject, string text, string charset, string references, string nntpText, IResourceList attachments) { IResourceStore store = Core.ResourceStore; if (!store.IsOwnerThread()) { IAsyncProcessor resourceProcessor = Core.ResourceAP; article = (IResource)resourceProcessor.RunUniqueJob( new PlaceArticleDelegate(PlaceArticle), article, folder, groups, from, subject, text, charset, references, nntpText, attachments); } else { if (article == null || article.IsDeleted) { article = store.BeginNewResource(NntpPlugin._newsLocalArticle); } else { article.BeginUpdate(); article.DeleteProp(NntpPlugin._propArticleId); } try { article.SetProp(Core.Props.Subject, subject); article.SetProp(Core.Props.Date, DateTime.Now); IContact sender; NewsArticleParser.ParseFrom(article, from, out sender); NewsArticleParser.ParseReferences(article, references); article.SetProp(Core.Props.LongBody, text); article.SetProp(Core.FileResourceManager.PropCharset, charset); article.SetProp(NntpPlugin._propNntpText, nntpText); if (!folder.IsDeleted) { article.SetProp(NntpPlugin._propTo, folder); } if (groups != null) { foreach (IResource group in groups) { if (!group.IsDeleted) { article.AddLink(NntpPlugin._propTo, group); } } } if (attachments != null) { foreach (IResource attachment in attachments) { if (!attachment.IsDeleted) { attachment.AddLink(NntpPlugin._propAttachment, article); string actualResourceType = Core.FileResourceManager.GetResourceTypeByExtension( IOTools.GetExtension(attachment.GetPropText(Core.Props.Name))); if (actualResourceType != null && attachment.Type != actualResourceType) { attachment.ChangeType(actualResourceType); } if (attachment.IsTransient) { attachment.EndUpdate(); } } } } Core.WorkspaceManager.AddToActiveWorkspace(article); } finally { article.EndUpdate(); Core.TextIndexManager.QueryIndexing(article.Id); } } return(article); }