private mwPost CreateMovableTypePost(Entry testEntry) { mwPost newPost = new mwPost(); newPost.link = ""; newPost.permalink = ""; newPost.postid = ""; newPost.categories = new string[0]; newPost.dateCreated = testEntry.CreatedUtc; newPost.description = testEntry.Content; newPost.title = testEntry.Title; newPost.postid = proxy.metaweblog_newPost(crosspostInfo.Site.BlogId, crosspostInfo.Site.Username, crosspostInfo.Site.Password, newPost, true); Crosspost cp = new Crosspost(); cp.TargetEntryId = newPost.postid; cp.ProfileName = crosspostInfo.Site.ProfileName; cp.Categories = crosspostInfo.Categories; testEntry.Crossposts.Add(cp); return(newPost); }
protected void HandleCrosspost(CrosspostInfo ci, Entry entry) { try { BloggerAPIClientProxy proxy = new BloggerAPIClientProxy(); UriBuilder uriBuilder = new UriBuilder("http", ci.Site.HostName, ci.Site.Port, ci.Site.Endpoint); proxy.Url = uriBuilder.ToString(); proxy.UserAgent = this.UserAgent; if (ci.IsAlreadyPosted) { try { if (ci.Site.ApiType == "metaweblog") { mwPost existingPost = new mwPost(); existingPost.link = ""; existingPost.permalink = ""; existingPost.categories = ci.Categories.Split(';'); existingPost.postid = ci.TargetEntryId; existingPost.dateCreated = entry.CreatedLocalTime; existingPost.title = entry.Title; existingPost.description = entry.Content + ci.GetTrackingSnippet(entry.EntryId); proxy.metaweblog_editPost(ci.TargetEntryId, ci.Site.Username, ci.Site.Password, existingPost, true); Crosspost cp = new Crosspost(); cp.TargetEntryId = ci.TargetEntryId; cp.ProfileName = ci.Site.ProfileName; cp.Categories = ci.Categories; entry.Crossposts.Add(cp); } else if (ci.Site.ApiType == "blogger") { proxy.blogger_editPost("", ci.TargetEntryId, ci.Site.Username, ci.Site.Password, entry.Content + ci.GetTrackingSnippet(entry.EntryId), true); Crosspost cp = new Crosspost(); cp.TargetEntryId = ci.TargetEntryId; cp.ProfileName = ci.Site.ProfileName; entry.Crossposts.Add(cp); } if (loggingService != null) { loggingService.AddEvent( new EventDataItem(EventCodes.CrosspostChanged, ci.Site.HostName, null)); } } catch (XmlRpcFaultException xrfe) { ErrorTrace.Trace(TraceLevel.Error, xrfe); if (loggingService != null) { loggingService.AddEvent( new EventDataItem(EventCodes.Error, xrfe.Message, String.Format("Updating cross-post entry {0} on {1}; Failed with server-fault code, {2} \"{3}\"", ci.TargetEntryId, ci.Site.ProfileName, xrfe.FaultCode, xrfe.FaultString))); } } catch (Exception e) { ErrorTrace.Trace(TraceLevel.Error, e); if (loggingService != null) { loggingService.AddEvent( new EventDataItem(EventCodes.Error, e.ToString().Replace("\n", "<br />"), String.Format("Updating cross-post entry {0} on {1}", ci.TargetEntryId, ci.Site.ProfileName))); } } } else { try { if (ci.Site.ApiType == "metaweblog") { mwPost newPost = new mwPost(); newPost.link = ""; newPost.permalink = ""; newPost.postid = ""; newPost.categories = ci.Categories.Split(';'); newPost.dateCreated = entry.CreatedLocalTime; newPost.description = entry.Content + ci.GetTrackingSnippet(entry.EntryId); newPost.title = entry.Title; newPost.postid = proxy.metaweblog_newPost(ci.Site.BlogId, ci.Site.Username, ci.Site.Password, newPost, true); Crosspost cp = new Crosspost(); cp.TargetEntryId = newPost.postid; cp.ProfileName = ci.Site.ProfileName; cp.Categories = ci.Categories; entry.Crossposts.Add(cp); } else if (ci.Site.ApiType == "blogger") { Crosspost cp = new Crosspost(); cp.TargetEntryId = proxy.blogger_newPost("", ci.Site.BlogId, ci.Site.Username, ci.Site.Password, entry.Content + ci.GetTrackingSnippet(entry.EntryId), true); cp.ProfileName = ci.Site.ProfileName; entry.Crossposts.Add(cp); } if (loggingService != null) { loggingService.AddEvent( new EventDataItem(EventCodes.CrosspostAdded, ci.Site.HostName, null)); } } catch (XmlRpcFaultException xrfe) { ErrorTrace.Trace(TraceLevel.Error, xrfe); if (loggingService != null) { loggingService.AddEvent( new EventDataItem(EventCodes.Error, xrfe.Message, String.Format("Adding cross-post entry to {0}; Failed with server-fault code, {1} \"{2}\"", ci.Site.ProfileName, xrfe.FaultCode, xrfe.FaultString))); } } catch (Exception e) { ErrorTrace.Trace(TraceLevel.Error, e); if (loggingService != null) { loggingService.AddEvent( new EventDataItem(EventCodes.Error, e.ToString().Replace("\n", "<br />"), String.Format("Adding cross-post entry to {0}", ci.Site.ProfileName))); } } } } catch (Exception e) { ErrorTrace.Trace(TraceLevel.Error, e); if (loggingService != null) { loggingService.AddEvent( new EventDataItem(EventCodes.Error, e.ToString().Replace("\n", "<br />"), String.Format("HandleCrosspost to {0}", ci.Site.ProfileName))); } } }
private mwPost CreateMovableTypePost(Entry testEntry) { mwPost newPost = new mwPost(); newPost.link =""; newPost.permalink=""; newPost.postid=""; newPost.categories = new string[0]; newPost.dateCreated = testEntry.CreatedUtc; newPost.description = testEntry.Content; newPost.title = testEntry.Title; newPost.postid = proxy.metaweblog_newPost(crosspostInfo.Site.BlogId, crosspostInfo.Site.Username, crosspostInfo.Site.Password, newPost, true); Crosspost cp = new Crosspost(); cp.TargetEntryId = newPost.postid; cp.ProfileName = crosspostInfo.Site.ProfileName; cp.Categories = crosspostInfo.Categories; testEntry.Crossposts.Add( cp ); return newPost; }