public void Remove(AccountConfigElement account)
 {
     if (BaseIndexOf(account) >= 0)
     {
         BaseRemove(account.Name);
     }
 }
예제 #2
0
		public BCAPI(long publisherId) {
			BrightcoveConfig bc = (BrightcoveConfig)ConfigurationManager.GetSection("brightcove");
			foreach (AccountConfigElement a in bc.Accounts) {
				if (a.PublisherID.Equals(publisherId)) {
					Account = a;
				}
			}
		}
예제 #3
0
		public BCAPI(string accountName) {
			BrightcoveConfig bc = (BrightcoveConfig)ConfigurationManager.GetSection("brightcove");
			foreach (AccountConfigElement a in bc.Accounts) {
				if(a.Name.Equals(accountName)){
					Account = a;
				}
			}
		}
        public BCAPI(long publisherId)
        {
            BrightcoveConfig bc = (BrightcoveConfig)ConfigurationManager.GetSection("brightcove");

            foreach (AccountConfigElement a in bc.Accounts)
            {
                if (a.PublisherID.Equals(publisherId))
                {
                    Account = a;
                }
            }
        }
        public BCAPI(string accountName)
        {
            BrightcoveConfig bc = (BrightcoveConfig)ConfigurationManager.GetSection("brightcove");

            foreach (AccountConfigElement a in bc.Accounts)
            {
                if (a.Name.Equals(accountName))
                {
                    Account = a;
                }
            }
        }
        public void InitApiConnection(IVideoCloudConfig configProvider)
        {
            if (configProvider == null)
            {
                return;
            }
            else
            {
                try
                {
                    if (string.IsNullOrEmpty(configProvider.PublisherId) ||
                    string.IsNullOrEmpty(configProvider.ReadToken) ||
                    string.IsNullOrEmpty(configProvider.WriteToken))
                    {
                        return;
                    }
                }
                catch { return; }
            }

            try
            {
                this.accountConfig = new AccountConfigElement("brightcove");
                this.accountConfig.PublisherID = Convert.ToInt64(configProvider.PublisherId);
                this.readTokenList = configProvider.ReadToken.Split(tokenDelim);
                this.writeTokenList = configProvider.WriteToken.Split(tokenDelim);

                if (this.readTokenList.Length > 0)
                {
                    this.accountConfig.ReadToken.Value = this.readTokenList[0];
                }
                else
                {
                    this.accountConfig.ReadToken.Value = configProvider.ReadToken;
                }

                if (this.writeTokenList.Length > 0)
                {
                    this.accountConfig.WriteToken.Value = this.writeTokenList[0];
                }
                else
                {
                    this.accountConfig.WriteToken.Value = configProvider.WriteToken;
                }

                this.accountConfig.ReadURL.Value = configProvider.ReadUrl;
                this.accountConfig.WriteURL.Value = configProvider.WriteUrl;

                // Set default values for player
                this.DefaultVideoPlayerId = configProvider.DefaultVideoPlayerId;
                this.DefaultPlaylistPlayerId = configProvider.DefaultPlaylistPlayerId;
            }
            catch
            {
                // Alert user there is a problem with their site settings
                //throw new Exception("Brightcove Configuration is not setup.  Please enter your Brightcove Video Cloud account settings in this site's Site Settings.");
                return;
            }

            ResetApiConnection();
        }
        private static BCQueryResult MultipleQueryHandler(Dictionary <String, String> reqparams, BCObjectType itemType, AccountConfigElement account)
        {
            //Get the JSon reader returned from the APIRequest
            BCQueryResult qr = new BCQueryResult();

            qr.TotalCount = 0;

            try {
                //set some global request paramameters
                if (!reqparams.ContainsKey("page_number"))
                {
                    reqparams.Add("page_number", "0");
                }

                //set if not set or
                if (!reqparams.ContainsKey("page_size"))
                {
                    qr.MaxToGet = -1;
                }
                else
                {
                    qr.MaxToGet = Convert.ToInt32(reqparams["page_size"]);
                }

                //get initial query
                double maxPageNum = 0;

                QueryResultPair qrp = BCAPIRequest.ExecuteRead(reqparams, account);
                //convert the result for deserialization
                qrp.JsonResult = qrp.JsonResult.Replace("\"items\":", "\"" + itemType.ToString() + "\":");
                qr.QueryResults.Add(qrp);
                qr.Merge(JSON.Converter.Deserialize <BCQueryResult>(qrp.JsonResult));

                //make sure you get the correct page num
                if (qr.TotalCount > 0)
                {
                    //if you want all use the total count to calculate the number of pages
                    if (qr.MaxToGet.Equals(-1))
                    {
                        maxPageNum = Math.Ceiling((double)(qr.TotalCount / 100));
                    }
                    //or just use the max you want to calculate the number of pages
                    else
                    {
                        maxPageNum = Math.Ceiling((double)(qr.MaxToGet / 100));
                    }
                }

                //if there are more to get move to next page and keep getting them
                for (int pageNum = 1; pageNum <= maxPageNum; pageNum++)
                {
                    //update page each iteration
                    reqparams["page_number"] = pageNum.ToString();

                    QueryResultPair qrp2 = BCAPIRequest.ExecuteRead(reqparams, account);
                    //convert the result for deserialization
                    qrp2.JsonResult = qrp2.JsonResult.Replace("\"items\":", "\"" + itemType.ToString() + "\":");
                    qr.QueryResults.Add(qrp2);
                    qr.Merge(JSON.Converter.Deserialize <BCQueryResult>(qrp2.JsonResult));
                }

                //sorting on our end

                if (itemType.Equals(BCObjectType.videos) && reqparams.ContainsKey("sort_by"))
                {
                    //PUBLISH_DATE,
                    if (reqparams["sort_by"].Equals("PUBLISH_DATE"))
                    {
                        qr.Videos.Sort(BCVideo.PublishDateComparison);
                    }
                    //PLAYS_TOTAL,
                    else if (reqparams["sort_by"].Equals("PLAYS_TOTAL"))
                    {
                        qr.Videos.Sort(BCVideo.TotalPlaysComparison);
                    }
                    //PLAYS_TRAILING_WEEK
                    else if (reqparams["sort_by"].Equals("PLAYS_TRAILING_WEEK"))
                    {
                        qr.Videos.Sort(BCVideo.PlaysTrailingComparison);
                    }
                    //MODIFIED_DATE,
                    else if (reqparams["sort_by"].Equals("MODIFIED_DATE"))
                    {
                        qr.Videos.Sort(BCVideo.ModifiedDateComparison);
                    }
                    //CREATION_DATE,
                    else
                    {
                        qr.Videos.Sort(BCVideo.CreationDateComparison);
                    }

                    //if they want asc
                    if (reqparams["sort_order"].Equals("DESC"))
                    {
                        qr.Videos.Reverse();
                    }

                    //trim if specified
                    if (qr.Videos.Count > qr.MaxToGet && !qr.MaxToGet.Equals(-1) && qr.MaxToGet < qr.TotalCount)
                    {
                        List <BCVideo> vidTemp = qr.Videos.GetRange(0, Convert.ToInt32(qr.MaxToGet));

                        qr.Videos.Clear();
                        qr.Videos.AddRange(vidTemp);
                    }
                }
            }
            catch (Exception ex) {
                throw new Exception(ex.ToString());
            }

            return(qr);
        }
 public BCAPI(AccountConfigElement account)
 {
     Account = account;
 }
 public void Add(AccountConfigElement account)
 {
     BaseAdd(account);
 }
 public int IndexOf(AccountConfigElement account)
 {
     return(BaseIndexOf(account));
 }
		public void Remove(AccountConfigElement account) {
			if (BaseIndexOf(account) >= 0)
				BaseRemove(account.Name);
		}
		public void Add(AccountConfigElement account) {
			BaseAdd(account);
		}
		public int IndexOf(AccountConfigElement account) {
			return BaseIndexOf(account);
		}
