Ejemplo n.º 1
0
        private async void AttachMediaFromUrl()
        {
            _recentMediaChange = DateTime.Now;

            string url = txtAttachmentURL.Text.Trim();

            if (url == "")
            {
                return;
            }

            var ap = DataContext as ArgPoint;

            if (ap == null)
            {
                return;
            }

            if (ap.Attachment.Any(at => at.Link == url))
            {
                return;
            }

            var a      = new Attachment();
            var imgSrc = AttachmentManager.ProcessAttachCmd(ap, txtAttachmentURL.Text, ref a);

            if (imgSrc != null)
            {
                a.Person = getFreshCurrentPerson();

                ap.ChangesPending = true;
                UISharedRTClient.Instance.clienRt.SendStatsEvent(
                    AttachmentToEvent(a, false),
                    ap.Person.Id,
                    ap.Topic.Discussion.Id,
                    ap.Topic.Id,
                    DeviceType.Wpf);
                UpdateOrderedMedia();
                BeginAttachmentNumberInjection();

                ap.RecentlyEnteredMediaUrl = url;
            }
            else
            {
                await Utils.DelayAsync(700);

                if (DateTime.Now.Subtract(_recentMediaChange).TotalMilliseconds > 700)
                {
                    if (!string.IsNullOrWhiteSpace(url) &&
                        url != ap.RecentlyEnteredMediaUrl)
                    {
                        ErrMessages.InvalidUrl();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        void AttachSource()
        {
            var ap = DataContext as ArgPoint;

            if (ap == null)
            {
                return;
            }

            string url = txtSource.Text.Trim();

            if (ap.Description.Source.FirstOrDefault(s => s.Text == url) != null)
            {
                return;
            }

            if (Validators.UriOk(url))
            {
                DaoUtils.AddSource(txtSource.Text, ap.Description);
                ap.ChangesPending = true;
                UISharedRTClient.Instance.clienRt.SendStatsEvent(
                    StEvent.SourceAdded,
                    ap.Person.Id,
                    ap.Topic.Discussion.Id,
                    ap.Topic.Id,
                    DeviceType.Wpf);

                UpdateOrderedSources();
                BeginSrcNumberInjection();
            }
            else if (!string.IsNullOrWhiteSpace(txtSource.Text) &&
                     txtSource.Text != ap.RecentlyEnteredSource)
            {
                ErrMessages.InvalidUrl();
            }
        }