コード例 #1
0
        public void AtomPersonConstructorTest()
        {
            string     name   = "TestValue";
            AtomPerson target = new AtomPerson(AtomPersonType.Contributor, name);

            Assert.AreEqual(target.Name, name);
        }
コード例 #2
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>public static bool IsPersonIdentical(AtomPerson theOne, AtomPerson theOther)</summary>
        /// <param name="theOne">the One Person </param>
        /// <param name="theOther">the Other Person</param>
        /// <returns>true if identical </returns>
        //////////////////////////////////////////////////////////////////////
        public static bool IsPersonIdentical(AtomPerson theOne, AtomPerson theOther)
        {
            if (theOne == null && theOther == null)
            {
                return(true);
            }

            if (!ObjectModelHelper.IsBaseIdentical(theOne, theOther))
            {
                Tracing.TraceInfo("IsPersonIdentical: comparing  base failed");
                return(false);
            }
            Tracing.TraceInfo("IsPersonIdentical: comparing  Name " + theOne.Name + " " + theOther.Name);

            if (String.Compare(theOne.Email, theOther.Email) != 0)
            {
                Tracing.TraceInfo("IsPersonIdentical: comparing  email failed" + theOne.Email + " " + theOther.Email);
                return(false);
            }
            if (String.Compare(theOne.Name, theOther.Name) != 0)
            {
                Tracing.TraceInfo("IsPersonIdentical: comparing  Name failed" + theOne.Name + " " + theOther.Name);
                return(false);
            }
            if (AtomUri.Compare(theOne.Uri, theOther.Uri) != 0)
            {
                Tracing.TraceInfo("IsPersonIdentical: comparing  URI failed - " + theOne.Uri.ToString() + " " + theOther.Uri.ToString());
                return(false);
            }
            return(true);
        }
コード例 #3
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>creates a new, in memory atom entry</summary>
        /// <returns>the new AtomEntry </returns>
        //////////////////////////////////////////////////////////////////////
        public static AtomEntry CreateAtomEntry(int iCount)
        {
            AtomEntry entry = new AtomEntry();

            // some unicode chars
            Char[] chars = new Char[] {
                '\u0023', // #
                '\u0025', // %
                '\u03a0', // Pi
                '\u03a3', // Sigma
                '\u03d1', // beta
                '&',
            };

            AtomPerson author = new AtomPerson(AtomPersonType.Author);

            author.Name  = "John Doe" + chars[0] + chars[1] + chars[2] + chars[3] + chars[4] + chars[5];
            author.Email = "*****@*****.**";
            entry.Authors.Add(author);

            AtomCategory cat = new AtomCategory();

            cat.Label = "Default";
            cat.Term  = "Default" + chars[4] + " Term";
            entry.Categories.Add(cat);

            entry.Content.Content = "this is the default text & entry";
            entry.Content.Type    = "html";
            entry.Published       = new DateTime(2001, 11, 20, 22, 30, 0);
            entry.Title.Text      = "This is a entry number: " + iCount;
            entry.Updated         = DateTime.Now;

            return(entry);
        }
コード例 #4
0
        public void XmlNameTest()
        {
            AtomPerson target = new AtomPerson();

            Assert.AreEqual(target.XmlName, AtomParserNameTable.XmlAuthorElement);

            target = new AtomPerson(AtomPersonType.Contributor);
            Assert.AreEqual(target.XmlName, AtomParserNameTable.XmlContributorElement);
        }
