コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //available querystring values for context info (id, language, version, database)

            try {
                //get the current item and database
                currentDB   = Sitecore.Configuration.Factory.GetDatabase("master");
                currentItem = new VideoItem(currentDB.Items[HttpContext.Current.Request.QueryString["id"].ToString()]);
                Item acct = currentItem.videoItem.Parent.Parent;
                //if current parent isn't the account then it's the parent of the folder
                if (!acct.TemplateName.Equals("Account Folder"))
                {
                    acct = acct.Parent;
                }
                accountItem = new AccountItem(acct.ID, acct.InnerData, acct.Database);
                bc          = new BCAPI(accountItem.PublisherID);

                if (!currentItem.ThumbnailURL.Equals(""))
                {
                    pnlThumb.Visible  = true;
                    imgThumb.ImageUrl = currentItem.ThumbnailURL;
                }
                if (!currentItem.VideoStillURL.Equals(""))
                {
                    pnlStill.Visible  = true;
                    imgStill.ImageUrl = currentItem.VideoStillURL;
                }
            }
            catch (Exception ex) {
                ltlError.Text = ex.ToString();
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
                //get the current item and database
                currentDB   = Sitecore.Configuration.Factory.GetDatabase("master");
                currentItem = new PlaylistItem(currentDB.Items[HttpContext.Current.Request.QueryString["id"].ToString()]);
                Item acct = currentItem.playlistItem.Parent.Parent;
                //if current parent isn't the account then it's the parent of the folder
                if (!acct.TemplateName.Equals("Account Folder"))
                {
                    acct = acct.Parent;
                }
                accountItem = new AccountItem(acct.ID, acct.InnerData, acct.Database);
                bc          = new BCAPI(accountItem.PublisherID);

                if (!IsPostBack)
                {
                    loadFormWithCurrentValues();

                    //load non-editable information
                    ltlPlaylistID.Text = currentItem.PlaylistID.ToString();
                    ltlVideos.Text     = currentItem.VideoIds.Count.ToString();
                    ltlAccount.Text    = currentItem.AccountId.ToString();
                }
            }
            catch (Exception ex) {
                ltlError.Text = ex.ToString();
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: zhy1/evemu_crucible
        private static void Main()
        {
            // Sets isDebugBuild variable to true if this is a debug build
            CheckIsDebug();

            // Quits non-debug builds if another instance already exists
            if (!s_isDebugBuild && !IsInstanceUnique)
            {
                return;
            }

            // Subscribe application's events (especially the unhandled exceptions management for the crash box)
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.ThreadException += Application_ThreadException;
            Application.ApplicationExit += ApplicationExitCallback;
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // Find our files
            EveClient.InitializeFileSystemPaths();

            // Creates a trace file
            EveClient.StartTraceLogging();
            EveClient.Trace("Starting up");

            // Make our windows nice
            MakeWindowsJuicy();

            // Check arguments
            bool startMinimized = Environment.GetCommandLineArgs().Contains("-startMinimized");

            // Initialization
            EveClient.Initialize();
            Settings.InitializeFromFile();

            // Did something requested an exit before we entered Run() ?
            if (s_exitRequested)
            {
                return;
            }

            // Fires the main window
            try
            {
                EveClient.Trace("Main loop - start");
                Application.Run(new MainWindow(startMinimized));
                EveClient.Trace("Main loop - done");
            }
            // Save before we quit
            finally
            {
                Settings.SaveImmediate();
                EveIDtoName.Save();
                BCAPI.UploadSettingsFile();
                EveClient.Trace("Closed");
                EveClient.StopTraceLogging();
            }
        }
コード例 #4
0
        public static string[] GetAllVideos(BCAPI api, int pageNumber, string query)
        {
            string[] result = null;

            if (api != null)
            {
                List <BrightcoveSDK.VideoFields> videoSearchFields = new List <VideoFields>();
                int           itemsPerPage = 50;
                int           itemCount    = 0;
                BCQueryResult videos       = null;

                videoSearchFields.Add(VideoFields.NAME);

                if (!string.IsNullOrEmpty(query))
                {
                    query = query.Trim();
                }
                else
                {
                    query = string.Empty;
                }

                if (query.Length == 0)
                {
                    videos = api.FindAllVideos(itemsPerPage, BCSortByType.MODIFIED_DATE, BCSortOrderType.DESC, null, null, MediaDeliveryTypeEnum.DEFAULT, pageNumber, true);
                }
                else
                {
                    videos = api.FindVideosByText(query, itemsPerPage, BCSortByType.MODIFIED_DATE, BCSortOrderType.DESC, null, null, MediaDeliveryTypeEnum.DEFAULT, pageNumber, true);
                }

                if (videos != null)
                {
                    itemCount = videos.TotalCount;
                }

                result = new string[videos.TotalCount];

                for (int i = 0; i < videos.Videos.Count; i++)
                {
                    BCVideo video = videos.Videos[i];

                    if (i < itemsPerPage)
                    {
                        result[i] = string.Format(@"{{ ""id"":{0}, ""name"":'{1}', ""thumbnailURL"":'{2}' }}",
                                                  video.id, Util.FixParam(video.name), Util.FixParam(video.thumbnailURL));
                    }
                    else
                    {
                        result[i] = "null";
                    }
                }
            }

            return(result);
        }
コード例 #5
0
        /// <summary>
        /// Checks the BattleClinic API credentials.
        /// </summary>
        private void CheckAPICredentials()
        {
            uint   bcUserID = Convert.ToUInt32(bcUserIDTextBox.Text);
            string bcAPIKey = bcAPIKeyTextBox.Text;

            BCAPI.CheckAPICredentials(bcUserID, bcAPIKey);

            throbber.Visible = true;
            throbber.State   = ThrobberState.Rotating;
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //available querystring values for context info (id, language, version, database)

            try {
                //get the current item and database
                currentDB   = Sitecore.Configuration.Factory.GetDatabase("master");
                currentItem = new PlayerItem(currentDB.Items[HttpContext.Current.Request.QueryString["id"].ToString()]);
                Item acct = currentItem.playerItem.Parent.Parent;
                //if current parent isn't the account then it's the parent of the folder
                if (!acct.TemplateName.Equals("Account Folder"))
                {
                    acct = acct.Parent;
                }
                accountItem = new AccountItem(acct.ID, acct.InnerData, acct.Database);
                bc          = new BCAPI(accountItem.PublisherID);

                //populate drop down
                if (!IsPostBack)
                {
                    foreach (Item itm in accountItem.Parent.ChildByTemplateAndName("Settings Folder", "Settings").ChildByTemplateAndName("Enum", "WMode").GetChildren())
                    {
                        ddlWMode.Items.Add(new ListItem(itm.DisplayName, itm.DisplayName));
                    }
                    //fill player drop down
                    foreach (VideoItem vp in accountItem.VideoLib.Videos)
                    {
                        ddlVideo.Items.Add(new ListItem(vp.VideoName, vp.videoItem.ID.ToString()));
                    }
                    //fill playlist drop down
                    foreach (PlaylistItem pl in accountItem.PlaylistLib.Playlists)
                    {
                        cblPlaylist.Items.Add(new ListItem(pl.PlaylistName, pl.playlistItem.ID.ToString()));
                    }
                    if (!currentItem.PlaylistType.Equals(PlayerPlaylistType.None) && cblPlaylist.Items.Count > 0)
                    {
                        cblPlaylist.SelectedIndex = 0;
                    }

                    //set the initial player up
                    if (ddlVideo.Items.Count > 0)
                    {
                        SetVideoPlayer();
                    }
                    else
                    {
                        ltlMessage.Text = "To use the preview section you must have already defined at least one player";
                    }
                }
            }
            catch (Exception ex) {
                ltlError.Text = ex.ToString();
            }
        }
コード例 #7
0
        /// <summary>
        /// Occurs when clicking the "Download settings file" button.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void downloadSettingsFileButton_Click(object sender, EventArgs e)
        {
            apiResponseLabel.ForeColor = SystemColors.ControlText;
            apiResponseLabel.Text      = String.Empty;

            if (m_queryPending)
            {
                return;
            }

            m_queryPending   = true;
            throbber.Visible = true;
            throbber.State   = ThrobberState.Rotating;

            BCAPI.FileGetByNameAsync(OnFileGetByName);
        }
コード例 #8
0
        public static string[] GetAllPlaylists(BCAPI api, int pageNumber, string query)
        {
            string[] result = null;

            if (api != null)
            {
                int           itemsPerPage = 50;
                int           itemCount    = 0;
                BCQueryResult playlists    = null;

                // Cannot search playlists yet, but in the future use "query" -ACA 9/12/2011
                if (!string.IsNullOrEmpty(query))
                {
                    query = query.Trim().ToLower();
                }
                else
                {
                    query = string.Empty;
                }

                playlists = api.FindAllPlaylists(itemsPerPage, BCSortByType.MODIFIED_DATE, BCSortOrderType.DESC, null, null, Util.PlaylistBrowseFields, MediaDeliveryTypeEnum.DEFAULT, pageNumber, true);

                if (playlists != null)
                {
                    itemCount = playlists.TotalCount;
                }

                result = new string[playlists.TotalCount];

                for (int i = 0; i < playlists.Playlists.Count; i++)
                {
                    if (i < itemsPerPage)
                    {
                        BCPlaylist playlist = playlists.Playlists[i];

                        result[i] = string.Format(@"{{ ""id"":{0}, ""name"":'{1}', ""thumbnailURL"":'{2}' }}",
                                                  playlist.id, Util.FixParam(playlist.name), Util.FixParam(playlist.thumbnailURL));
                    }
                    else
                    {
                        result[i] = "null";
                    }
                }
            }

            return(result.ToArray());
        }
コード例 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
                //get the current item and database
                currentDB   = Sitecore.Configuration.Factory.GetDatabase("master");
                currentItem = currentDB.Items[HttpContext.Current.Request.QueryString["id"].ToString()];
                accountItem = new AccountItem(currentItem.ID, currentItem.InnerData, currentItem.Database);
                bc          = new BCAPI(accountItem.PublisherID);

                //display the current video and playlist count
                ltlTotalPlaylists.Text = accountItem.PlaylistLib.Playlists.Count.ToString();
                ltlTotalVideos.Text    = accountItem.VideoLib.Videos.Count.ToString();
            }
            catch (Exception ex) {
                ltlError.Text  = "There was an error loading this page. You probably need to set the publisher Id<br/><br/>";
                ltlError.Text += ex.ToString();
            }
        }
