Пример #1
0
    void UpdateExpAttacks()
    {
        List <Experiment> attackingExps = experiments;

        groupStats[GENERAL_ATTACK_GROUP_ID] = new GroupStats(this);
        foreach (AttackCondition ac in aConditions)
        {
            attackingExps = ac.ConditionMet(attackingExps);
        }
        if (attackingExps.Count > 1)
        {
            numInteracting = attackingExps.Count;
            foreach (Experiment e in attackingExps)
            {
                if (e.id == GENERAL_ATTACK_GROUP_ID)
                {
                    groupStats [GENERAL_ATTACK_GROUP_ID].AddToGroup(e.id);
                }
                else
                {
                    GetGroupStats(e.GetGroup()).InitAttack();
                }
                e.SetState(Experiment.ExpState.Attacking);
            }
            groupStats [GENERAL_ATTACK_GROUP_ID].InitAttack();
        }
    }
Пример #2
0
 private void PlayAllFixtures(GroupStats groupStats, IEnumerable<Fixture> fixtures)
 {
     foreach (var fixture in fixtures)
     {
         groupStats.TryApplyResult(A.MatchResult.ForFixture(fixture).WithScore(1, 0).Build());
     }
 }
Пример #3
0
        public void ShouldCreateFixtures()
        {
            var groupStats = new GroupStats(5, A.Team.Repeat(9), isNeutralGround: false, hasReturnRound: true);
            var dates = Enumerable.Repeat(A.Date, 16).ToArray();
            var fixtures = groupStats.CreateFixtures(A.CupSeason.Build(), dates);

            Assert.That(fixtures, Is.Not.Empty);
        }
Пример #4
0
        public void ShouldUpdateTeamStatsAfterMatch()
        {
            var groupStats = new GroupStats(1, A.Team.Repeat(4), isNeutralGround: false, hasReturnRound: false);
            var result = A.MatchResult.ForTeams(groupStats.Teams.ElementAt(0), groupStats.Teams.ElementAt(2)).WithScore(0, 1).Build();

            groupStats.TryApplyResult(result);

            Assert.That(groupStats.TeamStats[2].Played, Is.EqualTo(1));
        }
Пример #5
0
        public void ShouldNotApplyMatchResultMeantForOtherGroup()
        {
            var groupStats = new GroupStats(1, A.Team.Repeat(4), isNeutralGround: false, hasReturnRound: false);
            var result = A.MatchResult.ForTeams(A.Team.Build(), groupStats.Teams.ElementAt(2)).WithScore(0, 1).Build();

            bool hasAppliedResult = groupStats.TryApplyResult(result);

            Assert.That(hasAppliedResult, Is.False);
        }
Пример #6
0
        public void ShouldCompleteWhenAllMatchesPlayed()
        {
            var groupStats = new GroupStats(1, A.Team.Repeat(4), isNeutralGround: false, hasReturnRound: false);

            var dates = Enumerable.Repeat(A.Date, 3).ToArray();
            var fixtures = groupStats.CreateFixtures(A.CupSeason.Build(), dates);
            PlayAllFixtures(groupStats, fixtures);

            Assert.That(groupStats.IsCompleted, Is.True);
        }
Пример #7
0
 void JoinSelectedExps()
 {
     groupStats [JOINING_GROUP_ID]        = new GroupStats(this);
     groupStats [JOINING_GROUP_ID].center = societyCenter;
     numInteracting = 0;
     foreach (Experiment e in mouseSelectedExps)
     {
         numInteracting++;
         e.SetState(Experiment.ExpState.Moving);
         e.SetGroup(JOINING_GROUP_ID);
         groupStats [JOINING_GROUP_ID].AddToGroup(e.id);
     }
     groupStats [JOINING_GROUP_ID].ResortExps();
 }
Пример #8
0
            public ParkingAndOverstayGroupStats(GroupStats copyFromBase)
                : base()
            {
                // Copy member and property values from the base object
                Type t = copyFromBase.GetType();

                foreach (FieldInfo fieldInf in t.GetFields())
                {
                    fieldInf.SetValue(this, fieldInf.GetValue(copyFromBase));
                }
                foreach (PropertyInfo propInf in t.GetProperties())
                {
                    if (propInf.CanRead && propInf.CanWrite)
                    {
                        propInf.SetValue(this, propInf.GetValue(copyFromBase, null), null);
                    }
                }
            }
Пример #9
0
        public ValueGrouper(int low, int high, int numGroups)
        {
            mLowEnd    = low;
            mHighEnd   = high;
            mNumGroups = numGroups;
            mGroupSize = (mHighEnd - mLowEnd + 1) / (float)mNumGroups;
            mGroups    = new GroupStats[numGroups];

            //see ValueGroup.xls if questions on math.  it's not documented, but at least lets you play with different setups

            int mGroupStart = mLowEnd;
            int mGroupEnd;

            for (int x = 0; x < numGroups; x++)
            {
                mGroupEnd   = (int)Math.Truncate((x + 1) * mGroupSize + mLowEnd - 1);
                mGroups[x]  = new GroupStats(x, mGroupStart, mGroupEnd);
                mGroupStart = mGroupEnd + 1;
            }
            mGroups[mNumGroups - 1].end = mHighEnd;
        }
Пример #10
0
        public GroupStats BiggestGroupWithNeighbors()
        {
            GroupStats biggestGroup = BiggestGroup();
            GroupStats newGroup     = null;

            if (biggestGroup.groupNdx > 0 && mGroups[biggestGroup.groupNdx - 1].count > 0)
            {
                GroupStats groupBefore = mGroups[biggestGroup.groupNdx - 1];
                newGroup       = new GroupStats(-999, groupBefore.start, biggestGroup.end);
                newGroup.count = groupBefore.count + biggestGroup.count;
                newGroup.sum   = groupBefore.sum + biggestGroup.sum;
                newGroup.min   = groupBefore.min;
                newGroup.max   = biggestGroup.max;
            }
            if (biggestGroup.groupNdx < NumGroups - 1 && mGroups[biggestGroup.groupNdx + 1].count > 0)
            {
                GroupStats groupAfter = mGroups[biggestGroup.groupNdx + 1];
                if (newGroup == null)
                {
                    newGroup       = new GroupStats(-999, biggestGroup.start, groupAfter.end);
                    newGroup.min   = biggestGroup.min;
                    newGroup.count = biggestGroup.count;
                    newGroup.sum   = biggestGroup.sum;
                }
                newGroup.max    = groupAfter.max;
                newGroup.count += groupAfter.count;
                newGroup.sum   += groupAfter.sum;
            }
            if (newGroup == null)
            {
                return(biggestGroup);
            }
            else
            {
                return(newGroup);
            }
        }
