//---------------------------------------------------------------------
        public void WriteLogEntry(ManagementArea mgmtArea, Stand stand)
        {
            int damagedSites            = 0;
            int cohortsDamaged          = 0;
            int standPrescriptionNumber = 0;

            foreach (ActiveSite site in stand)
            {
                //set the prescription name for this site
                if (SiteVars.Prescription[site] != null)
                {
                    standPrescriptionNumber         = SiteVars.Prescription[site].Number;
                    SiteVars.PrescriptionName[site] = SiteVars.Prescription[site].Name;
                    SiteVars.TimeOfLastEvent[site]  = PlugIn.ModelCore.CurrentTime;
                }
                int cohortsDamagedAtSite = SiteVars.CohortsDamaged[site];
                cohortsDamaged += cohortsDamagedAtSite;
                if (cohortsDamagedAtSite > 0)
                {
                    damagedSites++;
                }
            }


            totalSites[standPrescriptionNumber]        += stand.SiteCount;
            totalDamagedSites[standPrescriptionNumber] += damagedSites;

            //csv string for log file, contains species kill count
            //string species_count = "";
            double[] species_count = new double[modelCore.Species.Count];

            foreach (ISpecies species in PlugIn.ModelCore.Species)
            {
                int cohortCount = stand.DamageTable[species];
                species_count[species.Index] += cohortCount;
                totalSpeciesCohorts[standPrescriptionNumber, species.Index] += cohortCount;
            }
            //Trim trailing comma so we don't add an extra column
            //species_count = species_count.TrimEnd(',');


            //now that the damage table for this stand has been recorded, clear it!!
            stand.ClearDamageTable();

            //write to log file:
            //current time
            //management area's map code
            //the prescription that caused this harvest
            //stand's map code
            //stand's age
            //stand's current rank
            //total sites in the stand
            //damaged sites from this stand
            //cohorts killed in this stand, by this harvest
            //and only record stands where a site has been damaged
            //log.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}",
            //              PlugIn.ModelCore.CurrentTime, mgmtArea.MapCode, stand.PrescriptionName, stand.MapCode, stand.EventId,
            //              stand.Age, stand.HarvestedRank, stand.SiteCount, damagedSites, cohortsDamaged, species_count);

            eventLog.Clear();
            EventsLog el = new EventsLog();

            el.Time                  = modelCore.CurrentTime;
            el.ManagementArea        = mgmtArea.MapCode;
            el.Prescription          = stand.PrescriptionName;
            el.Stand                 = stand.MapCode;
            el.EventID               = stand.EventId;
            el.StandAge              = stand.Age;
            el.StandRank             = Convert.ToInt32(stand.HarvestedRank);
            el.NumberOfSites         = stand.SiteCount;
            el.HarvestedSites        = damagedSites;
            el.TotalCohortsHarvested = cohortsDamaged;
            el.CohortsHarvested_     = species_count;

            eventLog.AddObject(el);
            eventLog.WriteToFile();
        }
        //---------------------------------------------------------------------
        public void WriteLogEntry(ManagementArea mgmtArea, Stand stand)
        {
            int damagedSites = 0;
            int cohortsDamaged = 0;
            int standPrescriptionNumber = 0;

            foreach (ActiveSite site in stand) {
                //set the prescription name for this site
                if (SiteVars.Prescription[site] != null)
                {
                    standPrescriptionNumber = SiteVars.Prescription[site].Number;
                    SiteVars.PrescriptionName[site] = SiteVars.Prescription[site].Name;
                    SiteVars.TimeOfLastEvent[site] = PlugIn.ModelCore.CurrentTime;
                }
                int cohortsDamagedAtSite = SiteVars.CohortsDamaged[site];
                cohortsDamaged += cohortsDamagedAtSite;
                if (cohortsDamagedAtSite > 0) {
                    damagedSites++;
                }
            }

            totalSites[standPrescriptionNumber] += stand.SiteCount;
            totalDamagedSites[standPrescriptionNumber] += damagedSites;

            //csv string for log file, contains species kill count
            //string species_count = "";
            double[] species_count = new double[modelCore.Species.Count];

            foreach (ISpecies species in PlugIn.ModelCore.Species)
            {
                int cohortCount = stand.DamageTable[species];
                species_count[species.Index] += cohortCount;
                totalSpeciesCohorts[standPrescriptionNumber, species.Index] += cohortCount;
            }
            //Trim trailing comma so we don't add an extra column
            //species_count = species_count.TrimEnd(',');

            //now that the damage table for this stand has been recorded, clear it!!
            stand.ClearDamageTable();

            //write to log file:
                //current time
                //management area's map code
                //the prescription that caused this harvest
                //stand's map code
                //stand's age
                //stand's current rank
                //total sites in the stand
                //damaged sites from this stand
                //cohorts killed in this stand, by this harvest
            //and only record stands where a site has been damaged
            //log.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}",
            //              PlugIn.ModelCore.CurrentTime, mgmtArea.MapCode, stand.PrescriptionName, stand.MapCode, stand.EventId,
            //              stand.Age, stand.HarvestedRank, stand.SiteCount, damagedSites, cohortsDamaged, species_count);

            eventLog.Clear();
            EventsLog el = new EventsLog();
            el.Time = modelCore.CurrentTime;
            el.ManagementArea = mgmtArea.MapCode;
            el.Prescription = stand.PrescriptionName;
            el.Stand = stand.MapCode;
            el.EventID = stand.EventId;
            el.StandAge = stand.Age;
            el.StandRank = Convert.ToInt32(stand.HarvestedRank);
            el.NumberOfSites = stand.SiteCount;
            el.HarvestedSites = damagedSites;
            el.TotalCohortsHarvested = cohortsDamaged;
            el.CohortsHarvested_ = species_count;

            eventLog.AddObject(el);
            eventLog.WriteToFile();
        }