Ejemplo n.º 1
0
 private void RefreshSentMessagePanelCallback(MessageObjects sentobjects)
 {
     RefreshSentMessagePanel(sentobjects);
     MessagePanelRefresh.Visibility = Visibility.Collapsed;
     TabControlMessages.Opacity = 1.0;
     TabControlMessages.IsEnabled = true;
 }
Ejemplo n.º 2
0
        private MessageObjects GetMessageObjects(string data)
        {
            XmlDocument xdoc = new XmlDocument();
            xdoc.LoadXml(data);

            MessageObjects objects = new MessageObjects();
            List<Message> messages = new List<Message>();
            foreach (XmlNode mnode in xdoc.SelectNodes("/response/messages/message"))
            {
                Message message = new Message();
                message.WebUrl = new Uri(mnode.SelectSingleNode("web-url").InnerText);
                message.ClientType = mnode.SelectSingleNode("client-type").InnerText;
                MessageBody mb = new MessageBody();
                mb.Parsed = mnode.SelectSingleNode("body/parsed").InnerText;
                mb.Plain = mnode.SelectSingleNode("body/plain").InnerText;
                List<Uri> urls = new List<Uri>();
                foreach (XmlNode unode in mnode.SelectNodes("urls/url"))
                {
                    Uri u = new Uri(unode.InnerText);
                    urls.Add(u);
                }
                mb.Urls = urls;
                message.Body = mb;
                message.SenderType = (SenderType)Enum.Parse(Type.GetType("Yammer.SenderType"), mnode.SelectSingleNode("sender-type").InnerText.ToUpper());
                if (mnode.SelectSingleNode("client-url").InnerText != string.Empty)
                {
                    message.ClientUrl = new Uri(mnode.SelectSingleNode("client-url").InnerText);
                }
                message.Id = int.Parse(mnode.SelectSingleNode("id").InnerText);
                message.IsSystemMessage = (mnode.SelectSingleNode("system-message").InnerText == "true");
                message.Url = new Uri(mnode.SelectSingleNode("url").InnerText);
                message.ThreadId = int.Parse(mnode.SelectSingleNode("thread-id").InnerText);
                if (mnode.SelectSingleNode("replied-to-id").InnerText != string.Empty)
                {
                    message.RepliedToId = int.Parse(mnode.SelectSingleNode("replied-to-id").InnerText);
                }
                message.SenderId = int.Parse(mnode.SelectSingleNode("sender-id").InnerText);
                message.MessageType = (MessageType)Enum.Parse(Type.GetType("Yammer.MessageType"), mnode.SelectSingleNode("message-type").InnerText.ToUpper());
                message.CreatedAt = DateTime.Parse(mnode.SelectSingleNode("created-at").InnerText);

                messages.Add(message);
            }

            List<Reference> references = new List<Reference>();
            foreach (XmlNode rnode in xdoc.SelectNodes("/response/references/reference"))
            {
                Reference reference = new Reference();
                reference.Id = int.Parse(rnode.SelectSingleNode("id").InnerText);
                reference.ObjectType = (ObjectType)Enum.Parse(Type.GetType("Yammer.ObjectType"), rnode.SelectSingleNode("type").InnerText.ToUpper());
                switch (reference.ObjectType)
                {
                    case ObjectType.MESSAGE:
                        Message msg = new Message();
                        msg.Id = reference.Id;
                        msg.WebUrl = new Uri(rnode.SelectSingleNode("web-url").InnerText);
                        msg.SenderType = (SenderType)Enum.Parse(Type.GetType("Yammer.SenderType"), rnode.SelectSingleNode("sender-type").InnerText.ToUpper());
                        msg.Url = new Uri(rnode.SelectSingleNode("url").InnerText);
                        msg.ThreadId = int.Parse(rnode.SelectSingleNode("thread-id").InnerText);
                        if (rnode.SelectSingleNode("replied-to-id").InnerText != string.Empty)
                        {
                            msg.RepliedToId = int.Parse(rnode.SelectSingleNode("replied-to-id").InnerText);
                        }
                        msg.SenderId = int.Parse(rnode.SelectSingleNode("sender-id").InnerText);
                        msg.CreatedAt = DateTime.Parse(rnode.SelectSingleNode("created-at").InnerText);
                        msg.Body = new MessageBody { Plain = rnode.SelectSingleNode("body/plain").InnerText };
                        reference.Object = msg;
                        break;
                    case ObjectType.USER:
                        User usr = new User();
                        usr.Id = reference.Id;
                        usr.FullName = rnode.SelectSingleNode("full-name").InnerText;
                        usr.JobTitle = rnode.SelectSingleNode("job-title").InnerText;
                        usr.MugshotUrl = new Uri(rnode.SelectSingleNode("mugshot-url").InnerText);
                        usr.Name = rnode.SelectSingleNode("name").InnerText;
                        usr.Url = new Uri(rnode.SelectSingleNode("url").InnerText);
                        reference.Object = usr;
                        break;
                    case ObjectType.TAG:
                        Tag tag = new Tag();
                        tag.Id = reference.Id;
                        tag.WebUrl = new Uri(rnode.SelectSingleNode("web-url").InnerText);
                        tag.Name = rnode.SelectSingleNode("name").InnerText;
                        tag.Url = new Uri(rnode.SelectSingleNode("url").InnerText);
                        reference.Object = tag;
                        break;
                    case ObjectType.THREAD:
                        Thread thread = new Thread();
                        thread.Id = reference.Id;
                        thread.Url = new Uri(rnode.SelectSingleNode("url").InnerText);
                        thread.WebUrl = new Uri(rnode.SelectSingleNode("web-url").InnerText);
                        Stats stats = new Stats();
                        stats.Updates = int.Parse(rnode.SelectSingleNode("stats/updates").InnerText);
                        if (rnode.SelectSingleNode("stats/latest-reply-at").InnerText != string.Empty)
                        {
                            stats.LatestReplyAt = DateTime.Parse(rnode.SelectSingleNode("stats/latest-reply-at").InnerText);
                        }
                        thread.Stats = stats;
                        reference.Object = thread;
                        break;
                    default:
                        // NOP
                        break;
                }
                references.Add(reference);

            }

            objects.Messages = messages;
            objects.References = references;

            return objects;
        }
