private void UpdateSites() { _logger.Information("Updating Sites"); SiteDal dal = new SiteDal(_configuration, _logger); DateTime?lastUpdate = dal.GetLastAdded(); if (lastUpdate == null || lastUpdate.Value.Year == 0) { InitialiseSites(); } else { IEnumerable <SiteModel> siteModels = new SOAPHelper(_autotaskApiUsername, _autotaskApiPassword, _autotaskApiIntegrationCode, _autotaskApiUrl, _logger) .RetrieveNewSites(lastUpdate.Value); if (siteModels != null && siteModels.Count() > 0) { _logger.Information($"{siteModels.Count()} new Sites found"); } { foreach (SiteModel site in siteModels) { Domain.Enums.CRUDEnums.ActionResult actionResult = dal.Put(site).GetAwaiter().GetResult(); } } } }
private void FindAvailableCampSites() { int campground_id = CLIHelper.GetInteger("Please Select Campground ID"); Console.WriteLine(); DateTime startDate = CLIHelper.GetDateTime("Please Select Start of Stay (yyyy-mm-dd)"); Console.WriteLine(); DateTime endDate = CLIHelper.GetDateTime("Please Select Date of Depature (yyyy-mm-dd)"); SiteDal dal = new SiteDal(connectionString); List <Site> sites; bool avail = dal.IsSiteAvailable(campground_id, startDate, endDate); if (!avail) { Tools.ColorfulWriteLine("No availablity please try different dates or Campground", ConsoleColor.Red); } else if (avail) { sites = dal.GetTop5(campground_id, startDate, endDate); foreach (Site s in sites) { Console.WriteLine(); Tools.ColorfulWriteLine($"National Site ID".PadRight(20) + "Campground Site Number".PadRight(30) + "Max Occupancy".PadRight(25) + "Total Days".PadRight(20) + "Total Cost", ConsoleColor.Yellow); Console.WriteLine($"{s.site_id}".PadRight(20) + $"{s.site_number}".PadRight(30) + $"{s.max_occupancy}".PadRight(30) + $"{s.totalDays}".PadRight(20) + $"${s.totalCost}"); } } }
public void Display() { while (true) { Console.WriteLine(); Console.WriteLine("1 - Max Occupancy"); Console.WriteLine("2 - Accessible"); Console.WriteLine("3 - Max RV Length"); Console.WriteLine("4 - Are utilities provided"); Console.WriteLine("5 - Return to Main Menu"); Console.WriteLine(); string input = CLIHelper.GetString("Make your choice:"); Console.WriteLine(); if (input == "5") { return; } int siteId = CLIHelper.GetInteger("Please Select Site ID "); SiteDal siteDal = new SiteDal(connectionString); Site s = siteDal.GetSite(siteId); switch (input.ToLower()) { case "1": ShowMaxOccupancy(s); break; case "2": int site_idONE = CLIHelper.GetInteger("Please Select Site ID "); SiteDal accessible = new SiteDal(connectionString); IsItAccessible(accessible.ListIsSiteAccessible(site_idONE), site_idONE); break; case "3": int maxRVId = CLIHelper.GetInteger("Please Select Site ID "); SiteDal maxRV = new SiteDal(connectionString); MaxRvLength(maxRV.ListOfMaxRVLength(maxRVId), maxRVId); break; case "4": int utilityID = CLIHelper.GetInteger("Please Select Site ID "); SiteDal utility = new SiteDal(connectionString); AreThereUtilities(utility.ListAreThereUtilities(utilityID), utilityID); break; } } }
private void MaxRvLength(List <Site> rvLength, int site) { SiteDal dal = new SiteDal(connectionString); if (rvLength.Count > 0) { foreach (Site rv in rvLength) { Tools.ColorfulWriteLine($"The max rv length of site {site} is {rv.maxRVLength} feet", ConsoleColor.Green); } } }
private void IsItAccessible(List <Site> accessible, int site) { SiteDal dal = new SiteDal(connectionString); if (accessible.Count > 0) { Tools.ColorfulWriteLine($"{site} is accessible", ConsoleColor.Green); } else { Tools.ColorfulWriteLine($"Site {site} is not accessible", ConsoleColor.Red); } }
private void AreThereUtilities(List <Site> utilities, int siteID) { SiteDal dal = new SiteDal(connectionString); if (utilities.Count > 0) { Tools.ColorfulWriteLine($"{siteID} has utilities", ConsoleColor.Green); } else { Tools.ColorfulWriteLine($"Site {siteID} does not have utilities", ConsoleColor.Red); } }
private void InitialiseSites() { _logger.Information("Initialising Sites"); IEnumerable <SitePOCO> sites = new List <SitePOCO>(); try { sites = new DatabaseHelper(_remoteAutoTaskDatabaseConnection).GetAllSites(_accountTypeId); } catch (Exception ex) { _logger.Error(ex, "Failed intialising Sites"); } if (sites.Count() > 0) { _logger.Information($"{sites.Count()} Sites Found"); try { _logger.Information($"Uploading Sites"); IEnumerable <SiteModel> siteModels = from site in sites select new SiteModel() { AccountName = site.account_name, Address1 = site.address_1, Address2 = site.address_2, City = site.city, Country = site.country, DateCreated = site.create_time, Id = site.account_id, ParentAccountId = site.parent_account_id, State = site.state, ZipCode = site.zip_code }; SiteDal dal = new SiteDal(_configuration, _logger); dal.Truncate(); dal.BulkUpload(siteModels); _logger.Information($"Completed Sites Bulk insert"); } catch (Exception ex) { _logger.Error(ex, "Failed Bulk upload of sites"); } } }
protected bool createRatingMarkers(IEnumerable <EmailForExtendedDto> emails) { try { SiteDal siteDal = new SiteDal(_configuration, _logger); RatingMarkerDal ratingMarkerDal = new RatingMarkerDal(_configuration, _logger); int added = 0; int updated = 0; foreach (EmailForExtendedDto emailForExtendedDto in emails) { int siteId = siteDal.GetSiteIdByExternalIdentifier(emailForExtendedDto.Folder).GetAwaiter().GetResult(); if (siteId > -1) { int ratingMarkerId = ratingMarkerDal.Put(RatingMarkerHelper.EmailForExtendedToRatingMarker(emailForExtendedDto, siteId)).GetAwaiter().GetResult(); if (ratingMarkerId < 0) { _logger.Error($"An error occured while saving rating marker to the database"); continue; } added++; if (_emailAlertsDal.Post(emailForExtendedDto.UniqueIdentifier, ratingMarkerId).GetAwaiter().GetResult() != CRUDEnums.ActionResult.Success) { _logger.Error($"An error occured while updating Email Alerts in the database"); continue; } updated++; } else { _logger.Information($"Error linking Highlight Folder - {emailForExtendedDto.Folder}"); } } _logger.Information($"RatingMarkers added to the database {added}"); _logger.Information($"EmailAlerts updated in the database {updated}"); if (added != emails.Count()) { _logger.Warning($"RatingMarkers not added to the database {(emails.Count() - added)}"); } } catch (Exception ex) { _logger.Error("Error Saving RatingMarkers", ex); return(false); } return(true); }
public void RefreshAssociations() { _logger.Information("Attempting to link sites and folders"); SiteDal siteDal = new SiteDal(_configuration, _logger); IEnumerable <SiteForExtendedTicketDto> sites = siteDal.GetSiteForExtendedTicket("red alert").GetAwaiter().GetResult(); _logger.Information($"Retreived {sites.Count()} new link sites"); Dictionary <string, int> siteAssociation = new AssociationHelper(sites, _logger).SiteAssociation; foreach (KeyValuePair <string, int> site in siteAssociation) { CRUDEnums.ActionResult result = siteDal.Post(site.Value, site.Key).GetAwaiter().GetResult(); if (result != CRUDEnums.ActionResult.Success) { _logger.Error($"Error updating site {site.Value} with external identifier {site.Key} Error {result.ToString()}"); } } _logger.Information("Completed link sites and folders"); }
private void CheckReservation() { int siteID = CLIHelper.GetInteger("Please Select your Camp Site:"); SiteDal siteDal = new SiteDal(connectionString); Site site = siteDal.GetSite(siteID); if (site == null) { Console.WriteLine("That site does not exist."); return; } CampgroundDAL campDal = new CampgroundDAL(connectionString); Campground c = campDal.GetCampgroundById(site.campground_id); string name = CLIHelper.GetString("Please enter reservation Name:"); DateTime fromDate = CLIHelper.GetDateTime("Please select arrival date (yyyy-mm-dd):"); DateTime toDate = CLIHelper.GetDateTime("Please select depature date(yyyy-mm-dd):"); DateTime createDate = DateTime.Now; Console.WriteLine(); if (c.OpenFromMM > fromDate.Month || c.OpenToMM < toDate.Month) { Tools.ColorfulWriteLine("Sorry the camp is closed during that time frame. Please try again", ConsoleColor.Red); } else { ReservationDAL dal = new ReservationDAL(connectionString); dal.MakeReservation(siteID, name, fromDate, toDate, createDate); Reservation r = dal.GetReservationNumber(siteID, name, fromDate, toDate); Console.WriteLine("Success, your reservation confirmation is below!"); Tools.ColorfulWriteLine("Confirmation ID".PadRight(20) + "Name".PadRight(35) + "Arrival Date".PadRight(10) + "Depature Date".PadRight(15) + "Creation Date", ConsoleColor.Green); Console.WriteLine($"{r.reservationId})".PadRight(20) + $"{r.name}".PadRight(35) + $"{r.fromDate}".PadRight(10) + $"{r.toDate}".PadRight(15) + $"{r.createDate}"); } }
public static void DeleteSite(UInt32 sit_id) { SiteDal.Delete(sit_id); }
public static UInt32 InsertSite(Site sit) { return(SiteDal.Insert(sit)); }
public static void UpdateSite(Site sit) { SiteDal.Update(sit); }
public static List <Site> LoadAllSite() { return(SiteDal.LoadAll()); }