示例#1
0
        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();
        }
示例#2
0
 public override void HandleExecute(Common.workflow.ChainRequest request)
 {
     myRequest = (ButlerProcessRequest)request;
     Setup();
     //Add index info to request LOG, sas access to all Files (index output files)
     LogInfo();
 }
 public override void HandleCompensation(MediaButler.Common.workflow.ChainRequest request)
 {
     //Standar Step Compesnation, only LOG
     myRequest = (ButlerProcessRequest)request;
     string errorTxt = string.Format("[{0}] process Type {1} instance {2} has not compensation method", this.GetType().FullName, myRequest.ProcessTypeId, myRequest.ProcessInstanceId);
     Trace.TraceWarning(errorTxt);
 }
 public override void HandleExecute(Common.workflow.ChainRequest request)
 {
     myRequest = (ButlerProcessRequest)request;
     Setup();
     //Add index info to request LOG, sas access to all Files (index output files)
     LogInfo();
 }
示例#5
0
        public override void HandleCompensation(Common.workflow.ChainRequest request)
        {
            myRequest = (ButlerProcessRequest)request;
            string txtTrace;

            if (currentJob != null)
            {
                foreach (IAsset item in currentJob.OutputMediaAssets)
                {
                    txtTrace = string.Format("[{0}] process Type {1} instance {2} deleted Asset id={3}", this.GetType().FullName, myRequest.ProcessTypeId, myRequest.ProcessInstanceId, item.Id);
                    item.Delete();
                    Trace.TraceWarning(txtTrace);
                }
            }
            if (myAssetOriginal != null)
            {
                txtTrace = string.Format("[{0}] process Type {1} instance {2} deleted Asset id={3}", this.GetType().FullName, myRequest.ProcessTypeId, myRequest.ProcessInstanceId, myAssetOriginal.Id);

                myAssetOriginal.Delete();
                Trace.TraceWarning(txtTrace);
            }

            if ((myWorkflow != null) && (string.IsNullOrEmpty(myConfig.AssetWorkflowID)))
            {
                txtTrace = string.Format("[{0}] process Type {1} instance {2} deleted Asset id={3}", this.GetType().FullName, myRequest.ProcessTypeId, myRequest.ProcessInstanceId, myWorkflow.Id);
                myWorkflow.Delete();
                Trace.TraceWarning(txtTrace);
            }
        }
        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");
        }
示例#7
0
        public override void HandleCompensation(ChainRequest request)
        {
            myRequest = (ButlerProcessRequest)request;
            string errorTxt = string.Format("[{0}] process Type {1} instance {2} has not compensation method", this.GetType().FullName, myRequest.ProcessTypeId, myRequest.ProcessInstanceId);

            Trace.TraceWarning(errorTxt);
        }
        public override void HandleCompensation(MediaButler.Common.workflow.ChainRequest request)
        {
            //Standar Step Compesnation, only LOG
            myRequest = (ButlerProcessRequest)request;
            string errorTxt = string.Format("[{0}] process Type {1} instance {2} has not compensation method", this.GetType().FullName, myRequest.ProcessTypeId, myRequest.ProcessInstanceId);

            Trace.TraceWarning(errorTxt);
        }
示例#9
0
 public override void HandleExecute(Common.workflow.ChainRequest request)
 {
     //Butler Request
     myRequest = (ButlerProcessRequest)request;
     //Setup Step
     Setup();
     //Trigger Replica
     TriggerReplica();
 }
 public override void HandleExecute(Common.workflow.ChainRequest request)
 {
     //Butler Request
     myRequest = (ButlerProcessRequest)request;
     //Setup Step
     Setup();
     //Trigger Replica
     TriggerReplica();
 }
 public override void HandleExecute(Common.workflow.ChainRequest request)
 {
     myRequest = (ButlerProcessRequest)request;
     Setup();
     //Run index job
     IJob xJob = RunIndexingJob();
     //Update the asset ID with the Id of output asset.
     myRequest.AssetId = xJob.OutputMediaAssets.FirstOrDefault().Id;
 }
        public override void HandleExecute(ChainRequest request)
        {
            myRequest             = (ButlerProcessRequest)request;
            _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey);

            IAsset theAsset = (from m in _MediaServicesContext.Assets select m).Where(m => m.Id == myRequest.AssetId).FirstOrDefault();

            theAsset.Delete();
        }
        public override void HandleExecute(Common.workflow.ChainRequest request)
        {
            myRequest = (ButlerProcessRequest)request;
            Setup();
            //Run index job
            IJob xJob = RunIndexingJob();

            //Update the asset ID with the Id of output asset.
            myRequest.AssetId = xJob.OutputMediaAssets.FirstOrDefault().Id;
        }
 public override void HandleExecute(Common.workflow.ChainRequest request)
 {
     myRequest = (ButlerProcessRequest)request;
     Setup();
     ProcessReplica();
     //Update Default Asset ID
     myRequest.AssetId = targetAsset.Id;
     //Change defualt AMS to Target AMS for the rest of the process
     myRequest.ChangeMediaServices(myConfig.TargetAMSName,myConfig.TargetAMSKey,myConfig.TargetAMSStorageConn);
 }
 public override void HandleExecute(Common.workflow.ChainRequest request)
 {
     myRequest = (ButlerProcessRequest)request;
     Setup();
     ProcessReplica();
     //Update Default Asset ID
     myRequest.AssetId = targetAsset.Id;
     //Change defualt AMS to Target AMS for the rest of the process
     myRequest.ChangeMediaServices(myConfig.TargetAMSName, myConfig.TargetAMSKey, myConfig.TargetAMSStorageConn);
 }
