Example #1
0
        private List <FlatInfo> ReadSections()
        {
            List <FlatInfo> sections = new List <FlatInfo>();
            var             count    = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                var sect = new FlatInfo();
                sect.Area         = reader.ReadDouble();
                sect.Code         = reader.ReadString();
                sect.CountStep    = reader.ReadInt32();
                sect.Flats        = ReadFlats();
                sect.Floors       = reader.ReadInt32();
                sect.IdSection    = reader.ReadInt32();
                sect.ImageAngle   = reader.ReadInt32();
                sect.ImageStart   = ReadCell();
                sect.IsCorner     = reader.ReadBoolean();
                sect.IsDominant   = reader.ReadBoolean();
                sect.IsInvert     = reader.ReadBoolean();
                sect.IsVertical   = reader.ReadBoolean();
                sect.NumberInSpot = reader.ReadInt32();
                sect.SpotOwner    = reader.ReadString();
                sections.Add(sect);
            }
            return(sections);
        }
Example #2
0
        private static bool CheckSection(FlatInfo fl, out string err)
        {
            bool isValid = true;

            err = null;
            // Должно быть больше 3 квартир в секции (без ЛЛУ)
            if (fl.Flats.Count < 5)
            {
                isValid = false;
                err     = "Меньше 4 квартир в секции (без ЛЛУ)";
            }
            // Должно быть не больше 10 квартир в секции (без ЛЛУ)
            else if (fl.Flats.Count > 11)
            {
                isValid = false;
                err     = "Больше 10 квартир в секции (без ЛЛУ)";
            }
            // Студий должно быть не больше 3 в секции
            else if (fl.Flats.Count(w => w.SubZone == "01") > 3)
            {
                isValid = false;
                err     = "Больше 3 студий в секции";
            }
            return(isValid);
        }
Example #3
0
        public bool CheckSection(FlatInfo sect)
        {
            bool res = false;

            checkSection = sect;

            topFlats    = insService.GetSideFlatsInSection(sect.Flats, true, section.SectionType);
            bottomFlats = insService.GetSideFlatsInSection(sect.Flats, false, section.SectionType);

            //// Временно!!! подмена индекса угловой квартиры 2KL2
            //if (section.SectionType == SectionType.CornerLeft || section.SectionType == SectionType.CornerRight)
            //{
            //    var cornerFlat = section.SectionType == SectionType.CornerLeft ? bottomFlats.First() : bottomFlats.Last();
            //    if (cornerFlat.ShortType == "2KL2")
            //    {
            //        cornerFlat.LightingNiz = cornerFlat.Type == "PIK1_2KL2_A0" ? "2|3,4" : "1,2|3";
            //        cornerFlat.SelectedIndexBottom = 4;
            //    }
            //}

            // Проверка инсоляции квартир сверху
            isTop        = true;
            curSideFlats = topFlats;
            res          = CheckSideFlats();

            if (res) // прошла инсоляция верхних квартир
            {
                // Проверка инсоляции квартир снизу
                isTop        = false;
                curSideFlats = bottomFlats;
                res          = CheckSideFlats();
            }
            return(res);
        }
Example #4
0
        public FlatInfo NewFlats(Section section, FlatInfo flat, bool isInvert)
        {
            FlatInfo resFlats = flat.Copy();

            resFlats.NumberInSpot = section.NumberInSpot;
            resFlats.SpotOwner    = section.SpotOwner;
            resFlats.IsInvert     = isInvert;
            resFlats.IsVertical   = section.IsVertical;
            resFlats.ImageAngle   = section.ImageAngle;
            resFlats.ImageStart   = section.ImageStart;
            resFlats.Floors       = section.Floors;
            resFlats.IsDominant   = section.IsDominant;
            if (isInvert)
            {
                resFlats.ImageAngle += 180;
            }
            resFlats.Flats = flat.Flats;
            resFlats.Flats = flat.Flats.Select(f => f.Clone()).ToList();

            //// Временно - подмена индекса освещенностим для боковых квартир!!!???
            //foreach (var itemFlat in resFlats.Flats)
            //{
            //    var sideFlat = SideFlatFake.GetSideFlat(itemFlat);
            //    if (sideFlat != null)
            //    {
            //        itemFlat.LightingTop = sideFlat.LightingTop;
            //        itemFlat.LightingNiz = sideFlat.LightingBot;
            //    }
            //}
            //#else
            //            resFlats.Flats = flat.Flats;
            //#endif
            return(resFlats);
        }
