Ejemplo n.º 1
0
        public SoilSurveyMaterialsTable(MagikHeader header, MagikDataLine line, MagikToRowsDictionary magikToRowsDictionary)//:base(StringComparer.InvariantCultureIgnoreCase)
        {
            string[] cells = line.Cells;
            for (int i = 0; i < cells.Length; i++)
            {
                string columnName = header.ColumnNames[i];
                string cellValue  = cells[i];

                // parse materials:
                if (magikToRowsDictionary.ContainsKey(columnName))
                {
                    // only parse the material if it's not empty:
                    if (string.IsNullOrEmpty(cellValue))
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(cellValue.Trim()))
                    {
                        continue;
                    }

                    string materialColName = magikToRowsDictionary[columnName];
                    this[materialColName] = cellValue;
                }
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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;
            }
        }