private void DetailsViewBindData()
        {
            int pageSize = (PageLimit >= 10) ? PageLimit : 10;

            const string strPageToken = "page_token=";
            string searchText, searchBy, nextpage_url, page_token, metaDataSearch;

            searchText = txtSearch.Text.Equals("Enter Search Text")? string.Empty: Server.HtmlEncode(WPHelper.escapteChar(txtSearch.Text.Trim()));
            searchBy = ddlSearch.SelectedItem.Value;
            metaDataSearch = txtCustom.Text.Equals("Enter Metadata Key")?string.Empty : Server.HtmlEncode(WPHelper.escapteChar(txtCustom.Text.Trim()));

            //if (searchBy == "metadata")
            //{
            //    searchBy = "metadata." + metaDataSearch;
            //}

            if (searchBy == "metadata")
            {
                if (string.IsNullOrEmpty(searchText) && !string.IsNullOrEmpty(metaDataSearch))
                {
                    searchBy = "metadata." + metaDataSearch;
                }
                if (string.IsNullOrEmpty(searchText) && string.IsNullOrEmpty(metaDataSearch))
                {
                    searchBy = string.Empty; // if both text empty means it is like general search, no need come for where conditions
                }
                if (!string.IsNullOrEmpty(searchText) && !string.IsNullOrEmpty(metaDataSearch))
                {
                    searchBy = "metadata." + metaDataSearch;
                }
            }

            int currentPage = (int)ViewState["PageCount"];
            lblPageCount.Text = "Page No :" + currentPage.ToString();

            if (ViewState["PageToken" + (currentPage - 1).ToString()] != null)
                page_token = ViewState["PageToken" + (currentPage - 1).ToString()].ToString();
            else
                page_token = "";

            string APIKey, SecretKey;
            try
            {
                APIKey = txtAPIKey.Text;
                SecretKey = txtSecretKey.Text;
                OoyalaAssetDataResult cdata = new OoyalaAssetDataResult();
                cdata = OoyalaMediaUtils.GetLimitedAssets(SecretKey, APIKey, pageSize, searchBy, searchText, page_token, true, true);

                nextpage_url = cdata.next_page;
                if (nextpage_url != null)
                {
                    if (nextpage_url.IndexOf("page_token=") >= 0)
                        page_token = nextpage_url.Substring(nextpage_url.IndexOf(strPageToken) + strPageToken.Length);
                    else
                        page_token = "";
                }
                else
                    page_token = "";

                ViewState["PageToken" + currentPage.ToString()] = page_token;
                ViewState["MaxPageCount"] = currentPage;

                if (!string.IsNullOrEmpty(cdata.next_page))
                    btnNext.Visible = true;
                else
                    btnNext.Visible = false;

                var assetPreviewList = from itm in cdata.items select itm;

                dtgAssets.DataSource = assetPreviewList;
                dtgAssets.DataKeyNames = new string[] { "embed_code" };
                dtgAssets.DataBind();
                if (assetPreviewList.Count() == 0)
                {
                    lblPageCount.Text = string.Empty;
                }
            }
            catch(Exception e)
            {
                lblResults.Text = e.Message;
            }
        }
