private void InitLoadDBSections(List <int> stepsSet) { // Загрузка типов секций для этого дома // размерности секций var sectSteps = stepsSet.Select(s => SectionSteps[s]).ToList(); List <string> types = new List <string> { SectionOrdinaryName }; if (houseSpot.Segments.Count > 1) { types.Add(SectionCornerLeftName); types.Add(SectionCornerRightName); } List <string> levels = new List <string>(); levels.Add(GetSectionLevels(houseSpot.CountFloorsMain)); levels.Add(GetSectionLevels(houseSpot.CountFloorsDominant)); List <SelectSectionParam> selectSects = new List <SelectSectionParam>(); foreach (var typeSect in types) { foreach (var levelSect in levels) { foreach (var step in sectSteps) { SelectSectionParam selSectParam = new SelectSectionParam(step, typeSect, levelSect); selectSects.Add(selSectParam); } } } dbService.PrepareLoadSections(selectSects); }
private static FlatInfo GetSectinByDbFlats(List <DbFlat> dbFlats, SelectSectionParam ssp) { var rooms = dbFlats.Select(s => { var r = s.GetRoomInfo(); r.CodeReqIndex = GetRoomCode(r); return(r); }).ToList(); var fi = new FlatInfo(); fi.IdSection = dbFlats[0].ID_Section; fi.Flats = rooms; fi.Code = GetCodeSection(fi.Flats); if (ssp.Type != "Рядовая") { fi.IsCorner = true; } return(fi); }
private bool CutSectionsBySize(int[] houseSteps, out List <SectionBySize> sectionsBySize) { sectionsBySize = new List <SectionBySize>(); bool fail = false; string houseStepsPassed = string.Empty; bool addToFailed = true; int curStepInHouse = 1; int sectionsInHouse = houseSteps.Length; // Определение этажности для каждого номера секции var dominantsNumberSect = DefineDominantsHouseVar(houseSteps.Length); string key = string.Empty; // Перебор нарезанных секций в доме for (int numberSect = 1; numberSect <= sectionsInHouse; numberSect++) { SectionBySize sectBySyze = new SectionBySize(); fail = false; Section section = null; // Размер секции - шагов int sectSize = houseSteps[numberSect - 1]; var sectCountStep = SectionSteps[sectSize]; houseStepsPassed += sectSize + "."; // ключ размерности секции key = GetSectionDataKey(sectCountStep, numberSect, curStepInHouse, sectionsInHouse); sectBySyze.Key = key; if (failedSections.Contains(key)) { #if TEST Debug.WriteLine("failedSection - " + key); #endif fail = true; addToFailed = false; break; } if (!passedSections.TryGetValue(key, out section)) { #if TEST Debug.WriteLine("new sect key = " + key); #endif sectBySyze.isFromPassedDict = false; // // Отрезка секции из дома // section = houseSpot.GetSection(curStepInHouse, sectCountStep); if (section == null) { Debug.WriteLine("fail нарезки - key=" + key); fail = true; addToFailed = true; break; } failCutting = false; section.NumberInSpot = numberSect; section.SpotOwner = houseSpot.SpotName; section.IsStartSectionInHouse = numberSect == 1; section.IsEndSectionInHouse = numberSect == sectionsInHouse; // Этажность секции, тип var type = GetSectionType(section.SectionType); section.Floors = GetSectionFloors(ref section, dominantsNumberSect); var levels = GetSectionLevels(section.Floors); // // Запрос секций из базы // SelectSectionParam selSectParam = new SelectSectionParam(section.CountStep, type, levels); section.Sections = dbService.GetSections(section, selSectParam); if (section.Sections == null || section.Sections.Count == 0) { Debug.WriteLine("fail no in db - key=" + key + "; type=" + type + "; levels=" + levels); fail = true; addToFailed = true; break; } failFilterReqs = false; } else { sectBySyze.isFromPassedDict = true; } curStepInHouse += sectCountStep; sectBySyze.Section = section; sectionsBySize.Add(sectBySyze); } if (fail) { if (addToFailed) { failedSections.Add(key); } failedHouseSteps.Add(houseStepsPassed); } return(!fail); }