public async Task <GeneralStatusEnum> Save(byte[] audioBytes, ProcessStatusEnum status)
        {
            SetId();
            var fileName = $"UploadsAudio-{id}.mp3";

            _log.LogInformation($"audioId: {id}");

            var blobResponse = await _blobContext.Write(audioBytes, fileName);

            if (blobResponse.status == GeneralStatusEnum.BadRequest)
            {
                return(blobResponse.status);
            }
            //send to assemblyai

            //var assemblyresponse = await UploadAudioSample(blobResponse.url);
            //transcriptionId = assemblyresponse.Id;
            //if (assemblyresponse.Status == "queued")
            //{
            //	status = ProcessStatusEnum.Processing;
            //}
            //else
            //{
            //	status = ProcessStatusEnum.Failed;
            //}

            //blobResponse.status = await SaveAudioDetails(fileName, assemblyresponse.Id, status);

            return(blobResponse.status);
        }
        public async Task <GeneralStatusEnum> UpdateTable(string id, ProcessStatusEnum status, string audioUrl = null)
        {
            var fileName          = $"UploadsImage-{id}.jpg";
            var generalStatusCode = await SaveAudioDetails(fileName, id, status, audioUrl);

            return(generalStatusCode);
        }
Exemplo n.º 3
0
        public async Task Run([BlobTrigger("audiocontainer/UploadsAudio-{id}.mp3", Connection = "StorageConnectionString")] Stream myBlob, string id, ILogger log)
        {
            log.LogInformation($"C# Blob trigger function Processed blob\n Id:{id} \n Size: {myBlob.Length} Bytes");
            var filename = $"UploadsAudio-{id}.mp3";

            var audioUrl = $"https://audioclipstorage.blob.core.windows.net/{_blobConfiguration.BlobContainerName}/{filename}";


            log.LogInformation(audioUrl);

            TranscriptionResponse assemblyresponse = await UploadAudioSample(audioUrl);

            transcriptionId = assemblyresponse.Id;

            ProcessStatusEnum status = ProcessStatusEnum.Default;

            if (assemblyresponse.Status == "queued")
            {
                status = ProcessStatusEnum.Processing;
            }
            else
            {
                status = ProcessStatusEnum.Failed;
            }

            GeneralStatusEnum statuscode = await SaveAudioDetails(filename, transcriptionId, status, audioUrl);

            log.LogInformation($"Process status: {statuscode}, Audio URL: {audioUrl}, TranscriptionId: {transcriptionId}");
        }
