Пример #1
0
        protected void SummaryTab()
        {
            Worksheet sht = Workbook.Worksheets.AddNamed("Summary");

            sht.Cells.AddValueCell(1, 1, "Group No", _fmtHeaderCell);
            sht.Cells.AddValueCell(1, 2, "Group Name", _fmtHeaderCell);
            sht.Cells.AddValueCell(1, 3, "Category", _fmtHeaderCell);

            sht.Cells.AddValueCell(1, 4, "Total Points", _fmtHeaderCell);
            sht.Cells.AddValueCell(1, 5, "Total Time", _fmtHeaderCell);
            sht.Cells.AddValueCell(1, 6, "Time Disqualified", _fmtHeaderCell);
            sht.Cells.AddValueCell(1, 7, "Nett Points", _fmtHeaderCell);

            for (int r = 0; r < _dataSet.ReportGroup.Rows.Count; r++)
            {
                EmitScoreDataSet.ReportGroupRow g        = _dataSet.ReportGroup[r];
                EmitScoreDataSet.CategoryRow    category = _dataSet.Category.FindByCategoryId(g.CategoryId);

                sht.Cells.AddValueCell(r + 2, 1, g.GroupId, _fmtText);
                sht.Cells.AddValueCell(r + 2, 2, g.GroupName, _fmtText);
                sht.Cells.AddValueCell(r + 2, 3, category.CategoryName, _fmtText);

                EmitScoreDataSet.ReportGroupResultRow[] gr =
                    (EmitScoreDataSet.ReportGroupResultRow[])
                    _dataSet.ReportGroupResult.Select(String.Format("GroupId='{0}'", g.GroupId));

                if (!g.IsTotalPointsNull())
                {
                    sht.Cells.AddValueCell(r + 2, 4, g.TotalPoints, _fmtData);
                }

                if (!g.IsTotalTimeSecondsNull())
                {
                    DateTime totalTime = Swipe.CreateBaseDate();
                    totalTime = totalTime.AddSeconds(g.TotalTimeSeconds);
                    sht.Cells.AddValueCell(r + 2, 5, totalTime.ToString("HH:mm:ss"), _fmtTimestamp);
                }
                if (!g.IsTimeDisqualifiedNull())
                {
                    if (g.TimeDisqualified == 1)
                    {
                        sht.Cells.AddValueCell(r + 2, 6, "Yes", _fmtText);
                    }
                }
                if (!g.IsNettPointsNull())
                {
                    sht.Cells.AddValueCell(r + 2, 7, g.NettPoints, _fmtData);
                }
            }
        }