예제 #14
0
		private static BCQueryResult MultipleQueryHandler(Dictionary<String, String> reqparams, BCObjectType itemType, AccountConfigElement account)
        {
			//Get the JSon reader returned from the APIRequest
			BCQueryResult qr = new BCQueryResult();
			qr.TotalCount = 0;

			try {

				//set some global request paramameters
                if (!reqparams.ContainsKey("page_number")) {
                    reqparams.Add("page_number", "0");
                }

				//set if not set or 
				if (!reqparams.ContainsKey("page_size")) {
					qr.MaxToGet = -1;
				}
				else {
					qr.MaxToGet = Convert.ToInt32(reqparams["page_size"]);
				}

				//get initial query
				double maxPageNum = 0;

				QueryResultPair qrp = BCAPIRequest.ExecuteRead(reqparams, account);
				//convert the result for deserialization
				qrp.JsonResult = qrp.JsonResult.Replace("\"items\":", "\"" + itemType.ToString() + "\":");
				qr.QueryResults.Add(qrp);
                qr.Merge(JSON.Converter.Deserialize<BCQueryResult>(qrp.JsonResult));

                //make sure you get the correct page num
                if (qr.TotalCount > 0) {
                    //if you want all use the total count to calculate the number of pages
                    if (qr.MaxToGet.Equals(-1)) {
                        maxPageNum = Math.Ceiling((double)(qr.TotalCount / 100));
                    }
                    //or just use the max you want to calculate the number of pages
				    else {
					    maxPageNum = Math.Ceiling((double)(qr.MaxToGet / 100));
				    }
                }

				//if there are more to get move to next page and keep getting them
				for (int pageNum = 1; pageNum <= maxPageNum; pageNum++ ) {

					//update page each iteration
					reqparams["page_number"] = pageNum.ToString();
					
					QueryResultPair qrp2 = BCAPIRequest.ExecuteRead(reqparams, account);
					//convert the result for deserialization
					qrp2.JsonResult = qrp2.JsonResult.Replace("\"items\":", "\"" + itemType.ToString() + "\":");
					qr.QueryResults.Add(qrp2);
					qr.Merge(JSON.Converter.Deserialize<BCQueryResult>(qrp2.JsonResult));				
				}

				//sorting on our end

				if (itemType.Equals(BCObjectType.videos) && reqparams.ContainsKey("sort_by")) {
					//PUBLISH_DATE, 
					if (reqparams["sort_by"].Equals("PUBLISH_DATE")) {
						qr.Videos.Sort(BCVideo.PublishDateComparison);
					}
					//PLAYS_TOTAL, 
					else if (reqparams["sort_by"].Equals("PLAYS_TOTAL")) {
						qr.Videos.Sort(BCVideo.TotalPlaysComparison);
					}
					//PLAYS_TRAILING_WEEK
					else if (reqparams["sort_by"].Equals("PLAYS_TRAILING_WEEK")) {
						qr.Videos.Sort(BCVideo.PlaysTrailingComparison);
					}
                    //MODIFIED_DATE,
                    else if (reqparams["sort_by"].Equals("MODIFIED_DATE")) {
						qr.Videos.Sort(BCVideo.ModifiedDateComparison);
					}
                    //CREATION_DATE, 
					else {
						qr.Videos.Sort(BCVideo.CreationDateComparison);
					}

					//if they want asc
					if (reqparams["sort_order"].Equals("DESC")) {
						qr.Videos.Reverse();
					}
					
					//trim if specified
					if (qr.Videos.Count > qr.MaxToGet && !qr.MaxToGet.Equals(-1) && qr.MaxToGet < qr.TotalCount) {
						List<BCVideo> vidTemp = qr.Videos.GetRange(0, Convert.ToInt32(qr.MaxToGet));

						qr.Videos.Clear();
						qr.Videos.AddRange(vidTemp);
					}
				}
			}
			catch(Exception ex){
				throw new Exception(ex.ToString());
			}

			return qr;
		}
예제 #15
0
 public BCAPI(AccountConfigElement account)
 {
     Account = account;
 }