Пример #11
0
        public void GetReportAsExcelSpreadsheet(List <int> listOfMeterIDs, MemoryStream ms, CustomerLogic result)
        {
            timeIsolation.IsolationType = SensorAndPaymentReportEngine.TimeIsolations.None;

            // Start diagnostics timer
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            DateTime NowAtDestination = Convert.ToDateTime(this._CustomerConfig.DestinationTimeZoneDisplayName);

            // Now gather and analyze data for the report
            SensorAndPaymentReportEngine.RequiredDataElements requiredDataElements = new SensorAndPaymentReportEngine.RequiredDataElements();
            requiredDataElements.NeedsSensorData            = true;
            requiredDataElements.NeedsPaymentData           = false;
            requiredDataElements.NeedsOverstayData          = true;
            requiredDataElements.NeedsEnforcementActionData = true;

            this._ReportEngine = new SensorAndPaymentReportEngine(this._CustomerConfig, this._ReportParams);
            this._ReportEngine.GatherReportData(listOfMeterIDs, requiredDataElements, result);

            OfficeOpenXml.ExcelWorksheet ws = null;

            using (OfficeOpenXml.ExcelPackage pck = new OfficeOpenXml.ExcelPackage())
            {
                // Let's create a report coversheet and overall summary page, with hyperlinks to the other worksheets
                ws = pck.Workbook.Worksheets.Add("Details");

                // Render the standard report title lines
                rowIdx = 1; // Excel uses 1-based indexes
                colIdx = 1;
                RenderCommonReportTitle(ws, this._ReportName);

                // Render common report header for enforcement activity restriction filter, but only if its not for all activity
                if (this._ReportParams.ActionTakenRestrictionFilter != SensorAndPaymentReportEngine.ReportableEnforcementActivity.AllActivity)
                {
                    rowIdx++;
                    colIdx = 1;
                    RenderCommonReportFilterHeader_ActionTakenRestrictions(ws);
                }

                // Render common report header for regulated hour restriction filter
                rowIdx++;
                colIdx = 1;
                RenderCommonReportFilterHeader_RegulatedHourRestrictions(ws);

                using (OfficeOpenXml.ExcelRange rng = ws.Cells[2, 1, rowIdx, numColumnsMergedForHeader])
                {
                    rng.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;                 //Set Pattern for the background to Solid
                    rng.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.FromArgb(207, 221, 237)); //Set color to lighter blue FromArgb(184, 204, 228)
                }

                rowIdx++;
                rowIdx++;
                colIdx = 1;

                int detailsStartRow   = rowIdx;
                int detailColumnCount = 29;

                // Render the header row
                ws.SetValue(rowIdx, 1, "Space #");
                ws.SetValue(rowIdx, 2, "Meter #");
                ws.SetValue(rowIdx, 3, "Area #");
                ws.SetValue(rowIdx, 4, "Area");
                ws.SetValue(rowIdx, 5, "Event Timestamp");
                ws.SetValue(rowIdx, 6, "Record Timestamp");
                ws.SetValue(rowIdx, 7, "Latency");
                ws.SetValue(rowIdx, 8, "Occupied");
                ws.SetValue(rowIdx, 9, "Vacant Duration");
                ws.SetValue(rowIdx, 10, "Time Arrived");
                ws.SetValue(rowIdx, 11, "Time Departed");
                ws.SetValue(rowIdx, 12, "Parked Duration");
                ws.SetValue(rowIdx, 13, "Max Stay Regulation");
                ws.SetValue(rowIdx, 14, "Overstay Violation");
                ws.SetValue(rowIdx, 15, "Overstay Duration");
                ws.SetValue(rowIdx, 16, "Overstay (0-15min)");
                ws.SetValue(rowIdx, 17, "Overstay (15-30min)");
                ws.SetValue(rowIdx, 18, "Overstay (30-60min)");
                ws.SetValue(rowIdx, 19, "Overstay (>60min)");
                ws.SetValue(rowIdx, 20, "Violation Actioned");
                ws.SetValue(rowIdx, 21, "Violation Issued");
                ws.SetValue(rowIdx, 22, "Violation Warning");
                ws.SetValue(rowIdx, 23, "Violation Not Issued");
                ws.SetValue(rowIdx, 24, "Violation Fault");
                ws.SetValue(rowIdx, 25, "Violation Missed");
                ws.SetValue(rowIdx, 26, "Capture Rate (0-15min)");
                ws.SetValue(rowIdx, 27, "Capture Rate (15-30min)");
                ws.SetValue(rowIdx, 28, "Capture Rate (30-60min)");
                ws.SetValue(rowIdx, 29, "Capture Rate (>60min)");

                // Format the header row
                using (OfficeOpenXml.ExcelRange rng = ws.Cells[detailsStartRow, 1, detailsStartRow, 4])
                {
                    rng.Style.Font.Bold        = true;
                    rng.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;                 //Set Pattern for the background to Solid
                    rng.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.FromArgb(79, 129, 189));  //Set color to dark blue
                    rng.Style.Font.Color.SetColor(System.Drawing.Color.White);
                }
                using (OfficeOpenXml.ExcelRange rng = ws.Cells[detailsStartRow, 5, detailsStartRow, 8])
                {
                    rng.Style.Font.Bold        = true;
                    rng.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                    rng.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.FromArgb(36, 64, 98));
                    rng.Style.Font.Color.SetColor(System.Drawing.Color.White);
                }
                using (OfficeOpenXml.ExcelRange rng = ws.Cells[detailsStartRow, 9, detailsStartRow, 13])
                {
                    rng.Style.Font.Bold        = true;
                    rng.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                    rng.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.FromArgb(0, 176, 80));
                    rng.Style.Font.Color.SetColor(System.Drawing.Color.White);
                }
                using (OfficeOpenXml.ExcelRange rng = ws.Cells[detailsStartRow, 14, detailsStartRow, 29])
                {
                    rng.Style.Font.Bold        = true;
                    rng.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                    rng.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.FromArgb(150, 54, 52));
                    rng.Style.Font.Color.SetColor(System.Drawing.Color.White);
                }

                // Increment the row index, which will now be the 1st row of our data
                rowIdx++;
                detailsStartRow = rowIdx;

                timeIsolation.IsolationType = SensorAndPaymentReportEngine.TimeIsolations.None;
                GroupStats baseTotalStats = this._ReportEngine.GetOverallStats(timeIsolation);
                ParkingAndOverstayGroupStats totalStats = new ParkingAndOverstayGroupStats(baseTotalStats);

                #region Populate data for each record
                foreach (AreaAsset areaAsset in this._ReportEngine.ReportDataModel.AreasIncludedInReport)
                {
                    GroupStats baseAreaStats = this._ReportEngine.GetAreaStats(areaAsset.AreaID, timeIsolation);
                    ParkingAndOverstayGroupStats areaStats = new ParkingAndOverstayGroupStats(baseAreaStats);

                    foreach (SpaceAsset spaceAsset in this._ReportEngine.ReportDataModel.SpacesIncludedInReport)
                    {
                        // Skip record if its not applicable to the current area we are processing
                        if (spaceAsset.AreaID_PreferLibertyBeforeInternal != areaAsset.AreaID)
                        {
                            continue;
                        }

                        List <SensorAndPaymentReportEngine.CommonSensorAndPaymentEvent> spaceRecs = this._ReportEngine.ReportDataModel.FindRecsForBayAndMeter(spaceAsset.SpaceID, spaceAsset.MeterID);

                        TimeSpan previousVacantDuration = new TimeSpan(0);
                        SensorAndPaymentReportEngine.CommonSensorAndPaymentEvent previousOccupiedEvent = null;
                        foreach (SensorAndPaymentReportEngine.CommonSensorAndPaymentEvent repEvents in spaceRecs)
                        {
                            ws.SetValue(rowIdx, 1, repEvents.BayInfo.SpaceID);
                            ws.SetValue(rowIdx, 2, repEvents.BayInfo.MeterID);
                            if (areaAsset != null)
                            {
                                ws.SetValue(rowIdx, 3, areaAsset.AreaID);
                                ws.SetValue(rowIdx, 4, areaAsset.AreaName);
                            }

                            ws.SetValue(rowIdx, 5, repEvents.SensorEvent_Start);
                            ws.SetValue(rowIdx, 6, repEvents.SensorEvent_RecCreationDateTime);
                            ws.SetValue(rowIdx, 7, FormatTimeSpanAsHoursMinutesAndSeconds(repEvents.SensorEvent_Latency));
                            if (repEvents.SensorEvent_IsOccupied == true)
                            {
                                previousOccupiedEvent = repEvents;

                                ws.SetValue(rowIdx, 8, 1); // 1 for numeric version of "True"

                                if (previousVacantDuration.Ticks > 0)
                                {
                                    ws.SetValue(rowIdx, 9, FormatTimeSpanAsHoursMinutesAndSeconds(previousVacantDuration));
                                }

                                ws.SetValue(rowIdx, 10, repEvents.SensorEvent_Start);
                            }
                            else
                            {
                                ws.SetValue(rowIdx, 8, 0); // 1 for numeric version of "False"
                                ws.SetValue(rowIdx, 11, repEvents.SensorEvent_Start);

                                if (previousOccupiedEvent != null)
                                {
                                    bool firstOverstay = true;

                                    if (previousOccupiedEvent.Overstays.Count == 0)
                                    {
                                        ws.SetValue(rowIdx, 11, previousOccupiedEvent.SensorEvent_Start);
                                        ws.SetValue(rowIdx, 12, FormatTimeSpanAsHoursMinutesAndSeconds(previousOccupiedEvent.SensorEvent_Duration));

                                        RegulatedHoursDetail ruleForEvent = GetRegulationRuleAtEventTime(repEvents);
                                        if (ruleForEvent != null)
                                        {
                                            StringBuilder sb = new StringBuilder();
                                            sb.Append(ruleForEvent.MaxStayMinutes.ToString());
                                            ws.SetValue(rowIdx, 13, sb.ToString());
                                        }

                                        ws.SetValue(rowIdx, 14, "N");
                                    }

                                    foreach (SensorAndPaymentReportEngine.OverstayVioEvent overstay in previousOccupiedEvent.Overstays)
                                    {
                                        if (firstOverstay == false)
                                        {
                                            // Need to start new row and repeat the header info!
                                            rowIdx++;

                                            ws.SetValue(rowIdx, 1, previousOccupiedEvent.BayInfo.SpaceID);
                                            ws.SetValue(rowIdx, 2, previousOccupiedEvent.BayInfo.MeterID);
                                            if (areaAsset != null)
                                            {
                                                ws.SetValue(rowIdx, 3, areaAsset.AreaID);
                                                ws.SetValue(rowIdx, 4, areaAsset.AreaName);
                                            }

                                            ws.SetValue(rowIdx, 5, previousOccupiedEvent.SensorEvent_Start);
                                            ws.SetValue(rowIdx, 6, previousOccupiedEvent.SensorEvent_RecCreationDateTime);
                                            ws.SetValue(rowIdx, 7, FormatTimeSpanAsHoursMinutesAndSeconds(previousOccupiedEvent.SensorEvent_Latency));
                                            ws.SetValue(rowIdx, 8, 0); // 1 for numeric version of "False"
                                            ws.SetValue(rowIdx, 11, previousOccupiedEvent.SensorEvent_Start);
                                        }

                                        ws.SetValue(rowIdx, 12, FormatTimeSpanAsHoursMinutesAndSeconds(previousOccupiedEvent.SensorEvent_Duration));
                                        if (overstay.OverstayBasedOnRuleDetail != null)
                                        {
                                            StringBuilder sb = new StringBuilder();
                                            sb.Append(overstay.OverstayBasedOnRuleDetail.MaxStayMinutes.ToString());
                                            ws.SetValue(rowIdx, 13, sb.ToString());
                                        }

                                        ws.SetValue(rowIdx, 14, "Y");
                                        ws.SetValue(rowIdx, 15, FormatTimeSpanAsHoursMinutesAndSeconds(overstay.DurationOfTimeBeyondStayLimits));

                                        if (overstay.DurationOfTimeBeyondStayLimits.TotalMinutes < 15)
                                        {
                                            ws.SetValue(rowIdx, 16, "Y");
                                            areaStats.TotalOverstaysDuration0To15Mins++;
                                            totalStats.TotalOverstaysDuration0To15Mins++;
                                        }
                                        else if (overstay.DurationOfTimeBeyondStayLimits.TotalMinutes < 30)
                                        {
                                            ws.SetValue(rowIdx, 17, "Y");
                                            areaStats.TotalOverstaysDuration15To30Mins++;
                                            totalStats.TotalOverstaysDuration15To30Mins++;
                                        }
                                        else if (overstay.DurationOfTimeBeyondStayLimits.TotalMinutes < 60)
                                        {
                                            ws.SetValue(rowIdx, 18, "Y");
                                            areaStats.TotalOverstaysDuration30To60Mins++;
                                            totalStats.TotalOverstaysDuration30To60Mins++;
                                        }
                                        else
                                        {
                                            ws.SetValue(rowIdx, 19, "Y");
                                            areaStats.TotalOverstaysDurationOver60Mins++;
                                            totalStats.TotalOverstaysDurationOver60Mins++;
                                        }


                                        if (!string.IsNullOrEmpty(overstay.EnforcementActionTaken))
                                        {
                                            ws.SetValue(rowIdx, 20, "Y");
                                        }
                                        else
                                        {
                                            ws.SetValue(rowIdx, 20, "N");
                                        }


                                        if (string.Compare(overstay.EnforcementActionTaken, "Enforced", true) == 0)
                                        {
                                            ws.SetValue(rowIdx, 21, "Y");
                                        }
                                        else
                                        {
                                            ws.SetValue(rowIdx, 21, "N");
                                        }


                                        if (string.Compare(overstay.EnforcementActionTaken, "Cautioned", true) == 0)
                                        {
                                            ws.SetValue(rowIdx, 22, "Y");
                                        }
                                        else
                                        {
                                            ws.SetValue(rowIdx, 22, "N");
                                        }


                                        if (string.Compare(overstay.EnforcementActionTaken, "NotEnforced", true) == 0)
                                        {
                                            ws.SetValue(rowIdx, 23, "Y");
                                        }
                                        else
                                        {
                                            ws.SetValue(rowIdx, 23, "N");
                                        }


                                        if (string.Compare(overstay.EnforcementActionTaken, "Fault", true) == 0)
                                        {
                                            ws.SetValue(rowIdx, 24, "Y");
                                        }
                                        else
                                        {
                                            ws.SetValue(rowIdx, 24, "N");
                                        }


                                        if (string.IsNullOrEmpty(overstay.EnforcementActionTaken))
                                        {
                                            ws.SetValue(rowIdx, 25, "Y");

                                            ws.SetValue(rowIdx, 26, "N");
                                            ws.SetValue(rowIdx, 27, "N");
                                            ws.SetValue(rowIdx, 28, "N");
                                            ws.SetValue(rowIdx, 29, "N");
                                        }
                                        else
                                        {
                                            ws.SetValue(rowIdx, 25, "N");

                                            ws.SetValue(rowIdx, 26, "N");
                                            ws.SetValue(rowIdx, 27, "N");
                                            ws.SetValue(rowIdx, 28, "N");
                                            ws.SetValue(rowIdx, 29, "N");

                                            TimeSpan captureRate = (overstay.EnforcementActionTakenTimeStamp - overstay.StartOfOverstayViolation);
                                            if (captureRate.TotalMinutes < 15)
                                            {
                                                ws.SetValue(rowIdx, 26, "Y");
                                                areaStats.TotalOverstaysActioned0To15Mins++;
                                                totalStats.TotalOverstaysActioned0To15Mins++;
                                            }
                                            else if (captureRate.TotalMinutes < 30)
                                            {
                                                ws.SetValue(rowIdx, 27, "Y");
                                                areaStats.TotalOverstaysActioned15To30Mins++;
                                                totalStats.TotalOverstaysActioned15To30Mins++;
                                            }
                                            else if (captureRate.TotalMinutes < 60)
                                            {
                                                ws.SetValue(rowIdx, 28, "Y");
                                                areaStats.TotalOverstaysActioned30To60Mins++;
                                                totalStats.TotalOverstaysActioned30To60Mins++;
                                            }
                                            else
                                            {
                                                ws.SetValue(rowIdx, 29, "Y");
                                                areaStats.TotalOverstaysActionedOver60Mins++;
                                                totalStats.TotalOverstaysActionedOver60Mins++;
                                            }
                                        }

                                        // Set flag so we know we're no longer dealing with the first overstay of this occupied event
                                        firstOverstay = false;
                                    }
                                }
                            }

                            if (repEvents.SensorEvent_IsOccupied == false)
                            {
                                previousVacantDuration = new TimeSpan(repEvents.SensorEvent_Duration.Ticks);
                            }

                            // Increment the row index, which will now be the next row of our data
                            rowIdx++;
                        }
                    }

                    // Finish the area aggregations
                    areaStats.AggregateSelf();

                    colIdx = 1;
                    ws.SetValue(rowIdx, colIdx, "SUBTOTAL AREA");
                    MergeCellRange(ws, rowIdx, colIdx, rowIdx, 4);
                    using (OfficeOpenXml.ExcelRange rng = ws.Cells[rowIdx, colIdx, rowIdx, 29])
                    {
                        rng.Style.Font.Bold = true;
                    }

                    ws.SetValue(rowIdx, 7, FormatTimeSpanAsHoursMinutesAndSeconds(areaStats.AverageLatency));
                    ws.SetValue(rowIdx, 8, areaStats.ingress);
                    ws.SetValue(rowIdx, 9, areaStats.PercentVacantDuration.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 12, areaStats.PercentageOccupancy.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 14, areaStats.PercentOverstayedCount.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 15, areaStats.PercentageOverstayedDuration.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 16, areaStats.PercentOverstayedDuration_0To15Min.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 17, areaStats.PercentOverstayedDuration_15To30Min.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 18, areaStats.PercentOverstayedDuration_30To60Min.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 19, areaStats.PercentOverstayedDuration_Over60Min.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 20, areaStats.PercentOverstaysActioned.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 21, areaStats.PercentOverstaysIssued.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 22, areaStats.PercentOverstaysCautioned.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 23, areaStats.PercentOverstaysNotIssued.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 24, areaStats.PercentOverstaysFault.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 25, areaStats.PercentOverstaysMissed.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 26, areaStats.PercentOverstayedDuration_0To15Min.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 27, areaStats.PercentOverstayedDuration_15To30Min.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 28, areaStats.PercentOverstayedDuration_30To60Min.ToString("##0.00") + "%");
                    ws.SetValue(rowIdx, 29, areaStats.PercentOverstayedDuration_Over60Min.ToString("##0.00") + "%");

                    rowIdx++;
                    rowIdx++;
                }

                // Finish the total aggregations
                totalStats.AggregateSelf();

                colIdx = 1;
                ws.SetValue(rowIdx, colIdx, "TOTAL");
                MergeCellRange(ws, rowIdx, colIdx, rowIdx, 4);
                using (OfficeOpenXml.ExcelRange rng = ws.Cells[rowIdx, colIdx, rowIdx, 29])
                {
                    rng.Style.Font.Bold = true;
                }

                ws.SetValue(rowIdx, 7, FormatTimeSpanAsHoursMinutesAndSeconds(totalStats.AverageLatency));
                ws.SetValue(rowIdx, 8, totalStats.ingress);
                ws.SetValue(rowIdx, 9, totalStats.PercentVacantDuration.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 12, totalStats.PercentageOccupancy.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 14, totalStats.PercentOverstayedCount.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 15, totalStats.PercentageOverstayedDuration.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 16, totalStats.PercentOverstayedDuration_0To15Min.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 17, totalStats.PercentOverstayedDuration_15To30Min.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 18, totalStats.PercentOverstayedDuration_30To60Min.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 19, totalStats.PercentOverstayedDuration_Over60Min.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 20, totalStats.PercentOverstaysActioned.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 21, totalStats.PercentOverstaysIssued.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 22, totalStats.PercentOverstaysCautioned.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 23, totalStats.PercentOverstaysNotIssued.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 24, totalStats.PercentOverstaysFault.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 25, totalStats.PercentOverstaysMissed.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 26, totalStats.PercentOverstayedDuration_0To15Min.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 27, totalStats.PercentOverstayedDuration_15To30Min.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 28, totalStats.PercentOverstayedDuration_30To60Min.ToString("##0.00") + "%");
                ws.SetValue(rowIdx, 29, totalStats.PercentOverstayedDuration_Over60Min.ToString("##0.00") + "%");

                rowIdx++;
                rowIdx++;

                #endregion

                // AutoFilters aren't suitable for this report

                /*
                 * // We will add autofilters to our headers so user can sort the columns easier
                 * using (OfficeOpenXml.ExcelRange rng = ws.Cells[detailsStartRow - 1, 1, rowIdx, detailColumnCount])
                 * {
                 *  rng.AutoFilter = true;
                 * }
                 */

                ApplyNumberStyleToColumn(ws, 1, detailsStartRow, rowIdx, "########0", ExcelHorizontalAlignment.Left);
                ApplyNumberStyleToColumn(ws, 2, detailsStartRow, rowIdx, "########0", ExcelHorizontalAlignment.Left);
                ApplyNumberStyleToColumn(ws, 3, detailsStartRow, rowIdx, "########0", ExcelHorizontalAlignment.Left);
                ApplyNumberStyleToColumn(ws, 4, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Left);
                ApplyNumberStyleToColumn(ws, 5, detailsStartRow, rowIdx, "yyyy-mm-dd hh:mm:ss tt", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 6, detailsStartRow, rowIdx, "yyyy-mm-dd hh:mm:ss tt", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 7, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 8, detailsStartRow, rowIdx, "########0", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 9, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 10, detailsStartRow, rowIdx, "yyyy-mm-dd hh:mm:ss tt", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 11, detailsStartRow, rowIdx, "yyyy-mm-dd hh:mm:ss tt", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 12, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 13, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 14, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 15, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 16, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 17, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 18, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 19, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 20, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 21, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 22, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 23, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 24, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 25, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 26, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 27, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 28, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);
                ApplyNumberStyleToColumn(ws, 29, detailsStartRow, rowIdx, "@", ExcelHorizontalAlignment.Right);

                // And now lets size the columns
                for (int autoSizeColIdx = 1; autoSizeColIdx <= detailColumnCount; autoSizeColIdx++)
                {
                    using (OfficeOpenXml.ExcelRange col = ws.Cells[detailsStartRow - 1, autoSizeColIdx, rowIdx, autoSizeColIdx])
                    {
                        col.AutoFitColumns();
                    }
                }

                // And finally we will freeze the header rows for nicer scrolling
                ws.View.FreezePanes(7, 1);

                // All cells in spreadsheet are populated now, so render (save the file) to a memory stream
                byte[] bytes = pck.GetAsByteArray();
                ms.Write(bytes, 0, bytes.Length);
            }

            // Stop diagnostics timer
            sw.Stop();
            System.Diagnostics.Debug.WriteLine(this._ReportName + " generation took: " + sw.Elapsed.ToString());
        }
        protected override void RenderCommonHourlyData(ExcelWorksheet ws, int startRowIdx, ref int colIdx_HourlyCategory, int hourIdx, GroupStats hourlyStats)
        {
            if (this._ReportParams.IncludeHourlyStatistics == true)
            {
                int renderRowIdx = startRowIdx;
                int renderColIdx = colIdx_HourlyCategory + 1 + hourIdx;

                // Output and format hourly data cells
                ws.SetValue(renderRowIdx + 0, renderColIdx, FormatTimeSpanAsHoursMinutesAndSeconds(hourlyStats.TotalOccupancyTime));
                ws.SetValue(renderRowIdx + 1, renderColIdx, FormatTimeSpanAsHoursMinutesAndSeconds(hourlyStats.TotalOccupancyPaidTime));
                ws.SetValue(renderRowIdx + 2, renderColIdx, FormatTimeSpanAsHoursMinutesAndSeconds(hourlyStats.MaximumPotentialOccupancyTime));

                ws.SetValue(renderRowIdx + 3, renderColIdx, hourlyStats.PercentageOccupiedPaid);
                ApplyNumberStyleToCell(ws, renderRowIdx + 3, renderColIdx, "###0.00", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 4, renderColIdx, hourlyStats.PercentageOccupiedNotPaid);
                ApplyNumberStyleToCell(ws, renderRowIdx + 4, renderColIdx, "###0.00", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 5, renderColIdx, hourlyStats.ingress);
                ApplyNumberStyleToCell(ws, renderRowIdx + 5, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 6, renderColIdx, hourlyStats.egress);
                ApplyNumberStyleToCell(ws, renderRowIdx + 6, renderColIdx, "########0", ExcelHorizontalAlignment.Left);


                ws.SetValue(renderRowIdx + 7, renderColIdx, hourlyStats.PaymentCount);
                ApplyNumberStyleToCell(ws, renderRowIdx + 7, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 8, renderColIdx, hourlyStats.TotalZeroedOutEvents);
                ApplyNumberStyleToCell(ws, renderRowIdx + 8, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 9, renderColIdx, FormatTimeSpanAsHoursMinutesAndSeconds(hourlyStats.TotalZeroedOutDuration));

                ws.SetValue(renderRowIdx + 10, renderColIdx, hourlyStats.TotalPayViosActioned);
                ApplyNumberStyleToCell(ws, renderRowIdx + 10, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 11, renderColIdx, hourlyStats.PayVioCount);
                ApplyNumberStyleToCell(ws, renderRowIdx + 11, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 12, renderColIdx, hourlyStats.TotalPayViosEnforced);
                ApplyNumberStyleToCell(ws, renderRowIdx + 12, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 13, renderColIdx, hourlyStats.TotalPayViosCautioned);
                ApplyNumberStyleToCell(ws, renderRowIdx + 13, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 14, renderColIdx, hourlyStats.TotalPayViosNotEnforced);
                ApplyNumberStyleToCell(ws, renderRowIdx + 14, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 15, renderColIdx, hourlyStats.TotalPayViosFaulty);
                ApplyNumberStyleToCell(ws, renderRowIdx + 15, renderColIdx, "########0", ExcelHorizontalAlignment.Left);
            }
        }
