Пример #1
0
 public static ClassRankInfo Create(ClassRank classRank)
 {
     return(new ClassRankInfo
     {
         Rank = classRank.Rank,
         ClassSize = classRank.ClassSize
     });
 }
Пример #2
0
        public void TestRanknDirNoPoly()
        {
            Type         tMitarbeiter;
            Type         tReise;
            List <Class> classes = new List <Class>();


            Class cls = new Class(null);

            cls.FullName = "Mitarbeiter";
            tMitarbeiter = cls.SystemType = CreateType(cls.FullName).Object;
            var oid = new ClassOid(cls);

            oid.OidColumns.Add(new OidColumn(oid)
            {
                AutoIncremented = true
            });
            cls.Oid = oid;

            Mock <Relation> rel1Mock = new Mock <Relation>(cls);

            rel1Mock.Setup(t => t.Bidirectional).Returns(false);
            Relation        relation  = rel1Mock.Object;
            List <Relation> relations = (List <Relation>)cls.Relations;

            relations.Add(relation);
            relation.FieldName          = "reisen";
            relation.ReferencedTypeName = "Reise";
            relation.RelationName       = string.Empty;
            relation.Multiplicity       = RelationMultiplicity.List;
            relation.Composition        = true;
            relation.HasSubclasses      = false;

            classes.Add(cls);

            cls          = new Class(null);
            cls.FullName = "Reise";
            tReise       = cls.SystemType = CreateType(cls.FullName).Object;
            oid          = new ClassOid(cls);
            cls.Oid      = oid;
            classes.Add(cls);

            rel1Mock.Setup(r => r.ReferencedSubClasses).Returns(new List <Class> {
                classes[1]
            });
            rel1Mock.Setup(r => r.ForeignRelation).Returns((Relation)null);

            ClassRank classRank  = new ClassRank();
            var       updateRank = classRank.BuildUpdateRank(classes);

            Assert.That(updateRank[tReise] == 1);
            Assert.That(updateRank[tMitarbeiter] == 0);
            classes.Reverse();
            classRank  = new ClassRank();
            updateRank = classRank.BuildUpdateRank(classes);
            Assert.That(updateRank[tReise] == 1);
            Assert.That(updateRank[tMitarbeiter] == 0);
        }
Пример #3
0
        public void TestRank1DirNoPoly()
        {
            Type         tMitarbeiter;
            Type         tAdresse;
            List <Class> classes = new List <Class>();

            Class cls1 = new Class(null);

            cls1.FullName = "Mitarbeiter";
            tMitarbeiter  = cls1.SystemType = CreateType(cls1.FullName).Object;
            var oid = new ClassOid(cls1);

            oid.OidColumns.Add(new OidColumn(oid)
            {
                AutoIncremented = true
            });
            cls1.Oid = oid;

            Mock <Relation> rel1Mock = new Mock <Relation>(cls1);

            rel1Mock.Setup(t => t.Bidirectional).Returns(false);
            Relation        relation  = rel1Mock.Object;
            List <Relation> relations = (List <Relation>)cls1.Relations;

            relations.Add(relation);
            relation.FieldName          = "adresse";
            relation.ReferencedTypeName = "Adresse";
            relation.RelationName       = string.Empty;
            relation.Multiplicity       = RelationMultiplicity.Element;
            relation.Composition        = true;
            relation.HasSubclasses      = false;

            classes.Add(cls1);

            Class cls2 = new Class(null);

            cls2.FullName = "Adresse";
            tAdresse      = cls2.SystemType = CreateType(cls2.FullName).Object;
            cls2.Oid      = oid;         // We can use the same oid, since the code asks only for autoincremented columns
            classes.Add(cls2);

            rel1Mock.Setup(r => r.ReferencedSubClasses).Returns(new List <Class> {
                cls2
            });
            rel1Mock.Setup(r => r.ForeignRelation).Returns((Relation)null);

            ClassRank classRank  = new ClassRank();
            var       updateRank = classRank.BuildUpdateRank(classes);

            Assert.That(updateRank[tMitarbeiter] == 1);
            Assert.That(updateRank[tAdresse] == 0);
            classes.Reverse();
            classRank  = new ClassRank();
            updateRank = classRank.BuildUpdateRank(classes);
            Assert.That(updateRank[tMitarbeiter] == 1);
            Assert.That(updateRank[tAdresse] == 0);
        }
