Skip to content

Commit c02374b

Browse files
committed
Correctif bug list robot
1 parent 065aa13 commit c02374b

File tree

15 files changed

+73
-19
lines changed

15 files changed

+73
-19
lines changed

Backup/BackupController.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public class BackupController
2222

2323
public UserInfo userInfo;
2424

25-
public int timeoutBackup { get; set; } = 300;
26-
2725
public bool backupProgress { get; set; }
2826

2927
public BackupCreator backupCreator { get; set; }
@@ -95,7 +93,7 @@ public void StartBackup()
9593

9694
var d = (DateTime.Now - date).TotalSeconds;
9795

98-
if (d > timeoutBackup)
96+
if (d > robotparam.TimeoutBackup)
9997
{
10098
Console.WriteLine($"Timeout backup");
10199
controller?.Dispose();

Program.cs

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using System.Reflection.Emit;
1717
using AbbBackup.Backup;
1818
using System.Diagnostics;
19+
using System.Net.NetworkInformation;
1920

2021
namespace AbbBackup
2122
{
@@ -46,13 +47,12 @@ static private bool ScanReseau(NetworkScanner scanner, int timeScan)
4647

4748
static void Main(string[] args)
4849
{
49-
5050
//Pour quitter l'appli
5151
bool Cancel = false;
5252
Console.CancelKeyPress += delegate (object sender, ConsoleCancelEventArgs e)
5353
{
5454
Console.WriteLine($"=>Quit");
55-
e.Cancel = true
55+
e.Cancel = true;
5656
Cancel = true;
5757
};
5858

@@ -142,7 +142,7 @@ static void Main(string[] args)
142142
Process.Start("explorer.exe", Directory.GetParent(confFile).FullName);
143143
}
144144

145-
catch (Exception ex)
145+
catch (Exception ex)
146146
{
147147
Console.WriteLine(ex.Message);
148148
}
@@ -186,23 +186,62 @@ static void Main(string[] args)
186186
robotsParams = RobotParamsList.LoadToXml(defaultConfFile);
187187

188188
Console.WriteLine($"Chargement du fichier de configuration : {defaultConfFile}");
189-
189+
190190
}
191191

192192
Console.WriteLine($"Répertoire de sauvegarde par défaut : {robotsParams.DefaultFolderBackup}");
193-
194193

195-
//Recherche des robots présent sur le réseau
196194
scanner = new NetworkScanner();
197-
while (!ScanReseau(scanner, robotsParams.TimeScan) & Cancel == false)
195+
196+
List<ControllerInfo> controllerInfos = new List<ControllerInfo>();
197+
198+
//Recherche des robots présent dans le fichier
199+
foreach (var robot in robotsParams)
198200
{
199-
Console.WriteLine($"No robot detected, retry");
200-
Thread.Sleep(1000);
201+
try
202+
{
203+
Console.WriteLine($"Ping : {robot.IP}");
204+
205+
Ping pingSender = new Ping();
206+
PingReply reply = pingSender.Send(robot.IP);
207+
208+
if (reply.Status != IPStatus.Success)
209+
{
210+
Console.WriteLine($"Ping : { robot.IP} -> no response )");
211+
}
212+
else
213+
{
214+
Console.WriteLine($"Ping : {robot.IP} -> response OK ");
215+
}
216+
217+
Console.WriteLine($"Identification du robot : {robot.IP}");
218+
if (scanner.TryFind(robot.Id, robotsParams.TimeScan, robotsParams.RetryScan, out ControllerInfo cf))
219+
{
220+
Console.WriteLine($"Identification du robot : {robot.IP} | {cf.Name} | {cf.VersionName}");
221+
controllerInfos.Add(cf);
222+
}
223+
else
224+
{
225+
Console.WriteLine(robot.NameFileBackup + "-" + robot.Id + "-" + "no found");
226+
}
227+
228+
}
229+
catch (Exception ex)
230+
{
231+
Console.WriteLine(ex.Message);
232+
}
201233
}
202234

235+
//Recherche des robots présent sur le réseau
236+
//while (!ScanReseau(scanner, robotsParams.TimeScan) & Cancel == false)
237+
//{
238+
// Console.WriteLine($"No robot detected, retry");
239+
// Thread.Sleep(1000);
240+
//}
241+
203242

204243
//Liste les robot présent sur le réseau et dans le fichier de configuration
205-
var robotsasauvegarder = from controller in scanner.Controllers
244+
var robotsasauvegarder = from controller in controllerInfos
206245
join paramController in robotsParams on controller.SystemId equals paramController.Id into gj
207246
from Params in gj.DefaultIfEmpty()
208247
select new
@@ -243,6 +282,8 @@ from Params in gj.DefaultIfEmpty()
243282
continue;
244283
}
245284

