1.2.11.11 Golf Markers, Logs
This commit is contained in:
+5
-4
@@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Core.Web.Admin.Models;
|
||||
using Saxonite.Net.Core.Web.Admin.Models.Reference;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using Saxonite.Net.Standard.Base.Bus.Reference;
|
||||
@@ -15,10 +16,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Admin.Controllers.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Golf Controller - Ajax requests.
|
||||
//=======================================================================
|
||||
partial class ReferenceGolfController
|
||||
//=======================================================================
|
||||
// Reference Golf Controller - Ajax requests.
|
||||
//=======================================================================
|
||||
partial class ReferenceGolfController
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Get Stats ajax request.
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Core.Web.Admin.Consoles;
|
||||
using Saxonite.Net.Core.Web.Admin.Models;
|
||||
using Saxonite.Net.Core.Web.Admin.Models.Reference;
|
||||
using Saxonite.Net.Core.Web.Admin.Procs;
|
||||
using Saxonite.Net.Core.Web.Base.Procs;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using Saxonite.Net.Standard.Base.Bus.Reference;
|
||||
@@ -115,6 +120,46 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers.Reference
|
||||
PopulateUsgaCourseResponseListData(course, data);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// USGA Marker data.
|
||||
private class UsgaMarkerListData : AjaxResponse_Data.ItemData_Base
|
||||
{
|
||||
public long? UsgaMarkerId { get; set; }
|
||||
public String Caption { get; set; }
|
||||
public short? Holes { get; set; }
|
||||
public String HolesCaption { get; set; }
|
||||
public String Tee { get; set; }
|
||||
public String Gender { get; set; }
|
||||
public short? SlopeRating { get; set; }
|
||||
public short? Par { get; set; }
|
||||
public decimal? CourseRating { get; set; }
|
||||
public decimal? BogeyRating { get; set; }
|
||||
public short? Length { get; set; }
|
||||
}
|
||||
private class UsgaMarkerItemData : UsgaMarkerListData
|
||||
{
|
||||
}
|
||||
private void PopulateUsgaMarkerResponseListData(SaxGolfUsgaMarker marker, UsgaMarkerListData data)
|
||||
{
|
||||
data.Id = SysId.ToString(marker.Id);
|
||||
data.Caption = marker.Caption;
|
||||
data.Holes = marker.Holes;
|
||||
data.HolesCaption = marker.HolesCaption;
|
||||
data.Tee = marker.Tee;
|
||||
data.Gender = marker.Gender;
|
||||
data.SlopeRating = marker.SlopeRating;
|
||||
data.Par = marker.Par;
|
||||
data.Gender = marker.Gender;
|
||||
data.BogeyRating = marker.BogeyRating;
|
||||
data.Length = marker.Length;
|
||||
data.StatusCode = marker.StatusCode;
|
||||
data.StatusDesc = marker.StatusDesc;
|
||||
}
|
||||
private void PopulateUsgaMarkerResponseItemData(SaxGolfUsgaMarker course, UsgaMarkerItemData data)
|
||||
{
|
||||
PopulateUsgaMarkerResponseListData(course, data);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get Country List ajax request.
|
||||
//-------------------------------------------------------------------
|
||||
@@ -133,7 +178,6 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers.Reference
|
||||
[Route("Reference/Golf/Ajax/GetCountries")]
|
||||
public IActionResult Ajax_GetCountryList(Model_ReferenceGolf model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetCountryList";
|
||||
String messageTitle = Localiser["caption.reference.golf"];
|
||||
AjaxResponse_ReferenceGolf_CountryList responseData = new AjaxResponse_ReferenceGolf_CountryList(model);
|
||||
|
||||
@@ -218,7 +262,6 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers.Reference
|
||||
[Route("Reference/Golf/Ajax/GetProvinces")]
|
||||
public IActionResult Ajax_GetProvinceList(Model_ReferenceGolf model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetProvinceList";
|
||||
String messageTitle = Localiser["caption.reference.golf"];
|
||||
AjaxResponse_ReferenceGolf_ProvinceList responseData = new AjaxResponse_ReferenceGolf_ProvinceList(model);
|
||||
|
||||
@@ -305,7 +348,6 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers.Reference
|
||||
[Route("Reference/Golf/Ajax/GetCourses")]
|
||||
public IActionResult Ajax_GetCourseList(Model_ReferenceGolf model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetCourseList";
|
||||
String messageTitle = Localiser["caption.reference.golf"];
|
||||
AjaxResponse_ReferenceGolf_CourseList responseData = new AjaxResponse_ReferenceGolf_CourseList(model);
|
||||
|
||||
@@ -384,6 +426,164 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers.Reference
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get Marker List ajax request.
|
||||
//-------------------------------------------------------------------
|
||||
private class AjaxResponse_ReferenceGolf_CleanseUsgaCourseCaptions : AjaxResponse_Data
|
||||
{
|
||||
// Construction.
|
||||
public AjaxResponse_ReferenceGolf_CleanseUsgaCourseCaptions(SaxModel_Admin model) : base(model) { }
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("Reference/Golf/Ajax/CleanseUsgaCourseCaptions")]
|
||||
public IActionResult Ajax_CleanseUsgaCourseCaptions(Model_ReferenceGolf model)
|
||||
{
|
||||
String messageTitle = Localiser["caption.reference.golf"];
|
||||
AjaxResponse_ReferenceGolf_CleanseUsgaCourseCaptions responseData = new AjaxResponse_ReferenceGolf_CleanseUsgaCourseCaptions(model);
|
||||
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
|
||||
// Process console.
|
||||
SaxProcessConsole_Admin processConsole = GetProcessConsole_Admin(SessionContext);
|
||||
if (processConsole == null)
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
// Check whether process is in progress.
|
||||
if (processConsole.IsProcessing(SaxProcessConsole_Admin.ProcessType.GolfUsgaDataLookup))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.process.in.progress"]));
|
||||
|
||||
// Configure the process.
|
||||
SaxGolfUsgaDataLookup.Config processConfig = new SaxGolfUsgaDataLookup.Config(SessionContext, DbUpdateInfo);
|
||||
processConfig.Tasks.Add(SaxGolfUsgaDataLookup.Task.CleanseCourseCaptions);
|
||||
SaxGolfUsgaDataLookup process = new SaxGolfUsgaDataLookup(processConfig);
|
||||
|
||||
// Store the process and run.
|
||||
processConsole.SetProcess(process);
|
||||
process.RunAsync();
|
||||
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} {exc.GetType().Name} initialising organisation uploader.");
|
||||
return Json(responseData.SetMessage(messageTitle, exc.GetType().Name + " initialising USGA Golf Data Loader."));
|
||||
}
|
||||
}
|
||||
|
||||
// Complete response.
|
||||
Json(responseData.SetMessage(messageTitle, "Course caption cleansing is underway."));
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get Marker List ajax request.
|
||||
//-------------------------------------------------------------------
|
||||
private class AjaxResponse_ReferenceGolf_MarkerList : AjaxResponse_Data
|
||||
{
|
||||
// Construction.
|
||||
public AjaxResponse_ReferenceGolf_MarkerList(SaxModel_Admin model) : base(model) { }
|
||||
// Marker list.
|
||||
public List<UsgaMarkerListData> Markers { get; } = new List<UsgaMarkerListData>();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("Reference/Golf/Ajax/GetUsgaMarkerList")]
|
||||
[Route("Reference/Golf/Ajax/GetUsgaMarkers")]
|
||||
[Route("Reference/Golf/Ajax/GetMarkerList")]
|
||||
[Route("Reference/Golf/Ajax/GetMarkers")]
|
||||
public IActionResult Ajax_GetMarkerList(Model_ReferenceGolf model)
|
||||
{
|
||||
String messageTitle = Localiser["caption.reference.golf"];
|
||||
AjaxResponse_ReferenceGolf_MarkerList responseData = new AjaxResponse_ReferenceGolf_MarkerList(model);
|
||||
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Item columns.
|
||||
ColumnDfn colId = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.Id);
|
||||
ColumnDfn colUsgaMarkerId = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.UsgaMarkerId);
|
||||
ColumnDfn colCaption = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.Caption);
|
||||
ColumnDfn colHoles = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.Holes);
|
||||
ColumnDfn colHolesCaption = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.HolesCaption);
|
||||
ColumnDfn colTee = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.Tee);
|
||||
ColumnDfn colGender = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.Gender);
|
||||
ColumnDfn colSlopeRating = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.SlopeRating);
|
||||
ColumnDfn colPar = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.Par);
|
||||
ColumnDfn colCourseRating = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.CourseRating);
|
||||
ColumnDfn colBogeyRating = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.BogeyRating);
|
||||
ColumnDfn colLength = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.Length);
|
||||
ColumnDfn colFlags = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.Flags);
|
||||
ColumnDfn colStatus = ReferenceGolfMgr.GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column.Status);
|
||||
List<ColumnDfn> columns = new List<ColumnDfn>()
|
||||
{
|
||||
colId, colUsgaMarkerId, colCaption, colHoles, colHolesCaption, colTee, colGender, colSlopeRating, colPar, colCourseRating, colBogeyRating, colLength, colFlags, colStatus
|
||||
};
|
||||
|
||||
// Item filter.
|
||||
SaxGolfUsgaMarker.Params prmUsgaMarker = new SaxGolfUsgaMarker.Params();
|
||||
if (StringUtil.ToLong(model.Filter.CourseId) > 0)
|
||||
prmUsgaMarker.CourseIdsIncluded.Add(StringUtil.ToSysId(model.Filter.CourseId));
|
||||
prmUsgaMarker.MarkerFilter = model.Filter.MarkerSearch;
|
||||
prmUsgaMarker.StatusCat = SaxGolfUsgaMarker.StatusCat.Any;
|
||||
model.Paging.ItemTotal = (ulong)ReferenceGolfMgr.GetUsgaMarkerCount(prmUsgaMarker);
|
||||
model.PopulatePagingTo(prmUsgaMarker.ResultsPaging);
|
||||
// Restrict results is not paged.
|
||||
if (!prmUsgaMarker.ResultsPaging.Paged)
|
||||
{
|
||||
prmUsgaMarker.ResultsPaging.PageNo = 1;
|
||||
prmUsgaMarker.ResultsPaging.PageLength = 200;
|
||||
}
|
||||
|
||||
// Sort order.
|
||||
prmUsgaMarker.SortColumns.Add(colCaption);
|
||||
|
||||
// Query items.
|
||||
using (DbResultSet resultSet = ReferenceGolfMgr.ExecuteUsgaMarkerQuery(columns, prmUsgaMarker))
|
||||
{
|
||||
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = resultSet.GetRecordValues();
|
||||
ushort flags = (ushort)values.GetLong(colFlags.DataName);
|
||||
UsgaMarkerListData markerData = new UsgaMarkerListData()
|
||||
{
|
||||
Id = values.GetString(colId.DataName),
|
||||
UsgaMarkerId = values.GetLong(colUsgaMarkerId.DataName),
|
||||
Caption = values.GetString(colCaption.DataName),
|
||||
Holes = (short)values.GetLong(colHoles.DataName),
|
||||
HolesCaption = values.GetString(colHolesCaption.DataName),
|
||||
Tee = values.GetString(colTee.DataName),
|
||||
Gender = values.GetString(colGender.DataName),
|
||||
SlopeRating = (short)values.GetLong(colSlopeRating.DataName),
|
||||
Par = (short)values.GetLong(colPar.DataName),
|
||||
CourseRating = values.GetDecimal(colCourseRating.DataName),
|
||||
BogeyRating = values.GetDecimal(colBogeyRating.DataName),
|
||||
Length = (short)values.GetLong(colLength.DataName),
|
||||
StatusCode = values.GetString(colStatus.DataName),
|
||||
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))
|
||||
};
|
||||
responseData.Markers.Add(markerData);
|
||||
}
|
||||
}
|
||||
if (model.Paging.IsPaged)
|
||||
model.Paging.ItemCount = (ushort)responseData.Markers.Count;
|
||||
|
||||
// Complete response.
|
||||
responseData.SetPaging(model);
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Saxonite.Net.Core.Web.Admin.Models;
|
||||
using Saxonite.Net.Core.Web.Admin.Models.Reference;
|
||||
using Saxonite.Net.Core.Web.Base.App;
|
||||
using Saxonite.Net.Core.Web.Base.Controllers;
|
||||
using System;
|
||||
@@ -11,8 +11,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Admin.Controllers.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class ReferenceGolfController : SaxController_Admin
|
||||
//=======================================================================
|
||||
public partial class ReferenceGolfController : SaxController_Admin
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers.System
|
||||
private class LogFileData
|
||||
{
|
||||
public String Name { get; set; }
|
||||
public String UpdateFmt { get; set; }
|
||||
public long Size { get; set; }
|
||||
}
|
||||
|
||||
@@ -207,7 +208,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers.System
|
||||
DirectoryInfo folder = new DirectoryInfo(logFolder);
|
||||
foreach (FileInfo file in folder.EnumerateFiles())
|
||||
{
|
||||
responseData.Files.Add(new LogFileData() { Name = file.Name, Size = file.Length });
|
||||
responseData.Files.Add(new LogFileData() { Name = file.Name, UpdateFmt = file.LastWriteTime.ToString("d-MMM-yy HH:mm"), Size = file.Length });
|
||||
}
|
||||
|
||||
// Complete response.
|
||||
|
||||
Reference in New Issue
Block a user