Пример #2
0
        protected void ProcessBadgeData(string data)
        {
            BadgeData badge = null;

            try
            {
                badge = new BadgeData(_groupMap, _locationMap, data);
            }
            catch (Exception e)
            {
                MessageBox.Show(String.Format("{0}\n\n{1}",
                                              e.Message, e.StackTrace), "Error processing Badge",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (badge.IsValidBadge)
            {
                _sslRegister.Text = String.Format("Data received at {0}", DateTime.Now);

                if (RegisterMode)
                {
                    try
                    {
                        EmitScoreDataSet.GroupDataTable groupTable = new EmitScoreDataSet.GroupDataTable();
                        EmitScoreDataSet.GroupRow       groupRow   = groupTable.NewGroupRow();
                        groupRow.GroupId = badge.BadgeNo;
                        EmitScoreDataSet.CategoryRow defaultCat = (EmitScoreDataSet.CategoryRow)_dataSet.Category.Rows[0];
                        groupRow.CategoryId = defaultCat.CategoryId;

                        groupTable.AddGroupRow(groupRow);
                        groupTableAdapter.Update(groupTable);
                    }
                    catch (Exception)
                    {
                    }

                    FrmNewGroup newGroup = new FrmNewGroup(badge.BadgeNo);
                    newGroup.ShowDialog();
                }
                else
                {
                    // Retrieve the Group row
                    EmitScoreDataSet.GroupDataTable groupTable = new EmitScoreDataSet.GroupDataTable();
                    groupTableAdapter.Fill(groupTable);
                    EmitScoreDataSet.GroupRow groupRow = groupTable.FindByGroupId(badge.BadgeNo);

                    // Reset Group points to zero (they will be accumulated below)
                    badge.SwipeList.TotalPoints = 0;

                    // Delete any existing result rows for this badge
                    EmitScoreDataSet.GroupResultDataTable resultTable = new EmitScoreDataSet.GroupResultDataTable();
                    groupResultTableAdapter.Fill(resultTable);
                    foreach (DataRow delRow in resultTable.Select(String.Format("GroupId='{0}'", badge.BadgeNo)))
                    {
                        delRow.Delete();
                    }
                    groupResultTableAdapter.Update(resultTable);
                    resultTable.Clear();
                    groupResultTableAdapter.Fill(resultTable);

                    // Get the Team Results - to check if any other teams have visited these points
                    EmitScoreDataSet.TeamResultsDataTable teamResTable = new EmitScoreDataSet.TeamResultsDataTable();
                    teamResultsTableAdapter.Fill(teamResTable);

                    foreach (Swipe swipe in badge.SwipeList)
                    {
                        bool existingLocation = false;

                        if (!groupRow.IsTeamIdNull())
                        {
                            DataRow[] dr = teamResTable.Select(
                                String.Format("TeamId='{0}' AND LocationId='{1}'",
                                              groupRow.TeamId,
                                              swipe.Location.CourseLocation.LocationId));

                            existingLocation = (dr.Length > 0);
                        }

                        EmitScoreDataSet.GroupResultRow resultRow = resultTable.NewGroupResultRow();
                        resultRow.GroupId    = badge.BadgeNo;
                        resultRow.LocationId = swipe.Location.LocationId;

                        if (existingLocation)
                        {
                            // Someone else in the team has collected this Location's points
                            swipe.Points = 0;
                        }

                        resultRow.Points             = swipe.Points;
                        badge.SwipeList.TotalPoints += swipe.Points;
                        resultRow.Time    = swipe.LocationTime;
                        resultRow.CumTime = swipe.CummulativeTime;
                        resultRow.EndEdit();
                        resultTable.AddGroupResultRow(resultRow);
                    }
                    groupResultTableAdapter.Update(resultTable);

                    badge.SwipeList.AdjustPoints(); // After points deductions, adjust for time

                    // Now populate the parent record
                    groupRow.BeginEdit();
                    groupRow.TotalPoints      = badge.SwipeList.TotalPoints;
                    groupRow.NettPoints       = badge.SwipeList.NettPoints;
                    groupRow.TotalTime        = badge.SwipeList.TotalTime;
                    groupRow.TimeDisqualified = badge.SwipeList.TimeDisqualified;
                    groupRow.EndEdit();

                    if (groupRow.TotalTime > DateTime.MinValue)
                    {
                        groupTableAdapter.Update(groupRow);
                        groupRow.AcceptChanges();
                    }

                    if (!groupRow.IsTeamIdNull())
                    {
                        // Check to see if this group, or any others in the team
                        // have been time disqualified, and disqualify them all
                        groupTable = new EmitScoreDataSet.GroupDataTable();
                        groupTableAdapter.Fill(groupTable);
                        bool anyDisqualified = false;
                        foreach (EmitScoreDataSet.GroupRow gr1 in groupTable)
                        {
                            if (!gr1.IsTeamIdNull() && (gr1.TeamId == groupRow.TeamId))
                            {
                                if (!gr1.IsTimeDisqualifiedNull() && (gr1.TimeDisqualified == 1))
                                {
                                    anyDisqualified = true;
                                }
                            }
                        }
                        if (anyDisqualified)
                        {
                            foreach (EmitScoreDataSet.GroupRow gr1 in groupTable)
                            {
                                if (!gr1.IsTeamIdNull() && (gr1.TeamId == groupRow.TeamId))
                                {
                                    gr1.BeginEdit();
                                    gr1.NettPoints       = 0;
                                    gr1.TimeDisqualified = 1;
                                    gr1.EndEdit();
                                    groupTableAdapter.Update(gr1);
                                    gr1.AcceptChanges();
                                }
                            }
                        }
                    }

                    MessageBox.Show(String.Format("Group {0} - {1} results received.",
                                                  groupRow.GroupId, groupRow.GroupName), "Results Received",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Пример #3
0
        protected void ProcessBadgeData(string data)
        {
            BadgeData badge = null;

            try
            {
                badge = new BadgeData(_locationMap, data);
            }
            catch (Exception e)
            {
                MessageBox.Show(String.Format("{0}\n\n{1}",
                                              e.Message, e.StackTrace), "Error processing Badge",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (badge.IsValidBadge)
            {
                _sslRegister.Text = String.Format("Data received at {0}", DateTime.Now);

                if (RegisterMode)
                {
                    try
                    {
                        EmitScoreDataSet.GroupDataTable groupTable = new EmitScoreDataSet.GroupDataTable();
                        EmitScoreDataSet.GroupRow       groupRow   = groupTable.NewGroupRow();
                        groupRow.GroupId = badge.BadgeNo;
                        EmitScoreDataSet.CategoryRow defaultCat = (EmitScoreDataSet.CategoryRow)_dataSet.Category.Rows[0];
                        groupRow.CategoryId = defaultCat.CategoryId;

                        groupTable.AddGroupRow(groupRow);
                        groupTableAdapter.Update(groupTable);
                    }
                    catch (Exception)
                    {
                    }

                    FrmNewGroup newGroup = new FrmNewGroup(badge.BadgeNo);
                    newGroup.ShowDialog();
                }
                else
                {
                    // Retrieve the Group row
                    EmitScoreDataSet.GroupDataTable groupTable = new EmitScoreDataSet.GroupDataTable();
                    groupTableAdapter.Fill(groupTable);
                    EmitScoreDataSet.GroupRow groupRow = groupTable.FindByGroupId(badge.BadgeNo);

                    // Delete any existing result rows for this badge
                    EmitScoreDataSet.GroupResultDataTable resultTable = new EmitScoreDataSet.GroupResultDataTable();
                    groupResultTableAdapter.Fill(resultTable);
                    foreach (DataRow delRow in resultTable.Select(String.Format("GroupId='{0}'", badge.BadgeNo)))
                    {
                        delRow.Delete();
                    }
                    groupResultTableAdapter.Update(resultTable);
                    resultTable.Clear();
                    groupResultTableAdapter.Fill(resultTable);

                    foreach (Swipe swipe in badge.SwipeList)
                    {
                        EmitScoreDataSet.GroupResultRow resultRow = resultTable.NewGroupResultRow();
                        resultRow.GroupId    = badge.BadgeNo;
                        resultRow.LocationId = swipe.Location.Id;

                        resultRow.Points  = swipe.Points;
                        resultRow.Time    = swipe.LocationTime;
                        resultRow.CumTime = swipe.CummulativeTime;
                        resultRow.EndEdit();
                        resultTable.AddGroupResultRow(resultRow);
                    }
                    groupResultTableAdapter.Update(resultTable);

                    badge.SwipeList.AdjustPoints(); // After points deductions, adjust for time

                    // Now populate the parent record
                    groupRow.BeginEdit();
                    groupRow.TotalPoints      = badge.SwipeList.TotalPoints;
                    groupRow.NettPoints       = badge.SwipeList.NettPoints;
                    groupRow.TotalTime        = badge.SwipeList.TotalTime;
                    groupRow.TimeDisqualified = badge.SwipeList.TimeDisqualified;
                    groupRow.EndEdit();
                    groupTableAdapter.Update(groupRow);
                    groupRow.AcceptChanges();

                    LastGroupHome(groupRow.GroupName, groupRow.NettPoints, groupRow.TotalTime);

                    MessageBox.Show(String.Format("Group {0} - {1} results received.",
                                                  groupRow.GroupId, groupRow.GroupName), "Results Received",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Пример #4
0
        protected void SummaryTab()
        {
            EmitScoreDataSet.LocationRow[] lr =
                (EmitScoreDataSet.LocationRow[])_dataSet.Location.Select();
            int lastLocCol = lr.Length + 3;

            Worksheet sht = Workbook.Worksheets.AddNamed("Summary");

            sht.Cells.AddValueCell(2, 1, "Group No", _fmtHeaderCell);
            sht.Cells.AddValueCell(2, 2, "Group Name", _fmtHeaderCell);
            sht.Cells.AddValueCell(2, 3, "Category", _fmtHeaderCell);

            for (int c = 0; c < lr.Length; c++)
            {
                sht.Cells.AddValueCell(1, c + 4, lr[c].LocationId, _fmtHeaderCell);
                if (!lr[c].IsLocationNameNull())
                {
                    // Output the name if there is one
                    sht.Cells.AddValueCell(2, c + 4, lr[c].LocationName, _fmtHeaderCell);
                }
                else
                {
                    // Or simply the index otherwise
                    sht.Cells.AddValueCell(2, c + 4, c + 1, _fmtHeaderCell);
                }
            }

            sht.Cells.AddValueCell(2, lastLocCol + 1, "Total Points", _fmtHeaderCell);
            sht.Cells.AddValueCell(2, lastLocCol + 2, "Nett Points", _fmtHeaderCell);
            sht.Cells.AddValueCell(2, lastLocCol + 3, "Total Time", _fmtHeaderCell);
            sht.Cells.AddValueCell(2, lastLocCol + 4, "Time Disqualified", _fmtHeaderCell);

            for (int r = 0; r < _dataSet.ReportGroup.Rows.Count; r++)
            {
                EmitScoreDataSet.ReportGroupRow g        = _dataSet.ReportGroup[r];
                EmitScoreDataSet.CategoryRow    category = _dataSet.Category.FindByCategoryId(g.CategoryId);

                sht.Cells.AddValueCell(r + 3, 1, g.GroupId, _fmtText);
                sht.Cells.AddValueCell(r + 3, 2, g.GroupName, _fmtText);
                sht.Cells.AddValueCell(r + 3, 3, category.CategoryName, _fmtText);

                EmitScoreDataSet.ReportGroupResultRow[] gr =
                    (EmitScoreDataSet.ReportGroupResultRow[])
                    _dataSet.ReportGroupResult.Select(String.Format("GroupId='{0}'", g.GroupId));

                // Now export the points for each Location
                for (int c = 0; c < lr.Length; c++)
                {
                    for (int p = 0; p < gr.Length; p++)
                    {
                        if (gr[p].LocationId == lr[c].LocationId)
                        {
                            // Found the Location
                            sht.Cells.AddValueCell(r + 3, c + 4, gr[p].Points, _fmtData);
                        }
                    }
                }

                if (!g.IsTotalPointsNull())
                {
                    sht.Cells.AddValueCell(r + 3, lastLocCol + 1, g.TotalPoints, _fmtData);
                }
                if (!g.IsNettPointsNull())
                {
                    sht.Cells.AddValueCell(r + 3, lastLocCol + 2, g.NettPoints, _fmtData);
                }
                if (!g.IsTotalTimeSecondsNull())
                {
                    DateTime totalTime = Swipe.CreateBaseDate();
                    totalTime = totalTime.AddSeconds(g.TotalTimeSeconds);
                    sht.Cells.AddValueCell(r + 3, lastLocCol + 3, totalTime.ToString("HH:mm:ss"), _fmtTimestamp);
                }
                if (!g.IsTimeDisqualifiedNull())
                {
                    if (g.TimeDisqualified == 1)
                    {
                        sht.Cells.AddValueCell(r + 3, lastLocCol + 4, "Yes", _fmtText);
                    }
                }
            }
        }