Exemplo n.º 1
0
        /// <summary>
        /// This method will import / update a list of videos into the Brightcove Video Library
        /// </summary>
        /// <param name="Videos">
        /// The Videos to import / update
        /// </param>
        /// <returns>
        /// returns a list of the new videos imported
        /// </returns>
        public static UpdateInsertPair <VideoItem> ImportToSitecore(this AccountItem account, List <BCVideo> Videos, UpdateType utype)
        {
            UpdateInsertPair <VideoItem> uip = new UpdateInsertPair <VideoItem>();

            //set all BCVideos into hashtable for quick access
            Hashtable ht = new Hashtable();

            foreach (VideoItem exVid in account.VideoLib.Videos)
            {
                if (!ht.ContainsKey(exVid.VideoID.ToString()))
                {
                    //set as string, Item pair
                    ht.Add(exVid.VideoID.ToString(), exVid);
                }
            }

            //Loop through the data source and add them
            foreach (BCVideo vid in Videos)
            {
                try {
                    //remove access filter
                    using (new Sitecore.SecurityModel.SecurityDisabler()) {
                        VideoItem currentItem;

                        //if it exists then update it
                        if (ht.ContainsKey(vid.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE)))
                        {
                            currentItem = (VideoItem)ht[vid.id.ToString()];

                            //add it to the new items
                            uip.UpdatedItems.Add(currentItem);

                            using (new EditContext(currentItem.videoItem, true, false)) {
                                SetVideoFields(ref currentItem.videoItem, vid);
                            }
                        }
                        //else just add it
                        else if (!ht.ContainsKey(vid.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW)))
                        {
                            //Create new item
                            TemplateItem templateType = account.Database.Templates["Modules/Brightcove/Brightcove Video"];

                            currentItem = new VideoItem(account.VideoLib.videoLibraryItem.Add(vid.name.StripInvalidChars(), templateType));

                            //add it to the new items
                            uip.NewItems.Add(currentItem);

                            using (new EditContext(currentItem.videoItem, true, false)) {
                                SetVideoFields(ref currentItem.videoItem, vid);
                            }
                        }
                    }
                } catch (System.Exception ex) {
                    //HttpContext.Current.Response.Write(vid.name + "<br/>");
                    throw new Exception("Failed on video: " + vid.name + ". " + ex.ToString());
                }
            }

            return(uip);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //build bcvideo
            BCVideo vid = uvVideo.GetBCVideo();

            //upload the video
            RPCResponse <long> rpcr = bc.CreateVideo(vid, uvVideo.FileName, uvVideo.FileBytes);

            if (rpcr.error.message != null)
            {
                ltlMessage.Text = rpcr.error.code + ": " + rpcr.error.message;
            }
            else
            {
                ltlMessage.Text = "Video Created Successfully with ID: " + rpcr.result.ToString();

                vid.id               = rpcr.result;
                vid.creationDate     = DateTime.Now;
                vid.lastModifiedDate = DateTime.Now;
                vid.publishedDate    = DateTime.Now;

                UpdateInsertPair <VideoItem> a = accountItem.ImportToSitecore(vid, UpdateType.NEW);
            }

            //blank out the other fields after upload
            uvVideo.ClearForm();

            //display the current video and playlist count
            ltlTotalVideos.Text = accountItem.VideoLib.Videos.Count.ToString();
        }
        /// <summary>
        /// This handles syncing the local info with brightcove
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            pnlNewMessage.Visible    = false;
            pnlUpdateMessage.Visible = false;

            UpdateType utype = UpdateType.NEW;

            if (radUpdate.SelectedValue.Equals("update"))
            {
                utype = UpdateType.UPDATE;
            }
            else if (radUpdate.SelectedValue.Equals("both"))
            {
                utype = UpdateType.BOTH;
            }

            //import/update the playlists
            List <BCPlaylist> playlists             = bc.FindAllPlaylists().Playlists;
            UpdateInsertPair <PlaylistItem> playUIP = accountItem.ImportToSitecore(playlists, utype);

            if (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW))
            {
                pnlNewMessage.Visible = true;
                ltlNewPlaylists.Text  = playUIP.NewItems.Count.ToString();
            }
            if (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE))
            {
                //show message over how many things changed
                pnlUpdateMessage.Visible = true;
                ltlUpdatedPlaylists.Text = playUIP.UpdatedItems.Count.ToString();
            }

            //display the current video and playlist count
            ltlTotalPlaylists.Text = accountItem.PlaylistLib.Playlists.Count.ToString();
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //build bcvideo
            BCPlaylist plist = plPlaylist.GetBCPlaylist();

            //upload the video
            RPCResponse <long> rpcr = bc.CreatePlaylist(plist);

            if (rpcr.error.message != null)
            {
                ltlMessage.Text = rpcr.error.code + ": " + rpcr.error.message;
            }
            else
            {
                ltlMessage.Text = "Playlist Created Successfully with ID: " + rpcr.result.ToString();

                plist.id = rpcr.result;
                UpdateInsertPair <PlaylistItem> a = accountItem.ImportToSitecore(plist, UpdateType.NEW);
            }

            //blank out the other fields after upload
            plPlaylist.ClearForm();

            //display the current video and playlist count
            ltlTotalPlaylists.Text = accountItem.PlaylistLib.Playlists.Count.ToString();
        }