コード例 #5
0
        public void NameTest()
        {
            AtomPerson target   = new AtomPerson(); // TODO: Initialize to an appropriate value
            string     expected = "TestValue";
            string     actual;

            target.Name = expected;
            actual      = target.Name;
            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
        public void UriTest()
        {
            AtomPerson target   = new AtomPerson(); // TODO: Initialize to an appropriate value
            AtomUri    expected = new AtomUri("http://www.test.com/");
            AtomUri    actual;

            target.Uri = expected;
            actual     = target.Uri;
            Assert.AreEqual(expected, actual);
        }
コード例 #7
0
        public static Author FromAtomPerson(AtomPerson person)
        {
            Author author = new Author();

            author.Uri      = person.Uri.Content;
            author.Language = person.Language;
            author.Email    = person.Email;
            author.Name     = person.Name;

            return(author);
        }
コード例 #8
0
ファイル: GoogleUtil.cs プロジェクト: gvhung/hospital-finder
        /// <summary>
        /// GoogleUtil/InsertEventToCalendar
        /// </summary>
        /// <param name="appointment">Appointment need to sync to Calendar</param>
        /// <param name="doctor">Doctor of appointment</param>
        /// <param name="speciality">Speciality of appointment</param>
        /// <param name="gmailList">list of hospital user's gmail address string</param>
        public static async void InsertEventToCalendar(Appointment appointment, Doctor doctor, Speciality speciality, List <string> gmailList)
        {
            EventEntry entry = new EventEntry();

            //title of event
            entry.Title.Text = appointment.Patient_Full_Name;

            //Desrcription of event
            entry.Content.Type = "html";
            string description = string.Empty;

            if (appointment.Health_Insurance_Code != null)
            {
                description = appointment.Symptom_Description + "</br> Mã BHYT" + appointment.Health_Insurance_Code;
            }
            else
            {
                description = appointment.Symptom_Description;
            }
            entry.Content.Content = description;

            //Location of event
            Where eventLocation = new Where();

            string where = string.Empty;
            string doctorName = string.Empty;

            if (doctor != null)
            {
                doctorName = Constants.WhiteSpace + Constants.Minus + Constants.WhiteSpace +
                             doctor.Last_Name + Constants.WhiteSpace + doctor.First_Name;
            }
            eventLocation.ValueString = speciality.Speciality_Name + doctorName;
            entry.Locations.Add(eventLocation);

            //start time of event
            DateTime start     = DateTime.Parse(appointment.Appointment_Date.ToString()).Add(TimeSpan.Parse(appointment.Start_Time.ToString()));
            When     eventTime = new When();

            eventTime.StartTime = start;

            //end time of event
            DateTime endTime = DateTime.Parse(appointment.Appointment_Date.ToString()).Add(TimeSpan.Parse(appointment.End_Time.ToString()));

            eventTime.EndTime = endTime;
            entry.Times.Add(eventTime);

            //author of event
            AtomPerson author = new AtomPerson(AtomPersonType.Author);

            author.Name  = "HospitalF-Admin";
            author.Email = userName;
            entry.Authors.Add(author);


            //add event to google calendar
            CalendarService service = GetCalendarService();
            AtomEntry       insertedEntry;

            foreach (string gmail in gmailList)
            {
                try
                {
                    Uri calendarUri = GetCalendarUri(service, gmail);
                    insertedEntry = service.Insert(calendarUri, entry);
                }
                catch (Exception ex)
                {
                    LoggingUtil.LogException(ex);
                    SendEmailToRemind(gmail);
                }
            }
        }
コード例 #9
0
        private void RefreshFeed(string bloggerURI)
        {
            string userName = this.UserName.Text;
            string passWord = this.Password.Text;

            // Suppress repainting the TreeView until all the objects have been created.
            this.FeedView.BeginUpdate();
            // Clear the TreeView each time the method is called.
            this.FeedView.Nodes.Clear();

            if (this.feedUri != null)
            {
                BloggerQuery   query   = new BloggerQuery();
                BloggerService service = new BloggerService("BloggerSampleApp.NET");

                if (userName != null && userName.Length > 0)
                {
                    service.Credentials = new GDataCredentials(userName, passWord);
                }

                // only get event's for today - 1 month until today + 1 year

                query.Uri = new Uri(bloggerURI);

                // set wait cursor before...
                Cursor.Current = Cursors.WaitCursor;


                BloggerFeed bloggerFeed = service.Query(query);

                // Reset the cursor to the default for all controls.
                Cursor.Current = Cursors.Default;



                // now populate the calendar
                while (bloggerFeed != null && bloggerFeed.Entries.Count > 0)
                {
                    foreach (BloggerEntry entry in bloggerFeed.Entries)
                    {
                        int iIndex = this.FeedView.Nodes.Add(new TreeNode(entry.Title.Text));
                        if (iIndex >= 0)
                        {
                            AtomPerson author = entry.Authors[0];
                            this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode("by: " + author.Name));
                            this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode("published: " + entry.Published.ToString()));
                            if (entry.Content.Content.Length > 50)
                            {
                                this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode(entry.Content.Content.Substring(0, 50) + "...."));
                            }
                            else
                            {
                                this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode(entry.Content.Content));
                            }
                        }
                    }

                    // do the chunking...
                    if (bloggerFeed.NextChunk != null)
                    {
                        query.Uri   = new Uri(bloggerFeed.NextChunk);
                        bloggerFeed = service.Query(query);
                    }
                    else
                    {
                        bloggerFeed = null;
                    }
                }
            }

            // Reset the cursor to the default for all controls.
            Cursor.Current = Cursors.Default;
            // stop repainting the TreeView.
            this.FeedView.EndUpdate();
        }
