public static string createAssay(string xmlText) { var assay = new Assay(); var serializer = new XmlSerializer(typeof(Assay)); using (var xmlReader = XmlReader.Create(new StringReader(xmlText))) { try { assay = (Assay)serializer.Deserialize(xmlReader); assay.calculatedCrc = CrcValidator.CalculateCrcFor(xmlText); ProcessAssay(assay, xmlText); var javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer(); string jsonString = javaScriptSerializer.Serialize(assay); logger.Info("Parsed text successfully"); return(jsonString); } catch (Exception e) { logger.Warn("Unable to parse string"); return(null); } } }
private static void SortAssay(Assay assay) { assay.dataReduction.resultCategories = assay.dataReduction.resultCategories.OrderBy( i => i.index).ToList(); assay.dataReduction.resultCategories.ForEach(i => { i.resultEnum.interpretationList = i.resultEnum.interpretationList.OrderBy( x => x.reductionIndex).ToList(); }); assay.reagentTypeDescription.reagents = assay.reagentTypeDescription.reagents.OrderBy(v => v.isOnboard).ToList(); assay.reagentTypeDescription.reagents.Reverse(); }
private static Assay ProcessAssay(Assay assay, string xmlText) { string analytes = ""; foreach (Analyte analyte in assay.analyteList) { analytes += analyte.analyteName + ", "; } if (assay.calculatedCrc != assay.objectCrc) { assay.xmlText = xmlText; } assay.analytes = analytes.Trim(',', ' '); assay.getType(); assay.processSteps = GetProcessSteps(xmlText); SortAssay(assay); return(assay); }