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); }
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(); } } } }
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); }
public bool Exist(SkTaskModel recognitionTask) { return(TaskDb.ContainsKey(recognitionTask.Path)); }
/** * 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))); }
private string makeJsonOutputFileName(Configuration cfg, SkTaskModel task) { return(Path.ChangeExtension(makeTaskPath(cfg, task), ".json")); }
private string makeTaskPath(Configuration cfg, SkTaskModel task) { return(Path.Combine(cfg.outputPath, cfg.bucket, task.Path)); }