Ejemplo n.º 1
0
        public string SaveCrashReport(RaygunMessage crashReport, int maxReportsStored)
        {
            try
            {
                // Can only save the report if we havnt reached the report count limit.
                if (IsFileLimitReached(Math.Min(maxReportsStored, MAX_STORED_REPORTS_UPPER_LIMIT)))
                {
                    RaygunLogger.Warning("Failed to store crash report - Reached max crash reports stored on device");
                    return(null);
                }

                // Convert to JSON text.
                var reportJson = SimpleJson.SerializeObject(crashReport);

                // Generate a unique name for our report.
                var fileName = GetUniqueAcendingJsonName();

                // Save the report to disk.
                return(StoreCrashReport(fileName, reportJson));
            }
            catch (Exception ex)
            {
                RaygunLogger.Error(string.Format("Failed to store crash report - Error saving message to isolated storage {0}", ex.Message));
            }

            return(null);
        }
Ejemplo n.º 2
0
        private string GetVersion()
        {
            string version = ApplicationVersion;

            if (String.IsNullOrWhiteSpace(version))
            {
                try
                {
                    Context        context = RaygunClient.Context;
                    PackageManager manager = context.PackageManager;
                    PackageInfo    info    = manager.GetPackageInfo(context.PackageName, 0);
                    version = info.VersionCode + " / " + info.VersionName;
                }
                catch (Exception ex)
                {
                    RaygunLogger.Warning(string.Format("Error retrieving package version {0}", ex.Message));
                }
            }

            if (String.IsNullOrWhiteSpace(version))
            {
                version = "Not supplied";
            }

            return(version);
        }