How to get attributes out of an event of Google-Calendar? - c#

In the Last days I tried to read attributes out of an event of Google-calendar
So currently I have only achived to get the event-ID out of my calendar.
Code:
using System;
using Google.GData.Extensions;
using Google.GData.Calendar;
namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
EventQuery query = new EventQuery();
query.Uri = new Uri("https://www.google.com/calendar/feeds/my#e-mail.com/public/basic");
query.NumberToRetrieve = 10;
query.StartTime = System.DateTime.Now;
query.EndTime = System.DateTime.Today.AddDays(10);
CalendarService service = new CalendarService(appName);
service.setUserCredentials(userName, password);
EventFeed calFeed = service.Query(query);
foreach (EventEntry feedEntry in calFeed.Entries)
{
Console.WriteLine("Event ID: " + feedEntry.EventId);
Console.ReadLine();
}
}
}
}
and I tried feedEntry.Title.Text to get the Title ... but its always "busy"
So my question is:
Ho Can I Get informations out of my Event?

The Answer is:
query.Uri = new Uri("https://www.google.com/calendar/feeds/my#e-mail.com/public/basic");
has to be :
query.Uri = new Uri("https://www.google.com/calendar/feeds/my#e-mail.com/private/full");

You should migrate off this approach altogether. Gdata is a deprecated Calendar API and will be shut down in November: http://googleappsdeveloper.blogspot.co.at/2014/07/upgrade-now-to-calendar-apiv3.html
Use Events.List in the Calendar API v3 https://developers.google.com/google-apps/calendar/

Related

Exposing a Web service to insert batch records to NAV

Hey Guys i have had a problem with this line in my code while trying to insert to customers table in NAV id really appreciate any feedback and possible solutions to my problem.
service.Create(ref custArray);
the full code i'm implementing is as follows; **kenedy is my webservice.
namespace PrintCustomerList
{
// Import newly generated Web service proxy.
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using kenedy;
using System.Diagnostics;
using System.Xml;
class Program
{
static void Main(string[] args)
{
var service = new Customer_Service();
service.UseDefaultCredentials = true;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.Url = "http://..:7047/DynamicsNAV90/WS/..%20LIMITED/Page/Customer";
// Create instance of customer.
Customer custArray = new Customer();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("C:\\Users\\..\\Desktop\\Product.xml");
var nodeList = xmlDoc.DocumentElement.SelectNodes("/Table/Product");
for(var i = 0; i < nodeList.Count; i++)
{
foreach (XmlNode node in nodeList)
{
custArray.Address = node.SelectSingleNode("Product_id").InnerText;
custArray.Name = node.SelectSingleNode("Product_name").InnerText;
custArray.Address_2 = node.SelectSingleNode("Product_price").InnerText;
Console.WriteLine(custArray.Name);
}
}
Console.WriteLine("Records Inserted");
Console.WriteLine("End of Customers");
Console.WriteLine("Press [ENTER] to exit program!");
Console.ReadLine();
service.Create(ref custArray);
// service.Update(ref custArray);
//service.CreateMultiple(ref custArray);
// Create instance of service and set credentials.
}
}
}}
You need to declare a user that has the right to post data. Change your credentials to:
NetworkCredential cred = new NetworkCredential("user", "password", "domain");
service.Credentials = cred;
hit me up with the error if it throws one!

Get Tweets Within Specific Location with TweetSharp

I'm trying to get tweets in a specific location. I'm using TweetSharp for that. I tried the following code:
// Pass your credentials to the service
TwitterService service = new TwitterService("xx", "xx");
// Step 4 - User authenticates using the Access Token
service.AuthenticateWith("xx-xx", "xx");
TwitterGeoLocationSearch geoSearch = new TwitterGeoLocationSearch(39.56, 32.52, 500, TwitterGeoLocationSearch.RadiusType.Km);
//IEnumerable<TwitterStatus> mentions = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
var tweets = service.Search(new SearchOptions() { Q = "ankara", Count = 30, Geocode = geoSearch });
But tweets.Statuses returns empty. If I remove Geocode part from SearchOptions I can get results. But I want to get tweets in a specific location radius.
I manage to do it with Twitterizer library:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var tokens = new Twitterizer.OAuthTokens
{
ConsumerKey = #"",
ConsumerSecret = #"",
AccessToken = #"-",
AccessTokenSecret = #""
};
var response = Twitterizer.TwitterSearch.Search(tokens, " ",
new Twitterizer.SearchOptions
{
Count = 5,
GeoCode = "39.920687,32.853970,50km"
});
if (response.Result != Twitterizer.RequestResult.Success)
return;
var index = 0;
foreach (var status in response.ResponseObject)
{
index++;
Console.WriteLine(index);
Console.WriteLine(status.Text);
Console.WriteLine(status.CreatedDate);
}
Console.ReadLine();
}
}
}

