コード例 #1
0
        public void DoJobStats()
        {
            JobInfo       JR = new JobInfo(MyJob);
            StringBuilder SB = JR.GetStats();
            var           tokenDisplayForm = new EditorXMLJSON("Job report", SB.ToString(), false, false, false);

            tokenDisplayForm.Display();
        }
コード例 #2
0
        public void DoJobStats()
        {
            JobInfo       JR = new JobInfo(MyJob, _mainform._accountname);
            StringBuilder SB = JR.GetStats();
            var           tokenDisplayForm = new EditorXMLJSON(AMSExplorer.Properties.Resources.JobInformation_DoJobStats_JobReport, SB.ToString(), false, false, false);

            tokenDisplayForm.Display();
        }
コード例 #3
0
 private void SeeRhozetExample()
 {
     try
     {
         XDocument doc = XDocument.Load(Path.Combine(Application.StartupPath + Constants.PathConfigFiles, "SampleSemaphoreRhozet.xml"));
         var       tokenDisplayForm = new EditorXMLJSON("Sample Semaphore file", doc.Declaration.ToString() + Environment.NewLine + doc.ToString(), false, false, false);
         tokenDisplayForm.Display();
     }
     catch
     {
     }
 }
コード例 #4
0
 private void SeeJSONExample()
 {
     try
     {
         var sr = new StreamReader(Path.Combine(Application.StartupPath + Constants.PathConfigFiles, "SampleSemaphore.json"));
         var tokenDisplayForm = new EditorXMLJSON("Sample Semaphore JSON", sr.ReadToEnd(), false, false, false);
         tokenDisplayForm.Display();
     }
     catch
     {
     }
 }
コード例 #5
0
 private void copyPreviewURLToClipboard_Click(object sender, EventArgs e)
 {
     string preview = ReturnSelectedChannels().FirstOrDefault().Preview.Endpoints.FirstOrDefault().Url.AbsoluteUri;
     EditorXMLJSON DisplayForm = new EditorXMLJSON("Preview URL", preview, false, false, false);
     DisplayForm.Display();
 }
コード例 #6
0
        private async void DoGenerateManifest()
        {
            try
            {
                var smildata = Program.LoadAndUpdateManifestTemplate(myAsset);

                var editform = new EditorXMLJSON(string.Format("Online edit of '{0}'", smildata.FileName), smildata.Content, true, false);

                if (editform.Display() == DialogResult.OK)
                { // OK

                    string tempPath = System.IO.Path.GetTempPath();
                    string filePath = Path.Combine(tempPath, smildata.FileName);

                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);
                    }

                    StreamWriter outfile = new StreamWriter(filePath, false, Encoding.UTF8);
                    outfile.Write(editform.TextData);
                    outfile.Close();

                    progressBarUpload.Visible = true;
                    buttonClose.Enabled = false;

                    await Task.Factory.StartNew(() => ProcessUploadFileToAsset(Path.GetFileName(filePath), filePath, myAsset));

                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);
                    }

                    // Refresh the asset.
                    myAsset = Mainform._context.Assets.Where(a => a.Id == myAsset.Id).FirstOrDefault();
                    AssetInfo.SetFileAsPrimary(myAsset, smildata.FileName);
                }
            }
            catch
            {

            }
            progressBarUpload.Visible = false;
            buttonClose.Enabled = true;
            ListAssetFiles();
            BuildLocatorsTree();
        }
コード例 #7
0
        private void SeeClearKey(string key)
        {


            var editform = new EditorXMLJSON("Clear key value", key.ToString(), false, false);
            editform.Display();

        }
