MVC2 - Consume RSS feed with RDF and namespace http://www.w3.org/1999/02/22-rdf-syntax-ns#' - asp.net

I' trying to read the feed for the Washington Departmene of Fish and Wildlife, and keep etting this error:
The element with name 'RDF' and
namespace
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
is not an allowed feed format.
Here's the code from RssController:
public virtual ActionResult Index()
{
string feedUrl = #"http://wdfw.wa.gov/news/newsrss.php";
using (XmlReader reader = XmlReader.Create(feedUrl))
{
**SyndicationFeed rss = SyndicationFeed.Load(reader);**
return View(rss);
}
}
I've done seveal RSS applications but nave never ran into this issue. Anyone got any concrete ways of being able to parse this in ASP.NET MVC 2? (the lines with asterics are where the exception happens.

There's no support for RSS 1.0. Example of how to roll your own support here : https://web.archive.org/web/20211020140320/https://www.4guysfromrolla.com/articles/031809-1.aspx

This may not be applicable to you as it sounds like you are only interested in RSS, but if you want RDF support for your application (RSS 1.0 uses RDF/XML to encode it's data) then you could try my library dotNetRDF.
I suspect that a full blown RDF API is probably overkill though judging from your question.

Related

Microsoft Graph API online meetings DateTimeOffset format

I have a simple task which involves creating online meetings using Microsoft Graph API. I'm using the basic sample code from the site, something like this:
var onlineMeeting = new OnlineMeeting
{
StartDateTime = DateTimeOffset.Parse("2019-07-12T21:30:34.2444915+00:00"),
EndDateTime = DateTimeOffset.Parse("2019-07-12T21:30:34.2444915+00:00"),
Subject = "This is the subject"
};
var meeting = await graphClient.Users["userid here"].OnlineMeetings.Request().AddAsync(onlineMeeting);
This unfortunately gives a 400 response with a very obsure reasoning. However, I was able to narrow down the probable cause of the problem: the serialization of the DateTimeOffset properties. For some reason, my requests contain the data in the format like 19/07/12 21:30:34 -07:00", instead of the required format, which is basically the same as the argument provided for DateTimeOffset.Parse().
My question is how can I customize the serialization format in the SDK? And more importantly, why should I do this explicitly, and why can't I find any mention of this in the documentation?
Turns out I have not updated the SDK for a while now and I was using an old version. I updated to the latest version and the problem went away :)

Mail Merge Feature for a CRM web-app made in asp.NET

We're working on a web based CRM for my company in ASP.net. I frequently have to send newsletters to all of my customers, and it becomes tedious to manually copy all of their addresses. What I would like is a feature to send one mail to all of my customers, taking their addresses from our contacts database, similar to a mail merge.
My developer said that he can do this for Emails, but not for physical mail. His reasoning behind this is that he can write a script that sends the mails to all customers one by one, but he can only give one single print command, which would only be able to print the current contents of the page. Therefore, he would not be able to print the individual letters for all of the customers.
Does anyone have ideas on how this would be possible? E.g. printing the page in such a way that each letter would be printed on a seperate page, or another way to automatically print all of the letters (with the mailmerged fields)?
Any help will be appreciated. If you require more details, please tell me.
A webpage is not the right solution to physically print letters. What you need to produce is a report that would generate a PDF file. This report will generate a PDF document with a different customer address on each page. Try using Microsoft Reporting Services, it is included in SQL Server. Crystal Reports is also a popular reporting solution too.
Also, you will have a hard time printing the stylized contents of your nice looking e-mail in the reporting solutions mentioned above. Consider using the report only as the cover letter of your mail piece.
One possible solution is to use 3rd party library for creation of individual letters for your customers. Docentric Toolkit is .NET tool that solves exactly your problem. We are using it for creating individual letters for customers and they all are merged in one file so that printing is done only once. Users can even create or change template documents.
Next you would have to create a template document in MS Word where you would include fixed content and placeholders for variable content which would be filled in at runtime with customer information.
After processing the data in .NET application you merge the data with the template document (see code snippet below). Your final document will be one file with letters for your customers, each on its own page. This file can then be sent to the printer with one print command.
I am attaching a code snippet of a Main method of the sample console application. The project has references to Entity Framework and Docentric’s dlls and uses entity model of Northwind database.
As you can see, it is really easy to prepare the data and merge it with template document. Solution is suitable for ASP.NET and MVC applications because you don’t need Microsoft Office installed on the server.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Docentric.Word;
namespace DisplayCustomers
{
class Program
{
static void Main(string[] args)
{
// first we read customers - in the example we select only customers
// from USA and Canada and order them by country and customer name
List<Customers> customerList = new List<Customers>();
using (var db = new NORTHWNDEntities())
{
customerList = db.Customers
.OrderBy(o => o.Country)
.ThenBy(o => o.CompanyName)
.Where(w => w.Country == "USA" || w.Country == "Canada")
.ToList();
}
// next we merge customers data with the template and generate final document;
string templateDoc = #"C:\Test\Templates\CustomerLetter1_templ.docx";
string outputDoc = #"C:\Test\FinishedLetters\CustomerLetters1.docx";
DocumentGenerator dg = new DocumentGenerator(customerList);
DocumentGenerationResult result = dg.GenerateDocument(templateDoc, outputDoc);
}
}
}