コード例 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //available querystring values for context info (id, language, version, database)
            //disabling this for now
            pnlUpload.Visible = false;
            try {
                //get the current item and database
                currentDB   = Sitecore.Configuration.Factory.GetDatabase("master");
                currentItem = currentDB.Items[HttpContext.Current.Request.QueryString["id"].ToString()];
                accountItem = new AccountItem(currentItem.Parent.ID, currentItem.Parent.InnerData, currentItem.Parent.Database);
                bc          = new BCAPI(accountItem.PublisherID);

                //display the current video and playlist count
                ltlTotalVideos.Text = accountItem.VideoLib.Videos.Count.ToString();
            }
            catch (Exception ex) {
                ltlError.Text = ex.ToString();
            }
        }
コード例 #11
0
        public void ResetApiConnection()
        {
            if (this.accountConfig == null)
            {
                this.bcApi = null;

                return;
            }

            try
            {
                BrightcoveConfig config = new BrightcoveConfig();
                config.Accounts.Add(this.accountConfig);
                this.bcApi = new BCAPI(config.Accounts[0]);
            }
            catch
            {
                // Do nothing
            }
        }
コード例 #12
0
        /// <summary>
        /// On settings file downloaded we inform the user.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="errorMessage">The error message.</param>
        private void OnFileGetByName(BCAPIResult <SerializableBCAPIFiles> result, string errorMessage)
        {
            m_queryPending = false;

            throbber.State             = ThrobberState.Stopped;
            throbber.Visible           = false;
            apiResponseLabel.ForeColor = Color.Red;

            if (!String.IsNullOrEmpty(errorMessage))
            {
                apiResponseLabel.Text = errorMessage;
                return;
            }

            if (result.HasError)
            {
                apiResponseLabel.Text = result.Error.ErrorMessage;
                return;
            }

            BCAPI.SaveSettingsFile(result.Result.Files[0]);
        }
