public static ReaderInfo GetReaderByBar(string data) { ReaderLoader loader = new ReaderLoader(); ReaderInfo result = loader.LoadReaderByBar(data); return(result); }
public static ReaderInfo Authorize(AuthorizeInfo request) { int NumberReader = 0; ReaderInfo result = null; ReaderLoader loader = new ReaderLoader(); string LoginType = ReaderInfo.GetLoginType(request.login); if (LoginType == "NumberReader") { NumberReader = int.Parse(request.login); ReaderInfo reader = ReaderInfo.GetReader(NumberReader); if (reader == null) { throw new Exception("R001"); } request.password = ReaderInfo.HashPass(request.password, reader.Salt); result = loader.Authorize(NumberReader, request.password); } else if (LoginType == "Email") { ReaderInfo reader = ReaderInfo.GetReader(request.login); if (reader == null) { throw new Exception("R001"); } request.password = ReaderInfo.HashPass(request.password, reader.Salt); result = loader.Authorize(request.login, request.password); } if (result == null) { throw new Exception("R001"); } return(result); }
public static ReaderInfo GetReader(string Email) { ReaderLoader loader = new ReaderLoader(); ReaderInfo result = loader.LoadReader(Email); return(result); }
public static ReaderInfo GetReader(int Id) { ReaderLoader loader = new ReaderLoader(); ReaderInfo result = loader.LoadReader(Id); return(result); }
public static ReaderInfo GetReaderByOAuthToken(AccessToken token) { ReaderLoader loader = new ReaderLoader(); int Id = loader.GetReaderIdByOAuthToken(token.TokenValue); ReaderInfo result = loader.LoadReader(Id); return(result); }
public static ReaderRightsInfo GetReaderRights(int NumberReader) { ReaderRightsInfo result = new ReaderRightsInfo(); ReaderLoader loader = new ReaderLoader(); result = loader.GetReaderRights(NumberReader); result.NumberReader = NumberReader; return(result); }
private void ProcessFile(IOptions options, string rawFilePath, Action <string> statusUpdate = null) { var outputFilePath = GetOutputFileForDataset(options, rawFilePath); if (!options.OverwriteOutput && File.Exists(outputFilePath) && CompoundData.CheckSettings(outputFilePath, options)) { Console.WriteLine("Skipping file \"{0}\"; existing output was created with matching settings", rawFilePath); return; } Console.WriteLine("Processing file \"{0}\"", rawFilePath); statusUpdate?.Invoke($"Processing file \"{rawFilePath}\""); var instanceCreator = ReaderLoader.GetReaderForFile(rawFilePath); var rawReader = instanceCreator.CreateSpectraReader(rawFilePath); var methodReader = instanceCreator.CreateMethodReader(rawFilePath, options.MethodFilePath); var compounds = methodReader.ReadMethodData(options); var results = rawReader.ReadSpectraData(compounds); if (results == null) { return; } //Console.WriteLine("File \"{0}\": RawResults: {1}", rawFilePath, results.Count); //var combined = rawReader.AggregateResults(results, options.DefaultThreshold, CompoundThresholdsLookup); //Console.WriteLine("File \"{0}\": CombinedResults: {1}", rawFilePath, combined.Count); CompoundData.WriteCombinedResultsToFile(outputFilePath, results, options); Plotting.PlotResults(results, Path.GetFileNameWithoutExtension(rawFilePath), Path.ChangeExtension(outputFilePath, null) + "_summary", options.ImageSaveFormat); var pdfPath = Path.ChangeExtension(outputFilePath, "pdf"); var pdfWriter = new PdfWriter(Path.GetFileNameWithoutExtension(rawFilePath), rawFilePath, pdfPath); pdfWriter.WritePdf(results, options); /*////// * var imagesDir = Path.ChangeExtension(outputFilePath, null) + "_images"; * if (!Directory.Exists(imagesDir)) * { * try * { * Directory.CreateDirectory(imagesDir); * } * catch { } * } * * if (Directory.Exists(imagesDir)) * { * foreach (var compound in results) * { * // replace invalid characters with underscores * var name = Path.GetInvalidFileNameChars().Aggregate(compound.CompoundName, (current, c) => current.Replace(c.ToString(), "_")); * var namePrefix = (compound.PassesAllThresholds * ? "P" * : GetCompoundDataPrefix(compound)) + "_"; * var pathBase = Path.Combine(imagesDir, namePrefix + name); * Plotting.PlotCompound(compound, pathBase + ".png", Plotting.ExportFormat.PDF); * * foreach (var transition in compound.Transitions) * { * var path = $"{pathBase}_{transition.ProductMz:F2}.png"; * Plotting.PlotTransition(transition, path, Plotting.ExportFormat.PDF); * } * } * } * /**/ Console.WriteLine("Finished Processing file \"{0}\"", rawFilePath); statusUpdate?.Invoke($"Finished Processing file \"{rawFilePath}\""); }
public static Dictionary <int, string> GetCountriesList() { ReaderLoader loader = new ReaderLoader(); return(loader.GetReaderCountries()); }
public bool Validate() { var paths = ReaderLoader.GetDatasetPathsInPath(RawFilePath, Recurse); if (!string.IsNullOrWhiteSpace(FileFilter)) { // match the filter; replace "." with "\.", "*" with ".*", and "?" with ".", and use compiled regex. var regexFilterString = FileFilter.Replace(".", @"\.").Replace("*", ".*").Replace("?", "."); var regexFilter = new Regex(regexFilterString, RegexOptions.Compiled | RegexOptions.IgnoreCase); FilesToProcessList.AddRange(paths.Where(x => regexFilter.IsMatch(Path.GetFileName(x)))); } else { FilesToProcessList.AddRange(paths); } if (FilesToProcessList.Count == 0) { Console.WriteLine("ERROR: Cannot process file \"{0}\"! (No files to process)", RawFilePath); return(false); } if (FilesToProcessList.Any(x => x.EndsWith(".mzml", StringComparison.OrdinalIgnoreCase) || x.EndsWith(".mzml.gz", StringComparison.OrdinalIgnoreCase)) && (string.IsNullOrWhiteSpace(MethodFilePath) || !File.Exists(MethodFilePath))) { Console.WriteLine("ERROR: Method file required for mzML files."); return(false); } /*if (RawFilePath.ToLower().EndsWith(".raw")) * { * if (!File.Exists(RawFilePath)) * { * Console.WriteLine("ERROR: File \"{0}\" does not exist!", RawFilePath); * return false; * } * * FilesToProcessList.Add(RawFilePath); * } * else if (!Directory.Exists(RawFilePath)) * { * Console.WriteLine("ERROR: Directory \"{0}\" does not exist!", RawFilePath); * return false; * } * else if (Directory.Exists(RawFilePath)) * { * var searchOption = Recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; * var toProcess = Directory.EnumerateFiles(RawFilePath, FileFilter, searchOption); * FilesToProcessList.AddRange(toProcess); * } * else * { * Console.WriteLine("ERROR: Cannot process file \"{0}\"!", RawFilePath); * return false; * }*/ if (!string.IsNullOrWhiteSpace(CompoundThresholdFilePath) && !File.Exists(CompoundThresholdFilePath)) { Console.WriteLine("ERROR: Custom compound threshold file \"{0}\" does not exist!", CompoundThresholdFilePath); return(false); } if (!string.IsNullOrWhiteSpace(OutputFolder) && !Directory.Exists(OutputFolder)) { try { Directory.CreateDirectory(OutputFolder); } catch { Console.WriteLine("ERROR: Output folder \"{0}\" does not exist, and could not be created!", OutputFolder); return(false); } } if (CreateThresholdsFile) { if (string.IsNullOrWhiteSpace(CompoundThresholdOutputFilePath)) { Console.WriteLine("ERROR: When creating a thresholds output file, a path must be provided!"); return(false); } var directory = Path.GetDirectoryName(CompoundThresholdOutputFilePath); if (!Directory.Exists(directory)) { Console.WriteLine("ERROR: Thresholds output file folder does not exist!: \"{0}\"", directory); return(false); } } if (!string.IsNullOrWhiteSpace(SummaryStatsFilePath)) { if (!File.Exists(SummaryStatsFilePath)) { var directory = Path.GetDirectoryName(SummaryStatsFilePath); if (string.IsNullOrWhiteSpace(directory)) { directory = "."; } if (!Directory.Exists(directory)) { Console.WriteLine("EEROR: Cannot write summary file to \"{0}\": Directory does not exist.", SummaryStatsFilePath); return(false); } } } else { if (!string.IsNullOrWhiteSpace(OutputFolder)) { SummaryStatsFilePath = Path.Combine(OutputFolder, SummaryStatsFileDefaultName); } else if (Directory.Exists(RawFilePath)) { SummaryStatsFilePath = Path.Combine(RawFilePath, SummaryStatsFileDefaultName); } else { var directory = Path.GetDirectoryName(RawFilePath); if (string.IsNullOrWhiteSpace(directory)) { SummaryStatsFilePath = SummaryStatsFileDefaultName; } else { SummaryStatsFilePath = Path.Combine(directory, SummaryStatsFileDefaultName); } } } if (MaxThreads == 0) { MaxThreads = SystemInfo.GetCoreCount(); } return(true); }
internal void GiveFreeAbonementRight() { ReaderLoader loader = new ReaderLoader(); loader.GiveFreeAbonementRight(NumberReader); }