Javascript and Wordpress

Two related questions:
Is there any good documentation on the Fusion Tables Javascript API? I've found a list of methods, but with little info on return values, semantics, or usage idioms.
Is there any guidance (or suggested plugins or idioms) for integrating the FT Javascript API into a locally hosted Wordpress site?
There is some documentation here:
https://developers.google.com/fusiontables/docs/v1/getting_started#JS
but I didn't find it very useful.
But this example, in the context of the Google Maps API I found very useful for the new API 1.0
https://googledrive.com/host/0B5KVZ6J1ohN_Q3ZqVkFGSGZ2cEE/custom%20markers%20code/customicons_viaApi.html
You'll need to view and save the source. Also if you search the FT tag for JSONP you will find many examples using the old pre 1.0 API but the concepts are the same, just the AJAX end point has changed and the need for an apiKey.
The basic idea is that any FT query will return a JSON object with both columns and rows members, very much like a CSV response.
As the example above shows:
function onDataFetched(data) {
var rows = data.rows;
var cols = data.cols;
...
}

ASP.net (VB code behind) JSON parsing facebook Graph API response

net but wanted to try to do this code in ASP.net instead of my normal classic ASP.
I have been trying to find code examples that would show me how to parse out the name & id in a returned JSON from a facebook API Graph call. The JSON return looks like this from Facebook:
{
"data": [
{
"name": "David xxxxxx",
"id": "05121212",
"administrator": true
},
{
"name": "Billy xxxxxxx",
"id": "0005128888"
}
],
"paging": {
"next": "https://graph.facebook.com/xxxxx/members?format=json&limit=5000&offset=5000&__after_id=xxxxx"
}
}
Any examples on how to go about parsing out just the name and id from the JSON response in ASP.net would be awesome!
Thanks,
David
Go for, http://james.newtonking.com/
string response = <your fb data>; // I am lazy :P
JObject obj = JObject.Parse(response);
JArray data = (JArray)obj["data"];
for(int i=0,int len=data.count; i < len ; i++)
{
string name = data[i]["name"].ToString();
string id = data[i]["id"].ToString();
string administrator = string.Empty;
if(data[i]["administrator"]!=null)
{
string administrator = data[i]["administrator"].ToString();
}
}
I think, this code is enough to get you going.
Always check for null as api data may or may not have that value.
Edit: I noticed that you wanted a VB code, sorry. But it may help others, so leaving it here. You can convert the code from any C# to VB convertor.
Regardless of whether or not there is a known library for .NET and Open Graph, Json is Json. The way I see it you have three options:
1) Use Newtonsoft Json. You can install this package using nuget into your ASP.NET project and from there there are lots of places on the web that talk about working with this library. http://james.newtonking.com/ is the home page of the library, there are also posts here.
2) Use .NET Json. Again, lots of info on the web here. I found a pretty good looking post here Parse JSON in C#
3) Use the C# Facebook SDK. The FacebookClient class has the ability to serialize and de-serialize Json. You can also install this library via Nuget. I admit the documentation on the C# SDK is lacking, but none the less it works well. More information about it can be found here: http://blog.prabir.me/category/Facebook-C-SDK.aspx
I hope this helps you down the right path.
-Eric
There are no known supported libraries for .net for the new graph api. https://github.com/facebook-csharp-sdk has a few samples for using .net though.

Twitter Library for ASP.NET MVC that implements REST API

I been looking for a twitter lib for my ASP.NET NET MVC 3 software, but I need to implement the REST API functions that I nor found in Twitter Helper or Twitterizer. Rest API allow me to use a Find People query.
There is another one could solve my problem?
My suggestion would be to try looking into a library, such as TweetSharp that already has wrappers around a substantial amount of the Twitter API methods. If that doesn't work for you, consider writing your own wrapper around the methods you need using libraries such as HammockRest or RestSharp that have support for working with http, oauth and other such features that may assist you.
Looking better in Twitterizer I found what I need, perform Search People, and other functions. I recommend Twitterizer to use twitter in ASP.NET MVC 3, ´cause the oAuth process has a better code.
Here the Sample code to peform Search People in twitter using Twitterizer :
UserSearchOptions options = new UserSearchOptions();
options.NumberPerPage = 40;
options.Page = 1;
TwitterResponse<TwitterUserCollection> usersResponse = TwitterUser.Search(tokens,pesquisa.Conteudo,options);
if (usersResponse.Result == RequestResult.Success)
{
StringBuilder list = new StringBuilder();
foreach (var u in usersResponse.ResponseObject)
{
list2.Append(u.Name + "-" + u.Id);
}
ViewBag.Result_Twitter = list.ToString();
}

Resources