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