Skip to content

Commit

Permalink
Release 2.3.3
Browse files Browse the repository at this point in the history
Fixed more errorhandling in threads. (that caues unhandled exception)
Create AppConfigLocal.xml with code instead of copying a file that windows installer foorgetss sometimes (magically)
Rolledback to sqlite from local files instead of nuget.  Nuget and SQLite.Interop.dll  and clockonce seems lite a bag full of hurt...
  • Loading branch information
finwen committed Jun 29, 2015
1 parent 0b0496c commit aebd928
Show file tree
Hide file tree
Showing 18 changed files with 15,862 additions and 116 deletions.
13 changes: 4 additions & 9 deletions EDDiscovery/App.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="EDDiscovery.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<userSettings>
<EDDiscovery.Properties.Settings>
Expand All @@ -18,9 +18,4 @@
</setting>
</EDDiscovery.Properties.Settings>
</userSettings>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data></configuration>
</configuration>
6 changes: 2 additions & 4 deletions EDDiscovery/AppConfigLocal.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<AppConfig>
<AppConfig>
<Network
VerboseLogging="1"
>
VerboseLogging="1">
</Network>

</AppConfig>
1 change: 1 addition & 0 deletions EDDiscovery/DB/SQLiteDBClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public bool UpgradeDB()
catch (Exception ex)
{
MessageBox.Show("UpgradeDB error: " + ex.Message);
MessageBox.Show(ex.StackTrace);
return false;
}

Expand Down
16 changes: 11 additions & 5 deletions EDDiscovery/EDDB/EDDBClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,31 @@ private bool DownloadFile(string url, string filename)
request.Headers[HttpRequestHeader.IfNoneMatch] = etag;
}
}

try
{
var response = (HttpWebResponse) request.GetResponse();
var response = (HttpWebResponse)request.GetResponse();

File.WriteAllText(tmpEtagFilename, response.Headers[HttpResponseHeader.ETag]);
var destFileStream = File.Open(tmpFilename, FileMode.Create, FileAccess.Write);
response.GetResponseStream().CopyTo(destFileStream);

destFileStream.Close();
response.Close();

if (File.Exists(filename))
File.Delete(filename);
if (File.Exists(etagFilename))
File.Delete(etagFilename);

File.Move(tmpFilename, filename);
File.Move(tmpEtagFilename, etagFilename);

return true;
}
catch (WebException ex)
{
var code = ((HttpWebResponse) ex.Response).StatusCode;
var code = ((HttpWebResponse)ex.Response).StatusCode;
if (code == HttpStatusCode.NotModified)
{
System.Diagnostics.Trace.WriteLine("EDDB: " + filename + " up to date (etag).");
Expand All @@ -91,6 +91,12 @@ private bool DownloadFile(string url, string filename)
System.Diagnostics.Trace.WriteLine(ex.StackTrace);
return false;
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine("DownloadFile Exception:" + ex.Message);
System.Diagnostics.Trace.WriteLine(ex.StackTrace);
return false;
}
}


Expand Down
34 changes: 16 additions & 18 deletions EDDiscovery/EDDiscovery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>2.3.0.0</ApplicationVersion>
<ApplicationVersion>2.3.3.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
Expand Down Expand Up @@ -86,13 +84,11 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.97.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Core.1.0.97.0\lib\net40\System.Data.SQLite.dll</HintPath>
<Private>True</Private>
<Reference Include="System.Data.SQLite">
<HintPath>.\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.97.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.97.0\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
<Private>True</Private>
<Reference Include="System.Data.SQLite.Linq">
<HintPath>.\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.Windows.Forms.DataVisualization" />
Expand Down Expand Up @@ -201,6 +197,9 @@
<Content Include="fge-logo-001-dark.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="SQLite.Interop.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="RouteControl.resx">
<DependentUpon>RouteControl.cs</DependentUpon>
</EmbeddedResource>
Expand Down Expand Up @@ -250,19 +249,18 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="SQLite\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
copy ..\..\SQLite.Interop.dll .
if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
xcopy /s /y "$(SolutionDir)packages\Noesis.Javascript.0.7.1.0\NativeBinaries\net40\x86\*.*" "$(TargetDir)x86"
if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64"
xcopy /s /y "$(SolutionDir)packages\Noesis.Javascript.0.7.1.0\NativeBinaries\net40\amd64\*.*" "$(TargetDir)amd64"</PostBuildEvent>
</PropertyGroup>
<Import Project="..\packages\System.Data.SQLite.Core.1.0.97.0\build\net40\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.97.0\build\net40\System.Data.SQLite.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.97.0\build\net40\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.97.0\build\net40\System.Data.SQLite.Core.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
96 changes: 54 additions & 42 deletions EDDiscovery/EDDiscoveryForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,65 +418,77 @@ internal void DistancesLoaded()