示例#16
0
        public override void HandleExecute(ChainRequest request)
        {
            myRequest            = (ButlerProcessRequest)request;
            _MediaServiceContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey);
            IAsset x             = _MediaServiceContext.Assets.Where(xx => xx.Id == myRequest.AssetId).FirstOrDefault();
            string recordPattern = "[IAssetFile] /{0}/{1}";

            foreach (IAssetFile xFile in x.AssetFiles)
            {
                myRequest.Log.Add(string.Format(recordPattern, x.Uri.Segments[1], xFile.Name));
            }
        }
示例#17
0
        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(MediaButler.Common.workflow.ChainRequest request)
 {
     //Standar Init Step activities
     myRequest = (ButlerProcessRequest)request;
     _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey);
     //Read ServiceBus configuration from Step configuration
     myServiceBusData = Newtonsoft.Json.JsonConvert.DeserializeObject<ServiceBusData>(this.StepConfiguration);
     //Map info to output
     MapInfo();
     string jsonMessage = Newtonsoft.Json.JsonConvert.SerializeObject(this.myData);
     //Send Message
     this.SendMessage(jsonMessage);
     //step finish
 }
示例#19
0
        public override void HandleExecute(ChainRequest request)
        {
            myRequest = (ButlerProcessRequest)request;

            sshCommandConfig myConfig = Newtonsoft.Json.JsonConvert.DeserializeObject <sshCommandConfig>(this.StepConfiguration);

            myBridge = sshCommandStep.constructBridge(myConfig);

            string exitCode         = string.Format(ExitCodePatter, myRequest.ProcessInstanceId);
            string customSshCommand = myBridge.buildCommand(sshCommandStep.internalValues(myRequest), myRequest.MetaData);

            myBridge.WaitForProcessEnd(customSshCommand, exitCode, myRequest.ProcessInstanceId);
            myRequest.Log.Add(string.Format("[0] finish to execute at {1} ------------------------------", myRequest.ProcessInstanceId, DateTime.Now.ToString()));
        }
示例#20
0
        public override void HandleExecute(Common.workflow.ChainRequest request)
        {
            myRequest             = (ButlerProcessRequest)request;
            _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey);
            //Setup Step
            Setup();

            myAssetOriginal = (from m in _MediaServicesContext.Assets select m).Where(m => m.Id == myRequest.AssetId).FirstOrDefault();
            //set primary file
            SetVideoPrimary();
            //Load the workflow definition
            myWorkflow = getWorkflowAsset();
            //Encode
            myRequest.AssetId = CreateEncodingJob(myWorkflow, myAssetOriginal).Id;
        }
        public override void HandleExecute(MediaButler.Common.workflow.ChainRequest request)
        {
            //Standar Init Step activities
            myRequest             = (ButlerProcessRequest)request;
            _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey);
            //Read ServiceBus configuration from Step configuration
            myServiceBusData = Newtonsoft.Json.JsonConvert.DeserializeObject <ServiceBusData>(this.StepConfiguration);
            //Map info to output
            MapInfo();
            string jsonMessage = Newtonsoft.Json.JsonConvert.SerializeObject(this.myData);

            //Send Message
            this.SendMessage(jsonMessage);
            //step finish
        }
示例#22
0
        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);
        }
