init
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
using DbAPI.Connections;
|
||||
using DTS.Common.Classes;
|
||||
using DTS.Common.Interface.Database;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DbAPI.User
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic implementation of <see cref="IUser"/>
|
||||
/// <inheritdoc cref="IUser"/>
|
||||
/// </summary>
|
||||
internal class User : IUserDbRecord
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
public string Password { get; set; }
|
||||
public short Role { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
public string LastModifiedBy { get; set; }
|
||||
public bool LocalOnly { get; set; }
|
||||
|
||||
public User(int id, string user, string display, string pwd, short role, DateTime lastModified, string lastModifiedBy, bool local)
|
||||
{
|
||||
ID = id;
|
||||
UserName = user;
|
||||
DisplayName = display;
|
||||
Password = pwd;
|
||||
Role = role;
|
||||
LastModified = lastModified;
|
||||
LastModifiedBy = lastModifiedBy;
|
||||
LocalOnly = local;
|
||||
}
|
||||
|
||||
internal static ulong GetUser(IConnectionDetails connection, out IUserDbRecord usr, string userName)
|
||||
{
|
||||
usr = null;
|
||||
var res = ConnectionManager.GetSqlCommand(connection, out var cmd, "sp_UsersGetId");
|
||||
if (res != Errors.ErrorCodes.ERROR_SUCCESS)
|
||||
{
|
||||
return Errors.ErrorCodes.ERROR_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.Parameters.Add(new SqlParameter("@UserName", SqlDbType.NVarChar, 255) { Value = userName });
|
||||
var newId = new SqlParameter("@UserId", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(newId);
|
||||
|
||||
var reader = cmd.ExecuteReader();
|
||||
if (DBNull.Value.Equals(newId.Value))
|
||||
{
|
||||
return Errors.ErrorCodes.ERROR_LOGINFAILED;
|
||||
}
|
||||
|
||||
var id = Convert.ToInt32(newId.Value);
|
||||
if (0 >= id) { return Errors.ErrorCodes.ERROR_LOGINFAILED; }
|
||||
|
||||
reader.Close();
|
||||
|
||||
cmd.Parameters.Clear();
|
||||
cmd.CommandText = "sp_UsersGet";
|
||||
cmd.Parameters.Add(new SqlParameter("@UserId", SqlDbType.Int) { Value = id });
|
||||
reader = cmd.ExecuteReader();
|
||||
|
||||
if (!reader.Read()) { return Errors.ErrorCodes.ERROR_UNKNOWN; }
|
||||
|
||||
var thisid = Utility.GetInt(reader, "ID");
|
||||
var uname = Utility.GetString(reader, "UserName");
|
||||
var displayName = Utility.GetString(reader, "DisplayName");
|
||||
var password = Utility.GetString(reader, "password");
|
||||
var role = Utility.GetShort(reader, "Role");
|
||||
var lastModified = Utility.GetDateTime(reader, "LastModified", DateTime.MinValue);
|
||||
var lastModifiedBy = Utility.GetString(reader, "LastModifiedBy");
|
||||
var local = Utility.GetBool(reader, "LocalOnly");
|
||||
|
||||
usr = new User(thisid, uname, displayName, password, role, lastModified, lastModifiedBy, local);
|
||||
|
||||
return Errors.ErrorCodes.ERROR_SUCCESS;
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
{
|
||||
"version": 3,
|
||||
"targets": {
|
||||
".NETFramework,Version=v4.8": {
|
||||
"DTS.Common/1.0.0": {
|
||||
"type": "project",
|
||||
"dependencies": {
|
||||
"DTS.Common.Licensing": "1.0.0",
|
||||
"DTS.Common.SharedResource": "1.0.0",
|
||||
"DTS.Common.Utilities": "1.0.0"
|
||||
},
|
||||
"compile": {
|
||||
"bin/placeholder/DTS.Common.dll": {}
|
||||
},
|
||||
"runtime": {
|
||||
"bin/placeholder/DTS.Common.dll": {}
|
||||
}
|
||||
},
|
||||
"DTS.Common.Licensing/1.0.0": {
|
||||
"type": "project",
|
||||
"compile": {
|
||||
"bin/placeholder/DTS.Common.Licensing.dll": {}
|
||||
},
|
||||
"runtime": {
|
||||
"bin/placeholder/DTS.Common.Licensing.dll": {}
|
||||
}
|
||||
},
|
||||
"DTS.Common.SharedResource/1.0.0": {
|
||||
"type": "project",
|
||||
"compile": {
|
||||
"bin/placeholder/DTS.Common.SharedResource.dll": {}
|
||||
},
|
||||
"runtime": {
|
||||
"bin/placeholder/DTS.Common.SharedResource.dll": {}
|
||||
}
|
||||
},
|
||||
"DTS.Common.Utilities/1.0.0": {
|
||||
"type": "project",
|
||||
"compile": {
|
||||
"bin/placeholder/DTS.Common.Utilities.dll": {}
|
||||
},
|
||||
"runtime": {
|
||||
"bin/placeholder/DTS.Common.Utilities.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"DTS.Common/1.0.0": {
|
||||
"type": "project",
|
||||
"path": "../../Common/DTS.Common/DTS.Common.csproj",
|
||||
"msbuildProject": "../../Common/DTS.Common/DTS.Common.csproj"
|
||||
},
|
||||
"DTS.Common.Licensing/1.0.0": {
|
||||
"type": "project",
|
||||
"path": "../../Common/DTS.Common.Licensing/DTS.Common.Licensing.csproj",
|
||||
"msbuildProject": "../../Common/DTS.Common.Licensing/DTS.Common.Licensing.csproj"
|
||||
},
|
||||
"DTS.Common.SharedResource/1.0.0": {
|
||||
"type": "project",
|
||||
"path": "../../Common/DTS.Common.SharedResource/DTS.Common.SharedResource.csproj",
|
||||
"msbuildProject": "../../Common/DTS.Common.SharedResource/DTS.Common.SharedResource.csproj"
|
||||
},
|
||||
"DTS.Common.Utilities/1.0.0": {
|
||||
"type": "project",
|
||||
"path": "../../Common/DTS.Common.Utilities/DTS.Common.Utilities.csproj",
|
||||
"msbuildProject": "../../Common/DTS.Common.Utilities/DTS.Common.Utilities.csproj"
|
||||
}
|
||||
},
|
||||
"projectFileDependencyGroups": {
|
||||
".NETFramework,Version=v4.8": [
|
||||
"DTS.Common >= 1.0.0"
|
||||
]
|
||||
},
|
||||
"packageFolders": {
|
||||
"D:\\Users\\fatashband\\.nuget\\packages\\": {},
|
||||
"C:\\Program Files (x86)\\ComponentOne\\WPF Edition\\bin\\v5\\": {},
|
||||
"C:\\Program Files (x86)\\ComponentOne\\WinForms Edition\\bin\\v5\\": {},
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
|
||||
},
|
||||
"project": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\DTS Projects\\DataPRO\\BRANCH_DEVEL_4_03\\DataPRO\\DbAPI\\DbAPI.csproj",
|
||||
"projectName": "DbAPI",
|
||||
"projectPath": "C:\\DTS Projects\\DataPRO\\BRANCH_DEVEL_4_03\\DataPRO\\DbAPI\\DbAPI.csproj",
|
||||
"packagesPath": "C:\\Users\\john.dowling\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\DTS Projects\\DataPRO\\BRANCH_DEVEL_4_03\\DataPRO\\DbAPI\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"crossTargeting": true,
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"D:\\Users\\fatashband\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\ComponentOne.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||
],
|
||||
"originalTargetFrameworks": [
|
||||
"net48"
|
||||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\ComponentOne\\Packages": {},
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net48": {
|
||||
"targetAlias": "net48",
|
||||
"projectReferences": {
|
||||
"C:\\DTS Projects\\DataPRO\\BRANCH_DEVEL_4_03\\Common\\DTS.Common\\DTS.Common.csproj": {
|
||||
"projectPath": "C:\\DTS Projects\\DataPRO\\BRANCH_DEVEL_4_03\\Common\\DTS.Common\\DTS.Common.csproj"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
},
|
||||
"restoreAuditProperties": {
|
||||
"enableAudit": "true",
|
||||
"auditLevel": "low",
|
||||
"auditMode": "direct"
|
||||
},
|
||||
"SdkAnalysisLevel": "9.0.100"
|
||||
},
|
||||
"frameworks": {
|
||||
"net48": {
|
||||
"targetAlias": "net48",
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.408\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user