コード例 #8
0
        /// <summary>
        /// 
        /// </summary>
        private async void DoEditFile()
        {
            var SelectedAssetFiles = ReturnSelectedAssetFiles();

            if (SelectedAssetFiles.Count == 1 && SelectedAssetFiles.FirstOrDefault() != null)
            {
                IAssetFile assetFileToEdit = SelectedAssetFiles.FirstOrDefault();

                if (assetFileToEdit.ContentFileSize > 500 * 1024)
                {
                    MessageBox.Show("File is to big to edit it online.");
                    return;
                }

                try
                {
                    progressBarUpload.Maximum = 100;
                    progressBarUpload.Visible = true;
                    string tempPath = System.IO.Path.GetTempPath();
                    string filePath = Path.Combine(tempPath, assetFileToEdit.Name);

                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);
                    }
                    await Task.Factory.StartNew(() => ProcessDownloadFileToAsset(assetFileToEdit, filePath));

                    progressBarUpload.Visible = false;

                    StreamReader streamReader = new StreamReader(filePath);
                    Encoding fileEncoding = streamReader.CurrentEncoding;
                    string datastring = streamReader.ReadToEnd();
                    streamReader.Close();

                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);
                    }

                    var editform = new EditorXMLJSON(string.Format("Online edit of '{0}'", assetFileToEdit.Name), datastring, true, false);
                    if (editform.Display() == DialogResult.OK)
                    { // OK

                        StreamWriter outfile = new StreamWriter(filePath, false, fileEncoding);

                        outfile.Write(editform.TextData);
                        outfile.Close();

                        string assetFileName = assetFileToEdit.Name;
                        bool assetFilePrimary = assetFileToEdit.IsPrimary;
                        assetFileToEdit.Delete();

                        progressBarUpload.Visible = true;
                        buttonClose.Enabled = false;

                        await Task.Factory.StartNew(() => ProcessUploadFileToAsset(Path.GetFileName(filePath), filePath, myAsset));

                        if (File.Exists(filePath))
                        {
                            File.Delete(filePath);
                        }

                        if (assetFilePrimary)
                        {
                            AssetInfo.SetFileAsPrimary(myAsset, assetFileName);
                        }
                        // Refresh the asset.
                        myAsset = Mainform._context.Assets.Where(a => a.Id == myAsset.Id).FirstOrDefault();
                        progressBarUpload.Visible = false;
                        buttonClose.Enabled = true;
                        ListAssetFiles();
                    }
                }

                catch
                {
                    MessageBox.Show("Error when accessing/editing asset file.");
                }

            }
        }
コード例 #9
0
        private void WatchFolder_Load(object sender, EventArgs e)
        {
            // folder
            textBoxFolder.Text = _WatchFolderSettings.FolderPath;

            // activation
            radioButtonON.Checked = _WatchFolderSettings.IsOn;

            // delete file
            checkBoxDeleteFile.Checked = _WatchFolderSettings.DeleteFile;

            // Rohzet xml file
            checkBoxProcessXMLRohzet.Checked = _WatchFolderSettings.ProcessRohzetXML;

            // JSON semaphore file
            checkBoxProcessJSONSemaphore.Checked = _WatchFolderSettings.ProcessJSONSemaphore;

            // process asset
            checkBoxRunJobTemplate.Checked = (_WatchFolderSettings.JobTemplate != null);

            // add asset(s) to process
            if (_WatchFolderSettings.TypeInputExtraInput != TypeInputExtraInput.None)
            {
                checkBoAddAssetsToInput.Checked = true;
                if (_WatchFolderSettings.TypeInputExtraInput == TypeInputExtraInput.SelectedAssets)
                {
                    radioButtonInsertSelectedAssets.Checked = true;
                }
                else
                {
                    radioButtonInsertWorkflowAsset.Checked = true;
                }
            }

            // publish
            checkBoxPublishOAssets.Checked = _WatchFolderSettings.PublishOutputAssets;
            checkBoxPublishOAssets.Text    = string.Format(checkBoxPublishOAssets.Text, Properties.Settings.Default.DefaultLocatorDurationDaysNew);

            // send email
            checkBoxSendEMail.Checked = _WatchFolderSettings.SendEmailToRecipient != null;
            textBoxEMail.Text         = _WatchFolderSettings.SendEmailToRecipient;

            // other
            buttonOk.Enabled  = string.IsNullOrWhiteSpace(textBoxFolder.Text) ? false : true;
            labelWarning.Text = string.Empty;


            checkBoxCallAPI.Checked = _WatchFolderSettings.CallAPIUrl != null;
            textBoxAPIUrl.Text      = _WatchFolderSettings.CallAPIUrl;

            if (_WatchFolderSettings.CallAPJson != null)
            {
                BodyDisplayForm = new EditorXMLJSON("Body", _WatchFolderSettings.CallAPJson, true, false, true);
            }
            else
            {
                // Body for the API Call
                try
                {
                    StreamReader streamReader = new StreamReader(Path.Combine(Application.StartupPath + Constants.PathConfigFiles, "SampleWatchFolderJSONCall.json"));
                    BodyDisplayForm = new EditorXMLJSON("Body", streamReader.ReadToEnd(), true, false, true);
                    streamReader.Close();
                }
                catch
                {
                }
            }
        }