Exemplo n.º 5
0
        public static UpdateInsertPair <PlaylistItem> ImportToSitecore(this AccountItem account, List <BCPlaylist> Playlists, UpdateType utype)
        {
            UpdateInsertPair <PlaylistItem> uip = new UpdateInsertPair <PlaylistItem>();

            //set all BCVideos into hashtable for quick access
            Hashtable ht = new Hashtable();

            foreach (PlaylistItem exPlay in account.PlaylistLib.Playlists)
            {
                if (!ht.ContainsKey(exPlay.playlistItem.ToString()))
                {
                    //set as string, Item pair
                    ht.Add(exPlay.PlaylistID.ToString(), exPlay);
                }
            }

            //Loop through the data source and add them
            foreach (BCPlaylist play in Playlists)
            {
                try {
                    //remove access filter
                    using (new Sitecore.SecurityModel.SecurityDisabler()) {
                        PlaylistItem currentItem;

                        //if it exists then update it
                        if (ht.ContainsKey(play.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE)))
                        {
                            currentItem = (PlaylistItem)ht[play.id.ToString()];

                            //add it to the new items
                            uip.UpdatedItems.Add(currentItem);

                            using (new EditContext(currentItem.playlistItem, true, false)) {
                                SetPlaylistFields(ref currentItem.playlistItem, play);
                            }
                        }
                        //else just add it
                        else if (!ht.ContainsKey(play.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW)))
                        {
                            //Create new item
                            TemplateItem templateType = account.Database.Templates["Modules/Brightcove/Brightcove Playlist"];
                            currentItem = new PlaylistItem(account.PlaylistLib.playlistLibraryItem.Add(play.name.StripInvalidChars(), templateType));

                            //add it to the new items
                            uip.NewItems.Add(currentItem);

                            using (new EditContext(currentItem.playlistItem, true, false)) {
                                SetPlaylistFields(ref currentItem.playlistItem, play);
                            }
                        }
                    }
                } catch (System.Exception ex) {
                    throw new Exception("Failed on playlist: " + play.name + ". " + ex.ToString());
                }
            }

            return(uip);
        }
