コード例 #1
0
        public string Voice2TextFailed(bool requeueAsTheLast, [FromBody] Voice2Text task)
        {
            using (HlidacStatu.Q.Simple.Queue <Voice2Text> sq
                       = new Q.Simple.Queue <Voice2Text>(Voice2Text.QName + "_failed", Devmasters.Config.GetWebConfigValue("RabbitMqConnectionString")))
            {
                sq.Send(task);
            }

            return("OK");
        }
コード例 #2
0
        public string Voice2TextDone([FromBody] Voice2Text task)
        {
            using (HlidacStatu.Q.Simple.Queue <Voice2Text> sq
                       = new Q.Simple.Queue <Voice2Text>(Voice2Text.QName + "_done", Devmasters.Config.GetWebConfigValue("RabbitMqConnectionString")))
            {
                task.internaltaskid = 0;
                sq.Send(task);
            }


            return($"OK");
        }
コード例 #3
0
 public string Voice2TextNewTask(string datasetId, string itemId, int priority = 0)
 {
     using (HlidacStatu.Q.Simple.Queue <Voice2Text> sq = new Q.Simple.Queue <Voice2Text>(
                Voice2Text.QName_priority(priority),
                Devmasters.Config.GetWebConfigValue("RabbitMqConnectionString"))
            )
     {
         sq.Send(new Voice2Text()
         {
             dataset = datasetId, itemid = itemId
         });
         return($"OK");
     }
 }
コード例 #4
0
        public string Voice2TextFailed(bool requeueAsTheLast, [FromBody] Voice2Text task)
        {
            using (HlidacStatu.Q.Simple.Queue <TaskResult <Voice2Text> > sq
                       = new Q.Simple.Queue <TaskResult <Voice2Text> >(Voice2Text.QName_failed, Devmasters.Config.GetWebConfigValue("RabbitMqConnectionString")))
            {
                TaskResult <Voice2Text> result = new TaskResult <Voice2Text>()
                {
                    Payload = task,
                    Created = DateTime.Now,
                    Result  = "failed",
                    User    = this.ApiAuth?.ApiCall?.User,
                    FromIP  = this.HostIpAddress
                };
                sq.Send(result);
            }

            return("OK");
        }
コード例 #5
0
        public Voice2Text Voice2TextGetTask()
        {
            Voice2Text task = null;

            foreach (var p in Voice2Text.Priorities)
            {
                using (HlidacStatu.Q.Simple.Queue <Voice2Text> sq = new Q.Simple.Queue <Voice2Text>(Voice2Text.QName_priority(p),
                                                                                                    Devmasters.Config.GetWebConfigValue("RabbitMqConnectionString")))
                {
                    task = sq.GetAndAck();
                    if (task != null)
                    {
                        return(task);
                    }
                }
            }
            if (task == null)
            {
                throw new HttpResponseException(new ErrorMessage(System.Net.HttpStatusCode.NoContent, $"No taks available"));
            }
            return(task);
        }