Here are the examples of the csharp api System.DateTimeOffset.ToUnixTimeMilliseconds() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
656 Examples
19
View Source File : Amf3Writer.cs
License : MIT License
Project Creator : a1q123456
License : MIT License
Project Creator : a1q123456
public void WriteBytes(DateTime dateTime, SerializationContext context)
{
context.Buffer.WriteToBuffer((byte)Amf3Type.Date);
var refIndex = context.ObjectReferenceTable.IndexOf(dateTime);
uint header = 0;
if (refIndex >= 0)
{
header = (uint)refIndex << 1;
WriteU29BytesImpl(header, context);
return;
}
context.ObjectReferenceTable.Add(dateTime);
var timeOffset = new DateTimeOffset(dateTime);
var timestamp = timeOffset.ToUnixTimeMilliseconds();
header = 0x01;
WriteU29BytesImpl(header, context);
var backend = _arrayPool.Rent(sizeof(double));
try
{
var contractRet = NetworkBitConverter.TryGetBytes(timestamp, backend);
Contract.replacedert(contractRet);
context.Buffer.WriteToBuffer(backend.replacedpan(0, sizeof(double)));
}
finally
{
_arrayPool.Return(backend);
}
}
19
View Source File : Amf0Writer.cs
License : MIT License
Project Creator : a1q123456
License : MIT License
Project Creator : a1q123456
public void WriteBytes(DateTime dateTime, SerializationContext context)
{
var bytesNeed = Amf0CommonValues.MARKER_LENGTH + sizeof(double) + sizeof(short);
var backend = _arrayPool.Rent(bytesNeed);
try
{
var buffer = backend.replacedpan(0, bytesNeed);
buffer.Slice(0, bytesNeed).Clear();
buffer[0] = (byte)Amf0Type.Date;
var dof = new DateTimeOffset(dateTime);
var timestamp = (double)dof.ToUnixTimeMilliseconds();
var contractRet = NetworkBitConverter.TryGetBytes(timestamp, buffer.Slice(Amf0CommonValues.MARKER_LENGTH));
Contract.replacedert(contractRet);
context.Buffer.WriteToBuffer(buffer);
}
finally
{
_arrayPool.Return(backend);
}
}
19
View Source File : BankIdSimulatedApiClient.cs
License : MIT License
Project Creator : ActiveLogin
License : MIT License
Project Creator : ActiveLogin
private static long UnixTimestampMillisecondsFromDateTime(DateTime dateTime)
{
var offset = new DateTimeOffset(dateTime);
return offset.ToUnixTimeMilliseconds();
}
19
View Source File : MusicallyApiExtensions.cs
License : MIT License
Project Creator : AeonLucid
License : MIT License
Project Creator : AeonLucid
public static IFlurlRequest WithSignHeaders(this IFlurlRequest request, MusicallyClient api)
{
var requestId = Guid.NewGuid().ToString();
var requestInfo = JsonConvert.SerializeObject(new RequestInfo
{
Os = "android 8.0.0",
Version = "6.9.0",
SliderShowCookie = string.Empty,
XRequestId = requestId,
Url = request.Url.ToString(),
OsType = "android",
DeviceId = api.Cache.Device.DeviceId,
Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
});
var requestInfoEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(requestInfo));
var requestSignature = api.ApiSignature.GetSignature(requestInfoEncoded, api.Cache.Device.DeviceId).GetAwaiter().GetResult();
return request
.WithHeader("X-Request-ID", requestId)
.WithHeader("X-Request-Info5", requestInfoEncoded)
.WithHeader("X-Request-Sign5", requestSignature.Sign);
}
19
View Source File : Utilities.cs
License : MIT License
Project Creator : Aiko-IT-Systems
License : MIT License
Project Creator : Aiko-IT-Systems
public static long GetUnixTime(DateTimeOffset dto)
=> dto.ToUnixTimeMilliseconds();
19
View Source File : DateTimeHelper.cs
License : MIT License
Project Creator : aishang2015
License : MIT License
Project Creator : aishang2015
public static string DateTime2TimeStamp(bool milliseconds = false)
{
// 废止
//var ts = DateTime.Now - _startedDate;
//return Convert.ToInt64(milliseconds ? ts.TotalMilliseconds : ts.TotalSeconds).ToString();
return milliseconds ? DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString() :
DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString();
}
19
View Source File : AllureLifecycle.cs
License : Apache License 2.0
Project Creator : allure-framework
License : Apache License 2.0
Project Creator : allure-framework
public virtual AllureLifecycle StopFixture(string uuid)
{
var fixture = storage.Remove<FixtureResult>(uuid);
storage.ClearStepContext();
fixture.stage = Stage.finished;
fixture.stop = DateTimeOffset.Now.ToUnixTimeMilliseconds();
return this;
}
19
View Source File : AllureLifecycle.cs
License : Apache License 2.0
Project Creator : allure-framework
License : Apache License 2.0
Project Creator : allure-framework
public virtual AllureLifecycle StartTestCase(TestResult testResult)
{
testResult.stage = Stage.running;
testResult.start = DateTimeOffset.Now.ToUnixTimeMilliseconds();
storage.Put(testResult.uuid, testResult);
storage.ClearStepContext();
storage.StartStep(testResult.uuid);
return this;
}
19
View Source File : AllureLifecycle.cs
License : Apache License 2.0
Project Creator : allure-framework
License : Apache License 2.0
Project Creator : allure-framework
private void StartFixture(string uuid, FixtureResult fixtureResult)
{
storage.Put(uuid, fixtureResult);
fixtureResult.stage = Stage.running;
fixtureResult.start = DateTimeOffset.Now.ToUnixTimeMilliseconds();
storage.ClearStepContext();
storage.StartStep(uuid);
}
19
View Source File : AllureLifecycle.cs
License : Apache License 2.0
Project Creator : allure-framework
License : Apache License 2.0
Project Creator : allure-framework
public virtual AllureLifecycle StopTestCase(string uuid)
{
var testResult = storage.Get<TestResult>(uuid);
testResult.stage = Stage.finished;
testResult.stop = DateTimeOffset.Now.ToUnixTimeMilliseconds();
storage.ClearStepContext();
return this;
}
19
View Source File : AllureLifecycle.cs
License : Apache License 2.0
Project Creator : allure-framework
License : Apache License 2.0
Project Creator : allure-framework
public virtual AllureLifecycle StartStep(string parentUuid, string uuid, StepResult stepResult)
{
stepResult.stage = Stage.running;
stepResult.start = DateTimeOffset.Now.ToUnixTimeMilliseconds();
storage.StartStep(uuid);
storage.AddStep(parentUuid, uuid, stepResult);
return this;
}
19
View Source File : AllureLifecycle.cs
License : Apache License 2.0
Project Creator : allure-framework
License : Apache License 2.0
Project Creator : allure-framework
public virtual AllureLifecycle StopStep(string uuid)
{
var step = storage.Remove<StepResult>(uuid);
step.stage = Stage.finished;
step.stop = DateTimeOffset.Now.ToUnixTimeMilliseconds();
storage.StopStep();
return this;
}
19
View Source File : AllureLifecycle.cs
License : Apache License 2.0
Project Creator : allure-framework
License : Apache License 2.0
Project Creator : allure-framework
public virtual AllureLifecycle StartTestContainer(TestResultContainer container)
{
container.start = DateTimeOffset.Now.ToUnixTimeMilliseconds();
storage.Put(container.uuid, container);
return this;
}
19
View Source File : AllureLifecycle.cs
License : Apache License 2.0
Project Creator : allure-framework
License : Apache License 2.0
Project Creator : allure-framework
public virtual AllureLifecycle StopTestContainer(string uuid)
{
UpdateTestContainer(uuid, c => c.stop = DateTimeOffset.Now.ToUnixTimeMilliseconds());
return this;
}
19
View Source File : DataTimeExtension.cs
License : MIT License
Project Creator : AlphaYu
License : MIT License
Project Creator : AlphaYu
public static double GetTotalMilliseconds(this in DateTime dt) => new DateTimeOffset(dt).ToUnixTimeMilliseconds();
19
View Source File : UnixTimeConverter.cs
License : MIT License
Project Creator : Analogy-LogViewer
License : MIT License
Project Creator : Analogy-LogViewer
private void dateEdit1_EditValueChanged(object sender, EventArgs e)
{
textEdit1.Text = new DateTimeOffset(dateEdit1.DateTime).ToUnixTimeMilliseconds().ToString();
}
19
View Source File : UnixTimeConverter.cs
License : MIT License
Project Creator : Analogy-LogViewer
License : MIT License
Project Creator : Analogy-LogViewer
private void sbtnToUnix_Click(object sender, EventArgs e)
{
textEdit1.Text = new DateTimeOffset(dateEdit1.DateTime).ToUnixTimeMilliseconds().ToString();
}
19
View Source File : ZoomClientTests.cs
License : Apache License 2.0
Project Creator : AndcultureCode
License : Apache License 2.0
Project Creator : AndcultureCode
[Test]
public void Create_Meeting_Registrants_With_Preplacedword_Returns_Registrant()
{
// Arrange
GetUser();
GenerateMeeting(PreplacedWORD);
_meeting = _sut.Meetings.CreateMeeting(_userEmail, _meeting);
// Act
var result = _sut.Meetings.CreateMeetingRegistrant(_meeting.Id, new CreateMeetingRegistrant
{
Email = $"test{DateTimeOffset.Now.ToUnixTimeMilliseconds()}@gmail.com",
FirstName = "FirstName",
LastName = "LastName"
});
// replacedert
result.ShouldNotBeNull();
result.JoinUrl.ShouldNotBeNullOrWhiteSpace();
result.JoinUrl.ShouldContain("pwd=", "JoinUrl=" + _meeting.JoinUrl);
}
19
View Source File : ZoomClientTests.cs
License : Apache License 2.0
Project Creator : AndcultureCode
License : Apache License 2.0
Project Creator : AndcultureCode
[Test]
public void Create_Meeting_Registrants_Without_Preplacedword_Returns_Registrant()
{
// Arrange
GetUser();
GenerateMeeting();
_meeting = _sut.Meetings.CreateMeeting(_userEmail, _meeting);
// Act
var result = _sut.Meetings.CreateMeetingRegistrant(_meeting.Id, new CreateMeetingRegistrant
{
Email = $"test{DateTimeOffset.Now.ToUnixTimeMilliseconds()}@gmail.com",
FirstName = "FirstName",
LastName = "LastName"
});
// replacedert
result.ShouldNotBeNull();
result.JoinUrl.ShouldNotBeNullOrWhiteSpace();
result.JoinUrl.ShouldNotContain("pwd=", "JoinUrl=" + _meeting.JoinUrl);
}
19
View Source File : ZoomClientTests.cs
License : Apache License 2.0
Project Creator : AndcultureCode
License : Apache License 2.0
Project Creator : AndcultureCode
[Test]
public void Load_Groups_Returns_List()
{
// Arrange
var group = _sut.Groups.CreateGroup(new Models.Groups.CreateGroup
{
Name = $"Test Group {DateTimeOffset.Now.ToUnixTimeMilliseconds()}"
});
group.Id.ShouldNotBeNullOrWhiteSpace();
// Act
var result = _sut.Groups.GetGroups();
// replacedert
result.ShouldNotBeNull();
result.Groups.ShouldNotBeNull();
result.Groups.Count.ShouldBeGreaterThan(0);
// Cleanup
_sut.Groups.DeleteGroup(group.Id);
}
19
View Source File : ZoomClientTests.cs
License : Apache License 2.0
Project Creator : AndcultureCode
License : Apache License 2.0
Project Creator : AndcultureCode
[Test]
public void Get_Group_Returns_Valid_Group()
{
// Arrange
var group = _sut.Groups.CreateGroup(new Models.Groups.CreateGroup
{
Name = $"Test Group {DateTimeOffset.Now.ToUnixTimeMilliseconds()}"
});
group.Id.ShouldNotBeNullOrWhiteSpace();
// Act
var result = _sut.Groups.GetGroup(group.Id);
// replacedert
result.ShouldNotBeNull();
result.Id.ShouldNotBeNull();
result.Name.ShouldNotBeNullOrWhiteSpace();
// Cleanup
_sut.Groups.DeleteGroup(group.Id);
}
19
View Source File : ZoomClientTests.cs
License : Apache License 2.0
Project Creator : AndcultureCode
License : Apache License 2.0
Project Creator : AndcultureCode
[Test]
public void Get_Group_Members_Returns_List()
{
// Arrange
var group = _sut.Groups.CreateGroup(new Models.Groups.CreateGroup
{
Name = $"Test Group {DateTimeOffset.Now.ToUnixTimeMilliseconds()}"
});
group.Id.ShouldNotBeNullOrWhiteSpace();
GetUser();
_sut.Groups.AddGroupMembers(group.Id, new List<Models.Groups.CreateMember>
{
new Models.Groups.CreateMember
{
Email = _userEmail
}
});
// Act
var result = _sut.Groups.GetGroupMembers(group.Id);
// replacedert
result.ShouldNotBeNull();
result.TotalRecords.ShouldBeGreaterThan(0);
result.Members.ShouldNotBeNull();
result.Members.FirstOrDefault().Email.ShouldBe(_userEmail);
// Cleanup
_sut.Groups.DeleteGroup(group.Id);
}
19
View Source File : ZoomClientTests.cs
License : Apache License 2.0
Project Creator : AndcultureCode
License : Apache License 2.0
Project Creator : AndcultureCode
[Test]
public void Update_Meeting_Registrants_Returns_Success()
{
// Arrange
GetUser();
GenerateMeeting();
_meeting = _sut.Meetings.CreateMeeting(_userEmail, _meeting);
var registrant = _sut.Meetings.CreateMeetingRegistrant(_meeting.Id, new CreateMeetingRegistrant
{
Email = $"test{DateTimeOffset.Now.ToUnixTimeMilliseconds()}@gmail.com",
FirstName = "FirstName",
LastName = "LastName"
});
// Act
var result = _sut.Meetings.UpdateMeetingRegistrant(_meeting.Id, new List<UpdateMeetingRegistrant> { new UpdateMeetingRegistrant { Email = registrant.Email } }, UpdateMeetingRegistrantStatuses.Approve);
// replacedert
result.ShouldNotBeNull();
result.ShouldBe(true);
}
19
View Source File : ZoomClientTests.cs
License : Apache License 2.0
Project Creator : AndcultureCode
License : Apache License 2.0
Project Creator : AndcultureCode
[Test]
public void Update_Invalid_Meeting_Registrants_Throws_Exception()
{
// Arrange
// Act
var exception = replacedert.Throws<Exception>(() => _sut.Meetings.CreateMeetingRegistrant("99999999", new CreateMeetingRegistrant
{
Email = $"test{DateTimeOffset.Now.ToUnixTimeMilliseconds()}@gmail.com",
FirstName = "FirstName",
LastName = "LastName"
}));
// replacedert
exception.ShouldNotBeNull("Exception");
exception.Message.ShouldNotBeNull("Message");
exception.Message.ShouldContain(MISSING_MEETING_ERROR_STRING);
}
19
View Source File : ZoomClientTests.cs
License : Apache License 2.0
Project Creator : AndcultureCode
License : Apache License 2.0
Project Creator : AndcultureCode
[Test]
public void Update_User_Returns_Valid_User()
{
// Arrange
GetUser();
var user = _sut.Users.GetUser(_userEmail);
var originalLastName = user.LastName;
var newLastName = $"Last Name {DateTimeOffset.Now.ToUnixTimeMilliseconds()}";
var updateUser = new UpdateUser
{
FirstName = user.FirstName,
LastName = newLastName
};
// Act
var result = _sut.Users.UpdateUser(_userEmail, updateUser);
// replacedert
result.ShouldNotBeNull();
result.ShouldBe(true);
user = _sut.Users.GetUser(_userEmail);
user.Email.ShouldBe(_userEmail);
user.LastName.ShouldBe(newLastName);
// Cleanup
_sut.Users.UpdateUser(_userEmail, new UpdateUser
{
FirstName = user.FirstName,
LastName = originalLastName
});
}
19
View Source File : ZoomClientTests.cs
License : Apache License 2.0
Project Creator : AndcultureCode
License : Apache License 2.0
Project Creator : AndcultureCode
[Test]
public void Update_User_Email_Returns_Success()
{
// Arrange
GetUser();
var user = _sut.Users.GetUser(_userEmail);
var originalEmail = _userEmail;
var newEmail = $"testuser{DateTimeOffset.Now.ToUnixTimeMilliseconds()}@gmail.com";
// Act
var result = _sut.Users.UpdateUserEmail(originalEmail, newEmail);
// replacedert
result.ShouldNotBeNull();
result.ShouldBe(true);
user = _sut.Users.GetUser(newEmail);
user.Email.ShouldBe(newEmail);
// Cleanup
_sut.Users.UpdateUserEmail(newEmail, originalEmail);
}
19
View Source File : ZoomClientTests.cs
License : Apache License 2.0
Project Creator : AndcultureCode
License : Apache License 2.0
Project Creator : AndcultureCode
void GenerateMeeting(string preplacedword = null)
{
_meeting = new Meeting
{
Duration = 60,
Preplacedword = preplacedword,
Settings = new MeetingSettings
{
EnableHostVideo = true,
EnableParticipantVideo = true,
EnableJoinBeforeHost = false,
ApprovalType = MeetingApprovalTypes.Automatic,
AutoRecording = MeetingAutoRecordingOptions.Cloud,
EnableEnforceLogin = true
},
StartTime = DateTimeOffset.Now,
Topic = "Test Meeting " + DateTimeOffset.Now.ToUnixTimeMilliseconds(),
Type = MeetingTypes.Scheduled,
};
}
19
View Source File : DateHelper.cs
License : Apache License 2.0
Project Creator : anjoy8
License : Apache License 2.0
Project Creator : anjoy8
public static long ToUnixTimestampByMilliseconds(DateTime dt)
{
DateTimeOffset dto = new DateTimeOffset(dt);
return dto.ToUnixTimeMilliseconds();
}
19
View Source File : ProgressLog.cs
License : Apache License 2.0
Project Creator : AnkiUniversal
License : Apache License 2.0
Project Creator : AnkiUniversal
public static void End()
{
NewLine();
long start = startTimes[indent];
indent = Math.Max(0, indent - 1);
Debug.WriteLine(Leader() + "done" + " [" + ((DateTimeOffset.Now.ToUnixTimeMilliseconds() - start) / 1000) + "s]");
}
19
View Source File : ProgressLog.cs
License : Apache License 2.0
Project Creator : AnkiUniversal
License : Apache License 2.0
Project Creator : AnkiUniversal
public static void Begin(string message)
{
NewLine();
Debug.WriteLine(Leader() + message + "... ");
atEOL = true;
indent++;
startTimes[indent] = DateTimeOffset.Now.ToUnixTimeMilliseconds();
}
19
View Source File : MessageDeliveryTimeTest.cs
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
[Test, Timeout(20_000)]
public void TestDeliveryDelayHasItsReflectionInAmqpAnnotations()
{
using (TestAmqpPeer testPeer = new TestAmqpPeer())
{
// Determine current time
TimeSpan deliveryDelay = TimeSpan.FromMinutes(17);
long currentUnixEpochTime = new DateTimeOffset(DateTime.UtcNow + deliveryDelay).ToUnixTimeMilliseconds();
long currentUnixEpochTime2 = new DateTimeOffset(DateTime.UtcNow + deliveryDelay + deliveryDelay).ToUnixTimeMilliseconds();
IConnection connection = base.EstablishConnection(testPeer,
serverCapabilities: new Symbol[] {SymbolUtil.OPEN_CAPABILITY_DELAYED_DELIVERY, SymbolUtil.OPEN_CAPABILITY_SOLE_CONNECTION_FOR_CONTAINER});
testPeer.ExpectBegin();
testPeer.ExpectSenderAttach();
ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
IQueue queue = session.GetQueue("myQueue");
IMessageProducer producer = session.CreateProducer(queue);
producer.DeliveryDelay = deliveryDelay;
// Create and transfer a new message
testPeer.ExpectTransfer(message =>
{
replacedert.GreaterOrEqual((long) message.MessageAnnotations[SymbolUtil.NMS_DELIVERY_TIME], currentUnixEpochTime);
replacedert.Less((long) message.MessageAnnotations[SymbolUtil.NMS_DELIVERY_TIME], currentUnixEpochTime2);
replacedert.IsTrue(message.Header.Durable);
});
testPeer.ExpectClose();
ITextMessage textMessage = session.CreateTextMessage();
producer.Send(textMessage);
replacedert.AreEqual(MsgDeliveryMode.Persistent, textMessage.NMSDeliveryMode);
connection.Close();
testPeer.WaitForAllMatchersToComplete(1000);
}
}
19
View Source File : MessageDeliveryTimeTest.cs
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
private long CurrentTimeInMillis()
{
return new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds();
}
19
View Source File : AmqpNmsMessageFacadeTest.cs
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
[Test]
public void TestNMSDeliveryTime_Set_ShouldHaveMessageAnnotations()
{
AmqpNmsMessageFacade msg = new AmqpNmsMessageFacade();
Mock<IAmqpConnection> mockAmqpConnection = new Mock<IAmqpConnection>();
msg.Initialize(mockAmqpConnection.Object);
var deliveryTime = DateTime.UtcNow.AddMinutes(2);
msg.DeliveryTime = deliveryTime;
replacedert.AreEqual(new DateTimeOffset(deliveryTime).ToUnixTimeMilliseconds(), msg.MessageAnnotations[SymbolUtil.NMS_DELIVERY_TIME]);
}
19
View Source File : MessageDeliveryTimeTestAsync.cs
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
[Test, Timeout(20_000)]
public async Task TestDeliveryDelayHasItsReflectionInAmqpAnnotations()
{
using (TestAmqpPeer testPeer = new TestAmqpPeer())
{
// Determine current time
TimeSpan deliveryDelay = TimeSpan.FromMinutes(17);
long currentUnixEpochTime = new DateTimeOffset(DateTime.UtcNow + deliveryDelay).ToUnixTimeMilliseconds();
long currentUnixEpochTime2 = new DateTimeOffset(DateTime.UtcNow + deliveryDelay + deliveryDelay).ToUnixTimeMilliseconds();
IConnection connection = await base.EstablishConnectionAsync(testPeer,
serverCapabilities: new Symbol[] {SymbolUtil.OPEN_CAPABILITY_DELAYED_DELIVERY, SymbolUtil.OPEN_CAPABILITY_SOLE_CONNECTION_FOR_CONTAINER});
testPeer.ExpectBegin();
testPeer.ExpectSenderAttach();
ISession session = await connection.CreateSessionAsync(AcknowledgementMode.AutoAcknowledge);
IQueue queue = await session.GetQueueAsync("myQueue");
IMessageProducer producer = await session.CreateProducerAsync(queue);
producer.DeliveryDelay = deliveryDelay;
// Create and transfer a new message
testPeer.ExpectTransfer(message =>
{
replacedert.GreaterOrEqual((long) message.MessageAnnotations[SymbolUtil.NMS_DELIVERY_TIME], currentUnixEpochTime);
replacedert.Less((long) message.MessageAnnotations[SymbolUtil.NMS_DELIVERY_TIME], currentUnixEpochTime2);
replacedert.IsTrue(message.Header.Durable);
});
testPeer.ExpectClose();
ITextMessage textMessage = await session.CreateTextMessageAsync();
await producer.SendAsync(textMessage);
replacedert.AreEqual(MsgDeliveryMode.Persistent, textMessage.NMSDeliveryMode);
await connection.CloseAsync();
testPeer.WaitForAllMatchersToComplete(1000);
}
}
19
View Source File : SeekExtensions.cs
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
public static async ValueTask Seek(this ISeek seeker, DateTime publishTime, CancellationToken cancellationToken = default)
=> await seeker.Seek((ulong) new DateTimeOffset(publishTime).ToUnixTimeMilliseconds(), cancellationToken).ConfigureAwait(false);
19
View Source File : SeekExtensions.cs
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
public static async ValueTask Seek(this ISeek seeker, DateTimeOffset publishTime, CancellationToken cancellationToken = default)
=> await seeker.Seek((ulong) publishTime.ToUnixTimeMilliseconds(), cancellationToken).ConfigureAwait(false);
19
View Source File : MessageMetadataExtensions.cs
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
public static void SetDeliverAtTime(this Metadata metadata, DateTimeOffset timestamp)
=> metadata.DeliverAtTime = timestamp.ToUnixTimeMilliseconds();
19
View Source File : MessageMetadataExtensions.cs
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
public static void SetEventTime(this Metadata metadata, DateTimeOffset timestamp)
=> metadata.EventTime = (ulong) timestamp.ToUnixTimeMilliseconds();
19
View Source File : TimestampSchema.cs
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
public ReadOnlySequence<byte> Encode(DateTime message)
{
var milliseconds = new DateTimeOffset(message).ToUnixTimeMilliseconds();
return Schema.Int64.Encode(milliseconds);
}
19
View Source File : ProducerChannel.cs
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
public async Task<CommandSendReceipt> Send(MessageMetadata metadata, ReadOnlySequence<byte> payload, CancellationToken cancellationToken)
{
var sendPackage = _sendPackagePool.Get();
try
{
metadata.PublishTime = (ulong) DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
metadata.ProducerName = _name;
if (metadata.SchemaVersion is null && _schemaVersion is not null)
metadata.SchemaVersion = _schemaVersion;
if (sendPackage.Command is null)
{
sendPackage.Command = new CommandSend
{
ProducerId = _id,
NumMessages = 1
};
}
sendPackage.Command.SequenceId = metadata.SequenceId;
sendPackage.Metadata = metadata;
if (_compressorFactory is null)
sendPackage.Payload = payload;
else
{
sendPackage.Metadata.Compression = _compressorFactory.CompressionType;
sendPackage.Metadata.UncompressedSize = (uint) payload.Length;
using var compressor = _compressorFactory.Create();
sendPackage.Payload = compressor.Compress(payload);
}
var response = await _connection.Send(sendPackage, cancellationToken).ConfigureAwait(false);
response.Expect(BaseCommand.Type.SendReceipt);
return response.SendReceipt;
}
finally
{
_sendPackagePool.Return(sendPackage);
}
}
19
View Source File : AggregateRoot.cs
License : MIT License
Project Creator : ARKlab
License : MIT License
Project Creator : ARKlab
protected virtual void Emit<TEvent>(TEvent aggregateEvent, IDictionary<string,string> metadata = null)
where TEvent : clreplaced, IAggregateEvent<TAggregate>
{
Ensure.Any.IsNotNull(aggregateEvent, nameof(aggregateEvent));
if (_applying)
throw new InvalidOperationException("Emit shall not be called during Apply phase. Do it before or after Emitting an event");
var aggregateSequenceNumber = Version + 1;
var eventId = $"{Name}/{Identifier}/{aggregateSequenceNumber:D20}";
var now = DateTimeOffset.Now;
IMetadata eventMetadata = new Metadata
{
Timestamp = now,
AggregateVersion = aggregateSequenceNumber,
AggregateName = Name,
AggregateId = Identifier,
EventId = eventId,
EventName = AggregateHelper<TAggregate>.EventHelper<TEvent>.Name,
//EventVersion = AggregateHelper<TAggregate>.EventHelper<TEvent>.Version,
TimestampEpoch = now.ToUnixTimeMilliseconds()
};
if (metadata != null)
{
eventMetadata = eventMetadata.CloneWith(metadata);
}
var uncommittedEvent = new AggregateEventEnvelope<TAggregate>(aggregateEvent, eventMetadata);
_apply(uncommittedEvent);
_uncommittedAggregateEvents.Add(uncommittedEvent);
}
19
View Source File : AggregateRoot.cs
License : MIT License
Project Creator : ARKlab
License : MIT License
Project Creator : ARKlab
protected virtual void Publish<TEvent>(TEvent domainEvent, IMetadata metadata = null)
where TEvent : clreplaced, IDomainEvent
{
Ensure.Any.IsNotNull(domainEvent, nameof(domainEvent));
if (_applying)
throw new InvalidOperationException("Publish shall not be called during Apply phase. Do it before or after Emitting an event");
var now = DateTimeOffset.Now;
var eventMetadata = new Metadata
{
Timestamp = now,
EventId = Guid.NewGuid().ToString(),
TimestampEpoch = now.ToUnixTimeMilliseconds(),
AggregateVersion = Version,
AggregateName = Name,
AggregateId = Identifier,
};
if (metadata != null)
{
eventMetadata.CloneWith(metadata.Values);
}
_uncommittedDomainEvents.Add(new DomainEventEnvelope(domainEvent, eventMetadata));
}
19
View Source File : Utility.cs
License : Apache License 2.0
Project Creator : awslabs
License : Apache License 2.0
Project Creator : awslabs
public static long ToEpochMilliseconds(DateTime utcTime) => new DateTimeOffset(utcTime).ToUnixTimeMilliseconds();
19
View Source File : ICibRate.cs
License : GNU Affero General Public License v3.0
Project Creator : b11p
License : GNU Affero General Public License v3.0
Project Creator : b11p
public async static Task<CibRate> GetRates(this ICibRate cibRate)
{
await cibRate.Prepare().ConfigureAwait(false);
return await cibRate.GetRates(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()).ConfigureAwait(false);
}
19
View Source File : 称金币.ExecuteInfo.cs
License : GNU Affero General Public License v3.0
Project Creator : b11p
License : GNU Affero General Public License v3.0
Project Creator : b11p
private static bool GetRandomBool() => DateTimeOffset.Now.ToUnixTimeMilliseconds() % 2 == 0;
19
View Source File : Extensions.cs
License : GNU General Public License v3.0
Project Creator : BardMusicPlayer
License : GNU General Public License v3.0
Project Creator : BardMusicPlayer
public static long ToUtcMilliTime(this DateTimeOffset given) => given.ToUnixTimeMilliseconds();
19
View Source File : ClientRegistriesDelegate.cs
License : Apache License 2.0
Project Creator : bcgov
License : Apache License 2.0
Project Creator : bcgov
private static HCIM_IN_GetDemographicsRequest CreateRequest(OIDType oidType, string identifierValue)
{
using (Source.StartActivity("CreatePatientSOAPRequest"))
{
HCIM_IN_GetDemographics request = new HCIM_IN_GetDemographics();
request.id = new II() { root = "2.16.840.1.113883.3.51.1.1.1", extension = DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString(System.Globalization.CultureInfo.InvariantCulture) };
request.creationTime = new TS() { value = System.DateTime.Now.ToString("yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture) };
request.versionCode = new CS() { code = "V3PR1" };
request.interactionId = new II() { root = "2.16.840.1.113883.3.51.1.1.2", extension = "HCIM_IN_GetDemographics" };
request.processingCode = new CS() { code = "P" };
request.processingModeCode = new CS() { code = "T" };
request.acceptAckCode = new CS() { code = "NE" };
request.receiver = new MCCI_MT000100Receiver() { typeCode = "RCV" };
request.receiver.device = new MCCI_MT000100Device() { determinerCode = "INSTANCE", clreplacedCode = "DEV" };
request.receiver.device.id = new II() { root = "2.16.840.1.113883.3.51.1.1.4", extension = "192.168.0.1" };
request.receiver.device.asAgent = new MCCI_MT000100Agent() { clreplacedCode = "AGNT" };
request.receiver.device.asAgent.representedOrganization = new MCCI_MT000100Organization() { determinerCode = "INSTANCE", clreplacedCode = "ORG" };
request.receiver.device.asAgent.representedOrganization = new MCCI_MT000100Organization() { determinerCode = "INSTANCE", clreplacedCode = "ORG" };
request.receiver.device.asAgent.representedOrganization.id = new II() { root = "2.16.840.1.113883.3.51.1.1.3", extension = "HCIM" };
request.sender = new MCCI_MT000100Sender() { typeCode = "SND" };
request.sender.device = new MCCI_MT000100Device() { determinerCode = "INSTANCE", clreplacedCode = "DEV" };
request.sender.device.id = new II() { root = "2.16.840.1.113883.3.51.1.1.5", extension = "MOH_CRS" };
request.sender.device.asAgent = new MCCI_MT000100Agent() { clreplacedCode = "AGNT" };
request.sender.device.asAgent.representedOrganization = new MCCI_MT000100Organization() { determinerCode = "INSTANCE", clreplacedCode = "ORG" };
request.sender.device.asAgent.representedOrganization = new MCCI_MT000100Organization() { determinerCode = "INSTANCE", clreplacedCode = "ORG" };
request.sender.device.asAgent.representedOrganization.id = new II() { root = "2.16.840.1.113883.3.51.1.1.3", extension = "HGWAY" };
request.controlActProcess = new HCIM_IN_GetDemographicsQUQI_MT020001ControlActProcess() { clreplacedCode = "ACCM", moodCode = "EVN" };
request.controlActProcess.effectiveTime = new IVL_TS() { value = System.DateTime.Now.ToString("yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture) };
request.controlActProcess.dataEnterer = new QUQI_MT020001DataEnterer() { typeCode = "CST", time = null, typeId = null };
request.controlActProcess.dataEnterer.replacedignedPerson = new COCT_MT090100replacedignedPerson() { clreplacedCode = "ENT" };
request.controlActProcess.dataEnterer.replacedignedPerson.id = new II() { root = "2.16.840.1.113883.3.51.1.1.7", extension = "HLTHGTWAY" };
request.controlActProcess.queryByParameter = new HCIM_IN_GetDemographicsQUQI_MT020001QueryByParameter();
request.controlActProcess.queryByParameter.queryByParameterPayload = new HCIM_IN_GetDemographicsQueryByParameterPayload();
request.controlActProcess.queryByParameter.queryByParameterPayload.personid = new HCIM_IN_GetDemographicsPersonid();
request.controlActProcess.queryByParameter.queryByParameterPayload.personid.value = new II() { root = oidType.ToString(), extension = identifierValue, replacedigningAuthorityName = "LCTZ_IAS" };
return new HCIM_IN_GetDemographicsRequest(request);
}
}
19
View Source File : MicrosecondEpochJsonConverter.cs
License : Apache License 2.0
Project Creator : bcgov
License : Apache License 2.0
Project Creator : bcgov
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
{
var date = ((DateTimeOffset)value);
if (date <= DateTime.UtcNow.AddHours(1))
{
writer.WriteNumberValue(0);
}
else
{
long unixTime = date.ToUnixTimeMilliseconds();
writer.WriteNumberValue(unixTime);
}
}
19
View Source File : ScriptDataDate.cs
License : GNU General Public License v3.0
Project Creator : Bililive
License : GNU General Public License v3.0
Project Creator : Bililive
public void WriteTo(Stream stream)
{
var dateTime = (double)this.Value.ToUnixTimeMilliseconds();
var localDateTimeOffset = (short)this.Value.Offset.TotalMinutes;
var buffer1 = new byte[sizeof(double)];
var buffer2 = new byte[sizeof(ushort)];
BinaryPrimitives.WriteInt64BigEndian(buffer1, BitConverter.DoubleToInt64Bits(dateTime));
BinaryPrimitives.WriteInt16BigEndian(buffer2, localDateTimeOffset);
stream.WriteByte((byte)this.Type);
stream.Write(buffer1);
stream.Write(buffer2);
}
19
View Source File : AbstractMainchainState.cs
License : GNU Affero General Public License v3.0
Project Creator : blockbasenetwork
License : GNU Affero General Public License v3.0
Project Creator : blockbasenetwork
protected virtual bool IsTimeUpForSidechainPhase(long sidechainPhaseEndDate, int deltaToExecuteTransactions)
{
return sidechainPhaseEndDate * 1000 - deltaToExecuteTransactions <= DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
}
See More Examples