Exemple #1
0
        public void SelectTest()
        {
            IFreeSql db = g.sqlserver;

            db.Transaction(() =>
            {
                db.Delete <BuildDictionary>().Where("1=1").ExecuteAffrows();
                db.Delete <Build2>().Where("1=1").ExecuteAffrows();

                var dictionaries = new BuildDictionary[]
                {
                    new BuildDictionary {
                        Type = 1, Code = 'A', Name = "办公建筑"
                    },
                    new BuildDictionary {
                        Type = 1, Code = 'B', Name = "商场建筑"
                    },
                    new BuildDictionary {
                        Type = 1, Code = 'C', Name = "宾馆饭店建筑"
                    },
                    new BuildDictionary {
                        Type = 1, Code = 'D', Name = "文化教育建筑"
                    },
                    new BuildDictionary {
                        Type = 1, Code = 'E', Name = "医疗卫生建筑"
                    },
                    new BuildDictionary {
                        Type = 1, Code = 'F', Name = "体育建筑"
                    },
                    new BuildDictionary {
                        Type = 1, Code = 'G', Name = "综合建筑"
                    },
                    new BuildDictionary {
                        Type = 1, Code = 'Z', Name = "其他建筑"
                    },

                    new BuildDictionary {
                        Type = 2, Code = 'A', Name = "结构建筑"
                    },
                    new BuildDictionary {
                        Type = 2, Code = 'B', Name = "框剪结构"
                    },
                    new BuildDictionary {
                        Type = 2, Code = 'C', Name = "剪力墙结构"
                    },
                    new BuildDictionary {
                        Type = 2, Code = 'D', Name = "砖混结构"
                    },
                    new BuildDictionary {
                        Type = 2, Code = 'E', Name = "钢结构"
                    },
                    new BuildDictionary {
                        Type = 2, Code = 'F', Name = "筒体结构"
                    },
                    new BuildDictionary {
                        Type = 2, Code = 'G', Name = "木结构"
                    },
                    new BuildDictionary {
                        Type = 2, Code = 'Z', Name = "其他"
                    },

                    new BuildDictionary {
                        Type = 3, Code = 'A', Name = "集中式全空气系统"
                    },
                    new BuildDictionary {
                        Type = 3, Code = 'B', Name = "风机盘管+新风系统"
                    },
                    new BuildDictionary {
                        Type = 3, Code = 'C', Name = "分体式空调或 VRV 的局部式机组系统"
                    },
                    new BuildDictionary {
                        Type = 3, Code = 'Z', Name = "其他"
                    },

                    new BuildDictionary {
                        Type = 4, Code = 'A', Name = "散热器采暖"
                    },
                    new BuildDictionary {
                        Type = 4, Code = 'B', Name = "地板辐射采暖"
                    },
                    new BuildDictionary {
                        Type = 4, Code = 'C', Name = "电辐射采暖"
                    },
                    new BuildDictionary {
                        Type = 4, Code = 'D', Name = "空调系统集中供暖"
                    },
                    new BuildDictionary {
                        Type = 4, Code = 'Z', Name = "其他"
                    },

                    new BuildDictionary {
                        Type = 5, Code = 'A', Name = "砖"
                    },
                    new BuildDictionary {
                        Type = 5, Code = 'B', Name = "建筑砌块"
                    },
                    new BuildDictionary {
                        Type = 5, Code = 'C', Name = "板材墙体"
                    },
                    new BuildDictionary {
                        Type = 5, Code = 'D', Name = "复合墙板和墙体"
                    },
                    new BuildDictionary {
                        Type = 5, Code = 'E', Name = "玻璃幕墙"
                    },
                    new BuildDictionary {
                        Type = 5, Code = 'Z', Name = "其他"
                    },

                    new BuildDictionary {
                        Type = 6, Code = 'A', Name = "内保温"
                    },
                    new BuildDictionary {
                        Type = 6, Code = 'B', Name = "外保温"
                    },
                    new BuildDictionary {
                        Type = 6, Code = 'C', Name = "夹芯保温"
                    },
                    new BuildDictionary {
                        Type = 6, Code = 'Z', Name = "其他"
                    },

                    new BuildDictionary {
                        Type = 7, Code = 'A', Name = "单玻单层窗"
                    },
                    new BuildDictionary {
                        Type = 7, Code = 'B', Name = "单玻双层窗"
                    },
                    new BuildDictionary {
                        Type = 7, Code = 'C', Name = "单玻单层窗+单玻双层窗"
                    },
                    new BuildDictionary {
                        Type = 7, Code = 'D', Name = "中空双层玻璃窗"
                    },
                    new BuildDictionary {
                        Type = 7, Code = 'E', Name = "中空三层玻璃窗"
                    },
                    new BuildDictionary {
                        Type = 7, Code = 'F', Name = "中空充惰性气体"
                    },
                    new BuildDictionary {
                        Type = 7, Code = 'Z', Name = "其他"
                    },

                    new BuildDictionary {
                        Type = 8, Code = 'A', Name = "普通玻璃"
                    },
                    new BuildDictionary {
                        Type = 8, Code = 'B', Name = "镀膜玻璃"
                    },
                    new BuildDictionary {
                        Type = 8, Code = 'C', Name = "Low-e 玻璃"
                    },
                    new BuildDictionary {
                        Type = 8, Code = 'Z', Name = "其他"
                    },

                    new BuildDictionary {
                        Type = 9, Code = 'A', Name = "钢窗"
                    },
                    new BuildDictionary {
                        Type = 9, Code = 'B', Name = "铝合金"
                    },
                    new BuildDictionary {
                        Type = 9, Code = 'C', Name = "木窗"
                    },
                    new BuildDictionary {
                        Type = 9, Code = 'D', Name = "断热窗框"
                    },
                    new BuildDictionary {
                        Type = 9, Code = 'E', Name = "塑钢"
                    },
                    new BuildDictionary {
                        Type = 9, Code = 'Z', Name = "其他"
                    },
                };

                db.Insert(dictionaries).ExecuteAffrows();

                Build2 build = new Build2
                {
                    ID   = 1,
                    Name = "建筑 1",
                    BuildFunctionCode    = 'A',
                    BuildStructureCode   = 'A',
                    AirTypeCode          = 'A',
                    HeatTypeCode         = 'A',
                    WallMaterialTypeCode = 'A',
                    WallWarmTypeCode     = 'A',
                    WallWindowsTypeCode  = 'A',
                    GlassTypeCode        = 'A',
                    WinFrameMaterialCode = 'A'
                };

                db.Insert(build).ExecuteAffrows();
            });

            Build2 build = db.Select <Build2>()
                           .InnerJoin(a => a.BuildFunctionCode == a.BuildFunction.Code && a.BuildFunction.Type == 1)
                           .InnerJoin(a => a.BuildStructureCode == a.BuildStructure.Code && a.BuildStructure.Type == 2)
                           .InnerJoin(a => a.AirTypeCode == a.AirType.Code && a.AirType.Type == 3)
                           .InnerJoin(a => a.HeatTypeCode == a.HeatType.Code && a.HeatType.Type == 4)
                           .InnerJoin(a => a.WallMaterialTypeCode == a.WallMaterialType.Code && a.WallMaterialType.Type == 5)
                           .InnerJoin(a => a.WallWarmTypeCode == a.WallWarmType.Code && a.WallWarmType.Type == 6)
                           .InnerJoin(a => a.WallWindowsTypeCode == a.WallWindowsType.Code && a.WallWindowsType.Type == 7)
                           .InnerJoin(a => a.GlassTypeCode == a.GlassType.Code && a.GlassType.Type == 8)
                           .InnerJoin(a => a.WinFrameMaterialCode == a.WinFrameMaterial.Code && a.WinFrameMaterial.Type == 9)
                           .Where(a => a.ID == 1)
                           .ToOne();

            Assert.NotNull(build);
        }
        private bool Visit(string tocFilePath, BuildLogger logger)
        {
            _projectName = String.Empty;
            _projectFile = String.Empty;

            if (String.IsNullOrEmpty(tocFilePath))
            {
                return(false);
            }
            ReferenceTocLayoutType layoutType = _tocLayout.LayoutType;

            if (layoutType == ReferenceTocLayoutType.None ||
                layoutType == ReferenceTocLayoutType.Null ||
                layoutType == ReferenceTocLayoutType.Flat)
            {
                return(false);
            }

            XPathDocument  document          = new XPathDocument(tocFilePath);
            XPathNavigator documentNavigator = document.CreateNavigator();
            XPathNavigator projectNode       = documentNavigator.SelectSingleNode(
                "topics/topic[starts-with(@id, 'R:')]");

            if (projectNode != null)
            {
                _projectName = projectNode.GetAttribute("id", String.Empty);
                if (_projectName == null)
                {
                    _projectName = String.Empty;
                }
                _projectFile = projectNode.GetAttribute("file", String.Empty);
                if (_projectFile == null)
                {
                    _projectFile = String.Empty;
                }
            }

            XPathNavigator rootNode = projectNode;

            if (rootNode == null)
            {
                rootNode = documentNavigator.SelectSingleNode("topics");
            }

            XPathNodeIterator iterator = rootNode.Select(
                "topic[starts-with(@id, 'N:')]");

            if (iterator == null || iterator.Count == 0)
            {
                return(false);
            }

            _undocumentedNodes =
                new List <KeyValuePair <string, HierarchicalTocNode> >();
            _namingMethod = this.EngineSettings.Naming;
            _tocFilePath  = tocFilePath;

            _dicNavigators = new BuildDictionary <XPathNavigator>();

            if (layoutType == ReferenceTocLayoutType.Hierarchical)
            {
                _tocContents = new HierarchicalTocContent();
                _tocContents.BeginItems(_projectName, _projectFile);

                foreach (XPathNavigator navigator in iterator)
                {
                    string nsText = navigator.GetAttribute("id", String.Empty);
                    if (!String.IsNullOrEmpty(nsText) && nsText.Length > 2)
                    {
                        nsText = nsText.Substring(2);
                        string projName = navigator.GetAttribute("project", String.Empty);
                        string fileName = navigator.GetAttribute("file", String.Empty);

                        if (_tocContents.AddItem(nsText, projName, fileName))
                        {
                            _dicNavigators.Add(nsText, navigator.Clone());
                        }
                    }
                }

                _tocContents.EndItems();
            }
            else if (layoutType == ReferenceTocLayoutType.Custom)
            {
                _tocContents = this.Group.Content.HierarchicalToc;

                if (_tocContents != null)
                {
                    foreach (XPathNavigator navigator in iterator)
                    {
                        string nsText = navigator.GetAttribute("id", String.Empty);
                        if (!String.IsNullOrEmpty(nsText) && nsText.Length > 2)
                        {
                            nsText = nsText.Substring(2);
                            string projName = navigator.GetAttribute("project", String.Empty);
                            string fileName = navigator.GetAttribute("file", String.Empty);

                            _dicNavigators.Add(nsText, navigator.Clone());
                        }
                    }
                }
            }

            if (_tocContents == null)
            {
                return(false);
            }

            _rootNode = _tocContents.RootNode;

            return(_rootNode != null);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            //bag intr-un dictionar: cheie (nume elev)-> valoare clasa. dintr-un fisier initial.

            var excelElevi = new ExcelQueryFactory(@"F:\Downloads\newbddorna.xlsx"); //iau excel-ul cu baza de date
            var dataElevi  = (from c in excelElevi.Worksheet <ModelElevi>("BAZA")
                              select c)?.ToList();

            Dictionary <string, string> idToClass = new Dictionary <string, string>();

            idToClass = new BuildDictionary().GetDb(); //build the dictionary between id's and class

            Dictionary <string, int> classToNormal = new Dictionary <string, int>();

            classToNormal["XII"] = 12;
            classToNormal["XI"]  = 11;
            classToNormal["X"]   = 10;
            classToNormal["IX"]  = 9;
            classToNormal["VI"]  = 6;



            var excel = new ExcelQueryFactory(@"F:\Downloads\DornaGood.xlsx"); // de aici iau xlsx-ul cu rezultate (bnnm.xlsx)
            var data  = (from c in excel.Worksheet <ModelToExport>("Dorna")    //sheet-ul unde e rezultatul
                         select c)?.ToList();

            foreach (ModelToExport item in data)
            {
                Type   type         = item.GetType();
                var    propertyInfo = type.GetProperties();
                string id           = item.ID;
                string clasa        = idToClass[id];

                //add to cloud db the results
                var resultToAdd = new Rezultate
                {
                    Nume    = item.Nume,
                    Prenume = item.Prenume,
                    Scoala  = item.Scoala,
                    Clasa   = classToNormal[clasa]
                };

                //loop over all the properties
                foreach (var prop in propertyInfo)
                {
                    if (FactoryChooseClass.GetClasa(clasa).Contains(prop.Name))
                    {
                        object val = prop.GetValue(item, null); //valoarea
                        if (val != null)
                        {
                            //see if you can convert the value
                            AssignPointToModel.AssignProblemPoint(ref resultToAdd, val);
                        }
                    }
                }

                //save in db (local or azure)
            }


            //IRepository<Rezultate> repo = new LocalRepository();
            //repo.Add(new Rezultate { Clasa = 12, Nume = "Mock1", P1 = 30, P2 = 20, P3 = 15, Prenume = "PrenMock", Scoala = "Cnlr" });
            //repo.Save();

            //IRepository<Rezultate> repo = new AzureRepository();
            //repo.Add(new Rezultate { Clasa = 12, Nume = "Mock1", P1 = 30, P2 = 20, P3 = 15, Prenume = "PrenMock", Scoala = "Cnlr" });
            //repo.Save();

            Console.WriteLine("Hello Luciiiii");
            Console.ReadLine();
        }