public async ValueTask <List <OrderInfo> > GetMoneyForPeriod(DateOrder date) { try { var result = await connection.QueryAsync <City, Store, Product, OrderInfo, OrderInfo>( SpName.GetMoneyForPeriod, (city, store, product, orderinfo) => { OrderInfo newOrderInfo = orderinfo; orderinfo.Store = store; store.City = city; newOrderInfo.Product = product; return(newOrderInfo); }, new { date.StartDate, date.EndDate }, commandType : CommandType.StoredProcedure, splitOn : "Id"); return(result.ToList()); } catch (SqlException ex) { throw ex; } }
public override void Validate() { ClearMessageValidation(); if (DateOrder.Equals(DateTime.MinValue) || DateOrder.Equals(DateTime.MaxValue)) { AddMessageCritical("Critica - Data do pedido não informada."); } if (UserId == 0) { AddMessageCritical("Critica - Usuário do pedido não informado."); } if (PreviousDeliveryDate.Equals(DateTime.MinValue) || PreviousDeliveryDate.Equals(DateTime.MaxValue)) { AddMessageCritical("Critica - Data de previsão de entrega não informada."); } if (string.IsNullOrEmpty(CEP)) { AddMessageCritical("Critica - CEP não informado."); } if (string.IsNullOrEmpty(Estate)) { AddMessageCritical("Critica - Estado não informado."); } if (string.IsNullOrEmpty(City)) { AddMessageCritical("Critica - Cidade não informada."); } if (string.IsNullOrEmpty(FullAddress)) { AddMessageCritical("Critica - Endereço completo não informado."); } if (string.IsNullOrEmpty(Number)) { AddMessageCritical("Critica - Número não informado."); } if (!ItemOrders.Any()) { AddMessageCritical("Critica - Pedido deve ter pelo menos um item."); } if (FormPaymentId == 0) { AddMessageCritical("Critica - Forma de Pagamento não informada."); } }
public Customer() { Name = "Jirka"; Surname = ""; Email = ""; Phone = ""; BirthYear = ""; Description = ""; OrderDate = new DateOrder(); OrderTime = 0; DoctorID = 0; ID = 0; Description = "df"; }
public LogsRequest( int?roundId, HashSet <LogType>?types, HashSet <LogImpact>?impacts, DateTime?before, DateTime?after, Guid[]?anyPlayers, Guid[]?allPlayers, int?lastLogId, DateOrder dateOrder) { RoundId = roundId; Types = types; Impacts = impacts; Before = before; After = after; AnyPlayers = anyPlayers is { Length : > 0 } ? anyPlayers : null;
public async Task DownloadAsync( string symbol, Interval interval, OutputSize outputSize, DirectoryInfo directoryInfo, DateOrder dateOrder, bool timestampFiles = false, string apiKey = "demo") { Console.WriteLine($"Downloading: {symbol}"); var func = ToFunctionIntervalQueryValues(interval); var output = outputSize.ToString().ToLower(); var uri = $"https://www.alphavantage.co/query?{func}&symbol={symbol}&outputsize={output}&datatype=csv&apikey={apiKey}"; var response = await _client.GetAsync(uri); if (!response.IsSuccessStatusCode) { Console.WriteLine($"Failed download for: {symbol}. StatusCode: {response.StatusCode}, Content: {response.Content}"); return; } Console.WriteLine($"Saving: {symbol}"); if (!directoryInfo.Exists) { directoryInfo.Create(); } var data = await response.Content.ReadAsStringAsync(); if (dateOrder == DateOrder.Ascending) { var dataRows = data.Split(Environment.NewLine); data = $"{dataRows[0]}{string.Join(Environment.NewLine, dataRows.Skip(1).Reverse())}"; } var timestampString = timestampFiles ? "_" + DateTime.UtcNow.ToFileTimeUtc() : string.Empty; var fileName = $"{symbol}{timestampString}"; var path = Path.Combine(directoryInfo.FullName, $"{fileName}.csv"); await File.WriteAllTextAsync(path, data); Console.WriteLine($"Stored: {symbol}"); }
public static bool IsDate(string dateString, bool allowNull, out DateTime?date, DateOrder dateOrder, bool pIncludeTime) { date = null; dateString = dateString.Trim(); if (dateString == "") { if (allowNull == true) { return(true); } else { return(false); } } /// string[] datePartsTemp = dateString.Split(new char[] { ' ', '/', '-', '.', ',', '\'', ':', '\\' }, StringSplitOptions.RemoveEmptyEntries); if (datePartsTemp.Length > 8) { return(false); //throw new Exception("Date format is invalid: " + dateString + ". Supported format is d/m/y h:m:s.ms AMPM"); } string[] dateParts = new string[8] { "", "", "", "", "", "", "", "" }; /// int i = 0; string AMPM = ""; foreach (string dpart in datePartsTemp) { if (dpart == "AM" || dpart == "PM") { AMPM = dpart; } else { dateParts[i] = dpart; i++; } } dateParts[7] = AMPM; int year = 0, month = 0, date_of_month = 0, hour = 0, minute = 0, second = 0, millisecond = 0; DateTime vNow = DateTime.Now; try { if (dateOrder == DateOrder.D_M_Y) { date_of_month = Global.ToInteger(dateParts[0]); month = GetMonthNumber(dateParts[1]); year = Global.ToInteger(dateParts[2]); } else if (dateOrder == DateOrder.M_Y) { date_of_month = 1; month = GetMonthNumber(dateParts[0]); year = Global.ToInteger(dateParts[1]); } } catch (FormatException) { return(false); } if (date_of_month <= 0 || date_of_month >= 32) { date_of_month = vNow.Day; } if (month <= 0 || month >= 13) { month = vNow.Month; } if (year == 0) { year = vNow.Year; } else if (year < 50) { year += 2000; } else if (year < 100) { year += 1900; } else if (year < 1000) { year += 1000; } hour = Global.ToInteger(dateParts[3]); if (dateParts[7] == "AM" && hour == 12) { hour = 0; } else if (dateParts[7] == "PM" && hour != 12) { hour = hour + 12; } minute = Global.ToInteger(dateParts[4]); second = Global.ToInteger(dateParts[5]); millisecond = Global.ToInteger(dateParts[6]); try { if (pIncludeTime == true) { date = new DateTime(year, month, date_of_month, hour, minute, second, millisecond); } else { date = new DateTime(year, month, date_of_month); } } catch (ArgumentOutOfRangeException) { return(false); } return(true); /* * dateString = dateString.Trim(); * date = default(DateTime); * * if (dateString == "") * { * if (allowNull == true) * { * return true; * } * else * { * return false; * } * } * else * { * CultureInfo enUS = new CultureInfo("en-US"); * string[] dateStyles = new string[] { "dd/MM/yyyy", "dd/MM/yy", "dd/MM/y", "d/M/y", "d/M/yy", "d/M/yyyy", "dd/M/y", "dd/M/yy", "dd/M/yyyy", "d/MM/y", "d/MM/yy", "d/MM/yyyy", "d/MMM/yy", "dd/MMM/yy" }; * if (DateTime.TryParseExact(dateString, dateStyles, enUS, DateTimeStyles.None, out date) == true) * { * return true; * } * else * { * return false; * } * } */ }
public static bool IsDate(string dateString, bool allowNull, out DateTime?date, DateOrder dateOrder) { return(IsDate(dateString, allowNull, out date, dateOrder, false)); }
public async Task Date(DateOrder order) { await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true }); var server = pairTracker.Pair.Server; var sEntities = server.ResolveDependency <IEntityManager>(); var sAdminLogSystem = server.ResolveDependency <IAdminLogManager>(); var commonGuid = Guid.NewGuid(); var firstGuid = Guid.NewGuid(); var secondGuid = Guid.NewGuid(); var testMap = await PoolManager.CreateTestMap(pairTracker); var coordinates = testMap.GridCoords; await server.WaitPost(() => { var entity = sEntities.SpawnEntity(null, coordinates); sAdminLogSystem.Add(LogType.Unknown, $"{entity:Entity} test log: {commonGuid} {firstGuid}"); }); await Task.Delay(2000); await server.WaitPost(() => { var entity = sEntities.SpawnEntity(null, coordinates); sAdminLogSystem.Add(LogType.Unknown, $"{entity:Entity} test log: {commonGuid} {secondGuid}"); }); await PoolManager.WaitUntil(server, async() => { var commonGuidStr = commonGuid.ToString(); string firstGuidStr; string secondGuidStr; switch (order) { case DateOrder.Ascending: // Oldest first firstGuidStr = firstGuid.ToString(); secondGuidStr = secondGuid.ToString(); break; case DateOrder.Descending: // Newest first firstGuidStr = secondGuid.ToString(); secondGuidStr = firstGuid.ToString(); break; default: throw new ArgumentOutOfRangeException(nameof(order), order, null); } var firstFound = false; var secondFound = false; var both = await sAdminLogSystem.CurrentRoundLogs(new LogFilter { Search = commonGuidStr, DateOrder = order }); foreach (var log in both) { if (!log.Message.Contains(commonGuidStr)) { continue; } if (!firstFound) { Assert.That(log.Message, Does.Contain(firstGuidStr)); firstFound = true; continue; } Assert.That(log.Message, Does.Contain(secondGuidStr)); secondFound = true; break; } return(firstFound && secondFound); }); await pairTracker.CleanReturnAsync(); }
public async Task Date(DateOrder order) { var server = StartServer(new ServerContentIntegrationOption { CVarOverrides = { [CCVars.AdminLogsQueueSendDelay.Name] = "0" }, Pool = true }); await server.WaitIdleAsync(); var sEntities = server.ResolveDependency <IEntityManager>(); var sMaps = server.ResolveDependency <IMapManager>(); var sSystems = server.ResolveDependency <IEntitySystemManager>(); var sAdminLogSystem = sSystems.GetEntitySystem <AdminLogSystem>(); var commonGuid = Guid.NewGuid(); var firstGuid = Guid.NewGuid(); var secondGuid = Guid.NewGuid(); await server.WaitPost(() => { var coordinates = GetMainEntityCoordinates(sMaps); var entity = sEntities.SpawnEntity(null, coordinates); sAdminLogSystem.Add(LogType.Unknown, $"{entity:Entity} test log: {commonGuid} {firstGuid}"); }); await Task.Delay(2000); await server.WaitPost(() => { var coordinates = GetMainEntityCoordinates(sMaps); var entity = sEntities.SpawnEntity(null, coordinates); sAdminLogSystem.Add(LogType.Unknown, $"{entity:Entity} test log: {commonGuid} {secondGuid}"); }); await WaitUntil(server, async() => { var commonGuidStr = commonGuid.ToString(); string firstGuidStr; string secondGuidStr; switch (order) { case DateOrder.Ascending: // Oldest first firstGuidStr = firstGuid.ToString(); secondGuidStr = secondGuid.ToString(); break; case DateOrder.Descending: // Newest first firstGuidStr = secondGuid.ToString(); secondGuidStr = firstGuid.ToString(); break; default: throw new ArgumentOutOfRangeException(nameof(order), order, null); } var firstFound = false; var secondFound = false; var both = await sAdminLogSystem.CurrentRoundLogs(new LogFilter { Search = commonGuidStr, DateOrder = order }); foreach (var log in both) { if (!log.Message.Contains(commonGuidStr)) { continue; } if (!firstFound) { Assert.That(log.Message, Does.Contain(firstGuidStr)); firstFound = true; continue; } Assert.That(log.Message, Does.Contain(secondGuidStr)); secondFound = true; break; } return(firstFound && secondFound); }); }
public async ValueTask <RequestResult <List <OrderInfo> > > GetMoneyForPeriod(DateOrder date) { var result = new RequestResult <List <OrderInfo> >(); try { result.RequestData = await _reportStorage.GetMoneyForPeriod(date); result.IsOkay = true; } catch (Exception ex) { result.ExMessage = ex.Message; } return(result); }