Пример #13
0
        protected override void RenderCommonHourlyData(ExcelWorksheet ws, int startRowIdx, ref int colIdx_HourlyCategory, int hourIdx, GroupStats hourlyStats)
        {
            if (this._ReportParams.IncludeHourlyStatistics == true)
            {
                int renderRowIdx = startRowIdx;
                int renderColIdx = colIdx_HourlyCategory + 1 + hourIdx;

                // Output and format hourly data cells
                ws.SetValue(renderRowIdx + 0, renderColIdx, FormatTimeSpanAsHoursMinutesAndSeconds(hourlyStats.TotalOccupancyTime));
                ws.SetValue(renderRowIdx + 1, renderColIdx, FormatTimeSpanAsHoursMinutesAndSeconds(hourlyStats.MaximumPotentialOccupancyTime));

                ws.SetValue(renderRowIdx + 2, renderColIdx, hourlyStats.PercentageOccupancy);
                ApplyNumberStyleToCell(ws, renderRowIdx + 2, renderColIdx, "###0.00", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 3, renderColIdx, hourlyStats.ingress);
                ApplyNumberStyleToCell(ws, renderRowIdx + 3, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 4, renderColIdx, hourlyStats.egress);
                ApplyNumberStyleToCell(ws, renderRowIdx + 4, renderColIdx, "########0", ExcelHorizontalAlignment.Left);
            }
        }
