public void Can_Add_Hours() { Time time = new Time(12,30); time = time.AddHours(1); Assert.AreEqual(13,time.Hour); Assert.AreEqual(30,time.Minute); time = time.AddHours(11); Assert.AreEqual(0,time.Hour); }
static void WriteDailyTicks(TeaFile<Tick> tf, Time day, bool isGoodDay) { Time t = day.AddHours(9); // start trading session at 09:00 Time end = day.AddHours(17.5); // end trading session at 17:30 while (t < end) { // on a good day, we write many ticks, on a bad day however only 1 percent as much if (isGoodDay || DrawRandom(1)) { double p = r.NextDouble() * 100000.0; tf.Write(new Tick {Time = t, Price = p, Volume = 10}); } t = t.AddSeconds(15 + r.Next(0, 20)); } }
public void CanAddPositiveTime() { Time startTime = new Time(12, 0); Time actual = startTime.AddHours(13); Time expected = new Time(1, 0); Assert.Equal(expected, actual); }
public TimeStampRecord(string rec, DateTime flightdate) : base(rec) { Time = flightdate.Date; Time = Time.AddHours(Convert.ToInt32(rec.Substring(1, 2))); Time = Time.AddMinutes(Convert.ToInt32(rec.Substring(3, 2))); Time = Time.AddSeconds(Convert.ToInt32(rec.Substring(5, 2))); }
static void WriteDailyTicks(TeaFile <Tick> tf, Time day, bool isGoodDay) { Time t = day.AddHours(9); // start trading session at 09:00 Time end = day.AddHours(17.5); // end trading session at 17:30 while (t < end) { // on a good day, we write many ticks, on a bad day however only 1 percent as much if (isGoodDay || DrawRandom(1)) { double p = r.NextDouble() * 100000.0; tf.Write(new Tick { Time = t, Price = p, Volume = 10 }); } t = t.AddSeconds(15 + r.Next(0, 20)); } }
public void AddHourMoreThan_23_hour() { int hour = 1; int mins = 0; int second = 0; var target = new Time(hour, mins, second); int hour1 = 29; target = target.AddHours(hour1); Assert.AreEqual("6:0:0", target.ToString()); }
public void AddHours_ZeroHoursArgument_ShouldReturnCorrectTime() { // Arrange Time time = new Time(); // Act time.AddHours(0); // Assert time.Hours.Should().Be(0); time.Minutes.Should().Be(0); time.Seconds.Should().Be(0); }
public void ShouldAddHours() { // Given const double value = 123.456; var time = new Time(12345); // When var result = time.AddHours(value); // Then Assert.AreEqual(time.TotalSeconds + value * 60 * 60, result.TotalSeconds, TimeInaccuracy); }
public void AddHourTest() { int hour = 1; int mins = 2; int second = 3; var target = new Time(hour, mins, second); int hour1 = 3; target.AddHours(hour1); var expect = new DateTime(1, 1, 1, hour, mins, second); expect.AddHours(hour1); Assert.AreEqual(expect.Ticks, target.Ticks); }
protected override void unpack(BinaryBitReader reader) { Time = START.AddDays(reader.ReadUInt(14)); Time = Time.AddHours(reader.ReadUInt(5)); Time = Time.AddMinutes(reader.ReadUInt(2) * 15); if (reader.ReadBoolean()) { MonthlyBegin = START.AddDays(reader.ReadUInt(14)); MonthlyNext = START.AddDays(reader.ReadUInt(14)); } Balance = (int?)reader.ReadIntNullable(15); Units = (int?)reader.ReadIntNullable(15); Usages = (int?)reader.ReadIntNullable(15); }
public JsonResult ReportCompleto() { if ((Request.QueryString["DtInicio"] != null) && (Request.QueryString["DtFim"] != null)) { if ((Request.QueryString["DtInicio"] != "") && (Request.QueryString["DtFim"] != "")) { DateTime DtInicio = Convert.ToDateTime(Request.QueryString["DtInicio"]); DateTime DtFim = Convert.ToDateTime(Request.QueryString["DtFim"]); int idUsuario = Convert.ToInt32(Request.QueryString["id"]); //Captura o nome de usuario var estrutura = RetornaEstrutura(idUsuario); //Captura a lista var dados = this.dataInterface.BuscaReportHoras(DtInicio, DtFim); //Valida os campos de pesquisa if (dados != null) { foreach (var c in dados) { c.Nome = (c.Nome == null) ? "" : c.Nome; c.Estrutura = (c.Estrutura == null) ? "" : c.Estrutura; c.Funcao = (c.Funcao == null) ? "" : c.Funcao; c.Cliente = (c.Cliente == null) ? "" : c.Cliente; c.Produto = (c.Produto == null) ? "" : c.Produto; c.Id_Projeto = (c.Id_Projeto == null) ? "" : c.Id_Projeto; c.Projeto = (c.Projeto == null) ? "" : c.Projeto; c.Fase_Projeto = (c.Fase_Projeto == null) ? "" : c.Fase_Projeto; c.Atividade = (c.Atividade == null) ? "" : c.Atividade; c.Hora_Inicio = (c.Hora_Inicio == null) ? "" : c.Hora_Inicio; c.Data_Fim = (c.Data_Fim == null) ? "" : c.Data_Fim; c.Hora_Fim = (c.Hora_Fim == null) ? "" : c.Hora_Fim; c.HoraDecimal = (c.HoraDecimal == null) ? "" : c.HoraDecimal; c.Observação = (c.Observação == null) ? "" : c.Observação; c.HoraDecimal = (c.HoraDecimal == null) ? "" : c.HoraDecimal; c.Aprovacao = (c.Aprovacao != null) ? c.Aprovacao : ""; c.Motivo = (c.Motivo != null) ? c.Motivo : ""; c.Data_Inicio = (c.Data_Inicio == null) ? "" : c.Data_Inicio; //Calculo de tempo para o caso de justificativas de mais de 1 dia if (c.Data_Fim != c.Data_Inicio) { int diferenca = (Time.WorkDays(c.Data_Inicio, c.Data_Fim) - 2) * 8; var tempos = Time.TimeSpaces(c.Hora_Inicio, c.Hora_Fim); var res = Time.SumTimes(tempos[0], tempos[1]); c.Tempo = Time.AddHours(res, diferenca); } else { c.Tempo = (c.Tempo == null) ? "" : c.Tempo; } } dados = dados.ToList(); var usr = this.GetUser(idUsuario); var names = dados.Where(x => x.Estrutura.ToLower().Replace(" ", "") == usr.Nome.ToLower().Replace(" ", "")).Select(x => x.Nome).DistinctBy(x => x); var head = usr.Estrutura; var recursos = dados.Where(x => x.Estrutura.ToLower().Replace(" ", "") == usr.Nome.ToLower().Replace(" ", "")); var usuario = dados.Where(x => x.Nome.ToLower().Replace(" ", "") == usr.Nome.ToLower().Replace(" ", "")); return(base.Json(new { Estrutura = head, Nomes = names, Recursos = recursos, UsuarioHoras = usuario, UsuarioNome = usr.Nome }, JsonRequestBehavior.AllowGet)); } else { return(base.Json(new { Content = "" }, JsonRequestBehavior.AllowGet)); } } else { return(base.Json(new { erro = "Erro" }, JsonRequestBehavior.AllowGet)); } } return(base.Json(new { erro = "Erro" }, JsonRequestBehavior.AllowGet)); }
public JsonResult JustificaPonto(int justificativa, int id, int projetoId, int subFaseProjetoId, DateTime dataInicio, DateTime dataFim, string obs) { try { int usuarioId = Convert.ToInt32(Session["IDUSUARIO"]); List <Indigo_HorasProjeto> objn = dataInterface.BuscaHorasProjeto().Where(x => x.hpo_usrId == usuarioId && x.hpo_jtfAprovado == 1 && x.hpo_DataHoraInicio.Value.Month == DateTime.Now.Month).ToList(); var numero = objn.GroupBy(x => x.hpo_jtfSequencia).ToList(); string respEmail = ""; if (numero.Count <= 12) { List <RetornoEstruturaJustifica> retorno = new List <RetornoEstruturaJustifica>(); var obj = new Indigo_HorasProjeto { // hpo_Id = id, hpo_prjId = projetoId, hpo_sfpId = subFaseProjetoId, hpo_usrId = usuarioId, hpo_DataHoraInicio = dataInicio, hpo_DataHoraFim = dataFim, hpo_Observacao = obs, hpo_jtfAprovado = 0 }; retorno = this.dataInterface.IniciaHorasJust(obj, justificativa); string trataHora = ""; if (DateTime.Now.Hour < 12) { trataHora = "Bom dia"; } else if (DateTime.Now.Hour > 12 && DateTime.Now.Hour < 18) { trataHora = "Boa tarde"; } else if (DateTime.Now.Hour > 18) { trataHora = "Boa noite"; } foreach (var just in retorno) { if (just.DataInicio != just.DataFim) { int diferenca = (Time.WorkDays(just.DataInicio, just.DataFim) - 2) * 8; var tempos = Time.TimeSpaces(just.HoraInicio, just.HoraFim); var res = Time.SumTimes(tempos[0], tempos[1]); just.Tempo = Time.AddHours(res, diferenca); } else { just.Tempo = (just.Tempo == null) ? "" : just.Tempo; } StringBuilder pagina = new StringBuilder(); pagina.Append(@"<!DOCTYPE html> <html> <head> <title> Ponto justificado</title> </head> <body> <style> .Aprova { background: #1886cf; } .Negar { background: #e52525; } table { font-family: 'Helvetica Neue', sans-serif; border-bottom: 1px solid #555; border-top: 1px solid black; } table td { color: #555; padding: 1em; } .btn-container { text-align: center; margin-top: 1em; } .btn-container a { padding: 1em; border-radius: 3px; margin-top: 1em; color: white; font - size: 16px; text - transform: uppercase; } table th { font-weight: bolder; } </style> <p>" + just.NomeEstrutura + ", " + trataHora + @" </p> <p> Você tem uma justificativa de horas de projetos registrada por " + just.Nome + @", abaixo detalhes:</p> <table align = ""center""> <th> Nome </th> <th> Justificativa </th> <th> Data Início </th> <th> Hora Início </th> <th> Data Fim </th> <th> Hora Fim </th> <th> Tempo </th> <th> Cliente </th> <th> Produto </th> <th> Projeto </th> <th> Fase Projeto </th> <th> Atividade </th> <th> Observação </th> <tr> <td>" + just.Nome + @"</td> <td>" + just.Justificativa + @"</td> <td>" + just.DataInicio + @"</td> <td>" + just.HoraInicio + @"</td> <td>" + just.DataFim + @"</td> <td>" + just.HoraFim + @"</td> <td>" + just.Tempo + @"</td> <td>" + just.Cliente + @"</td> <td>" + just.Produto + @"</td> <td>" + just.Projeto + @"</td> <td>" + just.Fase_Projeto + @"</td> <td>" + just.Atividade + @"</td> <td>" + just.Observacao + @"</td> </tr> </table> <div class=""btn-container""> <a class=""Aprova"" href =""http://admin.indigosoft.biz/HorasProjeto/ProcessaJustificativa?id=" + usuarioId + "&jtfid=1&dao=" + dataInicio.ToString("yyyy-MM-dd") + "&daf=" + dataFim.ToString("yyyy-MM-dd") + "&justid=" + justificativa + @""" style=""text-decoration:none;"">APROVAR</a> <a class=""Negar"" href =""http://admin.indigosoft.biz/HorasProjeto/ProcessaJustificativa?id=" + usuarioId + "&jtfid=0&dao=" + dataInicio.ToString("yyyy-MM-dd") + "&daf=" + dataFim.ToString("yyyy-MM-dd") + @"&justid=" + justificativa + @""" style=""text-decoration:none;"">RECUSAR</a> </div> </body> </html>"); respEmail = EnviaEmail("*****@*****.**", "indigo.2017", just.EmailEstrutura.ToString(), "Ferramenta Check in/out", pagina.ToString()); } return(base.Json(new { Result = respEmail }, 0)); } else { return(base.Json(new { Result = "Você não pode justificar mais ausência esse mês !" }, 0)); } } catch (Exception ex) { log(ex.Message + " -- " + ex.StackTrace); return(base.Json(new { Result = ex.Message + " -- " + ex.StackTrace }, 0)); } }
public MyAppointment AddAppointment(Date startDate, Time startTime, int duration, string subject, string description = "", object resourceId = null, string resourceCaption = null) { return(AddAppointment(startDate, startTime, startDate, startTime.AddHours(duration), subject, description, resourceId, resourceCaption)); }