Example #5
0
        public bool CheckSection(FlatInfo sect, bool isRightOrTopLLu)
        {
            bool res = false;

            this.isRightOrTopLLu = isRightOrTopLLu;
            checkSection         = sect;

            topFlats    = insService.GetSideFlatsInSection(sect.Flats, true, section.SectionType);
            bottomFlats = insService.GetSideFlatsInSection(sect.Flats, false, section.SectionType);

            InvertInsSide(isRightOrTopLLu);

            // Проверка инсоляции квартир сверху
            isTop        = true;
            curSideFlats = topFlats;
            res          = CheckFlats();

            if (res) // прошла инсоляция верхних квартир
            {
                // Проверка инсоляции квартир снизу
                isTop        = false;
                curSideFlats = bottomFlats;
                res          = CheckFlats();
            }
            return(res);
        }
Example #6
0
        public override FlatInfo CheckInsFlatInfo(FlatInfo flatToIns)
        {
            // Для рядовой секции - проверка инсоляции с приоритетной стороны
            var      newFlat = insService.NewFlats(section, flatToIns, isInvert: !section.PriorityLluSideIsTop);
            FlatInfo insFlat = null;

            if (CheckSection(newFlat, isRightOrTopLLu: section.PriorityLluSideIsTop))
            {
                insFlat = newFlat;
            }
            else
            {
                // Проверка инсоляции с неприоритетной стороны секции
                newFlat = insService.NewFlats(section, flatToIns, isInvert: section.PriorityLluSideIsTop);
                if (CheckSection(newFlat, isRightOrTopLLu: !section.PriorityLluSideIsTop))
                {
                    insFlat = newFlat;
                }
#if TEST
                else
                {
                    insFlat = newFlat;
                }
#endif
            }
            return(insFlat);
        }
Example #7
0
        public Bitmap GenerateImageOneSection(FlatInfo section, string pathFlatImages)
        {
            ImagePath = pathFlatImages;
            var ExcelDataPath = @"БД_Параметрические данные квартир ПИК1.xlsx";

            Utils.AddRoomInfoForViz(section, ExcelDataPath);
            var res = GetImgSection(section);

            return(res.BmpSection);
        }
Example #8
0
        internal static void AddRoomInfoForViz(FlatInfo fi, string ExcelDataPath)
        {
            List <FlatType> fTypes = Utils.getFlatTypesFromXLSX(ExcelDataPath);

            foreach (RoomInfo ri in fi.Flats)
            {
                // Получение данных по типу квартиры
                FlatType ft = fTypes.Find(x => x.Type == ri.Type);
                ft.SetRoominFoParameters(ri);
            }
        }
Example #9
0
        public override FlatInfo CheckInsFlatInfo(FlatInfo flatToIns)
        {
            FlatInfo insFlat = null;
            // для угловой - проверка инсоляции в одном ее положении
            var newFlat = insService.NewFlats(section, flatToIns, isInvert: false);

            // Проверка инсоляции угловой секции
            if (CheckSection(newFlat))
            {
                insFlat = newFlat;
            }
#if TEST
            else
            {
                insFlat = newFlat;
            }
#endif
            return(insFlat);
        }
