Commit 1e8a0356 authored by Phat Nguyen's avatar Phat Nguyen

Add project

parents
This diff is collapsed.
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ii]nstalls/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
This diff is collapsed.
using System;
using System.Linq;
using System.Text;
namespace sl.LIBs_AccessDevice.Board
{
public static class Utility
{
public static string DecToHex(this int decString)
{
return decString.ToString("X");
}
public static int HexToDec(this string hexString)
{
return int.Parse(hexString, System.Globalization.NumberStyles.HexNumber);
}
public static string getExactly0203(this string hexString)
{
return hexString.Substring((hexString.IndexOf("02") == -1 ? 0 : hexString.IndexOf("02")),
hexString.LastIndexOf("03") == -1 ? (hexString.Length - (hexString.IndexOf("02") == -1 ? 0 : hexString.IndexOf("02"))) : ((hexString.LastIndexOf("03") - (hexString.IndexOf("02") == -1 ? 0 : hexString.IndexOf("02")) + 2)));
}
public static byte[] ToByteArrayV2(this string hexString)
{
return Enumerable.Range(0, hexString.Length)
.Where(x => x % 2 == 0)
.Select(x => Convert.ToByte(hexString.Substring(x, 2), 16))
.ToArray();
}
public static char[] hexs2chars(this string hexString)
{
string[] hexList = hexString.Split('-');
StringBuilder stringBuilder = new StringBuilder();
foreach (string hex in hexList)
{
char[] binArr = Convert.ToString(Convert.ToInt32(hex, 16), 2).PadLeft(8, '0').ToArray();
Array.Reverse(binArr);
stringBuilder.Append(String.Join("", binArr));
}
return stringBuilder.ToString().ToArray();
}
}
}
using sl.LIBs_AccessDevice.Board;
using sl.LIBs_AccessDevice.Logger;
using System;
using System.Diagnostics;
using System.Reflection;
using System.Text;
namespace sl.LIBs_AccessDevice
{
public class BoardControl
{
public string COMPort { get; set; }
public const string DeviceId = "BoardId";
BoardGateway driverBoard;
static readonly object _object = new object();
public BoardControl(string comPort)
{
COMPort = comPort;
driverBoard = BoardGateway.Instance;
driverBoard.Init(comPort);
}
public int GetVersion(byte board, out string version)
{
lock (_object)
{
return GetVersionCommand(board, out version);
}
}
public int GetVersionCommand(int board, out string version)
{
version = "";
string hexResult = driverBoard.CommandVersion(board);
if (hexResult == "NULL")
return 1;
string[] strArray = hexResult.Split('-');
if (strArray.Length < 5) return 1;
if (int.Parse(strArray[4].ToString(), System.Globalization.NumberStyles.HexNumber) == 0)
{
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i <= int.Parse(strArray[5].ToString(), System.Globalization.NumberStyles.HexNumber); i++)
{
stringBuilder.Append(String.Join("-", strArray[i + 6]));
}
version = Encoding.ASCII.GetString(stringBuilder.ToString().ToByteArrayV2());
return 0;
}
return 1;
}
/// <summary>
/// Open a box in specify board
/// 3.4 Open box
/// </summary>
/// <param name="idBoard"></param>
/// <param name="idBox"></param>
/// <returns></returns>
public int OpenBox(byte idBoard, byte idBox)
{
lock (_object)
{
var result = OpenBoxCommand(idBoard,idBox);
return result;
}
}
public int OpenBoxCommand(int board, int hardware)
{
if (hardware - 1 < 0) return 1;
string hexResult = driverBoard.CommandOpen(board, hardware);
if (hexResult == "NULL")
return 1;
string[] strArray = hexResult.Split('-');
if (strArray.Length < 5) return 1;
if (int.Parse(strArray[4].ToString(), System.Globalization.NumberStyles.HexNumber) == 0)
{
Debug.WriteLine($"Open Locker {board} - {hardware}");
return 0;
}
return 1;
}
public int CheckDoorsCommnad(int board, out Array openStateBoard)
{
char[] lstDoor = { };
openStateBoard = lstDoor;
string hexResult = driverBoard.CommandCheckDoors(board);
if (hexResult == "NULL")
return 1;
string[] strArray = hexResult.Split('-');
if (strArray.Length < 5) return 1;
if (int.Parse(strArray[4].ToString(), System.Globalization.NumberStyles.HexNumber) == 0)
{
lstDoor = (strArray[6] + "-" + strArray[7] + "-" + strArray[8] + "-" + strArray[9]).ToString().hexs2chars();
openStateBoard = lstDoor;
}
return 0;
}
/// <summary>
/// Get infomation about board
/// output: Byte Array
/// 3.7 Get the statue of door (door is open or close)
/// </summary>
/// <param name="idBoard"></param>
/// <param name="resultOut"></param>
/// <returns></returns>
public int GetOpenState(byte idBoard, out Array openStateBoard)
{
lock (_object)
{
return CheckDoorsCommnad(idBoard, out openStateBoard);
}
}
/// <summary>
/// 3.10 Get the statue needed
/// GetArticleState:
/// GetOpenState:
/// GetWarningState:
/// GetPowerState:
/// </summary>
/// <param name="idBoard"></param>
/// <returns></returns>
public int GetNeedStateBoardOneTime(byte idBoard, out Array needState)
{
needState = null;
int resultOut = -1;
try
{
lock (_object)
{
resultOut = NeededStageCommand(idBoard,out needState);
return resultOut;
}
}
catch (Exception)
{
return resultOut;
}
}
//[[0,0],[1,1],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]]
public int NeededStageCommand(int board, out Array openStateBoard)
{
openStateBoard = new int[32,2];
char[] lstItem, lstDoor = { };
string hexResult = driverBoard.CommandNeededStage(board, NeededData.N_ITEM_DOOR_MAINTANCEBOX);
if (hexResult == "NULL")
return 1;
string[] strArray = hexResult.Split('-');
if (strArray.Length < 5) return 1;
if (int.Parse(strArray[4].ToString(), System.Globalization.NumberStyles.HexNumber) == 0)
{
lstItem = (strArray[6] + "-" + strArray[7] + "-" + strArray[8] + "-" + strArray[9]).ToString().hexs2chars();
lstDoor = (strArray[10] + "-" + strArray[11] + "-" + strArray[12] + "-" + strArray[13]).ToString().hexs2chars();
for (int i = 0; i < 32; i++)
{
int items_status = int.Parse(lstItem[i].ToString());
int locker_status = int.Parse(lstDoor[i].ToString());
openStateBoard.SetValue(items_status, i, 0);
openStateBoard.SetValue(locker_status, i, 1);
}
}
return 0;
}
}
}
using System.IO;
using System.Text;
using System;
namespace sl.LIBs_AccessDevice.Logger
{
public static class FileLogger
{
public static void WriteLog(string Message, string logFile = "RAW")
{
string path = AppDomain.CurrentDomain.BaseDirectory + "\\log\\" + DateTime.Now.ToString("yyyy - MM") + "\\" + DateTime.Now.ToString("yyyy - MM - dd");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string filepath = AppDomain.CurrentDomain.BaseDirectory + "\\log\\" + DateTime.Now.ToString("yyyy - MM") + "\\" + DateTime.Now.ToString("yyyy - MM - dd") +
"\\Log - " + logFile + ".txt";
FileWriteString(filepath, String.Format("{0} {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), Message), true);
}
public static void WriteReport(string Message, string logFile = "REPORT")
{
string path = AppDomain.CurrentDomain.BaseDirectory + "\\report";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string filepath = AppDomain.CurrentDomain.BaseDirectory + "\\report\\" + "\\Report - " + logFile + ".txt";
FileWriteString(filepath, String.Format("{0} {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), Message), true);
}
private static bool FileWriteString(string pFileFullName, string pWriteData, bool pCRLF = true)
{
try
{
byte[] bWriteData;
//FileStream writer = new FileStream(pFileFullName, FileMode.OpenOrCreate | FileMode.Append, FileAccess.ReadWrite, FileShare.ReadWrite);
FileStream writer = new FileStream(pFileFullName, FileMode.OpenOrCreate | FileMode.Append, FileAccess.Write, FileShare.Write);
//writer.Seek(writer.Length, SeekOrigin.End);
UTF8Encoding utf8Encoding = new UTF8Encoding(true, true);
bWriteData = utf8Encoding.GetBytes(pWriteData);
writer.Write(bWriteData, 0, bWriteData.Length);
if (pCRLF == true)
{
byte bCR = (byte)'\r';
byte bLF = (byte)'\n';
writer.WriteByte(bCR);
writer.WriteByte(bLF);
}
writer.Close();
writer.Dispose();
return true;
}
catch (Exception)
{
return false;
}
}
}
public class LogConfig
{
public const string FILE_Raw = "RAW";
public const string FILE_Board = "BOARD";
public const string FILE_Temp = "TEMPERATURE";
public const string FILE_Error = "ERROR";
public const string FILE_Realtime = "REALTIME";
public const string FILE_Debug = "DEBUG";
public const string FILE_Data = "DATA";
public const string FILE_Report = "REPORT";
}
}
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("sl.LIBs_AccessDevice")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("sl.LIBs_AccessDevice")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("eb79308b-cc4d-4b17-9e97-60fa31c54638")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Data.Sqlite.Core" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Configuration" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Configuration.Abstractions" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Configuration.Binder" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Configuration.CommandLine" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Configuration.EnvironmentVariables" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Configuration.FileExtensions" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Configuration.Json" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Configuration.UserSecrets" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.FileProviders.Abstractions" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.FileProviders.Physical" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.FileSystemGlobbing" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Hosting" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Hosting.Abstractions" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging.Configuration" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging.Console" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging.Debug" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging.EventLog" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging.EventSource" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Options" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Options.ConfigurationExtensions" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Primitives" version="6.0.0" targetFramework="net472" />
<package id="RestSharp" version="106.11.7" targetFramework="net472" />
<package id="SQLitePCLRaw.core" version="2.0.6" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="6.0.0" targetFramework="net472" />
<package id="System.IO" version="4.3.0" targetFramework="net472" />
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="net472" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="6.0.0" targetFramework="net472" />
<package id="System.Text.Json" version="6.0.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>
\ No newline at end of file
This diff is collapsed.
namespace sl.LIBs_Data.Connection
{
public class Connection
{
}
}
using Microsoft.EntityFrameworkCore;
using sl.LIBs_Data.Imports;
using sl.LIBs_Entity.Enities;
namespace sl.LIBs_Data.Data
{
public class DbServiceContext : DbContext
{
public DbServiceContext(DbContextOptions options) : base(options)
{
Database.Migrate();
this.ImportSettingData();
}
public DbSet<Locker> Lockers { get; set; }
public DbSet<Terminal> Terminals { get; set; }
public DbSet<Webhook> Webhooks { get; set; }
public DbSet<ActivityLog> ActivityLogs { get; set; }
public DbSet<LockerLog> LockerLogs { get; set; }
public DbSet<Setting> Settings { get; set; }
public DbSet<User> Users { get; set; }
}
}
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
namespace sl.LIBs_Data.Data
{
public class DbServiceContextFactory : IDesignTimeDbContextFactory<DbServiceContext>
{
public DbServiceContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<DbServiceContext>();
optionsBuilder.UseSqlite("Data Source=smartLocker.db");
return new DbServiceContext(optionsBuilder.Options);
}
}
}

_/\__
---==/ \\
___ ___ |. \|\
| __|| __| | ) \\\
| _| | _| \_/ | //|\\
|___||_| / \\\/\\
TOPIC
about_EntityFrameworkCore
SHORT DESCRIPTION
Provides information about the Entity Framework Core Package Manager Console Tools.
LONG DESCRIPTION
This topic describes the Entity Framework Core Package Manager Console Tools. See https://docs.efproject.net for
information on Entity Framework Core.
The following Entity Framework Core commands are available.
Cmdlet Description
-------------------------- ---------------------------------------------------
Add-Migration Adds a new migration.
Drop-Database Drops the database.
Get-DbContext Gets information about a DbContext type.
Remove-Migration Removes the last migration.
Scaffold-DbContext Scaffolds a DbContext and entity types for a database.
Script-DbContext Generates a SQL script from the current DbContext.
Script-Migration Generates a SQL script from migrations.
Update-Database Updates the database to a specified migration.
SEE ALSO
Add-Migration
Drop-Database
Get-DbContext
Remove-Migration
Scaffold-DbContext
Script-DbContext
Script-Migration
Update-Database
using Microsoft.EntityFrameworkCore;
namespace sl.LIBs_Data.Data
{
public static class EntityExtensions
{
public static void Clear<T>(this DbSet<T> dbSet) where T : class
{
dbSet.RemoveRange(dbSet);
}
}
}
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using sl.LIBs_Data.Data;
using sl.LIBs_Entity.Enities;
namespace sl.LIBs_Data.Imports
{
public static partial class SettingImport
{
public static void ImportSettingData(this DbServiceContext dbService)
{
if (!dbService.Settings.Any())
{
var filePath = "Imports/settings.json";
if (File.Exists(filePath))
{
var settingsData = File.ReadAllText(filePath);
var settings = JsonConvert.DeserializeObject<List<Setting>>(settingsData);
dbService.Settings.AddRange(settings);
dbService.SaveChanges();
}
}
}
}
}
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using sl.LIBs_Data.Data;
namespace sl.LIBs_Data.Migrations
{
[DbContext(typeof(DbServiceContext))]
[Migration("20210514033717_InitDBContext")]
partial class InitDBContext
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.6");
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<bool>("IsPried")
.HasColumnType("INTEGER");
b.Property<int>("door_front_status")
.HasColumnType("INTEGER");
b.Property<int>("door_rear_status")
.HasColumnType("INTEGER");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<int>("items_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_hardware_address")
.HasColumnType("INTEGER");
b.Property<string>("locker_name")
.HasColumnType("TEXT");
b.Property<int>("locker_rear_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_rear_hardware_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_size")
.HasColumnType("INTEGER");
b.Property<int>("locker_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_type")
.HasColumnType("INTEGER");
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("typeName")
.HasColumnType("TEXT");
b.HasKey("locker_id");
b.HasIndex("terminal_id");
b.ToTable("Lockers");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("comport")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("terminal_name")
.HasColumnType("TEXT");
b.HasKey("terminal_id");
b.ToTable("Terminals");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.HasOne("sl.LIBs_Entity.Enities.Terminal", null)
.WithMany("lockers")
.HasForeignKey("terminal_id");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Navigation("lockers");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace sl.LIBs_Data.Migrations
{
public partial class InitDBContext : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Terminals",
columns: table => new
{
terminal_id = table.Column<string>(type: "TEXT", nullable: false),
terminal_name = table.Column<string>(type: "TEXT", nullable: true),
comport = table.Column<string>(type: "TEXT", nullable: true),
is_del = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Terminals", x => x.terminal_id);
});
migrationBuilder.CreateTable(
name: "Lockers",
columns: table => new
{
locker_id = table.Column<string>(type: "TEXT", nullable: false),
locker_name = table.Column<string>(type: "TEXT", nullable: true),
terminal_id = table.Column<string>(type: "TEXT", nullable: true),
locker_status = table.Column<int>(type: "INTEGER", nullable: false),
locker_front_hardware_address = table.Column<int>(type: "INTEGER", nullable: false),
locker_front_board_address = table.Column<int>(type: "INTEGER", nullable: false),
locker_rear_hardware_address = table.Column<int>(type: "INTEGER", nullable: false),
locker_rear_board_address = table.Column<int>(type: "INTEGER", nullable: false),
locker_size = table.Column<int>(type: "INTEGER", nullable: false),
is_del = table.Column<bool>(type: "INTEGER", nullable: false),
locker_type = table.Column<int>(type: "INTEGER", nullable: false),
IsPried = table.Column<bool>(type: "INTEGER", nullable: false),
door_front_status = table.Column<int>(type: "INTEGER", nullable: false),
door_rear_status = table.Column<int>(type: "INTEGER", nullable: false),
items_status = table.Column<int>(type: "INTEGER", nullable: false),
typeName = table.Column<string>(type: "TEXT", nullable: true),
},
constraints: table =>
{
table.PrimaryKey("PK_Lockers", x => x.locker_id);
table.ForeignKey(
name: "FK_Lockers_Terminals_terminal_id",
column: x => x.terminal_id,
principalTable: "Terminals",
principalColumn: "terminal_id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_Lockers_terminal_id",
table: "Lockers",
column: "terminal_id");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Lockers");
migrationBuilder.DropTable(
name: "Terminals");
}
}
}
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using sl.LIBs_Data.Data;
namespace sl.LIBs_Data.Migrations
{
[DbContext(typeof(DbServiceContext))]
[Migration("20210519044912_AddTableWebHooks")]
partial class AddTableWebHooks
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.6");
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<bool>("IsPried")
.HasColumnType("INTEGER");
b.Property<int>("door_front_status")
.HasColumnType("INTEGER");
b.Property<int>("door_rear_status")
.HasColumnType("INTEGER");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<int>("items_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_hardware_address")
.HasColumnType("INTEGER");
b.Property<string>("locker_name")
.HasColumnType("TEXT");
b.Property<int>("locker_rear_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_rear_hardware_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_size")
.HasColumnType("INTEGER");
b.Property<int>("locker_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_type")
.HasColumnType("INTEGER");
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("typeName")
.HasColumnType("TEXT");
b.HasKey("locker_id");
b.HasIndex("terminal_id");
b.ToTable("Lockers");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("comport")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("terminal_name")
.HasColumnType("TEXT");
b.HasKey("terminal_id");
b.ToTable("Terminals");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Webhook", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<DateTime>("CreateTime")
.HasColumnType("TEXT");
b.Property<bool>("DelFlag")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("SecretKey")
.HasColumnType("TEXT");
b.Property<string>("Url")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Webhooks");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.HasOne("sl.LIBs_Entity.Enities.Terminal", null)
.WithMany("lockers")
.HasForeignKey("terminal_id");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Navigation("lockers");
});
#pragma warning restore 612, 618
}
}
}
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace sl.LIBs_Data.Migrations
{
public partial class AddTableWebHooks : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Webhooks",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: true),
Url = table.Column<string>(type: "TEXT", nullable: true),
SecretKey = table.Column<string>(type: "TEXT", nullable: true),
DelFlag = table.Column<bool>(type: "INTEGER", nullable: false),
CreateTime = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Webhooks", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Webhooks");
}
}
}
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using sl.LIBs_Data.Data;
namespace sl.LIBs_Data.Migrations
{
[DbContext(typeof(DbServiceContext))]
[Migration("20210520095603_Settings_Logs")]
partial class Settings_Logs
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.6");
modelBuilder.Entity("sl.LIBs_Entity.Enities.ActivityLog", b =>
{
b.Property<string>("activelog_id")
.HasColumnType("TEXT");
b.Property<string>("action")
.HasColumnType("TEXT");
b.Property<DateTime>("created_time")
.HasColumnType("TEXT");
b.Property<string>("type")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("activelog_id");
b.ToTable("ActivityLogs");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<bool>("IsPried")
.HasColumnType("INTEGER");
b.Property<int>("door_front_status")
.HasColumnType("INTEGER");
b.Property<int>("door_rear_status")
.HasColumnType("INTEGER");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<int>("items_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_hardware_address")
.HasColumnType("INTEGER");
b.Property<string>("locker_name")
.HasColumnType("TEXT");
b.Property<int>("locker_rear_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_rear_hardware_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_size")
.HasColumnType("INTEGER");
b.Property<int>("locker_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_type")
.HasColumnType("INTEGER");
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("typeName")
.HasColumnType("TEXT");
b.HasKey("locker_id");
b.HasIndex("terminal_id");
b.ToTable("Lockers");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.LockerLog", b =>
{
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<string>("action")
.HasColumnType("TEXT");
b.Property<DateTime>("created_time")
.HasColumnType("TEXT");
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("user_id");
b.ToTable("LockerLogs");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Setting", b =>
{
b.Property<string>("setting_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<string>("groups")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("keys")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("unit")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime?>("updated_time")
.HasColumnType("TEXT");
b.Property<string>("value")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.HasKey("setting_id");
b.ToTable("Settings");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("comport")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("terminal_name")
.HasColumnType("TEXT");
b.HasKey("terminal_id");
b.ToTable("Terminals");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.User", b =>
{
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<string>("full_name")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("password")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("user_id");
b.ToTable("Users");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Webhook", b =>
{
b.Property<string>("webhook_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("name")
.HasColumnType("TEXT");
b.Property<string>("secret_key")
.HasColumnType("TEXT");
b.Property<string>("url")
.HasColumnType("TEXT");
b.HasKey("webhook_id");
b.ToTable("Webhooks");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.HasOne("sl.LIBs_Entity.Enities.Terminal", null)
.WithMany("lockers")
.HasForeignKey("terminal_id");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Navigation("lockers");
});
#pragma warning restore 612, 618
}
}
}
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace sl.LIBs_Data.Migrations
{
public partial class Settings_Logs : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Url",
table: "Webhooks",
newName: "url");
migrationBuilder.RenameColumn(
name: "Name",
table: "Webhooks",
newName: "name");
migrationBuilder.RenameColumn(
name: "SecretKey",
table: "Webhooks",
newName: "secret_key");
migrationBuilder.RenameColumn(
name: "DelFlag",
table: "Webhooks",
newName: "is_del");
migrationBuilder.RenameColumn(
name: "CreateTime",
table: "Webhooks",
newName: "create_time");
migrationBuilder.RenameColumn(
name: "Id",
table: "Webhooks",
newName: "webhook_id");
migrationBuilder.CreateTable(
name: "ActivityLogs",
columns: table => new
{
activelog_id = table.Column<string>(type: "TEXT", nullable: false),
user_id = table.Column<string>(type: "TEXT", nullable: true),
username = table.Column<string>(type: "TEXT", nullable: true),
action = table.Column<string>(type: "TEXT", nullable: true),
type = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
created_time = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ActivityLogs", x => x.activelog_id);
});
migrationBuilder.CreateTable(
name: "LockerLogs",
columns: table => new
{
user_id = table.Column<string>(type: "TEXT", nullable: false),
locker_id = table.Column<string>(type: "TEXT", nullable: true),
username = table.Column<string>(type: "TEXT", nullable: true),
action = table.Column<string>(type: "TEXT", nullable: true),
created_time = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LockerLogs", x => x.user_id);
});
migrationBuilder.CreateTable(
name: "Settings",
columns: table => new
{
setting_id = table.Column<string>(type: "TEXT", nullable: false),
groups = table.Column<string>(type: "TEXT", nullable: true),
name = table.Column<string>(type: "TEXT", nullable: false),
keys = table.Column<string>(type: "TEXT", maxLength: 255, nullable: false),
value = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
unit = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
create_time = table.Column<DateTime>(type: "TEXT", nullable: false),
updated_time = table.Column<DateTime>(type: "TEXT", nullable: true),
is_del = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Settings", x => x.setting_id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
user_id = table.Column<string>(type: "TEXT", nullable: false),
username = table.Column<string>(type: "TEXT", nullable: true),
full_name = table.Column<string>(type: "TEXT", nullable: true),
password = table.Column<string>(type: "TEXT", nullable: true),
create_time = table.Column<DateTime>(type: "TEXT", nullable: false),
is_del = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.user_id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ActivityLogs");
migrationBuilder.DropTable(
name: "LockerLogs");
migrationBuilder.DropTable(
name: "Settings");
migrationBuilder.DropTable(
name: "Users");
migrationBuilder.RenameColumn(
name: "url",
table: "Webhooks",
newName: "Url");
migrationBuilder.RenameColumn(
name: "name",
table: "Webhooks",
newName: "Name");
migrationBuilder.RenameColumn(
name: "secret_key",
table: "Webhooks",
newName: "SecretKey");
migrationBuilder.RenameColumn(
name: "is_del",
table: "Webhooks",
newName: "DelFlag");
migrationBuilder.RenameColumn(
name: "create_time",
table: "Webhooks",
newName: "CreateTime");
migrationBuilder.RenameColumn(
name: "webhook_id",
table: "Webhooks",
newName: "Id");
}
}
}
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using sl.LIBs_Data.Data;
namespace sl.LIBs_Data.Migrations
{
[DbContext(typeof(DbServiceContext))]
[Migration("20210522143128_update-relationship")]
partial class updaterelationship
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.6");
modelBuilder.Entity("sl.LIBs_Entity.Enities.ActivityLog", b =>
{
b.Property<string>("activelog_id")
.HasColumnType("TEXT");
b.Property<string>("action")
.HasColumnType("TEXT");
b.Property<DateTime>("created_time")
.HasColumnType("TEXT");
b.Property<string>("type")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("activelog_id");
b.ToTable("ActivityLogs");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<bool>("IsPried")
.HasColumnType("INTEGER");
b.Property<int>("door_front_status")
.HasColumnType("INTEGER");
b.Property<int>("door_rear_status")
.HasColumnType("INTEGER");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<int>("items_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_hardware_address")
.HasColumnType("INTEGER");
b.Property<string>("locker_name")
.HasColumnType("TEXT");
b.Property<int>("locker_rear_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_rear_hardware_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_size")
.HasColumnType("INTEGER");
b.Property<int>("locker_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_type")
.HasColumnType("INTEGER");
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<int>("terminal_terminal_id")
.HasColumnType("INTEGER");
b.Property<string>("typeName")
.HasColumnType("TEXT");
b.HasKey("locker_id");
b.HasIndex("terminal_id");
b.ToTable("Lockers");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.LockerLog", b =>
{
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<string>("action")
.HasColumnType("TEXT");
b.Property<DateTime>("created_time")
.HasColumnType("TEXT");
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("user_id");
b.ToTable("LockerLogs");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Setting", b =>
{
b.Property<string>("setting_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<string>("groups")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("keys")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("unit")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime?>("updated_time")
.HasColumnType("TEXT");
b.Property<string>("value")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.HasKey("setting_id");
b.ToTable("Settings");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("comport")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("terminal_name")
.HasColumnType("TEXT");
b.HasKey("terminal_id");
b.ToTable("Terminals");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.User", b =>
{
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<string>("full_name")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("password")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("user_id");
b.ToTable("Users");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Webhook", b =>
{
b.Property<string>("webhook_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("name")
.HasColumnType("TEXT");
b.Property<string>("secret_key")
.HasColumnType("TEXT");
b.Property<string>("url")
.HasColumnType("TEXT");
b.HasKey("webhook_id");
b.ToTable("Webhooks");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.HasOne("sl.LIBs_Entity.Enities.Terminal", "terminal")
.WithMany("lockers")
.HasForeignKey("terminal_id");
b.Navigation("terminal");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Navigation("lockers");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace sl.LIBs_Data.Migrations
{
public partial class updaterelationship : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "terminal_terminal_id",
table: "Lockers",
type: "INTEGER",
nullable: false,
defaultValue: 0);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "terminal_terminal_id",
table: "Lockers");
}
}
}
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using sl.LIBs_Data.Data;
namespace sl.LIBs_Data.Migrations
{
[DbContext(typeof(DbServiceContext))]
[Migration("20210523082842_update_db_log")]
partial class update_db_log
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.6");
modelBuilder.Entity("sl.LIBs_Entity.Enities.ActivityLog", b =>
{
b.Property<string>("activelog_id")
.HasColumnType("TEXT");
b.Property<string>("action")
.HasColumnType("TEXT");
b.Property<DateTime>("created_time")
.HasColumnType("TEXT");
b.Property<string>("type")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("activelog_id");
b.ToTable("ActivityLogs");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<bool>("IsPried")
.HasColumnType("INTEGER");
b.Property<int>("door_front_status")
.HasColumnType("INTEGER");
b.Property<int>("door_rear_status")
.HasColumnType("INTEGER");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<int>("items_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_hardware_address")
.HasColumnType("INTEGER");
b.Property<string>("locker_name")
.HasColumnType("TEXT");
b.Property<int>("locker_rear_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_rear_hardware_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_size")
.HasColumnType("INTEGER");
b.Property<int>("locker_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_type")
.HasColumnType("INTEGER");
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<int>("terminal_terminal_id")
.HasColumnType("INTEGER");
b.Property<string>("typeName")
.HasColumnType("TEXT");
b.HasKey("locker_id");
b.HasIndex("terminal_id");
b.ToTable("Lockers");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.LockerLog", b =>
{
b.Property<string>("locker_log_id")
.HasColumnType("TEXT");
b.Property<string>("action")
.HasColumnType("TEXT");
b.Property<DateTime>("created_time")
.HasColumnType("TEXT");
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("locker_log_id");
b.ToTable("LockerLogs");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Setting", b =>
{
b.Property<string>("setting_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<string>("groups")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("keys")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("unit")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime?>("updated_time")
.HasColumnType("TEXT");
b.Property<string>("value")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.HasKey("setting_id");
b.ToTable("Settings");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("comport")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("terminal_name")
.HasColumnType("TEXT");
b.HasKey("terminal_id");
b.ToTable("Terminals");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.User", b =>
{
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<string>("full_name")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("password")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("user_id");
b.ToTable("Users");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Webhook", b =>
{
b.Property<string>("webhook_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("name")
.HasColumnType("TEXT");
b.Property<string>("secret_key")
.HasColumnType("TEXT");
b.Property<string>("url")
.HasColumnType("TEXT");
b.HasKey("webhook_id");
b.ToTable("Webhooks");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.HasOne("sl.LIBs_Entity.Enities.Terminal", "terminal")
.WithMany("lockers")
.HasForeignKey("terminal_id");
b.Navigation("terminal");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Navigation("lockers");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace sl.LIBs_Data.Migrations
{
public partial class update_db_log : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_LockerLogs",
table: "LockerLogs");
migrationBuilder.AlterColumn<string>(
name: "user_id",
table: "LockerLogs",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AddColumn<string>(
name: "locker_log_id",
table: "LockerLogs",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.AddPrimaryKey(
name: "PK_LockerLogs",
table: "LockerLogs",
column: "locker_log_id");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_LockerLogs",
table: "LockerLogs");
migrationBuilder.DropColumn(
name: "locker_log_id",
table: "LockerLogs");
migrationBuilder.AlterColumn<string>(
name: "user_id",
table: "LockerLogs",
type: "TEXT",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AddPrimaryKey(
name: "PK_LockerLogs",
table: "LockerLogs",
column: "user_id");
}
}
}
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using sl.LIBs_Data.Data;
namespace sl.LIBs_Data.Migrations
{
[DbContext(typeof(DbServiceContext))]
[Migration("20210531095824_Update_table_locker")]
partial class Update_table_locker
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.6");
modelBuilder.Entity("sl.LIBs_Entity.Enities.ActivityLog", b =>
{
b.Property<string>("activelog_id")
.HasColumnType("TEXT");
b.Property<string>("action")
.HasColumnType("TEXT");
b.Property<DateTime>("created_time")
.HasColumnType("TEXT");
b.Property<string>("type")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("activelog_id");
b.ToTable("ActivityLogs");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<bool>("IsPried")
.HasColumnType("INTEGER");
b.Property<int>("door_front_status")
.HasColumnType("INTEGER");
b.Property<int>("door_rear_status")
.HasColumnType("INTEGER");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<int>("items_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_hardware_address")
.HasColumnType("INTEGER");
b.Property<string>("locker_name")
.HasColumnType("TEXT");
b.Property<int>("locker_rear_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_rear_hardware_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_size")
.HasColumnType("INTEGER");
b.Property<int>("locker_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_type")
.HasColumnType("INTEGER");
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("typeName")
.HasColumnType("TEXT");
b.HasKey("locker_id");
b.HasIndex("terminal_id");
b.ToTable("Lockers");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.LockerLog", b =>
{
b.Property<string>("locker_log_id")
.HasColumnType("TEXT");
b.Property<string>("action")
.HasColumnType("TEXT");
b.Property<DateTime>("created_time")
.HasColumnType("TEXT");
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("locker_log_id");
b.ToTable("LockerLogs");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Setting", b =>
{
b.Property<string>("setting_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<string>("groups")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("keys")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("unit")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime?>("updated_time")
.HasColumnType("TEXT");
b.Property<string>("value")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.HasKey("setting_id");
b.ToTable("Settings");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("comport")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("terminal_name")
.HasColumnType("TEXT");
b.HasKey("terminal_id");
b.ToTable("Terminals");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.User", b =>
{
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<string>("full_name")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("password")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("user_id");
b.ToTable("Users");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Webhook", b =>
{
b.Property<string>("webhook_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("name")
.HasColumnType("TEXT");
b.Property<string>("secret_key")
.HasColumnType("TEXT");
b.Property<string>("url")
.HasColumnType("TEXT");
b.HasKey("webhook_id");
b.ToTable("Webhooks");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.HasOne("sl.LIBs_Entity.Enities.Terminal", "terminal")
.WithMany("lockers")
.HasForeignKey("terminal_id");
b.Navigation("terminal");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Navigation("lockers");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace sl.LIBs_Data.Migrations
{
public partial class Update_table_locker : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using sl.LIBs_Data.Data;
#nullable disable
namespace sl.LIBs_Data.Migrations
{
[DbContext(typeof(DbServiceContext))]
[Migration("20240528083913_AddEmailToUser")]
partial class AddEmailToUser
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.0");
modelBuilder.Entity("sl.LIBs_Entity.Enities.ActivityLog", b =>
{
b.Property<string>("activelog_id")
.HasColumnType("TEXT");
b.Property<string>("action")
.HasColumnType("TEXT");
b.Property<DateTime>("created_time")
.HasColumnType("TEXT");
b.Property<string>("type")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("activelog_id");
b.ToTable("ActivityLogs");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<bool>("IsPried")
.HasColumnType("INTEGER");
b.Property<int>("door_front_status")
.HasColumnType("INTEGER");
b.Property<int>("door_rear_status")
.HasColumnType("INTEGER");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<int>("items_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_hardware_address")
.HasColumnType("INTEGER");
b.Property<string>("locker_name")
.HasColumnType("TEXT");
b.Property<int>("locker_rear_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_rear_hardware_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_size")
.HasColumnType("INTEGER");
b.Property<int>("locker_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_type")
.HasColumnType("INTEGER");
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("typeName")
.HasColumnType("TEXT");
b.HasKey("locker_id");
b.HasIndex("terminal_id");
b.ToTable("Lockers");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.LockerLog", b =>
{
b.Property<string>("locker_log_id")
.HasColumnType("TEXT");
b.Property<string>("action")
.HasColumnType("TEXT");
b.Property<DateTime>("created_time")
.HasColumnType("TEXT");
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("locker_log_id");
b.ToTable("LockerLogs");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Setting", b =>
{
b.Property<string>("setting_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<string>("groups")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("keys")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("unit")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime?>("updated_time")
.HasColumnType("TEXT");
b.Property<string>("value")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.HasKey("setting_id");
b.ToTable("Settings");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("comport")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("terminal_name")
.HasColumnType("TEXT");
b.HasKey("terminal_id");
b.ToTable("Terminals");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.User", b =>
{
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<string>("email")
.HasColumnType("TEXT");
b.Property<string>("full_name")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("password")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("user_id");
b.ToTable("Users");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Webhook", b =>
{
b.Property<string>("webhook_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("name")
.HasColumnType("TEXT");
b.Property<string>("secret_key")
.HasColumnType("TEXT");
b.Property<string>("url")
.HasColumnType("TEXT");
b.HasKey("webhook_id");
b.ToTable("Webhooks");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.HasOne("sl.LIBs_Entity.Enities.Terminal", "terminal")
.WithMany("lockers")
.HasForeignKey("terminal_id");
b.Navigation("terminal");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Navigation("lockers");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace sl.LIBs_Data.Migrations
{
public partial class AddEmailToUser : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "email",
table: "Users",
type: "TEXT",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "email",
table: "Users");
}
}
}
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using sl.LIBs_Data.Data;
#nullable disable
namespace sl.LIBs_Data.Migrations
{
[DbContext(typeof(DbServiceContext))]
partial class DbServiceContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.0");
modelBuilder.Entity("sl.LIBs_Entity.Enities.ActivityLog", b =>
{
b.Property<string>("activelog_id")
.HasColumnType("TEXT");
b.Property<string>("action")
.HasColumnType("TEXT");
b.Property<DateTime>("created_time")
.HasColumnType("TEXT");
b.Property<string>("type")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("activelog_id");
b.ToTable("ActivityLogs");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<bool>("IsPried")
.HasColumnType("INTEGER");
b.Property<int>("door_front_status")
.HasColumnType("INTEGER");
b.Property<int>("door_rear_status")
.HasColumnType("INTEGER");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<int>("items_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_front_hardware_address")
.HasColumnType("INTEGER");
b.Property<string>("locker_name")
.HasColumnType("TEXT");
b.Property<int>("locker_rear_board_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_rear_hardware_address")
.HasColumnType("INTEGER");
b.Property<int>("locker_size")
.HasColumnType("INTEGER");
b.Property<int>("locker_status")
.HasColumnType("INTEGER");
b.Property<int>("locker_type")
.HasColumnType("INTEGER");
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("typeName")
.HasColumnType("TEXT");
b.HasKey("locker_id");
b.HasIndex("terminal_id");
b.ToTable("Lockers");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.LockerLog", b =>
{
b.Property<string>("locker_log_id")
.HasColumnType("TEXT");
b.Property<string>("action")
.HasColumnType("TEXT");
b.Property<DateTime>("created_time")
.HasColumnType("TEXT");
b.Property<string>("locker_id")
.HasColumnType("TEXT");
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("locker_log_id");
b.ToTable("LockerLogs");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Setting", b =>
{
b.Property<string>("setting_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<string>("groups")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("keys")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("unit")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime?>("updated_time")
.HasColumnType("TEXT");
b.Property<string>("value")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.HasKey("setting_id");
b.ToTable("Settings");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Property<string>("terminal_id")
.HasColumnType("TEXT");
b.Property<string>("comport")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("terminal_name")
.HasColumnType("TEXT");
b.HasKey("terminal_id");
b.ToTable("Terminals");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.User", b =>
{
b.Property<string>("user_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<string>("email")
.HasColumnType("TEXT");
b.Property<string>("full_name")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("password")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("user_id");
b.ToTable("Users");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Webhook", b =>
{
b.Property<string>("webhook_id")
.HasColumnType("TEXT");
b.Property<DateTime>("create_time")
.HasColumnType("TEXT");
b.Property<bool>("is_del")
.HasColumnType("INTEGER");
b.Property<string>("name")
.HasColumnType("TEXT");
b.Property<string>("secret_key")
.HasColumnType("TEXT");
b.Property<string>("url")
.HasColumnType("TEXT");
b.HasKey("webhook_id");
b.ToTable("Webhooks");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Locker", b =>
{
b.HasOne("sl.LIBs_Entity.Enities.Terminal", "terminal")
.WithMany("lockers")
.HasForeignKey("terminal_id");
b.Navigation("terminal");
});
modelBuilder.Entity("sl.LIBs_Entity.Enities.Terminal", b =>
{
b.Navigation("lockers");
});
#pragma warning restore 612, 618
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="RestSharp" Version="106.11.7" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\sl.LIBs_Entity\sl.LIBs_Entity.csproj" />
</ItemGroup>
</Project>
using System;
namespace sl.LIBs_Entity.Custom
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class CustomGenerator : Attribute
{
public bool IsConstructorCall { get; private set; }
public object[] Values { get; private set; }
public CustomGenerator() : this(true) { }
public CustomGenerator(object value) : this(false, value) { }
public CustomGenerator(bool isConstructorCall, params object[] values)
{
IsConstructorCall = isConstructorCall;
Values = values ?? new object[0];
}
}
}
using System;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
namespace sl.LIBs_Entity.Custom
{
public abstract class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected ViewModelBase()
{
InitializeDefaultValues(this);
}
public static void InitializeDefaultValues(object obj)
{
var props = from prop in obj.GetType().GetProperties()
let attrs = prop.GetCustomAttributes(typeof(Custom.CustomGenerator), false)
where attrs.Any()
select new { Property = prop, Attr = ((Custom.CustomGenerator)attrs.First()) };
foreach (var pair in props)
{
object value;
if (pair.Property.PropertyType.Name == "String")
{
if (pair.Attr.Values.Length <= 0)
{
value = AutoGenString.GenerateNewGuidId();
}
else
{
if (pair.Attr.Values[0].ToString() == "AG_Unique_1")
{
value = AutoGenString.GenUniqueKey();
}
else if (pair.Attr.Values[0].ToString() == "AG_Unique_2")
{
value = AutoGenString.GenUniqueKeyOriginal_BIASED();
}
else
value = AutoGenString.GenerateNewGuidId();
}
}
else
{
value = !pair.Attr.IsConstructorCall && pair.Attr.Values.Length > 0
? pair.Attr.Values[0]
: Activator.CreateInstance(pair.Property.PropertyType, pair.Attr.Values);
}
pair.Property.SetValue(obj, value, null);
}
}
}
public class AutoGenString
{
internal static readonly char[] chars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray();
private static int _Size = 36;
public static string GenUniqueKey()
{
byte[] data = new byte[4 * _Size];
using (RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider())
{
crypto.GetBytes(data);
}
StringBuilder result = new StringBuilder(_Size);
for (int i = 0; i < _Size; i++)
{
var rnd = BitConverter.ToUInt32(data, i * 4);
var idx = rnd % chars.Length;
result.Append(chars[idx]);
}
return result.ToString();
}
public static string GenUniqueKeyOriginal_BIASED()
{
char[] chars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray();
byte[] data = new byte[_Size];
using (RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider())
{
crypto.GetBytes(data);
}
StringBuilder result = new StringBuilder(_Size);
foreach (byte b in data)
{
result.Append(chars[b % (chars.Length)]);
}
return result.ToString();
}
public static string GenerateNewGuidId()
{
//return Guid.NewGuid().ToString();
return Guid.NewGuid().ToString().Substring(0, _Size);
}
}
}
using sl.LIBs_Entity.Custom;
using System;
using System.ComponentModel.DataAnnotations;
namespace sl.LIBs_Entity.Enities
{
public class ActivityLog: ViewModelBase
{
#region Property
[Key]
[Custom.CustomGenerator("AG_Unique_2")]
public string activelog_id { get; set; }
public string user_id { get; set; }
public string username { get; set; }
public string action { get; set; }
[MaxLength(100)]
public string type { get; set; }
public DateTime created_time { get; set; }
#endregion
}
}
using sl.LIBs_Entity.Enum;
using System;
using System.ComponentModel.DataAnnotations;
namespace sl.LIBs_Entity.Enities
{
public class Locker : Custom.ViewModelBase, IDisposable
{
[Key]
[Custom.CustomGenerator("AG_Unique_2")]
public string locker_id { get; set; }
public string locker_name { get; set; }
public LockerStatus locker_status { get; set; } = LockerStatus.Enable;
public int locker_front_hardware_address { get; set; } = -99;
public int locker_front_board_address { get; set; } = -99;
public int locker_rear_hardware_address { get; set; } = -99;
public int locker_rear_board_address { get; set; } = -99;
public int locker_size { get; set; } = -99;
public Terminal terminal { get; set; }
private int _locker_type = 0;
public bool is_del { get; set; }
/// <summary>
/// 0: nomal, 1: screen 2: not use
/// </summary>
public int locker_type
{
get { return _locker_type; }
set
{
_locker_type = value;
if (_locker_type == 1)
locker_name = "Screen";
}
}
private bool _is_pried = false;
public bool IsPried
{
get { return _is_pried; }
set { _is_pried = value; NotifyPropertyChanged("IsPried"); }
}
private DoorStatus _door_front_status = DoorStatus.Close;
public DoorStatus door_front_status
{
get { return _door_front_status; }
set { _door_front_status = value; NotifyPropertyChanged("door_front_status"); }
}
private DoorStatus _door_rear_status = DoorStatus.Close;
public DoorStatus door_rear_status
{
get { return _door_rear_status; }
set { _door_rear_status = value; NotifyPropertyChanged("door_rear_status"); }
}
private ItemStatus _items_status = ItemStatus.Empty;
public ItemStatus items_status
{
get { return _items_status; }
set { _items_status = value; NotifyPropertyChanged("items_status"); }
}
public string typeName
{
get
{
if (locker_type == (int)LockerTypeEnum.Locker) return "Locker";
if (locker_type == (int)LockerTypeEnum.Screen) return "Screen"; return _typeName;
}
set { _typeName = value; }
}
private string _typeName { get; set; }
public override string ToString()
{
return base.ToString();
}
private System.ComponentModel.Component component = new System.ComponentModel.Component();
// Track whether Dispose has been called.
private bool disposed = false;
// Pointer to an external unmanaged resource.
private IntPtr handle;
public void Dispose()
{
Dispose(true);
// This object will be cleaned up by the Dispose method.
// Therefore, you should call GC.SupressFinalize to
// take this object off the finalization queue
// and prevent finalization code for this object
// from executing a second time.
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
// Check to see if Dispose has already been called.
if (!this.disposed)
{
// If disposing equals true, dispose all managed
// and unmanaged resources.
if (disposing)
{
// Dispose managed resources.
component.Dispose();
}
// Call the appropriate methods to clean up
// unmanaged resources here.
// If disposing is false,
// only the following code is executed.
CloseHandle(handle);
handle = IntPtr.Zero;
// Note disposing has been done.
disposed = true;
System.Diagnostics.Debug.WriteLine("Dispose LockerAddress ~");
}
}
// Use interop to call the method necessary
// to clean up the unmanaged resource.
[System.Runtime.InteropServices.DllImport("Kernel32")]
private extern static Boolean CloseHandle(IntPtr handle);
// Use C# destructor syntax for finalization code.
// This destructor will run only if the Dispose method
// does not get called.
// It gives your base class the opportunity to finalize.
// Do not provide destructors in types derived from this class.
~Locker()
{
// Do not re-create Dispose clean-up code here.
// Calling Dispose(false) is optimal in terms of
// readability and maintainability.
Dispose(false);
}
}
}
using sl.LIBs_Entity.Custom;
using System;
using System.ComponentModel.DataAnnotations;
namespace sl.LIBs_Entity.Enities
{
public class LockerLog : ViewModelBase
{
#region Property
[Key]
[Custom.CustomGenerator("AG_Unique_2")]
public string locker_log_id { get; set; }
public string user_id { get; set; }
public string locker_id { get; set; }
public string username { get; set; }
public virtual string action { get; set; }
public virtual DateTime created_time { get; set; }
#endregion
}
}
using sl.LIBs_Entity.Custom;
using System;
using System.ComponentModel.DataAnnotations;
namespace sl.LIBs_Entity.Enities
{
public class Setting : ViewModelBase
{
#region Property
[Key]
[Custom.CustomGenerator("AG_Unique_2")]
public string setting_id { get; set; }
public string groups { get; set; }
[Required]
public string name { get; set; }
[Required]
[MaxLength(255)]
public string keys { get; set; }
[MaxLength(255)]
public string value { get; set; }
[MaxLength(255)]
public string unit { get; set; }
public DateTime create_time { get; set; }
public DateTime? updated_time { get; set; }
public bool is_del { get; set; }
#endregion
}
}
using sl.LIBs_Entity.Custom;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace sl.LIBs_Entity.Enities
{
public class Terminal : ViewModelBase
{
[Key]
[Custom.CustomGenerator("AG_Unique_2")]
public string terminal_id { get; set; }
public string terminal_name { get; set; }
public string comport { get; set; }
public bool is_del { get; set; } = false;
public List<Locker> lockers { get; set; } = new List<Locker>();
}
}
using sl.LIBs_Entity.Custom;
using System;
using System.ComponentModel.DataAnnotations;
namespace sl.LIBs_Entity.Enities
{
public class User : ViewModelBase
{
[Key]
[Custom.CustomGenerator("AG_Unique_2")]
public string user_id { get; set; }
public string username { get; set; }
public string full_name { get; set; }
public string password { get; set; }
public DateTime create_time { get; set; }
public bool is_del { get; set; }
public string email { get; set; }
}
}
using sl.LIBs_Entity.Custom;
using System;
using System.ComponentModel.DataAnnotations;
namespace sl.LIBs_Entity.Enities
{
public class Webhook : ViewModelBase
{
[Key]
[Custom.CustomGenerator("AG_Unique_2")]
public string webhook_id { get; set; }
public string name { get; set; }
public string url { get; set; }
public string secret_key { get; set; }
public bool is_del { get; set; } = false;
public DateTime create_time { get; set; }
}
}
namespace sl.LIBs_Entity.Enum
{
public enum DoorStatus : int
{
Open = 0,
Close = 1,
}
public enum LockerStatus : int
{
Enable = 1,
Disable = 0,
Default = -99
}
public enum ImportLockerType: int
{
DeleteAndAddNew = 1,
AddNewOnly = 2,
Default = -99
}
public enum ItemStatus : int
{
Items = 1,
Empty = 0
}
public enum LockerTypeEnum : int
{
Locker = 0,
Screen = 1
}
public enum LockerItemDoor : int
{
OpenItems = 1,
OpenEmpty = 2,
CloseItems = 3,
CloseEmpty = 4,
LockerDisable = 9
}
public enum OpenType : int
{
Front = 1,
Rear = 2,
Both = 3,
Default = -99
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" />
<PackageReference Include="RestSharp" Version="106.11.7" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>
</Project>

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30204.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sl.NETAPIs_Hardware", "sl.NETAPIs_Hardware\sl.NETAPIs_Hardware.csproj", "{E1D1C9F8-BB7E-4D7B-9343-C5AB81C0B265}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sl.LIBs_AccessDevice", "sl.LIBs_AccessDevice\sl.LIBs_AccessDevice.csproj", "{EB79308B-CC4D-4B17-9E97-60FA31C54638}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sl.LIBs_Entity", "sl.LIBs_Entity\sl.LIBs_Entity.csproj", "{B49C8C27-0220-42F4-9EDF-4C583FEE0D7E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sl.LIBs_Data", "sl.LIBs_Data\sl.LIBs_Data.csproj", "{76F15624-45F0-4A8E-AF06-D2772AE6C041}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sl.Oauth_IdentityServer4", "sl.Oauth_IdentityServer4\sl.Oauth_IdentityServer4.csproj", "{2F26E913-9327-441B-B83A-94E7CAAF472A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E1D1C9F8-BB7E-4D7B-9343-C5AB81C0B265}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1D1C9F8-BB7E-4D7B-9343-C5AB81C0B265}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1D1C9F8-BB7E-4D7B-9343-C5AB81C0B265}.Debug|x86.ActiveCfg = Debug|Any CPU
{E1D1C9F8-BB7E-4D7B-9343-C5AB81C0B265}.Debug|x86.Build.0 = Debug|Any CPU
{E1D1C9F8-BB7E-4D7B-9343-C5AB81C0B265}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1D1C9F8-BB7E-4D7B-9343-C5AB81C0B265}.Release|Any CPU.Build.0 = Release|Any CPU
{E1D1C9F8-BB7E-4D7B-9343-C5AB81C0B265}.Release|x86.ActiveCfg = Release|Any CPU
{E1D1C9F8-BB7E-4D7B-9343-C5AB81C0B265}.Release|x86.Build.0 = Release|Any CPU
{EB79308B-CC4D-4B17-9E97-60FA31C54638}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB79308B-CC4D-4B17-9E97-60FA31C54638}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB79308B-CC4D-4B17-9E97-60FA31C54638}.Debug|x86.ActiveCfg = Debug|Any CPU
{EB79308B-CC4D-4B17-9E97-60FA31C54638}.Debug|x86.Build.0 = Debug|Any CPU
{EB79308B-CC4D-4B17-9E97-60FA31C54638}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB79308B-CC4D-4B17-9E97-60FA31C54638}.Release|Any CPU.Build.0 = Release|Any CPU
{EB79308B-CC4D-4B17-9E97-60FA31C54638}.Release|x86.ActiveCfg = Release|x86
{EB79308B-CC4D-4B17-9E97-60FA31C54638}.Release|x86.Build.0 = Release|x86
{B49C8C27-0220-42F4-9EDF-4C583FEE0D7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B49C8C27-0220-42F4-9EDF-4C583FEE0D7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B49C8C27-0220-42F4-9EDF-4C583FEE0D7E}.Debug|x86.ActiveCfg = Debug|Any CPU
{B49C8C27-0220-42F4-9EDF-4C583FEE0D7E}.Debug|x86.Build.0 = Debug|Any CPU
{B49C8C27-0220-42F4-9EDF-4C583FEE0D7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B49C8C27-0220-42F4-9EDF-4C583FEE0D7E}.Release|Any CPU.Build.0 = Release|Any CPU
{B49C8C27-0220-42F4-9EDF-4C583FEE0D7E}.Release|x86.ActiveCfg = Release|Any CPU
{B49C8C27-0220-42F4-9EDF-4C583FEE0D7E}.Release|x86.Build.0 = Release|Any CPU
{76F15624-45F0-4A8E-AF06-D2772AE6C041}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76F15624-45F0-4A8E-AF06-D2772AE6C041}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76F15624-45F0-4A8E-AF06-D2772AE6C041}.Debug|x86.ActiveCfg = Debug|Any CPU
{76F15624-45F0-4A8E-AF06-D2772AE6C041}.Debug|x86.Build.0 = Debug|Any CPU
{76F15624-45F0-4A8E-AF06-D2772AE6C041}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76F15624-45F0-4A8E-AF06-D2772AE6C041}.Release|Any CPU.Build.0 = Release|Any CPU
{76F15624-45F0-4A8E-AF06-D2772AE6C041}.Release|x86.ActiveCfg = Release|Any CPU
{76F15624-45F0-4A8E-AF06-D2772AE6C041}.Release|x86.Build.0 = Release|Any CPU
{2F26E913-9327-441B-B83A-94E7CAAF472A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2F26E913-9327-441B-B83A-94E7CAAF472A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2F26E913-9327-441B-B83A-94E7CAAF472A}.Debug|x86.ActiveCfg = Debug|Any CPU
{2F26E913-9327-441B-B83A-94E7CAAF472A}.Debug|x86.Build.0 = Debug|Any CPU
{2F26E913-9327-441B-B83A-94E7CAAF472A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2F26E913-9327-441B-B83A-94E7CAAF472A}.Release|Any CPU.Build.0 = Release|Any CPU
{2F26E913-9327-441B-B83A-94E7CAAF472A}.Release|x86.ActiveCfg = Release|Any CPU
{2F26E913-9327-441B-B83A-94E7CAAF472A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A30DC960-9D80-4AE9-9F47-661C0D51A5BC}
EndGlobalSection
EndGlobal
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
using sl.NETAPIs_Hardware.APIBase.Requests.System;
using System;
using System.Collections.Generic;
namespace sl.NETAPIs_Hardware.APIBase.Commons
{
//public class ClientManager
//{
//}
public static class ClientManager
{
private static Dictionary<Guid, AccountConnectTranfer> _allAccountLogin = new Dictionary<Guid, AccountConnectTranfer>();
/// <summary>
/// cấp phát token cho tài khoản
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
public static Guid CreateToken(AccountConnectTranfer accountConnect)
{
while (true)
{
var id = Guid.NewGuid();
while (_allAccountLogin.ContainsKey(id))
{
id = Guid.NewGuid();
}
// Add new login
if (_allAccountLogin.TryAdd(id, accountConnect))
{
return id;
}
}
}
/// <summary>
/// lấy thông tin tài khoản theo token
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
public static AccountConnectTranfer GetAccountByToken(Guid token)
{
_allAccountLogin.TryGetValue(token, out var accountConnect);
return accountConnect;
}
}
}
This diff is collapsed.
This diff is collapsed.
using sl.LIBs_Entity.Enities;
using System;
using System.Collections.Generic;
using System.Linq;
namespace sl.NETAPIs_Hardware.APIBase.Commons
{
public static class TerminalManager
{
private static Dictionary<Guid, Terminal> _allAccountLogin = new Dictionary<Guid, Terminal>();
/// <summary>
/// cấp phát token cho tài khoản
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
public static Guid CreateToken(Terminal terminal)
{
while (true)
{
var id = Guid.NewGuid();
while (_allAccountLogin.ContainsKey(id))
{
id = Guid.NewGuid();
}
// Add new login
if (_allAccountLogin.TryAdd(id, terminal))
{
return id;
}
}
}
/// <summary>
/// lấy thông tin tài khoản theo token
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
public static Terminal GetAccountByToken(Guid token)
{
_allAccountLogin.TryGetValue(token, out var terminal);
return terminal;
}
public static void UpdateDataTerminal(Terminal terminal)
{
if (terminal == null)
return;
var terminalUpdates = _allAccountLogin.Where(m => m.Value.terminal_id == terminal.terminal_id);
foreach (var tmp in terminalUpdates)
{
_allAccountLogin[tmp.Key] = terminal;
}
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
namespace sl.NETAPIs_Hardware.APIBase.Requests.System
{
public class AccountConnectTranfer
{
public string client_id { get; set; }
public string secret_key { get; set; }
}
}
namespace sl.NETAPIs_Hardware.APIBase.Requests.Users
{
public class ForgotPasswordTransfer
{
public string email { get; set; }
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment