Fehlerbehebung

This commit is contained in:
BlubbFish 2016-12-03 10:38:17 +00:00
parent c5f7243285
commit 1dd219dc40
6 changed files with 214 additions and 229 deletions

View File

@ -12,7 +12,9 @@ namespace svnsync.Controllers
{ {
private static ViewsTray viewTray; private static ViewsTray viewTray;
private static ControllersWindow controllerWindow; private static ControllersWindow controllerWindow;
private string args; //private string args;
public delegate void _enableLoopRun();
public event _enableLoopRun StartLoop;
/// <summary> /// <summary>
/// Controlls a Tray. /// Controlls a Tray.
@ -28,13 +30,24 @@ namespace svnsync.Controllers
viewTray.ShowSuccess(); viewTray.ShowSuccess();
System.Threading.Thread.Sleep(5000); System.Threading.Thread.Sleep(5000);
viewTray.Dispose(); viewTray.Dispose();
return; } else {
this.StartLoop();
} }
return;
} else { } else {
controllerWindow.execute(); controllerWindow.execute();
} }
} }
public override void Dispose() {
if(viewTray != null) {
viewTray.Dispose();
}
if(controllerWindow != null) {
controllerWindow.Dispose();
}
}
private bool cronJob(int run, bool readyToCommit) { private bool cronJob(int run, bool readyToCommit) {
if(viewTray.Model.Svn == null) { if(viewTray.Model.Svn == null) {
return HandleError(Handles.SvnType.NotInit, ""); return HandleError(Handles.SvnType.NotInit, "");
@ -48,7 +61,7 @@ namespace svnsync.Controllers
try { try {
viewTray.Model.Svn.CheckStatus(); viewTray.Model.Svn.CheckStatus();
} catch(NotImplementedException e) { } catch(NotImplementedException e) {
return HandleError(Handles.SvnType.UnexpectedError, e.Message); return HandleError(Handles.SvnType.UnexpectedError, e.Message, e.StackTrace);
} catch(Helpers.SvnLockedException e) { } catch(Helpers.SvnLockedException e) {
return HandleError(Handles.SvnType.LockedFile, e.Message); return HandleError(Handles.SvnType.LockedFile, e.Message);
} }
@ -91,7 +104,7 @@ namespace svnsync.Controllers
return true; return true;
} }
private bool HandleError(Handles.SvnType svnType, string p) { private bool HandleError(Handles.SvnType svnType, string p, string p1 = "") {
viewTray.ShowError(svnType, p); viewTray.ShowError(svnType, p);
switch(svnType) { switch(svnType) {
case Handles.SvnType.ToMutchChronRuns: case Handles.SvnType.ToMutchChronRuns:
@ -102,7 +115,7 @@ namespace svnsync.Controllers
break; break;
case Handles.SvnType.UnexpectedError: case Handles.SvnType.UnexpectedError:
controllerWindow.setAction(Handles.FormType.Error); controllerWindow.setAction(Handles.FormType.Error);
controllerWindow.setMessage(p); controllerWindow.setMessage(p+" "+p1);
break; break;
case Handles.SvnType.ExternDeletedFiles: case Handles.SvnType.ExternDeletedFiles:
controllerWindow.setAction(Handles.FormType.DeletedFiles); controllerWindow.setAction(Handles.FormType.DeletedFiles);

View File

@ -24,6 +24,11 @@ namespace svnsync.Controllers {
viewWindow.Model.FormType = initAction; viewWindow.Model.FormType = initAction;
} }
public override void Dispose() {
if(viewWindow != null)
viewWindow.Dispose();
}
public static void FormClosed(object sender, FormClosedEventArgs e) { public static void FormClosed(object sender, FormClosedEventArgs e) {
viewWindow.Dispose(); viewWindow.Dispose();
} }

View File

@ -4,10 +4,8 @@ using System.Linq;
using System.Text; using System.Text;
using System.Diagnostics; using System.Diagnostics;
namespace svnsync.Libraries namespace svnsync.Libraries {
{ class Svn {
class Svn
{
private string dir; private string dir;
private Process p = new Process(); private Process p = new Process();
private List<String> modified; private List<String> modified;
@ -22,14 +20,12 @@ namespace svnsync.Libraries
private Svn() { } private Svn() { }
public void setDirectory(string dir) public void setDirectory(string dir) {
{
this.dir = dir; this.dir = dir;
this.Init(); this.Init();
} }
private void Init() private void Init() {
{
p.StartInfo.FileName = "svn"; p.StartInfo.FileName = "svn";
p.StartInfo.WorkingDirectory = this.dir; p.StartInfo.WorkingDirectory = this.dir;
p.StartInfo.CreateNoWindow = true; p.StartInfo.CreateNoWindow = true;
@ -38,8 +34,7 @@ namespace svnsync.Libraries
p.StartInfo.UseShellExecute = false; p.StartInfo.UseShellExecute = false;
} }
internal void CheckStatus() internal void CheckStatus() {
{
modified = new List<string>(); modified = new List<string>();
noversion = new List<string>(); noversion = new List<string>();
wasdeleted = new List<string>(); wasdeleted = new List<string>();
@ -48,94 +43,71 @@ namespace svnsync.Libraries
external = new List<string>(); external = new List<string>();
this.runner("st"); this.runner("st");
string[] lines = this.SvnOutput.Split('\n'); string[] lines = this.SvnOutput.Split('\n');
foreach (String line in lines) foreach(String line in lines) {
{ if(line.Length < 7)
if (line.Length < 7)
break; break;
Char[] handles = line.Substring(0, 7).ToCharArray(); Char[] handles = line.Substring(0, 7).ToCharArray();
String file = line.Substring(8).Trim(new Char[] {'\r','\n',' ','\t'}); String file = line.Substring(8).Trim(new Char[] { '\r', '\n', ' ', '\t' });
if (handles[0] == ' ') if(handles[0] == ' ') {
{
if(handles[2] == 'L') { if(handles[2] == 'L') {
throw new svnsync.Helpers.SvnLockedException("Datei: " + file + " ist gelockt!"); throw new svnsync.Helpers.SvnLockedException("Datei: " + file + " ist gelockt!");
}
//Modifizierte Eigenschaft
else if(handles[1] == 'M') {
modified.Add(file);
} else { } else {
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] ' '"); throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] ' '");
} }
} } else if(handles[0] == 'A') {
else if (handles[0] == 'A')
{
added.Add(file); added.Add(file);
} } else if(handles[0] == 'D') {
else if (handles[0] == 'D')
{
isdeleted.Add(file); isdeleted.Add(file);
} }
else if (handles[0] == 'M') // Modifizierte Datei
{ else if(handles[0] == 'M') {
modified.Add(file); modified.Add(file);
} } else if(handles[0] == 'R') {
else if (handles[0] == 'R')
{
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'R'"); throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'R'");
} } else if(handles[0] == 'C') {
else if (handles[0] == 'C')
{
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'C'"); throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'C'");
} } else if(handles[0] == 'X') {
else if (handles[0] == 'X')
{
external.Add(file); external.Add(file);
} } else if(handles[0] == 'I') {
else if (handles[0] == 'I')
{
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'I'"); throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'I'");
} } else if(handles[0] == '?') {
else if (handles[0] == '?')
{
noversion.Add(file); noversion.Add(file);
} } else if(handles[0] == '!') {
else if (handles[0] == '!')
{
wasdeleted.Add(file); wasdeleted.Add(file);
} } else if(handles[0] == '~') {
else if (handles[0] == '~')
{
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] '~'"); throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] '~'");
} } else {
else
{
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: Unexpected Symbol! [0]: \"" + handles[0] + "\""); throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: Unexpected Symbol! [0]: \"" + handles[0] + "\"");
} }
} }
} }
internal bool IsNotOnlyModified() internal bool IsNotOnlyModified() {
{ if(this.noversion.Count != 0)
if (this.noversion.Count != 0)
return true; return true;
if (this.wasdeleted.Count != 0) if(this.wasdeleted.Count != 0)
return true; return true;
return false; return false;
} }
internal void SetArgCheckIn(string message) internal void SetArgCheckIn(string message) {
{
String arg = "ci -m \"" + message + "\""; String arg = "ci -m \"" + message + "\"";
this.runner(arg); this.runner(arg);
} }
internal void AddFiles(List<String> files) internal void AddFiles(List<String> files) {
{
String arg = "add"; String arg = "add";
foreach (String item in files) foreach(String item in files) {
{ arg += " \"" + item + "\"";
arg += " \"" + item+"\"";
} }
this.runner(arg); this.runner(arg);
} }
private void runner(string arg) private void runner(string arg) {
{
this.SvnOutput = ""; this.SvnOutput = "";
this.SvnError = ""; this.SvnError = "";
p.StartInfo.Arguments = arg; p.StartInfo.Arguments = arg;
@ -145,81 +117,66 @@ namespace svnsync.Libraries
p.WaitForExit(); p.WaitForExit();
} }
internal bool IsUncheckedFiles() internal bool IsUncheckedFiles() {
{ if(this.noversion.Count != 0)
if (this.noversion.Count != 0)
return true; return true;
return false; return false;
} }
internal bool IsExternDeletedFiles() internal bool IsExternDeletedFiles() {
{ if(this.wasdeleted.Count != 0)
if (this.wasdeleted.Count != 0)
return true; return true;
return false; return false;
} }
internal bool IsError() internal bool IsError() {
{ if(this.SvnError != "")
if (this.SvnError != "")
return true; return true;
return false; return false;
} }
internal string getError() internal string getError() {
{
return this.SvnError; return this.SvnError;
} }
internal void DeleteFiles(List<String> files) internal void DeleteFiles(List<String> files) {
{
String arg = "del"; String arg = "del";
foreach (String item in files) foreach(String item in files) {
{
arg += " \"" + item + "\""; arg += " \"" + item + "\"";
} }
this.runner(arg); this.runner(arg);
} }
internal List<String> getWasDeletedFiles() internal List<String> getWasDeletedFiles() {
{
return this.wasdeleted; return this.wasdeleted;
} }
internal List<String> getNoVersionFiles() internal List<String> getNoVersionFiles() {
{
return this.noversion; return this.noversion;
} }
internal void DeleteFiles(List<System.Windows.Forms.TreeNode> l) internal void DeleteFiles(List<System.Windows.Forms.TreeNode> l) {
{
List<String> s = new List<string>(); List<String> s = new List<string>();
foreach (System.Windows.Forms.TreeNode item in l) foreach(System.Windows.Forms.TreeNode item in l) {
{
s.Add(item.FullPath); s.Add(item.FullPath);
} }
this.DeleteFiles(s); this.DeleteFiles(s);
} }
internal void AddFiles(List<System.Windows.Forms.TreeNode> l) internal void AddFiles(List<System.Windows.Forms.TreeNode> l) {
{
List<String> s = new List<string>(); List<String> s = new List<string>();
foreach (System.Windows.Forms.TreeNode item in l) foreach(System.Windows.Forms.TreeNode item in l) {
{
s.Add(item.FullPath); s.Add(item.FullPath);
} }
this.AddFiles(s); this.AddFiles(s);
} }
internal void Update() internal void Update() {
{
this.runner("up"); this.runner("up");
} }
public static Svn getInstance() public static Svn getInstance() {
{ if(instances == null) {
if (instances == null)
{
instances = new Svn(); instances = new Svn();
} }
return instances; return instances;

View File

@ -10,6 +10,7 @@ namespace svnsync
{ {
static class Program static class Program
{ {
private static bool LoopStarted = false;
/// <summary> /// <summary>
/// Der Haupteinstiegspunkt für die Anwendung. /// Der Haupteinstiegspunkt für die Anwendung.
/// </summary> /// </summary>
@ -22,6 +23,7 @@ namespace svnsync
try { try {
Svn.getInstance().setDirectory(CmdArgs.getInstance().GetArgumentData("-d")); Svn.getInstance().setDirectory(CmdArgs.getInstance().GetArgumentData("-d"));
t = new ControllersTray(); t = new ControllersTray();
t.StartLoop += t_StartLoop;
t.execute(); t.execute();
} catch(Exception e) { } catch(Exception e) {
t.hideToolTip(); t.hideToolTip();
@ -32,20 +34,28 @@ namespace svnsync
return; return;
} }
if(!CmdArgs.getInstance().HasArgumentType("-cron")) { if(!CmdArgs.getInstance().HasArgumentType("-cron")) {
Application.Run(); t_StartLoop();
} }
return; return;
/*Application.Run();*/ /*Application.Run();*/
Application.EnableVisualStyles(); /*Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
try { try {
Application.Run(new Form1(args)); Application.Run(new Form1(args));
} catch(NotImplementedException e) { } catch(NotImplementedException e) {
System.Windows.Forms.MessageBox.Show("In: " + e.Source + "\n\n" + e.Message, "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Windows.Forms.MessageBox.Show("In: " + e.Source + "\n\n" + e.Message, "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error);
} catch(Exception /*e*/) { } catch(Exception e) {
//System.Windows.Forms.MessageBox.Show("In: " + e.Source + "\n\n" + e.Message, "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error); //System.Windows.Forms.MessageBox.Show("In: " + e.Source + "\n\n" + e.Message, "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit(); Application.Exit();
}*/
} }
static void t_StartLoop() {
if(!LoopStarted) {
LoopStarted = true;
Application.Run();
}
} }
private static bool cmd(string[] args) private static bool cmd(string[] args)

View File

@ -11,7 +11,7 @@ using System.Resources;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("BlubbFish")] [assembly: AssemblyCompany("BlubbFish")]
[assembly: AssemblyProduct("SvnSync")] [assembly: AssemblyProduct("SvnSync")]
[assembly: AssemblyCopyright("Copyright © 2012 - 2014")] [assembly: AssemblyCopyright("Copyright © 2012 - 03.12.2016")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -33,6 +33,6 @@ using System.Resources;
// 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.1.0")] [assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: NeutralResourcesLanguageAttribute("de-DE")] [assembly: NeutralResourcesLanguageAttribute("de-DE")]

Binary file not shown.