void LoadMedia()
        {
            try
            {
                var assets  = OoyalaMediaUtils.GetLiveAssets(SecretKey, APIKey);
                var players = OoyalaMediaUtils.GetAllPlayers(SecretKey, APIKey);
                if (assets == null)
                {
                    ErrorMessage = "<font color=red>No Media Assets found!</font>";
                    return;
                }
                if (players == null)
                {
                    ErrorMessage = "<font color=red>No Media players found!</font>";
                    return;
                }
                ddlMediaAssets.DataSource     = assets;
                ddlMediaAssets.DataTextField  = "name";
                ddlMediaAssets.DataValueField = "embed_code";
                ddlMediaAssets.DataBind();

                var orderedPlayers = from p in players orderby p.name select p;
                ddlMediaPlayers.DataSource     = orderedPlayers;
                ddlMediaPlayers.DataTextField  = "name";
                ddlMediaPlayers.DataValueField = "id";
                ddlMediaPlayers.DataBind();
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
            }
        }
示例#2
0
 private void SaveLabelSettings()
 {
     try
     {
         if (!string.IsNullOrEmpty(txtlblID.Text))
         {
             string    id = txtlblID.Text;
             Hashtable hs = new Hashtable();
             hs.Add("name", txtlblName.Text);
             var res = OoyalaMediaUtils.EditLabel(SecretKey, APIKey, id, hs);
             if (string.IsNullOrEmpty(res))
             {
                 lblResults.Text             = "<font color=red> " + WPHelper.permissionErrorMsg + " </font>";
                 WPHelper.permissionErrorMsg = string.Empty;
                 return;
             }
             BindTreviewData();
             txtlblName.Text = string.Empty;
             Response.Redirect(SPContext.Current.File.Name);
         }
     }
     catch (Exception e)
     {
         lblResults.Text = e.Message;
     }
 }
示例#3
0
        private void AddNewLabel()
        {
            try
            {
                string    id = string.Empty;
                Hashtable hs = new Hashtable();
                hs.Add("name", "New Label");

                if (trvView.CheckedNodes.Count == 1)
                {
                    id = trvView.CheckedNodes[0].Value;
                    hs.Add("parent_id", id);
                }

                var res = OoyalaMediaUtils.AddNewLabel(SecretKey, APIKey, hs);
                if (string.IsNullOrEmpty(res))
                {
                    //lblResults.Text = "<font color=red>You do not have permission to perform this operation.</font>";
                    lblResults.Text             = "<font color=red> " + WPHelper.permissionErrorMsg + " </font>";
                    WPHelper.permissionErrorMsg = string.Empty;
                    return;
                }

                BindTreviewData();
                txtlblName.Text = string.Empty;
                Response.Redirect(SPContext.Current.File.Name);
            }
            catch (Exception e)
            {
                lblResults.Text = e.Message;
            }
        }
示例#4
0
        private void SaveDBConfiguration()
        {
            string PartnerCode = txtPartnerCode.Text;
            string SecretKey   = txtSecretKey.Text;
            string APIKey      = txtAPIKey.Text;

            bool isValid = OoyalaMediaUtils.ValidateAPIInfo(SecretKey, APIKey);

            if (isValid)
            {
                string UserID = SPContext.Current.Web.CurrentUser.LoginName;

                if (LoginEntity.SaveConfiguration(PartnerCode, SecretKey, APIKey, UserID))
                {
                    lblResults.Text = "<font color=green>API Info is saved in DB successfully!</font>";
                }
                else
                {
                    lblResults.Text = "<font color=red>API Info is not able to save in Database<font>";
                }
            }
            else
            {
                lblResults.Text = "<font color=red>Please provide valid API details!</font>";
            }
        }
