Ejemplo n.º 1
0
        private GroupDetails FetchGroupDetails(VoterGroup group)
        {
            var details = new GroupDetails { GroupId = group.GroupId, Average = group.Average, Count = group.AllVoters.Count };

            if (group.ParentGroup != null)
                details.ParentGroupId = group.ParentGroup.GroupId;

            return details;
        }
Ejemplo n.º 2
0
        private HeatMapInfo FetchHeatMap(VoterGroup group)
        {
            if (group == null) return null;

            HeatMapInfo info = new HeatMapInfo();

            info.CurrentGroupDetails = FetchGroupDetails(group);

            info.SubGroupDetails = new List<GroupDetails>();

            group.SubGroups.ForEach(s => info.SubGroupDetails.Add(FetchGroupDetails(s)));

            return info;
        }
Ejemplo n.º 3
0
        private static void BuildIndex(VoterGroup group)
        {
            if (!_groupIndex.ContainsKey(group.GroupId)) _groupIndex[group.GroupId] = group;

            //Build Voter Index
            foreach (var voter in group.DirectChildren)
            {
                _voterIndex[voter.Id] = voter;
            }

            foreach (var subGroup in group.SubGroups)
            {
                BuildIndex(subGroup);
            }
        }
Ejemplo n.º 4
0
        private static void DummyTree()
        {
            VoterGroup VoterTreeRoot = new VoterGroup
            {
                GroupId = "Dummy root",
                DirectChildren = new List<Voter>
                {
                    new Voter{Id= "Top Boss"},
                    new Voter{Id= "Second Top Boss"}
                },
                SubGroups = new List<VoterGroup>
                {
                    new VoterGroup
                    {
                        GroupId = "Team 1",
                        DirectChildren = new List<Voter>
                        {
                            new Voter{Id="Employee1"},
                            new Voter{Id="Employee2"}
                        },
                        SubGroups= new List<VoterGroup>
                        {
                            new VoterGroup
                            {
                                GroupId = "SubTeam",
                                DirectChildren = new List<Voter>
                                {
                                    new Voter{Id = "SubTeam Employee1"},
                                    new Voter{Id = "SubTeam Employee2"},
                                }
                            }
                        }
                    },
                    new VoterGroup
                    {
                        GroupId = "Team 2",
                        DirectChildren = new List<Voter>
                        {
                            new Voter{Id="Employee3"},
                            new Voter{Id="Employee4"},
                            new Voter{Id="Employee5"}
                        }
                    }
                }
            };

            XmlSerializer serializer = new XmlSerializer(typeof(VoterGroup));
            TextWriter textWriter = new StreamWriter(usersFileName);
            serializer.Serialize(textWriter, VoterTreeRoot);
            textWriter.Close();
        }
Ejemplo n.º 5
0
        private static void PopolateAllVotersWithInEachSubGroup(VoterGroup group)
        {
            group.AllVoters = new List<Voter>();
            group.AllVoters.AddRange(group.DirectChildren);

            if (group.SubGroups != null && group.SubGroups.Count > 0)
            {
                group.SubGroups.ForEach(s => s.ParentGroup = group);

                group.SubGroups.ForEach(PopolateAllVotersWithInEachSubGroup);

                group.SubGroups.ForEach(s => group.AllVoters.AddRange(s.AllVoters));
            }
        }
Ejemplo n.º 6
0
 private static void LoadTree()
 {
     XmlSerializer deserializer = new XmlSerializer(typeof(VoterGroup));
     TextReader textReader = new StreamReader(usersFileName);
     RootNode = (VoterGroup)deserializer.Deserialize(textReader);
     textReader.Close();
 }