static void Main(string[] args) { string username = "******"; string password = "******"; DocumentsService service = new DocumentsService("MyDocumentsListIntegration-v1"); service.setUserCredentials(username, password); //DocumentsListQuery query = new DocumentsListQuery(); TextDocumentQuery query = new TextDocumentQuery(); // Make a request to the API and get all documents. DocumentsFeed feed = service.Query(query); // Iterate through all of the documents returned foreach (DocumentEntry entry in feed.Entries) { if (entry.Title.Text == "Rufo-Resume.doc") { // Print the title of this document to the screen Console.WriteLine(entry.Title.Text); var stream = service.Query(new Uri(entry.Content.Src.ToString())); var reader = new StreamReader(stream); Console.WriteLine(reader.ReadToEnd()); } } }
protected override void Render(System.Web.UI.HtmlTextWriter writer) { if (string.IsNullOrEmpty(this.DocName)) { base.Render(writer); return; } string username = "******"; string password = "******"; DocumentsService service = new DocumentsService("MyDocumentsListIntegration-v1"); service.setUserCredentials(username, password); //DocumentsListQuery query = new DocumentsListQuery(); TextDocumentQuery query = new TextDocumentQuery(); // Make a request to the API and get all documents. DocumentsFeed feed = service.Query(query); // Iterate through all of the documents returned foreach (DocumentEntry entry in feed.Entries) { if (entry.Title.Text == this.DocName) { writer.Write("<div class='gdoc'>"); Stream stream = service.Query(new Uri(entry.Content.Src.ToString())); StreamReader reader = new StreamReader(stream); writer.Write(reader.ReadToEnd()); writer.Write("</div>"); break; } } base.Render(writer); }
public void DeleteImageFile(Hashtable State,string url) { DocumentsService service = new DocumentsService("MobiFlexDocs"); service.setUserCredentials( HttpRuntime.Cache["MobiFlexGDocsUsername"].ToString(), HttpRuntime.Cache["MobiFlexGDocsPassword"].ToString()); AtomEntry entry = service.Get(url); entry.Delete(); }
private static DocumentsService getDocumentsService() { DocumentsService documentsService = new DocumentsService("Monitis2GoogleDocumentrService"); documentsService.setUserCredentials(USERNAME, PASSWORD); return documentsService; }
public SpreadsheetProxy(Credentials credentials) { spreadsheetService = new SpreadsheetsService("groundfloor-svc1"); spreadsheetService.setUserCredentials(credentials.username, credentials.password); documentService = new DocumentsService("groundfloor-svc2"); documentService.setUserCredentials(credentials.username, credentials.password); }
public DatabaseClient(string username, string password) { var docService = new DocumentsService("database"); docService.setUserCredentials(username, password); documentService = docService; var ssService = new SpreadsheetsService("database"); ssService.setUserCredentials(username, password); spreadsheetService = ssService; }
/// <summary> /// Authenticates to Google servers /// </summary> /// <param name="username">The user's username (e-mail)</param> /// <param name="password">The user's password</param> /// <exception cref="AuthenticationException">Thrown on invalid credentials.</exception> public void Login(string username, string password) { if(loggedIn) { throw new ApplicationException("Already logged in."); } try { service = new DocumentsService("DocListUploader"); ((GDataRequestFactory) service.RequestFactory).KeepAlive = false; service.setUserCredentials(username, password); //force the service to authenticate DocumentsListQuery query = new DocumentsListQuery(); query.NumberToRetrieve = 1; service.Query(query); loggedIn = true; } catch(AuthenticationException e) { loggedIn = false; service = null; throw e; } }
public string UploadImageFile(Hashtable State, string local_file_path) { DocumentsService service = new DocumentsService("MobiFlexDocs"); service.setUserCredentials( HttpRuntime.Cache["MobiFlexGDocsUsername"].ToString(), HttpRuntime.Cache["MobiFlexGDocsPassword"].ToString()); string name = local_file_path.Substring(local_file_path.IndexOf(@"media\") + 6).Replace(@"\", "."); DocumentEntry newEntry = service.UploadFile(local_file_path, name,"text/html",true); return newEntry.AlternateUri.ToString(); }
public static bool Connect(string username, string password) { try { service = new DocumentsService (GAppName); service.setUserCredentials (username, password); } catch (Exception e) { Log<GDocs>.Error (e.Message); return false; } return true; }
/// <summary> /// Authenticates to Google servers /// </summary> /// <param name="username">The user's username (e-mail)</param> /// <param name="password">The user's password</param> /// <exception cref="AuthenticationException">Thrown on invalid credentials.</exception> public void Login(string username, string password) { if (loggedIn) { throw new ApplicationException("Already logged in."); } try { service = new DocumentsService(APP_NAME); GDataGAuthRequestFactory reqFactory = (GDataGAuthRequestFactory)service.RequestFactory; reqFactory.KeepAlive = false; reqFactory.ProtocolMajor = 3; service.setUserCredentials(username, password); loggedIn = true; } catch (AuthenticationException e) { loggedIn = false; service = null; throw e; } }
static void Main(string[] args) { var localHtmlDocname = "docContents.htm"; //Get credentials Console.Write("Enter your username:"******"Enter your password:"******"my-service"); service.setUserCredentials(user, password); DocumentsFeed listFeed = null; AtomFeed feed = null; DocumentsListQuery query = null; IProgress<string> p = new Progress<string>(Console.WriteLine); //Get list of documents var getList = Task.Run(() => { p.Report("Reading list of documents"); query = new DocumentsListQuery(); feed = service.Query(query); }); getList.Wait(); foreach (DocumentEntry entry in feed.Entries.OrderBy(x => x.Title.Text)) { if (entry.IsDocument) Console.WriteLine(entry.Title.Text); } Console.WriteLine("Type the name of the document you would like to open:"); var openDocTitle = Console.ReadLine(); string contents = string.Empty; //Get list of documents var openDoc = Task.Run(() => { p.Report("Reading document contents"); query.Title = openDocTitle; feed = service.Query(query); var openMe = feed.Entries[0] as DocumentEntry; var stream = service.Query(new Uri(openMe.Content.Src.ToString())); var reader = new StreamReader(stream); contents = reader.ReadToEnd(); using (var fs = File.Create(localHtmlDocname)) { using (var writer = new StreamWriter(fs)) { contents += Environment.UserName + " was here - " + DateTime.Now.ToString() + "<br/>"; writer.Write(contents); writer.Flush(); writer.Close(); } fs.Close(); } //OPTIONAL: Uncomment to save changes BACK to the google doc /* openMe.MediaSource = new MediaFileSource(localHtmlDocname, "text/html"); var uploader = new ResumableUploader(); //Get an authenticator var authenticator = new ClientLoginAuthenticator("document-access-test", ServiceNames.Documents, service.Credentials); //Perform the upload... Console.WriteLine("Saving to Google Drive..."); uploader.Update(authenticator, openMe); */ }); openDoc.Wait(); Console.WriteLine("Opening contents of Google doc file..."); System.Diagnostics.Process.Start(localHtmlDocname); }