public override void HandleExecute(ChainRequest request) { myRequest = (ButlerProcessRequest)request; var myBlobManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); IjsonKeyValue dotControlData = myBlobManager.GetProcessConfig(myRequest.ButlerRequest.ControlFileUri, myRequest.ProcessTypeId); switch (dotControlData.Read(DotControlConfigKeys.SelectAssetByType)) { case "assetid": myRequest.AssetId = dotControlData.Read(DotControlConfigKeys.SelectAssetByValue); break; default: var _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey); string AssetName = dotControlData.Read(DotControlConfigKeys.SelectAssetByValue); try { IAsset asset = (from m in _MediaServicesContext.Assets select m).Where(m => m.Name == AssetName).FirstOrDefault(); myRequest.AssetId = asset.Id; } catch (Exception X) { throw new Exception("Error Loading Asset by name " + AssetName); } break; } }
public override void HandleExecute(ChainRequest request) { myRequest = (ButlerProcessRequest)request; _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey); myBlobManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); allPorcessData = myBlobManager.GetProcessConfig(myRequest.ButlerRequest.ControlFileUri, myRequest.ProcessTypeId); //1. Select VTT IAsset asset = (from m in _MediaServicesContext.Assets select m).Where(m => m.Id == myRequest.AssetId).FirstOrDefault(); var vttFile = (from f in asset.AssetFiles select f).Where(f => f.Name.EndsWith(".vtt")).FirstOrDefault(); vttFile.Download(myRequest.ProcessInstanceId); string readText = File.ReadAllText(myRequest.ProcessInstanceId); System.IO.File.Delete(myRequest.ProcessInstanceId); //2. Cognitive Service IAzureMLTextAnalyticsClient myClient = new AzureMLTextAnalyticsClient(); Language myLanguage = (Language)Enum.Parse(typeof(Language), allPorcessData.Read(DotControlConfigKeys.TextAnalitycsStepLanguage)); string apiURL = allPorcessData.Read(DotControlConfigKeys.TextAnalitycsStepApiURL); string apiKey = allPorcessData.Read(DotControlConfigKeys.TextAnalitycsStepApiKey); FileType ft = FileType.VTT; string jsonResponse = myClient.keyPhrasesTxt(readText, myLanguage, ft, apiURL, apiKey); //3. Add File string assetFileName = "keyPhrases." + myRequest.ProcessInstanceId + ".txt"; var xf = asset.AssetFiles.Create(assetFileName); File.WriteAllText(assetFileName, jsonResponse); xf.Upload(assetFileName); File.Delete(myRequest.ProcessInstanceId); asset.Update(); }
public override void HandleExecute(Common.workflow.ChainRequest request) { myRequest = (ButlerProcessRequest)request; _MediaServiceContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey); StorageManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); buildlocator(); }
/// <summary> /// Step execution /// </summary> /// <param name="request"></param> public override void HandleExecute(ChainRequest request) { //My request myRequest = (ButlerProcessRequest)request; //Media Context _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey); //0 Encoding Helper myEncodigSupport = new EncoderSupport(_MediaServicesContext); //1. Storage Manager myStorageManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); //2. Load Original Asset (current on context) myAssetOriginal = (from m in _MediaServicesContext.Assets select m).Where(m => m.Id == myRequest.AssetId).FirstOrDefault(); if (IdenpotenceControl()) { ConvertMP4toSmooth(myAssetOriginal); } else { //Job Just wait for finish the current job myEncodigSupport.OnJobError += MyEncodigSupport_OnJobError; myEncodigSupport.JobUpdate += MyEncodigSupport_JobUpdate; myEncodigSupport.WaitJobFinish(currentJob.Id); } //Update AssetID myRequest.AssetId = currentJob.OutputMediaAssets.FirstOrDefault().Id; }
/// <summary> /// Update the status in Track table. /// </summary> /// <param name="request"></param> protected void UpdateProcessStatus(ChainRequest request, string txtInformation) { Trace.TraceInformation(txtInformation); IButlerStorageManager storageManager = BlobManagerFactory.CreateBlobManager(request.ProcessConfigConn); storageManager.PersistProcessStatus(request); }
public override void HandleExecute(ChainRequest request) { myRequest = (ButlerProcessRequest)request; blobManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); IjsonKeyValue stepConfig = new jsonKeyValue(StepConfiguration); //Lead External Step from DLL try { blobManager.parkingNewBinaries(); myCustomStepExecution = buildCustomStep(stepConfig.Read("AssemblyName"), stepConfig.Read("TypeName")); } catch (Exception X) { sendError("MediaButlerCustomStep Loading error : " + X.Message); } //Transform ButlerProcessRequest to ICustomRequest myCustomRequest = buildRequest(myRequest); //Execute sync try { myCustomStepExecution.execute(myCustomRequest); //UPdate myRequest myRequest.AssetId = myCustomRequest.AssetId; } catch (Exception X) { sendError("MediaButlerCustomStep Execute error " + X.Message); } //Update status UpdateProcessStatus(myRequest, "Finish Custome Execution"); }
public override void HandleExecute(ChainRequest request) { //1. Step Setup myRequest = (ButlerProcessRequest)request; _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey); myEncodigSupport = new EncoderSupport(_MediaServicesContext); myBlobManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); IjsonKeyValue dotControlData = myBlobManager.GetDotControlData(myRequest.ButlerRequest.ControlFileUri); IjsonKeyValue processData = new jsonKeyValue(myBlobManager.GetButlerConfigurationValue(ProcessConfigKeys.DefualtPartitionKey, myRequest.ProcessTypeId + ".config")); IjsonKeyValue allPorcessData = myBlobManager.GetProcessConfig(myRequest.ButlerRequest.ControlFileUri, myRequest.ProcessTypeId); //2. Get Current Asset IAsset asset = (from m in _MediaServicesContext.Assets select m).Where(m => m.Id == myRequest.AssetId).FirstOrDefault(); //3. JOB parameters string OutputAssetsName = asset.Name + "_mbGridEncode"; string JobName = string.Format("GridEncodeStep_{1}_{0}", myRequest.ProcessInstanceId, asset.Name); string MediaProcessorName = myEncodigSupport.GetMediaProcessorName(allPorcessData, DotControlConfigKeys.GridEncodeStepMediaProcessorName, "Media Encoder Standard"); string[] encodeConfigurations = myEncodigSupport.GetLoadEncodignProfiles(dotControlData, processData, DotControlConfigKeys.GridEncodeStepEncodeConfigList, myRequest.ButlerRequest.MezzanineFiles, myRequest.ProcessConfigConn, this.StepConfiguration); //4. Execute JOB and Wait IJob currentJob = myEncodigSupport.ExecuteGridJob(OutputAssetsName, JobName, MediaProcessorName, encodeConfigurations, "Grid Task", asset.Id, MyEncodigSupport_OnJobError, MyEncodigSupport_JobUpdate); //9. Update AssetID myRequest.AssetId = currentJob.OutputMediaAssets.FirstOrDefault().Id; }
public string[] GetLoadEncodignProfiles(IjsonKeyValue dotControlData, IjsonKeyValue processData, List <string> MezzanineFiles, string ProcessConfigConn, string StepConfiguration) { var myBlobManager = BlobManagerFactory.CreateBlobManager(ProcessConfigConn); string[] EncodingProfiles; int profileId = 0; if (!string.IsNullOrEmpty(dotControlData.Read(DotControlConfigKeys.GridEncodeStepEncodeConfigList))) { //Definition encoders on instance level DotcControl File var Xlist = dotControlData.ReadArray(DotControlConfigKeys.GridEncodeStepEncodeConfigList).ToArray(); EncodingProfiles = new string[Xlist.Count()]; foreach (var profile in Xlist) { string url = MezzanineFiles.Where(f => f.ToLower().EndsWith(profile.ToString().ToLower())).FirstOrDefault(); if (url == null) { throw new Exception("Encoding profile is not on file package!"); } EncodingProfiles[profileId] = myBlobManager.ReadTextBlob(new Uri(url)); profileId += 1; } } else { if (!string.IsNullOrEmpty(processData.Read(DotControlConfigKeys.GridEncodeStepEncodeConfigList))) { //Definition Encoders profile on process level var profileNameList = processData.ReadArray(DotControlConfigKeys.GridEncodeStepEncodeConfigList).ToArray(); EncodingProfiles = new string[profileNameList.Count()]; foreach (var profileName in profileNameList) { EncodingProfiles[profileId] = myBlobManager.ReadTextBlob("mediabutlerbin", "encoderdefinitions/" + profileName); profileId += 1; } } else { //Definition on Process definition string encodigProfileFileName; if (string.IsNullOrEmpty(StepConfiguration)) { //Use default encodigProfileFileName = "H264 Multiple Bitrate 1080p.json"; } else { //Use process level definition encodigProfileFileName = StepConfiguration; } EncodingProfiles = new string[] { LoadEncodeProfile(encodigProfileFileName, ProcessConfigConn) }; } } return(EncodingProfiles); }
private void Setup() { //this.mySenGridData = new SenGridData(); //mySenGridData = Newtonsoft.Json.JsonConvert.DeserializeObject<SenGridData>(this.StepConfiguration); var myBlobManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); IjsonKeyValue myConfig = myBlobManager.GetProcessConfig(myRequest.ButlerRequest.ControlFileUri, myRequest.ProcessTypeId); string jsonTx = myConfig.Read(DotControlConfigKeys.SendGridStepConfig); mySenGridData = JsonConvert.DeserializeObject <SenGridData>(jsonTx); }
static public string[] internalValues(ButlerProcessRequest xRequest) { var bm = BlobManagerFactory.CreateBlobManager(xRequest.ProcessConfigConn); string[] internalValues = new string[10]; internalValues[0] = xRequest.ProcessInstanceId; internalValues[1] = xRequest.ProcessTypeId; internalValues[2] = xRequest.ProcessConfigConn; internalValues[3] = bm.GetBlobSasUri(xRequest.ButlerRequest.MezzanineFiles.FirstOrDefault(), 5); internalValues[4] = VideoName(xRequest.ButlerRequest.MezzanineFiles.FirstOrDefault()); return(internalValues); }
public override void HandleExecute(Common.workflow.ChainRequest request) { myRequest = (ButlerProcessRequest)request; IButlerStorageManager resource = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); foreach (string url in myRequest.ButlerRequest.MezzanineFiles) { resource.DeleteBlobFile(url); Trace.TraceInformation("{0} in process {1} processId {2} file {3} deleted", this.GetType().FullName, myRequest.ProcessTypeId, myRequest.ProcessInstanceId, url); } if (!string.IsNullOrEmpty(myRequest.ButlerRequest.ControlFileUri)) { resource.DeleteBlobFile(myRequest.ButlerRequest.ControlFileUri); Trace.TraceInformation("{0} in process {1} processId {2} file {3} deleted", this.GetType().FullName, myRequest.ProcessTypeId, myRequest.ProcessInstanceId, myRequest.ButlerRequest.ControlFileUri); } }
public override void HandleExecute(ChainRequest request) { myRequest = (ButlerProcessRequest)request; blobManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); sshCommandConfig myConfig = Newtonsoft.Json.JsonConvert.DeserializeObject <sshCommandConfig>(this.StepConfiguration); myBridge = sshCommandStep.constructBridge(myConfig); string customSshCommand = myBridge.buildCommand(sshCommandStep.internalValues(myRequest), myRequest.MetaData); myRequest.Log.Add(string.Format("[0] Start to execute at {1} Command {2}", myRequest.ProcessInstanceId, DateTime.Now.ToString(), customSshCommand)); myBridge.execCommand(customSshCommand); string message = string.Format("[{0}] {3} Result {1}: {2}", myRequest.ProcessInstanceId, myBridge.ResultCode, myBridge.Result, DateTime.Now.ToString()); myRequest.Log.Add(message); }
public override void HandleExecute(ChainRequest request) { myRequest = (ButlerProcessRequest)request; blobManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); string jsonControlFile = blobManager.ReadTextBlob(new Uri(myRequest.ButlerRequest.ControlFileUri)); dotControlConfig = new jsonKeyValue(jsonControlFile); if (dotControlConfig.Read(MediaButler.Common.DotControlConfigKeys.httpNotificationStepGetOnFinishUrl) != "") { //GET HttpGetNotification(); } else { //POST HttpPostNotification(); } }
public override void HandleExecute(ChainRequest request) { //1. Setup Step myRequest = (ButlerProcessRequest)request; _MediaServicesContext = new CloudMediaContext(new MediaServicesCredentials(myRequest.MediaAccountName, myRequest.MediaAccountKey)); myEncodigSupport = new EncoderSupport(_MediaServicesContext); myBlobManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); allPorcessData = myBlobManager.GetProcessConfig(myRequest.ButlerRequest.ControlFileUri, myRequest.ProcessTypeId); //2. Create Jobs definition List <IJobConfiguration> myJobsDefinition = GetJobConfig(myRequest.ProcessInstanceId, myRequest.AssetId, ""); //3. Execute myEncodigSupport.ExecuteMultiJobTaskEncode(myJobsDefinition, myRequest.ProcessInstanceId, MyEncodigSupport_OnJobError, MyEncodigSupport_JobUpdate); //4. Update context with output asset ID myRequest.AssetId = UpdateOutPut(myJobsDefinition, this.consolidateId); //5. Copy all asset files to Output asset and delete all temp Asset ConsolidateOutputs(myJobsDefinition, consolidateId); }
private void Setup() { myStorageManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); //TODO: load configuration from control // mange control worng properties //string jsonControl = myStorageManager.ReadTextBlob(myRequest.ButlerRequest.ControlFileUri); //myConfig =null; //try //{ // if (!string.IsNullOrEmpty(jsonControl)) // { // //instance process configuration // myConfig = Newtonsoft.Json.JsonConvert.DeserializeObject<PremiunConfig>(jsonControl); // } // else // { // if (!string.IsNullOrEmpty(this.StepConfiguration)) // { // //general process configuration // myConfig = Newtonsoft.Json.JsonConvert.DeserializeObject<PremiunConfig>(this.StepConfiguration); // } // } //} //catch (Exception) //{ // Trace.TraceWarning("PremiumEncodingStep configuration Error, it will use default"); //} if (myConfig == null) { //default configuration myConfig = new PremiunConfig() { AssetWorkflowID = null, EncodingJobName = "Media Bulter Premium Workflow encoding job " + myRequest.ProcessInstanceId, EncodigTaskName = "Media Bulter Premium Workflow encoding task" + myRequest.ProcessTypeId }; } }
private void Setup() { IBlobStorageManager resource = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); string jsonControl = resource.ReadTextBlob(myRequest.ButlerRequest.ControlFileUri); myConfig = null; try { if (!string.IsNullOrEmpty(jsonControl)) { //instance process configuration myConfig = Newtonsoft.Json.JsonConvert.DeserializeObject <PremiunConfig>(jsonControl); } else { if (!string.IsNullOrEmpty(this.StepConfiguration)) { //general process configuration myConfig = Newtonsoft.Json.JsonConvert.DeserializeObject <PremiunConfig>(this.StepConfiguration); } } } catch (Exception) { Trace.TraceWarning("PremiumEncodingStep configuration Error, it will use default"); } if (myConfig == null) { //default configuration myConfig = new PremiunConfig() { AssetWorkflowID = null, EncodingJobName = "Media Bulter Premium Workflow encoding job", EncodigTaskName = "Media Bulter Premium Workflow encoding task" }; } }
public override void HandleExecute(ChainRequest request) { myRequest = (ButlerProcessRequest)request; _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey); myBlobManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); //IjsonKeyValue dotControlData = myBlobManager.GetDotControlData(myRequest.ButlerRequest.ControlFileUri); IjsonKeyValue dotControlData = myBlobManager.GetProcessConfig(myRequest.ButlerRequest.ControlFileUri, myRequest.ProcessTypeId); string searchServiceName = dotControlData.Read(DotControlConfigKeys.InjectTTMLSearchServiceName); string adminApiKey = dotControlData.Read(DotControlConfigKeys.InjectTTMLadminApiKey); string indexName = dotControlData.Read(DotControlConfigKeys.InjectTTMLindexName); SearchServiceClient serviceClient = new SearchServiceClient(searchServiceName, new SearchCredentials(adminApiKey)); if (!serviceClient.Indexes.Exists(indexName)) { CreateVideoTextIndex(serviceClient, indexName); } IAsset asset = (from m in _MediaServicesContext.Assets select m).Where(m => m.Id == myRequest.AssetId).FirstOrDefault(); UploadTTML(serviceClient, indexName, asset); }
public override void HandleExecute(ChainRequest request) { myRequest = (ButlerProcessRequest)request; _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey); myBlobManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); IAsset asset = (from m in _MediaServicesContext.Assets select m).Where(m => m.Id == myRequest.AssetId).FirstOrDefault(); //Asset CloudStorageAccount assetStorageCount = CloudStorageAccount.Parse(myRequest.MediaStorageConn); CloudBlobClient assetClient = assetStorageCount.CreateCloudBlobClient(); CloudBlobContainer assetContainer = assetClient.GetContainerReference(asset.Uri.Segments[1]); //Stage Storage CloudStorageAccount MezzamineStorageCount = CloudStorageAccount.Parse(myRequest.ButlerRequest.StorageConnectionString); CloudBlobClient MezzamineClient = MezzamineStorageCount.CreateCloudBlobClient(); CloudBlobContainer MezzamineContainer = MezzamineClient.GetContainerReference(myRequest.ButlerRequest.WorkflowName); string filterXmlFileName = "_azuremediaservices.config"; string filterXmlBlobName = string.Format("Processing/{0}/{1}", myRequest.ProcessInstanceId, filterXmlFileName); CloudBlockBlob azureMediaServicesConfig = MezzamineContainer.GetBlockBlobReference(filterXmlBlobName); myBlobManager.CopyBlob(azureMediaServicesConfig, assetContainer, filterXmlFileName); }
/// <summary> /// Set MP4 as primary file /// </summary> private void setPrimaryFile() { string myPrimaryFile = null; IAssetFile mp4 = null; if (!string.IsNullOrEmpty(myRequest.ButlerRequest.ControlFileUri)) { // IButlerStorageManager resource = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn); string jsonControl = resource.ReadTextBlob(new Uri(myRequest.ButlerRequest.ControlFileUri)); if (!string.IsNullOrEmpty(jsonControl)) { IjsonKeyValue myControl = new jsonKeyValue(jsonControl); myPrimaryFile = myControl.Read(DotControlConfigKeys.IngestMultiMezzamineFilesPrimaryFile); } } IEncoderSupport myEncodigSupport = new EncoderSupport(MediaContext); if (!string.IsNullOrEmpty(myPrimaryFile)) { mp4 = currentAsset.AssetFiles.Where(f => f.Name.ToLower() == myPrimaryFile.ToLower()).FirstOrDefault(); } if (mp4 == null) { mp4 = currentAsset.AssetFiles.Where(f => f.Name.ToLower().EndsWith(".mp4")).FirstOrDefault(); } if (mp4 != null) { myEncodigSupport.SetPrimaryFile(currentAsset, mp4); } else { Trace.TraceWarning("{0} setPrimaryFile {2} processId {1}, has not MP4 file", this.GetType().FullName, myRequest.ProcessInstanceId, myRequest.ProcessTypeId); } }