private List <SelectSectionParam> GetSectionsTypesIndDb() { List <SelectSectionParam> resSectTypesInDb = new List <SelectSectionParam>(); vil_SectionsTypesTableAdapter adapterSectTypes = new vil_SectionsTypesTableAdapter(); var selRes = adapterSectTypes.GetSectionTypes(); foreach (var item in selRes) { SelectSectionParam selSectParam = new SelectSectionParam(item.CountModules, item.Type, item.Levels); resSectTypesInDb.Add(selSectParam); } return(resSectTypesInDb); }
private List <List <DbFlat> > LoadFromDbSection(SelectSectionParam selectSectParam) { List <SAPR.FlatsInSectionsRow> flatsDbRows; FlatsInSectionsTableAdapter flatsIsSection = new FlatsInSectionsTableAdapter(); if (ProjectScheme.MaxSectionBySize == 0) { flatsDbRows = flatsIsSection.GetFlatsInTypeSection(selectSectParam.Step, selectSectParam.Type, selectSectParam.Levels).ToList(); } else { flatsDbRows = flatsIsSection.GetFlatsInTypeSectionMax(ProjectScheme.MaxSectionBySize, selectSectParam.Step, selectSectParam.Type, selectSectParam.Levels).ToList(); // отсекаем первые и последние квартиры секции (она может быть неполной) if (flatsDbRows.Count == ProjectScheme.MaxSectionBySize) { //flatsDb = flatsDb.OrderBy(x => x.ID_FlatInSection).ToList(); var lastDbFlat = flatsDbRows.Last(); var idSectionLast = lastDbFlat.ID_Section; do { flatsDbRows.Remove(lastDbFlat); lastDbFlat = flatsDbRows.Last(); } while (lastDbFlat.ID_Section == idSectionLast); var firstDbFlat = flatsDbRows.First(); var idSectionFirst = firstDbFlat.ID_Section; do { flatsDbRows.Remove(firstDbFlat); firstDbFlat = flatsDbRows.First(); } while (firstDbFlat.ID_Section == idSectionFirst); } } var dbFlats = DbFlat.GetFlats(flatsDbRows); var res = GetDbFlatsBySections(dbFlats); return(res); }
public List <FlatInfo> GetSections(Section section, SelectSectionParam selecSectParam) { List <FlatInfo> sectionsBySyze; string key = section.CountStep + selecSectParam.Type + selecSectParam.Levels; if (!dictSections.TryGetValue(key, out sectionsBySyze)) { List <List <DbFlat> > flatsDbBySections; if (!dictDbFlats.TryGetValue(selecSectParam, out flatsDbBySections)) { return(null); } if (flatsDbBySections.Count == 0) { return(null); } sectionsBySyze = new List <FlatInfo>(); FlatInfo fl; bool isValidSection = true; foreach (var gg in flatsDbBySections) { fl = new FlatInfo(); fl.IsDominant = section.IsDominant; fl.ImageAngle = section.ImageAngle; fl.ImageStart = section.ImageStart; fl.Floors = section.Floors; fl.CountStep = section.CountStep; fl.Flats = new List <RoomInfo>(); fl.IsCorner = section.IsCorner; fl.IsVertical = section.IsVertical; fl.NumberInSpot = section.NumberInSpot; fl.SpotOwner = section.SpotOwner; isValidSection = true; for (int i = 0; i < gg.Count; i++) { var f = gg[i]; fl.IdSection = f.ID_Section; RoomInfo room = null; if (f.SubZone != "0") { for (int r = 0; r < ProjectScheme.ProjectInfo.requirments.Count; r++) { var req = ProjectScheme.ProjectInfo.requirments[r]; if (req.CodeZone == f.SubZone && f.AreaTotalStandart >= req.MinArea && f.AreaTotalStandart < req.MaxArea) { room = GetRoom(f); room.CodeReqIndex = r; break; } } } else { room = GetRoom(f); } if (room == null) { isValidSection = false; break; } fl.Flats.Add(room); } if (!isValidSection) { continue; } string err; if (CheckSection(fl, out err)) { fl.DefineIdenticalCodeSection(); sectionsBySyze.Add(fl); } else { // Trace.TraceWarning("Ошибочная секция - "+ err + "; idSection = " + fl.IdSection); } //if (maxSectionBySize != 0 && sectionsBySyze.Count == maxSectionBySize) //{ // break; //} } dictSections.Add(key, sectionsBySyze); } return(sectionsBySyze); }