Пример #4
0
        public StudentSummaryInfo GetStudentSummaryInfo(int studentId)
        {
            var classRank = new ClassRank
            {
                StudentId = studentId,
                ClassSize = 10
            };

            var syId = Context.SchoolYearId ?? ServiceLocator.SchoolYearService.GetCurrentSchoolYear().Id;

            var discipline = ((DemoDisciplineService)ServiceLocator.DisciplineService).GetList(DateTime.Today);

            var infractions = new List <StiConnector.Connectors.Model.Infraction>();

            foreach (var disciplineReferral in discipline.Where(disciplineReferral => disciplineReferral.Infractions != null))
            {
                infractions.AddRange(disciplineReferral.Infractions);
            }

            var chlkInfractions = ServiceLocator.InfractionService.GetInfractions();

            var infractionSummaries = from infr in infractions
                                      group infr by infr.Id
                                      into g
                                      select new { Id = g.Key, Count = g.Count() };

            var attendances =
                ((DemoAttendanceService)ServiceLocator.AttendanceService).GetStudentAbsenceSummary(studentId);

            var infractionSummary = infractionSummaries.Select(x => new InfractionSummary
            {
                StudentId    = studentId,
                InfractionId = x.Id,
                Occurrences  = x.Count
            }).ToList();

            var nowDashboard = new NowDashboard
            {
                ClassRank         = classRank,
                Infractions       = infractionSummary,
                SectionAttendance = new List <StudentSectionAbsenceSummary>(), //attendances,
                Scores            = ((DemoStudentAnnouncementService)ServiceLocator.StudentAnnouncementService).GetActivityScoresForStudent(studentId)
            };
            var student       = GetStudentDetails(studentId, syId);
            var activitiesids = nowDashboard.Scores.GroupBy(x => x.ActivityId).Select(x => x.Key).ToList();

            //TODO: impl
            var anns = new List <AnnouncementComplex>(); //((DemoAnnouncementService) ServiceLocator.ClassAnnouncementService).GetByActivitiesIds(activitiesids);
            var res  = StudentSummaryInfo.Create(student, nowDashboard, chlkInfractions, anns, MapperFactory.GetMapper <StudentAnnouncement, Score>());

            return(res);
        }
        private void BindData()
        {
            int pageIndex = Request.QueryString["pageIndex"] != null?int.Parse(Request.QueryString["pageIndex"]) : 1;

            int pageSize = 10;//页面记录数

            var className = Entity.SportsMan.GroupBy(a => a.Class).ToList();
            List <ClassRank> classRankList = new List <ClassRank>();

            foreach (var item in className)
            {
                ClassRank classRank = new ClassRank();
                classRank.ClassName = item.Key;
                var list = Entity.SignUp.Where(a => a.SportsMan.Class == item.Key);
                classRank.FirstNum  = list.Where(a => a.FinalRanK == 1).Count();
                classRank.SecondNum = list.Where(a => a.FinalRanK == 1).Count();
                classRank.ThirdNum  = list.Where(a => a.FinalRanK == 3).Count();
                classRank.AllNum    = classRank.FirstNum + classRank.SecondNum + classRank.ThirdNum;
                classRankList.Add(classRank);
            }
            int listCount = 0;

            //绑定记录
            if (string.IsNullOrEmpty(SreachWhere.Text))
            {
                classRankList = classRankList.Where(a => true).ToList();
                listCount     = classRankList.Count;
                classRankList = classRankList.OrderByDescending(a => a.AllNum).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            }
            else
            {
                classRankList = classRankList.Where(a => a.ClassName.Contains(SreachWhere.Text)).ToList();
                listCount     = classRankList.Count;
                classRankList = classRankList.OrderByDescending(a => a.AllNum).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            }
            string strBar = PageBar.GetPageBarType(pageIndex, listCount, pageSize);

            mPageBar = strBar;

            this.Repeater1.DataSource = classRankList;
            this.Repeater1.DataBind();
        }