private void GetEDDBUpdate()
{
EDDBClass eddb = new EDDBClass();
string timestr;
DateTime time;
try
{
EDDBClass eddb = new EDDBClass();
string timestr;
DateTime time;

Thread.Sleep(1000);
Thread.Sleep(1000);

SQLiteDBClass db = new SQLiteDBClass();
timestr = db.GetSettingString("EDDBSystemsTime", "0");
time = new DateTime(Convert.ToInt64(timestr), DateTimeKind.Utc);
bool updatedb = false;
SQLiteDBClass db = new SQLiteDBClass();
timestr = db.GetSettingString("EDDBSystemsTime", "0");
time = new DateTime(Convert.ToInt64(timestr), DateTimeKind.Utc);
bool updatedb = false;

if (DateTime.UtcNow.Subtract(time).TotalDays > 0.5)
{
LogText("Get systems from EDDB. ");

if (eddb.GetSystems())
if (DateTime.UtcNow.Subtract(time).TotalDays > 0.5)
{
LogText("OK." + Environment.NewLine);

db.PutSettingString("EDDBSystemsTime", DateTime.UtcNow.Ticks.ToString());
updatedb = true;
}
else
LogText("Failed." + Environment.NewLine, Color.Red);
LogText("Get systems from EDDB. ");

if (eddb.GetSystems())
{
LogText("OK." + Environment.NewLine);

db.PutSettingString("EDDBSystemsTime", DateTime.UtcNow.Ticks.ToString());
updatedb = true;
}
else
LogText("Failed." + Environment.NewLine, Color.Red);

eddb.GetCommodities();
}

eddb.GetCommodities();
}

timestr = db.GetSettingString("EDDBStationsLiteTime", "0");
time = new DateTime(Convert.ToInt64(timestr), DateTimeKind.Utc);

if (DateTime.UtcNow.Subtract(time).TotalDays > 0.5)
{
timestr = db.GetSettingString("EDDBStationsLiteTime", "0");
time = new DateTime(Convert.ToInt64(timestr), DateTimeKind.Utc);

LogText("Get stations from EDDB. ");
if (eddb.GetStationsLite())
if (DateTime.UtcNow.Subtract(time).TotalDays > 0.5)
{
LogText("OK." + Environment.NewLine);
db.PutSettingString("EDDBStationsLiteTime", DateTime.UtcNow.Ticks.ToString());
updatedb = true;

LogText("Get stations from EDDB. ");
if (eddb.GetStationsLite())
{
LogText("OK." + Environment.NewLine);
db.PutSettingString("EDDBStationsLiteTime", DateTime.UtcNow.Ticks.ToString());
updatedb = true;
}
else
LogText("Failed." + Environment.NewLine, Color.Red);

}
else
LogText("Failed." + Environment.NewLine, Color.Red);

}

if (updatedb)
{
List<SystemClass> eddbsystems = eddb.ReadSystems();
List<StationClass> eddbstations = eddb.ReadStations();

if (updatedb)
{
List<SystemClass> eddbsystems = eddb.ReadSystems();
List<StationClass> eddbstations = eddb.ReadStations();
LogText("Add new EDDB data to database." + Environment.NewLine);
eddb.Add2DB(eddbsystems, eddbstations);
}

LogText("Add new EDDB data to database." + Environment.NewLine);
eddb.Add2DB(eddbsystems, eddbstations);
}
return;

return ;
}
catch (Exception ex)
{
Invoke((MethodInvoker)delegate
{
TravelHistoryControl.LogText("GetEDSCSystems exception:" + ex.Message + Environment.NewLine);
});
}

}


Expand Down

0 comments on commit aebd928

Please sign in to comment.