/////////////////////////////////////////////////////////////////////////////

        #endregion


        #region Editing APIs

        //////////////////////////////////////////////////////////////////////
        /// <summary>uses the set service to insert a new entry. </summary>
        /// <param name="newEntry">the atomEntry to insert into the feed</param>
        /// <returns>the entry as echoed back from the server. The entry is NOT added
        ///          to the feeds collection</returns>
        //////////////////////////////////////////////////////////////////////
        public TEntry Insert <TEntry>(TEntry newEntry) where TEntry : AtomEntry
        {
            Tracing.Assert(newEntry != null, "newEntry should not be null");
            if (newEntry == null)
            {
                throw new ArgumentNullException("newEntry");
            }
            AtomEntry echoedEntry = null;

            if (newEntry.Feed == this)
            {
                // same object, already in here.
                throw new ArgumentException("The entry is already part of this colleciton");
            }

            // now we need to see if this is the same feed. If not, copy
            if (newEntry.Feed == null)
            {
                newEntry.setFeed(this);
            }
            else if (!AtomFeed.IsFeedIdentical(newEntry.Feed, this))
            {
                newEntry = AtomEntry.ImportFromFeed(newEntry) as TEntry;
                newEntry.setFeed(this);
            }

            if (this.Service != null)
            {
                echoedEntry = Service.Insert(this, newEntry);
            }
            return(echoedEntry as TEntry);
        }
 //////////////////////////////////////////////////////////////////////
 /// <summary>goes over all entries, and updates the ones that are dirty</summary>
 /// <returns> </returns>
 //////////////////////////////////////////////////////////////////////
 public virtual void Publish()
 {
     if (this.Service != null)
     {
         for (int i = 0; i < this.Entries.Count; i++)
         {
             AtomEntry entry = this.Entries[i];
             if (entry.IsDirty())
             {
                 if (entry.Id.Uri == null)
                 {
                     // new guy
                     Tracing.TraceInfo("adding new entry: " + entry.Title.Text);
                     this.Entries[i] = Service.Insert(this, entry);
                 }
                 else
                 {
                     // update the entry
                     Tracing.TraceInfo("updating entry: " + entry.Title.Text);
                     entry.Update();
                 }
             }
         }
     }
     this.MarkElementDirty(false);
 }
Beispiel #3
0
        /** 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 = "*****@*****.**";

                createdEntry = service.Insert(blogPostUri, newPost);
                if (createdEntry != null)
                {
                    Console.WriteLine("  New blog post created with title: " + createdEntry.Title.Text);
                }
            }
            return createdEntry;
        }
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
                }
            }
        }
Beispiel #7
0
    /// <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;
    }
Beispiel #8
0
        /** 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 = "*****@*****.**";
                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();
                }
            }
        }
Beispiel #9
0
 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;
 }
Beispiel #10
0
        /* 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("<", "&lt;");
                        fc = fc.Replace(">", "&gt;");

                        // 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("<", "&lt;");
                        fc = fc.Replace(">", "&gt;");

                        // 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;
        }
        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);
            }
        }
        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"]);
        }
Beispiel #13
0
        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);
                }
            }
        }