Пример #6
0
        public void RankDictionaryWorksWithTheGivenMocks()
        {
            Type         t1;
            Type         t2;
            List <Class> classes = new List <Class>();

            // Create two classes with an arbitrary relation
            // Class 1
            Class cls = new Class(null);

            cls.FullName = "Mitarbeiter";
            t1           = cls.SystemType = CreateType(cls.FullName).Object;
            var oid = new ClassOid(cls);

            oid.OidColumns.Add(new OidColumn(oid)
            {
                AutoIncremented = true
            });
            cls.Oid = oid;

            Mock <Relation> rel1Mock = new Mock <Relation>(cls);

            rel1Mock.Setup(t => t.Bidirectional).Returns(false);
            Relation        relation  = rel1Mock.Object;
            List <Relation> relations = (List <Relation>)cls.Relations;

            relations.Add(relation);
            relation.FieldName          = "reisen";
            relation.ReferencedTypeName = "Reise";
            relation.RelationName       = string.Empty;
            relation.Multiplicity       = RelationMultiplicity.List;
            relation.Composition        = true;
            relation.HasSubclasses      = false;

            classes.Add(cls);

            // Class 2
            cls          = new Class(null);
            cls.FullName = "Reise";
            t2           = cls.SystemType = CreateType(cls.FullName).Object;
            cls.Oid      = oid;

            rel1Mock.Setup(r => r.ForeignRelation).Returns((Relation)null);

            classes.Add(cls);

            ClassRank classRank  = new ClassRank();
            var       updateRank = classRank.BuildUpdateRank(classes);

            // Make sure, that the types returned by the list
            // are equal to the types we assigned to the Class objects
            var list = updateRank.Keys.ToList();
            var tx   = list[0];
            var ty   = list[1];

            Assert.That(tx.GetHashCode() != ty.GetHashCode());
            Assert.That(!tx.Equals(ty));
            Assert.That(tx.Equals(t1) && ty.Equals(t2) || tx.Equals(t2) && ty.Equals(t1));
            Assert.That(!tx.Equals(t1) && !ty.Equals(t2) || !tx.Equals(t2) && !ty.Equals(t1));

            // Make sure, that indexing the updateRank dictionary works
            int rank = updateRank[t1];                          // Will throw an exception, if indexing doesn't work

            Assert.That(rank == 0 || rank == 1);                // Expected result with two classes...
        }
Пример #7
0
        public void TestRank1nRightPoly()
        {
            Type         tMitarbeiter;
            Type         tReise;
            List <Class> classes = new List <Class>();

            Class cls1 = new Class(null);

            cls1.FullName = "Mitarbeiter";
            tMitarbeiter  = cls1.SystemType = CreateType(cls1.FullName).Object;
            var oid = new ClassOid(cls1);

            oid.OidColumns.Add(new OidColumn(oid)
            {
                AutoIncremented = true
            });
            cls1.Oid = oid;

            Mock <Relation> rel1Mock = new Mock <Relation>(cls1);

            rel1Mock.Setup(t => t.Bidirectional).Returns(true);
            Relation        relation  = rel1Mock.Object;
            List <Relation> relations = (List <Relation>)cls1.Relations;

            relations.Add(relation);
            relation.FieldName          = "reisen";
            relation.ReferencedTypeName = "ReiseBase";
            relation.RelationName       = string.Empty;
            relation.Multiplicity       = RelationMultiplicity.List;
            relation.Composition        = true;
            relation.HasSubclasses      = false;

            classes.Add(cls1);

            Class cls2 = new Class(null);

            cls2.FullName = "Reise";
            tReise        = cls2.SystemType = CreateType(cls2.FullName).Object;
            oid           = new ClassOid(cls2);
            cls2.Oid      = oid;

            Class cls2Base = new Class(null);

            cls2Base.FullName   = "ReiseBase";
            cls2Base.SystemType = CreateType(cls2Base.FullName).Object;
            cls2Base.Oid        = oid;
            classes.Add(cls2Base);

            Mock <Relation> rel2Mock = new Mock <Relation>(cls2);

            rel2Mock.Setup(t => t.Bidirectional).Returns(true);
            relation  = rel2Mock.Object;
            relations = (List <Relation>)cls2.Relations;
            relations.Add(relation);
            relation.FieldName          = "mitarbeiter";
            relation.ReferencedTypeName = "Mitarbeiter";
            relation.RelationName       = string.Empty;
            relation.Multiplicity       = RelationMultiplicity.Element;
            relation.Composition        = false;
            relation.HasSubclasses      = false;

            classes.Add(cls2);

            rel1Mock.Setup(r => r.ReferencedSubClasses).Returns(new List <Class> {
                cls2, cls2Base
            });
            rel1Mock.Setup(r => r.ForeignRelation).Returns(rel2Mock.Object);
            rel2Mock.Setup(r => r.ReferencedSubClasses).Returns(new List <Class> {
                cls1
            });
            rel2Mock.Setup(r => r.ForeignRelation).Returns(rel1Mock.Object);

            ClassRank classRank  = new ClassRank();
            var       updateRank = classRank.BuildUpdateRank(classes);
            int       maRank     = updateRank[tMitarbeiter];

            Assert.That(updateRank[tReise] > maRank);
            Assert.That(updateRank[cls2Base.SystemType] > maRank);
            classes.Reverse();
            classRank  = new ClassRank();
            updateRank = classRank.BuildUpdateRank(classes);
            maRank     = updateRank[tMitarbeiter];
            Assert.That(updateRank[tReise] > maRank);
            Assert.That(updateRank[cls2Base.SystemType] > maRank);
        }
