diff --git a/svnsync/Controllers/ControllersTray.cs b/svnsync/Controllers/ControllersTray.cs index 508f85c..57326d0 100644 --- a/svnsync/Controllers/ControllersTray.cs +++ b/svnsync/Controllers/ControllersTray.cs @@ -12,7 +12,9 @@ namespace svnsync.Controllers { private static ViewsTray viewTray; private static ControllersWindow controllerWindow; - private string args; + //private string args; + public delegate void _enableLoopRun(); + public event _enableLoopRun StartLoop; /// /// Controlls a Tray. @@ -28,13 +30,24 @@ namespace svnsync.Controllers viewTray.ShowSuccess(); System.Threading.Thread.Sleep(5000); viewTray.Dispose(); - return; + } else { + this.StartLoop(); } + return; } else { controllerWindow.execute(); } } + public override void Dispose() { + if(viewTray != null) { + viewTray.Dispose(); + } + if(controllerWindow != null) { + controllerWindow.Dispose(); + } + } + private bool cronJob(int run, bool readyToCommit) { if(viewTray.Model.Svn == null) { return HandleError(Handles.SvnType.NotInit, ""); @@ -48,7 +61,7 @@ namespace svnsync.Controllers try { viewTray.Model.Svn.CheckStatus(); } catch(NotImplementedException e) { - return HandleError(Handles.SvnType.UnexpectedError, e.Message); + return HandleError(Handles.SvnType.UnexpectedError, e.Message, e.StackTrace); } catch(Helpers.SvnLockedException e) { return HandleError(Handles.SvnType.LockedFile, e.Message); } @@ -91,7 +104,7 @@ namespace svnsync.Controllers return true; } - private bool HandleError(Handles.SvnType svnType, string p) { + private bool HandleError(Handles.SvnType svnType, string p, string p1 = "") { viewTray.ShowError(svnType, p); switch(svnType) { case Handles.SvnType.ToMutchChronRuns: @@ -102,7 +115,7 @@ namespace svnsync.Controllers break; case Handles.SvnType.UnexpectedError: controllerWindow.setAction(Handles.FormType.Error); - controllerWindow.setMessage(p); + controllerWindow.setMessage(p+" "+p1); break; case Handles.SvnType.ExternDeletedFiles: controllerWindow.setAction(Handles.FormType.DeletedFiles); diff --git a/svnsync/Controllers/ControllersWindow.cs b/svnsync/Controllers/ControllersWindow.cs index 78d8d4c..1475ce3 100644 --- a/svnsync/Controllers/ControllersWindow.cs +++ b/svnsync/Controllers/ControllersWindow.cs @@ -24,6 +24,11 @@ namespace svnsync.Controllers { viewWindow.Model.FormType = initAction; } + public override void Dispose() { + if(viewWindow != null) + viewWindow.Dispose(); + } + public static void FormClosed(object sender, FormClosedEventArgs e) { viewWindow.Dispose(); } diff --git a/svnsync/Libraries/Svn.cs b/svnsync/Libraries/Svn.cs index c2f3a0e..d15d040 100644 --- a/svnsync/Libraries/Svn.cs +++ b/svnsync/Libraries/Svn.cs @@ -4,225 +4,182 @@ using System.Linq; using System.Text; using System.Diagnostics; -namespace svnsync.Libraries -{ - class Svn - { - private string dir; - private Process p = new Process(); - private List modified; - private List noversion; - private List wasdeleted; - private List added; - private string SvnError = ""; - private string SvnOutput = ""; - private List isdeleted; - private List external; - private static Svn instances; +namespace svnsync.Libraries { + class Svn { + private string dir; + private Process p = new Process(); + private List modified; + private List noversion; + private List wasdeleted; + private List added; + private string SvnError = ""; + private string SvnOutput = ""; + private List isdeleted; + private List external; + private static Svn instances; - private Svn() { } + private Svn() { } - public void setDirectory(string dir) - { - this.dir = dir; - 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(); - noversion = new List(); - wasdeleted = new List(); - isdeleted = new List(); - added = new List(); - external = new List(); - 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 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 files) - { - String arg = "del"; - foreach (String item in files) - { - arg += " \"" + item + "\""; - } - this.runner(arg); - } - - internal List getWasDeletedFiles() - { - return this.wasdeleted; - } - - internal List getNoVersionFiles() - { - return this.noversion; - } - - internal void DeleteFiles(List l) - { - List s = new List(); - foreach (System.Windows.Forms.TreeNode item in l) - { - s.Add(item.FullPath); - } - this.DeleteFiles(s); - } - - internal void AddFiles(List l) - { - List s = new List(); - 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; - } + public void setDirectory(string dir) { + this.dir = dir; + 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(); + noversion = new List(); + wasdeleted = new List(); + isdeleted = new List(); + added = new List(); + external = new List(); + 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 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 files) { + String arg = "del"; + foreach(String item in files) { + arg += " \"" + item + "\""; + } + this.runner(arg); + } + + internal List getWasDeletedFiles() { + return this.wasdeleted; + } + + internal List getNoVersionFiles() { + return this.noversion; + } + + internal void DeleteFiles(List l) { + List s = new List(); + foreach(System.Windows.Forms.TreeNode item in l) { + s.Add(item.FullPath); + } + this.DeleteFiles(s); + } + + internal void AddFiles(List l) { + List s = new List(); + 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; + } + } } diff --git a/svnsync/Program.cs b/svnsync/Program.cs index bb5133d..0f977c9 100644 --- a/svnsync/Program.cs +++ b/svnsync/Program.cs @@ -10,6 +10,7 @@ namespace svnsync { static class Program { + private static bool LoopStarted = false; /// /// Der Haupteinstiegspunkt für die Anwendung. /// @@ -22,6 +23,7 @@ namespace svnsync try { Svn.getInstance().setDirectory(CmdArgs.getInstance().GetArgumentData("-d")); t = new ControllersTray(); + t.StartLoop += t_StartLoop; t.execute(); } catch(Exception e) { t.hideToolTip(); @@ -32,20 +34,28 @@ namespace svnsync return; } if(!CmdArgs.getInstance().HasArgumentType("-cron")) { - Application.Run(); + t_StartLoop(); } return; /*Application.Run();*/ - Application.EnableVisualStyles(); + /*Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { Application.Run(new Form1(args)); } catch(NotImplementedException e) { 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); Application.Exit(); + }*/ + } + + static void t_StartLoop() { + if(!LoopStarted) { + LoopStarted = true; + Application.Run(); } + } private static bool cmd(string[] args) diff --git a/svnsync/Properties/AssemblyInfo.cs b/svnsync/Properties/AssemblyInfo.cs index c30a36a..0df45cc 100644 --- a/svnsync/Properties/AssemblyInfo.cs +++ b/svnsync/Properties/AssemblyInfo.cs @@ -11,7 +11,7 @@ using System.Resources; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("BlubbFish")] [assembly: AssemblyProduct("SvnSync")] -[assembly: AssemblyCopyright("Copyright © 2012 - 2014")] +[assembly: AssemblyCopyright("Copyright © 2012 - 03.12.2016")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -33,6 +33,6 @@ using System.Resources; // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.1.0")] -[assembly: AssemblyFileVersion("1.0.1.0")] +[assembly: AssemblyVersion("1.0.2.0")] +[assembly: AssemblyFileVersion("1.0.2.0")] [assembly: NeutralResourcesLanguageAttribute("de-DE")] diff --git a/svnsync/bin/Release/SvnSync.exe b/svnsync/bin/Release/SvnSync.exe index 72903ba..f776602 100644 Binary files a/svnsync/bin/Release/SvnSync.exe and b/svnsync/bin/Release/SvnSync.exe differ