Skip to content

Commit

Permalink
Merge pull request #301 from MindscapeHQ/isolated-storage
Browse files Browse the repository at this point in the history
Isolated storage
  • Loading branch information
QuantumNightmare authored Jun 27, 2016
2 parents ca409f8 + 93e2715 commit 591fcb0
Show file tree
Hide file tree
Showing 23 changed files with 528 additions and 229 deletions.
4 changes: 2 additions & 2 deletions AssemblyVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.3.0.0")]
[assembly: AssemblyFileVersion("5.3.0.0")]
[assembly: AssemblyVersion("5.3.1.0")]
[assembly: AssemblyFileVersion("5.3.1.0")]
132 changes: 88 additions & 44 deletions Mindscape.Raygun4Net.ClientProfile/RaygunClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using System.Reflection;
using Mindscape.Raygun4Net.Builders;
using System.IO;
using System.IO.IsolatedStorage;
using System.Text;

namespace Mindscape.Raygun4Net
{
Expand Down Expand Up @@ -355,46 +357,69 @@ private void SaveMessage(string message)
{
try
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\RaygunOfflineStorage";
if (!Directory.Exists(path))
using (IsolatedStorageFile isolatedStorage = GetIsolatedStorageScope())
{
Directory.CreateDirectory(path);
}
int number = 1;
while (true)
{
bool exists = File.Exists(path + "\\RaygunErrorMessage" + number + ".txt");
if (!exists)
string directoryName = "RaygunOfflineStorage";
string[] directories = isolatedStorage.GetDirectoryNames("*");
if (!FileExists(directories, directoryName))
{
isolatedStorage.CreateDirectory(directoryName);
}

int number = 1;
string[] files = isolatedStorage.GetFileNames(directoryName + "\\*.txt");
while (true)
{
string nextFileName = path + "\\RaygunErrorMessage" + (number + 1) + ".txt";
exists = File.Exists(nextFileName);
if (exists)
bool exists = FileExists(files, "RaygunErrorMessage" + number + ".txt");
if (!exists)
{
File.Delete(nextFileName);
string nextFileName = "RaygunErrorMessage" + (number + 1) + ".txt";
exists = FileExists(files, nextFileName);
if (exists)
{
isolatedStorage.DeleteFile(directoryName + "\\" + nextFileName);
}
break;
}
break;
number++;
}
number++;
}
if (number == 11)
{
string firstFileName = path + "\\RaygunErrorMessage1.txt";
if (File.Exists(firstFileName))

if (number == 11)
{
string firstFileName = "RaygunErrorMessage1.txt";
if (FileExists(files, firstFileName))
{
isolatedStorage.DeleteFile(directoryName + "\\" + firstFileName);
}
}
using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(directoryName + "\\RaygunErrorMessage" + number + ".txt", FileMode.OpenOrCreate, FileAccess.Write, isolatedStorage))
{
File.Delete(firstFileName);
using (StreamWriter writer = new StreamWriter(isoStream, Encoding.Unicode))
{
writer.Write(message);
writer.Flush();
writer.Close();
}
}
System.Diagnostics.Trace.WriteLine("Saved message: " + "RaygunErrorMessage" + number + ".txt");
}
File.WriteAllText(path + "\\RaygunErrorMessage" + number + ".txt", message);
System.Diagnostics.Debug.WriteLine("Saved message: " + "RaygunErrorMessage" + number + ".txt");
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(string.Format("Error saving message to offline storage {0}", ex.Message));
if (RaygunSettings.Settings.ThrowOnError)
System.Diagnostics.Trace.WriteLine(string.Format("Error saving message to isolated storage {0}", ex.Message));
}
}

private bool FileExists(string[] files, string fileName)
{
foreach (string str in files)
{
if (fileName.Equals(str))
{
throw;
return true;
}
}
return false;
}