How to integrate Google Bigquery with c# console application

If it is possible to integrate Google big query with C# console application?.
If yes how we can do, i searched over internet i could not find proper answer for that.
I want connection string format? I have created Client ID from Google Developer console how authentication has done? It is one time configuration or every time we need to login in google account to authenticate.
If there is any sample application to connect sample data it would be helpful.
Thanks,
Selvakumar S
Here's a working sample based on another question in StackOverflow:
using DotNetOpenAuth.OAuth2;
using Google.Apis.Authentication.OAuth2;
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
using Google.Apis.Bigquery.v2;
using Google.Apis.Bigquery.v2.Data;
using Google.Apis.Util;
using System;
using System.Diagnostics;
using System.Collections.Generic;
namespace BigQueryConsole
{
public class BigQueryConsole
{
// Put your client ID and secret here (from https://developers.google.com/console)
// Use the installed app flow here.
// Client ID looks like "9999999.apps.googleusercontent.com"
static string clientId = "YOURCLIENTID";
static string clientSecret = "YOURSECRET";
// Project ID is in the URL of your project on the APIs Console
// Project ID looks like "999999";
static string projectId = "YOURPROJECTID";
// Query in SQL-like form
static string query = "SELECT state, count(*) from [publicdata:samples.natality] GROUP BY state ORDER BY state ASC";
public static void Main(string[] args)
{
// Register an authenticator.
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
provider.ClientIdentifier = clientId;
provider.ClientSecret = clientSecret;
// Initiate an OAuth 2.0 flow to get an access token
var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);
// Create the service.
var service = new BigqueryService(auth);
JobsResource j = service.Jobs;
QueryRequest qr = new QueryRequest();
qr.Query = query;
QueryResponse response = j.Query(qr, projectId).Fetch();
foreach (TableRow row in response.Rows)
{
List<string> list = new List<string>();
foreach (TableRow.FData field in row.F)
{
list.Add(field.V);
}
Console.WriteLine(String.Join("\t", list));
}
Console.WriteLine("\nPress enter to exit");
Console.ReadLine();
}
private static IAuthorizationState GetAuthorization(NativeApplicationClient arg)
{
// Get the auth URL:
IAuthorizationState state = new AuthorizationState(new[] { BigqueryService.Scopes.Bigquery.GetStringValue() });
state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
Uri authUri = arg.RequestUserAuthorization(state);
// Request authorization from the user (by opening a browser window):
Process.Start(authUri.ToString());
Console.Write(" Authorization Code: ");
string authCode = Console.ReadLine();
Console.WriteLine();
// Retrieve the access token by using the authorization code:
return arg.ProcessUserAuthorization(authCode, state);
}
}
}
In your answer i could not able to add namespace
"using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;"
But i manage to retrieve results from BigQuery using below code, you need to update Project Name, Project Id and Query.
Download Client ID (I am using Installed Application - Other category ) generate JSON file and add into your Debug folder.
using Google.Apis.Auth.OAuth2;
using System.IO;
using System.Threading;
using Google.Apis.Bigquery.v2;
using Google.Apis.Bigquery.v2.Data;
using System.Data;
using Google.Apis.Services;
using System;
namespace GoogleBigQuery
{
public class Class1
{
private static void Main()
{
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open,
FileAccess.Read))
{
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { BigqueryService.Scope.Bigquery },
"user", CancellationToken.None).Result;
}
// Create and initialize the Bigquery service. Use the Project Name value
// from the New Project window for the ApplicationName variable.
BigqueryService Service = new BigqueryService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "PROJECT NAME"
});
string query = "YOUR QUERY";
JobsResource j = Service.Jobs;
QueryRequest qr = new QueryRequest();
qr.Query = query;
DataTable DT = new DataTable();
int i = 0;
QueryResponse response = j.Query(qr, "PROJECT ID").Execute();
if (response != null)
{
int colCount = response.Schema.Fields.Count;
foreach (var Column in response.Schema.Fields)
{
DT.Columns.Add(Column.Name);
}
foreach (TableRow row in response.Rows)
{
DataRow dr = DT.NewRow();
for (i = 0; i < colCount; i++)
{
dr[i] = row.F[i].V;
}
DT.Rows.Add(dr);
}
}
else
{
Console.WriteLine("Response is null");
}
}
}
}
Thanks.

RallyDev - Getting Tasks for Stories using Rally.RestAPI.dll and Service V2.0

