Skip to content

Commit 97f44db

Browse files
committed
added support for miniserver newer generation
1 parent d8b04e3 commit 97f44db

11 files changed

+68
-47
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Changelog
22

3-
## Known issues
3+
## v1.0.2.0
44

5-
* FTP connection seems to not be possible with Miniserver Gen 2
5+
* Added: Support Miniserver newer generation for FTP download/upload by @mr-manuel
66

77
## v1.0.1.1
88

MiniserverForm.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MiniserverForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ private void UploadButton_Click(object sender, EventArgs e)
355355
// Launch project link
356356
private void githubLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
357357
{
358-
System.Diagnostics.Process.Start("https://github.com/ddeml/LoxStatEdit");
358+
System.Diagnostics.Process.Start("https://github.com/mr-manuel/Loxone_LoxStatEdit");
359359
}
360360

361361
#endregion

MsFileInfo.cs

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Globalization;
55
using System.IO;
66
using System.Net;
7+
using System.Text.RegularExpressions;
78
using System.Windows.Forms;
89

910
namespace LoxStatEdit
@@ -18,38 +19,40 @@ public static IList<MsFileInfo> Load(Uri uri)
1819
{
1920
try
2021
{
21-
// TO DO: Does not connect with Miniserver Gen 2. Probably because of TLS
2222
var list = new List<MsFileInfo>();
2323
var ftpWebRequest = (FtpWebRequest)FtpWebRequest.Create(uri);
24-
ftpWebRequest.Method = WebRequestMethods.Ftp.ListDirectory;
24+
ftpWebRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
2525
using (var response = ftpWebRequest.GetResponse())
2626
using (var ftpStream = response.GetResponseStream())
2727
using (var streamReader = new StreamReader(ftpStream))
2828
while (!streamReader.EndOfStream)
2929
{
30-
// Hacky but works fair enough in our particular use case (I hope...)
3130
var line = streamReader.ReadLine();
32-
Debug.WriteLine(line);
33-
int datePos = line.IndexOf(' ', 24);
34-
int size;
35-
if (!int.TryParse(line.Substring(18, datePos - 18), out size))
36-
size = -1;
37-
datePos++;
38-
int fileNamePos;
39-
DateTime dateTime;
40-
if (DateTime.TryParseExact(line.Substring(datePos, 12), "MMM dd HH:mm",
41-
CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
42-
fileNamePos = datePos + 13;
43-
else if (DateTime.TryParseExact(line.Substring(datePos, 11), "MMM dd yyyy",
44-
CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
45-
fileNamePos = datePos + 12;
46-
else fileNamePos = line.LastIndexOf(' ') + 1;
47-
list.Add(new MsFileInfo
31+
32+
// string pattern that matches Miniserver Gen 1 and Miniserver Gen 2
33+
string pattern = @"[-rwx]{10}\s+[0-9]+\s+[0-9]+\s+[0-9]+\s+([0-9]+)\s+([A-Za-z]{3}\s+[0-9]{1,2}\s+[0-9:]+)\s+([0-9a-z_\-\.]+)";
34+
var result = Regex.Match(line, pattern);
35+
36+
if (result.Success)
4837
{
49-
FileName = line.Substring(fileNamePos),
50-
Date = dateTime,
51-
Size = size,
52-
});
38+
var groups = result.Groups;
39+
int.TryParse(groups[1].Value, out int size);
40+
41+
DateTime dateTime;
42+
if (DateTime.TryParseExact(groups[2].Value.Replace(" ", " "), "MMM dd HH:mm",
43+
CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) ;
44+
else if (DateTime.TryParseExact(groups[2].Value.Replace(" ", " "), "MMM dd yyyy",
45+
CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) ;
46+
47+
var fileName = groups[3].Value;
48+
49+
list.Add(new MsFileInfo
50+
{
51+
FileName = fileName,
52+
Date = dateTime,
53+
Size = size,
54+
});
55+
}
5356
}
5457
return list;
5558
}
@@ -64,23 +67,7 @@ public static IList<MsFileInfo> Load(Uri uri)
6467
}
6568
catch (Exception ex)
6669
{
67-
if (ex.Source == "mscorlib" && ex.HResult == -2146233086)
68-
{
69-
MessageBox.Show(
70-
"The connection to a Miniserver newer generation (with TLS) is " +
71-
"not working yet. Use a third party FTP client (e.g. Filezilla, " +
72-
"Windows Explorer, ...) to download and upload the statistics.\n\n" +
73-
"Feel free to contribute to this project and help us to fix this. " +
74-
"You find the GitHub link at the bottom of the main window.",
75-
"Error - IList",
76-
MessageBoxButtons.OK,
77-
MessageBoxIcon.Error
78-
);
79-
}
80-
else
81-
{
82-
MessageBox.Show(ex.Message, "Error - IList", MessageBoxButtons.OK, MessageBoxIcon.Error);
83-
}
70+
MessageBox.Show(ex.Message, "Error - IList", MessageBoxButtons.OK, MessageBoxIcon.Error);
8471

8572
return null;
8673
}

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.0.1.1")]
35-
[assembly: AssemblyFileVersion("1.0.1.1")]
34+
[assembly: AssemblyVersion("1.0.2.0")]
35+
[assembly: AssemblyFileVersion("1.0.2.0")]

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Loxone Statistic Editor
2+
3+
<small>GitHub repository: [mr-manuel/Loxone_LoxStatEdit](https://github.com/mr-manuel/Loxone_LoxStatEdit)</small>
4+
5+
<small>LoxWiki: [LoxStatsEditor - Statistikdaten bearbeiten](https://loxwiki.atlassian.net/wiki/spaces/LOX/pages/1520762996/LoxStatsEditor+-+Statistikdaten+bearbeiten)</small>
6+
7+
<small>LoxForum: [Loxone Statistik Editor ](https://www.loxforum.com/forum/faqs-tutorials-howto-s/21686-loxone-statistik-editor)</small>
8+
9+
### Disclaimer
10+
11+
This app was forked from [ddeml/LoxStatEdit](https://github.com/ddeml/LoxStatEdit). A huge thanks for creating this app!
12+
13+
I updates this app for myself. I'm not responsible, if you damage something using this app.
14+
15+
16+
## Supporting/Sponsoring this project
17+
18+
You like the project and you want to support me?
19+
20+
[<img src="https://github.md0.eu/uploads/donate-button.svg" height="50">](https://www.paypal.com/donate/?hosted_button_id=3NEVZBDM5KABW)
21+
22+
23+
### Purpose
24+
25+
This app was created to be able to correct spikes in the Loxone Statistics. You can download, edit and upload directly in the app.
26+
27+
28+
### Screenshots
29+
30+
![LoxStatEdit - 1](/screenshots/loxstatedit-1.png)
31+
![LoxStatEdit - 2](/screenshots/loxstatedit-2.png)
32+
![LoxStatEdit - 3](/screenshots/loxstatedit-3.png)
33+
![LoxStatEdit - 4](/screenshots/loxstatedit-4.png)
34+
![LoxStatEdit - 5](/screenshots/loxstatedit-5.png)

screenshots/loxstatedit-1.png

20.9 KB
Loading

screenshots/loxstatedit-2.png

106 KB
Loading

screenshots/loxstatedit-3.png

101 KB
Loading

screenshots/loxstatedit-4.png

62 KB
Loading

0 commit comments

Comments
 (0)