diff --git a/src/BAGIS_ClassLibrary/enumerations/PublicPath.vb b/src/BAGIS_ClassLibrary/enumerations/PublicPath.vb index 27f8562..cbf24e2 100644 --- a/src/BAGIS_ClassLibrary/enumerations/PublicPath.vb +++ b/src/BAGIS_ClassLibrary/enumerations/PublicPath.vb @@ -70,4 +70,5 @@ Public Enum PublicPath MapParameters EBagisTaskLog FeatureServiceUrl + BagisHSettings End Enum diff --git a/src/BAGIS_P/Forms/FrmExportParametersEwsf.vb b/src/BAGIS_P/Forms/FrmExportParametersEwsf.vb index ea9c0a1..19e7cb5 100644 --- a/src/BAGIS_P/Forms/FrmExportParametersEwsf.vb +++ b/src/BAGIS_P/Forms/FrmExportParametersEwsf.vb @@ -532,10 +532,10 @@ Public Class FrmExportParametersEwsf If nmonthsTable IsNot Nothing Then Dim paramNamesToUpdate As IList(Of String) = New List(Of String) paramNamesToUpdate.Add(BA_Aoi_Parameter_jh_coef) - If CkPeAndSrObs.Checked Then - paramNamesToUpdate.Add(BA_Aoi_Parameter_PE_Obs) - paramNamesToUpdate.Add(BA_Aoi_Parameter_SR_Obs) - End If + 'If CkPeAndSrObs.Checked Then + ' paramNamesToUpdate.Add(BA_Aoi_Parameter_PE_Obs) + ' paramNamesToUpdate.Add(BA_Aoi_Parameter_SR_Obs) + 'End If nmonthsTable = BA_UpdateParametersInNmonthsTable(nmonthsTable, m_aoiParamTable, paramNamesToUpdate) m_tablesTable(NMONTHS) = nmonthsTable End If @@ -586,6 +586,18 @@ Public Class FrmExportParametersEwsf retVal = BA_ConvertGDBToShapefile(hruGdbName, vName, zipFolder, targetFile) 'Copy the parameter file into the tempBagisFolder File.Copy(TxtOutputFolder.Text, zipFolder & "\" & BA_GetBareName(TxtOutputFolder.Text), True) + 'Create the pe and Obs file into the zipfolder (If desired) + Dim peAndObsExportPath As String = zipFolder & BA_EnumDescription(PublicPath.PeAndObsExportCsv) + If File.Exists(peAndObsExportPath) Then File.Delete(peAndObsExportPath) + If CkPeAndSrObs.Checked Then + Dim peParam As AoiParameter = Nothing + Dim srParam As AoiParameter = Nothing + If m_hasPeObs Then peParam = m_aoiParamTable(BA_Aoi_Parameter_PE_Obs) + If m_hasSrObs Then srParam = m_aoiParamTable(BA_Aoi_Parameter_SR_Obs) + retVal = BA_ExportPeAndSrFile(peAndObsExportPath, m_aoi.Name, peParam, srParam, _ + missingData) + End If + m_exportMessage = "Converting HRU zones to ASCII .........." LblStatus.Text = m_exportMessage Dim hruClipPath As String = AddZonesToZipFolder(zipFolder, hruGdbName, targetFile) @@ -620,14 +632,18 @@ Public Class FrmExportParametersEwsf retVal = BA_ZipFolder(zipFolder, zipFileName) End If - If success = True And retVal = BA_ReturnCode.Success Then + If retVal = BA_ReturnCode.Success Then BA_Remove_Folder(zipFolder) - TimerStatus.Enabled = False - m_exportMessage = "" - LblStatus.Text = m_exportMessage MessageBox.Show("Parameter file export complete !", _ "File export", MessageBoxButtons.OK, MessageBoxIcon.Information) + Else + MessageBox.Show("An error occurred while trying to export the parameter file !", _ + "File export", MessageBoxButtons.OK, MessageBoxIcon.Warning) End If + 'Do this if we are successful or not + TimerStatus.Enabled = False + m_exportMessage = "" + LblStatus.Text = m_exportMessage Else TimerStatus.Enabled = False m_exportMessage = "" diff --git a/src/BAGIS_P/ParameterModule.vb b/src/BAGIS_P/ParameterModule.vb index 9eafe7f..3ba3c22 100644 --- a/src/BAGIS_P/ParameterModule.vb +++ b/src/BAGIS_P/ParameterModule.vb @@ -1766,7 +1766,8 @@ Module ParameterModule End Function Public Function BA_ExportPeAndSrFile(ByVal outputFile As String, ByVal aoiName As String, _ - ByVal pe_param As AoiParameter, ByVal sr_param As AoiParameter) As BA_ReturnCode + ByVal pe_param As AoiParameter, ByVal sr_param As AoiParameter, _ + ByVal missingValue As String) As BA_ReturnCode Dim sb As StringBuilder = New StringBuilder Try Using sw = New StreamWriter(outputFile) @@ -1778,7 +1779,7 @@ Module ParameterModule sb.Remove(0, sb.Length) sb.Append(LEN_KEY) sb.Append(",") - sb.Append(pe_param.ValuesList.Count) + sb.Append(NUM_MONTHS) sw.WriteLine(sb.ToString) sb.Remove(0, sb.Length) sb.Append(CREATED_AT) @@ -1807,7 +1808,66 @@ Module ParameterModule sb.Append(aoiName) sw.WriteLine(sb.ToString) sb.Remove(0, sb.Length) - + sb.Append("unit_for_PE") + sb.Append(",") + sb.Append("inch/day") + sw.WriteLine(sb.ToString) + sb.Remove(0, sb.Length) + sb.Append("unit_for_SR") + sb.Append(",") + sb.Append("langleys/day or calories/sq cm/day") + sw.WriteLine(sb.ToString) + sb.Remove(0, sb.Length) + sb.Append(HEADER_FLAG) + sb.Append(",") + sb.Append("date") + sb.Append(",") + sb.Append(BA_Aoi_Parameter_PE_Obs) + sb.Append(",") + sb.Append(BA_Aoi_Parameter_SR_Obs) + sw.WriteLine(sb.ToString) + sb.Remove(0, sb.Length) + sb.Append("Type") + sb.Append(",") + sb.Append("Date") + sb.Append(",") + sb.Append("Real") + sb.Append(",") + sb.Append("Real") + sw.WriteLine(sb.ToString) + sb.Remove(0, sb.Length) + 'Prepare to write table of values + Dim peValues As IList(Of String) = New List(Of String) + Dim srValues As IList(Of String) = New List(Of String) + If pe_param IsNot Nothing Then + peValues = pe_param.ValuesList + End If + If sr_param IsNot Nothing Then + srValues = sr_param.ValuesList + End If + 'Write out table + For i As Short = 1 To NUM_MONTHS + sb.Append(",") + sb.Append(i) + sb.Append(",") + Dim nextPe As String = missingValue + If peValues.Count >= i - 1 Then + If peValues.Item(i - 1) IsNot Nothing Then + nextPe = peValues.Item(i - 1) + End If + End If + sb.Append(nextPe) + sb.Append(",") + Dim nextSr As String = missingValue + If srValues.Count >= i - 1 Then + If srValues.Item(i - 1) IsNot Nothing Then + nextSr = srValues.Item(i - 1) + End If + End If + sb.Append(nextSr) + sw.WriteLine(sb.ToString) + sb.Remove(0, sb.Length) + Next End Using Return BA_ReturnCode.Success Catch ex As Exception