示例#5
0
        private OoyalaData.Players.Item PlayerSettingsToHashTable(string playerId, int EditRowIndex)
        {
            try
            {
                CheckBox chkShowShareDigg          = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowShareDigg");
                CheckBox chkShowShareEmailToFriend = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowShareEmailToFriend");
                CheckBox chkShowShareFacebook      = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowShareFacebook");
                CheckBox chkAdCountdown            = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkAdCountdown");
                CheckBox chkShowBitrateButton      = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowBitrateButton");
                CheckBox chkShowChannelButton      = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowChannelButton");
                CheckBox chkShowShareGrabEmbedCode = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowShareGrabEmbedCode");
                CheckBox chkReplay                    = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkReplay");
                CheckBox chkShowInfoButton            = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowInfoButton");
                CheckBox chkShowInfoExposeDescription = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowInfoExposeDescription");
                CheckBox chkShowInfoExposeProvider    = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowInfoExposeProvider");
                CheckBox chkShowInfoExposeTitle       = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowInfoExposeTitle");
                CheckBox chkShowShareButton           = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowShareButton");
                CheckBox chkShowVolumeButton          = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowVolumeButton");
                CheckBox chkShowShareToTwitter        = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowShareToTwitter");
                CheckBox chkShowShareLinkURL          = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkShowShareLinkURL");
                CheckBox chkAlwaysShowScrubber        = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkAlwaysShowScrubber");
                CheckBox chkBufferOnPause             = (CheckBox)playerGrid.Rows[EditRowIndex].FindControl("chkBufferOnPause");
                TextBox  txtplayerName                = (TextBox)playerGrid.Rows[EditRowIndex].FindControl("txtplayerName");

                OoyalaData.Players.Item player = OoyalaMediaUtils.GetPlayer(SecretKey, APIKey, playerId);
                player.name = txtplayerName.Text;

                player.ooyala_branding.digg_sharing                   = chkShowShareDigg.Checked;
                player.ooyala_branding.email_sharing                  = chkShowShareEmailToFriend.Checked;
                player.ooyala_branding.facebook_sharing               = chkShowShareFacebook.Checked;
                player.ooyala_branding.show_ad_countdown              = chkAdCountdown.Checked;
                player.ooyala_branding.show_bitrate_button            = chkShowBitrateButton.Checked;
                player.ooyala_branding.show_channel_button            = chkShowChannelButton.Checked;
                player.ooyala_branding.show_embed_button              = chkShowShareGrabEmbedCode.Checked;
                player.ooyala_branding.show_end_screen_replay_button  = chkReplay.Checked;
                player.ooyala_branding.show_info_button               = chkShowInfoButton.Checked;
                player.ooyala_branding.show_info_screen_description   = chkShowInfoExposeDescription.Checked;
                player.ooyala_branding.show_info_screen_homepage_link = chkShowInfoExposeProvider.Checked;
                player.ooyala_branding.show_info_screen_title         = chkShowInfoExposeTitle.Checked;
                player.ooyala_branding.show_share_button              = chkShowShareButton.Checked;
                player.ooyala_branding.show_volume_button             = chkShowVolumeButton.Checked;
                player.ooyala_branding.twitter_sharing                = chkShowShareToTwitter.Checked;
                player.ooyala_branding.url_sharing = chkShowShareLinkURL.Checked;
                player.scrubber.always_show        = chkAlwaysShowScrubber.Checked;
                player.playback.buffer_on_pause    = chkBufferOnPause.Checked;

                return(player);
            }
            catch (Exception e)
            {
                lblResults.Text = e.Message;
                return(null);
            }
        }
示例#6
0
 private void EditMediaPlayer(int NewEditIndex)
 {
     try
     {
         string id = (string)playerGrid.DataKeys[NewEditIndex].Value;
         playerGrid.EditIndex = NewEditIndex;
         BindData();
         OoyalaData.Players.Item itm = OoyalaMediaUtils.GetPlayer(SecretKey, APIKey, id);
         LoadSelectedPlayerSettings(itm, NewEditIndex);
     }
     catch (Exception e)
     {
         lblResults.Text = e.Message;
     }
 }
示例#7
0
 private void BindTreviewData()
 {
     try
     {
         List <OoyalaData.Labels.Item> labels = OoyalaMediaUtils.GetAllLabels(SecretKey, APIKey);
         trvView.Nodes.Clear();
         TreeNode tn = new TreeNode();
         AddLevel(ref tn, labels, null);
         //trvView.ExpandAll();
         trvView.CollapseAll();
     }
     catch (Exception e)
     {
         lblResults.Text = e.Message;
     }
 }
