/// <summary> /// Validate function for all DataPathOfTideService commands /// </summary> /// <param name="validationContext">System.ComponentModel.DataAnnotations.ValidationContext (Describes the context in which a validation check is performed.)</param> /// <param name="actionDBType">[ActionDBTypeEnum] (CSSPEnums.ActionDBTypeEnum.html) action type to validate</param> /// <returns>IEnumerable of ValidationResult (Where ValidationResult is a container for the results of a validation request.)</returns> private IEnumerable <ValidationResult> Validate(ValidationContext validationContext, ActionDBTypeEnum actionDBType) { string retStr = ""; Enums enums = new Enums(LanguageRequest); DataPathOfTide dataPathOfTide = validationContext.ObjectInstance as DataPathOfTide; dataPathOfTide.HasErrors = false; if (string.IsNullOrWhiteSpace(dataPathOfTide.Text)) { dataPathOfTide.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "Text"), new[] { "Text" })); } if (!string.IsNullOrWhiteSpace(dataPathOfTide.Text) && (dataPathOfTide.Text.Length < 1 || dataPathOfTide.Text.Length > 200)) { dataPathOfTide.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._LengthShouldBeBetween_And_, "Text", "1", "200"), new[] { "Text" })); } if (dataPathOfTide.WebTideDataSet != null) { retStr = enums.EnumTypeOK(typeof(WebTideDataSetEnum), (int?)dataPathOfTide.WebTideDataSet); if (dataPathOfTide.WebTideDataSet == null || !string.IsNullOrWhiteSpace(retStr)) { dataPathOfTide.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "WebTideDataSet"), new[] { "WebTideDataSet" })); } } if (!string.IsNullOrWhiteSpace(dataPathOfTide.WebTideDataSetText) && dataPathOfTide.WebTideDataSetText.Length > 100) { dataPathOfTide.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._MaxLengthIs_, "WebTideDataSetText", "100"), new[] { "WebTideDataSetText" })); } retStr = ""; // added to stop compiling CSSPError if (retStr != "") // will never be true { dataPathOfTide.HasErrors = true; yield return(new ValidationResult("AAA", new[] { "AAA" })); } }
private DataPathOfTide GetFilledRandomDataPathOfTide(string OmitPropName) { DataPathOfTide dataPathOfTide = new DataPathOfTide(); if (OmitPropName != "Text") { dataPathOfTide.Text = GetRandomString("", 6); } if (OmitPropName != "WebTideDataSet") { dataPathOfTide.WebTideDataSet = (WebTideDataSetEnum)GetRandomEnumType(typeof(WebTideDataSetEnum)); } if (OmitPropName != "WebTideDataSetText") { dataPathOfTide.WebTideDataSetText = GetRandomString("", 5); } return(dataPathOfTide); }
public List <DataPathOfTide> GetTideDataPathsDB() { List <DataPathOfTide> dataPathOfTideList = new List <DataPathOfTide>(); //Arctic DataPathOfTide dataPathOfTide9 = new DataPathOfTide(); dataPathOfTide9.Text = ServiceRes.Arctic; dataPathOfTide9.WebTideDataSet = WebTideDataSetEnum.arctic9; dataPathOfTideList.Add(dataPathOfTide9); // Brador DataPathOfTide dataPathOfTide2 = new DataPathOfTide(); dataPathOfTide2.Text = ServiceRes.BrasdOrLake; dataPathOfTide2.WebTideDataSet = WebTideDataSetEnum.brador; dataPathOfTideList.Add(dataPathOfTide2); // Global (LEGOS France) DataPathOfTide dataPathOfTide10 = new DataPathOfTide(); dataPathOfTide10.Text = ServiceRes.GlobalLEGOS; dataPathOfTide10.WebTideDataSet = WebTideDataSetEnum.HRglobal; dataPathOfTideList.Add(dataPathOfTide10); // Halifax Harbour DataPathOfTide dataPathOfTide3 = new DataPathOfTide(); dataPathOfTide3.Text = ServiceRes.HalifaxHarbour; dataPathOfTide3.WebTideDataSet = WebTideDataSetEnum.h3o; dataPathOfTideList.Add(dataPathOfTide3); //Hudson Bay (IML) DataPathOfTide dataPathOfTide6 = new DataPathOfTide(); dataPathOfTide6.Text = ServiceRes.HudsonBayIML; dataPathOfTide6.WebTideDataSet = WebTideDataSetEnum.hudson; dataPathOfTideList.Add(dataPathOfTide6); //North East Pacific (IOS) DataPathOfTide dataPathOfTide8 = new DataPathOfTide(); dataPathOfTide8.Text = ServiceRes.NorthEastPacificIOS; dataPathOfTide8.WebTideDataSet = WebTideDataSetEnum.ne_pac4; dataPathOfTideList.Add(dataPathOfTide8); // North West Atlantic DataPathOfTide dataPathOfTide5 = new DataPathOfTide(); dataPathOfTide5.Text = ServiceRes.NorthWestAtlantic; dataPathOfTide5.WebTideDataSet = WebTideDataSetEnum.nwatl; dataPathOfTideList.Add(dataPathOfTide5); //Quatsino Sound DataPathOfTide dataPathOfTide7 = new DataPathOfTide(); dataPathOfTide7.Text = ServiceRes.QuatsinoSound; dataPathOfTide7.WebTideDataSet = WebTideDataSetEnum.QuatsinoModel14; dataPathOfTideList.Add(dataPathOfTide7); // Scotian Fundy Maine DataPathOfTide dataPathOfTide4 = new DataPathOfTide(); dataPathOfTide4.Text = ServiceRes.ScotianFundyMaine; dataPathOfTide4.WebTideDataSet = WebTideDataSetEnum.sshelf; dataPathOfTideList.Add(dataPathOfTide4); // Upper Bay of Fundy DataPathOfTide dataPathOfTide1 = new DataPathOfTide(); dataPathOfTide1.Text = ServiceRes.UpperBayFundy; dataPathOfTide1.WebTideDataSet = WebTideDataSetEnum.flood; dataPathOfTideList.Add(dataPathOfTide1); // Vancouver Island (Mike Foreman) DataPathOfTide dataPathOfTide11 = new DataPathOfTide(); dataPathOfTide11.Text = ServiceRes.VancouverIslandMF; dataPathOfTide11.WebTideDataSet = WebTideDataSetEnum.vigf8; dataPathOfTideList.Add(dataPathOfTide11); return(dataPathOfTideList); }
private bool WriteHTMLMunicipalityHighestAndLowestMonthlyTides(StringBuilder sbHTML, WebTideDataSetEnum webTideDataSet, int Year, double Lat, double Lng) { int Days = 5; TideModel tideModel = new TideModel(_TVFileService.ChoseEDriveOrCDrive(_TVFileService.BasePath), webTideDataSet) { StartDate = new DateTime(Year, 1, 1), EndDate = new DateTime(Year + 1, 1, 1), Lat = Lat, Lng = Lng, Steps_min = 15, WebTideDataSet = webTideDataSet, DoWaterLevels = true, //TideDataPath --- already set in the constructor }; List <WaterLevelResult> waterLevelResultList = _TidesAndCurrentsService.GetTides(tideModel); if (_TaskRunnerBaseService._BWObj.TextLanguageList.Count > 0) { if (_TaskRunnerBaseService._BWObj.appTaskModel.Language == LanguageEnum.fr) { sbHTML.AppendLine(_TaskRunnerBaseService._BWObj.TextLanguageList[1].Text); } else { sbHTML.AppendLine(_TaskRunnerBaseService._BWObj.TextLanguageList[0].Text); } return(true); } List <PeakDifference> HighPeakDifferenceList = FindMonthlyHighAndLowTide(Year, waterLevelResultList, TideType.High, Days); List <PeakDifference> LowPeakDifferenceList = FindMonthlyHighAndLowTide(Year, waterLevelResultList, TideType.Low, Days); List <DataPathOfTide> dataPathOfTideList = _TideSiteService.GetTideDataPathsDB(); DataPathOfTide dataPathOfTide = dataPathOfTideList.Where(c => c.WebTideDataSet == webTideDataSet).FirstOrDefault(); sbHTML.AppendLine($"<h2>{ TaskRunnerServiceRes.WebTideDataSet}: { dataPathOfTide.Text }</h2>"); sbHTML.AppendLine($"<h2>{ TaskRunnerServiceRes.Location }: { Lat } { Lng }</h2>"); sbHTML.AppendLine($"<h3>{ TaskRunnerServiceRes.AllHoursAreInUTC}</h3>"); sbHTML.AppendLine(""); sbHTML.AppendLine(""); sbHTML.AppendLine($"<h2>{ TaskRunnerServiceRes.MonthlyHighTides }</h2>"); sbHTML.AppendLine(""); sbHTML.AppendLine(@"<table>"); sbHTML.AppendLine(@"<thead>"); sbHTML.AppendLine(@"<tr>"); sbHTML.AppendLine($@"<th>{ TaskRunnerServiceRes.Monthly }</th>"); sbHTML.AppendLine($@"<th>{ TaskRunnerServiceRes.StartTime }</th>"); sbHTML.AppendLine($@"<th>{ TaskRunnerServiceRes.EndTime }</th>"); sbHTML.AppendLine($@"<th>{ TaskRunnerServiceRes.Amplitude }</th>"); sbHTML.AppendLine(@"<th></th>"); sbHTML.AppendLine(@"<th></th>"); sbHTML.AppendLine(@"</tr>"); sbHTML.AppendLine(@"</thead>"); sbHTML.AppendLine(@"<tbody>"); foreach (PeakDifference peakDifference in HighPeakDifferenceList) { sbHTML.AppendLine(@"<tr>"); sbHTML.AppendLine($@"<td>{ peakDifference.StartDate.ToString("MMMM") }</td>"); sbHTML.AppendLine($@"<td>{ peakDifference.StartDate.ToString("yyyy-MMM-dd HH:mm:ss") }</td>"); sbHTML.AppendLine($@"<td>{ peakDifference.EndDate.ToString("yyyy-MMM-dd HH:mm:ss") }</td>"); sbHTML.AppendLine($@"<td>{ peakDifference.Value }</td>"); sbHTML.AppendLine($@"<td></td>"); sbHTML.AppendLine($@"<td></td>"); sbHTML.AppendLine(@"</tr>"); } sbHTML.AppendLine(@"</tbody>"); sbHTML.AppendLine(@"</table>"); sbHTML.AppendLine(""); sbHTML.AppendLine(""); sbHTML.AppendLine($"<h2>{ TaskRunnerServiceRes.MonthlyLowTides }</h2>"); sbHTML.AppendLine(""); sbHTML.AppendLine(""); sbHTML.AppendLine(@"<table>"); sbHTML.AppendLine(@"<thead>"); sbHTML.AppendLine(@"<tr>"); sbHTML.AppendLine($@"<th>{ TaskRunnerServiceRes.Monthly }</th>"); sbHTML.AppendLine($@"<th>{ TaskRunnerServiceRes.StartTime }</th>"); sbHTML.AppendLine($@"<th>{ TaskRunnerServiceRes.EndTime }</th>"); sbHTML.AppendLine($@"<th>{ TaskRunnerServiceRes.Amplitude }</th>"); sbHTML.AppendLine(@"</tr>"); sbHTML.AppendLine(@"</thead>"); sbHTML.AppendLine(@"<tbody>"); foreach (PeakDifference peakDifference in LowPeakDifferenceList) { sbHTML.AppendLine(@"<tr>"); sbHTML.AppendLine($@"<td>{ peakDifference.StartDate.ToString("MMMM") }</td>"); sbHTML.AppendLine($@"<td>{ peakDifference.StartDate.ToString("yyyy-MMM-dd HH:mm:ss") }</td>"); sbHTML.AppendLine($@"<td>{ peakDifference.EndDate.ToString("yyyy-MMM-dd HH:mm:ss") }</td>"); sbHTML.AppendLine($@"<td>{ peakDifference.Value }</td>"); sbHTML.AppendLine(@"</tr>"); } sbHTML.AppendLine(@"</tbody>"); sbHTML.AppendLine(@"</table>"); sbHTML.AppendLine(""); sbHTML.AppendLine(""); sbHTML.AppendLine($"<h2>{ TaskRunnerServiceRes.WaterLevelsData}</h2>"); sbHTML.AppendLine(""); sbHTML.AppendLine(""); sbHTML.AppendLine(@"<table>"); sbHTML.AppendLine(@"<thead>"); sbHTML.AppendLine(@"<tr>"); sbHTML.AppendLine($@"<th>{ TaskRunnerServiceRes.Time }</th>"); sbHTML.AppendLine($@"<th>{ TaskRunnerServiceRes.WaterLevel }</th>"); sbHTML.AppendLine(@"</tr>"); sbHTML.AppendLine(@"</thead>"); sbHTML.AppendLine(@"<tbody>"); foreach (WaterLevelResult waterLevelResult in waterLevelResultList) { sbHTML.AppendLine(@"<tr>"); sbHTML.AppendLine($@"<td>{ waterLevelResult.Date.ToString("yyyy-MMM-dd HH:mm:ss") }</td>"); sbHTML.AppendLine($@"<td>{ waterLevelResult.WaterLevel }</td>"); sbHTML.AppendLine(@"</tr>"); } sbHTML.AppendLine(@"</tbody>"); sbHTML.AppendLine(@"</table>"); return(true); }
public DataPathOfTideTest() { dataPathOfTide = new DataPathOfTide(); }