Пример #14
0
        protected override void RenderCommonData(ExcelWorksheet ws, int startRowIdx, int startColIdx, ref int colIdx_HourlyCategory, GroupStats statsObj)
        {
            int colIdx_1stCommonColumn = startColIdx;
            int renderColIdx           = colIdx_1stCommonColumn;
            int renderRowIdx           = startRowIdx;

            ws.SetValue(renderRowIdx, renderColIdx, statsObj.OverstayCount);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.PayVioCount);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.OverstayCount + statsObj.PayVioCount);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalOverstaysActioned + statsObj.TotalPayViosActioned);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalOverstaysEnforced + statsObj.TotalPayViosEnforced);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalOverstaysCautioned + statsObj.TotalPayViosCautioned);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalOverstaysNotEnforced + statsObj.TotalPayViosNotEnforced);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalOverstaysFaulty + statsObj.TotalPayViosFaulty);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalViosActioned0To15Mins);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalViosActioned15To40Mins);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalViosActionedOver40Mins);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, (statsObj.OverstayCount + statsObj.PayVioCount) - (statsObj.TotalOverstaysActioned + statsObj.TotalPayViosActioned));


            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 0, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 1, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 2, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 3, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 4, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 5, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 6, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 7, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 8, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 9, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 10, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 11, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);

            // And now lets autosize the columns
            for (int autoSizeColIdx = colIdx_1stCommonColumn; autoSizeColIdx <= renderColIdx; autoSizeColIdx++)
            {
                using (OfficeOpenXml.ExcelRange col = ws.Cells[1, autoSizeColIdx, renderRowIdx, autoSizeColIdx])
                {
                    col.AutoFitColumns();
                    col.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
                }
            }

            // And now finally we must manually size the columns that have wrap text (autofit doesn't work nicely when we have wrap text)
            ws.Column(colIdx_1stCommonColumn + 0).Width  = 20;
            ws.Column(colIdx_1stCommonColumn + 1).Width  = 20;
            ws.Column(colIdx_1stCommonColumn + 2).Width  = 20;
            ws.Column(colIdx_1stCommonColumn + 3).Width  = 20;
            ws.Column(colIdx_1stCommonColumn + 4).Width  = 20;
            ws.Column(colIdx_1stCommonColumn + 5).Width  = 20;
            ws.Column(colIdx_1stCommonColumn + 6).Width  = 20;
            ws.Column(colIdx_1stCommonColumn + 8).Width  = 20;
            ws.Column(colIdx_1stCommonColumn + 9).Width  = 20;
            ws.Column(colIdx_1stCommonColumn + 10).Width = 20;
            ws.Column(colIdx_1stCommonColumn + 11).Width = 20;

            if (this._ReportParams.IncludeHourlyStatistics == true)
            {
                // Now we will construct the hourly category column, followed by hour detail columns

                ws.SetValue(renderRowIdx + 0, colIdx_HourlyCategory, "Overstay Violations");
                ws.SetValue(renderRowIdx + 1, colIdx_HourlyCategory, "Payment Violations");
                ws.SetValue(renderRowIdx + 2, colIdx_HourlyCategory, "Total Violations");
                ws.SetValue(renderRowIdx + 3, colIdx_HourlyCategory, "Total Actioned");
                ws.SetValue(renderRowIdx + 4, colIdx_HourlyCategory, "Total Enforced");
                ws.SetValue(renderRowIdx + 5, colIdx_HourlyCategory, "Total Cautioned");
                ws.SetValue(renderRowIdx + 6, colIdx_HourlyCategory, "Total Not Enforced");
                ws.SetValue(renderRowIdx + 7, colIdx_HourlyCategory, "Total Faulty");
                ws.SetValue(renderRowIdx + 8, colIdx_HourlyCategory, "Actioned < 15 mins");
                ws.SetValue(renderRowIdx + 9, colIdx_HourlyCategory, "Actioned 15 - 40 mins");
                ws.SetValue(renderRowIdx + 10, colIdx_HourlyCategory, "Actioned > 40 mins");
                ws.SetValue(renderRowIdx + 11, colIdx_HourlyCategory, "Total Missed");

                using (OfficeOpenXml.ExcelRange col = ws.Cells[renderRowIdx, colIdx_HourlyCategory, renderRowIdx + (numberOfHourlyCategories - 1), colIdx_HourlyCategory])
                {
                    col.Style.Font.Bold = true;
                }

                MergeCellRange(ws, renderRowIdx + 1, 1, renderRowIdx + (numberOfHourlyCategories - 1), colIdx_HourlyCategory - 1);
            }
        }