コード例 #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //available querystring values for context info (id, language, version, database)

            try {
                //get the current item and database
                currentDB   = Sitecore.Configuration.Factory.GetDatabase("master");
                currentItem = new VideoItem(currentDB.Items[HttpContext.Current.Request.QueryString["id"].ToString()]);
                Item acct = currentItem.videoItem.Parent.Parent;
                //if current parent isn't the account then it's the parent of the folder
                if (!acct.TemplateName.Equals("Account Folder"))
                {
                    acct = acct.Parent;
                }
                accountItem = new AccountItem(acct.ID, acct.InnerData, acct.Database);
                bc          = new BCAPI(accountItem.PublisherID);

                //set the form values for the video
                if (!IsPostBack)
                {
                    loadFormWithCurrentValues();
                }

                //show the video id
                ltlVideoID.Text = currentItem.VideoID.ToString();

                //show the video upload status
                RPCResponse <UploadStatusEnum> rpcr = bc.GetUploadStatus(currentItem.VideoID);
                ltlStatus.Text = rpcr.result.ToString();

                ltlCreation.Text  = currentItem.CreationDate.ToString("MMMM d, yyyy");
                ltlModified.Text  = currentItem.LastModifiedDate.ToString("MMMM d, yyyy");
                ltlPublished.Text = currentItem.PublishedDate.ToString("MMMM d, yyyy");
                try {
                    long   milliseconds = currentItem.Length;
                    string lengthText   = "";
                    long   hours        = (milliseconds / 60000000);
                    if (hours >= 1)
                    {
                        milliseconds -= hours * 60000000;
                        lengthText   += hours + " hours, ";
                    }
                    long mins = (milliseconds / 60000);
                    if (mins >= 1)
                    {
                        milliseconds -= mins * 60000;
                        lengthText   += mins + " minutes, ";
                    }
                    long secs = (milliseconds / 1000);
                    if (secs >= 1)
                    {
                        milliseconds -= secs * 1000;
                        lengthText   += secs + " seconds";
                    }
                    ltlLength.Text = lengthText;
                }
                catch (Exception ex) {
                }
                ltlPlays.Text         = currentItem.PlaysTotal.ToString();
                ltlPlaysTrailing.Text = currentItem.PlaysTrailingWeek.ToString();
            }
            catch (Exception ex) {
                ltlError.Text = ex.ToString();
            }
        }