コード例 #10
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>creates a new, in memory atom entry</summary>
        /// <returns>the new AtomEntry </returns>
        //////////////////////////////////////////////////////////////////////
        public static ContactEntry CreateContactEntry(int iCount)
        {
            ContactEntry entry = new ContactEntry();

            // some unicode chars
            Char[] chars = new Char[] {
                '\u0023',                           // #
                '\u0025',                           // %
                '\u03a0',                           // Pi
                '\u03a3',                           // Sigma
                '\u03d1',                           // beta
            };

            // if unicode needs to be disabled for testing, just uncomment this line
            // chars = new Char[] { 'a', 'b', 'c', 'd', 'e'};



            AtomPerson author = new AtomPerson(AtomPersonType.Author);

            author.Name  = "John Doe" + chars[0] + chars[1] + chars[2] + chars[3];
            author.Email = "*****@*****.**";
            entry.Authors.Add(author);

            entry.Content.Content = "this is the default note for a contact entry";
            entry.Published       = new DateTime(2001, 11, 20, 22, 30, 0);
            entry.Title.Text      = "This is a contact number: " + iCount;
            entry.Updated         = DateTime.Now;

            // add an email.

            EMail email = new EMail("*****@*****.**" + Guid.NewGuid().ToString());

            email.Primary = true;
            email.Rel     = ContactsRelationships.IsWork;

            entry.Emails.Add(email);

            email       = new EMail("*****@*****.**" + Guid.NewGuid().ToString());
            email.Label = "some email";
            entry.Emails.Add(email);

            IMAddress im = new IMAddress("*****@*****.**");

            im.Primary = true;
            im.Rel     = ContactsRelationships.IsWork;

            entry.IMs.Add(im);
            im     = new IMAddress("*****@*****.**");
            im.Rel = ContactsRelationships.IsHome;

            PhoneNumber p = new PhoneNumber("123-3453457");

            p.Primary = true;
            p.Rel     = ContactsRelationships.IsWork;
            entry.Phonenumbers.Add(p);

            p       = new PhoneNumber("123-3334445");
            p.Label = "some other thing";
            entry.Phonenumbers.Add(p);

            StructuredPostalAddress pa = ContactsTestSuite.CreatePostalAddress();

            pa.Rel = ContactsRelationships.IsHome;
            entry.PostalAddresses.Add(pa);

            Organization org = new Organization();

            org.Name  = "This Test Org.Com";
            org.Title = "Junior guy";
            org.Label = "volunteer stuff";

            entry.Organizations.Add(org);


            return(entry);
        }
コード例 #11
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>creates a new, in memory atom entry</summary>
        /// <returns>the new AtomEntry </returns>
        //////////////////////////////////////////////////////////////////////
        public static EventEntry CreateEventEntry(int iCount)
        {
            EventEntry entry = new EventEntry();

            // some unicode chars
            Char[] chars = new Char[] {
                '\u0023',                           // #
                '\u0025',                           // %
                '\u03a0',                           // Pi
                '\u03a3',                           // Sigma
                '\u03d1',                           // beta
            };

            // if unicode needs to be disabled for testing, just uncomment this line
            // chars = new Char[] { 'a', 'b', 'c', 'd', 'e'};



            AtomPerson author = new AtomPerson(AtomPersonType.Author);

            author.Name  = "John Doe" + chars[0] + chars[1] + chars[2] + chars[3];
            author.Email = "*****@*****.**";
            entry.Authors.Add(author);

            AtomCategory cat = new AtomCategory();

            cat.Label = "Default";
            cat.Term  = "Default" + chars[4] + " Term";
            entry.Categories.Add(cat);

            entry.Content.Content = "this is the default text entry";
            entry.Published       = new DateTime(2001, 11, 20, 22, 30, 0);
            entry.Title.Text      = "This is a entry number: " + iCount;
            entry.Updated         = DateTime.Now;

            When newTime = new When();

            newTime.StartTime = DateTime.Today.AddDays(-3);
            newTime.EndTime   = DateTime.Today.AddDays(1);
            entry.Times.Add(newTime);


            entry.Reminder         = new Reminder();
            entry.Reminder.Minutes = DEFAULT_REMINDER_TIME;

            Who someone = new Who();

            someone.ValueString = "*****@*****.**";
            Who.AttendeeStatus status = new Who.AttendeeStatus();
            status.Value            = "event.accepted";
            someone.Attendee_Status = status;
            someone.Rel             = "http://schemas.google.com/g/2005#event.organizer";

            entry.Participants.Add(someone);


            Where newPlace = new Where();

            newPlace.ValueString = "A really nice place";
            entry.Locations.Add(newPlace);
            newPlace             = new Where();
            newPlace.ValueString = "Another really nice place";
            newPlace.Rel         = Where.RelType.EVENT_ALTERNATE;
            entry.Locations.Add(newPlace);
            return(entry);
        }