Пример #15
0
        public void ShouldCalculateRoundsPerTeamWhenHasReturnRound()
        {
            var groupStats = new GroupStats(3, A.Team.Repeat(4), isNeutralGround: false, hasReturnRound: true);

            Assert.That(groupStats.RoundsPerTeam, Is.EqualTo(6));
        }
Пример #16
0
    // It sorts experiments into groups,
    // populating group stats with info on each group, and
    // setting the group value of each experiment accordingly.
    void BucketExpsIntoGroups()
    {
        numInteracting = experiments.Count;
        int[] numInGroup = new int[numInteracting];
        List <Experiment>[] expGroups = new List <Experiment> [numInteracting];
        GroupStats[]        tempStats = new GroupStats[numInteracting];

        // Reset rogue spot bindings
        takenRogueSpot = new bool[rogueSpots.Length];

        // Figure what group each experiment goes in
        int allGroups = 0;

        numberOfGroups = 0;
        foreach (Experiment e in experiments)
        {
            if (numberOfGroups == allGroups)
            {
                numInGroup [allGroups++]   = 0;
                tempStats [numberOfGroups] = new GroupStats(this);
                expGroups [numberOfGroups] = new List <Experiment> ();
            }
            for (int i = 0; i < allGroups; i++)
            {
                // Check if experiment fits in group and set index to that group if it worked
                //print("Checking: " + e.name + "  " + e.id);
                if (tempStats [i].CanAddToGroup(e))
                {
                    expGroups [i].Add(e);
                    numInGroup [i]++;
                    if (i == numberOfGroups)
                    {
                        numberOfGroups++;
                    }
                    break;
                }
            }
        }

        // Index starts at NUM_EXTRA_GROUPS, because extra groups are at the beginning
        numberOfGroups = NUM_EXTRA_GROUPS;
        groupStats     = new GroupStats[experiments.Count + NUM_EXTRA_GROUPS];
        groupStats [ROGUE_GROUP_ID] = new GroupStats(this);
        for (int i = 0; i < allGroups; i++)
        {
            if (expGroups [i].Count > 1)
            {
                groupStats [numberOfGroups] = tempStats [i];
                groupStats [numberOfGroups].SetGroupSort(numInGroup [i]);
                foreach (Experiment e in expGroups[i])
                {
                    e.SetGroup(numberOfGroups);
                    groupStats [numberOfGroups].AddToGroup(e.id);
                }
                numberOfGroups++;
            }
            else if (numInGroup [i] > 0)
            {
                expGroups [i] [0].SetGroup(ROGUE_GROUP_ID);
                groupStats[ROGUE_GROUP_ID].AddToGroup(expGroups [i] [0].id);
            }
        }
        // print groups of experiments

        /*for (int i = 0; i < experiments.Count; i++) {
         *      print (experiments[i].name + "  " + experiments [i].GetGroup ());
         * }*/

        // Calculate where each group's centroid is.
        Vector2[] centroids = new Vector2[numberOfGroups];
        int       groupId;

        foreach (Experiment e in experiments)
        {
            groupId = e.GetGroup();
            if (centroids[groupId].Equals(default(Vector2)))
            {
                centroids[groupId] = new Vector2();
            }
            centroids[groupId] += (Vector2)e.transform.position;
        }
        for (int i = 0; i < centroids.Length; i++)
        {
            if (centroids[i].Equals(default(Vector2)))
            {
                continue;
            }
            centroids [i]        /= groupStats [i].numToSort;
            groupStats [i].center = centroids [i];
            //print (groupStats [i].center);
        }

        // Clip group centers to node points
        if (numberOfGroups > NUM_EXTRA_GROUPS)
        {
            node = (GameObject)Resources.Load("nodes/node" + (numberOfGroups - NUM_EXTRA_GROUPS).ToString());
            for (int i = 0; i < node.transform.childCount; i++)
            {
                Vector3 nodePos = node.transform.GetChild(i).transform.position;
                int     closest = -1;
                float   minDist = Mathf.Infinity, tempDist;
                for (int j = NUM_EXTRA_GROUPS; j < numberOfGroups; j++)
                {
                    if (groupStats [j].nodeFound)
                    {
                        continue;
                    }
                    tempDist = Vector3.Distance(groupStats [j].center, nodePos);
                    if (tempDist < minDist)
                    {
                        closest = j;
                        minDist = tempDist;
                    }
                }
                groupStats [closest].nodeFound = true;
                groupStats [closest].center    = societyCenter + nodePos;
                groupStats [closest].ResortExps();
            }
        }
    }