285+
if (!Directory.Exists(param.FolderBackup)) param.FolderBackup = robotsParams.DefaultFolderBackup;
286+
246287
BackupController backupController = backupCreator.Factory(c.controller, param);
247288
backupController.BackupStart += (p) => Console.WriteLine($"{p.robotparam.NameFileBackup} - Start backup");
248289
backupController.BackupCompleted += (p, e) => Console.WriteLine($"{p.robotparam.NameFileBackup} - Backup completed -> {p.robotparam.FolderBackup}");

Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
3333
// en utilisant '*', comme indiqué ci-dessous :
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.0.0.0")]
35+
[assembly: AssemblyVersion("2.0.0.1")]
3636
[assembly: AssemblyFileVersion("2.0.0.0")]

RobotParamsList.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public static RobotParams FromXml(XElement xElement)
4040
{
4141
RobotParams p = new RobotParams();
4242

43-
xElement = xElement.Element(nameof(RobotParams));
43+
try {
44+
4445
p.Id = new Guid(xElement.Element(nameof(Guid))?.Value);
4546
p.IP = xElement.Element(nameof(IP))?.Value;
4647
p.User = xElement.Element(nameof(User))?.Value;
@@ -49,6 +50,13 @@ public static RobotParams FromXml(XElement xElement)
4950
p.NameFileBackup = xElement.Element(nameof(NameFileBackup))?.Value;
5051
p.TimeoutBackup = int.Parse(xElement.Element(nameof(TimeoutBackup))?.Value);
5152
p.DelayDeleteFile = int.Parse(xElement.Element(nameof(DelayDeleteFile))?.Value);
53+
54+
}catch (Exception ex)
55+
{
56+
Console.WriteLine(ex.Message);
57+
return null;
58+
}
59+
5260
return p;
5361

5462
}
@@ -69,6 +77,7 @@ public class RobotParamsList : List<RobotParams>
6977
public int DefaultDelayDeleteFile { get; set; } = 360;
7078

7179
public int TimeScan { get; set; } = 5000;
80+
public int RetryScan { get; set; } = 5;
7281

7382
public RobotParams GetDefaultRobotParams()
7483
{
@@ -99,6 +108,7 @@ public RobotParams GetDefaultRobotParams(ControllerInfo controllerInfo)
99108

100109
public new bool Add(RobotParams robot)
101110
{
111+
102112
if (this.Any(r => r.Id == robot.Id))
103113
{
104114
return false;
@@ -117,6 +127,7 @@ public XElement ToXmlElement()
117127
XElement xElementTimeOut = new XElement(nameof(DefaultTimeoutBackup), DefaultTimeoutBackup);
118128
XElement xElementDelayDeleteFile = new XElement(nameof(DefaultDelayDeleteFile), DefaultDelayDeleteFile);
119129
XElement xElementTimeScan = new XElement(nameof(TimeScan), TimeScan);
130+
XElement xElementRetryScan = new XElement(nameof(RetryScan), RetryScan);
120131

121132
XElement xElementRobot = new XElement(nameof(RobotParamsList));
122133

@@ -130,6 +141,7 @@ public XElement ToXmlElement()
130141
xmlRoot.Add(xElementTimeOut);
131142
xmlRoot.Add(xElementDelayDeleteFile);
132143
xmlRoot.Add(xElementTimeScan);
144+
xmlRoot.Add(xElementRetryScan);
133145
xmlRoot.Add(xElementRobot);
134146

135147

@@ -144,12 +156,12 @@ public static RobotParamsList FromXml(XElement xElement)
144156
p.DefaultTimeoutBackup = int.Parse(xElement?.Element(nameof(DefaultTimeoutBackup))?.Value);
145157
p.DefaultDelayDeleteFile = int.Parse(xElement?.Element(nameof(DefaultDelayDeleteFile))?.Value);
146158
p.TimeScan = int.Parse(xElement?.Element(nameof(TimeScan))?.Value);
147-
159+
p.RetryScan = int.Parse(xElement?.Element(nameof(RetryScan))?.Value);
148160
xElement = xElement.Element(nameof(RobotParamsList));
149161

150-
foreach(XElement xElement1 in xElement.Elements())
162+
foreach(XElement xElementRobotParams in xElement.Elements())
151163
{
152-
p.Add(RobotParams.FromXml(xElement));
164+
p.Add(RobotParams.FromXml(xElementRobotParams));
153165
}
154166

155167
return p;

bin/AddRobot/AbbBackup.exe

0 Bytes
Binary file not shown.

bin/Debug/AbbBackup.exe

1 KB
Binary file not shown.

bin/Debug/AbbBackup.pdb

0 Bytes
Binary file not shown.

bin/Release/AbbBackup.exe

1 KB
Binary file not shown.

bin/Release/AbbBackup.pdb

2 KB
Binary file not shown.

obj/AddRobot/AbbBackup.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)