private static void SetupErrorReportInformation()
{
string version = Version;
if (version != null)
{
// Extract the fourth (and final) field of the version to get a date value.
int ich = version.IndexOf('.');
if (ich >= 0)
ich = version.IndexOf('.', ich + 1);
if (ich >= 0)
ich = version.IndexOf('.', ich + 1);
if (ich >= 0)
{
int iDate = Convert.ToInt32(version.Substring(ich + 1));
if (iDate > 0)
{
double oadate = Convert.ToDouble(iDate);
DateTime dt = DateTime.FromOADate(oadate);
version += string.Format(" {0}", dt.ToString("yyyy/MM/dd"));
}
}
#if DEBUG
version += " (Debug version)";
#endif
ErrorReporter.AddProperty("Version", version);
}
ErrorReporter.AddProperty("CommandLine", Environment.CommandLine);
ErrorReporter.AddProperty("CurrentDirectory", Environment.CurrentDirectory);
ErrorReporter.AddProperty("MachineName", Environment.MachineName);
ErrorReporter.AddProperty("OSVersion", Environment.OSVersion.ToString());
ErrorReporter.AddProperty("OSRelease", Palaso.Reporting.ErrorReport.GetOperatingSystemLabel());
if (MiscUtils.IsUnix)
{
var packageVersions = LinuxPackageUtils.FindInstalledPackages("fieldworks-applications*");
if (packageVersions.Count() > 0)
{
var packageVersion = packageVersions.First();
ErrorReporter.AddProperty("PackageVersion", string.Format("{0} {1}", packageVersion.Key, packageVersion.Value));
}
}
ErrorReporter.AddProperty("CLR version", Environment.Version.ToString());
ulong mem = MiscUtils.GetPhysicalMemoryBytes() / 1048576;
ErrorReporter.AddProperty("PhysicalMemory", mem + " Mb");
ulong diskSize;
ulong diskFree;
int cDisks = MiscUtils.GetDiskDriveStats(out diskSize, out diskFree);
diskFree /= 1073742; // 1024*1024*1024/1000 matches drive properties in Windows
diskSize /= 1073742;
ErrorReporter.AddProperty("LocalDiskCount", cDisks.ToString());
ErrorReporter.AddProperty("FwProgramDiskSize", diskSize + " Mb");
ErrorReporter.AddProperty("FwProgramDiskFree", diskFree + " Mb");
// TODO-Linux: WorkingSet always returns 0 on Mono.
ErrorReporter.AddProperty("WorkingSet", Environment.WorkingSet.ToString());
ErrorReporter.AddProperty("UserDomainName", Environment.UserDomainName);
ErrorReporter.AddProperty("UserName", Environment.UserName);
ErrorReporter.AddProperty("SystemDirectory", Environment.SystemDirectory);
ErrorReporter.AddProperty("Culture", System.Globalization.CultureInfo.CurrentCulture.ToString());
using (Bitmap bm = new Bitmap(10, 10))
{
ErrorReporter.AddProperty("ScreenDpiX", bm.HorizontalResolution.ToString());
ErrorReporter.AddProperty("ScreenDpiY", bm.VerticalResolution.ToString());
}
}