public List <LabDataModel> Import(string labDataContent, Dictionary <string, int> surveyPits, int surveyId) { //MagikToRowsDictionary magikToRowsDictionary = m_Dal.LoadMaterialsFromDb(); SurveyPits pits = ConvertPitsIdsToSurveyPits(surveyPits); MagikFile file = new MagikFile(labDataContent); MagikHeader header = new MagikHeader(file.HeaderPart); //ImportedFileId=m_Dal.FlushFileInDb(file); List <LabDataModel> result = new List <LabDataModel>(); foreach (string bodyLine in file.BodyPart) { if (string.IsNullOrEmpty(bodyLine)) { continue; } try { MagikDataLine line = new MagikDataLine(bodyLine); //SoilSurveyRow soilSurveyRow = new SoilSurveyRow(surveyId, pits, line, header); SoilSurveyMaterialsTable soilSurveyMaterials = new SoilSurveyMaterialsTable(header, line, m_MagikToRowsDictionary); LabDataModel labRow = new LabDataModel(pits, soilSurveyMaterials, surveyId); result.Add(labRow); } catch (Exception e) { //Logger.LogMessage(LogInfo.Error, "could not parse line \n" + bodyLine); } } return(result); }
private SurveyPits ConvertPitsIdsToSurveyPits(Dictionary <string, int> pitIds) { SurveyPits pits = new SurveyPits(); foreach (KeyValuePair <string, int> pitId in pitIds) { pits.Add(pitId.Value, pitId.Key); } return(pits); }
public SoilSurveyRow(int surveyId, SurveyPits pits, MagikDataLine line, MagikHeader header) { m_Values["SurveyId"] = surveyId; m_Pits = pits; m_Line = line; m_Header = header; try { ParseLine(); } catch (Exception e) { //Logger.LogMessage(LogInfo.Error, string.Format("pit {0} not exists in survey {1}",e,surveyId)); throw; } }