Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad2d41dde0 | ||
|
|
4a91406d4f | ||
|
|
f9216f7bc9 | ||
|
|
61a7f1ff7b | ||
|
|
3d1105a614 | ||
|
|
3358262211 | ||
|
|
2bbe2e023b |
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace BlubbFish.Utils {
|
namespace BlubbFish.Utils {
|
||||||
public class UpdaterEventArgs : EventArgs {
|
public class UpdaterEventArgs : EventArgs {
|
||||||
|
|||||||
+12
-2
@@ -52,7 +52,7 @@ namespace BlubbFish.Utils
|
|||||||
Dictionary<String, String> sub = new Dictionary<String, String>();
|
Dictionary<String, String> sub = new Dictionary<String, String>();
|
||||||
String cap = "";
|
String cap = "";
|
||||||
foreach (String line in buf) {
|
foreach (String line in buf) {
|
||||||
Match match = Regex.Match(line, @"^\[[a-zA-Z0-9\-_ ]+\]\w*$", RegexOptions.IgnoreCase);
|
Match match = Regex.Match(line, @"^\[[a-zA-ZäöüÄÖÜ0-9\-_ ]+\]\w*$", RegexOptions.IgnoreCase);
|
||||||
if (match.Success) {
|
if (match.Success) {
|
||||||
if (sub.Count != 0 && cap != "") {
|
if (sub.Count != 0 && cap != "") {
|
||||||
this.cont.Add(cap, sub);
|
this.cont.Add(cap, sub);
|
||||||
@@ -74,7 +74,17 @@ namespace BlubbFish.Utils
|
|||||||
|
|
||||||
public List<String> GetSections()
|
public List<String> GetSections()
|
||||||
{
|
{
|
||||||
return this.cont.Keys.ToList<String>();
|
return this.cont.Keys.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<String, String> GetSection(String section) {
|
||||||
|
if(this.cont.Keys.Contains(section)) {
|
||||||
|
return this.cont[section];
|
||||||
|
}
|
||||||
|
if(this.cont.Keys.Contains("["+section+"]")) {
|
||||||
|
return this.cont["[" + section + "]"];
|
||||||
|
}
|
||||||
|
return new Dictionary<String, String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String GetValue(String section, String key)
|
public String GetValue(String section, String key)
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace BlubbFish.Utils
|
namespace BlubbFish.Utils
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-4
@@ -7,9 +7,7 @@ using System.Threading.Tasks;
|
|||||||
namespace BlubbFish.Utils {
|
namespace BlubbFish.Utils {
|
||||||
public abstract class OwnView {
|
public abstract class OwnView {
|
||||||
|
|
||||||
protected OwnView() {
|
protected OwnView() { }
|
||||||
this.Init();
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called if the Oberver (Model) updates its View
|
/// Called if the Oberver (Model) updates its View
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -17,7 +15,7 @@ namespace BlubbFish.Utils {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called if view is viewed
|
/// Called if view is viewed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void Init();
|
//protected abstract void Init();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called if Form is Disposed
|
/// Called if Form is Disposed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("Utils")]
|
[assembly: AssemblyProduct("Utils")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2014 - 24.04.2017")]
|
[assembly: AssemblyCopyright("Copyright © 2014 - 24.09.2017")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.3.1")]
|
[assembly: AssemblyVersion("1.0.5.1")]
|
||||||
[assembly: AssemblyFileVersion("1.0.3.1")]
|
[assembly: AssemblyFileVersion("1.0.5.1")]
|
||||||
|
|||||||
+47
-7
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -55,8 +54,13 @@ namespace BlubbFish.Utils {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Waits for the Result of the Updater thread.
|
/// Waits for the Result of the Updater thread.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void WaitForExit() {
|
public void WaitForExit(Boolean exceuteUpdate = true) {
|
||||||
while (this.t.ThreadState == ThreadState.Running) { }
|
while (this.t.ThreadState == ThreadState.Running) { }
|
||||||
|
if(exceuteUpdate) {
|
||||||
|
if(File.Exists("update.bat")) {
|
||||||
|
System.Diagnostics.Process.Start("update.bat");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -107,11 +111,11 @@ namespace BlubbFish.Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void Runner() {
|
private void Runner() {
|
||||||
Thread.Sleep(1);
|
Thread.Sleep(1000);
|
||||||
try {
|
try {
|
||||||
Stream stream = WebRequest.Create(this.url + "version.xml").GetResponse().GetResponseStream();
|
Stream stream = WebRequest.Create(this.url + "version.xml").GetResponse().GetResponseStream();
|
||||||
String content = new StreamReader(stream).ReadToEnd();
|
String content = new StreamReader(stream).ReadToEnd();
|
||||||
List<VersionInfo> updates = new List<VersionInfo>();
|
Boolean update = false;
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
doc.LoadXml(content);
|
doc.LoadXml(content);
|
||||||
foreach (XmlNode node in doc.DocumentElement.ChildNodes) {
|
foreach (XmlNode node in doc.DocumentElement.ChildNodes) {
|
||||||
@@ -120,10 +124,11 @@ namespace BlubbFish.Utils {
|
|||||||
for(Int32 i=0;i<this.versions.Length;i++) {
|
for(Int32 i=0;i<this.versions.Length;i++) {
|
||||||
if (this.versions[i].GUID == guid && this.versions[i].Version != version) {
|
if (this.versions[i].GUID == guid && this.versions[i].Version != version) {
|
||||||
this.versions[i].HasUpdate = true;
|
this.versions[i].HasUpdate = true;
|
||||||
|
update = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (updates.Count > 0) {
|
if (update) {
|
||||||
this.UpdateResult(this, new UpdaterEventArgs(true, "Update verfügbar"));
|
this.UpdateResult(this, new UpdaterEventArgs(true, "Update verfügbar"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -141,12 +146,47 @@ namespace BlubbFish.Utils {
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Boolean Update(Boolean afterExit = true) {
|
public Boolean Update(Boolean afterExit = true) {
|
||||||
try {
|
try {
|
||||||
|
if (afterExit) {
|
||||||
} catch(Exception e) {
|
this.UpdateAfter();
|
||||||
|
} else {
|
||||||
|
this.UpdateNow();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
this.ErrorRaised?.Invoke(this, new UpdaterFailEventArgs(e));
|
this.ErrorRaised?.Invoke(this, new UpdaterFailEventArgs(e));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateAfter() {
|
||||||
|
this.UpdateNow(true);
|
||||||
|
StreamWriter update = new StreamWriter("update.bat", false);
|
||||||
|
update.WriteLine("echo off");
|
||||||
|
update.WriteLine("echo \"Warte 10s\"");
|
||||||
|
update.WriteLine("ping 127.0.0.1 -n 10");
|
||||||
|
update.WriteLine("echo \"Kopiere Dateien....\"");
|
||||||
|
foreach (VersionInfo file in this.versions) {
|
||||||
|
if (file.HasUpdate) {
|
||||||
|
update.WriteLine("echo \"Kopiere " + file.Filename + "\"");
|
||||||
|
update.WriteLine("del " + file.Filename);
|
||||||
|
update.WriteLine("move " + file.Filename + "_ " + file.Filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
update.WriteLine("start cmd /C ping 127.0.0.1 -n 10 & del update.bat");
|
||||||
|
update.Flush();
|
||||||
|
update.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateNow(Boolean forAfter = false) {
|
||||||
|
foreach (VersionInfo file in this.versions) {
|
||||||
|
if (file.HasUpdate) {
|
||||||
|
Stream stream = WebRequest.Create(this.url + file.Filename).GetResponse().GetResponseStream();
|
||||||
|
FileStream target = new FileStream(file.Filename + (forAfter ? "_" : ""), FileMode.Create);
|
||||||
|
stream.CopyTo(target);
|
||||||
|
target.Flush();
|
||||||
|
target.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user