コード例 #10
0
        private void SeeClearKey(string key)
        {
            var editform = new EditorXMLJSON("Value", key.ToString(), false, false);

            editform.Display();
        }
コード例 #11
0
 public void Initialize()
 {
     myPremiumXML = new EditorXMLJSON();
 }
コード例 #12
0
 private void SeeValueInEditor(string dataname, string key)
 {
     var editform = new EditorXMLJSON(dataname, key, false, false);
     editform.Display();
 }
コード例 #13
0
        private void SeeValueInEditor(string dataname, string key)
        {
            EditorXMLJSON editform = new EditorXMLJSON(dataname, key, false, false);

            editform.Display();
        }
コード例 #14
0
 private void DoCopyIngestURL()
 {
     var im = ReturnSelectedIngestManifests().FirstOrDefault();
     if (im != null)
     {
         string myurl = im.BlobStorageUriForUpload;
         var form = new EditorXMLJSON("Bulk Ingest URL", myurl, false, false, false);
         form.Display();
     }
 }
コード例 #15
0
        private void DoProcessCreateBulkIngestAndEncryptFiles(string IngestName, string IngestStorage, List<BulkUpload.BulkAsset> assetFiles, string assetStorage, AssetCreationOptions creationoption, string encryptToFolder, bool GenerateAzCopy, bool GenerateSigniant, List<string> SigniantServers, string SigniantAPIKey, bool GenerateAspera)
        {
            TextBoxLogWriteLine("Creating bulk ingest '{0}'...", IngestName);
            IIngestManifest manifest = _context.IngestManifests.Create(IngestName, IngestStorage);

            // Create the assets that will be associated with this bulk ingest manifest
            foreach (var asset in assetFiles)
            {
                try
                {
                    IAsset destAsset = _context.Assets.Create(asset.AssetName, assetStorage, creationoption);
                    IIngestManifestAsset bulkAsset = manifest.IngestManifestAssets.Create(destAsset, asset.AssetFiles);
                }
                catch (Exception ex)
                {
                    TextBoxLogWriteLine("Bulk: Error when declaring asset '{0}'.", asset.AssetName, true);
                    TextBoxLogWriteLine(ex);
                    return;
                }
            }
            TextBoxLogWriteLine("Bulk: {0} asset(s) / {1} file(s) declared for bulk ingest container '{2}'.", assetFiles.Count, manifest.Statistics.PendingFilesCount, manifest.Name);


            // Encryption of files
            bool Error = false;
            if (creationoption == AssetCreationOptions.StorageEncrypted)
            {

                TextBoxLogWriteLine("Encryption of asset files for bulk upload...");
                try
                {
                    manifest.EncryptFilesAsync(encryptToFolder, CancellationToken.None).Wait();
                    TextBoxLogWriteLine("Encryption of asset files done to folder {0}.", encryptToFolder);
                    Process.Start(encryptToFolder);
                }
                catch
                {
                    TextBoxLogWriteLine("Error when encrypting files to folder '{0}'.", encryptToFolder, true);
                    Error = true;
                }
            }

            if (!Error)
            {
                TextBoxLogWriteLine("You can upload the file(s) to {0}", manifest.BlobStorageUriForUpload);
                if (creationoption == AssetCreationOptions.StorageEncrypted)
                {
                    TextBoxLogWriteLine("Encrypted files are in {0}", encryptToFolder);
                }
                if (GenerateAspera)
                {
                    string commandline = GenerateAsperaUrl(manifest);
                    var form = new EditorXMLJSON("Aspera Ingest URL", commandline, false, false, false);
                    form.Display();
                }

                if (GenerateSigniant)
                {
                    string commandline = GenerateSigniantCommandLine(manifest, assetFiles, creationoption == AssetCreationOptions.StorageEncrypted, encryptToFolder, SigniantServers, SigniantAPIKey);
                    var form = new EditorXMLJSON("Signiant Command Line", commandline, false, false, false);
                    form.Display();
                }

                if (GenerateAzCopy)
                {
                    string commandline = GenerateAzCopyCommandLine(manifest, assetFiles, creationoption == AssetCreationOptions.StorageEncrypted, encryptToFolder);
                    var form = new EditorXMLJSON("AzCopy Command Line", commandline, false, false, false);
                    form.Display();
                }
            }
            DoRefreshGridIngestManifestV(false);
        }
