Beispiel #1
0
        public void LabRemoved(byte[] labData)
        {
            if (!GetEnvironmentVariableAsBool(_telemetryOptInVar, false))
            {
                return;
            }
            var lab      = Lab.Import(labData);
            var f        = new System.IO.FileInfo(lab.LabFilePath);
            var duration = DateTime.Now - f.CreationTime;

            var metrics = new Dictionary <string, double>
            {
                { "labRunningTicks", duration.Ticks }
            };

            var eventMessage = "Lab removed - Transmitting the following:" +
                               $"\r\nlabRunningTicks = {duration.Ticks}";

            try
            {
                EventLog.WriteEntry("AutomatedLab", eventMessage, EventLogEntryType.Information, 103);
            }
            catch { }

            try
            {
                telemetryClient.TrackEvent("LabRemoved", null, metrics);
                telemetryClient.Flush();
            }
            catch
            {
                ; //nothing to catch. If it doesn't work, it doesn't work.
            }
        }
Beispiel #2
0
        public void LabRemoved(byte[] labData)
        {
            if (GetEnvironmentVariableAsBool(_telemetryOptoutEnvVar, false))
            {
                return;
            }
            var lab      = Lab.Import(labData);
            var f        = new System.IO.FileInfo(lab.LabFilePath);
            var duration = DateTime.Now - f.CreationTime;

            var metrics = new Dictionary <string, double>
            {
                { "labRunningTicks", duration.Ticks }
            };

            try
            {
                telemetryClient.TrackEvent("LabRemoved", null, metrics);
                telemetryClient.Flush();
            }
            catch
            {
                ; //nothing to catch. If it doesn't work, it doesn't work.
            }
        }
Beispiel #3
0
        public void LabFinished(byte[] labData)
        {
            if (GetEnvironmentVariableAsBool(_telemetryOptoutEnvVar, false))
            {
                return;
            }
            var lab = Lab.Import(labData);

            var labDuration = DateTime.Now - labStarted;

            var properties = new Dictionary <string, string>
            {
                { "dayOfWeek", labStarted.DayOfWeek.ToString() }
            };

            var metrics = new Dictionary <string, double>
            {
                { "timeTakenSeconds", labDuration.TotalSeconds }
            };

            try
            {
                telemetryClient.TrackEvent("LabFinished", properties, metrics);
                telemetryClient.Flush();
            }
            catch
            {
                ; //nothing to catch. If it doesn't work, it doesn't work.
            }
        }
Beispiel #4
0
        public void LabStarted(byte[] labData, string version, string osVersion, string psVersion)
        {
            if (!GetEnvironmentVariableAsBool(_telemetryOptInVar, false))
            {
                return;
            }
            var lab = Lab.Import(labData);

            lab.Machines.ForEach(m => SendUsedRole(m.Roles.Select(r => r.Name.ToString()).ToList()));
            lab.Machines.ForEach(m => SendUsedRole(m.PostInstallationActivity.Where(p => p.IsCustomRole).Select(c => System.IO.Path.GetFileNameWithoutExtension(c.ScriptFileName)).ToList(), true));

            var properties = new Dictionary <string, string>
            {
                { "version", version },
                { "hypervisor", lab.DefaultVirtualizationEngine },
                { "osversion", osVersion },
                { "psversion", psVersion }
            };

            var metrics = new Dictionary <string, double>
            {
                {
                    "machineCount", lab.Machines.Count
                }
            };

            labStarted = DateTime.Now;

            var eventMessage = "Lab started - Transmitting the following:" +
                               $"\r\nversion = {version}" +
                               $"\r\nhypervisor = {lab.DefaultVirtualizationEngine}" +
                               $"\r\nosversion = {osVersion}" +
                               $"\r\npsversion = {psVersion}" +
                               $"\r\nmachineCount = {lab.Machines.Count}";

            try
            {
                EventLog.WriteEntry("AutomatedLab", eventMessage, EventLogEntryType.Information, 101);
            }
            catch { }
            try
            {
                telemetryClient.TrackEvent("LabStarted", properties, metrics);
                telemetryClient.Flush();
            }
            catch
            {
                ; //nothing to catch. If it doesn't work, it doesn't work.
            }
        }
Beispiel #5
0
        public LabValidator(string labXmlPath)
        {
            XmlDocument mainDoc = new XmlDocument();

            mainDoc.Load(labXmlPath);
            docs.Add(mainDoc);

            var xmlPaths = mainDoc.SelectNodes("//@Path").OfType <XmlAttribute>().Select(e => e.Value).Where(text => text.EndsWith(".xml"));

            foreach (var path in xmlPaths)
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(path);
                docs.Add(doc);
            }

            lab = Lab.Import(labXmlPath);
            lab.MachineDefinitionFiles.ForEach(file => machines.AddFromFile(file.Path));
            lab.Machines = machines;
        }
Beispiel #6
0
        public void LabFinished(byte[] labData)
        {
            if (!GetEnvironmentVariableAsBool(_telemetryOptInVar, false))
            {
                return;
            }
            var lab = Lab.Import(labData);

            var labDuration = DateTime.Now - labStarted;

            var properties = new Dictionary <string, string>
            {
                { "dayOfWeek", labStarted.DayOfWeek.ToString() }
            };

            var metrics = new Dictionary <string, double>
            {
                { "timeTakenSeconds", labDuration.TotalSeconds }
            };

            var eventMessage = "Lab finished - Transmitting the following:" +
                               $"\r\ndayOfWeek = {labStarted.DayOfWeek.ToString()}" +
                               $"\r\ntimeTakenSeconds = {labDuration.TotalSeconds}";

            try
            {
                EventLog.WriteEntry("AutomatedLab", eventMessage, EventLogEntryType.Information, 102);
            }
            catch { }
            try
            {
                telemetryClient.TrackEvent("LabFinished", properties, metrics);
                telemetryClient.Flush();
            }
            catch
            {
                ; //nothing to catch. If it doesn't work, it doesn't work.
            }
        }
Beispiel #7
0
        public void LabStarted(byte[] labData, string version, string osVersion, string psVersion)
        {
            if (GetEnvironmentVariableAsBool(_telemetryOptoutEnvVar, false))
            {
                return;
            }
            var lab = Lab.Import(labData);

            lab.Machines.ForEach(m => SendUsedRole(m.Roles.Select(r => r.Name.ToString()).ToList()));
            lab.Machines.ForEach(m => SendUsedRole(m.PostInstallationActivity.Where(p => p.IsCustomRole).Select(c => System.IO.Path.GetFileNameWithoutExtension(c.ScriptFileName)).ToList(), true));

            var properties = new Dictionary <string, string>
            {
                { "version", version },
                { "hypervisor", lab.DefaultVirtualizationEngine },
                { "osversion", osVersion },
                { "psversion", psVersion }
            };

            var metrics = new Dictionary <string, double>
            {
                {
                    "machineCount", lab.Machines.Count
                }
            };

            labStarted = DateTime.Now;

            try
            {
                telemetryClient.TrackEvent("LabStarted", properties, metrics);
                telemetryClient.Flush();
            }
            catch
            {
                ; //nothing to catch. If it doesn't work, it doesn't work.
            }
        }