Refactor is that shit
This commit is contained in:
parent
01311c6adc
commit
19bd2da502
@ -1,160 +1,163 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BlubbFish.Utils;
|
||||
using svnsync.Views;
|
||||
using svnsync.Helpers;
|
||||
|
||||
namespace svnsync.Controllers
|
||||
{
|
||||
class ControllersTray : OwnController
|
||||
class ControllersTray : OwnController
|
||||
{
|
||||
private static ViewsTray viewTray;
|
||||
private static ControllersWindow controllerWindow;
|
||||
//private string args;
|
||||
public delegate void _enableLoopRun();
|
||||
public event _enableLoopRun StartLoop;
|
||||
|
||||
/// <summary>
|
||||
/// Controlls a Tray.
|
||||
/// </summary>
|
||||
public ControllersTray() { }
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
private static ViewsTray viewTray;
|
||||
private static ControllersWindow controllerWindow;
|
||||
//private string args;
|
||||
public delegate void _enableLoopRun();
|
||||
public event _enableLoopRun StartLoop;
|
||||
|
||||
/// <summary>
|
||||
/// Controlls a Tray.
|
||||
/// </summary>
|
||||
public ControllersTray() {}
|
||||
|
||||
protected override void init() {
|
||||
viewTray = new ViewsTray();
|
||||
controllerWindow = new ControllersWindow();
|
||||
controllerWindow.setAction(Handles.FormType.Normal);
|
||||
if(viewTray.Model.Args.HasArgumentType("-cron")) {
|
||||
if(this.cronJob(0, false)) {
|
||||
viewTray.ShowSuccess();
|
||||
System.Threading.Thread.Sleep(5000);
|
||||
viewTray.Dispose();
|
||||
} 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, "");
|
||||
}
|
||||
if(run > 10) {
|
||||
return HandleError(Handles.SvnType.ToMutchChronRuns, "");
|
||||
}
|
||||
if(viewTray.Model.Svn.IsError()) {
|
||||
return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.getError());
|
||||
}
|
||||
try {
|
||||
viewTray.Model.Svn.CheckStatus();
|
||||
} catch(NotImplementedException e) {
|
||||
return HandleError(Handles.SvnType.UnexpectedError, e.Message, e.StackTrace);
|
||||
} catch(Helpers.SvnLockedException e) {
|
||||
return HandleError(Handles.SvnType.LockedFile, e.Message);
|
||||
}
|
||||
if(viewTray.Model.Svn.IsNotOnlyModified()) {
|
||||
if(viewTray.Model.Svn.IsUncheckedFiles()) {
|
||||
if(viewTray.Model.Args.HasArgumentType("-autoadd")) {
|
||||
viewTray.Model.Svn.AddFiles(viewTray.Model.Svn.getNoVersionFiles());
|
||||
if(viewTray.Model.Svn.IsError()) {
|
||||
return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.getError());
|
||||
}
|
||||
} else {
|
||||
return HandleError(Handles.SvnType.HasVersionitedFiles, "");
|
||||
}
|
||||
}
|
||||
if(viewTray.Model.Svn.IsExternDeletedFiles()) {
|
||||
if(viewTray.Model.Args.HasArgumentType("-autodelete")) {
|
||||
viewTray.Model.Svn.DeleteFiles(viewTray.Model.Svn.getWasDeletedFiles());
|
||||
if(viewTray.Model.Svn.IsError()) {
|
||||
return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.getError());
|
||||
}
|
||||
} else {
|
||||
return HandleError(Handles.SvnType.ExternDeletedFiles, "");
|
||||
}
|
||||
}
|
||||
return this.cronJob(run + 1, true);
|
||||
} else {
|
||||
if(readyToCommit) {
|
||||
viewTray.Model.Svn.SetArgCheckIn("Automatic Cronjob Checkin: " + StringHelper.GetTimeStamp(DateTime.Now));
|
||||
if(viewTray.Model.Svn.IsError()) {
|
||||
return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.getError());
|
||||
}
|
||||
} else {
|
||||
viewTray.Model.Svn.Update();
|
||||
if(viewTray.Model.Svn.IsError()) {
|
||||
return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.getError());
|
||||
}
|
||||
return this.cronJob(run + 1, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool HandleError(Handles.SvnType svnType, string p, string p1 = "") {
|
||||
viewTray.ShowError(svnType, p);
|
||||
switch(svnType) {
|
||||
case Handles.SvnType.ToMutchChronRuns:
|
||||
controllerWindow.setAction(Handles.FormType.MuchCronJobs);
|
||||
break;
|
||||
case Handles.SvnType.HasVersionitedFiles:
|
||||
controllerWindow.setAction(Handles.FormType.UnversionFiles);
|
||||
break;
|
||||
case Handles.SvnType.UnexpectedError:
|
||||
controllerWindow.setAction(Handles.FormType.Error);
|
||||
controllerWindow.setMessage(p+" "+p1);
|
||||
break;
|
||||
case Handles.SvnType.ExternDeletedFiles:
|
||||
controllerWindow.setAction(Handles.FormType.DeletedFiles);
|
||||
break;
|
||||
case Handles.SvnType.LockedFile:
|
||||
controllerWindow.setAction(Handles.FormType.ManualResolve);
|
||||
controllerWindow.setMessage(p);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If you Click on the Tray Icon
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public static void Click_Tray(object sender, EventArgs e)
|
||||
{
|
||||
controllerWindow.execute();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If you Click on the Tray Ballon
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public static void Click_Ballon(object sender, EventArgs e)
|
||||
{
|
||||
controllerWindow.execute();
|
||||
}
|
||||
|
||||
internal void hideToolTip() {
|
||||
viewTray.HideToolTip();
|
||||
}
|
||||
|
||||
internal static void Click_Quit(object sender, EventArgs e) {
|
||||
viewTray = new ViewsTray();
|
||||
controllerWindow = new ControllersWindow();
|
||||
controllerWindow.SetAction(Handles.FormType.Normal);
|
||||
if (viewTray.Model.Args.HasArgumentType("-cron")) {
|
||||
if (this.CronJob(0, false)) {
|
||||
viewTray.ShowSuccess();
|
||||
System.Threading.Thread.Sleep(5000);
|
||||
viewTray.Dispose();
|
||||
System.Windows.Forms.Application.Exit();
|
||||
} else {
|
||||
this.StartLoop();
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
controllerWindow.Execute();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
if (viewTray != null) {
|
||||
viewTray.Dispose();
|
||||
}
|
||||
if (controllerWindow != null) {
|
||||
controllerWindow.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean CronJob(Int32 run, Boolean readyToCommit)
|
||||
{
|
||||
if (viewTray.Model.Svn == null) {
|
||||
return HandleError(Handles.SvnType.NotInit, "");
|
||||
}
|
||||
if (run > 10) {
|
||||
return HandleError(Handles.SvnType.ToMutchChronRuns, "");
|
||||
}
|
||||
if (viewTray.Model.Svn.IsError) {
|
||||
return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.Error);
|
||||
}
|
||||
try {
|
||||
viewTray.Model.Svn.CheckStatus();
|
||||
} catch (NotImplementedException e) {
|
||||
return HandleError(Handles.SvnType.UnexpectedError, e.Message, e.StackTrace);
|
||||
} catch (Helpers.SvnLockedException e) {
|
||||
return HandleError(Handles.SvnType.LockedFile, e.Message);
|
||||
}
|
||||
if (viewTray.Model.Svn.IsNotOnlyModified) {
|
||||
if (viewTray.Model.Svn.IsUncheckedFiles) {
|
||||
if (viewTray.Model.Args.HasArgumentType("-autoadd")) {
|
||||
viewTray.Model.Svn.AddFiles(viewTray.Model.Svn.NoVersionFiles);
|
||||
if (viewTray.Model.Svn.IsError) {
|
||||
return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.Error);
|
||||
}
|
||||
} else {
|
||||
return HandleError(Handles.SvnType.HasVersionitedFiles, "");
|
||||
}
|
||||
}
|
||||
if (viewTray.Model.Svn.IsExternDeletedFiles) {
|
||||
if (viewTray.Model.Args.HasArgumentType("-autodelete")) {
|
||||
viewTray.Model.Svn.DeleteFiles(viewTray.Model.Svn.WasDeletedFiles);
|
||||
if (viewTray.Model.Svn.IsError) {
|
||||
return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.Error);
|
||||
}
|
||||
} else {
|
||||
return HandleError(Handles.SvnType.ExternDeletedFiles, "");
|
||||
}
|
||||
}
|
||||
return this.CronJob(run + 1, true);
|
||||
} else {
|
||||
if (readyToCommit) {
|
||||
viewTray.Model.Svn.SetArgCheckIn("Automatic Cronjob Checkin: " + StringHelper.GetTimeStamp(DateTime.Now));
|
||||
if (viewTray.Model.Svn.IsError) {
|
||||
return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.Error);
|
||||
}
|
||||
} else {
|
||||
viewTray.Model.Svn.Update();
|
||||
if (viewTray.Model.Svn.IsError) {
|
||||
return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.Error);
|
||||
}
|
||||
return this.CronJob(run + 1, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Boolean HandleError(Handles.SvnType svnType, String message, String stacktrace = "")
|
||||
{
|
||||
viewTray.ShowError(svnType, message);
|
||||
switch (svnType) {
|
||||
case Handles.SvnType.ToMutchChronRuns:
|
||||
controllerWindow.SetAction(Handles.FormType.MuchCronJobs);
|
||||
break;
|
||||
case Handles.SvnType.HasVersionitedFiles:
|
||||
controllerWindow.SetAction(Handles.FormType.UnversionFiles);
|
||||
break;
|
||||
case Handles.SvnType.UnexpectedError:
|
||||
controllerWindow.SetAction(Handles.FormType.Error);
|
||||
controllerWindow.SetMessage(message + " " + stacktrace);
|
||||
break;
|
||||
case Handles.SvnType.ExternDeletedFiles:
|
||||
controllerWindow.SetAction(Handles.FormType.DeletedFiles);
|
||||
break;
|
||||
case Handles.SvnType.LockedFile:
|
||||
controllerWindow.SetAction(Handles.FormType.ManualResolve);
|
||||
controllerWindow.SetMessage(message);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If you Click on the Tray Icon
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public static void Click_Tray(Object sender, EventArgs e)
|
||||
{
|
||||
controllerWindow.Execute();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If you Click on the Tray Ballon
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public static void Click_Ballon(Object sender, EventArgs e)
|
||||
{
|
||||
controllerWindow.Execute();
|
||||
}
|
||||
|
||||
internal void HideToolTip()
|
||||
{
|
||||
viewTray.HideToolTip();
|
||||
}
|
||||
|
||||
internal static void Click_Quit(Object sender, EventArgs e)
|
||||
{
|
||||
viewTray.Dispose();
|
||||
System.Windows.Forms.Application.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using BlubbFish.Utils;
|
||||
using svnsync.Views;
|
||||
using svnsync.Helpers;
|
||||
|
||||
namespace svnsync.Controllers {
|
||||
public class ControllersWindow : OwnController {
|
||||
namespace svnsync.Controllers
|
||||
{
|
||||
public class ControllersWindow : OwnController
|
||||
{
|
||||
private static ViewsWindow viewWindow;
|
||||
private Handles.FormType initAction;
|
||||
private string initMessage;
|
||||
private String initMessage;
|
||||
/// <summary>
|
||||
/// Tray Controller
|
||||
/// </summary>
|
||||
public ControllersWindow() { }
|
||||
|
||||
override protected void init() {
|
||||
override protected void Init()
|
||||
{
|
||||
viewWindow = new ViewsWindow();
|
||||
viewWindow.Model.Message = initMessage;
|
||||
viewWindow.Model.FormType = initAction;
|
||||
viewWindow.Model.Message = this.initMessage;
|
||||
viewWindow.Model.FormType = this.initAction;
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
if(viewWindow != null)
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
internal void setAction(Handles.FormType formType) {
|
||||
if(viewWindow == null) {
|
||||
internal void SetAction(Handles.FormType formType)
|
||||
{
|
||||
if (viewWindow == null) {
|
||||
this.initAction = formType;
|
||||
} else {
|
||||
viewWindow.Model.FormType = formType;
|
||||
@ -47,8 +50,9 @@ namespace svnsync.Controllers {
|
||||
//this.CreateFileList("Löschen", "Diese Daten sind gelöscht worden:", s.getWasDeletedFiles(), new EventHandler(deleteButton_Click));
|
||||
}
|
||||
|
||||
internal void setMessage(string p) {
|
||||
if(viewWindow == null) {
|
||||
internal void SetMessage(String p)
|
||||
{
|
||||
if (viewWindow == null) {
|
||||
this.initMessage = p;
|
||||
} else {
|
||||
viewWindow.Model.Message = p;
|
||||
|
@ -39,8 +39,8 @@ namespace svnsync
|
||||
pargs.Add("-cron", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single));
|
||||
pargs.Add("-autoadd", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single));
|
||||
pargs.Add("-autodelete", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single));
|
||||
this.c = CmdArgs.getInstance();
|
||||
this.c.setArguments(pargs, args);
|
||||
this.c = CmdArgs.Instance;
|
||||
this.c.SetArguments(pargs, args);
|
||||
this.StartSvn();
|
||||
if (this.s != null)
|
||||
{
|
||||
@ -68,8 +68,8 @@ namespace svnsync
|
||||
return this.HandleSvn(HandleSvnType.NotInit, "");
|
||||
if (run > 10)
|
||||
return this.HandleSvn(HandleSvnType.ToMutchChronRuns, "");
|
||||
if (s.IsError())
|
||||
return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError());
|
||||
if (s.IsError)
|
||||
return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
|
||||
try
|
||||
{
|
||||
s.CheckStatus();
|
||||
@ -78,26 +78,26 @@ namespace svnsync
|
||||
{
|
||||
return this.HandleSvn(HandleSvnType.UnexpectedError, e.Message);
|
||||
}
|
||||
if (s.IsNotOnlyModified())
|
||||
if (s.IsNotOnlyModified)
|
||||
{
|
||||
if (s.IsUncheckedFiles())
|
||||
if (s.IsUncheckedFiles)
|
||||
{
|
||||
if (c.HasArgumentType("-autoadd"))
|
||||
s.AddFiles(s.getNoVersionFiles());
|
||||
s.AddFiles(s.NoVersionFiles);
|
||||
else
|
||||
return this.HandleSvn(HandleSvnType.HasVersionitedFiles, "");
|
||||
}
|
||||
if (s.IsError())
|
||||
return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError());
|
||||
if (s.IsExternDeletedFiles())
|
||||
if (s.IsError)
|
||||
return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
|
||||
if (s.IsExternDeletedFiles)
|
||||
{
|
||||
if (c.HasArgumentType("-autodelete"))
|
||||
s.DeleteFiles(s.getWasDeletedFiles());
|
||||
s.DeleteFiles(s.WasDeletedFiles);
|
||||
else
|
||||
return this.HandleSvn(HandleSvnType.ExternDeletedFiles, "");
|
||||
}
|
||||
if (s.IsError())
|
||||
return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError());
|
||||
if (s.IsError)
|
||||
return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
|
||||
return this.cronJob(run + 1, true);
|
||||
}
|
||||
else
|
||||
@ -105,14 +105,14 @@ namespace svnsync
|
||||
if (readyToCommit)
|
||||
{
|
||||
s.SetArgCheckIn(this.GetTimeStamp(DateTime.Now));
|
||||
if (s.IsError())
|
||||
return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError());
|
||||
if (s.IsError)
|
||||
return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
s.Update();
|
||||
if (s.IsError())
|
||||
return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError());
|
||||
if (s.IsError)
|
||||
return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
|
||||
return this.cronJob(run + 1, true);
|
||||
}
|
||||
}
|
||||
@ -132,7 +132,7 @@ namespace svnsync
|
||||
return false;
|
||||
case HandleSvnType.HasVersionitedFiles:
|
||||
this.ShowToolTip("Svn Sync", "Es sind unversionierte Dateien vorhanden (?)", ToolTipIcon.Info);
|
||||
this.CreateFileList("Hinzufügen", "Diese Daten sind unversioniert:", s.getNoVersionFiles(), new EventHandler(addButton_Click));
|
||||
this.CreateFileList("Hinzufügen", "Diese Daten sind unversioniert:", s.NoVersionFiles, new EventHandler(addButton_Click));
|
||||
return false;
|
||||
case HandleSvnType.UnexpectedError:
|
||||
this.ShowToolTip("Svn Sync Fehler", "Es ist ein Unvorhersebarer Fehler aufgetreten: " + p, ToolTipIcon.Error);
|
||||
@ -140,7 +140,7 @@ namespace svnsync
|
||||
return false;
|
||||
case HandleSvnType.ExternDeletedFiles:
|
||||
this.ShowToolTip("Svn Sync", "Es sind extern gelöschte Dateien vorhanden (!)", ToolTipIcon.Info);
|
||||
this.CreateFileList("Löschen", "Diese Daten sind gelöscht worden:", s.getWasDeletedFiles(), new EventHandler(deleteButton_Click));
|
||||
this.CreateFileList("Löschen", "Diese Daten sind gelöscht worden:", s.WasDeletedFiles, new EventHandler(deleteButton_Click));
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
@ -424,9 +424,9 @@ namespace svnsync
|
||||
this.ShowInTaskbar = false;
|
||||
this.WindowState = FormWindowState.Minimized;
|
||||
s.DeleteFiles(l);
|
||||
if (s.IsError())
|
||||
if (s.IsError)
|
||||
{
|
||||
this.HandleSvn(HandleSvnType.UnexpectedError, s.getError());
|
||||
this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
|
||||
return;
|
||||
}
|
||||
this.runagainButton_Click(sender, null);
|
||||
@ -462,9 +462,9 @@ namespace svnsync
|
||||
this.ShowInTaskbar = false;
|
||||
this.WindowState = FormWindowState.Minimized;
|
||||
s.AddFiles(l);
|
||||
if (s.IsError())
|
||||
if (s.IsError)
|
||||
{
|
||||
this.HandleSvn(HandleSvnType.UnexpectedError, s.getError());
|
||||
this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
|
||||
return;
|
||||
}
|
||||
this.runagainButton_Click(sender, null);
|
||||
@ -494,8 +494,8 @@ namespace svnsync
|
||||
this.ShowToolTip("Svn Sync Fehler", "Kein Argument für \"-d\" angegeben", ToolTipIcon.Error);
|
||||
return;
|
||||
}
|
||||
this.s = Svn.getInstance();
|
||||
this.s.setDirectory(this.c.GetArgumentData("-d"));
|
||||
this.s = Svn.Instance;
|
||||
this.s.SetDirectory(this.c.GetArgumentData("-d"));
|
||||
}
|
||||
|
||||
private void EventHandler_Resize(object sender, System.EventArgs e)
|
||||
|
@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace svnsync.Helpers {
|
||||
class Handles {
|
||||
public enum SvnType {
|
||||
namespace svnsync.Helpers
|
||||
{
|
||||
class Handles
|
||||
{
|
||||
public enum SvnType
|
||||
{
|
||||
NotInit,
|
||||
ToMutchChronRuns,
|
||||
HasVersionitedFiles,
|
||||
@ -14,7 +13,8 @@ namespace svnsync.Helpers {
|
||||
ExternDeletedFiles,
|
||||
LockedFile,
|
||||
}
|
||||
public enum FormType {
|
||||
public enum FormType
|
||||
{
|
||||
MuchCronJobs,
|
||||
UnversionFiles,
|
||||
Error,
|
||||
@ -24,11 +24,13 @@ namespace svnsync.Helpers {
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
public class SvnLockedException : System.Exception {
|
||||
public class SvnLockedException : System.Exception
|
||||
{
|
||||
public SvnLockedException() : base() { }
|
||||
public SvnLockedException(string message) : base(message) { }
|
||||
public SvnLockedException(string message, System.Exception inner) : base(message, inner) { }
|
||||
public SvnLockedException(String message) : base(message) { }
|
||||
public SvnLockedException(String message, System.Exception inner) : base(message, inner) { }
|
||||
protected SvnLockedException(System.Runtime.Serialization.SerializationInfo info,
|
||||
System.Runtime.Serialization.StreamingContext context) { }
|
||||
System.Runtime.Serialization.StreamingContext context)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace svnsync.Helpers
|
||||
{
|
||||
class StringHelper
|
||||
class StringHelper
|
||||
{
|
||||
public static String GetTimeStamp(DateTime dateTime)
|
||||
{
|
||||
public static string GetTimeStamp(DateTime dateTime)
|
||||
{
|
||||
String ret = "";
|
||||
ret += dateTime.Year.ToString().PadLeft(4, '0');
|
||||
ret += dateTime.Month.ToString().PadLeft(2, '0');
|
||||
ret += dateTime.Day.ToString().PadLeft(2, '0');
|
||||
ret += "-";
|
||||
ret += dateTime.Hour.ToString().PadLeft(2, '0');
|
||||
ret += dateTime.Minute.ToString().PadLeft(2, '0');
|
||||
ret += dateTime.Second.ToString().PadLeft(2, '0');
|
||||
return ret;
|
||||
}
|
||||
String ret = "";
|
||||
ret += dateTime.Year.ToString().PadLeft(4, '0');
|
||||
ret += dateTime.Month.ToString().PadLeft(2, '0');
|
||||
ret += dateTime.Day.ToString().PadLeft(2, '0');
|
||||
ret += "-";
|
||||
ret += dateTime.Hour.ToString().PadLeft(2, '0');
|
||||
ret += dateTime.Minute.ToString().PadLeft(2, '0');
|
||||
ret += dateTime.Second.ToString().PadLeft(2, '0');
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,84 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace svnsync.Libraries {
|
||||
class Svn {
|
||||
private string dir;
|
||||
private String dir;
|
||||
private Process p = new Process();
|
||||
private List<String> modified;
|
||||
private List<String> noversion;
|
||||
private List<String> wasdeleted;
|
||||
private List<String> added;
|
||||
private string SvnError = "";
|
||||
private string SvnOutput = "";
|
||||
private List<string> isdeleted;
|
||||
private List<string> external;
|
||||
private String SvnError = "";
|
||||
private String SvnOutput = "";
|
||||
private List<String> isdeleted;
|
||||
private List<String> external;
|
||||
private static Svn instances;
|
||||
|
||||
private Svn() { }
|
||||
|
||||
public void setDirectory(string dir) {
|
||||
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;
|
||||
this.p.StartInfo.FileName = "svn";
|
||||
this.p.StartInfo.WorkingDirectory = this.dir;
|
||||
this.p.StartInfo.CreateNoWindow = true;
|
||||
this.p.StartInfo.RedirectStandardOutput = true;
|
||||
this.p.StartInfo.RedirectStandardError = true;
|
||||
this.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)
|
||||
this.modified = new List<String>();
|
||||
this.noversion = new List<String>();
|
||||
this.wasdeleted = new List<String>();
|
||||
this.isdeleted = new List<String>();
|
||||
this.added = new List<String>();
|
||||
this.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!");
|
||||
}
|
||||
if (handles[0] == ' ') {
|
||||
if (handles[2] == 'L') {
|
||||
throw new Helpers.SvnLockedException("Datei: " + file + " ist gelockt!");
|
||||
}
|
||||
//Modifizierte Eigenschaft
|
||||
else if(handles[1] == 'M') {
|
||||
modified.Add(file);
|
||||
else if (handles[1] == 'M') {
|
||||
this.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);
|
||||
} else if (handles[0] == 'A') {
|
||||
this.added.Add(file);
|
||||
} else if (handles[0] == 'D') {
|
||||
this.isdeleted.Add(file);
|
||||
}
|
||||
// Modifizierte Datei
|
||||
else if(handles[0] == 'M') {
|
||||
modified.Add(file);
|
||||
} else if(handles[0] == 'R') {
|
||||
else if (handles[0] == 'M') {
|
||||
this.modified.Add(file);
|
||||
} else if (handles[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'");
|
||||
} else if(handles[0] == 'X') {
|
||||
external.Add(file);
|
||||
} else if(handles[0] == 'I') {
|
||||
} else if (handles[0] == 'X') {
|
||||
this.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] == '~') {
|
||||
} else if (handles[0] == '?') {
|
||||
this.noversion.Add(file);
|
||||
} else if (handles[0] == '!') {
|
||||
this.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] + "\"");
|
||||
@ -86,100 +86,155 @@ namespace svnsync.Libraries {
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsNotOnlyModified() {
|
||||
if(this.noversion.Count != 0)
|
||||
return true;
|
||||
if(this.wasdeleted.Count != 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void SetArgCheckIn(string message) {
|
||||
internal void SetArgCheckIn(String message) {
|
||||
String arg = "ci -m \"" + message + "\"";
|
||||
this.runner(arg);
|
||||
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) {
|
||||
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();
|
||||
this.p.StartInfo.Arguments = arg;
|
||||
this.p.Start();
|
||||
Int64 e_lenth = 0;
|
||||
while (!this.p.HasExited) {
|
||||
if(this.p.StandardOutput.Peek() != -1) {
|
||||
this.SvnOutput += this.p.StandardOutput.ReadLine();
|
||||
}
|
||||
this.p.StandardError.BaseStream.Flush();
|
||||
|
||||
if (this.p.StandardError.BaseStream.Length > e_lenth) {
|
||||
this.SvnError += this.p.StandardError.BaseStream.ReadByte();
|
||||
e_lenth++;
|
||||
}
|
||||
System.Threading.Thread.Sleep(10);
|
||||
}
|
||||
this.SvnOutput += p.StandardOutput.ReadToEnd();
|
||||
this.SvnError += p.StandardError.ReadToEnd();
|
||||
/*this.p.OutputDataReceived += this.P_OutputDataReceived;
|
||||
this.p.ErrorDataReceived += this.P_ErrorDataReceived;
|
||||
this.p.BeginOutputReadLine();
|
||||
this.p.BeginErrorReadLine();
|
||||
while(!this.p.HasExited) {
|
||||
this.p.StandardError.BaseStream.FlushAsync();
|
||||
this.p.StandardOutput.BaseStream.FlushAsync();
|
||||
System.Threading.Thread.Sleep(10);
|
||||
}
|
||||
this.p.WaitForExit();
|
||||
this.p.CancelOutputRead();
|
||||
this.p.CancelErrorRead();*/
|
||||
}
|
||||
|
||||
internal bool IsUncheckedFiles() {
|
||||
if(this.noversion.Count != 0)
|
||||
return true;
|
||||
return false;
|
||||
private void P_ErrorDataReceived(Object sender, DataReceivedEventArgs e) {
|
||||
if(e.Data != null) {
|
||||
this.SvnError += e.Data + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
private void P_OutputDataReceived(Object sender, DataReceivedEventArgs e) {
|
||||
this.SvnOutput += e.Data + "\n";
|
||||
}
|
||||
|
||||
internal void DeleteFiles(List<String> files) {
|
||||
String arg = "del";
|
||||
foreach(String item in files) {
|
||||
foreach (String item in files) {
|
||||
arg += " \"" + item + "\"";
|
||||
}
|
||||
this.runner(arg);
|
||||
}
|
||||
|
||||
internal List<String> getWasDeletedFiles() {
|
||||
return this.wasdeleted;
|
||||
}
|
||||
|
||||
internal List<String> getNoVersionFiles() {
|
||||
return this.noversion;
|
||||
this.Runner(arg);
|
||||
}
|
||||
|
||||
internal void DeleteFiles(List<System.Windows.Forms.TreeNode> l) {
|
||||
List<String> s = new List<string>();
|
||||
foreach(System.Windows.Forms.TreeNode item in 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<String> files) {
|
||||
String arg = "add";
|
||||
foreach (String item in files) {
|
||||
arg += " \"" + item + "\"";
|
||||
}
|
||||
this.Runner(arg);
|
||||
}
|
||||
|
||||
internal void AddFiles(List<System.Windows.Forms.TreeNode> l) {
|
||||
List<String> s = new List<string>();
|
||||
foreach(System.Windows.Forms.TreeNode item in 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");
|
||||
this.Runner("up");
|
||||
}
|
||||
|
||||
public static Svn getInstance() {
|
||||
if(instances == null) {
|
||||
instances = new Svn();
|
||||
public static Svn Instance {
|
||||
get {
|
||||
if (instances == null) {
|
||||
instances = new Svn();
|
||||
}
|
||||
return instances;
|
||||
}
|
||||
}
|
||||
|
||||
internal Boolean IsNotOnlyModified {
|
||||
get {
|
||||
if (this.noversion.Count != 0) {
|
||||
return true;
|
||||
}
|
||||
if (this.wasdeleted.Count != 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal Boolean IsUncheckedFiles {
|
||||
get {
|
||||
if (this.noversion.Count != 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal Boolean IsExternDeletedFiles {
|
||||
get {
|
||||
if (this.wasdeleted.Count != 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal List<String> WasDeletedFiles {
|
||||
get {
|
||||
return this.wasdeleted;
|
||||
}
|
||||
}
|
||||
|
||||
internal List<String> NoVersionFiles {
|
||||
get {
|
||||
return this.noversion;
|
||||
}
|
||||
}
|
||||
|
||||
internal Boolean IsError {
|
||||
get {
|
||||
if (this.SvnError != "") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal String Error {
|
||||
get {
|
||||
return this.SvnError;
|
||||
}
|
||||
return instances;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BlubbFish.Utils;
|
||||
using BlubbFish.Utils;
|
||||
using svnsync.Libraries;
|
||||
|
||||
namespace svnsync.Models
|
||||
{
|
||||
class ModelsTray : OwnModel<ModelsTray>
|
||||
class ModelsTray : OwnModel<ModelsTray>
|
||||
{
|
||||
private ModelsTray()
|
||||
{
|
||||
private ModelsTray()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
protected override void init()
|
||||
{
|
||||
this.Args = CmdArgs.getInstance();
|
||||
this.Svn = Svn.getInstance();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the Argument of the Program
|
||||
/// </summary>
|
||||
public CmdArgs Args { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Save a SVN
|
||||
/// </summary>
|
||||
public Svn Svn { get; private set; }
|
||||
this.Init();
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
this.Args = CmdArgs.Instance;
|
||||
this.Svn = Svn.Instance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the Argument of the Program
|
||||
/// </summary>
|
||||
public CmdArgs Args { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Save a SVN
|
||||
/// </summary>
|
||||
public Svn Svn { get; private set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,33 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using BlubbFish.Utils;
|
||||
using svnsync.Helpers;
|
||||
|
||||
namespace svnsync.Models {
|
||||
namespace svnsync.Models
|
||||
{
|
||||
public class ModelsWindow : OwnModel<ModelsWindow> {
|
||||
private InIReader networkfile;
|
||||
//private InIReader networkfile;
|
||||
private ModelsWindow() {
|
||||
this.init();
|
||||
this.Init();
|
||||
}
|
||||
|
||||
protected override void init() {
|
||||
protected override void Init() {
|
||||
|
||||
}
|
||||
|
||||
private string MessageValue = "";
|
||||
public string Message {
|
||||
get { return MessageValue; }
|
||||
set { MessageValue = value; this.update(); }
|
||||
private String MessageValue = "";
|
||||
public String Message {
|
||||
get { return this.MessageValue; }
|
||||
set { this.MessageValue = value; this.Update(); }
|
||||
}
|
||||
|
||||
private Handles.FormType FormTypeValue;
|
||||
internal Handles.FormType FormType {
|
||||
get { return FormTypeValue; }
|
||||
set { FormTypeValue = value; this.update(); }
|
||||
get { return this.FormTypeValue; }
|
||||
set { this.FormTypeValue = value; this.Update(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using svnsync.Controllers;
|
||||
using BlubbFish.Utils;
|
||||
@ -8,76 +7,82 @@ using svnsync.Libraries;
|
||||
|
||||
namespace svnsync
|
||||
{
|
||||
static class Program
|
||||
static class Program
|
||||
{
|
||||
private static Boolean LoopStarted = false;
|
||||
|
||||
/// <summary>
|
||||
/// Der Haupteinstiegspunkt für die Anwendung.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main(String[] args)
|
||||
{
|
||||
private static bool LoopStarted = false;
|
||||
|
||||
/// <summary>
|
||||
/// Der Haupteinstiegspunkt für die Anwendung.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main(string[] args) {
|
||||
if(!cmd(args)) {
|
||||
return;
|
||||
}
|
||||
FileMutex.Instance.setName(CmdArgs.getInstance().GetArgumentData("-d"));
|
||||
if(!FileMutex.Instance.create()) {
|
||||
return;
|
||||
}
|
||||
ControllersTray t = null;
|
||||
try {
|
||||
Svn.getInstance().setDirectory(CmdArgs.getInstance().GetArgumentData("-d"));
|
||||
t = new ControllersTray();
|
||||
t.StartLoop += t_StartLoop;
|
||||
t.execute();
|
||||
} catch(Exception e) {
|
||||
t.hideToolTip();
|
||||
string text = e.Message + "\n\n" + e.StackTrace;
|
||||
string title = "Exception in SVNSync: " + CmdArgs.getInstance().GetArgumentData("-d");
|
||||
System.Windows.Forms.MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
FileMutex.Instance.delete();
|
||||
return;
|
||||
}
|
||||
if(!CmdArgs.getInstance().HasArgumentType("-cron")) {
|
||||
t_StartLoop();
|
||||
}
|
||||
FileMutex.Instance.delete();
|
||||
if (!Cmd(args)) {
|
||||
return;
|
||||
/*Application.Run();*/
|
||||
/*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) {
|
||||
//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();
|
||||
}
|
||||
|
||||
FileMutex.Instance.SetName(CmdArgs.Instance.GetArgumentData("-d"));
|
||||
#if !DEBUG
|
||||
if (!FileMutex.Instance.Create()) {
|
||||
return;
|
||||
}
|
||||
|
||||
private static bool cmd(string[] args)
|
||||
{
|
||||
Dictionary<string, CmdArgs.VaildArguments> pargs = new Dictionary<string, CmdArgs.VaildArguments>();
|
||||
pargs.Add("-d", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Touple, true));
|
||||
pargs.Add("-cron", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single));
|
||||
pargs.Add("-autoadd", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single));
|
||||
pargs.Add("-autodelete", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single));
|
||||
CmdArgs.getInstance().setArguments(pargs, args);
|
||||
if (!CmdArgs.getInstance().HasAllRequiredArguments())
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show(CmdArgs.getInstance().getUsageList("syncsvn.exe:"), "Fehlende Argumente auf der Komandozeile", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
ControllersTray t = null;
|
||||
try {
|
||||
Svn.Instance.SetDirectory(CmdArgs.Instance.GetArgumentData("-d"));
|
||||
t = new ControllersTray();
|
||||
t.StartLoop += T_StartLoop;
|
||||
t.Execute();
|
||||
} catch (Exception e) {
|
||||
t.HideToolTip();
|
||||
String text = e.Message + "\n\n" + e.StackTrace;
|
||||
String title = "Exception in SVNSync: " + CmdArgs.Instance.GetArgumentData("-d");
|
||||
MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
FileMutex.Instance.Delete();
|
||||
return;
|
||||
}
|
||||
if (!CmdArgs.Instance.HasArgumentType("-cron")) {
|
||||
T_StartLoop();
|
||||
}
|
||||
FileMutex.Instance.Delete();
|
||||
return;
|
||||
/*Application.Run();*/
|
||||
/*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) {
|
||||
//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 Boolean Cmd(String[] args)
|
||||
{
|
||||
Dictionary<String, CmdArgs.VaildArguments> pargs = new Dictionary<String, CmdArgs.VaildArguments> {
|
||||
{ "-d", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Touple, true) },
|
||||
{ "-cron", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) },
|
||||
{ "-autoadd", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) },
|
||||
{ "-autodelete", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) },
|
||||
{ "-externals-own", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) },
|
||||
{ "-externals", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) }
|
||||
};
|
||||
CmdArgs.Instance.SetArguments(pargs, args);
|
||||
if (!CmdArgs.Instance.HasAllRequiredArguments()) {
|
||||
MessageBox.Show(CmdArgs.Instance.GetUsageList("syncsvn.exe:"), "Fehlende Argumente auf der Komandozeile", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ using System.Resources;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("BlubbFish")]
|
||||
[assembly: AssemblyProduct("SvnSync")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2012 - 03.03.2017")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2012 - 10.03.2017")]
|
||||
[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.3.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.3.0")]
|
||||
[assembly: AssemblyVersion("1.0.3.1")]
|
||||
[assembly: AssemblyFileVersion("1.0.3.1")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("de-DE")]
|
||||
|
@ -1,126 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BlubbFish.Utils;
|
||||
using BlubbFish.Utils;
|
||||
using svnsync.Models;
|
||||
using svnsync.Controllers;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using svnsync.Properties;
|
||||
using svnsync.Helpers;
|
||||
using System;
|
||||
|
||||
namespace svnsync.Views
|
||||
{
|
||||
class ViewsTray : OwnView
|
||||
{
|
||||
/// <summary>
|
||||
/// Model of the View
|
||||
/// </summary>
|
||||
public ModelsTray Model { get; private set; }
|
||||
private NotifyIcon trayicon;
|
||||
class ViewsTray : OwnView
|
||||
{
|
||||
/// <summary>
|
||||
/// Model of the View
|
||||
/// </summary>
|
||||
public ModelsTray Model { get; private set; }
|
||||
private NotifyIcon trayicon;
|
||||
|
||||
/// <summary>
|
||||
/// View of a Tray
|
||||
/// </summary>
|
||||
public ViewsTray()
|
||||
{
|
||||
this.init();
|
||||
this.Model = ModelsTray.Instance;
|
||||
this.Model.setObserver(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the Tray
|
||||
/// </summary>
|
||||
public override void update()
|
||||
{
|
||||
this.trayicon.Text = "SvnSync: " + this.Model.Args.GetArgumentData("-d");
|
||||
}
|
||||
|
||||
protected override void init()
|
||||
{
|
||||
this.trayicon = new NotifyIcon();
|
||||
this.trayicon.Visible = true;
|
||||
this.trayicon.Icon = new Icon(Resources.Icon, 40, 40);
|
||||
this.trayicon.Text = "SVN Sync Tool";
|
||||
this.trayicon.DoubleClick += ControllersTray.Click_Tray;
|
||||
this.trayicon.BalloonTipClicked += ControllersTray.Click_Ballon;
|
||||
this.trayicon.ContextMenuStrip = this.genMenu();
|
||||
}
|
||||
|
||||
private ContextMenuStrip genMenu() {
|
||||
ContextMenuStrip menu = new ContextMenuStrip();
|
||||
ToolStripMenuItem m1 = new ToolStripMenuItem("Öffnen");
|
||||
m1.Image = Resources.door_open;
|
||||
m1.Click += ControllersTray.Click_Tray;
|
||||
m1.Name = "Open";
|
||||
menu.Items.Add(m1);
|
||||
|
||||
ToolStripMenuItem m2 = new ToolStripMenuItem("Beenden");
|
||||
m2.Image = Resources.door_open;
|
||||
m2.Click += ControllersTray.Click_Quit;
|
||||
m2.Name = "Quit";
|
||||
menu.Items.Add(m2);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete the Tray
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
this.trayicon.Visible = false;
|
||||
Application.ExitThread();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show a Success Message
|
||||
/// </summary>
|
||||
public void ShowSuccess()
|
||||
{
|
||||
this.showBallonTooltip("Datensicherung Erfolgreich\n" + this.Model.Args.GetArgumentData("-d").Replace("\\\\", "\\"), ToolTipIcon.Info);
|
||||
}
|
||||
|
||||
private void showBallonTooltip(string text, ToolTipIcon toolTipIcon, string title = "SvnSync")
|
||||
{
|
||||
this.trayicon.BalloonTipIcon = toolTipIcon;
|
||||
this.trayicon.BalloonTipText = text;
|
||||
this.trayicon.BalloonTipTitle = title;
|
||||
this.trayicon.ShowBalloonTip(100);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show a Error Message.
|
||||
/// </summary>
|
||||
/// <param name="svnType"></param>
|
||||
/// <param name="p"></param>
|
||||
public void ShowError(Handles.SvnType svnType, string p) {
|
||||
switch(svnType) {
|
||||
case Handles.SvnType.NotInit:
|
||||
this.showBallonTooltip("Svn wurde noch nicht inizialisiert", ToolTipIcon.Error, "Svn Sync Fehler");
|
||||
break;
|
||||
case Handles.SvnType.ToMutchChronRuns:
|
||||
this.showBallonTooltip("Fehler im Cronjob, mehr als 10 Aufrufe!", ToolTipIcon.Error, "Svn Sync Fehler");
|
||||
break;
|
||||
case Handles.SvnType.HasVersionitedFiles:
|
||||
this.showBallonTooltip("Es sind unversionierte Dateien vorhanden (?)", ToolTipIcon.Info, "Svn Sync Fehler");
|
||||
break;
|
||||
case Handles.SvnType.UnexpectedError:
|
||||
this.showBallonTooltip("Es ist ein Unvorhersebarer Fehler aufgetreten: " + p, ToolTipIcon.Error, "Svn Sync Fehler");
|
||||
break;
|
||||
case Handles.SvnType.ExternDeletedFiles:
|
||||
this.showBallonTooltip("Es sind extern gelöschte Dateien vorhanden (!)", ToolTipIcon.Info, "Svn Sync Fehler");
|
||||
break;
|
||||
case Handles.SvnType.LockedFile:
|
||||
this.showBallonTooltip("Es sind blokierte Dateien vorhanden (L)", ToolTipIcon.Info, "Svn Sync Fehler");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
internal void HideToolTip() {
|
||||
this.trayicon.Visible = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// View of a Tray
|
||||
/// </summary>
|
||||
public ViewsTray() {
|
||||
this.Init();
|
||||
this.Model = ModelsTray.Instance;
|
||||
this.Model.SetObserver(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the Tray
|
||||
/// </summary>
|
||||
public override void Update() {
|
||||
this.trayicon.Text = "SvnSync: " + ((this.Model.Args.GetArgumentData("-d").Length <= 54) ? this.Model.Args.GetArgumentData("-d") : "..."+this.Model.Args.GetArgumentData("-d").Substring(this.Model.Args.GetArgumentData("-d").Length - 51));
|
||||
}
|
||||
|
||||
protected override void Init() {
|
||||
this.trayicon = new NotifyIcon() {
|
||||
Visible = true,
|
||||
Icon = new Icon(Resources.Icon, 40, 40),
|
||||
Text = "SVN Sync Tool"
|
||||
};
|
||||
this.trayicon.DoubleClick += ControllersTray.Click_Tray;
|
||||
this.trayicon.BalloonTipClicked += ControllersTray.Click_Ballon;
|
||||
this.trayicon.ContextMenuStrip = this.GenMenu();
|
||||
}
|
||||
|
||||
private ContextMenuStrip GenMenu() {
|
||||
ContextMenuStrip menu = new ContextMenuStrip();
|
||||
ToolStripMenuItem m1 = new ToolStripMenuItem("Öffnen") {
|
||||
Image = Resources.door_open,
|
||||
Name = "Open"
|
||||
};
|
||||
m1.Click += ControllersTray.Click_Tray;
|
||||
menu.Items.Add(m1);
|
||||
|
||||
ToolStripMenuItem m2 = new ToolStripMenuItem("Beenden") {
|
||||
Image = Resources.door_open,
|
||||
Name = "Quit"
|
||||
};
|
||||
m2.Click += ControllersTray.Click_Quit;
|
||||
menu.Items.Add(m2);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete the Tray
|
||||
/// </summary>
|
||||
public override void Dispose() {
|
||||
this.trayicon.Visible = false;
|
||||
Application.ExitThread();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show a Success Message
|
||||
/// </summary>
|
||||
public void ShowSuccess() {
|
||||
this.ShowBallonTooltip("Datensicherung Erfolgreich\n" + this.Model.Args.GetArgumentData("-d").Replace("\\\\", "\\"), ToolTipIcon.Info);
|
||||
}
|
||||
|
||||
private void ShowBallonTooltip(System.String text, ToolTipIcon toolTipIcon, System.String title = "SvnSync") {
|
||||
this.trayicon.BalloonTipIcon = toolTipIcon;
|
||||
this.trayicon.BalloonTipText = text;
|
||||
this.trayicon.BalloonTipTitle = title;
|
||||
this.trayicon.ShowBalloonTip(100);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show a Error Message.
|
||||
/// </summary>
|
||||
/// <param name="svnType"></param>
|
||||
/// <param name="message"></param>
|
||||
public void ShowError(Handles.SvnType svnType, System.String message) {
|
||||
switch (svnType) {
|
||||
case Handles.SvnType.NotInit:
|
||||
this.ShowBallonTooltip("Svn wurde noch nicht inizialisiert", ToolTipIcon.Error, "Svn Sync Fehler");
|
||||
break;
|
||||
case Handles.SvnType.ToMutchChronRuns:
|
||||
this.ShowBallonTooltip("Fehler im Cronjob, mehr als 10 Aufrufe!", ToolTipIcon.Error, "Svn Sync Fehler");
|
||||
break;
|
||||
case Handles.SvnType.HasVersionitedFiles:
|
||||
this.ShowBallonTooltip("Es sind unversionierte Dateien vorhanden (?)", ToolTipIcon.Info, "Svn Sync Fehler");
|
||||
break;
|
||||
case Handles.SvnType.UnexpectedError:
|
||||
this.ShowBallonTooltip("Es ist ein Unvorhersebarer Fehler aufgetreten: " + message, ToolTipIcon.Error, "Svn Sync Fehler");
|
||||
break;
|
||||
case Handles.SvnType.ExternDeletedFiles:
|
||||
this.ShowBallonTooltip("Es sind extern gelöschte Dateien vorhanden (!)", ToolTipIcon.Info, "Svn Sync Fehler");
|
||||
break;
|
||||
case Handles.SvnType.LockedFile:
|
||||
this.ShowBallonTooltip("Es sind blokierte Dateien vorhanden (L)", ToolTipIcon.Info, "Svn Sync Fehler");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
internal void HideToolTip() {
|
||||
this.trayicon.Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using BlubbFish.Utils;
|
||||
using svnsync.Models;
|
||||
|
||||
namespace svnsync.Views {
|
||||
public class ViewsWindow : OwnView {
|
||||
namespace svnsync.Views
|
||||
{
|
||||
public class ViewsWindow : OwnView
|
||||
{
|
||||
private ViewsWindowForm form;
|
||||
public ViewsWindow() {
|
||||
public ViewsWindow()
|
||||
{
|
||||
this.form = new ViewsWindowForm();
|
||||
this.init();
|
||||
this.Model.setObserver(this);
|
||||
this.Init();
|
||||
this.Model.SetObserver(this);
|
||||
}
|
||||
|
||||
public override void update() {
|
||||
public override void Update()
|
||||
{
|
||||
this.form.UpdateForm();
|
||||
}
|
||||
|
||||
protected override void init() {
|
||||
protected override void Init()
|
||||
{
|
||||
this.Model = ModelsWindow.Instance;
|
||||
this.form.SetModel(this.Model);
|
||||
this.form.Show();
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
public override void Dispose()
|
||||
{
|
||||
this.form.BeginInvoke((Action)(() => {
|
||||
this.form.Dispose();
|
||||
}));
|
||||
|
15
svnsync/Views/ViewsWindowForm.Designer.cs
generated
15
svnsync/Views/ViewsWindowForm.Designer.cs
generated
@ -30,6 +30,7 @@
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.messageBox = new System.Windows.Forms.RichTextBox();
|
||||
this.opencmd = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
@ -50,11 +51,22 @@
|
||||
this.messageBox.TabIndex = 2;
|
||||
this.messageBox.Text = "";
|
||||
//
|
||||
// opencmd
|
||||
//
|
||||
this.opencmd.Location = new System.Drawing.Point(15, 227);
|
||||
this.opencmd.Name = "opencmd";
|
||||
this.opencmd.Size = new System.Drawing.Size(75, 23);
|
||||
this.opencmd.TabIndex = 3;
|
||||
this.opencmd.Text = "Open CMD";
|
||||
this.opencmd.UseVisualStyleBackColor = true;
|
||||
this.opencmd.Visible = false;
|
||||
//
|
||||
// ViewsWindowForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(464, 262);
|
||||
this.Controls.Add(this.opencmd);
|
||||
this.Controls.Add(this.messageBox);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Name = "ViewsWindowForm";
|
||||
@ -68,5 +80,6 @@
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.RichTextBox messageBox;
|
||||
}
|
||||
private System.Windows.Forms.Button opencmd;
|
||||
}
|
||||
}
|
@ -10,21 +10,26 @@ using System.Windows.Forms;
|
||||
using svnsync.Models;
|
||||
using svnsync.Controllers;
|
||||
|
||||
namespace svnsync.Views {
|
||||
public partial class ViewsWindowForm : Form {
|
||||
namespace svnsync.Views
|
||||
{
|
||||
public partial class ViewsWindowForm : Form
|
||||
{
|
||||
private ModelsWindow model;
|
||||
public ViewsWindowForm() {
|
||||
public ViewsWindowForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.FormClosed += ControllersWindow.FormClosed;
|
||||
}
|
||||
|
||||
public void UpdateForm() {
|
||||
public void UpdateForm()
|
||||
{
|
||||
this.BeginInvoke((Action)(() => {
|
||||
this.messageBox.Text = this.model.Message;
|
||||
}));
|
||||
}
|
||||
|
||||
public void SetModel(ModelsWindow window) {
|
||||
public void SetModel(ModelsWindow window)
|
||||
{
|
||||
this.model = window;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
@ -42,7 +42,7 @@
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<StartArguments>-d "E:\Eigene Dateien\Doc%27s\Basteleien" -cron -autoadd -autodelete</StartArguments>
|
||||
<StartArguments>-d "E:\\Eigene Dateien\\Dokumente\\Visual Studio 2017\\Projects" -cron -autoadd -autodelete -externals-own</StartArguments>
|
||||
<RemoteDebugEnabled>false</RemoteDebugEnabled>
|
||||
<StartAction>Project</StartAction>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<StartArguments>-d "D:\\Doc%27s\\Studium\\" -cron -autoadd -autodelete</StartArguments>
|
||||
<StartArguments>-d "E:\\Eigene Dateien\\Dokumente\\Visual Studio 2017\\Projects" -cron -autoadd -autodelete -externals-own</StartArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PublishUrlHistory>veröffentlichen\</PublishUrlHistory>
|
||||
|
Loading…
Reference in New Issue
Block a user