Skip to content

Commit fc8c16e

Browse files
committed
Automatic Update
1 parent e5bb312 commit fc8c16e

28 files changed

+672
-200
lines changed

DataCommander.Providers/DataCommander.Providers.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
<SpecificVersion>False</SpecificVersion>
186186
<HintPath>..\DataCommander\Foreign\Binaries\adodb.dll</HintPath>
187187
</Reference>
188+
<Reference Include="Microsoft.CSharp" />
188189
<Reference Include="Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
189190
<SpecificVersion>False</SpecificVersion>
190191
<HintPath>..\DataCommander\Foreign\Binaries\Microsoft.Office.Interop.Word.dll</HintPath>

DataCommander.Providers/DataCommanderApplication.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
using System.Data.Common;
1+
using System;
2+
using System.Data.Common;
23
using System.Diagnostics;
34
using System.Drawing;
5+
using System.IO;
46
using System.Reflection;
57
using DataCommander.Providers.Connection;
8+
using Foundation;
69
using Foundation.Configuration;
10+
using Foundation.Deployment;
711
using Foundation.Diagnostics;
812
using Foundation.Log;
913
using Microsoft.Win32;
14+
using Newtonsoft.Json;
1015
using Application = System.Windows.Forms.Application;
1116
using Task = System.Threading.Tasks.Task;
1217

@@ -18,12 +23,14 @@ public sealed class DataCommanderApplication
1823

1924
private static readonly ILog Log = LogFactory.Instance.GetCurrentTypeLog();
2025
private string _sectionName;
26+
private bool _updaterStarted;
2127

2228
#endregion
2329

2430
private DataCommanderApplication()
2531
{
26-
var fileName = Assembly.GetEntryAssembly().Location;
32+
var entryAssembly = Assembly.GetEntryAssembly();
33+
var fileName = entryAssembly.Location;
2734
var versionInfo = FileVersionInfo.GetVersionInfo(fileName);
2835
Name = versionInfo.ProductName;
2936

@@ -66,14 +73,17 @@ public ConfigurationNode ConnectionsConfigurationNode
6673

6774
public void Run()
6875
{
69-
MainForm = new MainForm();
70-
71-
Task.Delay(1000).ContinueWith(task =>
76+
if (!_updaterStarted)
7277
{
73-
Log.Write(LogLevel.Trace, "{0}\r\n{1}", AppDomainMonitor.EnvironmentInfo, AppDomainMonitor.CurrentDomainState);
74-
});
78+
MainForm = new MainForm();
79+
80+
Task.Delay(1000).ContinueWith(task =>
81+
{
82+
Log.Write(LogLevel.Trace, "{0}\r\n{1}", AppDomainMonitor.EnvironmentInfo, AppDomainMonitor.CurrentDomainState);
83+
});
7584

76-
Application.Run(MainForm);
85+
Application.Run(MainForm);
86+
}
7787
}
7888

7989
public void SaveApplicationData()

DataCommander.Providers/MainForm.cs

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
using Foundation;
1919
using Foundation.Assertions;
2020
using Foundation.Configuration;
21+
using Foundation.Deployment;
2122
using Foundation.Diagnostics;
2223
using Foundation.Linq;
2324
using Foundation.Log;
24-
using Foundation.Setup;
2525
using Foundation.Threading;
2626
using Foundation.Windows.Forms;
2727

@@ -178,42 +178,7 @@ public void UpdateTotalMemory()
178178
: Color.Red;
179179
}
180180

181-
private void Timer_Tick(object sender, EventArgs e)
182-
{
183-
if (_first)
184-
{
185-
_first = false;
186-
187-
var localVersion = File.ReadAllText("Version.txt");
188-
string remoteVersion = null;
189-
190-
try
191-
{
192-
remoteVersion = Installer.DownloadString("https://raw.githubusercontent.com/csbernath/DataCommander/master/DataCommander/Version.txt");
193-
}
194-
catch
195-
{
196-
}
197-
198-
//if (remoteVersion != null && localVersion != remoteVersion)
199-
_timer.Stop();
200-
this.Invoke(() => Download(remoteVersion));
201-
}
202-
203-
UpdateTotalMemory();
204-
}
205-
206-
private void Download(string remoteVersion)
207-
{
208-
var text = $"New version {remoteVersion} is avaliable. Do you want to install it?";
209-
210-
if (MessageBox.Show(text, "Data Commander", MessageBoxButtons.YesNo) == DialogResult.Yes)
211-
{
212-
var uri = new Uri("https://github.com/csbernath/DataCommander/releases/download/2018-04-13/DataCommander.7z");
213-
Installer.Download(uri, "Setup.exe");
214-
Close();
215-
}
216-
}
181+
private void Timer_Tick(object sender, EventArgs e) => UpdateTotalMemory();
217182

218183
/// <summary>
219184
/// Clean up any resources being used.

DataCommander.Update/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
5+
</startup>
6+
</configuration>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{0B6B1DFC-696B-457A-A57E-A0BCBA0C463D}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>DataCommander.Update</RootNamespace>
10+
<AssemblyName>DataCommander.Update</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Xml.Linq" />
38+
<Reference Include="System.Data.DataSetExtensions" />
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.Data" />
41+
<Reference Include="System.Deployment" />
42+
<Reference Include="System.Drawing" />
43+
<Reference Include="System.Net.Http" />
44+
<Reference Include="System.Windows.Forms" />
45+
<Reference Include="System.Xml" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<Compile Include="Form1.cs">
49+
<SubType>Form</SubType>
50+
</Compile>
51+
<Compile Include="Form1.Designer.cs">
52+
<DependentUpon>Form1.cs</DependentUpon>
53+
</Compile>
54+
<Compile Include="Program.cs" />
55+
<Compile Include="Properties\AssemblyInfo.cs" />
56+
<EmbeddedResource Include="Properties\Resources.resx">
57+
<Generator>ResXFileCodeGenerator</Generator>
58+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
59+
<SubType>Designer</SubType>
60+
</EmbeddedResource>
61+
<Compile Include="Properties\Resources.Designer.cs">
62+
<AutoGen>True</AutoGen>
63+
<DependentUpon>Resources.resx</DependentUpon>
64+
</Compile>
65+
<None Include="Properties\Settings.settings">
66+
<Generator>SettingsSingleFileGenerator</Generator>
67+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
68+
</None>
69+
<Compile Include="Properties\Settings.Designer.cs">
70+
<AutoGen>True</AutoGen>
71+
<DependentUpon>Settings.settings</DependentUpon>
72+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
73+
</Compile>
74+
</ItemGroup>
75+
<ItemGroup>
76+
<None Include="App.config" />
77+
</ItemGroup>
78+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
79+
</Project>

DataCommander.Update/Form1.Designer.cs

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DataCommander.Update/Form1.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using System.Windows.Forms;
10+
11+
namespace DataCommander.Update
12+
{
13+
public partial class Form1 : Form
14+
{
15+
public Form1()
16+
{
17+
InitializeComponent();
18+
}
19+
}
20+
}

DataCommander.Update/Program.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using System.Windows.Forms;
6+
7+
namespace DataCommander.Update
8+
{
9+
static class Program
10+
{
11+
[STAThread]
12+
static void Main()
13+
{
14+
15+
16+
17+
//Application.EnableVisualStyles();
18+
//Application.SetCompatibleTextRenderingDefault(false);
19+
//Application.Run(new Form1());
20+
}
21+
}
22+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("DataCommander.Update")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("DataCommander.Update")]
13+
[assembly: AssemblyCopyright("Copyright © 2018")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("0b6b1dfc-696b-457a-a57e-a0bcba0c463d")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)