public override string HandleBytes(byte[] bytes, string experiment, string ppid, int sessionNum, string dataName, UXFDataType dataType, int optionalTrialNum = 0) { string ext = Path.GetExtension(dataName); dataName = Path.GetFileNameWithoutExtension(dataName); if (dataType.GetDataLevel() == UXFDataLevel.PerTrial) { dataName = string.Format("{0}_T{1:000}", dataName, optionalTrialNum); } string directory = GetSessionPath(experiment, ppid, sessionNum); if (sortDataIntoFolders && dataType != UXFDataType.TrialResults) { directory = Path.Combine(directory, dataType.ToLower()); } Directory.CreateDirectory(directory); string name = string.IsNullOrEmpty(ext) ? string.Format("{0}.txt", dataName) : string.Format("{0}{1}", dataName, ext); string savePath = Path.Combine(directory, name); if (verboseDebug) { Utilities.UXFDebugLogFormat("Queuing save of file: {0}", savePath); } ManageInWorker(() => { File.WriteAllBytes(savePath, bytes); }); return(GetRelativePath(storagePath, savePath)); }
public override string HandleJSONSerializableObject(Dictionary <string, object> serializableObject, string experiment, string ppid, int sessionNum, string dataName, UXFDataType dataType, int optionalTrialNum = 0) { if (dataType.GetDataLevel() == UXFDataLevel.PerTrial) { dataName = string.Format("{0}_T{1:000}", dataName, optionalTrialNum); } string text = MiniJSON.Json.Serialize(serializableObject); string directory = GetSessionPath(experiment, ppid, sessionNum); if (sortDataIntoFolders && dataType != UXFDataType.TrialResults) { directory = Path.Combine(directory, dataType.ToLower()); } Directory.CreateDirectory(directory); string savePath = Path.Combine(directory, string.Format("{0}.json", dataName)); if (verboseDebug) { Debug.LogFormat("Queuing save of file: {0}", savePath); } ManageInWorker(() => { File.WriteAllText(savePath, text); }); return(savePath); }
public override string HandleJSONSerializableObject(List <object> serializableObject, string experiment, string ppid, int sessionNum, string dataName, UXFDataType dataType, int optionalTrialNum = 0) { // get data as text string text = MiniJSON.Json.Serialize(serializableObject); string ext = Path.GetExtension(dataName); dataName = Path.GetFileNameWithoutExtension(dataName); if (dataType.GetDataLevel() == UXFDataLevel.PerTrial) { dataName = string.Format("{0}_T{1:000}", dataName, optionalTrialNum); } string directory = GetSessionPathRelative(experiment, ppid, sessionNum); if (dataType != UXFDataType.TrialResults) { directory = Path.Combine(directory, dataType.ToLower()); } string name = string.IsNullOrEmpty(ext) ? string.Format("{0}.json", dataName) : string.Format("{0}{1}", dataName, ext); string savePath = Path.Combine(directory, name); savePath = savePath.Replace('\\', '/'); // here we send our data request AuthenticatedRequest(savePath, text); // return a string representing the location of the data. Will be stored in the trial_results output. return(savePath); }
public override string HandleDataTable(UXFDataTable table, string experiment, string ppid, int sessionNum, string dataName, UXFDataType dataType, int optionalTrialNum = 0) { if (dataType.GetDataLevel() == UXFDataLevel.PerTrial) { dataName = string.Format("{0}_T{1:000}", dataName, optionalTrialNum); } string[] lines = table.GetCSVLines(); string directory = GetSessionPath(experiment, ppid, sessionNum); if (sortDataIntoFolders && dataType != UXFDataType.TrialResults) { directory = Path.Combine(directory, dataType.ToLower()); } Directory.CreateDirectory(directory); string savePath = Path.Combine(directory, string.Format("{0}.csv", dataName)); if (verboseDebug) { Debug.LogFormat("Queuing save of file: {0}", savePath); } ManageInWorker(() => { File.WriteAllLines(savePath, lines); }); return(savePath); }
public override string HandleText(string text, string experiment, string ppid, int sessionNum, string dataName, UXFDataType dataType, int optionalTrialNum = 0) { if (dataType.GetDataLevel() == UXFDataLevel.PerTrial) { dataName = string.Format("{0}_T{1:000}", dataName, optionalTrialNum); } string directory = GetSessionPath(experiment, ppid, sessionNum); if (sortDataIntoFolders && dataType != UXFDataType.TrialResults) { directory = Path.Combine(directory, dataType.ToLower()); } Directory.CreateDirectory(directory); string savePath = Path.Combine(directory, string.Format("{0}.txt", dataName)); if (verboseDebug) { Utilities.UXFDebugLogFormat("Queuing save of file: {0}", savePath); } ManageInWorker(() => { File.WriteAllText(savePath, text); }); return(GetRelativePath(storagePath, savePath));; }