public void CreateTemplate() { DocumentsService service = new DocumentsService(applicationName); DocumentEntry entry = new DocumentEntry(); // Set the document title entry.Title.Text = spreadsheetName; entry.IsSpreadsheet = true; // Set the media source entry.MediaSource = new MediaFileSource(GetStreamWithTemplate(), applicationName, "text/csv"); // Define the resumable upload link Uri createUploadUrl = new Uri("https://docs.google.com/feeds/upload/create-session/default/private/full"); AtomLink link = new AtomLink(createUploadUrl.AbsoluteUri); link.Rel = ResumableUploader.CreateMediaRelation; entry.Links.Add(link); // Set the service to be used to parse the returned entry entry.Service = service; // Instantiate the ResumableUploader component. ResumableUploader uploader = new ResumableUploader(); // Start the upload process uploader.Insert(new ClientLoginAuthenticator(applicationName,ServiceNames.Documents,userName,password), entry); }
public SpreadSheet() { service = new SpreadsheetsService("stock-market"); service.setUserCredentials("shurai", "$gva99void!"); SpreadsheetQuery query = new SpreadsheetQuery(); SpreadsheetFeed feed = service.Query(query); SpreadsheetEntry ssentry = (SpreadsheetEntry)feed.Entries[0]; AtomLink sslink = ssentry.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null); WorksheetQuery wkquery = new WorksheetQuery(sslink.HRef.ToString()); WorksheetFeed wkfeed = service.Query(wkquery); WorksheetEntry wkentry = (WorksheetEntry)wkfeed.Entries[0]; listFeedLink = wkentry.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null); listQuery = new ListQuery(listFeedLink.HRef.ToString()); listFeed = service.Query(listQuery); Console.WriteLine("Worksheet has {0} rows: ", listFeed.Entries.Count); foreach (ListEntry worksheetRow in listFeed.Entries) { ListEntry.CustomElementCollection elements = worksheetRow.Elements; foreach (ListEntry.Custom element in elements) { Console.Write(element.Value + "\t"); } Console.WriteLine(); } }
public async Task UploadToYouTube(HttpPostedFile postedFile, string title) { UploadingDispatcher.SetProgress(uploadId, 2); Video video = new Video(); video.Title = title; video.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema)); video.Private = false; video.MediaSource = new MediaFileSource(postedFile.InputStream, postedFile.FileName, postedFile.ContentType); var link = new AtomLink("http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads"); link.Rel = ResumableUploader.CreateMediaRelation; video.YouTubeEntry.Links.Add(link); var youtubeApiKey = ConfigurationManager.AppSettings["youtubeApiKey"]; var applicationName = ConfigurationManager.AppSettings["applicationName"]; var youtubeUserName = ConfigurationManager.AppSettings["youtubeUserName"]; var youtubePassword = ConfigurationManager.AppSettings["youtubePassword"]; var youtubeChunksize = int.Parse(ConfigurationManager.AppSettings["youtubeChunksize"]); var resumableUploader = new ResumableUploader(youtubeChunksize); resumableUploader.AsyncOperationCompleted += resumableUploader_AsyncOperationCompleted; resumableUploader.AsyncOperationProgress += resumableUploader_AsyncOperationProgress; var youTubeAuthenticator = new ClientLoginAuthenticator(applicationName, ServiceNames.YouTube, youtubeUserName, youtubePassword); youTubeAuthenticator.DeveloperKey = youtubeApiKey; resumableUploader.InsertAsync(youTubeAuthenticator, video.YouTubeEntry, uploadId); }
/// <summary> /// Adds a reply link to this commententry /// -> this new entry will reply to the passed in entry when the comment is /// submitted. This will not protect from adding the same guy several times. /// </summary> /// <param name="theOriginalComment"></param> /// <returns></returns> public void ReplyTo(CommentEntry theOriginalComment) { if (theOriginalComment.SelfUri == null) { throw new ArgumentException("You can only reply to an entry with a valid SelfUri"); } AtomLink link = new AtomLink(AtomLink.ATOM_TYPE, YouTubeNameTable.ReplyToRelationship); link.HRef = theOriginalComment.SelfUri; this.Links.Add(link); }
public void TypeTest() { AtomLink target = new AtomLink(); // TODO: Initialize to an appropriate value string expected = "TestValue"; string actual; target.Type = expected; actual = target.Type; Assert.AreEqual(expected, actual); }
public static void CreateGoogleNote(/*Document parentFolder, */Document googleNote, object UserData, DocumentsRequest documentsRequest, ResumableUploader uploader, OAuth2Authenticator authenticator) { // Define the resumable upload link Uri createUploadUrl = new Uri("https://docs.google.com/feeds/upload/create-session/default/private/full"); //Uri createUploadUrl = new Uri(GoogleNotesFolder.AtomEntry.EditUri.ToString()); AtomLink link = new AtomLink(createUploadUrl.AbsoluteUri); link.Rel = ResumableUploader.CreateMediaRelation; googleNote.DocumentEntry.Links.Add(link); //if (parentFolder != null) // googleNote.DocumentEntry.ParentFolders.Add(new AtomLink(parentFolder.DocumentEntry.SelfUri.ToString())); // Set the service to be used to parse the returned entry googleNote.DocumentEntry.Service = documentsRequest.Service; // Start the upload process //uploader.InsertAsync(_authenticator, match.GoogleNote.DocumentEntry, new object()); uploader.InsertAsync(authenticator, googleNote.DocumentEntry, UserData); }
/// <summary>standard typed accessor method </summary> public bool Contains( AtomLink value ) { // If value is not of type AtomLink, this will return false. return( List.Contains( value ) ); }
/// <summary>standard typed accessor method </summary> public void Remove( AtomLink value ) { List.Remove( value ); }
/// <summary>standard typed accessor method </summary> public void Insert( int index, AtomLink value ) { List.Insert( index, value ); }
public void HRefTest() { AtomLink target = new AtomLink(); // TODO: Initialize to an appropriate value AtomUri expected = new AtomUri("http://www.test.com/"); AtomUri actual; target.HRef = expected; actual = target.HRef; Assert.AreEqual(expected, actual); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>compares 2 link objects</summary> /// <param name="theOne">the One link</param> /// <param name="theOther">the Other link</param> /// <returns>true if identical </returns> ////////////////////////////////////////////////////////////////////// public static bool IsLinkIdentical(AtomLink theOne, AtomLink theOther) { if (theOne == null && theOther == null) { return true; } if (ObjectModelHelper.IsBaseIdentical(theOne, theOther)==false) { return false; } if (AtomUri.Compare(theOne.HRef, theOther.HRef)!=0) { return false; } if (theOne.Length != theOther.Length) { return false; } if (String.Compare(theOne.Rel, theOther.Rel)!= 0) { return false; } if (String.Compare(theOne.Type, theOther.Type)!= 0) { return false; } if (String.Compare(theOne.HRefLang, theOther.HRefLang)!= 0) { return false; } if (String.Compare(theOne.Title, theOther.Title)!= 0) { return false; } return true; }
private Link mapLink(AtomLink link) { Link linkObj = new Link(); linkObj.Rel = link.Rel; linkObj.Title = link.Title; linkObj.Type = link.Type; linkObj.Uri = link.AbsoluteUri; return linkObj; }
void DrawCreateWorkbookGUI() { EditorGUILayout.BeginHorizontal(); DrawHelpButtonGUI("ID_HELP_UPLOAD_WORKBOOK"); DrawLabelHeader("ID_CREATE_WORKBOOK"); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); Indent(1); GUI.backgroundColor = Color.clear; GUI.color = Color.yellow; bool bDoSave = false; GUI.SetNextControlName("Clear"); if (GUILayout.Button(_BrowseButton, EditorStyles.toolbarButton, GUILayout.Width(24))) { ClearMessages(); string workbookpath = EditorUtility.OpenFilePanel( Localize("ID_SELECT_UPLOAD_WORKBOOK_PATH"), EditorApplication.applicationPath, "*.xls;*.xlsx;*.ods;*.csv;*.txt;*.tsv"); if (!string.IsNullOrEmpty(workbookpath)) { if ((workbookpath.IndexOf(".xls", System.StringComparison.InvariantCultureIgnoreCase) != -1) || (workbookpath.IndexOf(".xlsx", System.StringComparison.InvariantCultureIgnoreCase) != -1) || (workbookpath.IndexOf(".ods", System.StringComparison.InvariantCultureIgnoreCase) != -1) || (workbookpath.IndexOf(".csv", System.StringComparison.InvariantCultureIgnoreCase) != -1) || (workbookpath.IndexOf(".txt", System.StringComparison.InvariantCultureIgnoreCase) != -1) || (workbookpath.IndexOf(".tsv", System.StringComparison.InvariantCultureIgnoreCase) != -1)) { bDoSave = true; } if (bDoSave) { _WorkbookUploadPath = workbookpath; GUI.FocusControl("Clear"); Repaint(); } else { _EditorWarning = Localize("ID_ERROR_UPLOAD_WORKBOOK_PATH"); Debug.LogWarning(_EditorWarning); } } } GUI.backgroundColor = _DefaultBgColor; GUI.color = _DefaultFgColor; EditorGUILayout.TextField(_WorkbookUploadPath); GUILayout.Label(System.String.Empty, GUILayout.Width(5)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(System.String.Empty); if (CreatingWorkbook) GUI.enabled = false; if (GUILayout.Button(Localize("ID_CREATE"), EditorStyles.miniButton, GUILayout.Width(65))) { ClearMessages(); // We need a DocumentService var service = new Google.GData.Documents.DocumentsService("GoogleFuUploader"); string mimeType = GoogleFuMimeType.GetMimeType(_WorkbookUploadPath); var authenticator = new Google.GData.Client.ClientLoginAuthenticator("UnityGoogleFu", Google.GData.Client.ServiceNames.Documents, _Username, _Password); //service.setUserCredentials(_username, _password); // Instantiate a DocumentEntry object to be inserted. var entry = new Google.GData.Documents.DocumentEntry(); CreatingWorkbook = true; entry.MediaSource = new Google.GData.Client.MediaFileSource(_WorkbookUploadPath, mimeType); // Define the resumable upload link var createUploadUrl = new System.Uri("https://docs.google.com/feeds/upload/create-session/default/private/full"); var link = new Google.GData.Client.AtomLink(createUploadUrl.AbsoluteUri) { Rel = Google.GData.Client.ResumableUpload.ResumableUploader.CreateMediaRelation }; entry.Links.Add(link); // Set the service to be used to parse the returned entry entry.Service = service; // Instantiate the ResumableUploader component. var uploader = new Google.GData.Client.ResumableUpload.ResumableUploader(); // Set the handlers for the completion and progress events uploader.AsyncOperationCompleted += OnSpreadsheetUploadDone; uploader.AsyncOperationProgress += OnSpreadsheetUploadProgress; // Start the upload process uploader.InsertAsync(authenticator, entry, new object()); _EditorInfo = Localize("ID_CREATING_DATABASE_MESSAGE"); //Repaint(); } GUI.enabled = true; GUILayout.Label(System.String.Empty, GUILayout.Width(5)); EditorGUILayout.EndHorizontal(); }
public void AtomLinkConstructorTest() { string type = "TestValue"; // TODO: Initialize to an appropriate value string rel = "TestValue"; // TODO: Initialize to an appropriate value AtomLink target = new AtomLink(type, rel); Assert.AreEqual(target.Type, type); Assert.AreEqual(target.Rel, rel); }
public void XmlNameTest() { AtomLink target = new AtomLink(); // TODO: Initialize to an appropriate value Assert.AreEqual(target.XmlName, AtomParserNameTable.XmlLinkElement); }
public void AtomLinkConstructorTest1() { string link = "http://www.test.com/"; AtomLink target = new AtomLink(link); Assert.AreEqual(target.AbsoluteUri, link); }
public void AtomLinkConstructorTest2() { AtomLink target = new AtomLink(); Assert.IsNotNull(target); Assert.IsNull(target.AbsoluteUri); }
public void AbsoluteUriTest() { AtomLink target = new AtomLink(); // TODO: Initialize to an appropriate value AtomUri expected = new AtomUri("http://www.test.com/"); target.HRef = expected; Assert.AreEqual(target.AbsoluteUri, "http://www.test.com/"); }
/// <summary>creates an atomlink object</summary> /// <param name="reader">correctly positioned xmlreader</param> /// <param name="owner">the object containing the person</param> /// <returns> the created AtomLink object</returns> protected AtomLink ParseLink(XmlReader reader, AtomBase owner) { Tracing.Assert(reader != null, "reader should not be null"); if (reader == null) { throw new ArgumentNullException("reader"); } if (owner == null) { throw new ArgumentNullException("owner"); } bool noChildren = reader.IsEmptyElement; Tracing.TraceCall(); AtomLink link = owner.CreateAtomSubElement(reader, this) as AtomLink; object localname = null; if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { localname = reader.LocalName; if (localname.Equals(this.nameTable.HRef)) { link.HRef = new AtomUri(reader.Value); } else if (localname.Equals(this.nameTable.Rel)) { link.Rel = Utilities.DecodedValue(reader.Value); } else if (localname.Equals(this.nameTable.Type)) { link.Type = Utilities.DecodedValue(reader.Value); } else if (localname.Equals(this.nameTable.HRefLang)) { link.HRefLang = Utilities.DecodedValue(reader.Value); } else if (localname.Equals(this.nameTable.Title)) { link.Title = Utilities.DecodedValue(reader.Value); } else if (localname.Equals(this.nameTable.Length)) { link.Length = int.Parse(Utilities.DecodedValue(reader.Value), CultureInfo.InvariantCulture); } else { ParseBaseAttributes(reader, link); } } } if (!noChildren) { reader.MoveToElement(); int lvl = -1; while (NextChildElement(reader, ref lvl)) { ParseExtensionElements(reader, link); } } return(link); }
public AtomEntry updloadAttachment(String filename, String contentType, AtomEntry parent, String title, String description) { SiteEntry entry = new SiteEntry(); AtomCategory category = new AtomCategory(SitesService.ATTACHMENT_TERM, SitesService.KIND_SCHEME); category.Label = "attachment"; entry.Categories.Add(category); AtomLink parentLink = new AtomLink(AtomLink.ATOM_TYPE, SitesService.PARENT_REL); parentLink.HRef = parent.SelfUri; entry.Links.Add(parentLink); entry.MediaSource = new MediaFileSource(filename, contentType); entry.Content.Type = contentType; if (title == "") { entry.Title.Text = entry.MediaSource.Name; } else { entry.Title.Text = title; } entry.Summary.Text = description; AtomEntry newEntry = null; try { newEntry = service.Insert(new Uri(makeFeedUri("content")), entry); } catch (GDataRequestException e) { Console.WriteLine(e.ResponseString); } return newEntry; }
/// <summary> /// insert a new video. /// </summary> /// <param name="row"></param> /// <param name="retryCounter"></param> /// <returns></returns> private bool InsertVideo(DataGridViewRow row, int retryCounter) { Trace.TraceInformation("Entering InsertVideo: starting a new upload"); Video v = new Video(); v.Title = row.Cells[0].Value.ToString(); v.Description = row.Cells[1].Value.ToString(); v.Keywords = row.Cells[2].Value.ToString(); v.Tags.Add(new MediaCategory(row.Cells[3].Value.ToString())); v.Private = row.Cells[4].Value.ToString().ToLower() == "true"; string contentType = MediaFileSource.GetContentTypeForFileName(row.Cells[COLUMNINDEX_FILENAME].Value.ToString()); v.MediaSource = new MediaFileSource(row.Cells[COLUMNINDEX_FILENAME].Value.ToString(), contentType); // add the upload uri to it AtomLink link = new AtomLink("http://uploads.gdata.youtube.com/resumable/feeds/api/users/" + this.youtubeAccount + "/uploads"); link.Rel = ResumableUploader.CreateMediaRelation; v.YouTubeEntry.Links.Add(link); UserState u = new UserState(row); u.RetryCounter = retryCounter; lock (this.flag) { this.queue.Add(u); } ru.InsertAsync(this.youTubeAuthenticator, v.YouTubeEntry, u); row.Cells[COLUMNINDEX_STATUS].Value = "Queued up..."; row.Cells[COLUMNINDEX_STATUS].Tag = u; return true; }
/// <summary>standard typed accessor method </summary> public int Add( AtomLink value ) { // Remove link with same relation to avoid duplication. AtomLink oldLink = FindService(value.Rel, value.Type); if (oldLink != null) { List.Remove(oldLink); } return( List.Add( value ) ); }
private static void RunSample(string username, string password, string accountId) { // Connect to the service ContentForShoppingService service = new ContentForShoppingService("ContentForShopping-Sample"); service.setUserCredentials(username, password); // Retrieve the list of all existing products string projection = "schema"; ProductQuery query = new ProductQuery(projection, accountId); ProductFeed feed = service.Query(query); // Display title and id for each product Console.WriteLine("Listing all products"); foreach (ProductEntry p in feed.Entries) { Console.WriteLine("Product: " + p.Title.Text + " (" + p.ProductId + ")"); } // Create a new product ProductEntry entry = new ProductEntry(); entry.Title.Text = "Wool sweater"; AtomContent c = new AtomContent(); c.Content = "Comfortable and soft, this sweater will keep you warm on those cold winter nights. Red and blue stripes."; entry.Content = c; entry.ProductId = "123457"; entry.Language = "it"; entry.TargetCountry = "US"; entry.ContentLanguage = "en"; entry.Brand = "ACME"; entry.Condition = "new"; entry.Price = new Price("usd", "25"); entry.ProductType = "Clothing & Accessories > Clothing > Outerwear > Sweaters"; entry.Quantity = 3; entry.ShippingWeight = new ShippingWeight("lb", "0.1"); entry.ImageLink = new ImageLink("http://www.example.com/image.jpg"); entry.Availability = "available for order"; entry.Channel = "online"; entry.Gender = "female"; entry.Material = "wool"; entry.Pattern = "Red and blue stripes"; entry.Color = "red"; AtomLink link = new AtomLink(); link.HRef = "http://www.example.com"; link.Rel = "alternate"; link.Type = "text/html"; entry.Links.Add(link); // Shipping rules Shipping s1 = new Shipping(); s1.Country = "US"; s1.Region = "MA"; s1.Service = "Speedy Shipping - Ground"; s1.Price = new ShippingPrice("usd", "5.95"); Shipping s2 = new Shipping(); s2.Country = "US"; s2.Region = "024*"; s2.Service = "Speedy Shipping - Air"; s2.Price = new ShippingPrice("usd", "7.95"); entry.ShippingRules.Add(s1); entry.ShippingRules.Add(s2); // Tax rules Tax t1 = new Tax(); t1.Country = "US"; t1.Region = "CA"; t1.Rate = "8.25"; t1.Ship = true; Tax t2 = new Tax(); t2.Country = "US"; t2.Region = "926*"; t2.Rate = "8.75"; t2.Ship = false; entry.TaxRules.Add(t1); entry.TaxRules.Add(t2); // Additional Image Links AdditionalImageLink il1 = new AdditionalImageLink("http://www.example.com/1.jpg"); entry.AdditionalImageLinks.Add(il1); AdditionalImageLink il2 = new AdditionalImageLink("http://www.example.com/2.jpg"); entry.AdditionalImageLinks.Add(il2); // Add the product to the server feed Console.WriteLine("Inserting product"); ProductEntry inserted = service.Insert(feed, entry); // Update the product we just inserted inserted.Title.Text = "2011 Wool sweater"; Console.WriteLine("Updating product"); ProductEntry updated = service.Update(inserted); // Retrieve the new list of products feed = service.Query(query); // Display title and id for each product Console.WriteLine("Listing all products again"); foreach (ProductEntry p in feed.Entries) { Console.WriteLine("Product: " + p.Title.Text + " (" + p.ProductId + ")"); } // Delete the item we inserted and updated Console.WriteLine("Deleting product"); service.Delete(updated); }
/// <summary>standard typed accessor method </summary> public int IndexOf( AtomLink value ) { return( List.IndexOf( value ) ); }
public void DoWorkbookUpload(object in_instance) { var instance = in_instance as Google2uData; if (instance == null) return; if (!string.IsNullOrEmpty(instance.WorkbookUploadPath)) { try { // We need a DocumentService var service = new DocumentsService("Google2Unity"); var mimeType = Google2uMimeType.GetMimeType(instance.WorkbookUploadPath); var authenticator = new OAuth2Authenticator("Google2Unity", _authParameters); // Instantiate a DocumentEntry object to be inserted. var entry = new DocumentEntry { MediaSource = new MediaFileSource(instance.WorkbookUploadPath, mimeType) }; // Define the resumable upload link var createUploadUrl = new Uri("https://docs.google.com/feeds/upload/create-session/default/private/full"); var link = new AtomLink(createUploadUrl.AbsoluteUri) { Rel = ResumableUploader.CreateMediaRelation }; entry.Links.Add(link); // Set the service to be used to parse the returned entry entry.Service = service; // Instantiate the ResumableUploader component. var uploader = new ResumableUploader(); // Set the handlers for the completion and progress events uploader.AsyncOperationCompleted += OnSpreadsheetUploadDone; uploader.AsyncOperationProgress += OnSpreadsheetUploadProgress; // Start the upload process uploader.InsertAsync(authenticator, entry, instance); } catch (Exception) { PushNotification( "There is a problem with your credentials. Clear the credentials and Re-Authorize G2U"); //instance.Messages.Add(new G2GUIMessage(GFGUIMessageType.InvalidLogin, ex.Message)); instance.Commands.Remove(GFCommand.WaitingForUpload); } } }
public void LengthTest() { AtomLink target = new AtomLink(); // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; target.Length = expected; actual = target.Length; Assert.AreEqual(expected, actual); }