/// <summary> /// Saves a collection of simplemeasurements to a *.pssession file. /// </summary> /// <param name="simpleMeasurements">Array of simplemeasurements.</param> /// <param name="filepath">The filepath of the *.pssession file.</param> /// <exception cref="System.ArgumentException">File path must be specified</exception> /// <exception cref="System.ArgumentNullException">SimpleMeasurements cannot be null</exception> /// <exception cref="System.Exception">An error occured while saving, please make sure the file path is correct</exception> public static void SaveMeasurements(SimpleMeasurement[] simpleMeasurements, string filepath) { if (string.IsNullOrEmpty(filepath)) { throw new ArgumentException("File path must be specified"); } if (simpleMeasurements == null || simpleMeasurements.Where(meas => meas == null).Count() > 0) { throw new ArgumentNullException("SimpleMeasurements cannot be null"); } SessionManager session = new SessionManager(); foreach (SimpleMeasurement measurement in simpleMeasurements) { if (measurement != null) { session.AddMeasurement(measurement.Measurement); } } session.MethodForEditor = simpleMeasurements[0].Measurement.Method; try { LoadSaveHelperFunctions.SaveSessionFile(filepath, session); } catch (Exception ex) { Crashes.TrackError(ex); throw new Exception("An error occured while saving, please make sure the file path is correct"); } }
/// <summary> /// Saves a simplemeasurement to a *.pssession file. /// </summary> /// <param name="simpleMeasurement">The simple measurement.</param> /// <param name="filepath">The filepath of the *.pssession file.</param> /// <exception cref="System.ArgumentException">File path must be specified</exception> /// <exception cref="System.ArgumentNullException">SimpleMeasurement cannot be null</exception> /// <exception cref="System.Exception">An error occured while saving, please make sure the file path is correct</exception> public static void SaveMeasurement(SimpleMeasurement simpleMeasurement, string filepath) { if (string.IsNullOrEmpty(filepath)) { throw new ArgumentException("File path must be specified"); } if (simpleMeasurement == null) { throw new ArgumentNullException("SimpleMeasurement cannot be null"); } SessionManager session = new SessionManager(); session.AddMeasurement(simpleMeasurement.Measurement); session.MethodForEditor = simpleMeasurement.Measurement.Method; try { LoadSaveHelperFunctions.SaveSessionFile(filepath, session); } catch (Exception ex) { Crashes.TrackError(ex); throw new Exception("An error occured while saving, please make sure the file path is correct"); } }