Пример #17
0
        protected override void RenderCommonData(ExcelWorksheet ws, int startRowIdx, int startColIdx, ref int colIdx_HourlyCategory, GroupStats statsObj)
        {
            int colIdx_1stCommonColumn = startColIdx;
            int renderColIdx           = colIdx_1stCommonColumn;
            int renderRowIdx           = startRowIdx;

            ws.SetValue(renderRowIdx, renderColIdx, FormatTimeSpanAsHoursMinutesAndSeconds(statsObj.TotalOccupancyTime));

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, FormatTimeSpanAsHoursMinutesAndSeconds(statsObj.MaximumPotentialOccupancyTime));

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.PercentageOccupancy);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.ingress);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.egress);

            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 2, renderRowIdx, renderRowIdx, "###0.00", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 3, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 4, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);

            // And now lets autosize the columns
            for (int autoSizeColIdx = colIdx_1stCommonColumn; autoSizeColIdx <= renderColIdx; autoSizeColIdx++)
            {
                using (OfficeOpenXml.ExcelRange col = ws.Cells[1, autoSizeColIdx, renderRowIdx, autoSizeColIdx])
                {
                    col.AutoFitColumns();
                    col.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
                }
            }

            // And now finally we must manually size the columns that have wrap text (autofit doesn't work nicely when we have wrap text)
            ws.Column(colIdx_1stCommonColumn + 1).Width = 20;
            ws.Column(colIdx_1stCommonColumn + 3).Width = 12;
            ws.Column(colIdx_1stCommonColumn + 4).Width = 12;

            if (this._ReportParams.IncludeHourlyStatistics == true)
            {
                // Now we will construct the hourly category column, followed by hour detail columns
                ws.SetValue(renderRowIdx + 0, colIdx_HourlyCategory, "Occupied Duration");
                ws.SetValue(renderRowIdx + 1, colIdx_HourlyCategory, "Max Possible Duration");
                ws.SetValue(renderRowIdx + 2, colIdx_HourlyCategory, "% Occupied");
                ws.SetValue(renderRowIdx + 3, colIdx_HourlyCategory, "Arrivals");
                ws.SetValue(renderRowIdx + 4, colIdx_HourlyCategory, "Departures");

                using (OfficeOpenXml.ExcelRange col = ws.Cells[renderRowIdx, colIdx_HourlyCategory, renderRowIdx + (numberOfHourlyCategories - 1), colIdx_HourlyCategory])
                {
                    col.Style.Font.Bold = true;
                }

                MergeCellRange(ws, renderRowIdx + 1, 1, renderRowIdx + (numberOfHourlyCategories - 1), colIdx_HourlyCategory - 1);
            }
        }
