Last active
October 25, 2018 03:04
-
-
Save danieleli/a59d23be06ffbe176b007e43522a2e98 to your computer and use it in GitHub Desktop.
SendBol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Batch() | |
{ | |
var batchOne = GetBatch(1000, "Origin1", "Dest1", "Carrier1", DateTime.Now.AddDays(-1), DateTime.Now.AddHours(-1)); | |
foreach (var item in batchOne) | |
{ | |
SendBol(item); | |
} | |
var threadId = Thread.CurrentThread.ManagedThreadId; | |
for (int i = 0; i < 20; i++) | |
{ | |
Thread.Sleep(TimeSpan.FromSeconds(1)); | |
_output.WriteLine("thread: " + threadId + ", debug: " + i); | |
} | |
} | |
private List<BolConstraint> GetBatch(int count, string origin, string dest, string carrierId, DateTime puDate, DateTime timestamp) | |
{ | |
var rtn = new List<BolConstraint>(); | |
for (int i = 0; i < count; i++) | |
{ | |
var item = new BolConstraint | |
{ | |
Origin = "origin1", | |
Destination = "dest1", | |
CarrierId = "2", | |
PickupDate = new DateTime(2018, 10, 1), | |
Timestamp = DateTime.Now | |
}; | |
rtn.Add(item); | |
} | |
return rtn; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BolConstraint | |
{ | |
public string Origin; | |
public string Destination; | |
public string CarrierId; | |
public DateTime PickupDate; | |
public DateTime Timestamp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Temp | |
{ | |
private readonly ITestOutputHelper _output; | |
public Temp(ITestOutputHelper output) | |
{ | |
_output = output; | |
} | |
[Fact] | |
public void First() | |
{ | |
var item = new BolConstraint | |
{ | |
Origin = "origin1", | |
Destination = "dest1", | |
CarrierId = "1", | |
PickupDate = new DateTime(2018, 10, 1), | |
Timestamp = DateTime.Now | |
}; | |
SendBol(item); | |
for (int i = 0; i < 20; i++) | |
{ | |
Thread.Sleep(TimeSpan.FromSeconds(1)); | |
_output.WriteLine("debug: " + i); | |
} | |
} | |
async Task SendBol(BolConstraint constraint) | |
{ | |
await Task.Delay(TimeSpan.FromMinutes(15)) | |
.ConfigureAwait(false); | |
// get records based on constraint | |
// send records as bol with single shipperShipmentId | |
// update records | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void Second() | |
{ | |
var item1 = new BolConstraint | |
{ | |
Origin = "origin1", | |
Destination = "dest1", | |
CarrierId = "1", | |
PickupDate = new DateTime(2018, 10, 1), | |
Timestamp = DateTime.Now | |
}; | |
var item2 = new BolConstraint | |
{ | |
Origin = "origin1", | |
Destination = "dest1", | |
CarrierId = "2", | |
PickupDate = new DateTime(2018, 10, 1), | |
Timestamp = DateTime.Now | |
}; | |
SendBol(item1); | |
SendBol(item2); | |
var threadId = Thread.CurrentThread.ManagedThreadId; | |
for (int i = 0; i < 20; i++) | |
{ | |
Thread.Sleep(TimeSpan.FromSeconds(1)); | |
_output.WriteLine("thread: " + threadId + ", debug: " + i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment