Implementing better localhost support and Id verification
This commit is contained in:
parent
2748d3c1fe
commit
1b8a85cd94
1
.gitignore
vendored
1
.gitignore
vendored
@ -0,0 +1 @@
|
||||
backups
|
BIN
.vs/BuechermarktClient/DesignTimeBuild/.dtbcache
Normal file
BIN
.vs/BuechermarktClient/DesignTimeBuild/.dtbcache
Normal file
Binary file not shown.
Binary file not shown.
BIN
.vs/BuechermarktClient/v15/Server/sqlite3/storage.ide
Normal file
BIN
.vs/BuechermarktClient/v15/Server/sqlite3/storage.ide
Normal file
Binary file not shown.
BIN
.vs/BuechermarktClient/v15/Server/sqlite3/storage.ide-shm
Normal file
BIN
.vs/BuechermarktClient/v15/Server/sqlite3/storage.ide-shm
Normal file
Binary file not shown.
BIN
.vs/BuechermarktClient/v15/Server/sqlite3/storage.ide-wal
Normal file
BIN
.vs/BuechermarktClient/v15/Server/sqlite3/storage.ide-wal
Normal file
Binary file not shown.
@ -9,6 +9,10 @@
|
||||
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="8fb06cb64d019a17" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.8.1.0" newVersion="2.8.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
@ -76,7 +76,7 @@ namespace BuechermarktClient
|
||||
rowBook["Title"] = "Unbekannt";
|
||||
}
|
||||
rowBook["LabelId"] = book.LabelId;
|
||||
rowBook["Price"] = book.State == Models.BookState.BackToStudent ? (object)DBNull.Value : book.Price;
|
||||
rowBook["Price"] = book.State == Models.BookState.BackToStudent || book.State == Models.BookState.InStock ? (object)DBNull.Value : book.Price;
|
||||
total += !rowBook.IsNull("Price") ? rowBook.Field<decimal>("Price") : 0m;
|
||||
tableBooks.Rows.Add(rowBook);
|
||||
books++;
|
||||
|
@ -9,6 +9,7 @@ using System.Windows.Data;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace BuechermarktClient
|
||||
{
|
||||
@ -51,9 +52,9 @@ namespace BuechermarktClient
|
||||
}
|
||||
set
|
||||
{
|
||||
if(value != Book.LabelId)
|
||||
if(value.ToUpper() != Book.LabelId)
|
||||
{
|
||||
Book.LabelId = value;
|
||||
Book.LabelId = value.ToUpper();
|
||||
OnPropertyChanged("LabelId");
|
||||
}
|
||||
}
|
||||
@ -247,7 +248,16 @@ namespace BuechermarktClient
|
||||
StateComboBox.ItemsSource = StatesList;
|
||||
}
|
||||
|
||||
private Regex lableid_regex = new Regex("^[A-Z0-9 ]*$");
|
||||
|
||||
private void Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!lableid_regex.IsMatch(Book.LabelId))
|
||||
{
|
||||
MessageBox.Show("Die ID stimmt nicht mit den Richtlinien überein!!!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (New)
|
||||
{
|
||||
@ -264,7 +274,8 @@ namespace BuechermarktClient
|
||||
Book.State = BookState.InStock;
|
||||
OnPropertyChanged(string.Empty);
|
||||
return;
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
}
|
||||
catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@ -284,13 +295,15 @@ namespace BuechermarktClient
|
||||
.Set(b => b.LabelId, Book.LabelId));
|
||||
Close();
|
||||
return;
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
}
|
||||
catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Delete_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
@ -34,6 +34,9 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DocumentFormat.OpenXml, Version=2.8.1.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DocumentFormat.OpenXml.2.8.1\lib\net40\DocumentFormat.OpenXml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MongoDB.Bson, Version=2.4.4.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MongoDB.Bson.2.4.4\lib\net45\MongoDB.Bson.dll</HintPath>
|
||||
</Reference>
|
||||
@ -56,6 +59,7 @@
|
||||
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
@ -172,9 +176,26 @@
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Content Include="MSOfficeUtils.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Vorlage.docx">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="libeay32.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="mongodump.exe">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="ssleay32.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -49,7 +49,9 @@ namespace BuechermarktClient
|
||||
string message = Encoding.ASCII.GetString(bytes);
|
||||
if(message == ServerIdentifier)
|
||||
{
|
||||
MainWindow.MongoHost = ip.Address.ToString();
|
||||
var cip = ip.Address.ToString();
|
||||
if (IsLocalIpAddress(cip)) cip = "127.0.0.1";
|
||||
MainWindow.MongoHost = cip;
|
||||
Dispatcher.BeginInvoke(new Action(delegate () {
|
||||
Close();
|
||||
}));
|
||||
@ -60,5 +62,29 @@ namespace BuechermarktClient
|
||||
ListenForServer();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsLocalIpAddress(string host)
|
||||
{
|
||||
try
|
||||
{ // get host IP addresses
|
||||
IPAddress[] hostIPs = Dns.GetHostAddresses(host);
|
||||
// get local IP addresses
|
||||
IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
|
||||
|
||||
// test if any host IP equals to any local IP or to localhost
|
||||
foreach (IPAddress hostIP in hostIPs)
|
||||
{
|
||||
// is localhost
|
||||
if (IPAddress.IsLoopback(hostIP)) return true;
|
||||
// is local address
|
||||
foreach (IPAddress localIP in localIPs)
|
||||
{
|
||||
if (hostIP.Equals(localIP)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
BuechermarktClient/MSOfficeUtils.dll
Normal file
BIN
BuechermarktClient/MSOfficeUtils.dll
Normal file
Binary file not shown.
@ -30,9 +30,6 @@ namespace BuechermarktClient
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private Dictionary<char, char> _Dictionary;
|
||||
private Dictionary<char, char> _ReverseDictionary;
|
||||
|
||||
private string _AddField;
|
||||
public string AddField
|
||||
{
|
||||
@ -43,9 +40,10 @@ namespace BuechermarktClient
|
||||
|
||||
set
|
||||
{
|
||||
if(value != _AddField)
|
||||
string val = value.ToUpper();
|
||||
if(val != _AddField)
|
||||
{
|
||||
_AddField = value;
|
||||
_AddField = val;
|
||||
OnPropertyChanged("AddField");
|
||||
}
|
||||
}
|
||||
@ -107,51 +105,6 @@ namespace BuechermarktClient
|
||||
DataContext = this;
|
||||
_SellBooks = new ObservableCollection<SellBook>();
|
||||
_SellBooks.CollectionChanged += listChanged;
|
||||
_Dictionary = new Dictionary<char, char>();
|
||||
_Dictionary.Add('a', 'A');
|
||||
_Dictionary.Add('b', 'B');
|
||||
_Dictionary.Add('c', 'C');
|
||||
_Dictionary.Add('d', 'D');
|
||||
_Dictionary.Add('e', 'E');
|
||||
_Dictionary.Add('f', 'F');
|
||||
_Dictionary.Add('g', 'G');
|
||||
_Dictionary.Add('h', 'H');
|
||||
_Dictionary.Add('i', 'I');
|
||||
_Dictionary.Add('j', 'J');
|
||||
_Dictionary.Add('k', 'K');
|
||||
_Dictionary.Add('l', 'L');
|
||||
_Dictionary.Add('m', 'M');
|
||||
_Dictionary.Add('n', 'N');
|
||||
_Dictionary.Add('o', 'O');
|
||||
_Dictionary.Add('p', 'P');
|
||||
_Dictionary.Add('q', 'Q');
|
||||
_Dictionary.Add('r', 'R');
|
||||
_Dictionary.Add('s', 'S');
|
||||
_Dictionary.Add('t', 'T');
|
||||
_Dictionary.Add('u', 'U');
|
||||
_Dictionary.Add('v', 'V');
|
||||
_Dictionary.Add('w', 'W');
|
||||
_Dictionary.Add('x', 'X');
|
||||
_Dictionary.Add('y', 'Y');
|
||||
_Dictionary.Add('z', 'Z');
|
||||
_Dictionary.Add('1', '!');
|
||||
_Dictionary.Add('2', '"');
|
||||
_Dictionary.Add('3', '§');
|
||||
_Dictionary.Add('4', '$');
|
||||
_Dictionary.Add('5', '%');
|
||||
_Dictionary.Add('6', '&');
|
||||
_Dictionary.Add('7', '/');
|
||||
_Dictionary.Add('8', '(');
|
||||
_Dictionary.Add('9', ')');
|
||||
_Dictionary.Add('0', '=');
|
||||
_Dictionary.Add('ß', '?');
|
||||
_Dictionary.Add('-', '_');
|
||||
|
||||
_ReverseDictionary = new Dictionary<char, char>();
|
||||
foreach(var entry in _Dictionary)
|
||||
{
|
||||
_ReverseDictionary.Add(entry.Value, entry.Key);
|
||||
}
|
||||
}
|
||||
|
||||
private void Add_Click(object sender, RoutedEventArgs e)
|
||||
@ -160,19 +113,16 @@ namespace BuechermarktClient
|
||||
{
|
||||
try
|
||||
{
|
||||
var reverse = ReverseString(AddField);
|
||||
var case1 = ReverseUnderscore(AddField);
|
||||
var case2 = ReverseUnderscore(reverse);
|
||||
foreach (var s in SellBooks)
|
||||
{
|
||||
if(s.LabelId == AddField || s.LabelId == reverse || s.LabelId == case1 ||s.LabelId == case2)
|
||||
if(s.LabelId == AddField)
|
||||
{
|
||||
MessageBox.Show("Das Buch ist bereits in der Liste");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var item = MainWindow.BookCollection.FindSync<Models.Book>(b => b.LabelId == AddField || b.LabelId == reverse || b.LabelId == case1 || b.LabelId == case2).FirstOrDefault();
|
||||
var item = MainWindow.BookCollection.FindSync<Models.Book>(b => b.LabelId == AddField).FirstOrDefault();
|
||||
if (item == null)
|
||||
{
|
||||
MessageBox.Show("Das Buch ist nicht vorhanden bitte überprüfen");
|
||||
@ -245,35 +195,6 @@ namespace BuechermarktClient
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string ReverseString(string s)
|
||||
{
|
||||
var res = String.Empty;
|
||||
foreach(var i in s)
|
||||
{
|
||||
char v;
|
||||
if(_Dictionary.TryGetValue(i, out v) || _ReverseDictionary.TryGetValue(i, out v))
|
||||
{
|
||||
res += v;
|
||||
} else {
|
||||
MessageBox.Show(string.Format("Das Label enthält ungültige Zeichen ( {0} ), {1}", i, s));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private string ReverseUnderscore(string s)
|
||||
{
|
||||
if(s.IndexOf("_") >= 0 || s.IndexOf("-") >= 0)
|
||||
{
|
||||
s = s.Replace("_", "?").Replace("-", "ß");
|
||||
} else
|
||||
{
|
||||
s = s.Replace("?", "_").Replace("ß", "-");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
public class SellBook
|
||||
|
BIN
BuechermarktClient/Vorlage/Vorlage.docx
Normal file
BIN
BuechermarktClient/Vorlage/Vorlage.docx
Normal file
Binary file not shown.
BIN
BuechermarktClient/Vorlage/VorlageReleasebackup.docx
Normal file
BIN
BuechermarktClient/Vorlage/VorlageReleasebackup.docx
Normal file
Binary file not shown.
Binary file not shown.
@ -9,6 +9,10 @@
|
||||
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="8fb06cb64d019a17" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.8.1.0" newVersion="2.8.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
308746
BuechermarktClient/bin/Debug/DocumentFormat.OpenXml.xml
Normal file
308746
BuechermarktClient/bin/Debug/DocumentFormat.OpenXml.xml
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user