I'm pulling data off the Rally server at https://rally1.rallydev.com using C# and the Rally.RestAPI.dll. The server was recently upgraded to webservice v2.0 and I'm having some problems getting tasks for a user story. I know the way child collections are presented were changed in the API with the move to 2.0, but what I'm trying isn't working.
v2.0 removed the ability to return child collections in the same
response for performance reasons. Now fetching a collection will return
an object with the count and the url from which to get the collection
data.A separate request is needed to get to the elements of the
collection.
Here is the code that iterates over user story results, accesses "Tasks" collection on stories and issues a separate request to access individual Task attributes:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using Rally.RestApi;
using Rally.RestApi.Response;
namespace aRestApp_CollectionOfTasks
{
class Program
{
static void Main(string[] args)
{
//Initialize the REST API
RallyRestApi restApi;
restApi = new RallyRestApi("user#co.com", "secret", "https://rally1.rallydev.com", "v2.0");
//Set our Workspace and Project scopings
String workspaceRef = "/workspace/11111"; //please replace this OID with an OID of your workspace
String projectRef = "/project/22222"; //please replace this OID with an OID of your project
bool projectScopingUp = false;
bool projectScopingDown = true;
Request storyRequest = new Request("HierarchicalRequirement");
storyRequest.Workspace = workspaceRef;
storyRequest.Project = projectRef;
storyRequest.ProjectScopeUp = projectScopingUp;
storyRequest.ProjectScopeDown = projectScopingDown;
storyRequest.Fetch = new List<string>()
{
"Name",
"FormattedID",
"Tasks",
"Estimate"
};
storyRequest.Query = new Query("LastUpdateDate", Query.Operator.GreaterThan, "2013-08-01");
QueryResult queryStoryResults = restApi.Query(storyRequest);
foreach (var s in queryStoryResults.Results)
{
Console.WriteLine("----------");
Console.WriteLine("FormattedID: " + s["FormattedID"] + " Name: " + s["Name"]);
//Console.WriteLine("Tasks ref: " + s["Tasks"]._ref);
Request taskRequest = new Request(s["Tasks"]);
QueryResult queryTaskResult = restApi.Query(taskRequest);
if (queryTaskResult.TotalResultCount > 0)
{
foreach (var t in queryTaskResult.Results)
{
var taskEstimate = t["Estimate"];
var taskName = t["Name"];
Console.WriteLine("Task Name: " + taskName + " Estimate: " + taskEstimate);
}
}
else
{
Console.WriteLine("no tasks found");
}
}
}
}
}

Using C#, how do I set a Rally weblink field?

Here's a screenshot of the field I'm trying to update:
How do I update the URL field?
WebLink type fields consist of two parts: LinkID and DisplayString. In order to set a LinkID (which corresponds to the variable ${id} in your screenshot, a DisplayString needs also to be set to an empty string.
Here is a full code example that uses Rally .NET REST toolkit:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using Rally.RestApi;
using Rally.RestApi.Response;
namespace aRestApp_CollectionOfTasks
{
class Program
{
static void Main(string[] args)
{
//Initialize the REST API
RallyRestApi restApi;
restApi = new RallyRestApi("user#co.com", "secret", "https://rally1.rallydev.com", "v2.0");
//Set our Workspace and Project scopings
String workspaceRef = "/workspace/1111"; //please replace this OID with an OID of your workspace
String projectRef = "/project/2222"; //please replace this OID with an OID of your project
bool projectScopingUp = false;
bool projectScopingDown = true;
Request storyRequest = new Request("Defect");
storyRequest.Workspace = workspaceRef;
storyRequest.Project = projectRef;
storyRequest.ProjectScopeUp = projectScopingUp;
storyRequest.ProjectScopeDown = projectScopingDown;
storyRequest.Fetch = new List<string>()
{
"Name",
"_ref",
"c_JiraLink"
};
storyRequest.Query = new Query("FormattedID", Query.Operator.Equals, "DE170");
QueryResult queryStoryResults = restApi.Query(storyRequest);
foreach (var s in queryStoryResults.Results)
{
Console.WriteLine(" Name: " + s["Name"] + " JiraLink's DisplayString: " + s["c_JiraLink"]["DisplayString"] + " JiraLink's LinkID: " + s["c_JiraLink"]["LinkID"]);
DynamicJsonObject toUpdate = new DynamicJsonObject();
DynamicJsonObject myLink = new DynamicJsonObject();
myLink["LinkID"] = "NM-3";
myLink["DisplayString"] = "";
toUpdate["c_JiraLink"] = myLink;
OperationResult updateResult = restApi.Update(s["_ref"], toUpdate);
}
}
}
}
Note that this is not different from a more general example of setting LinkID of a WebLink type of filed using a browser's REST client.
Method: POST
URL:
https://rally1.rallydev.com/slm/webservice/v2.0/defect/3807704995?key=abc123...
Request Body:
{
"defect":
{
"c_JiraLink":{
"DisplayString":"",
"LinkID":"NM-2"
}
}
}

Categories

Resources