Example #10
0
        public List <FlatInfo> CheckSections(Section sectionBySize)
        {
            var passedSections = new Dictionary <string, FlatInfo>();

            foreach (var section in sectionBySize.Sections)
            {
                section.Code = insService.GetFlatCode(section);
                FlatInfo passedSect;
                if (!passedSections.TryGetValue(section.IdenticalCode, out passedSect))
                {
                    FlatInfo insFlat = CheckInsFlatInfo(section);
                    if (insFlat != null)
                    {
                        passedSections.Add(section.IdenticalCode, insFlat);
                    }
                }
            }
            return(passedSections.Values.ToList());
        }
Example #11
0
        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);
        }
Example #12
0
        public string GetFlatCode(FlatInfo flat)
        {
            string code;

            if (!dictFlatsCodes.TryGetValue(flat.Flats, out code))
            {
                code = string.Empty;
                var dictCountFlatByReq = flat.Flats.Where(r => r.SubZone != "0").
                                         GroupBy(g => g.CodeReqIndex).ToDictionary(k => k.Key, v => v.Count());

                for (int i = 0; i < ProjectScheme.ProjectInfo.requirments.Count; i++)
                {
                    int count = 0;
                    dictCountFlatByReq.TryGetValue(i, out count);
                    code += count.ToString();
                }
                dictFlatsCodes.Add(flat.Flats, code);
            }
            return(code);
        }
Example #13
0
        public void GetHousePercentage(ref HouseInfo houseInfo)
        {
            var sp1 = projectInfo.Copy();

            for (int k = 0; k < houseInfo.Sections.Count; k++) //Квартиры
            {
                FlatInfo section = houseInfo.Sections[k];
                for (int l = 0; l < section.Flats.Count; l++) //Квартиры
                {
                    if (section.Flats[l].SubZone.Equals("0"))
                    {
                        continue;
                    }
                    var reqs =
                        sp1.requirments.Where(
                            x => x.CodeZone.Equals(section.Flats[l].SubZone))
                        .Where(x => x.MaxArea > section.Flats[l].AreaTotal & x.MinArea <= section.Flats[l].AreaTotal)
                        .ToList();
                    if (reqs.Count == 0)
                    {
                        continue;
                    }
                    reqs[0].RealCountFlats += section.Floors - 1;
                }
            }
            int countFlats = 0;

            foreach (var r in sp1.requirments)
            {
                countFlats += r.RealCountFlats;
            }
            foreach (var r in sp1.requirments)
            {
                double percentage = r.RealCountFlats * 100 / countFlats;
                r.RealPercentage = percentage;
            }
            houseInfo.SpotInf = sp1;
        }
