示例#1
0
        private static SkTaskModel SplitAndFill(string line)
        {
            var sampleAlert = new SkTaskModel();

            var props = typeof(SkTaskModel).GetProperties();

            var values = line.Split(";");

            for (var i = 0; i < values.Length; i++)
            {
                props[i].SetValue(sampleAlert, values[i].Trim());
            }

            return(sampleAlert);
        }
示例#2
0
 public void storeTask(SkTaskModel recognitionTask)
 {
     if (!Exist(recognitionTask))
     {
         lock (TaskDb)
         {
             using (StreamWriter sw = File.AppendText(this.TaskDbFilePath))
             {
                 sw.WriteLine($"{recognitionTask.Path}; {recognitionTask.AudioUrl}; {recognitionTask.TaskId}");
                 TaskDb.Add(recognitionTask.Path, recognitionTask);
                 sw.Flush();
             }
         }
     }
 }
示例#3
0
        public string StoreResults(dynamic jsonResponse, Configuration cfg, SkTaskModel task)
        {
            string path    = makeTaskPath(cfg, task);
            string taskDir = CheckDir(Path.GetDirectoryName(path));

            // write json
            string jsonFileName = makeJsonOutputFileName(cfg, task);

            File.WriteAllText(jsonFileName, jsonResponse.ToString(Formatting.Indented));

            // write text
            string txtFileName = makeTxtOutputFileName(cfg, task);

            File.WriteAllText(txtFileName, extractText((JObject)jsonResponse));

            log.Information($"Task id {task.TaskId} results succesfully stored at {jsonFileName}");
            return(txtFileName);
        }
示例#4
0
 public bool Exist(SkTaskModel recognitionTask)
 {
     return(TaskDb.ContainsKey(recognitionTask.Path));
 }
示例#5
0
 /**
  * Task is compleated if output file exists
  **/
 public bool CheckCompleated(Configuration cfg, SkTaskModel task)
 {
     return(File.Exists(makeTxtOutputFileName(cfg, task)) && File.Exists(makeJsonOutputFileName(cfg, task)));
 }
示例#6
0
 private string makeJsonOutputFileName(Configuration cfg, SkTaskModel task)
 {
     return(Path.ChangeExtension(makeTaskPath(cfg, task), ".json"));
 }
示例#7
0
 private string makeTaskPath(Configuration cfg, SkTaskModel task)
 {
     return(Path.Combine(cfg.outputPath, cfg.bucket, task.Path));
 }