示例#23
0
        public override void HandleExecute(Common.workflow.ChainRequest request)
        {
            //Request
            myRequest = (ButlerProcessRequest)request;
            //Media Context
            _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey);
            // Original Asset
            myAssetOriginal = (from m in _MediaServicesContext.Assets select m).Where(m => m.Id == myRequest.AssetId).FirstOrDefault();
            //Setup Step
            Setup();
            //Load the workflow definition
            myWorkflow = createWorkflowAsset();
            //Delete workflow from Original Asset
            string fileName = "";

            fileName = myAssetOriginal.AssetFiles.Where(af => af.Name.ToLower().EndsWith(".workflow")).FirstOrDefault().Name;
            myAssetOriginal.AssetFiles.Where(f => f.Name.ToLower() == fileName.ToLower()).FirstOrDefault().Delete();
            //Encode Uisng Premiun Encoder
            myRequest.AssetId = CreateEncodingJob(myWorkflow, myAssetOriginal).Id;
        }
        private ICustomRequest buildRequest(ButlerProcessRequest xRequest)
        {
            ICustomRequest yRequest = new customeRequest();

            yRequest.AssetId                      = xRequest.AssetId;
            yRequest.ConfigData                   = xRequest.ConfigData;
            yRequest.Exceptions                   = xRequest.Exceptions;
            yRequest.Log                          = xRequest.Log;
            yRequest.MediaAccountKey              = xRequest.MediaAccountKey;
            yRequest.MediaAccountName             = xRequest.MediaAccountName;
            yRequest.MediaStorageConn             = xRequest.MediaStorageConn;
            yRequest.MetaData                     = xRequest.MetaData;
            yRequest.ProcessConfigConn            = xRequest.ProcessConfigConn;
            yRequest.ProcessInstanceId            = xRequest.ProcessInstanceId;
            yRequest.ProcessTypeId                = xRequest.ProcessTypeId;
            yRequest.TimeStampProcessingStarted   = xRequest.TimeStampProcessingStarted;
            yRequest.ButlerRequest_ControlFileUri = xRequest.ButlerRequest.ControlFileUri;
            yRequest.ButlerRequest_MezzanineFiles = xRequest.ButlerRequest.MezzanineFiles;
            yRequest.StepConfiguration            = this.StepConfiguration;
            return(yRequest);
        }
示例#25
0
        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);
        }
        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);
        }
示例#28
0
        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 + "_mbIndex2";
            string JobName            = string.Format("GridEncodeStep_{1}_{0}", myRequest.ProcessInstanceId, asset.Name);
            string MediaProcessorName = myEncodigSupport.GetMediaProcessorName(allPorcessData, DotControlConfigKeys.Index2EncodeStepMediaProcessorName, "Azure Media Indexer 2 Preview");

            string[] encodeConfigurations = myEncodigSupport.GetLoadEncodignProfiles(dotControlData, processData, DotControlConfigKeys.Index2EncodeStepEncodeConfigList, myRequest.ButlerRequest.MezzanineFiles, myRequest.ProcessConfigConn, this.StepConfiguration);

            //4. Execute JOB and Wait
            IJob currentJob = myEncodigSupport.ExecuteGridJob(OutputAssetsName, JobName, MediaProcessorName, encodeConfigurations, "Indexing Task", asset.Id, MyEncodigSupport_OnJobError, MyEncodigSupport_JobUpdate);

            //5. Copy subtitles files to input asste?
            if ("yes" == dotControlData.Read(DotControlConfigKeys.Index2PreviewCopySubTitles))
            {
                CopyCaptions(currentJob.OutputMediaAssets.FirstOrDefault(), asset);
                currentJob.OutputMediaAssets.FirstOrDefault().Delete();
            }
            else
            {
                myRequest.AssetId = currentJob.OutputMediaAssets.FirstOrDefault().Id;
            }
        }
        public override void HandleExecute(Common.workflow.ChainRequest request)
        {
            myRequest = (ButlerProcessRequest)request;

            ProcessClipFilters();
        }
示例#30
0
 public override void HandleExecute(Common.workflow.ChainRequest request)
 {
     myRequest = (ButlerProcessRequest)request;
     //Select the asset by name and updtae the request with this AssetID
     SelectMediaAssetbyName();
 }
        public override void HandleExecute(Common.workflow.ChainRequest request)
        {
            myRequest = (ButlerProcessRequest)request;

            ProcessClipFilters();
        }
 public override void HandleExecute(Common.workflow.ChainRequest request)
 {
     myRequest = (ButlerProcessRequest)request;
     //Select the asset by name and updtae the request with this AssetID
     SelectMediaAssetbyName();
 }