// private static bool _AddRow(string rackColumnName, double maxBeamSpan, double usl, string typeOfBracing, double maxLoad) { if (string.IsNullOrEmpty(rackColumnName) || Utils.FLE(maxBeamSpan, 0.0) || Utils.FLE(usl, 0.0) || string.IsNullOrEmpty(typeOfBracing) || Utils.FLE(maxLoad, 0.0)) { return(false); } // Lets try to find RackColumn with rackColumnName. RackColumn rackColumn = m_RacksColumnsList.FirstOrDefault(c => c != null && c.Name == rackColumnName); if (rackColumn == null) { rackColumn = new RackColumn(rackColumnName); m_RacksColumnsList.Add(rackColumn); } rackColumn.AddRow(maxBeamSpan, usl, typeOfBracing, maxLoad); return(true); }
private static void _ReadBeamSheet(Microsoft.Office.Interop.Excel._Worksheet beamSheet) { if (beamSheet == null) { return; } try { m_ReallyUsedBeamsList.Clear(); // Data structure // column 1(A) - column system name // column 2(B) - max beam span // all other columns contains beams names with MaxLoad Microsoft.Office.Interop.Excel.Range xlRange = beamSheet.UsedRange; // Find maximum column index - find the first column with empty [3;index + 1] cell int iMaxColumnIndex = -1; // Column index to beam dictionary. Dictionary <int, RackBeam> columnIndexToBeamDict = new Dictionary <int, RackBeam>(); // Fill dictionary for (int i = 3; i <= 100; ++i) { object objColumnName = xlRange[2, i].Value2; if (objColumnName == null) { break; } else { string strColumnName = objColumnName.ToString(); if (!string.IsNullOrEmpty(strColumnName)) { // try to find this beam in m_BeamsList RackBeam foundBeam = m_BeamsList.FirstOrDefault(beam => beam != null && beam.Name == strColumnName); if (foundBeam == null) { continue; } columnIndexToBeamDict[i] = foundBeam; iMaxColumnIndex = i; } } } // if (iMaxColumnIndex < 0) { return; } // Read data from the rows. // If there are 3 empty row then break data read. int iMaxEmptyRowsCellCount = 3; int iEmptyRowCellCount = 0; // for (int iRow = BEAM_SHEET_START_ROW_INDEX + 1; iRow < 10000; ++iRow) { if (iEmptyRowCellCount == iMaxEmptyRowsCellCount) { break; } // read column name RackColumn foundColumn = null; object obColumnName = xlRange[iRow, 1].Value2; if (obColumnName == null) { ++iEmptyRowCellCount; continue; } else { string strColumnName = obColumnName.ToString(); if (string.IsNullOrEmpty(strColumnName)) { ++iEmptyRowCellCount; continue; } // Column should exist in m_RacksColumnsList. foundColumn = m_RacksColumnsList.FirstOrDefault(c => c != null && c.Name == strColumnName); if (foundColumn == null) { continue; } } // read max beam span double rMaxBeamSpan = 0.0; object objMaxBeamSpan = xlRange[iRow, 2].Value2; if (objMaxBeamSpan == null) { continue; } else { try { rMaxBeamSpan = Convert.ToDouble(objMaxBeamSpan); } catch { continue; } } if (Utils.FLE(rMaxBeamSpan, 0.0)) { continue; } // Read beams for (int iColumn = 3; iColumn <= iMaxColumnIndex; ++iColumn) { RackBeam foundBeam = null; if (columnIndexToBeamDict.ContainsKey(iColumn)) { foundBeam = columnIndexToBeamDict[iColumn]; } if (foundBeam == null) { continue; } // Read max beam load object objMaxBeamLoad = xlRange[iRow, iColumn].Value2; if (objMaxBeamLoad == null) { continue; } else { try { int maxBeamLoad = Convert.ToInt32(objMaxBeamLoad); if (foundColumn.AddBeam(rMaxBeamSpan, maxBeamLoad, foundBeam) && !m_ReallyUsedBeamsList.Contains(foundBeam)) { m_ReallyUsedBeamsList.Add(foundBeam); } } catch { } } } iEmptyRowCellCount = 0; } } catch { } }