delete old Reporting code.

pull/4/head
Keivan Beigi 11 years ago
parent 41c5619d1b
commit ba634b75d6

@ -1,21 +0,0 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace NzbDrone.Common.Contract
{
public class ParseErrorReport : ReportBase
{
[JsonProperty("t")]
public string Title { get; set; }
protected override Dictionary<string, string> GetString()
{
var dic = new Dictionary<string, string>
{
{"Title", Title.NullSafe()},
};
return dic;
}
}
}

@ -1,31 +0,0 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace NzbDrone.Common.Contract
{
public abstract class ReportBase
{
[JsonProperty("v")]
public string Version { get; set; }
[JsonProperty("p")]
public bool IsProduction { get; set; }
[JsonProperty("u")]
public Guid UGuid { get; set; }
public override string ToString()
{
var childString = "";
foreach (var keyValue in GetString())
{
childString += string.Format("{0}: {1} ", keyValue.Key, keyValue.Value);
}
return string.Format("[{0} Prd:{1} V:{2} ID:{3} | {4}]", GetType().Name, IsProduction, Version, UGuid, childString.Trim());
}
protected abstract Dictionary<string,string> GetString();
}
}

@ -118,8 +118,6 @@
<Compile Include="ServiceFactory.cs" /> <Compile Include="ServiceFactory.cs" />
<Compile Include="HttpProvider.cs" /> <Compile Include="HttpProvider.cs" />
<Compile Include="ConsoleService.cs" /> <Compile Include="ConsoleService.cs" />
<Compile Include="Contract\ReportBase.cs" />
<Compile Include="Contract\ParseErrorReport.cs" />
<Compile Include="PathExtensions.cs" /> <Compile Include="PathExtensions.cs" />
<Compile Include="DiskProvider.cs" /> <Compile Include="DiskProvider.cs" />
<Compile Include="EnvironmentInfo\AppFolderInfo.cs" /> <Compile Include="EnvironmentInfo\AppFolderInfo.cs" />
@ -127,7 +125,6 @@
<Compile Include="ProcessProvider.cs" /> <Compile Include="ProcessProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\SharedAssemblyInfo.cs" /> <Compile Include="Properties\SharedAssemblyInfo.cs" />
<Compile Include="RestProvider.cs" />
<Compile Include="ServiceProvider.cs" /> <Compile Include="ServiceProvider.cs" />
<Compile Include="TinyIoC.cs" /> <Compile Include="TinyIoC.cs" />
<Compile Include="TPL\TaskExtensions.cs" /> <Compile Include="TPL\TaskExtensions.cs" />

@ -1,60 +0,0 @@
using System;
using System.IO;
using System.Net;
using System.Text;
using NzbDrone.Common.Contract;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Serializer;
namespace NzbDrone.Common
{
public class RestProvider
{
private const int TIMEOUT = 15000;
private const string METHOD = "POST";
public virtual void PostData(string url, ReportBase reportBase)
{
reportBase.Version = BuildInfo.Version.ToString();
reportBase.IsProduction = RuntimeInfo.IsProduction;
PostData(url, reportBase as object);
}
private static void PostData(string url, object message)
{
try
{
var json = message.ToJson();
var request = (HttpWebRequest)WebRequest.Create(url);
request.Timeout = TIMEOUT;
request.Proxy = WebRequest.DefaultWebProxy;
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version10;
request.Method = METHOD;
request.ContentType = "application/json";
byte[] postBytes = Encoding.UTF8.GetBytes(json);
request.ContentLength = postBytes.Length;
var requestStream = request.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();
var response = (HttpWebResponse)request.GetResponse();
var streamreader = new StreamReader(response.GetResponseStream());
streamreader.Close();
}
catch (Exception e)
{
e.Data.Add("URL", url);
throw;
}
}
}
}

@ -3,7 +3,6 @@ using System.Linq;
using FluentAssertions; using FluentAssertions;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common.Contract;
using NzbDrone.Common.Expansive; using NzbDrone.Common.Expansive;
using NzbDrone.Core.Parser; using NzbDrone.Core.Parser;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
@ -116,17 +115,6 @@ namespace NzbDrone.Core.Test.ParserTests
ExceptionVerification.IgnoreWarns(); ExceptionVerification.IgnoreWarns();
} }
[Test]
[Ignore]
public void unparsable_path_should_report_the_path()
{
Parser.Parser.ParsePath("C:\\SOMETHING 12345.avi").Should().BeNull();
MockedRestProvider.Verify(c => c.PostData(It.IsAny<string>(), It.IsAny<ParseErrorReport>()), Times.Exactly(2));
ExceptionVerification.IgnoreWarns();
}
[TestCase("[DmonHiro] The Severing Crime Edge - Cut 02 - Portrait Of Heresy [BD, 720p] [BE36E9E0]")] [TestCase("[DmonHiro] The Severing Crime Edge - Cut 02 - Portrait Of Heresy [BD, 720p] [BE36E9E0]")]
public void unparsable_title_should_log_warn_and_return_null(string title) public void unparsable_title_should_log_warn_and_return_null(string title)
{ {

@ -9,7 +9,6 @@ using NzbDrone.Common;
using NzbDrone.Common.Cache; using NzbDrone.Common.Cache;
using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
using NzbDrone.Core.Messaging;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
using NzbDrone.Test.Common.AutoMoq; using NzbDrone.Test.Common.AutoMoq;
@ -62,7 +61,6 @@ namespace NzbDrone.Test.Common
} }
} }
protected Mock<RestProvider> MockedRestProvider { get; private set; }
protected int RandomNumber protected int RandomNumber
{ {
@ -102,8 +100,6 @@ namespace NzbDrone.Test.Common
TempFolder = Path.Combine(Directory.GetCurrentDirectory(), "_temp_" + DateTime.Now.Ticks); TempFolder = Path.Combine(Directory.GetCurrentDirectory(), "_temp_" + DateTime.Now.Ticks);
MockedRestProvider = new Mock<RestProvider>();
Directory.CreateDirectory(TempFolder); Directory.CreateDirectory(TempFolder);
} }

Loading…
Cancel
Save