private void uiCleanUp_Tick(ThreadPoolTimer timer) { if (Now.Subtract(_lastExceptionReceived.GetValueOrDefault()).TotalMilliseconds > 2900) { UpdateErrorMessageBox("No Recent Exceptions Received"); } }
public void Comparer() { var v1 = Type.Seed(null); var v2 = Now.Subtract(TimeSpan.FromTicks(DateAccuracyInTicks)); Assert.That(() => Type.Comparator.Compare(v1, v2), Throws.Nothing); }
public async Task ComparerAsync() { var v1 = await(Type.SeedAsync(null, CancellationToken.None)); var v2 = Now.Subtract(TimeSpan.FromTicks(DateAccuracyInTicks)); Assert.That(() => Type.Comparator.Compare(v1, v2), Throws.Nothing); }
internal (Products prod, int totalMilliseconds) GetProduct(int id) { Products result = null; using (var sqlCommand = new SqlCommand($"SELECT * FROM Products WHERE ProductID = {id}", _conn)) { sqlCommand.CommandText = sqlCommand.CommandText; var ds = new DataSet(); var da = new SqlDataAdapter(sqlCommand.CommandText, _conn); da.Fill(ds, "Products"); result = ds .Tables[0] .AsEnumerable() .Select(s => new Products() { ProductId = (int)s["ProductID"], ProductName = s["ProductName"].ToString(), SupplierId = (int?)s["SupplierID"], CategoryId = (int?)s["CategoryID"], QuantityPerUnit = s["QuantityPerUnit"].ToString(), UnitPrice = (decimal?)s["UnitPrice"], UnitsInStock = (short?)s["UnitsInStock"], UnitsOnOrder = (short?)s["UnitsOnOrder"], ReorderLevel = (short?)s["ReorderLevel"], Discontinued = (bool)s["Discontinued"] }) .FirstOrDefault(); } return(result, DateTime.Now.Subtract(_dateBegin).Milliseconds); }
internal (IList <Suppliers> list, int totalMilliseconds) GetSuppliersByCountryFK_OneToMany(string country) { IList <Suppliers> result = null; using (var sqlCommand = new SqlCommand($"SELECT * FROM Suppliers s JOIN Products p ON p.SupplierID = s.SupplierID AND s.Country = '{country}'", _conn)) { sqlCommand.CommandText = sqlCommand.CommandText; var ds = new DataSet(); var da = new SqlDataAdapter(sqlCommand.CommandText, _conn); da.Fill(ds, "Products"); result = ds .Tables[0] .AsEnumerable() .Select(s => new Suppliers() { SupplierId = (int)s["SupplierID"], CompanyName = s["CompanyName"].ToString(), ContactName = s["ContactName"].ToString(), ContactTitle = s["ContactTitle"].ToString(), Address = s["Address"].ToString(), City = s["City"].ToString(), Region = s["Region"].ToString(), PostalCode = s["PostalCode"].ToString(), Country = s["Country"].ToString(), Phone = s["Phone"].ToString(), Fax = s["Fax"].ToString(), HomePage = s["HomePage"].ToString() }) .GroupBy(g => g.SupplierId) .Select(s => s.FirstOrDefault()) .ToList(); foreach (var row in result) { row.Products = ds .Tables[0] .AsEnumerable() .Where(w => (int)w["SupplierID"] == row.SupplierId) .Select(s => new Products() { ProductId = (int)s["ProductID"], ProductName = s["ProductName"].ToString(), SupplierId = (int?)s["SupplierID"], CategoryId = (int?)s["CategoryID"], QuantityPerUnit = s["QuantityPerUnit"].ToString(), UnitPrice = (decimal?)s["UnitPrice"], UnitsInStock = (short?)s["UnitsInStock"], UnitsOnOrder = (short?)s["UnitsOnOrder"], ReorderLevel = (short?)s["ReorderLevel"], Discontinued = (bool)s["Discontinued"], }) .ToList(); } } return(result, DateTime.Now.Subtract(_dateBegin).Milliseconds); }
public void Next() { // Take some margin, as DbTimestampType takes its next value from the database, which // may have its clock a bit shifted even if running on the same server. (Seen with PostgreSQL, // off by a few seconds, and with SAP HANA running in a vm, off by twenty seconds.) var current = Now.Subtract(TimeSpan.FromMinutes(2)); var next = Type.Next(current, null); Assert.That(next, Is.TypeOf <DateTime>(), "next should be DateTime"); Assert.That(next, Is.GreaterThan(current), "next should be greater than current"); }
// 最初の 1 秒で LastFullMoon を求める void Init() { // 満月基準日を 2018/08/01 01:55 とする(wiki より) DateTime reference = new DateTime(2018, 8, 1, 1, 55, 0); // 現在時刻との差を求める TimeSpan span = Now.Subtract(reference); // 分に換算 double min = span.TotalMinutes; // 118 で割って切り捨て int div = (int)Math.Floor(min / INTERVAL_MINUTES); // 最終満月を求める LastFullMoon = reference.AddMinutes(INTERVAL_MINUTES * div); }
public (IList <Products> prods, int totalMilliseconds) GetProductsByNameWithFk(string name) { IList <Products> result = null; using (var sqlCommand = new SqlCommand($"SELECT * FROM Products p Inner JOIN Suppliers s ON s.SupplierID = p.SupplierID WHERE p.ProductName = '{name}'", _conn)) { sqlCommand.CommandText = sqlCommand.CommandText; var ds = new DataSet(); var da = new SqlDataAdapter(sqlCommand.CommandText, _conn); da.Fill(ds, "Products"); result = ds .Tables[0] .AsEnumerable() .Select(s => new Products() { ProductId = (int)s["ProductID"], ProductName = s["ProductName"].ToString(), SupplierId = (int?)s["SupplierID"], CategoryId = (int?)s["CategoryID"], QuantityPerUnit = s["QuantityPerUnit"].ToString(), UnitPrice = (decimal?)s["UnitPrice"], UnitsInStock = (short?)s["UnitsInStock"], UnitsOnOrder = (short?)s["UnitsOnOrder"], ReorderLevel = (short?)s["ReorderLevel"], Discontinued = (bool)s["Discontinued"], Supplier = new Suppliers() { SupplierId = (int)s["SupplierID"], CompanyName = s["CompanyName"].ToString(), ContactName = s["ContactName"].ToString(), ContactTitle = s["ContactTitle"].ToString(), Address = s["Address"].ToString(), City = s["City"].ToString(), Region = s["Region"].ToString(), PostalCode = s["PostalCode"].ToString(), Country = s["Country"].ToString(), Phone = s["Phone"].ToString(), Fax = s["Fax"].ToString(), HomePage = s["HomePage"].ToString() } }) .ToList(); } return(result, DateTime.Now.Subtract(_dateBegin).Milliseconds); }
public void Initialize(DateTime dateTime) { now = dateTime; // 満月基準日を 2018/08/01 01:55 とする(wiki より) DateTime reference = new DateTime(2018, 8, 1, 1, 55, 0); // 現在時刻との差を求める TimeSpan span = Now.Subtract(reference); // 分に換算 double min = span.TotalMinutes; // 118 で割って切り捨て int div = (int)Math.Floor(min / INTERVAL_MINUTES); // 最終満月を求める LastFullMoon = reference.AddMinutes(INTERVAL_MINUTES * div); // タイマー用の設定 lastMessage = LastFullMoon.AddMinutes(MESSAGE_MINUTES); lastSnooze = LastFullMoon.AddMinutes(SNOOZE_MINUTES); lastEnded = LastFullMoon.AddMinutes(TEN_MINUTES); }
public double CalculateFractionOfSecond(DateTime from) { return(Now.Subtract(from.ToUniversalTime()).Milliseconds / 1000.0); }