Skip to content

Commit

Permalink
检查时间
Browse files Browse the repository at this point in the history
  • Loading branch information
maikebing committed Mar 1, 2023
1 parent 62e844e commit 5d7740e
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion IoTSharp.Data/AuditLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class AuditLog
public string ActionName { get; set; }
public string ActionData { get; set; }
public string ActionResult { get; set; }
public DateTime ActiveDateTime { get; set; } = DateTime.Now;
public DateTime ActiveDateTime { get; set; } = DateTime.UtcNow;

}
}
4 changes: 2 additions & 2 deletions IoTSharp.Data/DataExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public static Dic PreparingData<L>(this ApplicationDbContext _context, Dictionar
var tx = tl.First();
tx.FillKVToMe(kp);
// TODO:jy 待重新设计主键
tx.DateTime = DateTime.Now;
tx.DateTime = DateTime.UtcNow;
_context.Set<L>().Update(tx).State = EntityState.Modified;
}
else
{
var t2 = new L() { DateTime = DateTime.Now, DeviceId = deviceId, KeyName = kp.Key, DataSide = dataSide };
var t2 = new L() { DateTime = DateTime.UtcNow, DeviceId = deviceId, KeyName = kp.Key, DataSide = dataSide };
t2.Catalog = (typeof(L) == typeof(AttributeLatest) ? DataCatalog.AttributeLatest
: ((typeof(L) == typeof(TelemetryLatest) ? DataCatalog.TelemetryLatest
: 0)));
Expand Down
10 changes: 5 additions & 5 deletions IoTSharp.Data/Extensions/AlarmExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ public static async Task<ApiResult<Alarm>> OccurredAlarm(this ApplicationDbConte
var alarm = new Alarm
{
Id = Guid.NewGuid(),
AckDateTime = DateTime.Now,
AckDateTime = DateTime.UtcNow,
AlarmDetail = dto.AlarmDetail,
AlarmStatus = AlarmStatus.Active_UnAck,
AlarmType = dto.AlarmType,
ClearDateTime = new DateTime(1970, 1, 1),
EndDateTime = new DateTime(1970, 1, 1),
Propagate = true,
Serverity = dto.Serverity,
StartDateTime = DateTime.Now,
StartDateTime = DateTime.UtcNow,
};
action?.Invoke(alarm);
var isone = from a in _context.Alarms where a.OriginatorId == alarm.OriginatorId && a.AlarmType == alarm.AlarmType && (a.AlarmStatus == AlarmStatus.Cleared_UnAck|| a.AlarmStatus == AlarmStatus.Active_UnAck) select a;
Expand All @@ -99,15 +99,15 @@ public static async Task<ApiResult<Alarm>> OccurredAlarm(this ApplicationDbConte
{
if (old.Serverity== ServerityLevel.Indeterminate && dto.Serverity!= ServerityLevel.Indeterminate)
{
old.StartDateTime = DateTime.Now;
old.StartDateTime = DateTime.UtcNow;
alarm.Propagate = true;
}
else if (old.Serverity != ServerityLevel.Indeterminate && dto.Serverity == ServerityLevel.Indeterminate)
{
old.EndDateTime = DateTime.Now;
old.EndDateTime = DateTime.UtcNow;
if (old.ClearDateTime.Year == 1970)
{
old.ClearDateTime = DateTime.Now;
old.ClearDateTime = DateTime.UtcNow;
}
alarm.Propagate = true;
}
Expand Down
3 changes: 2 additions & 1 deletion IoTSharp.Data/Extensions/DBExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public static class DBExtension
{
public static void CheckApplicationDBMigrations(this IApplicationBuilder app)
{
var applicationDb = app.ApplicationServices.GetService<ApplicationDbContext>();
using var scope = app.ApplicationServices.CreateScope();
using var applicationDb = scope.ServiceProvider.GetService<ApplicationDbContext>();
if (applicationDb.Database.IsRelational() && applicationDb.Database.GetPendingMigrations().Any())
{
applicationDb.Database.Migrate();
Expand Down
4 changes: 2 additions & 2 deletions IoTSharp.Data/Extensions/DeviceExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void AfterCreateDevice(this ApplicationDbContext _context, Devic
IdentityId = Guid.NewGuid().ToString().Replace("-", "")
});
Dictionary<string, object> pairs = new Dictionary<string, object>();
pairs.Add("CreateDateTime", DateTime.Now);
pairs.Add("CreateDateTime", DateTime.UtcNow);
_context.PreparingData<AttributeLatest>(pairs, device.Id, DataSide.ServerSide);
}
}
Expand All @@ -51,7 +51,7 @@ public static void AfterCreateDevice(this ApplicationDbContext _context, Device
IdentityValue = password
}) ;
Dictionary<string, object> pairs = new Dictionary<string, object>();
pairs.Add("CreateDateTime", DateTime.Now);
pairs.Add("CreateDateTime", DateTime.UtcNow);
_context.PreparingData<AttributeLatest>(pairs, device.Id, DataSide.ServerSide);
}
}
Expand Down
2 changes: 1 addition & 1 deletion IoTSharp.Data/PlayloadData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace IoTSharp.Data
{
public class PlayloadData
{
public DateTime ts { get; set; } = DateTime.Now;
public DateTime ts { get; set; } = DateTime.UtcNow;
public Guid DeviceId { get; set; }
public Dictionary<string, object> MsgBody { get; set; }
public DataSide DataSide { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion IoTSharp.Extensions.X509/X509SelfExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static X509Certificate2 CreateTlsClientRSA(this X509Certificate2 issuer,
}
var notbefor = issuer.NotBefore;
var notAfter = issuer.NotAfter;
X509Certificate2 signedCert = request.Create(issuer, DateTimeOffset.Now, DateTimeOffset.Now.AddSeconds(notAfter.Subtract(DateTime.Now).TotalSeconds), guid.ToByteArray());
X509Certificate2 signedCert = request.Create(issuer, DateTimeOffset.Now, DateTimeOffset.Now.AddSeconds(notAfter.Subtract(DateTime.UtcNow).TotalSeconds), guid.ToByteArray());
return signedCert.CopyWithPrivateKey(ecdsa);
}
}
Expand Down
2 changes: 1 addition & 1 deletion IoTSharp.SDKs/IoTSharp.Sdk.MQTT/MQTTClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async Task<bool> ConnectAsync(X509Certificate2 ca, X509Certificate2 clien
chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
chain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot;
chain.ChainPolicy.VerificationFlags = X509VerificationFlags.NoFlag;
chain.ChainPolicy.VerificationTime = DateTime.Now;
chain.ChainPolicy.VerificationTime = DateTime.UtcNow;
chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 0, 0);
chain.ChainPolicy.CustomTrustStore.Add(ca);
chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust;
Expand Down
4 changes: 2 additions & 2 deletions IoTSharp.SDKs/MQTTDemo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
{
if (client.IsConnected)
{
await client.UploadTelemetryDataAsync(new { DateTime.Now });
Console.WriteLine(DateTime.Now);
await client.UploadTelemetryDataAsync(new { DateTime.UtcNow });
Console.WriteLine(DateTime.UtcNow);
}
Thread.Sleep(TimeSpan.FromSeconds(5));
Console.WriteLine("====");
Expand Down

0 comments on commit 5d7740e

Please sign in to comment.