mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: Reformat code.
This commit is contained in:
@@ -72,10 +72,13 @@ namespace DiscImageChef.Server
|
||||
|
||||
try
|
||||
{
|
||||
if(!File.Exists(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Statistics", "Statistics.xml")))
|
||||
if(!File.Exists(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Statistics",
|
||||
"Statistics.xml")))
|
||||
{
|
||||
#if DEBUG
|
||||
content.InnerHtml = string.Format("<b>Sorry, cannot load data file \"{0}\"</b>", Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Statistics", "Statistics.xml"));
|
||||
content.InnerHtml = string.Format("<b>Sorry, cannot load data file \"{0}\"</b>",
|
||||
Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"),
|
||||
"Statistics", "Statistics.xml"));
|
||||
#else
|
||||
content.InnerHtml = "<b>Sorry, cannot load data file</b>";
|
||||
#endif
|
||||
@@ -85,7 +88,9 @@ namespace DiscImageChef.Server
|
||||
statistics = new Stats();
|
||||
|
||||
XmlSerializer xs = new XmlSerializer(statistics.GetType());
|
||||
FileStream fs = WaitForFile(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Statistics", "Statistics.xml"), FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
FileStream fs =
|
||||
WaitForFile(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Statistics", "Statistics.xml"),
|
||||
FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
statistics = (Stats)xs.Deserialize(fs);
|
||||
fs.Close();
|
||||
|
||||
@@ -93,13 +98,20 @@ namespace DiscImageChef.Server
|
||||
{
|
||||
operatingSystems = new List<NameValueStats>();
|
||||
foreach(OsStats nvs in statistics.OperatingSystems)
|
||||
operatingSystems.Add(new NameValueStats { name = string.Format("{0}{1}{2}", Interop.DetectOS.GetPlatformName((Interop.PlatformID)Enum.Parse(typeof(Interop.PlatformID), nvs.name), nvs.version),
|
||||
string.IsNullOrEmpty(nvs.version) ? "" : " ", nvs.version), Value = nvs.Value });
|
||||
operatingSystems.Add(new NameValueStats
|
||||
{
|
||||
name = string.Format("{0}{1}{2}",
|
||||
Interop.DetectOS
|
||||
.GetPlatformName((Interop.PlatformID)Enum.Parse(typeof(Interop.PlatformID), nvs.name),
|
||||
nvs.version),
|
||||
string.IsNullOrEmpty(nvs.version) ? "" : " ", nvs.version),
|
||||
Value = nvs.Value
|
||||
});
|
||||
|
||||
repOperatingSystems.DataSource = operatingSystems.OrderBy(os => os.name).ToList();
|
||||
repOperatingSystems.DataBind();
|
||||
}
|
||||
else
|
||||
divOperatingSystems.Visible = false;
|
||||
else divOperatingSystems.Visible = false;
|
||||
|
||||
if(statistics.Versions != null)
|
||||
{
|
||||
@@ -107,15 +119,14 @@ namespace DiscImageChef.Server
|
||||
foreach(NameValueStats nvs in statistics.Versions)
|
||||
{
|
||||
if(nvs.name == "previous")
|
||||
versions.Add(new NameValueStats { name = "Previous than 3.4.99.0", Value = nvs.Value });
|
||||
else
|
||||
versions.Add(nvs);
|
||||
versions.Add(new NameValueStats {name = "Previous than 3.4.99.0", Value = nvs.Value});
|
||||
else versions.Add(nvs);
|
||||
}
|
||||
|
||||
repVersions.DataSource = versions.OrderBy(ver => ver.name).ToList();
|
||||
repVersions.DataBind();
|
||||
}
|
||||
else
|
||||
divVersions.Visible = false;
|
||||
else divVersions.Visible = false;
|
||||
|
||||
if(statistics.Commands != null)
|
||||
{
|
||||
@@ -139,40 +150,35 @@ namespace DiscImageChef.Server
|
||||
lblListDevices.Text = statistics.Commands.ListDevices.ToString();
|
||||
lblListEncodings.Text = statistics.Commands.ListEncodings.ToString();
|
||||
}
|
||||
else
|
||||
divCommands.Visible = false;
|
||||
else divCommands.Visible = false;
|
||||
|
||||
if(statistics.Filters != null)
|
||||
{
|
||||
repFilters.DataSource = statistics.Filters.OrderBy(filter => filter.name).ToList();
|
||||
repFilters.DataBind();
|
||||
}
|
||||
else
|
||||
divFilters.Visible = false;
|
||||
else divFilters.Visible = false;
|
||||
|
||||
if(statistics.MediaImages != null)
|
||||
{
|
||||
repMediaImages.DataSource = statistics.MediaImages.OrderBy(filter => filter.name).ToList();
|
||||
repMediaImages.DataBind();
|
||||
}
|
||||
else
|
||||
divMediaImages.Visible = false;
|
||||
else divMediaImages.Visible = false;
|
||||
|
||||
if(statistics.Partitions != null)
|
||||
{
|
||||
repPartitions.DataSource = statistics.Partitions.OrderBy(filter => filter.name).ToList();
|
||||
repPartitions.DataBind();
|
||||
}
|
||||
else
|
||||
divPartitions.Visible = false;
|
||||
else divPartitions.Visible = false;
|
||||
|
||||
if(statistics.Filesystems != null)
|
||||
{
|
||||
repFilesystems.DataSource = statistics.Filesystems.OrderBy(filter => filter.name).ToList();
|
||||
repFilesystems.DataBind();
|
||||
}
|
||||
else
|
||||
divFilesystems.Visible = false;
|
||||
else divFilesystems.Visible = false;
|
||||
|
||||
if(statistics.Medias != null)
|
||||
{
|
||||
@@ -183,29 +189,29 @@ namespace DiscImageChef.Server
|
||||
string type;
|
||||
string subtype;
|
||||
|
||||
MediaType.MediaTypeToString((CommonTypes.MediaType)Enum.Parse(typeof(CommonTypes.MediaType), nvs.type), out type, out subtype);
|
||||
MediaType
|
||||
.MediaTypeToString((CommonTypes.MediaType)Enum.Parse(typeof(CommonTypes.MediaType), nvs.type),
|
||||
out type, out subtype);
|
||||
|
||||
if(nvs.real)
|
||||
realMedia.Add(new MediaItem { Type = type, SubType = subtype, Count = nvs.Value });
|
||||
else
|
||||
virtualMedia.Add(new MediaItem { Type = type, SubType = subtype, Count = nvs.Value });
|
||||
if(nvs.real) realMedia.Add(new MediaItem {Type = type, SubType = subtype, Count = nvs.Value});
|
||||
else virtualMedia.Add(new MediaItem {Type = type, SubType = subtype, Count = nvs.Value});
|
||||
}
|
||||
|
||||
if(realMedia.Count > 0)
|
||||
{
|
||||
repRealMedia.DataSource = realMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList();
|
||||
repRealMedia.DataSource =
|
||||
realMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList();
|
||||
repRealMedia.DataBind();
|
||||
}
|
||||
else
|
||||
divRealMedia.Visible = false;
|
||||
else divRealMedia.Visible = false;
|
||||
|
||||
if(virtualMedia.Count > 0)
|
||||
{
|
||||
repVirtualMedia.DataSource = virtualMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList();
|
||||
repVirtualMedia.DataSource =
|
||||
virtualMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList();
|
||||
repVirtualMedia.DataBind();
|
||||
}
|
||||
else
|
||||
divVirtualMedia.Visible = false;
|
||||
else divVirtualMedia.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -220,37 +226,40 @@ namespace DiscImageChef.Server
|
||||
{
|
||||
string url = null;
|
||||
string xmlFile;
|
||||
if(!string.IsNullOrWhiteSpace(device.Manufacturer) && !string.IsNullOrWhiteSpace(device.Model) && !string.IsNullOrWhiteSpace(device.Revision))
|
||||
if(!string.IsNullOrWhiteSpace(device.Manufacturer) &&
|
||||
!string.IsNullOrWhiteSpace(device.Model) && !string.IsNullOrWhiteSpace(device.Revision))
|
||||
{
|
||||
xmlFile = device.Manufacturer + "_" + device.Model + "_" + device.Revision + ".xml";
|
||||
url = string.Format("ViewReport.aspx?manufacturer={0}&model={1}&revision={2}",
|
||||
HttpUtility.UrlPathEncode(device.Manufacturer), HttpUtility.UrlPathEncode(device.Model), HttpUtility.UrlPathEncode(device.Revision));
|
||||
HttpUtility.UrlPathEncode(device.Manufacturer),
|
||||
HttpUtility.UrlPathEncode(device.Model),
|
||||
HttpUtility.UrlPathEncode(device.Revision));
|
||||
}
|
||||
else if(!string.IsNullOrWhiteSpace(device.Manufacturer) && !string.IsNullOrWhiteSpace(device.Model))
|
||||
else if(!string.IsNullOrWhiteSpace(device.Manufacturer) &&
|
||||
!string.IsNullOrWhiteSpace(device.Model))
|
||||
{
|
||||
xmlFile = device.Manufacturer + "_" + device.Model + ".xml";
|
||||
url = string.Format("ViewReport.aspx?manufacturer={0}&model={1}",
|
||||
HttpUtility.UrlPathEncode(device.Manufacturer), HttpUtility.UrlPathEncode(device.Model));
|
||||
HttpUtility.UrlPathEncode(device.Manufacturer),
|
||||
HttpUtility.UrlPathEncode(device.Model));
|
||||
}
|
||||
else if(!string.IsNullOrWhiteSpace(device.Model) && !string.IsNullOrWhiteSpace(device.Revision))
|
||||
{
|
||||
xmlFile = device.Model + "_" + device.Revision + ".xml";
|
||||
url = string.Format("ViewReport.aspx?model={0}&revision={1}",
|
||||
HttpUtility.UrlPathEncode(device.Model), HttpUtility.UrlPathEncode(device.Revision));
|
||||
HttpUtility.UrlPathEncode(device.Model),
|
||||
HttpUtility.UrlPathEncode(device.Revision));
|
||||
}
|
||||
else
|
||||
{
|
||||
xmlFile = device.Model + ".xml";
|
||||
url = string.Format("ViewReport.aspx?model={0}",
|
||||
HttpUtility.UrlPathEncode(device.Model));
|
||||
url = string.Format("ViewReport.aspx?model={0}", HttpUtility.UrlPathEncode(device.Model));
|
||||
}
|
||||
|
||||
xmlFile = xmlFile.Replace('/', '_').Replace('\\', '_').Replace('?', '_');
|
||||
|
||||
if(!File.Exists(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Reports", xmlFile)))
|
||||
{
|
||||
url = null;
|
||||
}
|
||||
if(!File.Exists(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Reports",
|
||||
xmlFile))) { url = null; }
|
||||
|
||||
devices.Add(new DeviceItem()
|
||||
{
|
||||
@@ -258,15 +267,17 @@ namespace DiscImageChef.Server
|
||||
Model = device.Model,
|
||||
Revision = device.Revision,
|
||||
Bus = device.Bus,
|
||||
ReportLink = url == null ? "No" : string.Format("<a href=\"{0}\" target=\"_blank\">Yes</a>", url)
|
||||
ReportLink =
|
||||
url == null ? "No" : string.Format("<a href=\"{0}\" target=\"_blank\">Yes</a>", url)
|
||||
});
|
||||
}
|
||||
repDevices.DataSource = devices.OrderBy(device => device.Manufacturer).ThenBy(device => device.Model).ThenBy(device => device.Revision).ThenBy(device => device.Bus).ToList();
|
||||
|
||||
repDevices.DataSource = devices.OrderBy(device => device.Manufacturer)
|
||||
.ThenBy(device => device.Model).ThenBy(device => device.Revision)
|
||||
.ThenBy(device => device.Bus).ToList();
|
||||
repDevices.DataBind();
|
||||
}
|
||||
else
|
||||
divDevices.Visible = false;
|
||||
|
||||
else divDevices.Visible = false;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -289,10 +300,7 @@ namespace DiscImageChef.Server
|
||||
}
|
||||
catch(IOException)
|
||||
{
|
||||
if(fs != null)
|
||||
{
|
||||
fs.Dispose();
|
||||
}
|
||||
if(fs != null) { fs.Dispose(); }
|
||||
System.Threading.Thread.Sleep(50);
|
||||
}
|
||||
}
|
||||
@@ -300,4 +308,4 @@ namespace DiscImageChef.Server
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user