コード例 #14
0
        // For AJAX calls to get video list across web parts
        public bool AsyncVideoList()
        {
            bool   returnValue = false;
            int    resultCount = 0;
            string resultItems = "";
            int    pageNumber  = 0;
            string pagingLink  = "";

            string query = "";

            if (Page.Request.QueryString[VideoCloudWebPart.QueryStringKeyAsyncQueryText] != null)
            {
                query = Page.Request.QueryString[VideoCloudWebPart.QueryStringKeyAsyncQueryText];
            }
            string order = "";

            if (Page.Request.QueryString[VideoCloudWebPart.QueryStringKeyAsyncOrder] != null)
            {
                order = Page.Request.QueryString[VideoCloudWebPart.QueryStringKeyAsyncOrder];
            }
            string sort = "";

            if (Page.Request.QueryString[VideoCloudWebPart.QueryStringKeyAsyncSort] != null)
            {
                sort = Page.Request.QueryString[VideoCloudWebPart.QueryStringKeyAsyncSort];
            }
            if (query != null)
            {
                VideoCloudWebPartUserControl videoCloud = new VideoCloudWebPartUserControl();
                BCAPI api = videoCloud.CreateAPI(this.configProvider);

                if (api != null)
                {
                    string   chooser = Page.Request.QueryString[VideoCloudWebPart.QueryStringKeyAsyncChooserText];
                    string[] result  = null;

                    if (!string.IsNullOrEmpty(Page.Request.QueryString[Util.PagingKey]))
                    {
                        pageNumber = int.Parse(Page.Request.QueryString[Util.PagingKey]);
                    }

                    query = query.Trim();

                    if (string.IsNullOrEmpty(chooser))
                    {
                        result = Util.GetAllVideos(api, pageNumber, query, order, sort);
                    }
                    else
                    {
                        chooser = chooser.Trim();

                        if (chooser == "PlaylistId")
                        {
                            // Playlists
                            if (this._playlistCache == null)
                            {
                                result = Util.GetAllPlaylists(api, pageNumber, query, order, sort);
                                this._playlistCache = result;
                            }
                            else
                            {
                                result = this._playlistCache;
                            }
                        }
                        else
                        {
                            // Videos
                            if (this._videoListCache == null)
                            {
                                result = Util.GetAllVideos(api, pageNumber, query, order, sort);
                                this._videoListCache = result;
                            }
                            else
                            {
                                result = this._videoListCache;
                            }
                        }
                    }

                    if (result == null)
                    {
                        result = new string[0];
                    }

                    string[] pagePath = Page.Request.FilePath.Split("/".ToCharArray());
                    string   t        = DateTime.Now.Ticks.ToString();
                    pagingLink = pagePath[pagePath.Length - 1] + "?" + VideoCloudWebPart.QueryStringKeyAsyncQueryText + "=" + HttpUtility.UrlEncode(query) + "&t=" + t;

                    if (!string.IsNullOrEmpty(chooser))
                    {
                        pagingLink += "&" + VideoCloudWebPart.QueryStringKeyAsyncChooserText + "=" + HttpUtility.UrlEncode(chooser);
                    }

                    resultCount = result.Length;
                    resultItems = string.Join(",", result);

                    returnValue = true;
                }

                string resultJson = string.Format(
                    @"<script language=""javascript"" type=""text/javascript"" charset=""utf-8"">/*<![CDATA[*/
                            var vcAsyncVideoCount = {0};
                            var vcAsyncVideoResults = [{1}];
                            var vcAsyncVideoPaging = '{2}';
                        /*]]>*/</script>", resultCount, resultItems, Util.GetPaging(pageNumber, 50, resultCount, pagingLink));

                // Clear the response and just display the results
                Page.Response.Clear();
                Page.Response.Write(resultJson);
                Page.Response.Flush();
                Page.Response.End();
            }

            return(returnValue);
        }
コード例 #15
0
        public static string[] GetAllPlaylists(BCAPI api, int pageNumber, string query, string order, string sort)
        {
            string[] result = null;

            if (api != null)
            {
                int               itemsPerPage    = 50;
                int               itemCount       = 0;
                BCQueryResult     playlists       = null;
                List <BCPlaylist> playListsSorted = new List <BCPlaylist>();
                // Cannot search playlists yet, but in the future use "query" -ACA 9/12/2011
                if (!string.IsNullOrEmpty(query))
                {
                    query = query.Trim().ToLower();
                }
                else
                {
                    query = string.Empty;
                }

                playlists = api.FindAllPlaylists(itemsPerPage, getSort(sort), getOrder(order), null, null, Util.PlaylistBrowseFields, MediaDeliveryTypeEnum.DEFAULT, pageNumber, true);
                if (sort != null)
                {
                    if (sort.Equals("display name"))
                    {
                        if (order.Equals("ascending"))
                        {
                            playListsSorted = playlists.Playlists.OrderBy(i => i.name).ToList();
                        }
                        else
                        {
                            playListsSorted = playlists.Playlists.OrderByDescending(i => i.name).ToList();
                        }
                    }
                }

                if (playListsSorted != null)
                {
                    if (playListsSorted.Count == 0)
                    {
                        playListsSorted = playlists.Playlists;
                    }
                }

                if (playlists != null)
                {
                    itemCount = playListsSorted.Count;
                }

                result = new string[playListsSorted.Count];

                for (int i = 0; i < playListsSorted.Count; i++)
                {
                    if (i < itemsPerPage)
                    {
                        BCPlaylist playlist = playListsSorted[i];

                        result[i] = string.Format(@"{{ ""id"":{0}, ""name"":'{1}', ""thumbnailURL"":'{2}' }}",
                                                  playlist.id, Util.FixParam(playlist.name), Util.FixParam(playlist.thumbnailURL));
                    }
                    else
                    {
                        result[i] = "null";
                    }
                }
            }

            return(result.ToArray());
        }
コード例 #16
0
        public static string[] GetAllVideos(BCAPI api, int pageNumber, string query, string order, string sort)
        {
            string[] result = null;

            if (api != null)
            {
                List <BrightcoveSDK.VideoFields> videoSearchFields = new List <VideoFields>();
                int            itemsPerPage = 50;
                int            itemCount    = 0;
                BCQueryResult  videos       = null;
                List <BCVideo> videosSorted = new List <BCVideo>();


                videoSearchFields.Add(VideoFields.NAME);

                if (!string.IsNullOrEmpty(query))
                {
                    query = query.Trim();
                }
                else
                {
                    query = string.Empty;
                }

                if (query.Length == 0)
                {
                    videos = api.FindAllVideos(itemsPerPage, getSort(sort), getOrder(order), null, null, MediaDeliveryTypeEnum.DEFAULT, pageNumber, true);
                }
                else
                {
                    videos = api.FindVideosByText(query, itemsPerPage, getSort(sort), getOrder(order), null, null, MediaDeliveryTypeEnum.DEFAULT, pageNumber, true);
                }

                if (videos != null)
                {
                    itemCount = videos.TotalCount;
                }
                if (sort != null)
                {
                    if (sort.Equals("display name"))
                    {
                        if (order.Equals("ascending"))
                        {
                            videosSorted = videos.Videos.OrderBy(i => i.name).ToList();
                        }
                        else
                        {
                            videosSorted = videos.Videos.OrderByDescending(i => i.name).ToList();
                        }
                    }
                }

                if (videosSorted != null)
                {
                    if (videosSorted.Count == 0)
                    {
                        videosSorted = videos.Videos;
                    }
                }

                result = new string[videosSorted.Count];

                for (int i = 0; i < videosSorted.Count; i++)
                {
                    BCVideo video = videosSorted[i];

                    if (i < itemsPerPage)
                    {
                        result[i] = string.Format(@"{{ ""id"":{0}, ""name"":'{1}', ""thumbnailURL"":'{2}' }}",
                                                  video.id, Util.FixParam(video.name), Util.FixParam(video.thumbnailURL));
                    }
                    else
                    {
                        result[i] = "null";
                    }
                }
            }

            return(result);
        }