예제 #1
0
파일: DbFlat.cs 프로젝트: vildar82/AR_Zhuk
        public static List <DbFlat> GetFlats(List <SAPR.FlatsInSectionsRow> dbFlatsRows)
        {
            List <DbFlat> resFlats = new List <DbFlat>();

            foreach (var item in dbFlatsRows)
            {
                var flat = new DbFlat(item);
                resFlats.Add(flat);
            }
            return(resFlats);
        }
예제 #2
0
        public static RoomInfo GetRoom(DbFlat f)
        {
            var fflat = new RoomInfo(f.ShortType, f.SubZone, f.TypeFlat, "",
                                     "", f.LinkageBefore, f.LinkageAfter, "", "", "", f.Levels, "", "", f.LightBottom, f.LightTop,
                                     "");

            fflat.AreaModules         = f.AreaInModule;
            fflat.AreaTotal           = f.AreaTotalStrong;
            fflat.AreaTotalStandart   = f.AreaTotalStandart;
            fflat.SelectedIndexTop    = f.SelectedIndexTop;
            fflat.SelectedIndexBottom = f.SelectedIndexBottom;
            return(fflat);
        }
예제 #3
0
        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);
        }
예제 #4
0
 public void LoadDbFlatsFromFile()
 {
     try
     {
         using (Stream stream = File.Open("data.bin", FileMode.Open))
         {
             var xmlDbFlats = new List <XmlDbFlats>();
             using (var binaryReader = new BinaryReader(stream))
             {
                 int countXmlFlats = binaryReader.ReadInt32();
                 for (int i = 0; i < countXmlFlats; i++)
                 {
                     XmlDbFlats xmlFlat = new XmlDbFlats();
                     xmlFlat.SelectParam        = new SelectSectionParam();
                     xmlFlat.SelectParam.Levels = binaryReader.ReadString();
                     xmlFlat.SelectParam.Step   = binaryReader.ReadInt32();
                     xmlFlat.SelectParam.Type   = binaryReader.ReadString();
                     xmlFlat.DbFlats            = new List <List <DbFlat> >();
                     var countSects = binaryReader.ReadInt32();
                     for (int s = 0; s < countSects; s++)
                     {
                         List <DbFlat> sect       = new List <DbFlat>();
                         var           countFlats = binaryReader.ReadInt32();
                         for (int f = 0; f < countFlats; f++)
                         {
                             DbFlat flat = new DbFlat();
                             flat.AreaInModule        = binaryReader.ReadInt32();
                             flat.AreaLive            = binaryReader.ReadDouble();
                             flat.AreaTotalStandart   = binaryReader.ReadDouble();
                             flat.AreaTotalStrong     = binaryReader.ReadDouble();
                             flat.CountModules        = binaryReader.ReadInt32();
                             flat.Expr1               = binaryReader.ReadInt32();
                             flat.Expr2               = binaryReader.ReadInt32();
                             flat.FactorSmoke         = binaryReader.ReadString();
                             flat.ID_Flat             = binaryReader.ReadInt32();
                             flat.ID_FlatInSection    = binaryReader.ReadInt32();
                             flat.ID_Section          = binaryReader.ReadInt32();
                             flat.IndexBottom         = binaryReader.ReadString();
                             flat.IndexTop            = binaryReader.ReadString();
                             flat.Levels              = binaryReader.ReadString();
                             flat.LightBottom         = binaryReader.ReadString();
                             flat.LightTop            = binaryReader.ReadString();
                             flat.LinkageAfter        = binaryReader.ReadString();
                             flat.LinkageBefore       = binaryReader.ReadString();
                             flat.SelectedIndexBottom = binaryReader.ReadInt32();
                             flat.SelectedIndexTop    = binaryReader.ReadInt32();
                             flat.ShortType           = binaryReader.ReadString();
                             flat.SubZone             = binaryReader.ReadString();
                             flat.TypeFlat            = binaryReader.ReadString();
                             flat.TypeSection         = binaryReader.ReadString();
                             sect.Add(flat);
                         }
                         xmlFlat.DbFlats.Add(sect);
                     }
                     xmlDbFlats.Add(xmlFlat);
                 }
             }
             foreach (var xmlDbFlat in xmlDbFlats)
             {
                 dictDbFlats.TryAdd(xmlDbFlat.SelectParam, xmlDbFlat.DbFlats);
             }
         }
     }
     catch { }
 }