Exemplo n.º 4
0
        public static string StatusDesc(ProcessStatusEnum processStatus)
        {
            string desc = string.Empty;

            switch (processStatus)
            {
            case ProcessStatusEnum.EndOK:
                desc = "Sukses";
                break;

            case ProcessStatusEnum.EndWarning:
                desc = "Warning";
                break;

            case ProcessStatusEnum.EndError:
                desc = "Error";
                break;

            case ProcessStatusEnum.EndFail:
                desc = "Gagal";
                break;

            case ProcessStatusEnum.InProgress:
                desc = "In progress";
                break;
            }

            return(desc);
        }
        public async Task <UploadResponse> SaveResponse(byte[] imageBytes, ProcessStatusEnum status)
        {
            var uploadResponse = new UploadResponse();

            uploadResponse.GeneralStatusEnum = await Save(imageBytes, status);

            uploadResponse.Id = id.ToString();
            return(uploadResponse);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Stops processing temporarily and waits for a resume (or stop) event.
 /// </summary>
 public void Pause()
 {
     using (LoggingContext lc = new LoggingContext(string.Format("ThreadPool: {0}; TaskProcess QueueCode: {1}"
                                                                 , _threadPoolLabel, _taskQueueCode)))
     {
         _daMgr.loggingMgr.Trace("Pausing", enumTraceLevel.Level5);
         _processStatus = ProcessStatusEnum.Paused;
     }
 }
        public async Task <UploadResponse> SaveResponse(byte[] audioBytes, ProcessStatusEnum status)
        {
            var uploadResponse = new UploadResponse();

            uploadResponse.GeneralStatusEnum = await Save(audioBytes, status);

            uploadResponse.Id = transcriptionId;
            return(uploadResponse);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Resumes processing which was temporarily paused.
 /// </summary>
 public void Resume()
 {
     using (LoggingContext lc = new LoggingContext(string.Format("ThreadPool: {0}; TaskProcess QueueCode: {1}"
                                                                 , _threadPoolLabel, _taskQueueCode)))
     {
         _daMgr.loggingMgr.Trace("Resuming", enumTraceLevel.Level5);
         _processStatus = ProcessStatusEnum.Working;
         _resumeEvent.Set();   // signal to resume
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Stops processing of the task by changing state and sending stopEvent signal.  All tasks to exit from processing.
 /// </summary>
 public void Stop()
 {
     using (LoggingContext lc = new LoggingContext(string.Format("ThreadPool: {0}; TaskProcess QueueCode: {1}"
                                                                 , _threadPoolLabel, _taskQueueCode)))
     {
         _daMgr.loggingMgr.Trace("Stopping", enumTraceLevel.Level5);
         _processStatus = ProcessStatusEnum.Stopped;
         _stopEvent.Set();   // signal to stop
     }
 }
        private async Task <GeneralStatusEnum> SaveAudioDetails(
            string fileName,
            string id,
            ProcessStatusEnum status,
            string audioUrl = null)
        {
            var uploadEntity = new AudioEntity("Uploads", id, fileName, status, audioUrl);

            return(await _tableDbContext.InsertOrMergeEntityAsync(uploadEntity));
        }
Exemplo n.º 11
0
        //更新采购状态
        public void UpdatePurchaseProcessStatus(Guid purchaseId, ProcessStatusEnum status)
        {
            Purchase purchase = _purchaseRepository.FindBy(x => x.PurchaseId == purchaseId).FirstOrDefault();

            if (purchase == null)
            {
                return;
            }
            purchase.Status = status;
            _purchaseRepository.Save();
            UpdatePurchaseApplicationProcessStatus(purchase.PurchaseApplicationId, status);
        }
Exemplo n.º 12
0
 public ImageEntity(
     string partitionKey,
     string id,
     string fileName,
     ProcessStatusEnum processStatusEnum,
     string processedUrl)
 {
     PartitionKey      = partitionKey;
     RowKey            = id;
     FileName          = fileName;
     ProcessStatusEnum = processStatusEnum.EnumValue();
     ProcessedUrl      = processedUrl;
 }
 public AudioEntity(
     string partitionKey,
     string id,
     string fileName,
     ProcessStatusEnum processStatusEnum,
     string processedUrl)
 {
     PartitionKey = partitionKey;
     // this is the transcription id from AssemblyAI
     RowKey            = id;
     FileName          = fileName;
     ProcessStatusEnum = processStatusEnum.EnumValue();
     ProcessedUrl      = processedUrl;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Constructor for a new task process that can queued and processed by Transaction Processing Engine (TPE)
 /// </summary>
 /// <param name="daMgr">A data access manager object</param>
 /// <param name="taskId">Unique Task Identifier</param>
 /// <param name="taskQueueCode">Unique code for the entry in the task processing queue</param>
 /// <param name="parameters">Optional parameters to pass to function</param>
 /// <param name="taskCompletedHandler">A delegate which will be called when task is completed or fails</param>
 /// <param name="threadPoolLabel">A string identifier to be used for the set of threads created under this instance</param>
 public TaskProcess(DataAccessMgr daMgr
                    , string taskId
                    , int taskQueueCode
                    , string parameters
                    , TaskCompletedDelegate taskCompletedHandler
                    , string threadPoolLabel)
 {
     _daMgr                = daMgr;
     _taskId               = taskId;
     _taskQueueCode        = taskQueueCode;
     _parameters           = parameters;
     _taskCompletedHandler = taskCompletedHandler;
     _threadPoolLabel      = threadPoolLabel;
     _processStatus        = ProcessStatusEnum.Ready;
 }
Exemplo n.º 15
0
        public async Task <GeneralStatusEnum> Save(byte[] audioBytes, ProcessStatusEnum status)
        {
            SetId();
            var fileName = $"UploadsAudio-{id}.mp3";

            _log.LogInformation($"audioId: {id}");

            var blobResponse = await _blobContext.Write(audioBytes, fileName);

            if (blobResponse.status == GeneralStatusEnum.BadRequest)
            {
                return(blobResponse.status);
            }

            return(blobResponse.status);
        }
        public async Task <GeneralStatusEnum> Save(byte[] imageBytes, ProcessStatusEnum status)
        {
            SetId();
            var fileName = $"UploadsImage-{id}.jpg";

            _log.LogInformation($"imageId: {id}");

            var generalStatusCode = await _blobContext.Write(imageBytes, fileName);

            if (generalStatusCode == GeneralStatusEnum.BadRequest)
            {
                return(generalStatusCode);
            }

            generalStatusCode = await SaveImageDetails(fileName, id.ToString(), status);

            return(generalStatusCode);
        }
        public static string EnumValue(this ProcessStatusEnum e)
        {
            switch (e)
            {
            case ProcessStatusEnum.Uploaded:
                return("Uploaded");

            case ProcessStatusEnum.Processing:
                return("Processing");

            case ProcessStatusEnum.Completed:
                return("Completed");

            case ProcessStatusEnum.Failed:
                return("Failed");
            }
            return("Horrible Failure!!");
        }
Exemplo n.º 18
0
        private void detailView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
        {
            GridView currentView = sender as GridView;

            e.Appearance.BackColor = Color.Beige;
            ProcessStatusEnum status = (ProcessStatusEnum)currentView.GetRowCellValue(e.RowHandle, nameof(childModel.Status));

            if (e.Column.FieldName == nameof(childModel.Status))
            {
                Enum.TryParse(currentView.GetRowCellValue(e.RowHandle, nameof(childModel.Status)).ToString(), out ProcessStatusEnum processStatus);
                RenderCommonHelper.SetStatusColor(processStatus, e);
            }

            if (e.Column.FieldName == nameof(childModel.Price))
            {
                bool isPriceChange = (bool)currentView.GetRowCellValue(e.RowHandle, nameof(childModel.IsPriceChange));
                if (isPriceChange)
                {
                    e.Appearance.BackColor = Color.OrangeRed;
                }
            }
        }
Exemplo n.º 19
0
        public void run()
        {
            //Do nothing if disabled
            if(!enabled)
                return;
            //Do nothing if no data source
            if (_dataSource == null)
                return;

            //Update process status
            _status = ProcessStatusEnum.Running;

            //Get the rows from the data source
            DataTable dt = _dataSource.getData(-1);
            foreach (DataRow row in dt.Rows)
            {
                //Apply modifiers
                //apply templates
            }

            //Open/create output file
            FileStream fs = File.Open(_outputFileName, FileMode.Create, FileAccess.Write);

            //Write output file

            //close output file
            fs.Close();

            //Update process status
            _status = ProcessStatusEnum.Completed;

            //Update lastRun date
            _lastRun = DateTime.Now;
        }
Exemplo n.º 20
0
        //更新采购申请状态
        public void UpdatePurchaseApplicationProcessStatus(Guid purchaseApplicationId, ProcessStatusEnum status)
        {
            var purchaseApplication = _purchaseApplicationRepository.FindBy(x => x.PurchaseApplicationId == purchaseApplicationId).FirstOrDefault();

            if (purchaseApplication == null)
            {
                return;
            }
            purchaseApplication.ProcessStatus = status;
            purchaseApplication.UpdateDate    = DateTime.Now;
            _purchaseApplicationRepository.Save();
            _requestService.UpdateRequestProcessStatus(purchaseApplication.RequestId, status);
        }
        public static void  SetStatusColor(ProcessStatusEnum processStatus, RowCellStyleEventArgs e)
        {
            switch (processStatus)
            {
            case ProcessStatusEnum.需求建立:
                e.Appearance.BackColor = Color.SkyBlue;
                break;

            case ProcessStatusEnum.申请审核中:
                e.Appearance.BackColor = Color.YellowGreen;
                break;

            case ProcessStatusEnum.采购中:
                e.Appearance.BackColor = Color.Yellow;
                break;

            case ProcessStatusEnum.退货中:
                e.Appearance.BackColor = Color.Yellow;
                break;

            case ProcessStatusEnum.采购完成:
                e.Appearance.BackColor = Color.LawnGreen;
                break;

            case ProcessStatusEnum.采购入库:
                e.Appearance.BackColor = Color.Chocolate;
                break;

            case ProcessStatusEnum.已出库:
                e.Appearance.BackColor = Color.LightSeaGreen;
                break;

            case ProcessStatusEnum.工程车维修入库:
                e.Appearance.BackColor = Color.LawnGreen;
                break;

            case ProcessStatusEnum.维修中:
                e.Appearance.BackColor = Color.Yellow;
                break;

            case ProcessStatusEnum.维修完成:
                e.Appearance.BackColor = Color.LawnGreen;
                break;

            case ProcessStatusEnum.工程车维修出库:
                e.Appearance.BackColor = Color.LightSeaGreen;
                break;

            case ProcessStatusEnum.借出出库:
                e.Appearance.BackColor = Color.Yellow;
                break;

            case ProcessStatusEnum.归还入库:
                e.Appearance.BackColor = Color.LawnGreen;
                break;

            case ProcessStatusEnum.补给出库:
                e.Appearance.BackColor = Color.LawnGreen;
                break;

            case ProcessStatusEnum.退货申请完成:
                e.Appearance.BackColor = Color.LightSeaGreen;
                break;

            case ProcessStatusEnum.退货出库:
                e.Appearance.BackColor = Color.LawnGreen;
                break;

            case ProcessStatusEnum.报废出库:
                e.Appearance.BackColor = Color.Red;
                break;

            case ProcessStatusEnum.取消:
                e.Appearance.BackColor = Color.Red;
                break;
            }
        }
Exemplo n.º 22
0
 public void SetStatus(ProcessStatusEnum status)
 {
     _status = status;
 }
Exemplo n.º 23
0
        /// <summary>
        /// Begins the task process
        /// <para>A task process will loop until the underlying function completes or fails.</para>
        /// <para>A process can be paused and resumed while it is in base class's body.  Once control passes to the underlying function
        /// , it is up to the task's designer to implement properly;  the framework does provide sample tasks however.</para>
        /// <para>A task designer has the option to implement a task to run continuously or repeatedly after stopping.</para>
        /// </summary>
        public void Start()
        {
            using (LoggingContext lc = new LoggingContext(string.Format("ThreadPool: {0}; TaskProcess QueueCode: {1}"
                                                                        , _threadPoolLabel, _taskQueueCode)))
            {
                try
                {
                    // loop continuously until process has not completed
                    while (_processStatus == ProcessStatusEnum.Ready ||
                           _processStatus == ProcessStatusEnum.Working)
                    {
                        // handle paused (and resume) and stop events
                        if (_processStatus == ProcessStatusEnum.Paused)
                        {
                            WaitHandle[] waithandles = new WaitHandle[3];
                            waithandles[0] = _stopEvent;
                            waithandles[1] = _resumeEvent;
                            int waitResult = WaitHandle.WaitAny(waithandles);
                            if (waitResult == 0)
                            {
                                _stopEvent.Reset();
                            }
                            if (waitResult == 1)
                            {
                                _resumeEvent.Reset();
                            }
                        }

                        // make call to task's function body in seperate assembly.
                        // pass in the parameters
                        TaskStatusEnum taskStatus = TaskFunctionBody(_parameters);
                        // if task has completed or failed, then this process is over
                        // otherwise continue working and calling function again
                        if (taskStatus == TaskStatusEnum.Completed ||
                            taskStatus == TaskStatusEnum.Failed)
                        {
                            if (taskStatus == TaskStatusEnum.Completed)
                            {
                                _processStatus = ProcessStatusEnum.Completed;
                            }
                            if (taskStatus == TaskStatusEnum.Failed)
                            {
                                _processStatus = ProcessStatusEnum.Failed;
                            }
                        }

                        _daMgr.loggingMgr.Trace("Working", enumTraceLevel.Level5);
                    }
                }
                catch
                {
                    // If there are any unhandled exceptions, then the task is considered failed
                    // and the process will terminate.
                    _processStatus = ProcessStatusEnum.Failed;
                }
                finally
                {
                    // whether it had succeeded or failed, we let delegate know
                    // that task completed and pass in the status
                    _taskCompletedHandler(_taskQueueCode, _processStatus);
                }
                _daMgr.loggingMgr.Trace("Finished", enumTraceLevel.Level5);
            }
        }
Exemplo n.º 24
0
 public ProcessStatusInfoBase()
 {
     _status   = ProcessStatusEnum.Pending;
     _progress = 0;
 }