Example #14
0
        private ImgSection GetImgSection(FlatInfo fi, ImgHouse imgHouse = null)
        {
            ImgSection imgSection = new ImgSection();

            //if (hi.SectionsBySize[0].)
            //{
            //    imgSection.Angle += 90;
            //}

            //if (fi.IsInvert)
            //{
            //    imgSection.Angle += 180;
            //}

            imgSection.Angle = fi.ImageAngle;

            // Корректировка точки вставки секций
            if (fi.IsCorner)
            {
                imgSection.CoordYCorrection = 0;
                if (imgHouse != null)
                {
                    imgHouse.IsCorner = true;
                }
            }

            // Определение положения дома - вертикальный/горизонтальный
            if (!fi.IsVertical)
            {
                if (imgHouse != null)
                {
                    imgHouse.IsVertical = false;
                }
            }

            int SelectedDownPrev = 0;
            int offset           = 0;
            int minX             = 0;

            int X = 0;

            bool prev3NL2  = false;
            int  FlatIndex = 0;

            foreach (RoomInfo ri in fi.Flats)
            {
                // Корректировка неверно выданных данных
                if (ri.Type.Contains("3NL2"))
                {
                    ri.SelectedIndexTop    = 4;
                    ri.SelectedIndexBottom = 0;
                    imgSection.Height      = 5;
                }

                // Корректировка неверно выданных данных
                if (ri.Type == "PIK1U_BS_A_10-17_A_2")
                {
                    ri.SelectedIndexTop = 3;
                }

                // Корректировка положения квартиры 2KL2 и 2NM1

                if (ri.Type.Contains("2KL2") || ri.Type.Contains("2NM1"))
                {
                    if (prev3NL2 || (fi.Flats.Any(x => x.Type.Contains("3NL2")) && (fi.Flats.Count == FlatIndex + 2)))
                    {
                        ri.ImageNameSuffix = "_U";

                        if (ri.Type.Contains("2NM1"))
                        {
                            ri.SelectedIndexBottom = 1;
                        }
                        if (ri.Type.Contains("2KL2"))
                        {
                            ri.SelectedIndexBottom = 2;
                        }
                        ri.HorisontalModules = 2;
                        prev3NL2             = false;
                    }
                    else
                    {
                        ri.ImageNameSuffix     = "";
                        ri.SelectedIndexBottom = 3;
                        ri.HorisontalModules   = 3;
                    }

                    if (fi.Flats.Any(x => x.Type.Contains("3NL2")) && (fi.Flats.Count == FlatIndex + 2))
                    {
                        ri.NextOffsetX = 1;
                    }
                }

                if (ri.Type.Contains("3NL2"))
                {
                    // Флаг предыдущей секции 3NL2
                    prev3NL2 = true;

                    // Если после ЛЛУ идёт квартира типа 3NL2, то дом L-ориентирован
                    if (FlatIndex == 1)
                    {
                        if (imgHouse != null)
                        {
                            imgHouse.LOrientation = true;
                        }
                    }

                    // Если встретилась повёрнутая секция, то дом не является горизонтально ориентированным
                    // TODO: неясно, для чего было условие, разобраться

                    //if (fi.IsVertical)
                    //{

                    //}
                }
                else
                {
                    prev3NL2 = false;
                }
                FlatIndex++;

                ImgFlat imgFlat = new ImgFlat(ImagePath, ri.Type + ri.ImageNameSuffix, 0);
                imgFlat.Width  = ri.HorisontalModules + 2;
                imgFlat.Heigth = 6;

                // Определение точки вставки квартиры
                if (ri.SelectedIndexTop > 0 && ri.SelectedIndexBottom > 0 && SelectedDownPrev > 0)
                {
                    offset           = SelectedDownPrev;
                    SelectedDownPrev = 0;
                }
                else
                {
                    offset = SelectedDownPrev - ri.SelectedIndexTop;
                    if (ri.SelectedIndexBottom > 0)
                    {
                        SelectedDownPrev = ri.HorisontalModules + ri.NextOffsetX;
                    }
                    else
                    {
                        SelectedDownPrev = ri.SelectedIndexBottom;
                    }
                }

                X = X + offset + ri.CurrentOffsetX;

                if (X < minX)
                {
                    minX = X;
                }

                imgFlat.CoordX = X;

                imgSection.Lenght += ri.SelectedIndexBottom;

                imgSection.ImgFlats.Add(imgFlat);
            }

            foreach (ImgFlat imgFlat in imgSection.ImgFlats)
            {
                imgFlat.CoordX -= minX;
            }

            imgSection.SectionInfo = fi;

            //imgSection.BmpSectionPath = imgDir + imgName;

            imgSection.BmpSection = generateOneSection(imgSection);

            // Сохранение отдельных секций для отладки
#if DEBUG
            string imgName = @"Секция" + SectionIndex + ".png";
            string imgDir  = @"Section\";// @"C:\Users\fazleevaa\Links\Desktop\RRR" + "\\";
            SaveImage(imgSection.BmpSection, imgDir, imgName);
#endif
            return(imgSection);
        }
Example #15
0
 public abstract FlatInfo CheckInsFlatInfo(FlatInfo flatInfo);
Example #16
0
        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);
        }