Пример #8
0
        public void TestRank()
        {
            Type         t1;
            Type         t2;
            List <Class> classes = new List <Class>();


            Class cls1 = new Class(null);

            cls1.FullName = "ShopFachklassen.AllgemeinZugabeGutschein";
            t1            = cls1.SystemType = CreateType(cls1.FullName).Object;
            var oid = new ClassOid(cls1);

            oid.OidColumns.Add(new OidColumn(oid)
            {
                AutoIncremented = true
            });
            cls1.Oid = oid;

            Mock <Relation> rel1Mock = new Mock <Relation>(cls1);

            rel1Mock.Setup(t => t.Bidirectional).Returns(true);
            Relation        relation  = rel1Mock.Object;
            List <Relation> relations = (List <Relation>)cls1.Relations;

            relations.Add(relation);
            relation.FieldName          = "code";
            relation.ReferencedTypeName = "ShopFachklassen.GutscheinCode";
            relation.RelationName       = string.Empty;
            relation.Multiplicity       = RelationMultiplicity.Element;
            relation.Composition        = true;
            relation.HasSubclasses      = false;

            classes.Add(cls1);

            Class cls2 = new Class(null);

            cls2.FullName = "ShopFachklassen.GutscheinCode";
            t2            = cls2.SystemType = CreateType(cls2.FullName).Object;
            cls2.Oid      = oid;

            Mock <Relation> rel2Mock = new Mock <Relation>(cls1);

            rel2Mock.Setup(t => t.Bidirectional).Returns(true);
            relation  = rel2Mock.Object;
            relations = (List <Relation>)cls2.Relations;
            relations.Add(relation);
            relation.FieldName          = "gutschein";
            relation.ReferencedTypeName = "ShopFachklassen.Gutschein";
            relation.RelationName       = string.Empty;
            relation.Multiplicity       = RelationMultiplicity.Element;
            relation.Composition        = false;
            relation.HasSubclasses      = false;

            rel1Mock.Setup(r => r.ForeignRelation).Returns(rel2Mock.Object);
            rel1Mock.Setup(r => r.ReferencedSubClasses).Returns(new List <Class> {
                cls2
            });
            rel2Mock.Setup(r => r.ForeignRelation).Returns(rel1Mock.Object);
            rel2Mock.Setup(r => r.ReferencedSubClasses).Returns(new List <Class> {
                cls1
            });

            classes.Add(cls2);
            ClassRank classRank  = new ClassRank();
            var       updateRank = classRank.BuildUpdateRank(classes);

            Assert.That(updateRank[t2] == 0);
            Assert.That(updateRank[t1] == 1);
            classes.Reverse();
            classRank  = new ClassRank();
            updateRank = classRank.BuildUpdateRank(classes);
            Assert.That(updateRank[t2] == 0);
            Assert.That(updateRank[t1] == 1);
        }
Пример #9
0
 public TypeMetricWithNamespace WithRank(ClassRank rank)
 {
     Rank = rank;
     return(this);
 }
 public TypeMetricWithNamespace WithRank(ClassRank rank)
 {
     Rank = rank;
     return this;
 }