/// <summary> /// Creates the file name for <see cref="TestResults"/> /// </summary> private string CreateResultsFileName(ServerTestResults result) { var hours = result.Date.ToShortTimeString().Replace(':', '-'); var date = result.Date.ToShortDateString().Replace('/', '-'); return("Result" + "-" + date + "-" + hours); }
/// <summary> /// Writes <see cref="TestResults"/> to file /// </summary> public override void WriteToFile(ServerTestResults results) { // Make sure we have results to write and the writer object type is set to result if (results == null || ObjectType != SaveableObjects.Results) { throw new Exception("Wrong BinaryWriter usage."); } // Create the file name for this results var filenameFinal = CreateFinalFileName(CreateResultsFileName(results)); // Try to convert the results object to binary array if (!DataPackageDescriptor.TryConvertToBin(out var dataBin, results)) { throw new Exception("Results object is unconvertable."); } // Finally save the file WriteBinaryDataToFile(filenameFinal, dataBin); }
/// <summary> /// Deletes the <see cref="TestResults"/> /// </summary> /// <param name="result">Results to be deleted</param> public override void DeleteFile(ServerTestResults result) { // Make sure we have results to delete and the writer object type is set to result if (result == null || ObjectType != SaveableObjects.Results) { throw new Exception("Wrong BinaryWriter usage."); } // If there is no results like passed one, don't delete anything if (!BinaryReader.Results.ContainsKey(result)) { return; } // Try to delete results by filename var filename = BinaryReader.Results[result]; if (!DeleteBinaryFileByName(filename)) { // If something went wrong, throw an error throw new Exception("Cannot delete file!"); } }
/// <summary> /// Deletes the <see cref="TestResults"/> /// </summary> public virtual void DeleteFile(ServerTestResults results) { }
/// <summary> /// Writes <see cref="TestResults"/> to file /// </summary> public virtual void WriteToFile(ServerTestResults tr) { }