private static object _sendLock = new object();
Expand All @@ -405,38 +430,57 @@ private void SendStoredMessages()
{
try
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\RaygunOfflineStorage";
if (Directory.Exists(path))
using (IsolatedStorageFile isolatedStorage = GetIsolatedStorageScope())
{
string[] files = Directory.GetFiles(path);
foreach (string name in files)
string directoryName = "RaygunOfflineStorage";
string[] directories = isolatedStorage.GetDirectoryNames("*");
if (FileExists(directories, directoryName))
{
string text = File.ReadAllText(name);

try
string[] fileNames = isolatedStorage.GetFileNames(directoryName + "\\*.txt");
foreach (string name in fileNames)
{
Send(text);
IsolatedStorageFileStream isoFileStream = new IsolatedStorageFileStream(directoryName + "\\" + name, FileMode.Open, isolatedStorage);
using (StreamReader reader = new StreamReader(isoFileStream))
{
string text = reader.ReadToEnd();
try
{
Send(text);
}
catch
{
// If just one message fails to send, then don't delete the message, and don't attempt sending anymore until later.
return;
}
System.Diagnostics.Debug.WriteLine("Sent " + name);
}
isolatedStorage.DeleteFile(directoryName + "\\" + name);
}
catch
if (isolatedStorage.GetFileNames(directoryName + "\\*.txt").Length == 0)
{
// If just one message fails to send, then don't delete the message, and don't attempt sending anymore until later.
return;
System.Diagnostics.Debug.WriteLine("Successfully sent all pending messages");
isolatedStorage.DeleteDirectory(directoryName);
}
System.Diagnostics.Debug.WriteLine("Sent " + name);

File.Delete(name);
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(string.Format("Error sending stored messages to Raygun.io {0}", ex.Message));
if (RaygunSettings.Settings.ThrowOnError)
{
throw;
}
}
}
}

private IsolatedStorageFile GetIsolatedStorageScope()
{
if (AppDomain.CurrentDomain != null && AppDomain.CurrentDomain.ActivationContext != null)
{
return IsolatedStorageFile.GetUserStoreForApplication();
}
else
{
return IsolatedStorageFile.GetUserStoreForAssembly();
}
}
}
}
19 changes: 19 additions & 0 deletions Mindscape.Raygun4Net.Core.Signed.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Mindscape.Raygun4Net.Core.Signed</id>
<version>5.3.1</version>
<title />
<authors>Raygun</authors>
<owners />
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Core library for signed MVC and WebApi Raygun providers</description>
<iconUrl>https://app.raygun.com/Content/Images/nuget-icon.png</iconUrl>
<projectUrl>https://github.com/MindscapeHQ/raygun4net</projectUrl>
<licenseUrl>https://raw.github.com/MindscapeHQ/raygun4net/master/LICENSE</licenseUrl>
</metadata>
<files>
<file src="build\signed\Net4\Mindscape.Raygun4Net.dll" target="lib\net40\Mindscape.Raygun4Net.dll" />
<file src="build\signed\Net4\Mindscape.Raygun4Net.pdb" target="lib\net40\Mindscape.Raygun4Net.pdb" />
</files>
</package>
4 changes: 2 additions & 2 deletions Mindscape.Raygun4Net.Core.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Mindscape.Raygun4Net.Core</id>
<version>5.3.0</version>
<version>5.3.1</version>
<title />
<authors>Raygun</authors>
<owners />
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Core library for MVC and WebApi Raygun providers</description>
<iconUrl>https://app.raygun.io/Content/Images/nuget-icon.png</iconUrl>
<iconUrl>https://app.raygun.com/Content/Images/nuget-icon.png</iconUrl>
<projectUrl>https://github.com/MindscapeHQ/raygun4net</projectUrl>
<licenseUrl>https://raw.github.com/MindscapeHQ/raygun4net/master/LICENSE</licenseUrl>
</metadata>
Expand Down
29 changes: 29 additions & 0 deletions Mindscape.Raygun4Net.Mvc.Signed.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Mindscape.Raygun4Net.Mvc.Signed</id>
<version>5.3.1</version>
<title />
<authors>Raygun</authors>
<owners />
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Raygun provider for signed ASP.NET MVC projects</description>
<iconUrl>https://app.raygun.com/Content/Images/nuget-icon.png</iconUrl>
<projectUrl>https://github.com/MindscapeHQ/raygun4net</projectUrl>
<licenseUrl>https://raw.github.com/MindscapeHQ/raygun4net/master/LICENSE</licenseUrl>
<dependencies>
<dependency id="Mindscape.Raygun4Net.Core.Signed" version="5.3.1" />
</dependencies>
</metadata>
<files>
<!-- .NET 3.5 -->
<file src="build\signed\Mindscape.Raygun4Net.dll" target="lib\net35\Mindscape.Raygun4Net.dll" />
<!-- .NET 4.0+ -->
<file src="build\signed\Mvc\Mindscape.Raygun4Net.Mvc.dll" target="lib\net40\Mindscape.Raygun4Net.Mvc.dll" />
<file src="build\signed\Mvc\Mindscape.Raygun4Net.Mvc.pdb" target="lib\net40\Mindscape.Raygun4Net.Mvc.pdb" />
<file src="build\signed\Mvc\Mindscape.Raygun4Net4.dll" target="lib\net40\Mindscape.Raygun4Net4.dll" />
<file src="build\signed\Mvc\Mindscape.Raygun4Net4.pdb" target="lib\net40\Mindscape.Raygun4Net4.pdb" />