Пример #18
0
        protected override void RenderCommonHourlyData(ExcelWorksheet ws, int startRowIdx, ref int colIdx_HourlyCategory, int hourIdx, GroupStats hourlyStats)
        {
            if (this._ReportParams.IncludeHourlyStatistics == true)
            {
                int renderRowIdx = startRowIdx;
                int renderColIdx = colIdx_HourlyCategory + 1 + hourIdx;

                // Output and format hourly data cells
                ws.SetValue(renderRowIdx + 0, renderColIdx, hourlyStats.OverstayCount);
                ApplyNumberStyleToCell(ws, renderRowIdx + 0, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 1, renderColIdx, hourlyStats.PayVioCount);
                ApplyNumberStyleToCell(ws, renderRowIdx + 1, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 2, renderColIdx, hourlyStats.OverstayCount + hourlyStats.PayVioCount);
                ApplyNumberStyleToCell(ws, renderRowIdx + 2, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 3, renderColIdx, hourlyStats.TotalOverstaysActioned + hourlyStats.TotalPayViosActioned);
                ApplyNumberStyleToCell(ws, renderRowIdx + 3, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 4, renderColIdx, hourlyStats.TotalOverstaysEnforced + hourlyStats.TotalPayViosEnforced);
                ApplyNumberStyleToCell(ws, renderRowIdx + 4, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 5, renderColIdx, hourlyStats.TotalOverstaysCautioned + hourlyStats.TotalPayViosCautioned);
                ApplyNumberStyleToCell(ws, renderRowIdx + 5, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 6, renderColIdx, hourlyStats.TotalOverstaysNotEnforced + hourlyStats.TotalPayViosNotEnforced);
                ApplyNumberStyleToCell(ws, renderRowIdx + 6, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 7, renderColIdx, hourlyStats.TotalOverstaysFaulty + hourlyStats.TotalPayViosFaulty);
                ApplyNumberStyleToCell(ws, renderRowIdx + 7, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 8, renderColIdx, hourlyStats.TotalViosActioned0To15Mins);
                ApplyNumberStyleToCell(ws, renderRowIdx + 8, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 9, renderColIdx, hourlyStats.TotalViosActioned15To40Mins);
                ApplyNumberStyleToCell(ws, renderRowIdx + 9, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 10, renderColIdx, hourlyStats.TotalViosActionedOver40Mins);
                ApplyNumberStyleToCell(ws, renderRowIdx + 10, renderColIdx, "########0", ExcelHorizontalAlignment.Left);

                ws.SetValue(renderRowIdx + 11, renderColIdx, (hourlyStats.OverstayCount + hourlyStats.PayVioCount) - (hourlyStats.TotalOverstaysActioned + hourlyStats.TotalPayViosActioned));
                ApplyNumberStyleToCell(ws, renderRowIdx + 11, renderColIdx, "########0", ExcelHorizontalAlignment.Left);
            }
        }