예제 #2
0
        private void ThumbnailViewBindData()
        {
            int          pageSize = PageColumns * PageRows;
            const string strPageToken = "page_token=";
            string       searchText, searchBy, nextpage_url, page_token, metaDataSearch;

            searchText = txtSearch.Text;
            searchBy   = ddlSearch.SelectedItem.Value;

            searchText     = txtSearch.Text.Equals("Enter Search Text") ? string.Empty : Server.HtmlEncode(WPHelper.escapteChar(txtSearch.Text.Trim()));
            searchBy       = ddlSearch.SelectedItem.Value;
            metaDataSearch = txtCustom.Text.Equals("Enter Metadata Key") ? string.Empty : Server.HtmlEncode(WPHelper.escapteChar(txtCustom.Text.Trim()));

            if (searchBy == "metadata")
            {
                if (string.IsNullOrEmpty(searchText) && !string.IsNullOrEmpty(metaDataSearch))
                {
                    searchBy = "metadata." + metaDataSearch;
                }
                if (string.IsNullOrEmpty(searchText) && string.IsNullOrEmpty(metaDataSearch))
                {
                    searchBy = string.Empty; // if both text empty means it is like general search
                }
                if (!string.IsNullOrEmpty(searchText) && !string.IsNullOrEmpty(metaDataSearch))
                {
                    searchBy = "metadata." + metaDataSearch;
                }
            }

            int currentPage = (int)ViewState["PageCount"];

            lblPageCount.Text = "Page No :" + currentPage.ToString();

            if (ViewState["PageToken" + (currentPage - 1).ToString()] != null)
            {
                page_token = ViewState["PageToken" + (currentPage - 1).ToString()].ToString();
            }
            else
            {
                page_token = "";
            }

            try
            {
                OoyalaAssetDataResult cdata = new OoyalaAssetDataResult();
                cdata = OoyalaMediaUtils.GetLimitedAssets(SecretKey, APIKey, pageSize, searchBy, searchText, page_token, false, false);

                nextpage_url = cdata.next_page;
                if (nextpage_url != null)
                {
                    if (nextpage_url.IndexOf("page_token=") >= 0)
                    {
                        page_token = nextpage_url.Substring(nextpage_url.IndexOf(strPageToken) + strPageToken.Length);
                    }
                    else
                    {
                        page_token = "";
                    }
                }
                else
                {
                    page_token = "";
                }

                ViewState["PageToken" + currentPage.ToString()] = page_token;
                ViewState["MaxPageCount"] = currentPage;

                if (!string.IsNullOrEmpty(cdata.next_page))
                {
                    btnNext.Visible = true;
                }
                else
                {
                    btnNext.Visible = false;
                }

                var assetPreviewList = from itm in cdata.items
                                       select new
                {
                    itm.name,
                    itm.preview_image_url
                };
                dtlAsssets.DataSource    = assetPreviewList;
                dtlAsssets.RepeatColumns = PageColumns;
                dtlAsssets.DataBind();

                if (assetPreviewList.Count() == 0)
                {
                    lblPageCount.Text       = string.Empty;
                    tblMessage.Visible      = true;
                    lblDataListMessage.Text = "No Data Found!";
                }
            }
            catch (Exception e)
            {
                lblResults.Text = e.Message;
            }
        }
        private void ThumbnailViewBindData()
        {
            int pageSize = PageColumns * PageRows;
            const string strPageToken = "page_token=";
            string searchText, searchBy, nextpage_url, page_token, metaDataSearch;
            searchText = txtSearch.Text;
            searchBy = ddlSearch.SelectedItem.Value;

            searchText = txtSearch.Text.Equals("Enter Search Text") ? string.Empty : Server.HtmlEncode(WPHelper.escapteChar(txtSearch.Text.Trim()));
            searchBy = ddlSearch.SelectedItem.Value;
            metaDataSearch = txtCustom.Text.Equals("Enter Metadata Key") ? string.Empty : Server.HtmlEncode(WPHelper.escapteChar(txtCustom.Text.Trim()));

            if (searchBy == "metadata")
            {
                if (string.IsNullOrEmpty(searchText) && !string.IsNullOrEmpty(metaDataSearch))
                {
                    searchBy = "metadata." + metaDataSearch;
                }
                if(string.IsNullOrEmpty(searchText) && string.IsNullOrEmpty(metaDataSearch))
                {
                    searchBy = string.Empty; // if both text empty means it is like general search
                }
                if (!string.IsNullOrEmpty(searchText) && !string.IsNullOrEmpty(metaDataSearch))
                {
                    searchBy = "metadata." + metaDataSearch;
                }
            }

            int currentPage = (int)ViewState["PageCount"];
            lblPageCount.Text = "Page No :" + currentPage.ToString();

            if (ViewState["PageToken" + (currentPage - 1).ToString()] != null)
                page_token = ViewState["PageToken" + (currentPage - 1).ToString()].ToString();
            else
                page_token = "";

            try
            {
                OoyalaAssetDataResult cdata = new OoyalaAssetDataResult();
                cdata = OoyalaMediaUtils.GetLimitedAssets(SecretKey, APIKey, pageSize, searchBy, searchText, page_token,false,false);

                nextpage_url = cdata.next_page;
                if (nextpage_url != null)
                {
                    if (nextpage_url.IndexOf("page_token=") >= 0)
                        page_token = nextpage_url.Substring(nextpage_url.IndexOf(strPageToken) + strPageToken.Length);
                    else
                        page_token = "";
                }
                else
                    page_token = "";

                ViewState["PageToken" + currentPage.ToString()] = page_token;
                ViewState["MaxPageCount"] = currentPage;

                if (!string.IsNullOrEmpty(cdata.next_page))
                    btnNext.Visible = true;
                else
                    btnNext.Visible = false;

                var assetPreviewList = from itm in cdata.items
                                       select new
                                       {
                                           itm.name,
                                           itm.preview_image_url
                                       };
                dtlAsssets.DataSource = assetPreviewList;
                dtlAsssets.RepeatColumns = PageColumns;
                dtlAsssets.DataBind();

                if (assetPreviewList.Count() == 0)
                {
                    lblPageCount.Text = string.Empty;
                    tblMessage.Visible = true;
                    lblDataListMessage.Text = "No Data Found!";
                }
            }
            catch (Exception e)
            {
                lblResults.Text = e.Message;
            }
        }
        private void DetailsViewBindData()
        {
            int pageSize = (PageLimit >= 10) ? PageLimit : 10;

            const string strPageToken = "page_token=";
            string       searchText, searchBy, nextpage_url, page_token, metaDataSearch;

            searchText     = txtSearch.Text.Equals("Enter Search Text")? string.Empty: Server.HtmlEncode(WPHelper.escapteChar(txtSearch.Text.Trim()));
            searchBy       = ddlSearch.SelectedItem.Value;
            metaDataSearch = txtCustom.Text.Equals("Enter Metadata Key")?string.Empty : Server.HtmlEncode(WPHelper.escapteChar(txtCustom.Text.Trim()));

            //if (searchBy == "metadata")
            //{
            //    searchBy = "metadata." + metaDataSearch;
            //}

            if (searchBy == "metadata")
            {
                if (string.IsNullOrEmpty(searchText) && !string.IsNullOrEmpty(metaDataSearch))
                {
                    searchBy = "metadata." + metaDataSearch;
                }
                if (string.IsNullOrEmpty(searchText) && string.IsNullOrEmpty(metaDataSearch))
                {
                    searchBy = string.Empty; // if both text empty means it is like general search, no need come for where conditions
                }
                if (!string.IsNullOrEmpty(searchText) && !string.IsNullOrEmpty(metaDataSearch))
                {
                    searchBy = "metadata." + metaDataSearch;
                }
            }


            int currentPage = (int)ViewState["PageCount"];

            lblPageCount.Text = "Page No :" + currentPage.ToString();

            if (ViewState["PageToken" + (currentPage - 1).ToString()] != null)
            {
                page_token = ViewState["PageToken" + (currentPage - 1).ToString()].ToString();
            }
            else
            {
                page_token = "";
            }

            string APIKey, SecretKey;

            try
            {
                APIKey    = txtAPIKey.Text;
                SecretKey = txtSecretKey.Text;
                OoyalaAssetDataResult cdata = new OoyalaAssetDataResult();
                cdata = OoyalaMediaUtils.GetLimitedAssets(SecretKey, APIKey, pageSize, searchBy, searchText, page_token, true, true);

                nextpage_url = cdata.next_page;
                if (nextpage_url != null)
                {
                    if (nextpage_url.IndexOf("page_token=") >= 0)
                    {
                        page_token = nextpage_url.Substring(nextpage_url.IndexOf(strPageToken) + strPageToken.Length);
                    }
                    else
                    {
                        page_token = "";
                    }
                }
                else
                {
                    page_token = "";
                }

                ViewState["PageToken" + currentPage.ToString()] = page_token;
                ViewState["MaxPageCount"] = currentPage;

                if (!string.IsNullOrEmpty(cdata.next_page))
                {
                    btnNext.Visible = true;
                }
                else
                {
                    btnNext.Visible = false;
                }

                var assetPreviewList = from itm in cdata.items select itm;

                dtgAssets.DataSource   = assetPreviewList;
                dtgAssets.DataKeyNames = new string[] { "embed_code" };
                dtgAssets.DataBind();
                if (assetPreviewList.Count() == 0)
                {
                    lblPageCount.Text = string.Empty;
                }
            }
            catch (Exception e)
            {
                lblResults.Text = e.Message;
            }
        }