示例#8
0
    /// <summary>
    /// Get API Key and Secret Key info from Database based on Loggedin User
    /// </summary>
    /// <param name="UserID">Logged in User ID</param>
    /// <returns>API Validation Result</returns>
    public static int LoadConfiguration(string UserID, ref Hashtable hs)
    {
        //TextWriter tw = new StreamWriter(@"E:\logfile.txt",);
        string        ConnectionString = ConfigurationManager.AppSettings["OoyalaConnectionString"];
        string        queryString      = "Select PartnerCode,SecretKey,APIKey From tblUser Where UserID=@UserID";
        SqlConnection con = new SqlConnection(ConnectionString);
        SqlCommand    cmd = new SqlCommand(queryString, con);

        cmd.Parameters.AddWithValue("UserID", UserID);
        //tw.WriteLine("User ID : " + UserID);
        try
        {
            con.Open();
            SqlDataReader rdr = cmd.ExecuteReader();
            //tw.WriteLine("Hash table count: " + hs.Count);
            if (rdr.Read())
            {
                //tw.WriteLine("Reader : " + rdr.Read());
                hs.Add("PartnerCode", rdr["PartnerCode"].ToString());
                hs.Add("SecretKey", rdr["SecretKey"].ToString());
                hs.Add("APIKey", rdr["APIKey"].ToString());

                if (OoyalaMediaUtils.ValidateAPIInfo(rdr["SecretKey"].ToString(), rdr["APIKey"].ToString()))
                {
                    return(ValidationSuccess);
                }
                else
                {
                    return(ValidationFailed);
                }
            }
            else
            {
                //tw.WriteLine("else : " );
                return(DBRetriveError);
            }
        }
        catch (Exception e)
        {
            //tw.WriteLine("Exception Message " + e.Message);
            //tw.Close();
            //tw.Dispose();

            throw e;
        }
    }
示例#9
0
 private void BindLabelsTreviewData()
 {
     try
     {
         List <OoyalaData.Labels.Item> labels = OoyalaMediaUtils.GetAllLabels(SecretKey, APIKey);
         trvAsset.Nodes.Clear();
         TreeNode nd = new TreeNode();
         nd.SelectAction = TreeNodeSelectAction.None;
         //trvAsset.Nodes.Add(nd);
         AddLevel(ref nd, labels, null);
         trvAsset.CollapseAll();
         //trvAsset.ExpandAll();
     }
     catch (Exception e)
     {
         lblResults.Text = e.Message;
     }
 }
示例#10
0
 private void DeleteMediaPlayer(string id)
 {
     try
     {
         var res = OoyalaMediaUtils.DeletePlayer(SecretKey, APIKey, id);
         if (!res)
         {
             lblResults.Text             = "<font color=red> " + WPHelper.permissionErrorMsg + " </font>";
             WPHelper.permissionErrorMsg = string.Empty;
             return;
         }
         BindData();
         Response.Redirect(SPContext.Current.File.Name);
     }
     catch (Exception e)
     {
         lblResults.Text = e.Message;
     }
 }
示例#11
0
        private void BindData()
        {
            try
            {
                List <OoyalaData.Players.Item> players = OoyalaMediaUtils.GetAllPlayers(SecretKey, APIKey);

                var playerlist = from itm in players
                                 orderby itm.is_default descending, itm.name ascending
                //orderby itm.name ascending
                    select new { itm.id, itm.name, itm.is_default };
                playerGrid.DataSource   = playerlist;
                playerGrid.DataKeyNames = new string[] { "id" };
                playerGrid.DataBind();
            }
            catch (Exception e)
            {
                lblResults.Text = e.Message;
            }
        }
