forked from ddrilling/AsbCloudServer
nit refactoring
This commit is contained in:
parent
2ab29df231
commit
5966920019
@ -42,23 +42,23 @@ namespace AsbCloudInfrastructure.Services
|
||||
public async Task<UserTokenDto> LoginAsync(string login, string password,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var identity = await GetClaimsUserAsync(login, password, token)
|
||||
var (identity, user) = await GetClaimsUserAsync(login, password, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (identity == default || identity.User.State == 0)
|
||||
if (identity == default || user.State == 0)
|
||||
return null;
|
||||
|
||||
return new UserTokenDto
|
||||
{
|
||||
Id = identity.User.Id,
|
||||
Name = identity.User.Name,
|
||||
CompanyName = identity.User.Company.Caption,
|
||||
Level = identity.User.Level,
|
||||
Login = identity.User.Login,
|
||||
Patronymic = identity.User.Patronymic,
|
||||
RoleName = identity.User.Role.Caption,
|
||||
Surname = identity.User.Surname,
|
||||
Token = MakeToken(identity.Identity.Claims),
|
||||
Id = user.Id,
|
||||
Name = user.Name,
|
||||
CompanyName = user.Company.Caption,
|
||||
Level = user.Level,
|
||||
Login = user.Login,
|
||||
Patronymic = user.Patronymic,
|
||||
RoleName = user.Role.Caption,
|
||||
Surname = user.Surname,
|
||||
Token = MakeToken(identity.Claims),
|
||||
};
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
var newUser = new User
|
||||
{
|
||||
IdCompany = userDto.IdCompany,
|
||||
IdRole = 2, // simple user
|
||||
IdRole = userDto.IdRole ?? 2, // simple user
|
||||
State = 0,
|
||||
Name = userDto.Name,
|
||||
Surname = userDto.Surname,
|
||||
|
@ -78,12 +78,11 @@ namespace AsbCloudInfrastructure.Services
|
||||
int approxPointsCount = 1024, CancellationToken token = default)
|
||||
{
|
||||
var well = cacheWells.FirstOrDefault(w => w.Id == idWell);
|
||||
if (well is null)
|
||||
if (well?.IdTelemetry is null)
|
||||
return default;
|
||||
|
||||
var telemetry = cacheTelemetry.FirstOrDefault(t => t.Id == well.IdTelemetry);
|
||||
if (telemetry is null)
|
||||
return default;
|
||||
if (dateBegin == default)
|
||||
dateBegin = telemetryService.GetLastTelemetryDate(well.IdTelemetry??0);
|
||||
|
||||
if (dateBegin == default)
|
||||
dateBegin = DateTime.Now.AddSeconds(-intervalSec);
|
||||
@ -95,7 +94,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
var dbSet = db.Set<TModel>();
|
||||
|
||||
var query = from data in dbSet
|
||||
where data.IdTelemetry == telemetry.Id
|
||||
where data.IdTelemetry == well.IdTelemetry
|
||||
&& data.Date >= dateBegin && data.Date < datEnd
|
||||
select data;
|
||||
|
||||
|
@ -18,16 +18,18 @@ namespace AsbCloudInfrastructure.Services
|
||||
.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
|
||||
.Options;
|
||||
using var db = new AsbCloudDbContext(options);
|
||||
|
||||
|
||||
var cacheTelemetry = cacheDb.GetCachedTable<Telemetry>(db);
|
||||
|
||||
var lastTelemetriesDates = (from d in db.TelemetryDataSaub
|
||||
group d by d.IdTelemetry into g
|
||||
select new
|
||||
{
|
||||
IdTelemetry = g.Max(t => t.IdTelemetry),
|
||||
IdTelemetry = g.Key,
|
||||
Date = g.Max(t => t.Date)
|
||||
}).ToList();
|
||||
})
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
|
||||
requests = lastTelemetriesDates.Select(t => new
|
||||
{
|
||||
|
@ -65,11 +65,11 @@ namespace AsbCloudInfrastructure.Services
|
||||
CancellationToken token = default)
|
||||
{
|
||||
if (dto.IdWellType is < 1 or > 2)
|
||||
throw new ArgumentException("Тип секции указан неправильно.", nameof(dto));
|
||||
throw new ArgumentException("Тип скважины указан неправильно.", nameof(dto));
|
||||
|
||||
if (dto.IdState is < 0 or > 2)
|
||||
throw new ArgumentException("Текущее состояние работы скважины" +
|
||||
"указано неправильно.", nameof(dto));
|
||||
throw new ArgumentException("Текущее состояние работы скважины указано неправильно.", nameof(dto));
|
||||
|
||||
var entity = await db.Wells
|
||||
.FirstOrDefaultAsync(w => w.Id == idWell, token)
|
||||
.ConfigureAwait(false);
|
||||
@ -146,7 +146,11 @@ namespace AsbCloudInfrastructure.Services
|
||||
Caption = well.Caption,
|
||||
Cluster = well.Cluster.Caption,
|
||||
Deposit = well.Cluster.Deposit.Caption,
|
||||
LastTelemetryDate = GetLastTelemetryDate(well.Id)
|
||||
LastTelemetryDate = GetLastTelemetryDate(well.Id),
|
||||
IdWellType = well.IdWellType ?? default,
|
||||
IdState = well.IdState,
|
||||
Latitude = well.Latitude,
|
||||
Longitude = well.Longitude,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -86,9 +86,6 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (!isCompanyOwnsWell)
|
||||
return Forbid();
|
||||
|
||||
if (begin == default)
|
||||
begin = DateTime.Now.AddSeconds(-intervalSec);
|
||||
|
||||
var content = await telemetryDataService.GetAsync(idWell, begin,
|
||||
intervalSec, approxPointsCount, token).ConfigureAwait(false);
|
||||
|
||||
|
@ -1,23 +1,22 @@
|
||||
{
|
||||
"files": {
|
||||
"main.css": "/static/css/main.e92a8ff6.chunk.css",
|
||||
"main.js": "/static/js/main.fb09e9cb.chunk.js",
|
||||
"main.js.map": "/static/js/main.fb09e9cb.chunk.js.map",
|
||||
"runtime-main.js": "/static/js/runtime-main.1100f000.js",
|
||||
"runtime-main.js.map": "/static/js/runtime-main.1100f000.js.map",
|
||||
"static/js/2.e611d81c.chunk.js": "/static/js/2.e611d81c.chunk.js",
|
||||
"static/js/2.e611d81c.chunk.js.map": "/static/js/2.e611d81c.chunk.js.map",
|
||||
"static/js/3.921d7a03.chunk.js": "/static/js/3.921d7a03.chunk.js",
|
||||
"static/js/3.921d7a03.chunk.js.map": "/static/js/3.921d7a03.chunk.js.map",
|
||||
"main.css": "/static/css/main.2e1e40de.chunk.css",
|
||||
"main.js": "/static/js/main.bd15a5a8.chunk.js",
|
||||
"main.js.map": "/static/js/main.bd15a5a8.chunk.js.map",
|
||||
"runtime-main.js": "/static/js/runtime-main.75a65898.js",
|
||||
"runtime-main.js.map": "/static/js/runtime-main.75a65898.js.map",
|
||||
"static/js/2.fe530333.chunk.js": "/static/js/2.fe530333.chunk.js",
|
||||
"static/js/2.fe530333.chunk.js.map": "/static/js/2.fe530333.chunk.js.map",
|
||||
"static/js/3.5c25a85c.chunk.js": "/static/js/3.5c25a85c.chunk.js",
|
||||
"static/js/3.5c25a85c.chunk.js.map": "/static/js/3.5c25a85c.chunk.js.map",
|
||||
"index.html": "/index.html",
|
||||
"static/css/main.e92a8ff6.chunk.css.map": "/static/css/main.e92a8ff6.chunk.css.map",
|
||||
"static/js/2.e611d81c.chunk.js.LICENSE.txt": "/static/js/2.e611d81c.chunk.js.LICENSE.txt",
|
||||
"static/media/pointer.e8df778c.svg": "/static/media/pointer.e8df778c.svg"
|
||||
"static/css/main.2e1e40de.chunk.css.map": "/static/css/main.2e1e40de.chunk.css.map",
|
||||
"static/js/2.fe530333.chunk.js.LICENSE.txt": "/static/js/2.fe530333.chunk.js.LICENSE.txt"
|
||||
},
|
||||
"entrypoints": [
|
||||
"static/js/runtime-main.1100f000.js",
|
||||
"static/js/2.e611d81c.chunk.js",
|
||||
"static/css/main.e92a8ff6.chunk.css",
|
||||
"static/js/main.fb09e9cb.chunk.js"
|
||||
"static/js/runtime-main.75a65898.js",
|
||||
"static/js/2.fe530333.chunk.js",
|
||||
"static/css/main.2e1e40de.chunk.css",
|
||||
"static/js/main.bd15a5a8.chunk.js"
|
||||
]
|
||||
}
|
@ -1 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="manifest" href="/manifest.json"/><title>АСБ Vision</title><link href="/static/css/main.e92a8ff6.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,a,i=r[0],c=r[1],l=r[2],s=0,p=[];s<i.length;s++)a=i[s],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&p.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);p.length;)p.shift()();return u.push.apply(u,l||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var c=t[i];0!==o[c]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+"static/js/"+({}[e]||e)+"."+{3:"921d7a03"}[e]+".chunk.js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:i})}),12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="/",a.oe=function(e){throw console.error(e),e};var i=this.webpackJsonpasb_cloud_front_react=this.webpackJsonpasb_cloud_front_react||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var l=0;l<i.length;l++)r(i[l]);var f=c;t()}([])</script><script src="/static/js/2.e611d81c.chunk.js"></script><script src="/static/js/main.fb09e9cb.chunk.js"></script></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="manifest" href="/manifest.json"/><title>АСБ Vision</title><link href="/static/css/main.2e1e40de.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,a,i=r[0],c=r[1],l=r[2],s=0,p=[];s<i.length;s++)a=i[s],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&p.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);p.length;)p.shift()();return u.push.apply(u,l||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var c=t[i];0!==o[c]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+"static/js/"+({}[e]||e)+"."+{3:"5c25a85c"}[e]+".chunk.js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:i})}),12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="/",a.oe=function(e){throw console.error(e),e};var i=this.webpackJsonpasb_cloud_front_react=this.webpackJsonpasb_cloud_front_react||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var l=0;l<i.length;l++)r(i[l]);var f=c;t()}([])</script><script src="/static/js/2.fe530333.chunk.js"></script><script src="/static/js/main.bd15a5a8.chunk.js"></script></body></html>
|
Loading…
Reference in New Issue
Block a user