public void CreateReport(string fileName, TestLogFull log)
        {
            try
            {
                var data = new Datasheet();
                data.Features = log.Features;

                if (log.DeviceInfo != null)
                {
                    data.Capabilities = log.DeviceInformation.Capabilities;

                    data.DeviceInformation = new Tests.Engine.DeviceInformation();
                    data.DeviceInformation.FirmwareVersion = log.DeviceInformation.FirmwareVersion;
                    data.DeviceInformation.HardwareID      = log.DeviceInformation.HardwareID;
                    data.DeviceInformation.Manufacturer    = log.DeviceInformation.Manufacturer;
                    data.DeviceInformation.Model           = log.DeviceInformation.Model;
                    data.DeviceInformation.SerialNumber    = log.DeviceInformation.SerialNumber;
                }
                data.TestInformation          = new TestInformation();
                data.TestInformation.TestDate = log.TestExecutionTime;
                if (log.DeviceInfo != null)
                {
                    data.TestInformation.ProductName = log.DeviceInfo.ProductName;
                }
                if (log.Application != null)
                {
                    data.TestInformation.ToolVersion = log.Application.ToolVersion;
                }

                using (var fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                {
                    var serializer = new XmlSerializer(typeof(Datasheet));
                    serializer.Serialize(fileStream, data);
                }
                RaiseOnReportSaved();
            }
            catch (Exception ex)
            {
                RaiseOnException(ex);
            }
        }
Beispiel #2
0
        public void CreateReport(string fileName, TestLogFull log)
        {
            try
            {
                var data = new Datasheet();
                data.Features = log.Features;

                if (log.DeviceInformation != null)
                {
                    data.Capabilities = log.DeviceInformation.Capabilities;

                    data.DeviceInformation = new DeviceInformation();
                    data.DeviceInformation.FirmwareVersion = log.DeviceInformation.FirmwareVersion;
                    data.DeviceInformation.HardwareID      = log.DeviceInformation.HardwareID;
                    data.DeviceInformation.Manufacturer    = log.DeviceInformation.Manufacturer;
                    data.DeviceInformation.Model           = log.DeviceInformation.Model;
                    data.DeviceInformation.SerialNumber    = log.DeviceInformation.SerialNumber;
                }
                data.TestInformation             = new TestInformation();
                data.TestInformation.TestDate    = log.TestExecutionTime;
                data.TestInformation.ProductName = log.ProductName;

                // this code block is commented until full list of product type will be available

                /*
                 * if (!string.IsNullOrEmpty(log.ProductTypes))
                 * {
                 *  string[] delimiters = { ", " };
                 *  string[] types = log.ProductTypes.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                 *
                 *  if (types != null && types.Length != 0)
                 *  {
                 *      data.TestInformation.ProductType = new List<TestInformation.Type>();
                 *      foreach (var type in types)
                 *      {
                 *          switch (type)
                 *          {
                 *              case "Camera":
                 *                  data.TestInformation.ProductType.Add(TestInformation.Type.Camera);
                 *                  break;
                 *              case "Encoder":
                 *                  data.TestInformation.ProductType.Add(TestInformation.Type.Encoder);
                 *                  break;
                 *              case "Recorder":
                 *                  data.TestInformation.ProductType.Add(TestInformation.Type.Recorder);
                 *                  break;
                 *              case "VMS":
                 *                  data.TestInformation.ProductType.Add(TestInformation.Type.VMS);
                 *                  break;
                 *              case "Display":
                 *                  data.TestInformation.ProductType.Add(TestInformation.Type.Display);
                 *                  break;
                 *              case "Dome":
                 *                  data.TestInformation.ProductType.Add(TestInformation.Type.Dome);
                 *                  break;
                 *          }
                 *      }
                 *  }
                 * }
                 */

                if (!string.IsNullOrEmpty(log.ProductTypes))
                {
                    string[] delimiters = { ", " };
                    string[] types      = log.ProductTypes.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                    if (types != null && types.Length != 0)
                    {
                        data.TestInformation.ProductType = new List <string>(types);
                    }
                }

                // conformance information
                var countOfFailedTests  = log.TestResults.Count(item => item.Value.Log.TestStatus == TestTool.Tests.Definitions.Trace.TestStatus.Failed);
                var isConformanceFailed = (countOfFailedTests > 0) ||
                                          !log.InitializationData.SupportedProfiles.Any(e => ProfileVersionStatus.Release == e.GetProfileVersionStatus()) ||
                                          log.InitializationData.FailedProfiles.Any(e => ProfileVersionStatus.Release == e.GetProfileVersionStatus());
                isConformanceFailed = isConformanceFailed || log.InitializationData.UndefinedFeatures.Any();

                if (!isConformanceFailed && (log.InitializationData.SupportedProfiles != null || log.InitializationData.SupportedProfiles.Count != 0))
                {
                    data.ConformanceInformation = new ConformanceInformation();
                    data.ConformanceInformation.SupportedProfile = new List <ConformanceInformation.Profile>();
                    foreach (var profile in log.InitializationData.SupportedProfiles)
                    {
                        if (profile.GetProfileVersionStatus() == ProfileVersionStatus.Release)
                        {
                            switch (profile.GetProfileName())
                            {
                            case "Profile S":
                                data.ConformanceInformation.SupportedProfile.Add(ConformanceInformation.Profile.S);
                                break;

                            case "Profile G":
                                data.ConformanceInformation.SupportedProfile.Add(ConformanceInformation.Profile.G);
                                break;

                            case "Profile C":
                                data.ConformanceInformation.SupportedProfile.Add(ConformanceInformation.Profile.C);
                                break;
                            }
                        }
                    }
                }

                if (log.SupportInfo != null)
                {
                    data.SupportInformation = new SupportInfo();

                    data.SupportInformation.InternationalAddress =
                        string.IsNullOrEmpty(log.SupportInfo.InternationalAddress) ? null : log.SupportInfo.InternationalAddress;

                    data.SupportInformation.RegionalAddress =
                        string.IsNullOrEmpty(log.SupportInfo.RegionalAddress) ? null : log.SupportInfo.RegionalAddress;

                    data.SupportInformation.SupportUrl =
                        string.IsNullOrEmpty(log.SupportInfo.SupportUrl) ? null : log.SupportInfo.SupportUrl;

                    data.SupportInformation.SupportEmail =
                        string.IsNullOrEmpty(log.SupportInfo.SupportEmail) ? null : log.SupportInfo.SupportEmail;

                    data.SupportInformation.SupportPhone =
                        string.IsNullOrEmpty(log.SupportInfo.SupportPhone) ? null : log.SupportInfo.SupportPhone;
                }

                data.RequestsTimeouts = log.Timeouts;

                if (log.Application != null)
                {
                    data.TestInformation.ToolVersion = log.Application.ToolVersion;
                }

                data.ManagementSettings = log.ManagementSettings;

                using (var fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                {
                    var serializer = new XmlSerializer(typeof(Datasheet));
                    serializer.Serialize(fileStream, data);
                }
                RaiseOnReportSaved();
            }
            catch (Exception ex)
            {
                RaiseOnException(ex);
            }
        }