示例#12
0
        private void populateAssetSelection()
        {
            try
            {
                var assets  = OoyalaMediaUtils.GetAllAssets(SecretKey, APIKey);
                var players = OoyalaMediaUtils.GetAllPlayers(SecretKey, APIKey);
                if (assets == null)
                {
                    mAssetSelectionList.Enabled = false;
                    errorMessage.Controls.Add(new Label()
                    {
                        Text = "No Assets returned. Is the plug-in installed with the correct API Key and Secret?"
                    });
                    return;
                }
                if (players == null)
                {
                    mPlayerList.Enabled = false;
                    errorMessage.Controls.Add(new Label()
                    {
                        Text = "No Media Players returned. Is the plug-in installed with the correct API Key and Secret?"
                    });
                    return;
                }
                mAssetSelectionList.DataSource     = assets;
                mAssetSelectionList.DataTextField  = "name";
                mAssetSelectionList.DataValueField = "embed_code";
                mAssetSelectionList.DataBind();

                mPlayerList.DataSource     = players;
                mPlayerList.DataTextField  = "name";
                mPlayerList.DataValueField = "id";
                mPlayerList.DataBind();
            }
            catch
            {
                errorMessage.Controls.Add(new Label()
                {
                    Text = "Error has occured. Is the plug-in installed with the correct API Key and Secret?"
                });
            }
        }
        private void DeleteMediaAsset(string id)
        {
            string APIKey, SecretKey;

            try
            {
                APIKey    = txtAPIKey.Text;
                SecretKey = txtSecretKey.Text;
                var res = OoyalaMediaUtils.DeleteMediaAsset(SecretKey, APIKey, id);
                if (!res)
                {
                    lblResults.Text             = "<font color=red> " + WPHelper.permissionErrorMsg + " </font>";
                    WPHelper.permissionErrorMsg = string.Empty;
                    return;
                }
            }
            catch (Exception e)
            {
                lblResults.Text = e.Message;
            }
        }
示例#14
0
 private void DeleteLabel(string treeNodeValue)
 {
     try
     {
         if (!string.IsNullOrEmpty(treeNodeValue))
         {
             //OoyalaMediaUtils.DeleteLabel(SecretKey, APIKey, treeNodeValue);
             var res = OoyalaMediaUtils.DeleteLabel(SecretKey, APIKey, treeNodeValue);
             if (!res)
             {
                 lblResults.Text             = "<font color=red> " + WPHelper.permissionErrorMsg + " </font>";
                 WPHelper.permissionErrorMsg = string.Empty;
                 return;
             }
             Response.Redirect(SPContext.Current.File.Name);
         }
     }
     catch (Exception e)
     {
         lblResults.Text = e.Message;
     }
 }
        private void EditMediaAsset(int NewEditIndex)
        {
            //if (!(ShowLabels && ShowCustomMetadata)) return;

            string APIKey, SecretKey;

            try
            {
                string id = (string)dtgAssets.DataKeys[NewEditIndex].Value;
                APIKey    = txtAPIKey.Text;
                SecretKey = txtSecretKey.Text;

                if (ShowLabels)
                {
                    TreeView trvAsset = (TreeView)dtgAssets.Rows[NewEditIndex].FindControl("trvAsset");
                    List <OoyalaData.Labels.Item> allLabels     = OoyalaMediaUtils.GetAllLabels(SecretKey, APIKey);
                    List <OoyalaData.Labels.Item> checkedSource = OoyalaMediaUtils.GetAssetLabels(SecretKey, APIKey, id);

                    TreeNode nd = new TreeNode();
                    AddLevel(ref trvAsset, ref nd, allLabels, checkedSource, null);
                    //trvAsset.ExpandAll();
                    trvAsset.CollapseAll();
                }

                if (ShowCustomMetadata)
                {
                    GridView  dtgMetadata = (GridView)dtgAssets.Rows[NewEditIndex].FindControl("dtgMetadata");
                    Hashtable hsMD        = OoyalaMediaUtils.GetAssetCustomMetadata(SecretKey, APIKey, id);
                    DataTable tbl         = CreateMetadataTable(hsMD);
                    dtgMetadata.DataSource = tbl;
                    dtgMetadata.DataBind();
                }
            }
            catch (Exception e)
            {
                lblResults.Text = e.Message;
            }
        }
示例#16
0
 private void AddNewMediaPlayer()
 {
     if (!IsAllowAdd)
     {
         return;
     }
     try
     {
         var res = OoyalaMediaUtils.AddNewPlayer(SecretKey, APIKey);
         if (string.IsNullOrEmpty(res))
         {
             lblResults.Text             = "<font color=red> " + WPHelper.permissionErrorMsg + " </font>";
             WPHelper.permissionErrorMsg = string.Empty;
             return;
         }
         BindData();
         Response.Redirect(SPContext.Current.File.Name);
     }
     catch (Exception e)
     {
         lblResults.Text = e.Message;
     }
 }
