v1.3.2
This commit is contained in:
parent
d77c510423
commit
1756d32c79
|
@ -41,9 +41,11 @@ namespace PortProxyGUI.Data
|
|||
public void Add<T>(T obj) where T : class
|
||||
{
|
||||
var newid = Guid.NewGuid().ToString();
|
||||
|
||||
if (obj is Rule rule)
|
||||
{
|
||||
Sql($"INSERT INTO Rules (Id, Type, ListenOn, ListenPort, ConnectTo, ConnectPort, Comment, `Group`) VALUES ({newid}, {rule.Type}, {rule.ListenOn}, {rule.ListenPort}, {rule.ConnectTo}, {rule.ConnectPort}, {rule.Comment ?? ""}, {rule.Group ?? ""});");
|
||||
rule.Id = newid;
|
||||
}
|
||||
else throw new NotSupportedException($"Adding {obj.GetType().FullName} is not supported.");
|
||||
}
|
||||
public void AddRange<T>(IEnumerable<T> objs) where T : class
|
||||
|
@ -53,7 +55,10 @@ namespace PortProxyGUI.Data
|
|||
|
||||
public void Update<T>(T obj) where T : class
|
||||
{
|
||||
if (obj is Rule rule) Sql($"UPDATE Rules SET Type={rule.Type}, ListenOn={rule.ListenOn}, ListenPort={rule.ListenPort}, ConnectTo={rule.ConnectTo}, ConnectPort={rule.ConnectPort} WHERE Id={rule.Id};");
|
||||
if (obj is Rule rule)
|
||||
{
|
||||
Sql($"UPDATE Rules SET Type={rule.Type}, ListenOn={rule.ListenOn}, ListenPort={rule.ListenPort}, ConnectTo={rule.ConnectTo}, ConnectPort={rule.ConnectPort} WHERE Id={rule.Id};");
|
||||
}
|
||||
else throw new NotSupportedException($"Updating {obj.GetType().FullName} is not supported.");
|
||||
}
|
||||
public void UpdateRange<T>(IEnumerable<T> objs) where T : class
|
||||
|
@ -63,7 +68,10 @@ namespace PortProxyGUI.Data
|
|||
|
||||
public void Remove<T>(T obj) where T : class
|
||||
{
|
||||
if (obj is Rule rule) Sql($"DELETE FROM Rules WHERE Id={rule.Id};");
|
||||
if (obj is Rule rule)
|
||||
{
|
||||
Sql($"DELETE FROM Rules WHERE Id={rule.Id};");
|
||||
}
|
||||
else throw new NotSupportedException($"Removing {obj.GetType().FullName} is not supported.");
|
||||
}
|
||||
public void RemoveRange<T>(IEnumerable<T> objs) where T : class
|
||||
|
|
|
@ -182,7 +182,12 @@ namespace PortProxyGUI
|
|||
}
|
||||
|
||||
var pendingAdds = proxies.Where(x => x.Valid && x.Id == null);
|
||||
var pendingUpdates = proxies.Where(x => x.Valid && x.Id != null && !x.Equals(rules.First(r => r.Id == x.Id)));
|
||||
var pendingUpdates =
|
||||
from proxy in proxies
|
||||
let exsist = rules.FirstOrDefault(r => r.Id == proxy.Id)
|
||||
where exsist is not null
|
||||
where proxy.Valid && proxy.Id is not null
|
||||
select proxy;
|
||||
|
||||
Program.SqliteDbScope.AddRange(pendingAdds);
|
||||
Program.SqliteDbScope.UpdateRange(pendingUpdates);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<PackageTags>portproxy TCP/IP redirector</PackageTags>
|
||||
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
|
||||
<Copyright>Copyright © nstandard.net 2020</Copyright>
|
||||
<Version>1.3.1</Version>
|
||||
<Version>1.3.2</Version>
|
||||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||
<ApplicationDefaultFont>Microsoft Sans Serif, 8pt</ApplicationDefaultFont>
|
||||
<AssemblyName>PPGUI</AssemblyName>
|
||||
|
|
Loading…
Reference in New Issue