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();
        }
        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();
        }
Ejemplo n.º 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
     {
     }
 }
Ejemplo n.º 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
     {
     }
 }
 private void SeeValueInEditor(string dataname, string key)
 {
     var editform = new EditorXMLJSON(dataname, key, false, false);
     editform.Display();
 }
 void ButtonXML_Click(object sender, EventArgs e)
 {
     myPremiumXML.Display();
 }
        private void SeeValueInEditor(string dataname, string key)
        {
            EditorXMLJSON editform = new EditorXMLJSON(dataname, key, false, false);

            editform.Display();
        }
Ejemplo n.º 8
0
 private void JsonBodyDisplayEdit()
 {
     BodyDisplayForm.Display();
 }
        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();
        }
        private void SeeClearKey(string key)
        {


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

        }
        /// <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.");
                }

            }
        }
        private void SeeClearKey(string key)
        {
            var editform = new EditorXMLJSON("Value", key.ToString(), false, false);

            editform.Display();
        }
        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);
                }
            }
        }
 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();
 }
 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();
     }
 }
        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);
        }
        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();
            }
        }
        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);
        }