Ejemplo n.º 3
0
        private void RefreshSentMessagePanel(MessageObjects sentobjects)
        {
            MessageSentContainer.Children.Clear();

            foreach (Message item in sentobjects.Messages)
            {
                MessagePanel mp = new MessagePanel();
                mp.TbMessage.Text = item.Body.Plain;
                Reference refer = sentobjects.References.Find(o => o.Id == item.SenderId && o.ObjectType == ObjectType.USER);
                User user = (User)refer.Object;
                mp.TbUserId.Text = user.FullName;
                if (this.Session.Proxy != null)
                {
                    mp.ImgUser.Source = GetMugshotImage(user.MugshotUrl);
                }
                else
                {
                    mp.ImgUser.Source = new BitmapImage(user.MugshotUrl);
                }
                MessageSentContainer.Children.Add(mp);
            }
            MessageSentContainer.Children.Add(new MoreInformationPanel());
        }
Ejemplo n.º 4
0
        private void RefreshMessagePanelsCallback(MessageObjects allobjects, MessageObjects sentobjects, MessageObjects followingobjects, MessageObjects receivedobjects)
        {
            RefreshAllMessagePanel(allobjects);
            RefreshSentMessagePanel(sentobjects);
            RefreshFollowingMessagePanel(followingobjects);
            RefreshReceivedMessagePanel(receivedobjects);

            MessagePanelRefresh.Visibility = Visibility.Collapsed;
            TabControlMessages.Opacity = 1.0;
            TabControlMessages.IsEnabled = true;
        }
Ejemplo n.º 5
0
        private void RefreshAllMessagePanel(MessageObjects allobjects)
        {
            MessageAllContainer.Children.Clear();

            //MessageObjects allobjects = messages.GetAllMessage();
            int i = 0;
            foreach (Message item in allobjects.Messages)
            {
                MessagePanel mp = new MessagePanel();
                mp.TbMessage.Text = item.Body.Plain;
                if (item.RepliedToId != 0)
                {
                    mp.TbReplyTo.Visibility = Visibility.Visible;
                    mp.TbReplyTo.MouseDown += new MouseButtonEventHandler(TbReplyTo_MouseDown);
                    mp.TbReplyTo.DataContext = item.RepliedToId;
                }
                Reference refer = allobjects.References.Find(o => o.Id == item.SenderId && o.ObjectType == ObjectType.USER);
                User user = (User)refer.Object;
                mp.TbUserId.Text = user.FullName;
                if (this.Session.Proxy != null)
                {
                    mp.ImgUser.Source = GetMugshotImage(user.MugshotUrl);
                }
                else
                {
                    mp.ImgUser.Source = new BitmapImage(user.MugshotUrl);
                }
                TimeSpan tp = DateTime.Now - item.CreatedAt;
                if (tp.Days != 0)
                {
                    mp.TbUpdateTime.Text = tp.Days + " days ago";
                }
                else if (tp.Hours != 0)
                {
                    mp.TbUpdateTime.Text = tp.Hours + " hours ago";
                }
                else if (tp.Minutes != 0)
                {
                    mp.TbUpdateTime.Text = tp.Minutes + " minutes ago";
                }
                else
                {
                    mp.TbUpdateTime.Text = tp.Seconds + " seconds ago";
                }

                if (i == 0)
                {
                    this.MostLastestMessageId = item.Id;
                }
                mp.DataContext = item.Id;
                mp.DeleteButton.Click += new RoutedEventHandler(DeleteButton_Click);
                mp.ReplyButton.Click += new RoutedEventHandler(ReplyButton_Click);
                MessageAllContainer.Children.Add(mp);
                i++;
            }
            MessageAllContainer.Children.Add(new MoreInformationPanel());
        }
Ejemplo n.º 6
0
        private void MainPanelShow(MessageObjects messages)
        {
            string szNetwork = this.Session.CurrentUser.Extention.NetworkName;
            CompanyName.Text = szNetwork;
            LogoImage.Visibility = Visibility.Visible;
            RefreshAllMessagePanel(messages);
            this.ProgressPanel.Visibility = Visibility.Collapsed;
            this.AuthPanel.Visibility = Visibility.Collapsed;
            this.PanelContainer.Visibility = Visibility.Visible;

            #region check cycle test
            FrameTimer.Tick += new EventHandler(FrameTimer_Tick);
            FrameTimer.Interval = TimeSpan.FromMinutes(1.00);
            FrameTimer.Start();
            #endregion
        }
Ejemplo n.º 7
0
        private void FeedCheckerShow(MessageObjects objects)
        {
            NotifyWindow notify = new NotifyWindow();
            Message message = objects.Messages[0];
            this.MostLastestMessageId = message.Id;
            notify.BodyText = message.Body.Plain;
            Reference refer = objects.References.Find(o => o.Id == message.SenderId && o.ObjectType == ObjectType.USER);
            User user = (User)refer.Object;
            notify.UserId = user.FullName;
            if (this.Session.Proxy != null)
            {
                notify.UserImage = GetMugshotImage(user.MugshotUrl);
            }
            else
            {
                notify.UserImage = new BitmapImage(user.MugshotUrl);
            }
            notify.Show();

            RefreshMessagePanels();
        }