コード例 #1
0
        public void Index()
        {
            var g = new Service("local", "application");//, "ABQIAAAACPMbozlNv9AIzNvsWUm6vhSvnLMDprvOSMH9Qt_oH5Ww7FTw1hRHT7gTSie1yM34rowNwVfw424XPA");

            Assert.Fail("Need to put password here");
            g.setUserCredentials("*****@*****.**", "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"]);
        }
コード例 #2
0
ファイル: TasksForm.cs プロジェクト: kos89/kos89repository
        private void button1_Click(object sender, EventArgs e)
        {
            Service service = new Service("cl", "companyName-appName-1");
            service.setUserCredentials("*****@*****.**", "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);
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Generates a new Authentication Toklen for AppsService 
 /// with the specified credentials for accessing provisioning feeds on the specified domain.
 /// </summary>
 /// <param name="domain">the domain to access</param>
 /// <param name="adminEmailAddress">the administrator's email address</param>
 /// <param name="adminPassword">the administrator's password</param>
 /// <returns>the newly generated authentication token</returns>
 public static String GetNewAuthenticationToken(string domain, string adminEmailAddress, string adminPassword)
 {
     Service service = new Service(AppsNameTable.GAppsService,"apps-"+domain);
     service.setUserCredentials(adminEmailAddress, adminPassword);
     return service.QueryClientLoginToken();
 }
コード例 #4
0
        static void Main(string[] args)
        {
            if (args.Length < 5)
            {
                Console.WriteLine("Not enough parameters. Usage is ExecRequest <service> <cmd> <uri> <username> <password>, where cmd is QUERY, UPDATE, INSERT, DELETE");
                Console.WriteLine("or");
                Console.WriteLine("ExecRequest <service> <cmd> <uri> /a <authsubtoken> - to use a session token");
                Console.WriteLine("or");
                Console.WriteLine("ExecRequest <service> <cmd> <uri> /e <authsubtoken> - to exchance a one time token for a session token");
                return; 
            }

            string s         = args[0];
            string cmd       = args[1];

            string targetUri = args[2];

            string userName = args[3];
            string passWord = args[4];
            

            Service service = new Service(s, ApplicationName);
            
            if (userName.Equals("/a"))
            {
                Console.WriteLine("Using AuthSubToken: " + passWord);
                // password should contain the authsubtoken
                GAuthSubRequestFactory factory = new GAuthSubRequestFactory(s, ApplicationName);
                factory.Token = passWord;
                service.RequestFactory = factory;
            }
            else if (userName.Equals("/e"))
            {
                Console.WriteLine("Using Onetime token: " + passWord);
                passWord = AuthSubUtil.exchangeForSessionToken(passWord, null);
                Console.WriteLine("Exchanged for Session Token: " + passWord);
                // password should contain the authsubtoken
                GAuthSubRequestFactory factory = new GAuthSubRequestFactory(s, ApplicationName);
                factory.Token = passWord;
                service.RequestFactory = factory;
            }
            else 
            {
                Console.WriteLine("Setting user credentials for: " + userName);
                service.setUserCredentials(userName, passWord);
            }

            try
            {
                if (cmd.Equals("QUERY"))
                {
                    Console.WriteLine("Querying: " + targetUri);
                    Stream result = service.Query(new Uri(targetUri));
                    DumpStream(result);
                }
                if (cmd.Equals("DELETE"))
                {
                    service.Delete(new Uri(targetUri));
                    Console.WriteLine("successfully deleted: " + targetUri);
                }
                if (cmd.Equals("POST"))
                {
                    String input = Console.In.ReadToEnd();
                    Console.Write(input);
                    Stream result = service.StringSend(new Uri(targetUri), input, GDataRequestType.Insert);
                    DumpStream(result);
                }
                if (cmd.Equals("UPDATE"))
                {
                    String input = Console.In.ReadToEnd();
                    Console.Write(input);
                    Stream result = service.StringSend(new Uri(targetUri), input, GDataRequestType.Update);
                    DumpStream(result);
                }
            } catch (GDataRequestException e)
            {
                HttpWebResponse response = e.Response as HttpWebResponse;
                Console.WriteLine("Error executing request for Verb: " + cmd + ", Errorcode: " + response.StatusCode);
                Console.WriteLine(response.StatusDescription);
                Console.WriteLine(e.ResponseString);
            }
        }
コード例 #5
0
ファイル: MapDataService.cs プロジェクト: hankbeasley/hoahome
 private static Service CreateService()
 {
     var service = new Service("local", "application");
     service.setUserCredentials("*****@*****.**", "walmart");
     return service;
 }
コード例 #6
0
ファイル: LobbyClient.cs プロジェクト: YoshiEnVerde/OCTGN
 /// <summary>
 /// Login here
 /// </summary>
 /// <param name="onFinish">Delegate for when Login is done.</param>
 /// <param name="email">Users e-mail address</param>
 /// <param name="password">Password</param>
 /// <param name="captcha">Captcha string if required</param>
 /// <param name="status">Status to log in as</param>
 public void Login(LoginFinished onFinish, LoginProgressUpdate onUpdate, string email, string password, string captcha, UserStatus status)
 {
     if(Socket.Connected)
     {
         Thread t = new Thread(() =>
                                   {
                                       //TODO Need to add a method to handle 2-step signin.
                                       _onLoginFinished = onFinish;
                                       String appName = "skylabs-LobbyClient-" + Version;
                                       Service s = new Service("code", appName);
                                       s.setUserCredentials(email, password);
                                       if(captcha != null && _mCaptchaToken != null)
                                       {
                                           onUpdate.Invoke("Verifying captcha");
                                           if(!String.IsNullOrWhiteSpace(captcha) || !String.IsNullOrWhiteSpace(_mCaptchaToken))
                                           {
                                               s.Credentials.CaptchaToken = _mCaptchaToken;
                                               s.Credentials.CaptchaAnswer = captcha;
                                           }
                                       }
                                       try
                                       {
                                           Debug.WriteLine("Querying Google...");
                                           onUpdate.Invoke("Logging into Google...");
                                           string ret = s.QueryClientLoginToken();
                                           onUpdate.Invoke("Sending login token to Server...");
                                           Debug.WriteLine("Received login token.");
                                           SocketMessage sm = new SocketMessage("login");
                                           sm.AddData("email", email);
                                           sm.AddData("token", ret);
                                           sm.AddData("status", status);
                                           WriteMessage(sm);
                                           onUpdate.Invoke("Waiting for server response...");
                                       }
                                       catch(CaptchaRequiredException ce)
                                       {
                                           _mCaptchaToken = ce.Token;
                                           if(OnCaptchaRequired != null) OnCaptchaRequired.Invoke("https://www.google.com/accounts/DisplayUnlockCaptcha", ce.Url);
                                       }
                                       catch(AuthenticationException re)
                                       {
                                           string cu = (string)re.Data["CaptchaUrl"];
                                           onFinish.Invoke(LoginResult.Failure, DateTime.Now, re.Message);
                                       }
                                       catch(WebException)
                                       {
                                           onFinish.Invoke(LoginResult.Failure, DateTime.Now, "Connection problem.");
                                       }
                                       onFinish.Invoke(LoginResult.WaitingForResponse, DateTime.Now, "");
                                   });
         t.Start();
     }
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: nicocrm/GoogleContactImport
        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);
                }
            }
        }