private void OnEmployeeServiceOpenReadComplete(object sender, OpenReadCompletedEventArgs e)
        {
            var reader = new StreamReader(e.Result);
            var result = reader.ReadToEnd();
            XmlReader XMLReader = XmlReader.Create(new MemoryStream(System.Text.UnicodeEncoding.Unicode.GetBytes(result)));
            XDocument data = XDocument.Load(XMLReader);

            var query = from emp in data.Elements("employee")
                        select new Colleague
                        {
                            ColleagueID = emp.Element("guid").Value,
                            FirstName = emp.Element("firstname").Value,
                            LastName = emp.Element("lastname").Value,
                            Title = emp.Element("title").Value,
                            CurrentLocation = emp.Element("currentlocation").Value,
                            PhotoURL = string.Format("http://{0}", emp.Element("photourl").Value),
                            ThumbnailURL = string.Format("http://{0}", emp.Element("thumbnailurl").Value),
                            MobilePhone = emp.Element("mobilephonenumber").Value
                        };
            colleague = query.SingleOrDefault();
            this.DataContext = colleague;
        }
        private void OnHistoryServiceOpenReadComplete(object sender, OpenReadCompletedEventArgs e)
        {
            var reader = new StreamReader(e.Result);
            var result = reader.ReadToEnd();
            XmlReader XMLReader = XmlReader.Create(new MemoryStream(System.Text.UnicodeEncoding.Unicode.GetBytes(result)));
            XDocument xml = XDocument.Load(XMLReader);

            var xColleagues = from emp in xml.Descendants("history")
                              select emp;
            colleagues = new List<Colleague>();
            var cnt = 0;
            lstColleagues.Items.Clear();
            List<string> latestArrivals = new List<string>();

            foreach (var xColleague in xColleagues)
            {
                DateTime lastAction;
                DateTime.TryParse(xColleague.Element("timestamp").Value, out lastAction);
                var colleague = new Colleague
                {
                    ColleagueID = xColleague.Element("employeeguid").Value,
                    FullName = xColleague.Element("employeename").Value,
                    UserName = xColleague.Element("employeeusername").Value,
                    LastAction = lastAction,
                    PhotoURL = string.Format("/Images/Colleagues/{0}.jpg", xColleague.Element("employeeusername").Value.Replace(".", "_"))
                };
                colleagues.Add(colleague);
                if (!latestArrivals.Contains(colleague.UserName))
                {
                    if (cnt < 5)
                    {
                        lstColleagues.Items.Add(colleague);
                        latestArrivals.Add(colleague.UserName);
                        cnt++;
                    }
                }

            }
            var latestEntrants = from c in colleagues
                                 orderby c.LastAction descending
                                 select c;
            var latestEntrant = latestEntrants.First();
            var tenSecondsAgo = DateTime.Now.AddSeconds(-10);
            if (latestEntrant.LastAction >= tenSecondsAgo)
            {
                //txtWelcome.Text = string.Format("Good morning, {0}!", latestEntrant.FullName);
                this.ShowColleague(latestEntrant.UserName);

            }
            locatorTimer.Start();
        }
        private void OnEmployeeServiceOpenReadComplete(object sender, OpenReadCompletedEventArgs e)
        {
            var reader = new StreamReader(e.Result);
            var result = reader.ReadToEnd();
            XmlReader XMLReader = XmlReader.Create(new MemoryStream(System.Text.UnicodeEncoding.Unicode.GetBytes(result)));
            XDocument data = XDocument.Load(XMLReader);

            var query = from emp in data.Elements("employee")
                        select new Colleague
                        {
                            ColleagueID = emp.Element("guid").Value,
                            FirstName = emp.Element("firstname").Value,
                            LastName = emp.Element("lastname").Value,
                            Title = emp.Element("title").Value,
                            CurrentLocation = emp.Element("currentlocation").Value,
                            PhotoURL = string.Format("/Images/Colleagues/{0}.jpg", emp.Element("username").Value.Replace(".","_")),
                            ThumbnailURL = string.Format("http://{0}", emp.Element("thumbnailurl").Value),
                            MobilePhone = emp.Element("mobilephonenumber").Value
                        };
            colleague = query.SingleOrDefault();
            //this.DataContext = colleague;

            txtColleagueHeader.Text = string.Format("Welcome, {0} {1}", colleague.FirstName, colleague.LastName);

            PopulateMeetings();
            PopulateTasks();

            /*
            cell01Colleague.Children.Clear();
            var colleaguePhoto = new Image();
            colleaguePhoto.Source = new BitmapImage(new Uri(colleague.PhotoURL, UriKind.Absolute));

            cell01Colleague.Children.Add(colleaguePhoto);
            colleaguePhoto.Width = cell01Colleague.Width;
            colleaguePhoto.Height = cell01Colleague.Height;
            colleaguePhoto.Stretch = Stretch.Fill;
            */
            imgColleaguePhoto.Source = new BitmapImage(new Uri(colleague.PhotoURL,UriKind.Relative));
            imgColleaguePhoto.Height = 180;
            imgColleaguePhoto.Width = 170;

            cell00Home.Visibility = Visibility.Collapsed;
            cell02Home.Visibility = Visibility.Collapsed;

            cell00Colleague.Visibility = Visibility.Visible;
            cell02Colleague.Visibility = Visibility.Visible;

            cell12Home.Visibility = Visibility.Collapsed;
            cell12Colleague.Visibility = Visibility.Visible;

            cell13Home.Visibility = Visibility.Collapsed;
            cell13Colleague.Visibility = Visibility.Visible;

            cell01Home.Visibility = Visibility.Collapsed;
            cell01Colleague.Visibility = Visibility.Visible;

            cell01Home.Visibility = Visibility.Collapsed;
            cell01Colleague.Visibility = Visibility.Visible;

            cell20Home.Visibility = Visibility.Collapsed;
            cell20Colleague.Visibility = Visibility.Visible;

            cell21Home.Visibility = Visibility.Collapsed;
            cell21Colleague.Visibility = Visibility.Visible;

            cell11Home.Visibility = Visibility.Collapsed;

            imgBuildingPhoto.Visibility = Visibility.Collapsed;
            cell10Colleague.Visibility = Visibility.Visible;

            txtColleagueDay.Text = DateTime.Now.ToString("dd");
            txtColleagueDate.Text = DateTime.Now.ToString("MMMM yyyy");

            colleagueTimer.Start();
        }