本文整理汇总了C#中Google.GData.Client.Service.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# Service.Insert方法的具体用法?C# Service.Insert怎么用?C# Service.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google.GData.Client.Service
的用法示例。
在下文中一共展示了Service.Insert方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostNewEntry
/** Creates a new blog entry and sends it to the specified Uri */
static AtomEntry PostNewEntry(Service service, Uri blogPostUri)
{
Console.WriteLine("\nPublishing a blog post");
AtomEntry createdEntry = null;
if (blogPostUri != null)
{
// construct the new entry
AtomEntry newPost = new AtomEntry();
newPost.Title.Text = "Marriage!";
newPost.Content = new AtomContent();
newPost.Content.Content = "<div xmlns='http://www.w3.org/1999/xhtml'>" +
"<p>Mr. Darcy has <em>proposed marriage</em> to me!</p>" +
"<p>He is the last man on earth I would ever desire to marry.</p>" +
"<p>Whatever shall I do?</p>" +
"</div>";
newPost.Content.Type = "xhtml";
newPost.Authors.Add(new AtomPerson());
newPost.Authors[0].Name = "Elizabeth Bennet";
newPost.Authors[0].Email = "[email protected]";
createdEntry = service.Insert(blogPostUri, newPost);
if (createdEntry != null)
{
Console.WriteLine(" New blog post created with title: " + createdEntry.Title.Text);
}
}
return createdEntry;
}
示例2: PublishNewEntry
public void PublishNewEntry(BlogDescriptor blogDescriptor, String title, String content)
{
if (blogDescriptor == null)
throw new ArgumentNullException("blogDescriptor");
if (String.IsNullOrEmpty(blogDescriptor.Username))
throw new ArgumentException("blogDescriptor.Username cannot be null or an empty string.");
var entry = new gClient.AtomEntry();
entry.Content.Content = content;
entry.Content.Type = "html";
entry.Title.Text = title;
var service = new gClient.Service("blogger", GoogleSucks.GetApplicationName());
service.Credentials = new gClient.GDataCredentials(blogDescriptor.Username, blogDescriptor.Password);
service.Insert(new Uri(GetFeedUri(blogDescriptor)), entry);
}
示例3: button1_Click
private void button1_Click(object sender, EventArgs e)
{
Service service = new Service("cl", "companyName-appName-1");
service.setUserCredentials("[email protected]", "jWH>45bY1");
EventEntry entry = new EventEntry();
DataSet ds = new DataSet();
When eventTimes = new When();
AtomEntry insertedEntry;
SqlConnection cn = new SqlConnection();
try
{
cn = DBDevite.DBOpen();
SqlDataAdapter da = new SqlDataAdapter("SELECT u.Users as userw, c.Name as client, t.Date as date, t.TimeStart as start, t.TimeEnd as endw, t.About as about, t.TaskStatus " +
"FROM tasks t " +
"LEFT JOIN users u ON t.userID = u.ID " +
"LEFT JOIN clients c ON t.clientID = c.ID " +
"WHERE t.TaskStatus = 'true'", cn);
SqlCommandBuilder cb = new SqlCommandBuilder(da);
da.Fill(ds);
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
DBDevite.DBClose(cn);
}
Uri postUri = new Uri("http://www.google.com/calendar/feeds/[email protected]/private/full");
//запись в EventEntry
foreach(DataTable thisTable in ds.Tables)
{
foreach(DataRow row in thisTable.Rows)
{
entry.Title.Text = row["client"].ToString() + " " + row["userw"].ToString();
entry.Content.Content = row["about"].ToString();
eventTimes.StartTime = Convert.ToDateTime(Convert.ToDateTime(row["date"].ToString()).ToString("dd-MM-yyyy") + " " + row["start"].ToString().Trim() + ":00");
eventTimes.EndTime = Convert.ToDateTime(Convert.ToDateTime(row["date"].ToString()).ToString("dd-MM-yyyy") + " " + row["endw"].ToString().Trim() + ":00");
entry.Times.Add(eventTimes);
insertedEntry = service.Insert(postUri, entry);
}
}
}
示例4: PostNewEntry
/// <summary>
/// Creates a new blog entry and sends it to the specified Uri
/// </summary>
/// <param name="service"></param>
/// <param name="blogPostUri"></param>
/// <returns></returns>
private AtomEntry PostNewEntry(Service service, Uri blogPostUri, string Title, string Body)
{
AtomEntry createdEntry = null;
if (blogPostUri != null)
{
// construct the new entry
AtomEntry newPost = new AtomEntry();
newPost.Title.Text = Title;
newPost.Content = new AtomContent();
newPost.Content.Content = Body;
newPost.Content.Type = "xhtml";
newPost.Authors.Add(new AtomPerson());
newPost.Authors[0].Name = string.Empty;
newPost.Authors[0].Email = string.Empty;
createdEntry = service.Insert(blogPostUri, newPost);
}
return createdEntry;
}
示例5: PostAndDeleteNewDraftEntry
/** Creates a new blog entry and sends it to the specified Uri */
static void PostAndDeleteNewDraftEntry(Service service, Uri blogPostUri)
{
Console.WriteLine("\nCreating a draft blog post");
AtomEntry draftEntry = null;
if (blogPostUri != null)
{
// construct the new entry
AtomEntry newPost = new AtomEntry();
newPost.Title.Text = "Marriage! (Draft)";
newPost.Content = new AtomContent();
newPost.Content.Content = "<div xmlns='http://www.w3.org/1999/xhtml'>" +
"<p>Mr. Darcy has <em>proposed marriage</em> to me!</p>" +
"<p>He is the last man on earth I would ever desire to marry.</p>" +
"<p>Whatever shall I do?</p>" +
"</div>";
newPost.Content.Type = "xhtml";
newPost.Authors.Add(new AtomPerson());
newPost.Authors[0].Name = "Elizabeth Bennet";
newPost.Authors[0].Email = "[email protected]";
newPost.IsDraft = true;
draftEntry = service.Insert(blogPostUri, newPost);
if (draftEntry != null)
{
Console.WriteLine(" New draft post created with title: " + draftEntry.Title.Text);
// Delete the newly created draft entry
Console.WriteLine(" Press enter to delete the draft blog post");
Console.ReadLine();
draftEntry.Delete();
}
}
}
示例6: PostNewComment
static AtomEntry PostNewComment(Service service, Uri commentPostUri)
{
Console.WriteLine("\nCommenting on a blog post");
AtomEntry postedComment = null;
if (commentPostUri != null)
{
// Add a comment.
AtomEntry comment;
comment = new AtomEntry();
comment.Title.Text = "This is my first comment";
comment.Content.Content = "This is my first comment";
comment.Authors.Add(new AtomPerson());
comment.Authors[0].Name = "Blog Author Name";
postedComment = service.Insert(commentPostUri, comment);
Console.WriteLine(" Result's title: " + postedComment.Title.Text);
}
return postedComment;
}
示例7: PostNewEntry
/* Creates a new blog entry and sends it to the specified Uri */
static AtomEntry PostNewEntry(Service service, Uri blogPostUri, BlogPost bP)
{
Console.WriteLine("\nPublishing a blog post");
AtomEntry createdEntry = null;
if (blogPostUri != null)
{
// Construct the new entry
AtomEntry newPost = new AtomEntry();
newPost.Title.Text = bP.postTitle;
newPost.Content = new AtomContent();
newPost.Content.Type = "html";
newPost.Authors.Add(new AtomPerson());
newPost.Authors[0].Name = bP.postAuthor;
//newPost.Authors[0].Email = "";
string fc = "";
if (bP.outFile.Length > 0)
{
if (File.Exists(bP.codeFile))
{
// Parse the code file
fc = File.ReadAllText(bP.codeFile);
fc = fc.Replace("<", "<");
fc = fc.Replace(">", ">");
// Append the code to the post
newPost.Content.Content = "<script src=\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\"></script>" +
"<h2>Code</h2>" + "<pre class=\"prettyprint\">" + fc + "</pre>";
}
else
{
Console.WriteLine("\nCode file does not exist.\n");
}
}
if (bP.outFile.Length > 0)
{
if (File.Exists(bP.outFile))
{
// Parse the output file
fc = File.ReadAllText(bP.outFile);
fc = fc.Replace("<", "<");
fc = fc.Replace(">", ">");
// Append the code output to the post
newPost.Content.Content += "<h2>Output</h2>" + fc;
} else {
Console.WriteLine("\nOutput file does not exist.\n");
}
}
createdEntry = service.Insert(blogPostUri, newPost);
if (createdEntry != null)
{
Console.WriteLine(" New blog post created with title: " + createdEntry.Title.Text);
}
}
return createdEntry;
}
示例8: AddEntry_Click
private void AddEntry_Click(object sender, System.EventArgs e)
{
addentry dlg = new addentry();
if (dlg.ShowDialog() == DialogResult.OK &&
dlg.Entry.Length > 0)
{
// now add this to the feed.
AtomEntry entry = new AtomEntry();
entry.Content.Content = dlg.Entry;
entry.Content.Type = "html";
entry.Title.Text = dlg.EntryTitle;
string userName = this.UserName.Text;
string passWord = this.Password.Text;
FeedQuery query = new FeedQuery();
Service service = new Service("blogger", "BloggerSampleApp");
if (userName != null && userName.Length > 0)
{
service.Credentials = new GDataCredentials(userName, passWord);
}
service.Insert(new Uri(this.feedUri), entry);
RefreshFeed(this.feedUri);
}
}
示例9: Index
public void Index()
{
var g = new Service("local", "application");//, "ABQIAAAACPMbozlNv9AIzNvsWUm6vhSvnLMDprvOSMH9Qt_oH5Ww7FTw1hRHT7gTSie1yM34rowNwVfw424XPA");
Assert.Fail("Need to put password here");
g.setUserCredentials("[email protected]", "zzz");
var entry = new AtomEntry();
entry.Content.ExtensionFactories.Add(new MapsExtension());
entry.Title.Text = "test";
entry.Content.Type = "application/vnd.google-earth.kml+xml";
XmlDocument doc = new XmlDocument();
doc.LoadXml(@"<Placemark xmlns='http://www.opengis.net/kml/2.2'>
<name>Faulkner's Birthplace</name>
<description/>
<Point>
<coordinates>-89.520753,34.360902,0.0</coordinates>
</Point>
</Placemark>");
entry.Content.ExtensionElements.Add(new XmlExtension((XmlNode)doc.DocumentElement));
// doc.LoadXml(@"@"<m:Placemark>
// <m:name>Faulkner's Birthplace</m:name>
// <m:description/>
// <m:Point>
// <m:coordinates>-89.520753,34.360902,0.0</m:coordinates>
// </m:Point>
//</m:Placemark>";
//entry.Content.Content = ;
//entry.AddExtension(new MapsExtension());
var m = new MemoryStream();
//var mapStuff = entry.Content.CreateExtension("PlaceMark", "http://www.opengis.net/kml/2.2");
// entry.Update();
try
{
entry.SaveToXml(m);
}
catch (Exception e)
{
var s = e.ToString();
throw;
}
m.Position = 0;
var mm = new StreamReader(m).ReadToEnd();
var q = g.Insert(new Uri("http://maps.google.com/maps/feeds/features/208433541473729117510/0004779109f86bbabd62d/full"), entry);
var p = g.Query(new Uri("http://maps.google.com/maps/feeds/maps/default/full"));
var z = new StreamReader(p).ReadToEnd();
//// Arrange
//HomeController controller = new HomeController();
//// Act
//ViewResult result = controller.Index() as ViewResult;
//// Assert
//ViewDataDictionary viewData = result.ViewData;
//Assert.AreEqual("Welcome to ASP.NET MVC!", viewData["Message"]);
}
示例10: ImportAllContacts
private static void ImportAllContacts(String username, String password)
{
Service service = new Service("cp", "exampleCo-exampleApp-1");
// Set your credentials:
service.setUserCredentials(username, password);
service.ProtocolMajor = 3;
service.ProtocolMinor = 0;
//ContactsRequest cr = new ContactsRequest();
OleDbConnection cn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\Administrator\\My Documents\\BlackBerry\\Backup;Extended Properties=\"text;HDR=Yes;FMT=Delimited\";");
cn.Open();
OleDbCommand cmd = cn.CreateCommand();
cmd.CommandText = "select * from [MB_Export_02205018.csv]";
using (var rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
if (rdr[0].ToString() == "")
continue;
ContactEntry entry = new ContactEntry();
entry.Name = new Google.GData.Extensions.Name { FullName = rdr["Name"].ToString(), GivenName = rdr["First Name"].ToString(), FamilyName = rdr["Last Name"].ToString() };
entry.GroupMembership.Add(new GroupMembership { HRef = "https://www.google.com/m8/feeds/groups/" + username + "/base/6" });
if (rdr["Company"].ToString() != "")
entry.Organizations.Add(new Organization { Name = rdr["Company"].ToString(), Title = rdr["Job"].ToString(), Rel = "http://schemas.google.com/g/2005#work" });
if (rdr["Email"].ToString() != "")
entry.Emails.Add(new Google.GData.Extensions.EMail { Label = "Home", Address = rdr["Email"].ToString() });
if (rdr["Mobile"].ToString() != "")
entry.Phonenumbers.Add(new PhoneNumber { Label = "Mobile", Value = rdr["Mobile"].ToString() });
if (rdr["Work Phone 1"].ToString() != "")
entry.Phonenumbers.Add(new PhoneNumber { Label = "Work", Value = rdr["Work Phone 1"].ToString() });
if (rdr["Work Phone 2"].ToString() != "")
entry.Phonenumbers.Add(new PhoneNumber { Label = "Work 2", Value = rdr["Work Phone 2"].ToString() });
if (rdr["Home Phone 1"].ToString() != "")
entry.Phonenumbers.Add(new PhoneNumber { Label = "Home", Value = rdr["Home Phone 1"].ToString() });
if (rdr["Home Address 1"].ToString() != "")
{
entry.PostalAddresses.Add(new StructuredPostalAddress
{
Label = "Home",
Street = rdr["Home Address 1"].ToString(),
City = rdr["Home City"].ToString(),
Region = rdr["Home State"].ToString(),
Postcode = rdr["Home ZIP"].ToString()
});
}
if (rdr["Work Address 1"].ToString() != "")
{
entry.PostalAddresses.Add(new StructuredPostalAddress
{
Label = "Work",
Street = rdr["Work Address 1"].ToString(),
City = rdr["Work City"].ToString(),
Region = rdr["Work State"].ToString(),
Postcode = rdr["Work ZIP"].ToString()
});
}
if (rdr["Birthday"].ToString() != "")
{
DateTime bd;
if (DateTime.TryParse(rdr["Birthday"].ToString(), out bd))
{
entry.Birthday = bd.ToString("yyyy-MM-dd");
}
}
Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));
AtomEntry insertedEntry = service.Insert(feedUri, entry);
}
}
}