<file src="Mindscape.Raygun4Net.Mvc\readme.txt" />
</files>
</package>
8 changes: 4 additions & 4 deletions Mindscape.Raygun4Net.Mvc.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Mindscape.Raygun4Net.Mvc</id>
<version>5.3.0</version>
<version>5.3.1</version>
<title />
<authors>Raygun</authors>
<owners />
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Raygun.io Provider for ASP.NET MVC projects</description>
<iconUrl>https://app.raygun.io/Content/Images/nuget-icon.png</iconUrl>
<description>Raygun provider for ASP.NET MVC projects</description>
<iconUrl>https://app.raygun.com/Content/Images/nuget-icon.png</iconUrl>
<projectUrl>https://github.com/MindscapeHQ/raygun4net</projectUrl>
<licenseUrl>https://raw.github.com/MindscapeHQ/raygun4net/master/LICENSE</licenseUrl>
<dependencies>
<dependency id="Mindscape.Raygun4Net.Core" version="5.3.0" />
<dependency id="Mindscape.Raygun4Net.Core" version="5.3.1" />
</dependencies>
</metadata>
<files>
Expand Down
8 changes: 5 additions & 3 deletions Mindscape.Raygun4Net.Mvc.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mindscape.Raygun4Net.Mvc", "Mindscape.Raygun4Net.Mvc\Mindscape.Raygun4Net.Mvc.csproj", "{2CF1FE1F-AD2D-40BD-9F99-57FF00445A9D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mindscape.Raygun4Net.Mvc.Tests", "Mindscape.Raygun4Net.Mvc.Tests\Mindscape.Raygun4Net.Mvc.Tests.csproj", "{69BFF5D8-7B18-4685-B828-8DF2AADEA20D}"
Expand All @@ -20,8 +22,8 @@ Global
{2CF1FE1F-AD2D-40BD-9F99-57FF00445A9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CF1FE1F-AD2D-40BD-9F99-57FF00445A9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CF1FE1F-AD2D-40BD-9F99-57FF00445A9D}.Release|Any CPU.Build.0 = Release|Any CPU
{2CF1FE1F-AD2D-40BD-9F99-57FF00445A9D}.Sign|Any CPU.ActiveCfg = Release|Any CPU
{2CF1FE1F-AD2D-40BD-9F99-57FF00445A9D}.Sign|Any CPU.Build.0 = Release|Any CPU
{2CF1FE1F-AD2D-40BD-9F99-57FF00445A9D}.Sign|Any CPU.ActiveCfg = Sign|Any CPU
{2CF1FE1F-AD2D-40BD-9F99-57FF00445A9D}.Sign|Any CPU.Build.0 = Sign|Any CPU
{69BFF5D8-7B18-4685-B828-8DF2AADEA20D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69BFF5D8-7B18-4685-B828-8DF2AADEA20D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69BFF5D8-7B18-4685-B828-8DF2AADEA20D}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
16 changes: 16 additions & 0 deletions Mindscape.Raygun4Net.Mvc/Mindscape.Raygun4Net.Mvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Sign|AnyCPU' ">
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Sign|AnyCPU' ">
<AssemblyOriginatorKeyFile>Raygun4Net.Mvc.snk</AssemblyOriginatorKeyFile>
<OutputPath>bin\Sign\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Sign|AnyCPU'">
<OutputPath>bin\Sign\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
Expand Down
8 changes: 4 additions & 4 deletions Mindscape.Raygun4Net.Mvc/readme.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Raygun4Net.Mvc - Raygun.io Provider for ASP .NET MVC projects
Raygun4Net.Mvc - Raygun Provider for ASP .NET MVC projects
=============================================================

Where is my app API key?
========================
When you create a new application on your Raygun.io dashboard, your app API key is displayed at the top of the instructions page.
You can also find the API key by clicking the "Application Settings" button in the side bar of the Raygun.io dashboard.
When you create a new application in your Raygun dashboard, your app API key is displayed at the top of the instructions page.
You can also find the API key by clicking the "Application Settings" button in the side bar of the Raygun dashboard.

Namespace
=========
Expand Down Expand Up @@ -72,7 +72,7 @@ For example if you wanted to exclude errors that return the "I'm a teapot" respo
Exclude errors that originate from a local origin
-------------------------------------------------

Toggle this boolean and the HTTP module will not send errors to Raygun.io if the request originated from a local origin.
Toggle this boolean and the HTTP module will not send errors to Raygun if the request originated from a local origin.
i.e. A way to prevent local debug/development from notifying Raygun without having to resort to Web.config transforms.

<RaygunSettings apikey="YOUR_APP_API_KEY" excludeErrorsFromLocal="true" />
Expand Down
8 changes: 5 additions & 3 deletions Mindscape.Raygun4Net.Signed.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Mindscape.Raygun4Net.Signed</id>
<version>5.3.0</version>
<version>5.3.1</version>
<title />
<authors>Raygun</authors>
<owners />
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Raygun.io provider for signed projects built with .NET Framework + Windows Store apps, Windows Phone, Xamarin, Windows 8 and WinRT.</description>
<iconUrl>https://app.raygun.io/Content/Images/nuget-icon.png</iconUrl>
<description>Raygun provider for signed projects built with .NET Framework + Windows Store apps, Windows Phone, Xamarin, Windows 8 and WinRT.</description>
<iconUrl>https://app.raygun.com/Content/Images/nuget-icon.png</iconUrl>
<projectUrl>https://github.com/MindscapeHQ/raygun4net</projectUrl>
<licenseUrl>https://raw.github.com/MindscapeHQ/raygun4net/master/LICENSE</licenseUrl>
</metadata>
Expand All @@ -31,6 +31,8 @@
<file src="build\Mindscape.Raygun4Net.Xamarin.iOS.dll" target="lib\MonoTouch4.0\Mindscape.Raygun4Net.Xamarin.iOS.dll" />
<file src="build\Mindscape.Raygun4Net.Xamarin.iOS.dll" target="lib\MonoTouch\Mindscape.Raygun4Net.Xamarin.iOS.dll" />
<file src="build\Mindscape.Raygun4Net.Xamarin.iOS.Unified.dll" target="lib\Xamarin.iOS10\Mindscape.Raygun4Net.Xamarin.iOS.Unified.dll" />
<!-- Xamarin.Mac -->
<file src="build\Mindscape.Raygun4Net.Xamarin.Mac.Unified.dll" target="lib\Xamarin.Mac20\Mindscape.Raygun4Net.Xamarin.Mac.Unified.dll" />
<!-- Windows Store universal apps (Windows 8.1 and Windows Phone 8.1) -->
<file src="build\signed\Mindscape.Raygun4Net.WindowsStore.dll" target="lib\portable-net45+win81+wpa81+windows81\Mindscape.Raygun4Net.WindowsStore.dll" />
<!-- WinRT and Windows 8 -->
Expand Down
24 changes: 24 additions & 0 deletions Mindscape.Raygun4Net.WebApi.Signed.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Mindscape.Raygun4Net.WebApi.Signed</id>
<version>5.3.1</version>
<title />
<authors>Raygun</authors>
<owners />
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Raygun provider for signed ASP.NET WebApi projects</description>
<iconUrl>https://app.raygun.com/Content/Images/nuget-icon.png</iconUrl>
<projectUrl>https://github.com/MindscapeHQ/raygun4net</projectUrl>
<licenseUrl>https://raw.github.com/MindscapeHQ/raygun4net/master/LICENSE</licenseUrl>
<dependencies>
<dependency id="Mindscape.Raygun4Net.Core.Signed" version="5.3.1" />
</dependencies>
</metadata>
<files>
<file src="build\signed\WebApi\Mindscape.Raygun4Net.WebApi.dll" target="lib\net45\Mindscape.Raygun4Net.WebApi.dll" />
<file src="build\signed\WebApi\Mindscape.Raygun4Net.WebApi.pdb" target="lib\net45\Mindscape.Raygun4Net.WebApi.pdb" />

<file src="Mindscape.Raygun4Net.WebApi\readme.txt" />
</files>
</package>
Loading

0 comments on commit 591fcb0

Please sign in to comment.