public string AddOrEditForDomain(DomainViewModel domainViewModel) { var hijackingDomainDto = new HijackingDomainDto(); try { if (domainViewModel.Id != null) { hijackingDomainDto = hijackingDomainService.GetById(domainViewModel.Id); } hijackingDomainDto.Protocol = domainViewModel.Protocol; hijackingDomainDto.Domain = domainViewModel.Domain; hijackingDomainDto.DestinationIp = domainViewModel.DestinationIp; hijackingDomainDto.CustomerId = domainViewModel.CustomerID; hijackingDomainDto.Status = (int)StatusEnum.enabled; hijackingDomainDto.ToStartTime = Convert.ToDateTime(domainViewModel.ToStartTime).ToLocalTime(); hijackingDomainDto.ToEndTime = Convert.ToDateTime(domainViewModel.ToEndTime).ToLocalTime(); hijackingDomainDto.Interval = domainViewModel.Interval; hijackingDomainDto.Province = domainViewModel.CheckedProvince; hijackingDomainDto.Isp = domainViewModel.CheckedIsp; hijackingDomainDto.LastExecuted = DateTime.Now.AddHours(-3).ToLocalTime(); hijackingDomainDto.Redirection = string.IsNullOrEmpty(domainViewModel.Redirection) ? "" : domainViewModel.Redirection.ToLower().Trim(); hijackingDomainService.AddOrEdit(hijackingDomainDto); } catch (Exception ex) { log.Error(ex); } return(JsonConvert.SerializeObject(new { result = "true" })); }
public List <HijackingDomainDto> DomainList() { var domainForTest = new List <HijackingDomainDto>(); try { var filterDomain = hijackingDomainService.GetAll().Where(s => s.ToEndTime > DateTime.Now.ToLocalTime() && DateTime.Now.ToLocalTime() > s.ToStartTime && s.Status == 1); domainForTest = filterDomain.Where(s => DateTime.UtcNow > s.LastExecuted.AddMinutes(s.Interval)).ToList(); } catch (Exception ex) { Console.WriteLine(ex.Message); } foreach (var domain in domainForTest) { domain.LastExecuted = DateTime.Now.ToLocalTime(); hijackingDomainService.AddOrEdit(domain); } return(domainForTest); }