Пример #19
0
 public FileList()
 {
     ListofFiles = new List <AnalysisObject>(); rowCounts = new List <int>(); colCounts = new List <int>(); groupStats = new GroupStats();
 }
        protected override void RenderCommonData(ExcelWorksheet ws, int startRowIdx, int startColIdx, ref int colIdx_HourlyCategory, GroupStats statsObj)
        {
            int colIdx_1stCommonColumn = startColIdx;
            int renderColIdx           = colIdx_1stCommonColumn;
            int renderRowIdx           = startRowIdx;

            ws.SetValue(renderRowIdx, renderColIdx, FormatTimeSpanAsHoursMinutesAndSeconds(statsObj.TotalOccupancyTime));

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, FormatTimeSpanAsHoursMinutesAndSeconds(statsObj.TotalOccupancyPaidTime));

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, FormatTimeSpanAsHoursMinutesAndSeconds(statsObj.MaximumPotentialOccupancyTime));

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.PercentageOccupiedPaid);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.PercentageOccupiedNotPaid);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.ingress);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.egress);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.PaymentCount);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalZeroedOutEvents);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, FormatTimeSpanAsHoursMinutesAndSeconds(statsObj.TotalZeroedOutDuration));

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalPayViosActioned);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.PayVioCount);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalPayViosEnforced);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalPayViosCautioned);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalPayViosNotEnforced);

            renderColIdx++;
            ws.SetValue(renderRowIdx, renderColIdx, statsObj.TotalPayViosFaulty);

            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 3, renderRowIdx, renderRowIdx, "###0.00", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 4, renderRowIdx, renderRowIdx, "###0.00", ExcelHorizontalAlignment.Right);

            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 5, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 6, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 7, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 8, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);

            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 10, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 11, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 12, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 13, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 14, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);
            ApplyNumberStyleToColumn(ws, colIdx_1stCommonColumn + 15, renderRowIdx, renderRowIdx, "########0", ExcelHorizontalAlignment.Right);

            // And now lets autosize the columns
            for (int autoSizeColIdx = colIdx_1stCommonColumn; autoSizeColIdx <= renderColIdx; autoSizeColIdx++)
            {
                using (OfficeOpenXml.ExcelRange col = ws.Cells[1, autoSizeColIdx, renderRowIdx, autoSizeColIdx])
                {
                    col.AutoFitColumns();
                    col.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
                }
            }

            // And now finally we must manually size the columns that have wrap text (autofit doesn't work nicely when we have wrap text)
            ws.Column(colIdx_1stCommonColumn + 0).Width = 15;
            ws.Column(colIdx_1stCommonColumn + 1).Width = 20;
            ws.Column(colIdx_1stCommonColumn + 2).Width = 20;
            ws.Column(colIdx_1stCommonColumn + 3).Width = 20;
            ws.Column(colIdx_1stCommonColumn + 4).Width = 24;

            ws.Column(colIdx_1stCommonColumn + 5).Width = 12;
            ws.Column(colIdx_1stCommonColumn + 6).Width = 12;

            ws.Column(colIdx_1stCommonColumn + 8).Width = 15;
            ws.Column(colIdx_1stCommonColumn + 9).Width = 15;

            ws.Column(colIdx_1stCommonColumn + 10).Width = 12;
            ws.Column(colIdx_1stCommonColumn + 11).Width = 12;
            ws.Column(colIdx_1stCommonColumn + 12).Width = 12;
            ws.Column(colIdx_1stCommonColumn + 13).Width = 12;
            ws.Column(colIdx_1stCommonColumn + 14).Width = 12;
            ws.Column(colIdx_1stCommonColumn + 15).Width = 12;

            ws.Column(colIdx_1stCommonColumn + 16).Width = 40;

            if (this._ReportParams.IncludeHourlyStatistics == true)
            {
                // Now we will construct the hourly category column, followed by hour detail columns

                ws.SetValue(renderRowIdx + 0, colIdx_HourlyCategory, "Occupied Duration");
                ws.SetValue(renderRowIdx + 1, colIdx_HourlyCategory, "Occupied & Paid Duration");
                ws.SetValue(renderRowIdx + 2, colIdx_HourlyCategory, "Max Possible Duration");
                ws.SetValue(renderRowIdx + 3, colIdx_HourlyCategory, "Occupied & Paid % (Compliance)");
                ws.SetValue(renderRowIdx + 4, colIdx_HourlyCategory, "Occupied & Not Paid % (Non-Compliance");
                ws.SetValue(renderRowIdx + 5, colIdx_HourlyCategory, "Arrivals");
                ws.SetValue(renderRowIdx + 6, colIdx_HourlyCategory, "Departures");
                ws.SetValue(renderRowIdx + 7, colIdx_HourlyCategory, "Payment Count");
                ws.SetValue(renderRowIdx + 8, colIdx_HourlyCategory, "Zeroed Out Events");
                ws.SetValue(renderRowIdx + 9, colIdx_HourlyCategory, "Total Zeroed Out Time");
                ws.SetValue(renderRowIdx + 10, colIdx_HourlyCategory, "Violations Actioned");
                ws.SetValue(renderRowIdx + 11, colIdx_HourlyCategory, "Total Violations");
                ws.SetValue(renderRowIdx + 12, colIdx_HourlyCategory, "Total Enforced");
                ws.SetValue(renderRowIdx + 13, colIdx_HourlyCategory, "Total Cautioned");
                ws.SetValue(renderRowIdx + 14, colIdx_HourlyCategory, "Total Not Enforced");
                ws.SetValue(renderRowIdx + 15, colIdx_HourlyCategory, "Total Faulty");

                using (OfficeOpenXml.ExcelRange col = ws.Cells[renderRowIdx, colIdx_HourlyCategory, renderRowIdx + (numberOfHourlyCategories - 1), colIdx_HourlyCategory])
                {
                    col.Style.Font.Bold = true;
                }

                MergeCellRange(ws, renderRowIdx + 1, 1, renderRowIdx + (numberOfHourlyCategories - 1), colIdx_HourlyCategory - 1);
            }
        }