nm-l2tp[4393] <debug> uses default --bus-name "org.freedesktop.NetworkManager.l2tp"
nm-l2tp[4393] <info> ipsec enable flag: yes
** Message: Check port 1701
** Message: Can't bind to port 1701
nm-l2tp[4393] <warn> L2TP port 1701 is busy, using ephemeral.
connection
id : "VPN-\321\201\320\276\320\265\320\264\320\270\320\275\320\265\320\275\320\270\320\265 1" (s)
uuid : "9736eb99-3963-4d91-8782-6613b9aa2359" (s)
interface-name : NULL (sd)
type : "vpn" (s)
permissions : ["user:xasya:"] (s)
autoconnect : FALSE (s)
autoconnect-priority : 0 (sd)
autoconnect-retries : -1 (sd)
timestamp : 0 (sd)
read-only : FALSE (sd)
zone : NULL (sd)
master : NULL (sd)
slave-type : NULL (sd)
autoconnect-slaves : ((NMSettingConnectionAutoconnectSlaves) NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT) (sd)
secondaries : NULL (sd)
gateway-ping-timeout : 0 (sd)
metered : ((NMMetered) NM_METERED_UNKNOWN) (sd)
lldp : -1 (sd)
mdns : -1 (sd)
stable-id : NULL (sd)
auth-retries : -1 (sd)
ipv6
method : "auto" (s)
dns : [] (s)
dns-search : [] (s)
dns-options : NULL (sd)
dns-priority : 0 (sd)
addresses : ((GPtrArray*) 0x6376621a2740) (s)
gateway : NULL (sd)
routes : ((GPtrArray*) 0x6376621a26c0) (s)
route-metric : -1 (sd)
route-table : 0 (sd)
ignore-auto-routes : FALSE (sd)
ignore-auto-dns : FALSE (sd)
dhcp-hostname : NULL (sd)
dhcp-send-hostname : TRUE (sd)
never-default : FALSE (sd)
may-fail : TRUE (sd)
dad-timeout : -1 (sd)
dhcp-timeout : 0 (sd)
ip6-privacy : ((NMSettingIP6ConfigPrivacy) NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED) (s)
addr-gen-mode : 1 (sd)
token : NULL (sd)
proxy
method : 0 (sd)
browser-only : FALSE (sd)
pac-url : NULL (sd)
pac-script : NULL (sd)
vpn
service-type : "org.freedesktop.NetworkManager.l2tp" (s)
user-name : "xasya" (s)
persistent : FALSE (sd)
data : ((GHashTable*) 0x637662186b60) (s)
secrets : ((GHashTable*) 0x637662186b60) (s)
timeout : 0 (sd)
ipv4
method : "auto" (s)
dns : [] (s)
dns-search : [] (s)
dns-options : NULL (sd)
dns-priority : 0 (sd)
addresses : ((GPtrArray*) 0x6376621a2540) (s)
gateway : NULL (sd)
routes : ((GPtrArray*) 0x6376621a2520) (s)
route-metric : -1 (sd)
route-table : 0 (sd)
ignore-auto-routes : FALSE (sd)
ignore-auto-dns : FALSE (sd)
dhcp-hostname : NULL (sd)
dhcp-send-hostname : TRUE (sd)
never-default : FALSE (sd)
may-fail : TRUE (sd)
dad-timeout : -1 (sd)
dhcp-timeout : 0 (sd)
dhcp-client-id : NULL (sd)
dhcp-fqdn : NULL (sd)
nm-l2tp[4393] <info> starting ipsec
Stopping strongSwan IPsec failed: starter is not running
Starting strongSwan 5.5.1 IPsec [starter]...
Loading config setup
Loading conn '9736eb99-3963-4d91-8782-6613b9aa2359'
found netkey IPsec stack
nm-l2tp[4393] <info> Spawned ipsec up script with PID 4462.
initiating Main Mode IKE_SA 9736eb99-3963-4d91-8782-6613b9aa2359[1] to 82.151.114.56
generating ID_PROT request 0 [ SA V V V V V ]
sending packet: from 172.172.172.81[500] to 82.151.114.56[500] (240 bytes)
sending retransmit 1 of request message ID 0, seq 1
sending packet: from 172.172.172.81[500] to 82.151.114.56[500] (240 bytes)
nm-l2tp[4393] <warn> Timeout trying to establish IPsec connection
nm-l2tp[4393] <info> Terminating ipsec script with PID 4462.
Stopping strongSwan IPsec...
destroying IKE_SA in state CONNECTING without notification
establishing connection '9736eb99-3963-4d91-8782-6613b9aa2359' failed
nm-l2tp[4393] <warn> Could not establish IPsec tunnel.
(nm-l2tp-service:4393): GLib-GIO-CRITICAL **: g_dbus_method_invocation_take_error: assertion 'error != NULL' failed
nm-l2tp[4393] <info> starting ipsec
Stopping strongSwan IPsec failed: starter is not running
Starting strongSwan 5.5.1 IPsec [starter]...
Loading config setup
Loading conn '9736eb99-3963-4d91-8782-6613b9aa2359'
found netkey IPsec stack
nm-l2tp[4393] <info> Spawned ipsec up script with PID 4462.
initiating Main Mode IKE_SA 9736eb99-3963-4d91-8782-6613b9aa2359[1] to 82.151.114.56
generating ID_PROT request 0 [ SA V V V V V ]
sending packet: from 172.172.172.81[500] to 82.151.114.56[500] (240 bytes)
sending retransmit 1 of request message ID 0, seq 1
sending packet: from 172.172.172.81[500] to 82.151.114.56[500] (240 bytes)
nm-l2tp[4393] <warn> Timeout trying to establish IPsec connection
nm-l2tp[4393] <info> Terminating ipsec script with PID 4462.
Stopping strongSwan IPsec...
destroying IKE_SA in state CONNECTING without notification
establishing connection '9736eb99-3963-4d91-8782-6613b9aa2359' failed
nm-l2tp[4393] <warn> Could not establish IPsec tunnel.
(nm-l2tp-service:4393): GLib-GIO-CRITICAL **: g_dbus_method_invocation_take_error: assertion 'error != NULL' failed
DataContext db;
public Form1(IServiceProvider serviceProvider, ILogger<Form1> logger, IDbContextFactory<DataContext> dbFactory, ISynchService synchService, BarCodeScanner barCodeScanner, ICashRegisterService cashService)
{
db = dbFactory.CreateDbContext();
_cashService = cashService;
this.serviceProvider = serviceProvider;
_logger = logger;
DataContext _db;
public FormMenu(IConfiguration configuration, IDbContextFactory<DataContext> dbFactory)
{
serverName = configuration.GetSection("serverName").Value;
idShop = Convert.ToInt32(configuration.GetSection("idShop").Value);
cashierName = configuration.GetSection("cashierName").Value;
cashierInn = configuration.GetSection("cashierInn").Value;
_configuration = configuration;
_db = dbFactory.CreateDbContext();
InitializeComponent();
}
var fr = serviceProvider.GetRequiredService<FormMenu>();
fr.ShowDialog();
//После закрытие второй формы перечитываем список товаров, который поменялся
Task.Run(async () =>
{
GoodList = await db.Goods.Where(g=>g.IsDeleted==false).ToListAsync();
});
Task.Run(async () =>
{
bool statusSuccess = true;
string messageRequest = "";
try
{
var str = await new HttpClient().GetAsync($"{serverName}/api/Goodssynchnew/{idShop}").Result.Content.ReadAsStringAsync();
List<GoodSynchDataModel> goods = JsonSerializer.Deserialize<List<GoodSynchDataModel>>(str);
foreach (var good in goods)
{
var goodDb = _db.Goods.Include(g=>g.BarCodes).Where(g => g.Uuid == good.Uuid).FirstOrDefault();
if (goodDb == null)
{
var newgood = new Good
{
Uuid = good.Uuid,
Name = good.Name,
Article = good.Name,
Unit = good.Unit,
Price = good.Price,
SpecialType=good.SpecialType,
VPackage=good.VPackage,
IsDeleted=good.IsDeleted
};
_db.Goods.Add(newgood);
//добавление штрих кодов
foreach (string barcode in good.Barcodes)
_db.BarCodes.Add(new BarCode
{
Good = newgood,
Code = barcode
});
}
else
{
goodDb.Name = good.Name;
goodDb.Unit = good.Unit;
goodDb.Price = good.Price;
goodDb.SpecialType = good.SpecialType;
goodDb.VPackage = good.VPackage;
goodDb.IsDeleted = good.IsDeleted;
//добавление новых или измененных штрих кодов
foreach (string barcode in good.Barcodes)
if (goodDb.BarCodes.Count(b => b.Code == barcode) == 0)
_db.BarCodes.Add(new BarCode { Good = goodDb, Code = barcode });
//Удаление не зарегестрированных на сервере штрихкодов
foreach (var barcodeDb in goodDb.BarCodes)
if (good.Barcodes.Count(b => b == barcodeDb.Code) == 0)
_db.BarCodes.Remove(barcodeDb);
}
};
await _db.SaveChangesAsync();
//System.Threading.Thread.Sleep(TimeSpan.FromSeconds(20));
messageRequest = "Перезыпаустите программу, для работы по новым ценам";
}
catch (SystemException ex)
{
statusSuccess = false;
messageRequest = ex.Message;
}
var action = new Action(() =>
{
button1.BackColor = statusSuccess ? Color.LightGreen : Color.LightPink;
errorTextBox.Text = messageRequest;
});
Invoke(action);
});
public static void ConfigureService(ServiceCollection services)
{
var builder = new ConfigurationBuilder()
.SetBasePath(Path.Combine(AppContext.BaseDirectory))
.AddJsonFile("appsettings.json", optional: true);
services
.AddDbContextFactory<DataContext>(opt=>opt.UseSqlite("Data Source=CustomerDB.db;"))
.AddSingleton<BarCodeScanner>()
.AddSingleton<ICashRegisterService, AtolService>()
.AddLogging(configure => { configure.AddSerilog(); configure.SetMinimumLevel(LogLevel.Error | LogLevel.Warning); })
.AddScoped<ISynchService, SynchService>()
.AddSingleton<ISynchBackgroundService, SynchBackgroundService>()
.AddTransient<IConfiguration>(_ => builder.Build())
.AddScoped<Form1>()
.AddScoped<FormMenu>()
//.AddTransient<PayForm>()
.AddTransient<FormPaymentCombine>()
.AddTransient<FormWriteOf>()
.AddTransient<FormArrival>()
.AddTransient<FormStocktaking>()
.AddTransient<FormCashMoney>()
.AddTransient<FormNewGood>()
.AddTransient<FormFindGood>()
.AddTransient<FormHistory>()
;
}
await host.RunAsync();