Exemplo n.º 6
0
		/// <summary>
		/// This method will import / update a list of videos into the Brightcove Video Library
		/// </summary>
		/// <param name="Videos">
		/// The Videos to import / update
		/// </param>
		/// <returns>
		/// returns a list of the new videos imported
		/// </returns>
		public static UpdateInsertPair<VideoItem> ImportToSitecore(this AccountItem account, List<BCVideo> Videos, UpdateType utype) {

			UpdateInsertPair<VideoItem> uip = new UpdateInsertPair<VideoItem>();

			//set all BCVideos into hashtable for quick access
			Hashtable ht = new Hashtable();
			foreach (VideoItem exVid in account.VideoLib.Videos) {
				if (!ht.ContainsKey(exVid.VideoID.ToString())) {
					//set as string, Item pair
					ht.Add(exVid.VideoID.ToString(), exVid);
				}
			}

			//Loop through the data source and add them
			foreach (BCVideo vid in Videos) {

				try {
					//remove access filter
					using (new Sitecore.SecurityModel.SecurityDisabler()) {

						VideoItem currentItem;

						//if it exists then update it
						if (ht.ContainsKey(vid.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE))) {
							currentItem = (VideoItem)ht[vid.id.ToString()];

							//add it to the new items
							uip.UpdatedItems.Add(currentItem);

							using (new EditContext(currentItem.videoItem, true, false)) {
								SetVideoFields(ref currentItem.videoItem, vid);
							}
						}
							//else just add it
						else if (!ht.ContainsKey(vid.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW))) {
							//Create new item
							TemplateItem templateType = account.Database.Templates["Modules/Brightcove/Brightcove Video"];

							currentItem = new VideoItem(account.VideoLib.videoLibraryItem.Add(vid.name.StripInvalidChars(), templateType));

							//add it to the new items
							uip.NewItems.Add(currentItem);

							using (new EditContext(currentItem.videoItem, true, false)) {
								SetVideoFields(ref currentItem.videoItem, vid);
							}
						}
					}
				} catch (System.Exception ex) {
					//HttpContext.Current.Response.Write(vid.name + "<br/>");
					throw new Exception("Failed on video: " + vid.name + ". " + ex.ToString());
				}
			}

			return uip;
		}
Exemplo n.º 7
0
		public static UpdateInsertPair<PlaylistItem> ImportToSitecore(this AccountItem account, List<BCPlaylist> Playlists, UpdateType utype) {

			UpdateInsertPair<PlaylistItem> uip = new UpdateInsertPair<PlaylistItem>();

			//set all BCVideos into hashtable for quick access
			Hashtable ht = new Hashtable();
			foreach (PlaylistItem exPlay in account.PlaylistLib.Playlists) {
				if (!ht.ContainsKey(exPlay.playlistItem.ToString())) {
					//set as string, Item pair
					ht.Add(exPlay.PlaylistID.ToString(), exPlay);
				}
			}

			//Loop through the data source and add them
			foreach (BCPlaylist play in Playlists) {

				try {
					//remove access filter
					using (new Sitecore.SecurityModel.SecurityDisabler()) {

						PlaylistItem currentItem;

						//if it exists then update it
						if (ht.ContainsKey(play.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE))) {
							currentItem = (PlaylistItem)ht[play.id.ToString()];

							//add it to the new items
							uip.UpdatedItems.Add(currentItem);

							using (new EditContext(currentItem.playlistItem, true, false)) {
								SetPlaylistFields(ref currentItem.playlistItem, play);
							}
						}
							//else just add it
						else if (!ht.ContainsKey(play.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW))) {
							//Create new item
							TemplateItem templateType = account.Database.Templates["Modules/Brightcove/Brightcove Playlist"];
							currentItem = new PlaylistItem(account.PlaylistLib.playlistLibraryItem.Add(play.name.StripInvalidChars(), templateType));

							//add it to the new items
							uip.NewItems.Add(currentItem);

							using (new EditContext(currentItem.playlistItem, true, false)) {
								SetPlaylistFields(ref currentItem.playlistItem, play);
							}
						}
					}
				} catch (System.Exception ex) {
					throw new Exception("Failed on playlist: " + play.name + ". " + ex.ToString());
				}
			}

			return uip;
		}
Exemplo n.º 8
0
        /// <summary>
        /// This handles syncing the local info with brightcove
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            pnlUpdateMessage.Visible = true;

            //import/update the video

            BCVideo v = bc.FindVideoById(currentItem.VideoID);
            UpdateInsertPair <VideoItem> vidUIP = accountItem.ImportToSitecore(v, UpdateType.UPDATE);

            //show message over how many things changed
            if (vidUIP.UpdatedItems.Count > 0)
            {
                loadFormWithCurrentValues();
                ltlUpdateMessage.Text = "The settings have been updated from Brightcove.";
            }
            else
            {
                ltlUpdateMessage.Text = "There was a problem updating this video.";
            }
        }