示例#1
0
        public bool CheckVideos()
        {
            for (int i = 0; i < _extensionDataList.Length; i++)
            {
                if (_extensionDataList[i].ObjectState is IStatusWatcher)
                {
                    PublishStatus status = ((IStatusWatcher)_extensionDataList[i].ObjectState).Status;
                    if ((status.Status & validState) != 0)
                    {
                        _extensionDataList[i] = null;
                    }
                    else if ((status.Status & invalidState) != 0)
                    {
                        _isSuccessful = false;
                        return(true);
                    }
                }
                else
                {
                    _extensionDataList[i] = null;
                }
            }

            _extensionDataList = (IExtensionData[])ArrayHelper.Compact(_extensionDataList);

            if (_extensionDataList.Length == 0)
            {
                _isSuccessful = true;
                return(true);
            }


            return(false);
        }
示例#2
0
        /// <summary>
        /// Gets the status of a video.  In the event the video is already published to a service
        /// this function should return "".  When it is being published by WLW we will get the status
        /// from the publisher.  It needs a window so that it can prompt the user for the
        /// username/password if a status watcher needs to be created.
        /// </summary>
        /// <param name="window"></param>
        /// <returns></returns>
        private string GenerateStatus(IWin32Window window, string blogId)
        {
            if (VideoHasProgress())
            {
                IStatusWatcher publisher = (IStatusWatcher)((IInternalContent)_content).ObjectState;

                // check to see if we need to create a status watcher, this happens during a post load
                if (publisher == null)
                {
                    // Make a video for the publisher to create a watcher for
                    Video video = new Video(_content.Properties.GetString(VIDEO_ID, Guid.Empty.ToString()),
                                            _content.Properties.GetString(VIDEO_URL, String.Empty),
                                            EmbedFormat,
                                            EditorFormat,
                                            null,
                                            HtmlSize.Width,
                                            HtmlSize.Height,
                                            VideoAspectRatioType.Unknown);
                    video.Username = _content.Properties.GetString(VIDEO_USERNAME, null);

                    IVideoPublisher newPublisher;
                    if (Provider.IsYouTube)
                    {
                        newPublisher = new YouTubeVideoPublisher();
                    }
                    else
                    {
                        newPublisher = null;
                        Trace.Fail("Unknown video publisher has been found. ID: " + Provider.ServiceId);
                    }

                    newPublisher.Init(null, window, blogId);

                    // Try to create a new watcher that can be used
                    publisher = newPublisher.CreateStatusWatcher(video);
                    ((IInternalContent)_content).ObjectState     = publisher;
                    ((IInternalContent)_content).RefreshCallback = DateTimeHelper.UtcNow;
                }

                // If the publisher couldnt make a new status watcher
                // we just try to take a snap shot and then pretend it is completed
                if (publisher == null)
                {
                    StopProgress(false);
                    return(VideoPublishStatus.Completed.ToString());
                }

                // Check to see the status and if it is completed we can stop tracking the progress
                PublishStatus publishStatus = publisher.Status;

                Id = publishStatus.Id;

                if (publishStatus.Status == VideoPublishStatus.Completed)
                {
                    StopProgress(false);
                    return(VideoPublishStatus.Completed.ToString());
                }

                if (publishStatus.Status == VideoPublishStatus.Error)
                {
                    StopProgress(true);
                    return(publishStatus.DisplayMessage);
                }

                // return the status message
                return(publishStatus.DisplayMessage);
            }
            return(String.Empty);
        }