コード例 #16
0
        private void DoCopyChannelInputURLToClipboard(bool secondary = false, bool https = false)
        {
            IChannel channel = ReturnSelectedChannels().FirstOrDefault();
            string absuri;
            bool Error = false;

            if (secondary && channel.Input.Endpoints.Count > 1) // secondary
            {
                absuri = channel.Input.Endpoints[1].Url.AbsoluteUri;
            }
            else // primary
            {
                absuri = channel.Input.Endpoints.FirstOrDefault().Url.AbsoluteUri;
            }

            if (https)
            {
                if (channel.Input.StreamingProtocol == StreamingProtocol.FragmentedMP4)
                {
                    absuri.Replace("http://", "https://");
                }
                else
                {
                    MessageBox.Show("SSL is only possible for Smooth Streaming input.", "SSL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Error = true;
                }
            }

            if (!Error) //System.Windows.Forms.Clipboard.SetText(absuri);
            {
                string label = string.Format("Input URL ({0})", secondary ? "secondary" : "primary");
                EditorXMLJSON DisplayForm = new EditorXMLJSON(label, absuri, false, false, false);
                DisplayForm.Display();
            }
        }
コード例 #17
0
        private void DoGetTestToken()
        {

            bool Error = true;
            IAsset MyAsset = ReturnSelectedAssetsFromProgramsOrAssets().FirstOrDefault();
            if (MyAsset != null)
            {
                DynamicEncryption.TokenResult testToken = DynamicEncryption.GetTestToken(MyAsset, _context, displayUI: true);

                if (!string.IsNullOrEmpty(testToken.TokenString))
                {
                    TextBoxLogWriteLine("The authorization test token (with Bearer) is :\n{0}", Constants.Bearer + testToken.TokenString);
                    var tokenDisplayForm = new EditorXMLJSON("Authorization test token", Constants.Bearer + testToken.TokenString, false, false);
                    tokenDisplayForm.Display();
                    Error = false;
                }

            }
            if (Error) MessageBox.Show("Error when generating the test token", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
コード例 #18
0
ファイル: EditorXMLJSON.cs プロジェクト: zhshen/HuaweiAMS
 public void Initialize()
 {
     myPremiumXML = new EditorXMLJSON(editMode: true, showSamplePremium: true);
 }
コード例 #19
0
 public void Initialize()
 {
     myPremiumXML = new EditorXMLJSON(editMode: true, showSamplePremium: true);
 }
コード例 #20
0
        private void DoCopyOutputURLAssetOrProgramToClipboard()
        {
            IAsset asset = ReturnSelectedAssetsFromProgramsOrAssets().FirstOrDefault();
            if (asset != null)
            {
                AssetInfo AI = new AssetInfo(asset);
                IEnumerable<Uri> ValidURIs = AI.GetValidURIs();
                if (ValidURIs != null && ValidURIs.FirstOrDefault() != null)
                {
                    string url = ValidURIs.FirstOrDefault().AbsoluteUri;

                    if (_context.StreamingEndpoints.Count() > 1 || (_context.StreamingEndpoints.FirstOrDefault() != null && _context.StreamingEndpoints.FirstOrDefault().CustomHostNames.Count > 0) || _context.Filters.Count() > 0 || (asset.AssetFilters.Count() > 0))
                    {
                        var form = new ChooseStreamingEndpoint(_context, asset, url);
                        if (form.ShowDialog() == DialogResult.OK)
                        {
                            url = AssetInfo.RW(new Uri(url), form.SelectStreamingEndpoint, form.SelectedFilters, form.ReturnHttps, form.ReturnSelectCustomHostName, form.ReturnStreamingProtocol, form.ReturnHLSAudioTrackName, form.ReturnHLSNoAudioOnlyMode).ToString();
                        }
                        else
                        {
                            return;
                        }
                    }
                    var tokenDisplayForm = new EditorXMLJSON("Output URL", url, false, false, false);
                    tokenDisplayForm.Display();
                }
                else
                {
                    MessageBox.Show(string.Format("No valid URL is available for asset '{0}'.", asset.Name), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
コード例 #21
0
        private async void buttonPickupAccount_Click(object sender, EventArgs e)
        {
            AddAMSAccount1 addaccount1 = new AddAMSAccount1();

            if (addaccount1.ShowDialog() == DialogResult.OK)
            {
                if (addaccount1.SelectedMode == AddAccountMode.BrowseSubscriptions)
                {
                    environment = addaccount1.GetEnvironment();

                    AuthenticationContext authContext = new AuthenticationContext(
                        // authority:  environment.Authority,
                        authority: environment.AADSettings.AuthenticationEndpoint.ToString() + "common",
                        validateAuthority: true
                        );

                    AuthenticationResult accessToken;
                    try
                    {
                        accessToken = await authContext.AcquireTokenAsync(
                            resource : environment.AADSettings.TokenAudience.ToString(),
                            clientId : environment.ClientApplicationId,
                            redirectUri : new Uri("urn:ietf:wg:oauth:2.0:oob"),
                            parameters : new PlatformParameters(addaccount1.SelectUser ? PromptBehavior.SelectAccount : PromptBehavior.Auto)
                            );
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    TokenCredentials credentials = new TokenCredentials(accessToken.AccessToken, "Bearer");

                    SubscriptionClient subscriptionClient = new SubscriptionClient(environment.ArmEndpoint, credentials);
                    Microsoft.Rest.Azure.IPage <Microsoft.Azure.Management.ResourceManager.Models.Subscription> subscriptions = subscriptionClient.Subscriptions.List();



                    // tenants browsing
                    myTenants tenants = new myTenants();
                    string    URL     = environment.ArmEndpoint + "tenants?api-version=2017-08-01";

                    HttpClient client = new HttpClient();
                    client.DefaultRequestHeaders.Remove("Authorization");
                    client.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken.AccessToken);
                    HttpResponseMessage response = await client.GetAsync(URL);

                    if (response.IsSuccessStatusCode)
                    {
                        string str = await response.Content.ReadAsStringAsync();

                        tenants = (myTenants)JsonConvert.DeserializeObject(str, typeof(myTenants));
                    }
                    AddAMSAccount2Browse addaccount2 = new AddAMSAccount2Browse(credentials, subscriptions, environment, tenants.value, new PlatformParameters(addaccount1.SelectUser ? PromptBehavior.SelectAccount : PromptBehavior.Auto));

                    if (addaccount2.ShowDialog() == DialogResult.OK)
                    {
                        // Getting Media Services accounts...
                        AzureMediaServicesClient mediaServicesClient = new AzureMediaServicesClient(environment.ArmEndpoint, credentials);

                        CredentialsEntryV3 entry = new CredentialsEntryV3(addaccount2.selectedAccount,
                                                                          environment,
                                                                          addaccount1.SelectUser ? PromptBehavior.SelectAccount : PromptBehavior.Auto,
                                                                          false,
                                                                          addaccount2.selectedTenantId,
                                                                          false
                                                                          );
                        CredentialList.MediaServicesAccounts.Add(entry);
                        AddItemToListviewAccounts(entry);

                        SaveCredentialsToSettings();
                    }
                    else
                    {
                        return;
                    }
                }


                // Get info from the Azure CLI JSON
                else if (addaccount1.SelectedMode == AddAccountMode.FromAzureCliJson)
                {
                    string        example = @"{
  ""AadClientId"": ""00000000-0000-0000-0000-000000000000"",
  ""AadEndpoint"": ""https://login.microsoftonline.com"",
  ""AadSecret"": ""00000000-0000-0000-0000-000000000000"",
  ""AadTenantId"": ""00000000-0000-0000-0000-000000000000"",
  ""AccountName"": ""amsaccount"",
  ""ArmAadAudience"": ""https://management.core.windows.net/"",
  ""ArmEndpoint"": ""https://management.azure.com/"",
  ""Region"": ""West Europe"",
  ""ResourceGroup"": ""amsResourceGroup"",
  ""SubscriptionId"": ""00000000-0000-0000-0000-000000000000""
}";
                    EditorXMLJSON form    = new EditorXMLJSON("Enter the JSON output of Azure Cli Service Principal creation (az ams account sp create)", example, true, false, true, "The Service Principal secret is stored encrypted in the application settings.");

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        JsonFromAzureCli json = null;
                        try
                        {
                            json = (JsonFromAzureCli)JsonConvert.DeserializeObject(form.TextData, typeof(JsonFromAzureCli));
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Error reading the json", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        string resourceId  = string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Media/mediaservices/{2}", json.SubscriptionId, json.ResourceGroup, json.AccountName);
                        string AADtenantId = json.AadTenantId;

                        ActiveDirectoryServiceSettings aadSettings = new ActiveDirectoryServiceSettings()
                        {
                            AuthenticationEndpoint = json.AadEndpoint,
                            TokenAudience          = json.ArmAadAudience,
                            ValidateAuthority      = true
                        };

                        AzureEnvironment env = new AzureEnvironment(AzureEnvType.Custom)
                        {
                            AADSettings = aadSettings, ArmEndpoint = json.ArmEndpoint
                        };

                        CredentialsEntryV3 entry = new CredentialsEntryV3(
                            new SubscriptionMediaService(resourceId, json.AccountName, null, null, json.Region),
                            env,
                            PromptBehavior.Auto,
                            true,
                            AADtenantId,
                            false
                            )
                        {
                            ADSPClientId          = json.AadClientId,
                            ClearADSPClientSecret = json.AadSecret
                        };

                        CredentialList.MediaServicesAccounts.Add(entry);
                        AddItemToListviewAccounts(entry);

                        SaveCredentialsToSettings();
                    }
                    else
                    {
                        return;
                    }
                }
                else if (addaccount1.SelectedMode == AddAccountMode.ManualEntry)
                {
                    AddAMSAccount2Manual form = new AddAMSAccount2Manual();
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        string accountnamecc = form.textBoxAMSResourceId.Text.Split('/').Last();

                        CredentialsEntryV3 entry = new CredentialsEntryV3(
                            new SubscriptionMediaService(form.textBoxAMSResourceId.Text, accountnamecc, null, null, form.textBoxLocation.Text),
                            addaccount1.GetEnvironment(),
                            PromptBehavior.Auto,
                            form.radioButtonAADServicePrincipal.Checked,
                            form.textBoxAADtenantId.Text,
                            true
                            );

                        CredentialList.MediaServicesAccounts.Add(entry);
                        AddItemToListviewAccounts(entry);

                        SaveCredentialsToSettings();
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }
コード例 #22
0
 public void Initialize()
 {
     myPremiumXML = new EditorXMLJSON();
 }