示例#17
0
        private void SaveMediaPlayerSettings(int EditRowIndex)
        {
            string id = (string)playerGrid.DataKeys[EditRowIndex].Value.ToString();

            try
            {
                OoyalaData.Players.Item player = PlayerSettingsToHashTable(id, EditRowIndex);
                var res = OoyalaMediaUtils.EditPlayer(SecretKey, APIKey, player);
                if (string.IsNullOrEmpty(res))
                {
                    lblResults.Text             = "<font color=red> " + WPHelper.permissionErrorMsg + " </font>";
                    WPHelper.permissionErrorMsg = string.Empty;
                    return;
                }

                playerGrid.EditIndex = -1;
                BindData();
                Response.Redirect(SPContext.Current.File.Name);
            }
            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;
            }
        }
示例#19
0
        private void SaveMediaAssetSettings()
        {
            try
            {
                UPLOAD_LIMIT = UPLOAD_LIMIT * WPHelper.fileSize();

                string url = SPContext.Current.Web.Url.ToString() + "/" + trvSharePoint.CheckedNodes[0].Value;

                Stream stream = OoyalaMediaUtils.GetFileStream(url);

                if (stream == null)
                {
                    lblResults.Text = "<font color=red>Please select valid file!</font>";
                    ResetFields();
                    return;
                }

                if (stream.Length > UPLOAD_LIMIT)
                {
                    lblResults.Text = "<font color=red>The file could not be uploaded. File size should not be greater than " + Convert.ToString(WPHelper.fileSize()) + " MB</font>";
                    ResetFields();
                    return;
                }

                Hashtable hs = new Hashtable();
                if (!string.IsNullOrEmpty(txtTitle.Text))
                {
                    hs.Add("name", txtTitle.Text);
                }
                else
                {
                    hs.Add("name", trvSharePoint.CheckedNodes[0].Text);
                }

                string filename = trvSharePoint.CheckedNodes[0].Text;
                hs.Add("file_name", filename);

                string astType     = Path.GetExtension(filename).ToUpper();
                bool   isValidType = WPHelper.fileType(astType);

                //switch (astType)
                //{
                //    case ".AVI":
                //    case ".MPG":
                //    case ".MOV":
                //    case ".RM" :
                //    case ".MP4":
                //    case ".WMV":
                //    case ".WM" :
                //        hs.Add("asset_type", "video");
                //        break;
                //    case ".WAV":
                //    case ".AIF":
                //    case ".MP3":
                //    case ".MID":
                //    case ".RA" :
                //        hs.Add("asset_type", "audio");
                //        break;
                //    default:
                //        isValidType = true;
                //        break;
                //}
                if (!isValidType)
                {
                    lblResults.Text = "<font color=red>File Type is not supported!</font>";
                    ResetFields();
                    return;
                }
                else
                {
                    hs.Add("asset_type", "video");
                }

                hs.Add("file_size", stream.Length.ToString());

                if (!string.IsNullOrEmpty(txtDesc.Text))
                {
                    hs.Add("description", txtDesc.Text);
                }

                if (!string.IsNullOrEmpty(ddlPostUploadStatus.SelectedValue))
                {
                    hs.Add("post_processing_status", ddlPostUploadStatus.SelectedValue);
                }

                string id = OoyalaMediaUtils.NewMediaAsset(SecretKey, APIKey, hs);

                if (string.IsNullOrEmpty(id))
                {
                    lblResults.Text             = "<font color=red> " + WPHelper.permissionErrorMsg + " </font>";
                    WPHelper.permissionErrorMsg = string.Empty;
                    return;
                }

                OoyalaMediaUtils.NewMediaUploadStream(SecretKey, APIKey, id, stream);

                if (ShowLabels)
                {
                    ArrayList arl = new ArrayList();
                    foreach (TreeNode tn in trvAsset.CheckedNodes)
                    {
                        if (!string.IsNullOrEmpty(tn.Value))
                        {
                            arl.Add(tn.Value);
                        }
                    }
                    OoyalaMediaUtils.ApplyLabelsToAssets(SecretKey, APIKey, id, arl);
                }

                if (ShowCustomMetadata)
                {
                    Hashtable hsMD = new Hashtable();
                    foreach (GridViewRow rw in dtgMetadata.Rows)
                    {
                        TextBox txtCustomMetadataKey   = (TextBox)rw.FindControl("txtCustomMetadataKey");
                        TextBox txtCustomMetadataValue = (TextBox)rw.FindControl("txtCustomMetadataValue");
                        if (!(string.IsNullOrEmpty(txtCustomMetadataKey.Text) && string.IsNullOrEmpty(txtCustomMetadataValue.Text)))
                        {
                            if (!hsMD.ContainsKey(txtCustomMetadataKey.Text))
                            {
                                hsMD.Add(txtCustomMetadataKey.Text, txtCustomMetadataValue.Text);
                            }
                        }
                    }
                    OoyalaMediaUtils.ApplyCustomMetadataToAssets(SecretKey, APIKey, id, hsMD);
                }
                OoyalaMediaUtils.SetMediaFileStatus(SecretKey, APIKey, id, "uploaded");
                lblResults.Text = "<font color=green>File Successfully Uploaded!</font>";
                ResetFields();
            }
            catch (Exception e)
            {
                lblResults.Text = e.Message;
            }
        }
        private void SaveMediaAssetSettings()
        {
            try
            {
                string    filename = Path.GetFileName(fuAsset.FileName);
                Hashtable hs       = new Hashtable();

                if (!string.IsNullOrEmpty(txtTitle.Text))
                {
                    hs.Add("name", txtTitle.Text);
                }
                else
                {
                    hs.Add("name", filename);
                }

                hs.Add("file_name", filename);

                string astType     = Path.GetExtension(filename).ToUpper();
                bool   isValidType = WPHelper.fileType(astType);

                //switch (astType)
                //{
                //    case ".AVI":
                //    case ".MPG":
                //    case ".MOV":
                //    case ".RM":
                //    case ".MP4":
                //    case ".WMV":
                //    case ".WM":
                //        hs.Add("asset_type", "video");
                //        break;
                //    case ".WAV":
                //    case ".AIF":
                //    case ".MP3":
                //    case ".MID":
                //    case ".RA":
                //    case ".AAC":
                //        hs.Add("asset_type", "audio");
                //        break;
                //    default:
                //        isValidType = true;
                //        break;
                //}

                if (!isValidType)
                {
                    lblResults.Text = "<font color=red>File Type is not supported!</font>";
                    ResetFields();
                    return;
                }
                else
                {
                    hs.Add("asset_type", "video");
                }

                hs.Add("file_size", fuAsset.PostedFile.ContentLength.ToString());

                if (!string.IsNullOrEmpty(txtDesc.Text))
                {
                    hs.Add("description", txtDesc.Text);
                }

                if (!string.IsNullOrEmpty(ddlPostUploadStatus.SelectedValue))
                {
                    hs.Add("post_processing_status", ddlPostUploadStatus.SelectedValue);
                }

                string id = OoyalaMediaUtils.NewMediaAsset(SecretKey, APIKey, hs);

                if (string.IsNullOrEmpty(id))
                {
                    lblResults.Text             = "<font color=red> " + WPHelper.permissionErrorMsg + " </font>";
                    WPHelper.permissionErrorMsg = string.Empty;
                    ResetFields();
                    return;
                }

                //if (string.IsNullOrEmpty(id))
                //{
                //    lblResults.Text = "<font color=red>Not able to create New Media Asset</font>";
                //    ResetFields();
                //    return;
                //}

                OoyalaMediaUtils.NewMediaUploadStream(SecretKey, APIKey, id, fuAsset.PostedFile.InputStream);

                if (ShowLabels)
                {
                    ArrayList arl         = new ArrayList();
                    bool      isAvailable = false;
                    foreach (TreeNode tn in trvAsset.CheckedNodes)
                    {
                        if (!string.IsNullOrEmpty(tn.Value))
                        {
                            arl.Add(tn.Value);
                            isAvailable = true;
                        }
                    }
                    if (isAvailable)
                    {
                        OoyalaMediaUtils.ApplyLabelsToAssets(SecretKey, APIKey, id, arl);
                    }
                }

                if (ShowCustomMetadata)
                {
                    Hashtable hsMD        = new Hashtable();
                    bool      isAvailable = false;
                    foreach (GridViewRow rw in dtgMetadata.Rows)
                    {
                        TextBox txtCustomMetadataKey   = (TextBox)rw.FindControl("txtCustomMetadataKey");
                        TextBox txtCustomMetadataValue = (TextBox)rw.FindControl("txtCustomMetadataValue");
                        if (!(string.IsNullOrEmpty(txtCustomMetadataKey.Text) && string.IsNullOrEmpty(txtCustomMetadataValue.Text)))
                        {
                            isAvailable = true;
                            if (!hsMD.ContainsKey(txtCustomMetadataKey.Text))
                            {
                                hsMD.Add(txtCustomMetadataKey.Text, txtCustomMetadataValue.Text);
                            }
                        }
                    }
                    if (isAvailable)
                    {
                        OoyalaMediaUtils.ApplyCustomMetadataToAssets(SecretKey, APIKey, id, hsMD);
                    }
                }

                OoyalaMediaUtils.SetMediaFileStatus(SecretKey, APIKey, id, "uploaded");
                lblResults.Text = "<font color=green>File Successfully Uploaded!</font>";
                ResetFields();
            }
            catch (Exception e)
            {
                lblResults.Text = e.Message;
            }
        }
        private void SaveMediaAssetSettings(int EditRowIndex)
        {
            string id = (string)dtgAssets.DataKeys[EditRowIndex].Value.ToString();
            string APIKey, SecretKey;

            try
            {
                APIKey    = txtAPIKey.Text;
                SecretKey = txtSecretKey.Text;

                if (AllowEdit)
                {
                    Hashtable hs           = new Hashtable();
                    TextBox   txtAssetName = (TextBox)dtgAssets.Rows[EditRowIndex].FindControl("txtAssetName");
                    if (!string.IsNullOrEmpty(txtAssetName.Text))
                    {
                        hs.Add("name", txtAssetName.Text);
                    }

                    TextBox txtAssetDesc = (TextBox)dtgAssets.Rows[EditRowIndex].FindControl("txtAssetDesc");
                    if (!string.IsNullOrEmpty(txtAssetDesc.Text))
                    {
                        hs.Add("description", txtAssetDesc.Text);
                    }
                    else
                    {
                        hs.Add("description", txtAssetDesc.Text);
                    }

                    var res = OoyalaMediaUtils.ApplyMetadataToAssets(SecretKey, APIKey, id, hs);
                    if (string.IsNullOrEmpty(res))
                    {
                        lblResults.Text             = "<font color=red> " + WPHelper.permissionErrorMsg + " </font>";
                        WPHelper.permissionErrorMsg = string.Empty;
                        return;
                    }

                    if (ShowLabels)
                    {
                        TreeView  trvAsset = (TreeView)dtgAssets.Rows[EditRowIndex].FindControl("trvAsset");
                        ArrayList arl      = new ArrayList();
                        foreach (TreeNode tn in trvAsset.CheckedNodes)
                        {
                            if (!string.IsNullOrEmpty(tn.Value))
                            {
                                arl.Add(tn.Value);
                            }
                        }
                        OoyalaMediaUtils.DeleteLabelsFromAssets(SecretKey, APIKey, id);
                        OoyalaMediaUtils.ApplyLabelsToAssets(SecretKey, APIKey, id, arl);
                    }

                    if (ShowCustomMetadata)
                    {
                        GridView  dtgMetadata = (GridView)dtgAssets.Rows[EditRowIndex].FindControl("dtgMetadata");
                        Hashtable hsMD        = new Hashtable();
                        foreach (GridViewRow rw in dtgMetadata.Rows)
                        {
                            TextBox txtCustomMetadataKey   = (TextBox)rw.FindControl("txtCustomMetadataKey");
                            TextBox txtCustomMetadataValue = (TextBox)rw.FindControl("txtCustomMetadataValue");
                            if (!(string.IsNullOrEmpty(txtCustomMetadataKey.Text) && string.IsNullOrEmpty(txtCustomMetadataValue.Text)))
                            {
                                if (!hsMD.ContainsKey(txtCustomMetadataKey.Text))
                                {
                                    hsMD.Add(txtCustomMetadataKey.Text, txtCustomMetadataValue.Text);
                                }
                            }
                        }
                        OoyalaMediaUtils.ApplyCustomMetadataToAssets(SecretKey, APIKey, id, hsMD);
                    }
                }
            }
            catch (Exception e)
            {
                lblResults.Text = e.Message;
            }
        }
示例#22
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;
            }
        }