public HomeController() { var fileLoc = HostingEnvironment.MapPath("/"); _service = new StoryService(int.Parse(ConfigurationManager.ConnectionStrings["AgileProjectID"].ConnectionString), ConfigurationManager.ConnectionStrings["AgileKey"].ConnectionString, fileLoc); _tzService = new TimeZoneService(); _timeNotAssignedToStories = Math.Round(_tzService.EntriesNotAssignedToStories().Where(x => x.Role == "Senior Front End Developer" | x.Role == "Senior Developer" | x.Role == "Developer").Sum(x => x.Time) / 7,2); _overhead = Math.Round(_timeNotAssignedToStories / _service.GetStories().Sum(x => x.Actual) * 100, 2); }
List <TimeZoneResponseModel> ResultGenerator(List <WeatherItem> weatherItems) { var googleTimeZoneTasks = weatherItems.Select(item => { return(Task <TimeZoneResponseModel> .Factory.StartNew(() => { var req = new TimeZoneRequest { Location = new LatLng(item.City.Coordinates.Latitude, item.City.Coordinates.Longitude) }; var response = new TimeZoneService().GetResponse(req); return TimeZoneResponseModelFactory.Create(item.City.Id, response); })); }).ToArray(); Task.WaitAll(googleTimeZoneTasks, HttpClientTimeout); return(googleTimeZoneTasks.Select(task => task.Result).ToList()); }
protected async override Task OnInitializedAsync() { await base.OnInitializedAsync(); CurrentUserId = await AuthCsroService.GetCurrentUserId(); if (!LocalDateTimeOffset.HasValue) { try { LocalDateTimeOffset = await TimeZoneService.GetLocalDateTime(DateTimeOffset.UtcNow); } catch (Exception ex) { _loggerCsroAuthComponentBase.LogError(ex, nameof(OnInitializedAsync), ex); } } }
// GET api/<controller>/5 public IHttpActionResult Get(int id) { try { var timeZoneService = new TimeZoneService(new TimeZoneRepository()); TimeZoneDTO item = timeZoneService.GetByID(id); if (!User.IsInRole("Admin") && (item.Owner != User.Identity.Name)) { return(Unauthorized()); } return(Ok(item)); } catch (Exception e) { return(InternalServerError(e)); } }
public ClockItem(string tzoneId) { _tz = TimeZoneService.FindSystemTimeZoneById(tzoneId); TimeZone = _tz.ToTimeZoneSelectItem(); //TimerTask = new AsyncTimer(1000).WhenTick(i => OnOneSecondPassed()).StartAsync(); var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; timer.Tick += (sender, o) => { var offset = _tz.ConvertTime(DateTime.Now); Time = offset.DateTime; OnPropertyChanged("Time"); }; timer.Start(); }
// DELETE api/<controller>/5 public IHttpActionResult Delete(int id) { try { var timeZoneService = new TimeZoneService(new TimeZoneRepository()); TimeZoneDTO timeZone = timeZoneService.GetByID(id); if (!User.IsInRole("Admin") && (timeZone.Owner != User.Identity.Name)) { return(Unauthorized()); } timeZoneService.Remove(id); return(Ok(HttpStatusCode.NoContent)); } catch (Exception e) { return(InternalServerError(e)); } }
public IActionResult GetTimeByZone([FromRoute(Name = "timezonename")] string timeZoneName) { var currentTime = TimeZoneService.GetTime(timeZoneName); var utcTime = DateTime.UtcNow; var serverTime = DateTime.Now; var ip = this.HttpContext.Connection.RemoteIpAddress.ToString(); var returnVal = new CurrentTimeQuery { UTCTime = utcTime, ClientIp = ip, Time = serverTime, SelectedTimeZone = timeZoneName }; using (var db = new ClockworkContext()) { db.CurrentTimeQueries.Add(returnVal); var count = db.SaveChanges(); Console.WriteLine("{0} records saved to database", count); Console.WriteLine(); foreach (var CurrentTimeQuery in db.CurrentTimeQueries) { Console.WriteLine(" - {0}", CurrentTimeQuery.UTCTime); } } try { return(Ok(currentTime.ToString())); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
// PUT api/<controller>/5 public IHttpActionResult Put(int id, [FromBody] TimeZoneDTO item) { try { var timeZoneService = new TimeZoneService(new TimeZoneRepository()); TimeZoneDTO timeZone = timeZoneService.GetByID(id); if (!User.IsInRole("Admin") && (item.Owner != User.Identity.Name)) { return(Unauthorized()); } item.ID = id; timeZoneService.Update(item); return(Ok(HttpStatusCode.NoContent)); } catch (Exception e) { return(InternalServerError(e)); } }
public static List <TimeZoneService> BuildServices(byte[] data) { var timeZoneServices = new List <TimeZoneService>(); for (int index = 0; index < Zd2911Utils.PassItemCount; index++) { int groupIndex = index * 7; var timeZoneService = new TimeZoneService() { TimeZoneId = index, MondayTimeGroupId = data[groupIndex + 0], TuesdayTimeGroupId = data[groupIndex + 1], WednesdayTimeGroupId = data[groupIndex + 2], ThursdayTimeGroupId = data[groupIndex + 3], FridayTimeGroupId = data[groupIndex + 4], SaturdayTimeGroupId = data[groupIndex + 5], SundayTimeGroupId = data[groupIndex + 6], }; timeZoneServices.Add(timeZoneService); } return(timeZoneServices); }
public LaunchInfoEmbedGenerator(TimeZoneService timeZoneService) { _timeZoneService = timeZoneService; }
public TimeZoneQueryHandler(ITelegramBotClientEx bot, IDateTimeZoneProvider dateTimeZoneProvider, IClock clock, IUrlHelper urlHelper, RaidBattlesContext db, IOptions <BotConfiguration> options, TimeZoneNotifyService timeZoneNotifyService, TimeZoneService timeZoneService) { myBot = bot; myDateTimeZoneProvider = dateTimeZoneProvider; myClock = clock; myUrlHelper = urlHelper; myDB = db; myTimeZoneNotifyService = timeZoneNotifyService; myTimeZoneService = timeZoneService; mySuperAdministrators = options.Value?.SuperAdministrators ?? new HashSet <long>(0); }
public TimeZoneController() { _timeZoneService = new TimeZoneService(); }
public GymInlineQueryHandler(IUrlHelper urlHelper, GeneralInlineQueryHandler generalInlineQueryHandler, IngressClient ingressClient, ITelegramBotClientEx bot, RaidBattlesContext db, RaidService raidService, GeoCoderEx geoCoder, IClock clock, TimeZoneService timeZoneService) { myUrlHelper = urlHelper; myGeneralInlineQueryHandler = generalInlineQueryHandler; myIngressClient = ingressClient; myBot = bot; myDb = db; myRaidService = raidService; myGeoCoder = geoCoder; myClock = clock; myTimeZoneService = timeZoneService; }
public TimeZoneCommands(TimeZoneService timeZoneService, TimeZoneEmbedGenerator timeZoneEmbedGenerator) { _timeZoneService = timeZoneService; _timeZoneEmbedGenerator = timeZoneEmbedGenerator; }
public BlogController(IPostCategoryService postCategoryService, IPostService postService, ICommentService commentService, IReviewService reviewService, IReportCategoryService reportCategoryService, IReportService reportService, ImageService imageService, TimeZoneService timeZoneService, IWebHostEnvironment webHostEnvironment, UserManager <ApplicationUser> userManager, ILogger <BlogController> logger, IConfiguration configuration) { _postCategoryService = postCategoryService; _postService = postService; _commentService = commentService; _reviewService = reviewService; _reportCategoryService = reportCategoryService; _reportService = reportService; _imageService = imageService; _timeZoneService = timeZoneService; _webHostEnvironment = webHostEnvironment; _userManager = userManager; _logger = logger; _configuration = configuration; }