From 53b237bc14aa4ceb4896a0ab0e91bf57562acb8a Mon Sep 17 00:00:00 2001 From: patowhiz Date: Fri, 12 Jul 2024 10:06:55 +0300 Subject: [PATCH 01/13] New climsoft dialog --- instat/dlgClimSoft.Designer.vb | 536 +++++++++++------- instat/dlgClimSoft.vb | 442 ++++++++------- instat/instat.vbproj | 6 + instat/sdgClimsoft.Designer.vb | 259 +++++++++ instat/sdgClimsoft.vb | 112 ++++ .../static/InstatObject/R/instat_object_R6.R | 242 ++++++++ 6 files changed, 1195 insertions(+), 402 deletions(-) create mode 100644 instat/sdgClimsoft.Designer.vb create mode 100644 instat/sdgClimsoft.vb diff --git a/instat/dlgClimSoft.Designer.vb b/instat/dlgClimSoft.Designer.vb index aa14f7e0879..18e11098e6a 100644 --- a/instat/dlgClimSoft.Designer.vb +++ b/instat/dlgClimSoft.Designer.vb @@ -39,202 +39,310 @@ Partial Class dlgClimSoft Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() - Me.cmdEstablishConnection = New System.Windows.Forms.Button() - Me.lblElements = New System.Windows.Forms.Label() - Me.lblStations = New System.Windows.Forms.Label() - Me.lblStartDate = New System.Windows.Forms.Label() - Me.lblEndDate = New System.Windows.Forms.Label() + Me.btnConnection = New System.Windows.Forms.Button() + Me.lblSelectElements = New System.Windows.Forms.Label() + Me.lblSelectStations = New System.Windows.Forms.Label() Me.ttClimsoft = New System.Windows.Forms.ToolTip(Me.components) - Me.ucrChkUnstackData = New instat.ucrCheck() - Me.ucrChkFlagsData = New instat.ucrCheck() - Me.ucrChkElements = New instat.ucrCheck() - Me.ucrChkDateRange = New instat.ucrCheck() - Me.ucrDtpEndDate = New instat.ucrDateTimePicker() - Me.ucrDtpStartdate = New instat.ucrDateTimePicker() - Me.ucrChkObservationData = New instat.ucrCheck() + Me.ucrChkImportElementsMetadata = New instat.ucrCheck() + Me.ucrChkImportStationsMetadata = New instat.ucrCheck() + Me.ucrChkDataDate = New instat.ucrCheck() + Me.ucrDtpEndDataDate = New instat.ucrDateTimePicker() + Me.ucrDtpStartDataDate = New instat.ucrDateTimePicker() + Me.ucrChkImportFlagsMetadata = New instat.ucrCheck() Me.lblConnection = New System.Windows.Forms.Label() - Me.ucrComboBoxElements = New instat.ucrInputComboBox() - Me.ucrComboBoxStations = New instat.ucrInputComboBox() + Me.lblToDataDate = New System.Windows.Forms.Label() + Me.lblSelectTable = New System.Windows.Forms.Label() + Me.lblSelectQCStatus = New System.Windows.Forms.Label() + Me.btnCheckRecords = New System.Windows.Forms.Button() + Me.lblRecordsNum = New System.Windows.Forms.Label() + Me.btnMoreOptions = New System.Windows.Forms.Button() + Me.rdoMetadata = New System.Windows.Forms.RadioButton() + Me.rdoData = New System.Windows.Forms.RadioButton() + Me.ucrPnlOptions = New instat.UcrPanel() + Me.ucrCboQCStatus = New instat.ucrInputComboBox() + Me.ucrCboTable = New instat.ucrInputComboBox() + Me.ucrCboElements = New instat.ucrInputComboBox() + Me.ucrCboStations = New instat.ucrInputComboBox() Me.ucrSelectorForClimSoft = New instat.ucrSelectorAddRemove() Me.ucrReceiverMultipleElements = New instat.ucrReceiverMultiple() Me.ucrReceiverMultipleStations = New instat.ucrReceiverMultiple() Me.ucrBase = New instat.ucrButtons() Me.SuspendLayout() ' - 'cmdEstablishConnection - ' - Me.cmdEstablishConnection.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.cmdEstablishConnection.Location = New System.Drawing.Point(8, 8) - Me.cmdEstablishConnection.Name = "cmdEstablishConnection" - Me.cmdEstablishConnection.Size = New System.Drawing.Size(142, 23) - Me.cmdEstablishConnection.TabIndex = 1 - Me.cmdEstablishConnection.Text = "Establish Connection..." - Me.cmdEstablishConnection.UseVisualStyleBackColor = True - ' - 'lblElements - ' - Me.lblElements.AutoSize = True - Me.lblElements.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblElements.Location = New System.Drawing.Point(256, 194) - Me.lblElements.Name = "lblElements" - Me.lblElements.Size = New System.Drawing.Size(98, 13) - Me.lblElements.TabIndex = 4 - Me.lblElements.Text = "Selected Elements:" - ' - 'lblStations - ' - Me.lblStations.AutoSize = True - Me.lblStations.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblStations.Location = New System.Drawing.Point(256, 38) - Me.lblStations.Name = "lblStations" - Me.lblStations.Size = New System.Drawing.Size(93, 13) - Me.lblStations.TabIndex = 2 - Me.lblStations.Text = "Selected Stations:" - Me.lblStations.TextAlign = System.Drawing.ContentAlignment.MiddleCenter - ' - 'lblStartDate - ' - Me.lblStartDate.AutoSize = True - Me.lblStartDate.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblStartDate.Location = New System.Drawing.Point(32, 307) - Me.lblStartDate.Name = "lblStartDate" - Me.lblStartDate.Size = New System.Drawing.Size(58, 13) - Me.lblStartDate.TabIndex = 7 - Me.lblStartDate.Text = "Start Date:" - ' - 'lblEndDate - ' - Me.lblEndDate.AutoSize = True - Me.lblEndDate.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblEndDate.Location = New System.Drawing.Point(34, 349) - Me.lblEndDate.Name = "lblEndDate" - Me.lblEndDate.Size = New System.Drawing.Size(55, 13) - Me.lblEndDate.TabIndex = 9 - Me.lblEndDate.Text = "End Date:" - ' - 'ucrChkUnstackData - ' - Me.ucrChkUnstackData.AutoSize = True - Me.ucrChkUnstackData.Checked = True - Me.ucrChkUnstackData.Location = New System.Drawing.Point(8, 235) - Me.ucrChkUnstackData.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) - Me.ucrChkUnstackData.Name = "ucrChkUnstackData" - Me.ucrChkUnstackData.Size = New System.Drawing.Size(178, 23) - Me.ucrChkUnstackData.TabIndex = 9 - Me.ttClimsoft.SetToolTip(Me.ucrChkUnstackData, "Select Observation Data Date Range") - ' - 'ucrChkFlagsData - ' - Me.ucrChkFlagsData.AutoSize = True - Me.ucrChkFlagsData.Checked = False - Me.ucrChkFlagsData.Location = New System.Drawing.Point(8, 212) - Me.ucrChkFlagsData.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) - Me.ucrChkFlagsData.Name = "ucrChkFlagsData" - Me.ucrChkFlagsData.Size = New System.Drawing.Size(213, 23) - Me.ucrChkFlagsData.TabIndex = 8 - Me.ttClimsoft.SetToolTip(Me.ucrChkFlagsData, "Select Observation Data Date Range") - ' - 'ucrChkElements - ' - Me.ucrChkElements.AutoSize = True - Me.ucrChkElements.Checked = False - Me.ucrChkElements.Location = New System.Drawing.Point(8, 258) - Me.ucrChkElements.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) - Me.ucrChkElements.Name = "ucrChkElements" - Me.ucrChkElements.Size = New System.Drawing.Size(230, 23) - Me.ucrChkElements.TabIndex = 10 - Me.ttClimsoft.SetToolTip(Me.ucrChkElements, "Select Observation Data Date Range") - ' - 'ucrChkDateRange - ' - Me.ucrChkDateRange.AutoSize = True - Me.ucrChkDateRange.Checked = False - Me.ucrChkDateRange.Location = New System.Drawing.Point(8, 283) - Me.ucrChkDateRange.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) - Me.ucrChkDateRange.Name = "ucrChkDateRange" - Me.ucrChkDateRange.Size = New System.Drawing.Size(178, 23) - Me.ucrChkDateRange.TabIndex = 11 - Me.ttClimsoft.SetToolTip(Me.ucrChkDateRange, "Select Observation Data Date Range") - ' - 'ucrDtpEndDate - ' - Me.ucrDtpEndDate.AutoSize = True - Me.ucrDtpEndDate.DateValue = New Date(2021, 5, 18, 16, 45, 8, 379) - Me.ucrDtpEndDate.Format = "dd MMM yyyy" - Me.ucrDtpEndDate.Location = New System.Drawing.Point(36, 367) - Me.ucrDtpEndDate.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) - Me.ucrDtpEndDate.MaxDate = New Date(9998, 12, 31, 0, 0, 0, 0) - Me.ucrDtpEndDate.MinDate = New Date(1753, 1, 1, 0, 0, 0, 0) - Me.ucrDtpEndDate.Name = "ucrDtpEndDate" - Me.ucrDtpEndDate.Size = New System.Drawing.Size(163, 20) - Me.ucrDtpEndDate.TabIndex = 13 - Me.ttClimsoft.SetToolTip(Me.ucrDtpEndDate, "End Date (To)") - ' - 'ucrDtpStartdate - ' - Me.ucrDtpStartdate.AutoSize = True - Me.ucrDtpStartdate.DateValue = New Date(2021, 5, 18, 16, 45, 8, 408) - Me.ucrDtpStartdate.Format = "dd MMM yyyy" - Me.ucrDtpStartdate.Location = New System.Drawing.Point(35, 322) - Me.ucrDtpStartdate.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) - Me.ucrDtpStartdate.MaxDate = New Date(9998, 12, 31, 0, 0, 0, 0) - Me.ucrDtpStartdate.MinDate = New Date(1753, 1, 1, 0, 0, 0, 0) - Me.ucrDtpStartdate.Name = "ucrDtpStartdate" - Me.ucrDtpStartdate.Size = New System.Drawing.Size(163, 20) - Me.ucrDtpStartdate.TabIndex = 12 - Me.ttClimsoft.SetToolTip(Me.ucrDtpStartdate, "Start Date (From)") - ' - 'ucrChkObservationData - ' - Me.ucrChkObservationData.AutoSize = True - Me.ucrChkObservationData.Checked = False - Me.ucrChkObservationData.Location = New System.Drawing.Point(8, 188) - Me.ucrChkObservationData.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) - Me.ucrChkObservationData.Name = "ucrChkObservationData" - Me.ucrChkObservationData.Size = New System.Drawing.Size(202, 23) - Me.ucrChkObservationData.TabIndex = 7 - Me.ttClimsoft.SetToolTip(Me.ucrChkObservationData, "Select Observation Data Date Range") + 'btnConnection + ' + Me.btnConnection.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.btnConnection.Location = New System.Drawing.Point(7, 45) + Me.btnConnection.Name = "btnConnection" + Me.btnConnection.Size = New System.Drawing.Size(147, 23) + Me.btnConnection.TabIndex = 1 + Me.btnConnection.Text = "Connect to Database" + Me.btnConnection.UseVisualStyleBackColor = True + ' + 'lblSelectElements + ' + Me.lblSelectElements.AutoSize = True + Me.lblSelectElements.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblSelectElements.Location = New System.Drawing.Point(285, 226) + Me.lblSelectElements.Name = "lblSelectElements" + Me.lblSelectElements.Size = New System.Drawing.Size(86, 13) + Me.lblSelectElements.TabIndex = 4 + Me.lblSelectElements.Text = "Select Elements:" + ' + 'lblSelectStations + ' + Me.lblSelectStations.AutoSize = True + Me.lblSelectStations.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblSelectStations.Location = New System.Drawing.Point(285, 70) + Me.lblSelectStations.Name = "lblSelectStations" + Me.lblSelectStations.Size = New System.Drawing.Size(81, 13) + Me.lblSelectStations.TabIndex = 2 + Me.lblSelectStations.Text = "Select Stations:" + Me.lblSelectStations.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + ' + 'ucrChkImportElementsMetadata + ' + Me.ucrChkImportElementsMetadata.AutoSize = True + Me.ucrChkImportElementsMetadata.Checked = True + Me.ucrChkImportElementsMetadata.Location = New System.Drawing.Point(10, 110) + Me.ucrChkImportElementsMetadata.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) + Me.ucrChkImportElementsMetadata.Name = "ucrChkImportElementsMetadata" + Me.ucrChkImportElementsMetadata.Size = New System.Drawing.Size(213, 23) + Me.ucrChkImportElementsMetadata.TabIndex = 36 + Me.ttClimsoft.SetToolTip(Me.ucrChkImportElementsMetadata, "Unstack elements") + ' + 'ucrChkImportStationsMetadata + ' + Me.ucrChkImportStationsMetadata.AutoSize = True + Me.ucrChkImportStationsMetadata.Checked = True + Me.ucrChkImportStationsMetadata.Location = New System.Drawing.Point(10, 85) + Me.ucrChkImportStationsMetadata.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) + Me.ucrChkImportStationsMetadata.Name = "ucrChkImportStationsMetadata" + Me.ucrChkImportStationsMetadata.Size = New System.Drawing.Size(213, 23) + Me.ucrChkImportStationsMetadata.TabIndex = 35 + Me.ttClimsoft.SetToolTip(Me.ucrChkImportStationsMetadata, "Unstack elements") + ' + 'ucrChkDataDate + ' + Me.ucrChkDataDate.AutoSize = True + Me.ucrChkDataDate.Checked = False + Me.ucrChkDataDate.Location = New System.Drawing.Point(9, 289) + Me.ucrChkDataDate.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) + Me.ucrChkDataDate.Name = "ucrChkDataDate" + Me.ucrChkDataDate.Size = New System.Drawing.Size(169, 23) + Me.ucrChkDataDate.TabIndex = 21 + Me.ttClimsoft.SetToolTip(Me.ucrChkDataDate, "Select Observation Data Date Range") + ' + 'ucrDtpEndDataDate + ' + Me.ucrDtpEndDataDate.AutoSize = True + Me.ucrDtpEndDataDate.DateValue = New Date(2021, 5, 18, 16, 45, 8, 379) + Me.ucrDtpEndDataDate.Format = "dd MMM yyyy" + Me.ucrDtpEndDataDate.Location = New System.Drawing.Point(156, 312) + Me.ucrDtpEndDataDate.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) + Me.ucrDtpEndDataDate.MaxDate = New Date(9998, 12, 31, 0, 0, 0, 0) + Me.ucrDtpEndDataDate.MinDate = New Date(1753, 1, 1, 0, 0, 0, 0) + Me.ucrDtpEndDataDate.Name = "ucrDtpEndDataDate" + Me.ucrDtpEndDataDate.Size = New System.Drawing.Size(102, 20) + Me.ucrDtpEndDataDate.TabIndex = 23 + Me.ttClimsoft.SetToolTip(Me.ucrDtpEndDataDate, "End Date (To)") + ' + 'ucrDtpStartDataDate + ' + Me.ucrDtpStartDataDate.AutoSize = True + Me.ucrDtpStartDataDate.DateValue = New Date(2021, 5, 18, 16, 45, 8, 408) + Me.ucrDtpStartDataDate.Format = "dd MMM yyyy" + Me.ucrDtpStartDataDate.Location = New System.Drawing.Point(23, 313) + Me.ucrDtpStartDataDate.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) + Me.ucrDtpStartDataDate.MaxDate = New Date(9998, 12, 31, 0, 0, 0, 0) + Me.ucrDtpStartDataDate.MinDate = New Date(1753, 1, 1, 0, 0, 0, 0) + Me.ucrDtpStartDataDate.Name = "ucrDtpStartDataDate" + Me.ucrDtpStartDataDate.Size = New System.Drawing.Size(102, 20) + Me.ucrDtpStartDataDate.TabIndex = 22 + Me.ttClimsoft.SetToolTip(Me.ucrDtpStartDataDate, "Start Date (From)") + ' + 'ucrChkImportFlagsMetadata + ' + Me.ucrChkImportFlagsMetadata.AutoSize = True + Me.ucrChkImportFlagsMetadata.Checked = True + Me.ucrChkImportFlagsMetadata.Location = New System.Drawing.Point(10, 135) + Me.ucrChkImportFlagsMetadata.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) + Me.ucrChkImportFlagsMetadata.Name = "ucrChkImportFlagsMetadata" + Me.ucrChkImportFlagsMetadata.Size = New System.Drawing.Size(213, 23) + Me.ucrChkImportFlagsMetadata.TabIndex = 37 + Me.ttClimsoft.SetToolTip(Me.ucrChkImportFlagsMetadata, "Unstack elements") ' 'lblConnection ' Me.lblConnection.AutoSize = True Me.lblConnection.ForeColor = System.Drawing.Color.Red Me.lblConnection.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblConnection.Location = New System.Drawing.Point(153, 14) + Me.lblConnection.Location = New System.Drawing.Point(164, 51) Me.lblConnection.Name = "lblConnection" Me.lblConnection.Size = New System.Drawing.Size(78, 13) Me.lblConnection.TabIndex = 16 Me.lblConnection.Text = "No Connection" ' - 'ucrComboBoxElements - ' - Me.ucrComboBoxElements.AddQuotesIfUnrecognised = True - Me.ucrComboBoxElements.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrComboBoxElements.GetSetSelectedIndex = -1 - Me.ucrComboBoxElements.IsReadOnly = False - Me.ucrComboBoxElements.Location = New System.Drawing.Point(259, 210) - Me.ucrComboBoxElements.Margin = New System.Windows.Forms.Padding(9, 12, 9, 12) - Me.ucrComboBoxElements.Name = "ucrComboBoxElements" - Me.ucrComboBoxElements.Size = New System.Drawing.Size(137, 21) - Me.ucrComboBoxElements.TabIndex = 5 - ' - 'ucrComboBoxStations - ' - Me.ucrComboBoxStations.AddQuotesIfUnrecognised = True - Me.ucrComboBoxStations.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrComboBoxStations.GetSetSelectedIndex = -1 - Me.ucrComboBoxStations.IsReadOnly = False - Me.ucrComboBoxStations.Location = New System.Drawing.Point(256, 53) - Me.ucrComboBoxStations.Margin = New System.Windows.Forms.Padding(9, 12, 9, 12) - Me.ucrComboBoxStations.Name = "ucrComboBoxStations" - Me.ucrComboBoxStations.Size = New System.Drawing.Size(137, 21) - Me.ucrComboBoxStations.TabIndex = 3 + 'lblToDataDate + ' + Me.lblToDataDate.AutoSize = True + Me.lblToDataDate.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblToDataDate.Location = New System.Drawing.Point(130, 315) + Me.lblToDataDate.Name = "lblToDataDate" + Me.lblToDataDate.Size = New System.Drawing.Size(20, 13) + Me.lblToDataDate.TabIndex = 20 + Me.lblToDataDate.Text = "To" + ' + 'lblSelectTable + ' + Me.lblSelectTable.AutoSize = True + Me.lblSelectTable.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblSelectTable.Location = New System.Drawing.Point(5, 238) + Me.lblSelectTable.Name = "lblSelectTable" + Me.lblSelectTable.Size = New System.Drawing.Size(96, 13) + Me.lblSelectTable.TabIndex = 24 + Me.lblSelectTable.Text = "Select Data Table:" + Me.lblSelectTable.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + ' + 'lblSelectQCStatus + ' + Me.lblSelectQCStatus.AutoSize = True + Me.lblSelectQCStatus.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblSelectQCStatus.Location = New System.Drawing.Point(5, 265) + Me.lblSelectQCStatus.Name = "lblSelectQCStatus" + Me.lblSelectQCStatus.Size = New System.Drawing.Size(117, 13) + Me.lblSelectQCStatus.TabIndex = 26 + Me.lblSelectQCStatus.Text = "Select Data QC Status:" + Me.lblSelectQCStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + ' + 'btnCheckRecords + ' + Me.btnCheckRecords.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.btnCheckRecords.Location = New System.Drawing.Point(6, 376) + Me.btnCheckRecords.Name = "btnCheckRecords" + Me.btnCheckRecords.Size = New System.Drawing.Size(139, 23) + Me.btnCheckRecords.TabIndex = 28 + Me.btnCheckRecords.Text = "Check Records" + Me.btnCheckRecords.UseVisualStyleBackColor = True + ' + 'lblRecordsNum + ' + Me.lblRecordsNum.AutoSize = True + Me.lblRecordsNum.ForeColor = System.Drawing.Color.Red + Me.lblRecordsNum.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblRecordsNum.Location = New System.Drawing.Point(156, 380) + Me.lblRecordsNum.Name = "lblRecordsNum" + Me.lblRecordsNum.Size = New System.Drawing.Size(64, 13) + Me.lblRecordsNum.TabIndex = 29 + Me.lblRecordsNum.Text = "No Records" + ' + 'btnMoreOptions + ' + Me.btnMoreOptions.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.btnMoreOptions.Location = New System.Drawing.Point(5, 345) + Me.btnMoreOptions.Name = "btnMoreOptions" + Me.btnMoreOptions.Size = New System.Drawing.Size(139, 23) + Me.btnMoreOptions.TabIndex = 31 + Me.btnMoreOptions.Text = "More options" + Me.btnMoreOptions.UseVisualStyleBackColor = True + ' + 'rdoMetadata + ' + Me.rdoMetadata.Appearance = System.Windows.Forms.Appearance.Button + Me.rdoMetadata.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoMetadata.FlatAppearance.BorderSize = 2 + Me.rdoMetadata.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoMetadata.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.rdoMetadata.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.rdoMetadata.Location = New System.Drawing.Point(197, 5) + Me.rdoMetadata.Name = "rdoMetadata" + Me.rdoMetadata.Size = New System.Drawing.Size(145, 28) + Me.rdoMetadata.TabIndex = 34 + Me.rdoMetadata.TabStop = True + Me.rdoMetadata.Tag = "" + Me.rdoMetadata.Text = "Metadata" + Me.rdoMetadata.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + Me.rdoMetadata.UseVisualStyleBackColor = True + ' + 'rdoData + ' + Me.rdoData.Appearance = System.Windows.Forms.Appearance.Button + Me.rdoData.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoData.FlatAppearance.BorderSize = 2 + Me.rdoData.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoData.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.rdoData.Location = New System.Drawing.Point(55, 5) + Me.rdoData.Name = "rdoData" + Me.rdoData.Size = New System.Drawing.Size(145, 28) + Me.rdoData.TabIndex = 33 + Me.rdoData.TabStop = True + Me.rdoData.Tag = "" + Me.rdoData.Text = "Observation Data" + Me.rdoData.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + Me.rdoData.UseVisualStyleBackColor = True + ' + 'ucrPnlOptions + ' + Me.ucrPnlOptions.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrPnlOptions.Location = New System.Drawing.Point(6, 4) + Me.ucrPnlOptions.Margin = New System.Windows.Forms.Padding(5) + Me.ucrPnlOptions.Name = "ucrPnlOptions" + Me.ucrPnlOptions.Size = New System.Drawing.Size(428, 30) + Me.ucrPnlOptions.TabIndex = 32 + ' + 'ucrCboQCStatus + ' + Me.ucrCboQCStatus.AddQuotesIfUnrecognised = True + Me.ucrCboQCStatus.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrCboQCStatus.GetSetSelectedIndex = -1 + Me.ucrCboQCStatus.IsReadOnly = False + Me.ucrCboQCStatus.Location = New System.Drawing.Point(154, 259) + Me.ucrCboQCStatus.Margin = New System.Windows.Forms.Padding(9, 12, 9, 12) + Me.ucrCboQCStatus.Name = "ucrCboQCStatus" + Me.ucrCboQCStatus.Size = New System.Drawing.Size(104, 21) + Me.ucrCboQCStatus.TabIndex = 27 + ' + 'ucrCboTable + ' + Me.ucrCboTable.AddQuotesIfUnrecognised = True + Me.ucrCboTable.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrCboTable.GetSetSelectedIndex = -1 + Me.ucrCboTable.IsReadOnly = False + Me.ucrCboTable.Location = New System.Drawing.Point(154, 233) + Me.ucrCboTable.Margin = New System.Windows.Forms.Padding(9, 12, 9, 12) + Me.ucrCboTable.Name = "ucrCboTable" + Me.ucrCboTable.Size = New System.Drawing.Size(104, 21) + Me.ucrCboTable.TabIndex = 25 + ' + 'ucrCboElements + ' + Me.ucrCboElements.AddQuotesIfUnrecognised = True + Me.ucrCboElements.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrCboElements.GetSetSelectedIndex = -1 + Me.ucrCboElements.IsReadOnly = False + Me.ucrCboElements.Location = New System.Drawing.Point(288, 242) + Me.ucrCboElements.Margin = New System.Windows.Forms.Padding(9, 12, 9, 12) + Me.ucrCboElements.Name = "ucrCboElements" + Me.ucrCboElements.Size = New System.Drawing.Size(137, 21) + Me.ucrCboElements.TabIndex = 5 + ' + 'ucrCboStations + ' + Me.ucrCboStations.AddQuotesIfUnrecognised = True + Me.ucrCboStations.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrCboStations.GetSetSelectedIndex = -1 + Me.ucrCboStations.IsReadOnly = False + Me.ucrCboStations.Location = New System.Drawing.Point(285, 85) + Me.ucrCboStations.Margin = New System.Windows.Forms.Padding(9, 12, 9, 12) + Me.ucrCboStations.Name = "ucrCboStations" + Me.ucrCboStations.Size = New System.Drawing.Size(137, 21) + Me.ucrCboStations.TabIndex = 3 ' 'ucrSelectorForClimSoft ' Me.ucrSelectorForClimSoft.AutoSize = True Me.ucrSelectorForClimSoft.bShowHiddenColumns = False - Me.ucrSelectorForClimSoft.Location = New System.Drawing.Point(8, 43) + Me.ucrSelectorForClimSoft.Location = New System.Drawing.Point(7, 84) Me.ucrSelectorForClimSoft.Margin = New System.Windows.Forms.Padding(0) Me.ucrSelectorForClimSoft.Name = "ucrSelectorForClimSoft" Me.ucrSelectorForClimSoft.Size = New System.Drawing.Size(216, 147) @@ -244,7 +352,7 @@ Partial Class dlgClimSoft ' Me.ucrReceiverMultipleElements.AutoSize = True Me.ucrReceiverMultipleElements.frmParent = Me - Me.ucrReceiverMultipleElements.Location = New System.Drawing.Point(259, 234) + Me.ucrReceiverMultipleElements.Location = New System.Drawing.Point(288, 266) Me.ucrReceiverMultipleElements.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverMultipleElements.Name = "ucrReceiverMultipleElements" Me.ucrReceiverMultipleElements.Selector = Nothing @@ -257,7 +365,7 @@ Partial Class dlgClimSoft ' Me.ucrReceiverMultipleStations.AutoSize = True Me.ucrReceiverMultipleStations.frmParent = Me - Me.ucrReceiverMultipleStations.Location = New System.Drawing.Point(256, 77) + Me.ucrReceiverMultipleStations.Location = New System.Drawing.Point(285, 109) Me.ucrReceiverMultipleStations.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverMultipleStations.Name = "ucrReceiverMultipleStations" Me.ucrReceiverMultipleStations.Selector = Nothing @@ -270,10 +378,10 @@ Partial Class dlgClimSoft ' Me.ucrBase.AutoSize = True Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(8, 402) + Me.ucrBase.Location = New System.Drawing.Point(9, 407) Me.ucrBase.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.ucrBase.Name = "ucrBase" - Me.ucrBase.Size = New System.Drawing.Size(405, 52) + Me.ucrBase.Size = New System.Drawing.Size(408, 52) Me.ucrBase.TabIndex = 14 ' 'dlgClimSoft @@ -281,25 +389,33 @@ Partial Class dlgClimSoft Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True - Me.ClientSize = New System.Drawing.Size(408, 459) - Me.Controls.Add(Me.ucrChkUnstackData) - Me.Controls.Add(Me.ucrChkFlagsData) + Me.ClientSize = New System.Drawing.Size(438, 464) + Me.Controls.Add(Me.ucrChkImportFlagsMetadata) + Me.Controls.Add(Me.ucrChkImportElementsMetadata) + Me.Controls.Add(Me.ucrChkImportStationsMetadata) + Me.Controls.Add(Me.rdoMetadata) + Me.Controls.Add(Me.rdoData) + Me.Controls.Add(Me.ucrPnlOptions) + Me.Controls.Add(Me.btnMoreOptions) + Me.Controls.Add(Me.lblRecordsNum) + Me.Controls.Add(Me.btnCheckRecords) + Me.Controls.Add(Me.ucrCboQCStatus) + Me.Controls.Add(Me.lblSelectQCStatus) + Me.Controls.Add(Me.ucrCboTable) + Me.Controls.Add(Me.lblSelectTable) + Me.Controls.Add(Me.ucrChkDataDate) + Me.Controls.Add(Me.ucrDtpEndDataDate) + Me.Controls.Add(Me.ucrDtpStartDataDate) + Me.Controls.Add(Me.lblToDataDate) Me.Controls.Add(Me.lblConnection) - Me.Controls.Add(Me.ucrChkElements) - Me.Controls.Add(Me.ucrComboBoxElements) - Me.Controls.Add(Me.ucrComboBoxStations) - Me.Controls.Add(Me.ucrChkDateRange) - Me.Controls.Add(Me.ucrDtpEndDate) - Me.Controls.Add(Me.ucrDtpStartdate) - Me.Controls.Add(Me.ucrChkObservationData) - Me.Controls.Add(Me.lblEndDate) + Me.Controls.Add(Me.ucrCboElements) + Me.Controls.Add(Me.ucrCboStations) Me.Controls.Add(Me.ucrSelectorForClimSoft) - Me.Controls.Add(Me.lblStartDate) Me.Controls.Add(Me.ucrReceiverMultipleElements) - Me.Controls.Add(Me.lblStations) - Me.Controls.Add(Me.lblElements) + Me.Controls.Add(Me.lblSelectStations) + Me.Controls.Add(Me.lblSelectElements) Me.Controls.Add(Me.ucrReceiverMultipleStations) - Me.Controls.Add(Me.cmdEstablishConnection) + Me.Controls.Add(Me.btnConnection) Me.Controls.Add(Me.ucrBase) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.MaximizeBox = False @@ -313,23 +429,31 @@ Partial Class dlgClimSoft End Sub Friend WithEvents ucrBase As ucrButtons - Friend WithEvents cmdEstablishConnection As Button + Friend WithEvents btnConnection As Button Friend WithEvents ucrReceiverMultipleStations As ucrReceiverMultiple Friend WithEvents ucrReceiverMultipleElements As ucrReceiverMultiple - Friend WithEvents lblStations As Label - Friend WithEvents lblElements As Label - Friend WithEvents lblStartDate As Label + Friend WithEvents lblSelectStations As Label + Friend WithEvents lblSelectElements As Label Friend WithEvents ucrSelectorForClimSoft As ucrSelectorAddRemove - Friend WithEvents lblEndDate As Label Friend WithEvents ttClimsoft As ToolTip - Friend WithEvents ucrDtpEndDate As ucrDateTimePicker - Friend WithEvents ucrDtpStartdate As ucrDateTimePicker - Friend WithEvents ucrChkObservationData As ucrCheck - Friend WithEvents ucrChkDateRange As ucrCheck - Friend WithEvents ucrComboBoxStations As ucrInputComboBox - Friend WithEvents ucrComboBoxElements As ucrInputComboBox - Friend WithEvents ucrChkElements As ucrCheck + Friend WithEvents ucrCboStations As ucrInputComboBox + Friend WithEvents ucrCboElements As ucrInputComboBox Friend WithEvents lblConnection As Label - Friend WithEvents ucrChkFlagsData As ucrCheck - Friend WithEvents ucrChkUnstackData As ucrCheck -End Class + Friend WithEvents ucrChkDataDate As ucrCheck + Friend WithEvents ucrDtpEndDataDate As ucrDateTimePicker + Friend WithEvents ucrDtpStartDataDate As ucrDateTimePicker + Friend WithEvents lblToDataDate As Label + Friend WithEvents ucrCboTable As ucrInputComboBox + Friend WithEvents lblSelectTable As Label + Friend WithEvents ucrCboQCStatus As ucrInputComboBox + Friend WithEvents lblSelectQCStatus As Label + Friend WithEvents lblRecordsNum As Label + Friend WithEvents btnCheckRecords As Button + Friend WithEvents btnMoreOptions As Button + Friend WithEvents rdoMetadata As RadioButton + Friend WithEvents rdoData As RadioButton + Friend WithEvents ucrPnlOptions As UcrPanel + Friend WithEvents ucrChkImportElementsMetadata As ucrCheck + Friend WithEvents ucrChkImportStationsMetadata As ucrCheck + Friend WithEvents ucrChkImportFlagsMetadata As ucrCheck +End Class \ No newline at end of file diff --git a/instat/dlgClimSoft.vb b/instat/dlgClimSoft.vb index fd5aeac8f7a..c6113117e85 100644 --- a/instat/dlgClimSoft.vb +++ b/instat/dlgClimSoft.vb @@ -14,28 +14,22 @@ ' You should have received a copy of the GNU General Public License ' along with this program. If not, see . -Imports instat + Imports instat.Translations +Imports RDotNet Public Class dlgClimSoft Private bFirstLoad As Boolean = True Private bReset As Boolean = True - Private clsRImportFromClimsoft As New RFunction + Private clsRImportClimsoftData, clsRImportClimsoftMetaData As New RFunction - 'the 2 dictionaries hold data for the station and elements comboboxes + 'the 4 dictionaries hold data for the station, elements, tables and QC comboboxes 'As of 28th August 2020, there is no direct way of getting the selected value from the custom combobox 'these are declared here to be used in getting the selected value - Private dctStationColumns As New Dictionary(Of String, String) - Private dctElementsColumns As New Dictionary(Of String, String) - - 'flag used by elements receiver to determine when not to clear itself and change its sql query - 'useful when form is reloaded, to let the elements reciever retain the elements selected - Private bIgnoreReceiverChanges As Boolean = False + Private dctStationCols, dctElementsCols, dctTables, dctQCStatuses As New Dictionary(Of String, String) Private Sub dlgClimSoft_Load(sender As Object, e As EventArgs) Handles MyBase.Load - bIgnoreReceiverChanges = True If bFirstLoad Then - bIgnoreReceiverChanges = False InitialiseDialog() bFirstLoad = False End If @@ -44,7 +38,6 @@ Public Class dlgClimSoft End If SetRCodeForControls(bReset) bReset = False - bIgnoreReceiverChanges = False CheckAndUpdateConnectionStatus() 'autoTranslate(Me) ' temporary commented, affects the connected text by overwriting it with wrong text End Sub @@ -52,221 +45,287 @@ Public Class dlgClimSoft Private Sub InitialiseDialog() ucrBase.iHelpTopicID = 329 - 'stations combobox - dctStationColumns.Add("Station IDs", Chr(34) & "stationId" & Chr(34)) - dctStationColumns.Add("Station Names", Chr(34) & "stationName" & Chr(34)) - dctStationColumns.Add("Station Qualifiers", Chr(34) & "qualifier" & Chr(34)) - ucrComboBoxStations.SetParameter(New RParameter("stationfiltercolumn", 0)) - ucrComboBoxStations.SetItems(dctStationColumns) - ucrComboBoxStations.SetRDefault(Chr(34) & "stationId" & Chr(34)) - ucrComboBoxStations.bAllowNonConditionValues = False - ucrComboBoxStations.SetDropDownStyleAsNonEditable() - - 'stations receiver - ucrReceiverMultipleStations.SetParameter(New RParameter("stations", 1)) + '--------------------------------------- + 'tables + dctTables.Add("Initial", Chr(34) & "observationinitial" & Chr(34)) + dctTables.Add("Final", Chr(34) & "observationfinal" & Chr(34)) + ucrCboTable.SetParameter(New RParameter("table", 0)) + ucrCboTable.SetItems(dctTables) + ucrCboTable.bAllowNonConditionValues = False + ucrCboTable.SetDropDownStyleAsNonEditable() + ucrCboTable.SetLinkedDisplayControl(lblSelectTable) + '--------------------------------------- + + 'stations + '--------------------------------------- + dctStationCols.Add("Station IDs", Chr(34) & "stationId" & Chr(34)) + dctStationCols.Add("Station Names", Chr(34) & "stationName" & Chr(34)) + dctStationCols.Add("Station Qualifiers", Chr(34) & "qualifier" & Chr(34)) + ucrCboStations.SetParameter(New RParameter("station_filter_column", 1)) + ucrCboStations.SetItems(dctStationCols) + ucrCboStations.bAllowNonConditionValues = False + ucrCboStations.SetDropDownStyleAsNonEditable() + ucrCboElements.SetLinkedDisplayControl(lblSelectElements) + + ucrReceiverMultipleStations.SetParameter(New RParameter("stations", 2)) ucrReceiverMultipleStations.SetParameterIsString() ucrReceiverMultipleStations.Selector = ucrSelectorForClimSoft ucrReceiverMultipleStations.SetItemType("database_variables") ucrReceiverMultipleStations.strSelectorHeading = "Stations" - ucrReceiverMultipleStations.SetLinkedDisplayControl(lblStations) - - 'elements combobox - dctElementsColumns.Add("Element IDs", Chr(34) & "elementId" & Chr(34)) - dctElementsColumns.Add("Element Names", Chr(34) & "elementName" & Chr(34)) - dctElementsColumns.Add("Element Abbreviation", Chr(34) & "abbreviation" & Chr(34)) - dctElementsColumns.Add("Element Types", Chr(34) & "elementtype" & Chr(34)) - ucrComboBoxElements.SetParameter(New RParameter("elementfiltercolumn", 2)) - ucrComboBoxElements.SetItems(dctElementsColumns) - ucrComboBoxElements.SetRDefault(Chr(34) & "elementId" & Chr(34)) - ucrComboBoxElements.bAllowNonConditionValues = False - ucrComboBoxElements.SetDropDownStyleAsNonEditable() - - 'elements receiver - ucrReceiverMultipleElements.SetParameter(New RParameter("elements", 3)) + ucrReceiverMultipleStations.SetLinkedDisplayControl(lblSelectStations) + '--------------------------------------- + + 'elements + '--------------------------------------- + dctElementsCols.Add("Element IDs", Chr(34) & "elementId" & Chr(34)) + dctElementsCols.Add("Element Names", Chr(34) & "elementName" & Chr(34)) + dctElementsCols.Add("Element Abbreviation", Chr(34) & "abbreviation" & Chr(34)) + dctElementsCols.Add("Element Types", Chr(34) & "elementtype" & Chr(34)) + ucrCboElements.SetParameter(New RParameter("element_filter_column", 3)) + ucrCboElements.SetItems(dctElementsCols) + ucrCboElements.bAllowNonConditionValues = False + ucrCboElements.SetDropDownStyleAsNonEditable() + ucrCboElements.SetLinkedDisplayControl(lblSelectElements) + + ucrReceiverMultipleElements.SetParameter(New RParameter("elements", 4)) ucrReceiverMultipleElements.SetParameterIsString() ucrReceiverMultipleElements.Selector = ucrSelectorForClimSoft ucrReceiverMultipleElements.SetItemType("database_variables") ucrReceiverMultipleElements.strSelectorHeading = "Elements" - ucrReceiverMultipleElements.SetLinkedDisplayControl(lblElements) - - 'include observation data checkbox - ucrChkObservationData.SetText("Include Observation Data") - ucrChkObservationData.SetParameter(New RParameter("include_observation_data", 4)) - ucrChkObservationData.SetRDefault("FALSE") - - 'include flags data checkbox - ucrChkFlagsData.SetText("Include Observation Flags") - ucrChkFlagsData.SetParameter(New RParameter("include_observation_flags", 5)) - ucrChkFlagsData.SetRDefault("FALSE") - - 'include Unstack data checkbox. - 'parameter attached to it is determined by elements receiver no. of contents. Thus not directly set by the control - ucrChkUnstackData.SetText("Unstack Data") - 'ucrChkUnstackData.Checked = True - - 'include elements info checkbox - ucrChkElements.SetText("Include Elements Information") - ucrChkElements.SetParameter(New RParameter("include_elements_info", 7)) - ucrChkElements.SetRDefault("FALSE") - - 'date range checkbox - ucrChkDateRange.SetText("Select Date Range") - - 'start date datepicker - ucrDtpStartdate.SetParameter(New RParameter("start_date", 8)) - ucrDtpStartdate.SetParameterIsRDate() - ucrDtpStartdate.SetLinkedDisplayControl(lblStartDate) - - 'end date datepicker - ucrDtpEndDate.SetParameter(New RParameter("end_date", 9)) - ucrDtpEndDate.SetParameterIsRDate() - ucrDtpEndDate.SetLinkedDisplayControl(lblEndDate) - - 'linking observation data related controls to include observation data checkbox - ucrChkObservationData.AddToLinkedControls({ucrChkFlagsData, ucrChkUnstackData, ucrChkElements, ucrComboBoxElements, ucrReceiverMultipleElements}, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) - 'link date range checkbox - ucrChkObservationData.AddToLinkedControls({ucrChkDateRange}, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) - 'linking date pickers to date range checkbox - ucrChkDateRange.AddToLinkedControls({ucrDtpStartdate, ucrDtpEndDate}, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrReceiverMultipleElements.SetLinkedDisplayControl(lblSelectElements) + '--------------------------------------- + + 'qc status + '--------------------------------------- + dctQCStatuses.Add("All", "-1") + dctQCStatuses.Add("Zero", "0") + dctQCStatuses.Add("One", "1") + dctQCStatuses.Add("Two", "2") + ucrCboQCStatus.SetParameter(New RParameter("qc_status", 5)) + ucrCboQCStatus.SetItems(dctQCStatuses) + ucrCboQCStatus.SetRDefault("-1") + ucrCboQCStatus.bAllowNonConditionValues = False + ucrCboQCStatus.SetDropDownStyleAsNonEditable() + ucrCboQCStatus.SetLinkedDisplayControl(lblSelectQCStatus) + '--------------------------------------- + + 'date range + '--------------------------------------- + ucrChkDataDate.SetText("Select Data Date") + + ucrDtpStartDataDate.SetParameter(New RParameter("start_date", 6)) + ucrDtpStartDataDate.SetParameterIsRDate() + ucrDtpStartDataDate.SetLinkedDisplayControl(lblToDataDate) + + ucrDtpEndDataDate.SetParameter(New RParameter("end_date", 7)) + ucrDtpEndDataDate.SetParameterIsRDate() + + ucrChkDataDate.AddToLinkedControls({ucrDtpStartDataDate, ucrDtpEndDataDate}, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + '--------------------------------------- + + 'metadata controls + '--------------------------------------- + ucrChkImportStationsMetadata.SetText("Import All Stations Metadata") + ucrChkImportStationsMetadata.SetParameter(New RParameter("import_stations", 0)) + ucrChkImportStationsMetadata.SetRDefault("FALSE") + + ucrChkImportElementsMetadata.SetText("Import All Elements Metadata") + ucrChkImportElementsMetadata.SetParameter(New RParameter("import_elements", 2)) + ucrChkImportElementsMetadata.SetRDefault("FALSE") + + ucrChkImportFlagsMetadata.SetText("Import All Flags Metadata") + ucrChkImportFlagsMetadata.SetParameter(New RParameter("import_flags", 3)) + ucrChkImportFlagsMetadata.SetRDefault("FALSE") + '--------------------------------------- + + 'dialog options + '--------------------------------------- + ucrPnlOptions.AddRadioButton(rdoData) + ucrPnlOptions.AddRadioButton(rdoMetadata) + + ucrPnlOptions.AddFunctionNamesCondition(rdoData, frmMain.clsRLink.strInstatDataObject & "$import_climsoft_data") + ucrPnlOptions.AddFunctionNamesCondition(rdoMetadata, frmMain.clsRLink.strInstatDataObject & "$import_climsoft_metadata") + + + ucrPnlOptions.AddToLinkedControls({ucrCboTable, ucrCboQCStatus, ucrSelectorForClimSoft, ucrReceiverMultipleStations, ucrReceiverMultipleElements, ucrCboStations, ucrCboElements, ucrChkDataDate}, + {rdoData}, bNewLinkedAddRemoveParameter:=False, bNewLinkedHideIfParameterMissing:=True) + ucrPnlOptions.AddToLinkedControls({ucrChkImportStationsMetadata, ucrChkImportElementsMetadata, ucrChkImportFlagsMetadata}, + {rdoMetadata}, bNewLinkedAddRemoveParameter:=False, bNewLinkedHideIfParameterMissing:=True) + + '--------------------------------------- End Sub Private Sub SetDefaults() - clsRImportFromClimsoft = New RFunction - clsRImportFromClimsoft.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$import_from_climsoft") - ucrBase.clsRsyntax.SetBaseRFunction(clsRImportFromClimsoft) + clsRImportClimsoftData = New RFunction + clsRImportClimsoftMetaData = New RFunction + + 'data command + '--------------------------------------- + clsRImportClimsoftData.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$import_climsoft_data") + clsRImportClimsoftData.AddParameter(strParameterName:="table", strParameterValue:=Chr(34) & "observationinitial" & Chr(34), iPosition:=0) + clsRImportClimsoftData.AddParameter(strParameterName:="station_filter_column", strParameterValue:=Chr(34) & "stationId" & Chr(34), iPosition:=1) + clsRImportClimsoftData.AddParameter(strParameterName:="element_filter_column", strParameterValue:=Chr(34) & "elementId" & Chr(34), iPosition:=3) + '--------------------------------------- + + 'metadata command + '--------------------------------------- + clsRImportClimsoftMetaData.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$import_climsoft_metadata") + '--------------------------------------- + + ucrBase.clsRsyntax.SetBaseRFunction(clsRImportClimsoftData) - ucrReceiverMultipleStations.SetMeAsReceiver() ucrSelectorForClimSoft.Reset() - ucrChkUnstackData.Checked = True - ucrChkDateRange.Checked = False + ucrReceiverMultipleStations.SetMeAsReceiver() + ucrChkDataDate.Checked = False + rdoData.Checked = True End Sub Private Sub SetRCodeForControls(bReset As Boolean) - ucrComboBoxStations.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) - ucrReceiverMultipleStations.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) - ucrComboBoxElements.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) - ucrReceiverMultipleElements.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) - ucrChkObservationData.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) - ucrChkFlagsData.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) - ucrChkElements.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) - ucrDtpStartdate.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) - ucrDtpEndDate.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) - End Sub - Private Sub TestOKEnabled() - ucrBase.OKEnabled((Not ucrReceiverMultipleStations.IsEmpty() AndAlso Not ucrChkObservationData.Checked) OrElse (Not ucrReceiverMultipleElements.IsEmpty() AndAlso ucrChkObservationData.Checked)) - End Sub + 'data option + '--------------------------------------- + ucrCboStations.SetRCode(clsRImportClimsoftData, bReset) + ucrReceiverMultipleStations.SetRCode(clsRImportClimsoftData, bReset) - Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset - SetDefaults() - SetRCodeForControls(True) - sdgImportFromClimSoft.Reset() - CheckAndUpdateConnectionStatus() - TestOKEnabled() + ucrCboElements.SetRCode(clsRImportClimsoftData, bReset) + ucrReceiverMultipleElements.SetRCode(clsRImportClimsoftData, bReset) + + ucrCboTable.SetRCode(clsRImportClimsoftData, bReset) + + ucrCboQCStatus.SetRCode(clsRImportClimsoftData, bReset) + + ucrDtpStartDataDate.SetRCode(clsRImportClimsoftData, bReset) + ucrDtpEndDataDate.SetRCode(clsRImportClimsoftData, bReset) + + 'data sub dialog + sdgClimsoft.SetRCode(clsRImportClimsoftData, bReset) + '--------------------------------------- + + 'metadata option + '--------------------------------------- + ucrChkImportStationsMetadata.SetRCode(clsRImportClimsoftMetaData, bReset) + ucrChkImportElementsMetadata.SetRCode(clsRImportClimsoftMetaData, bReset) + ucrChkImportFlagsMetadata.SetRCode(clsRImportClimsoftMetaData, bReset) + '--------------------------------------- End Sub - Private Sub btnEstablishConnection_Click(sender As Object, e As EventArgs) Handles cmdEstablishConnection.Click + Private Sub btnConnection_Click(sender As Object, e As EventArgs) Handles btnConnection.Click 'shows the database connect sub dialog and checks if connection has been established sdgImportFromClimSoft.ShowDialog() CheckAndUpdateConnectionStatus() ucrReceiverMultipleStations.Clear() + ucrReceiverMultipleElements.Clear() ucrReceiverMultipleStations.SetMeAsReceiver() End Sub - ''' - ''' constructs and sets the stations reciver SQL query - ''' - ''' returns true if receivers query was changed - Private Function SetStationsReceiverQuery() As Boolean - If dctStationColumns.Count < 1 Then - Return False - End If - - 'sql query to get station values of the selected column from station table - Dim strQuery As String - Dim strSelectedColumn As String = dctStationColumns.Item(ucrComboBoxStations.GetText).Trim("""") - - strQuery = "SELECT DISTINCT " & strSelectedColumn & " FROM station WHERE " & strSelectedColumn & " IS NOT NULL AND " & strSelectedColumn & " <> '';" - If ucrReceiverMultipleStations.strDatabaseQuery = strQuery Then - Return False - End If - ucrReceiverMultipleStations.Clear() - ucrReceiverMultipleStations.strDatabaseQuery = strQuery - Return True - End Function - - ''' - ''' constructs and sets elements receiver SQL query - ''' - ''' returns true if receivers query was changed - Private Function SetElementsRecieverQuery() As Boolean - If dctElementsColumns.Count < 1 Then - Return False - End If + Private Sub ucrPnlOption_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlOptions.ControlValueChanged + btnMoreOptions.Visible = rdoData.Checked + btnCheckRecords.Visible = rdoData.Checked + lblRecordsNum.Visible = rdoData.Checked + ucrBase.clsRsyntax.SetBaseRFunction(If(rdoData.Checked, clsRImportClimsoftData, clsRImportClimsoftMetaData)) + End Sub - 'sql query to get distinct element values of the selected column(obselement TABLE COLUMN) from the observationfinal table - Dim strQuery As String - strQuery = "SELECT DISTINCT obselement." & dctElementsColumns.Item(ucrComboBoxElements.GetText).Trim("""") & - " FROM observationfinal" & - " INNER JOIN obselement ON observationfinal.describedBy = obselement.elementId" & - " INNER JOIN station ON observationfinal.recordedFrom = station.stationId" - 'if stations have been specified, then get elements for those stations only - If Not ucrReceiverMultipleStations.IsEmpty Then - strQuery = strQuery & " WHERE " & "station." & dctStationColumns.Item(ucrComboBoxStations.GetText).Trim("""") & " IN (" & - String.Join(",", ucrReceiverMultipleStations.GetVariableNamesList(strQuotes:=Chr(39))) & ")" + Private Sub ucrCboStations_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrCboStations.ControlValueChanged + If dctStationCols.Count < 1 Then + Exit Sub End If - strQuery &= ";" + SetRecieverQuery("station", dctStationCols.Item(ucrCboStations.GetText).Trim(""""), ucrReceiverMultipleStations) + 'set as selected receiver. will also execute the receiver's sql query + ucrReceiverMultipleStations.SetMeAsReceiver() + End Sub - If ucrReceiverMultipleElements.strDatabaseQuery = strQuery Then - Return False - End If - ucrReceiverMultipleElements.Clear() - ucrReceiverMultipleElements.strDatabaseQuery = strQuery - Return True - End Function - - Private Sub ucrComboBoxStations_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrComboBoxStations.ControlValueChanged - If SetStationsReceiverQuery() Then - 'set as selected receiver. will also execute the receiver's sql query - ucrReceiverMultipleStations.SetMeAsReceiver() + Private Sub ucrCboElements_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrCboElements.ControlValueChanged + If dctElementsCols.Count < 1 Then + Exit Sub End If + SetRecieverQuery("obselement", dctElementsCols.Item(ucrCboElements.GetText).Trim(""""), ucrReceiverMultipleElements) + 'set as selected receiver. will also execute receiver's sql the query + ucrReceiverMultipleElements.SetMeAsReceiver() End Sub - Private Sub ucrReceiverMultipleStations_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverMultipleStations.ControlValueChanged - If Not bIgnoreReceiverChanges Then - SetElementsRecieverQuery() + + Private Sub ucrChkDataDate_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkDataDate.ControlValueChanged + 'this forces the date pickers to write default parameter values to the Rfunction. + 'date picker controls have a problem of default date. + 'its not set by default until the user changes selected date + 'todo. in future, this may not be needed + If ucrChkDataDate.Checked Then + ucrDtpEndDataDate.OnControlValueChanged() + ucrDtpStartDataDate.OnControlValueChanged() End If End Sub - Private Sub ucrComboBoxElements_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrComboBoxElements.ControlValueChanged - If SetElementsRecieverQuery() Then - 'set as selected receiver. will also execute receiver's sql the query - ucrReceiverMultipleElements.SetMeAsReceiver() - End If + Private Sub btnMoreOptions_Click(sender As Object, e As EventArgs) Handles btnMoreOptions.Click + sdgClimsoft.ShowDialog() + lblRecordsNum.Text = "" End Sub - Private Sub ucrUnstackDataControlsValueChanged_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkUnstackData.ControlValueChanged, ucrReceiverMultipleElements.ControlValueChanged, ucrChkObservationData.ControlValueChanged - 'only change the receivers if the event was raised by ucrChkObservationData checkbox - If TypeOf ucrChangedControl Is ucrCheck Then - If ucrChkObservationData.Checked Then - ucrReceiverMultipleElements.SetMeAsReceiver() - Else - ucrReceiverMultipleStations.SetMeAsReceiver() + Private Sub btnCheckRecords_Click(sender As Object, e As EventArgs) Handles btnCheckRecords.Click + Try + lblRecordsNum.Text = "" + Dim strTableName As String = dctTables.Item(ucrCboTable.GetText).Trim("""") + Dim strStationColumn As String = dctStationCols.Item(ucrCboStations.GetText).Trim("""") + Dim strElementsColumn As String = dctElementsCols.Item(ucrCboElements.GetText).Trim("""") + Dim strStationsValues As String = String.Join(",", ucrReceiverMultipleStations.GetVariableNamesList(bWithQuotes:=True, strQuotes:="'")) + Dim strElementsValues As String = String.Join(",", ucrReceiverMultipleElements.GetVariableNamesList(bWithQuotes:=True, strQuotes:="'")) + Dim strQueryCondition As String = " INNER JOIN station ON " & strTableName & ".recordedFrom = station.stationId" & + " INNER JOIN obselement ON " & strTableName & ".describedBy = obselement.elementId WHERE" & + " station." & strStationColumn & " IN (" & strStationsValues & ")" & + " AND obselement." & strElementsColumn & " IN (" & strElementsValues & ")" + + Dim strQCStatus As String = If(dctQCStatuses.Item(ucrCboQCStatus.GetText) = "-1", "", dctQCStatuses.Item(ucrCboQCStatus.GetText)) + + If dctQCStatuses.Item(ucrCboQCStatus.GetText) <> "-1" Then + strQueryCondition = strQueryCondition & " AND qcStatus = " & dctQCStatuses.Item(ucrCboQCStatus.GetText) End If - End If - 'unstack observation data only when more than 1 element is selected - If ucrChkObservationData.Checked AndAlso ucrReceiverMultipleElements.GetVariableNamesAsList.Count > 1 Then - ucrChkUnstackData.Enabled = True - clsRImportFromClimsoft.AddParameter("unstack_data", If(ucrChkUnstackData.Checked, "TRUE", "FALSE"), iPosition:=6) - Else - ucrChkUnstackData.Enabled = False - clsRImportFromClimsoft.RemoveParameterByName("unstack_data") + If ucrChkDataDate.Checked Then + strQueryCondition = strQueryCondition & " AND obsDatetime >= '" & ucrDtpStartDataDate.DateValue.ToString("yyyy-MM-dd") & "' AND obsDatetime <= '" & ucrDtpEndDataDate.DateValue.ToString("yyyy-MM-dd") & "'" + End If + + Dim clsRowsCountRFunction As New RFunction + clsRowsCountRFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_db_table_row_count") + clsRowsCountRFunction.AddParameter(strParameterName:="tableName", strParameterValue:=Chr(34) & strTableName & Chr(34)) + clsRowsCountRFunction.AddParameter(strParameterName:="query_condition", strParameterValue:=Chr(34) & strQueryCondition & Chr(34)) + + Dim expTemp As SymbolicExpression = frmMain.clsRLink.RunInternalScriptGetValue(clsRowsCountRFunction.ToScript()) + If expTemp IsNot Nothing Then + Dim recordsNum As Integer = expTemp.AsNumeric().FirstOrDefault() + lblRecordsNum.Text = recordsNum & " records found" + lblRecordsNum.ForeColor = If(recordsNum > 0, Color.Green, Color.Red) + End If + Catch ex As Exception + MessageBox.Show(Me, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) + End Try + End Sub + + Private Sub ucrControlsContents_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverMultipleStations.ControlContentsChanged, ucrReceiverMultipleElements.ControlContentsChanged, ucrCboTable.ControlContentsChanged, ucrCboQCStatus.ControlContentsChanged, ucrDtpStartDataDate.ControlContentsChanged, ucrDtpEndDataDate.ControlContentsChanged, ucrPnlOptions.ControlContentsChanged, ucrChkImportStationsMetadata.ControlContentsChanged, ucrChkImportElementsMetadata.ControlContentsChanged, ucrChkImportFlagsMetadata.ControlContentsChanged + Dim bValid As Boolean = False + If rdoData.Checked Then + bValid = Not ucrReceiverMultipleStations.IsEmpty() AndAlso Not ucrReceiverMultipleElements.IsEmpty() AndAlso Not ucrCboTable.IsEmpty() + btnCheckRecords.Enabled = bValid + lblRecordsNum.Text = "" + ElseIf rdoMetadata.Checked Then + bValid = ucrChkImportStationsMetadata.Checked OrElse ucrChkImportElementsMetadata.Checked OrElse ucrChkImportFlagsMetadata.Checked End If + ucrBase.OKEnabled(bValid) End Sub - Private Sub ucrControlsContents_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverMultipleStations.ControlContentsChanged, ucrReceiverMultipleElements.ControlContentsChanged, ucrChkObservationData.ControlContentsChanged, ucrChkUnstackData.ControlContentsChanged - TestOKEnabled() + Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset + SetDefaults() + SetRCodeForControls(True) + sdgImportFromClimSoft.Reset() + CheckAndUpdateConnectionStatus() + End Sub + + Private Sub SetRecieverQuery(strTable As String, strSelectedColumn As String, ucrReceiverControl As ucrReceiverMultiple) + 'sql query to get values of the selected column from the table + Dim strQuery As String = "SELECT DISTINCT " & strSelectedColumn & " FROM " & strTable & " WHERE " & strSelectedColumn & " IS NOT NULL AND " & strSelectedColumn & " <> '';" + If ucrReceiverControl.strDatabaseQuery = strQuery Then + Exit Sub + End If + ucrReceiverControl.Clear() + ucrReceiverControl.strDatabaseQuery = strQuery End Sub Private Sub CheckAndUpdateConnectionStatus() @@ -277,18 +336,9 @@ Public Class dlgClimSoft lblConnection.Text = "No Connection" lblConnection.ForeColor = Color.Red ucrReceiverMultipleStations.Clear() + ucrReceiverMultipleElements.Clear() End If - autoTranslate(Me) End Sub - Private Sub ucrChkDateRange_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkDateRange.ControlValueChanged - 'this forces the date pickers to write default parameter values to the Rfunction. - 'date picker controls have a problem of default date. - 'its not set by default until the user changes selected date - 'todo. in future, this may not be needed - If ucrChkDateRange.Checked Then - ucrDtpEndDate.OnControlValueChanged() - ucrDtpStartdate.OnControlValueChanged() - End If - End Sub -End Class + +End Class \ No newline at end of file diff --git a/instat/instat.vbproj b/instat/instat.vbproj index 741d4f7da58..ac9774d99bb 100644 --- a/instat/instat.vbproj +++ b/instat/instat.vbproj @@ -313,6 +313,12 @@ + + sdgClimsoft.vb + + + Form + sdgDefineAnnualRainfall.vb diff --git a/instat/sdgClimsoft.Designer.vb b/instat/sdgClimsoft.Designer.vb new file mode 100644 index 00000000000..0dc1103611d --- /dev/null +++ b/instat/sdgClimsoft.Designer.vb @@ -0,0 +1,259 @@ + +Partial Class sdgClimsoft + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + + Private Sub InitializeComponent() + Me.tbpTitles = New System.Windows.Forms.TabPage() + Me.grpMetadataToImport = New System.Windows.Forms.GroupBox() + Me.tbColumns = New System.Windows.Forms.TabPage() + Me.grpColumnsToInclude = New System.Windows.Forms.GroupBox() + Me.tbpMoreOptions = New System.Windows.Forms.TabControl() + Me.ucrBaseSubdialog = New instat.ucrButtonsSubdialogue() + Me.ucrChkIncludeQCLog = New instat.ucrCheck() + Me.ucrChkIncludeCapturedBy = New instat.ucrCheck() + Me.ucrChkIncludeQCStatus = New instat.ucrCheck() + Me.ucrChkIncludeLevel = New instat.ucrCheck() + Me.ucrChkIncludeElementAbbrv = New instat.ucrCheck() + Me.ucrChkIncludeStationName = New instat.ucrCheck() + Me.ucrChkIncludeAquistion = New instat.ucrCheck() + Me.ucrChkIncludeEntryForm = New instat.ucrCheck() + Me.ucrChkIncludeFlag = New instat.ucrCheck() + Me.ucrChkImportElementsMetadata = New instat.ucrCheck() + Me.ucrChkImportStationsMetadata = New instat.ucrCheck() + Me.tbpTitles.SuspendLayout() + Me.grpMetadataToImport.SuspendLayout() + Me.tbColumns.SuspendLayout() + Me.grpColumnsToInclude.SuspendLayout() + Me.tbpMoreOptions.SuspendLayout() + Me.SuspendLayout() + ' + 'tbpTitles + ' + Me.tbpTitles.Controls.Add(Me.grpMetadataToImport) + Me.tbpTitles.Location = New System.Drawing.Point(4, 22) + Me.tbpTitles.Name = "tbpTitles" + Me.tbpTitles.Padding = New System.Windows.Forms.Padding(3) + Me.tbpTitles.Size = New System.Drawing.Size(409, 281) + Me.tbpTitles.TabIndex = 2 + Me.tbpTitles.Tag = "" + Me.tbpTitles.Text = "Metadata" + Me.tbpTitles.UseVisualStyleBackColor = True + ' + 'grpMetadataToImport + ' + Me.grpMetadataToImport.Controls.Add(Me.ucrChkImportElementsMetadata) + Me.grpMetadataToImport.Controls.Add(Me.ucrChkImportStationsMetadata) + Me.grpMetadataToImport.Location = New System.Drawing.Point(6, 6) + Me.grpMetadataToImport.Name = "grpMetadataToImport" + Me.grpMetadataToImport.Size = New System.Drawing.Size(384, 243) + Me.grpMetadataToImport.TabIndex = 8 + Me.grpMetadataToImport.TabStop = False + Me.grpMetadataToImport.Text = "Metadata to Import" + ' + 'tbColumns + ' + Me.tbColumns.Controls.Add(Me.grpColumnsToInclude) + Me.tbColumns.Location = New System.Drawing.Point(4, 22) + Me.tbColumns.Name = "tbColumns" + Me.tbColumns.Padding = New System.Windows.Forms.Padding(3) + Me.tbColumns.Size = New System.Drawing.Size(409, 281) + Me.tbColumns.TabIndex = 3 + Me.tbColumns.Tag = "" + Me.tbColumns.Text = "Data" + Me.tbColumns.UseVisualStyleBackColor = True + ' + 'grpColumnsToInclude + ' + Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeQCLog) + Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeCapturedBy) + Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeQCStatus) + Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeLevel) + Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeElementAbbrv) + Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeStationName) + Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeAquistion) + Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeEntryForm) + Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeFlag) + Me.grpColumnsToInclude.Location = New System.Drawing.Point(8, 10) + Me.grpColumnsToInclude.Name = "grpColumnsToInclude" + Me.grpColumnsToInclude.Size = New System.Drawing.Size(394, 265) + Me.grpColumnsToInclude.TabIndex = 32 + Me.grpColumnsToInclude.TabStop = False + Me.grpColumnsToInclude.Text = "Columns to Include" + ' + 'tbpMoreOptions + ' + Me.tbpMoreOptions.Controls.Add(Me.tbColumns) + Me.tbpMoreOptions.Controls.Add(Me.tbpTitles) + Me.tbpMoreOptions.Location = New System.Drawing.Point(-1, 4) + Me.tbpMoreOptions.Name = "tbpMoreOptions" + Me.tbpMoreOptions.SelectedIndex = 0 + Me.tbpMoreOptions.Size = New System.Drawing.Size(417, 307) + Me.tbpMoreOptions.TabIndex = 2 + ' + 'ucrBaseSubdialog + ' + Me.ucrBaseSubdialog.AutoSize = True + Me.ucrBaseSubdialog.Location = New System.Drawing.Point(88, 315) + Me.ucrBaseSubdialog.Name = "ucrBaseSubdialog" + Me.ucrBaseSubdialog.Size = New System.Drawing.Size(224, 29) + Me.ucrBaseSubdialog.TabIndex = 3 + ' + 'ucrChkIncludeQCLog + ' + Me.ucrChkIncludeQCLog.AutoSize = True + Me.ucrChkIncludeQCLog.Checked = True + Me.ucrChkIncludeQCLog.Location = New System.Drawing.Point(6, 186) + Me.ucrChkIncludeQCLog.Name = "ucrChkIncludeQCLog" + Me.ucrChkIncludeQCLog.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeQCLog.TabIndex = 21 + ' + 'ucrChkIncludeCapturedBy + ' + Me.ucrChkIncludeCapturedBy.AutoSize = True + Me.ucrChkIncludeCapturedBy.Checked = True + Me.ucrChkIncludeCapturedBy.Location = New System.Drawing.Point(6, 138) + Me.ucrChkIncludeCapturedBy.Name = "ucrChkIncludeCapturedBy" + Me.ucrChkIncludeCapturedBy.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeCapturedBy.TabIndex = 20 + ' + 'ucrChkIncludeQCStatus + ' + Me.ucrChkIncludeQCStatus.AutoSize = True + Me.ucrChkIncludeQCStatus.Checked = True + Me.ucrChkIncludeQCStatus.Location = New System.Drawing.Point(6, 162) + Me.ucrChkIncludeQCStatus.Name = "ucrChkIncludeQCStatus" + Me.ucrChkIncludeQCStatus.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeQCStatus.TabIndex = 0 + ' + 'ucrChkIncludeLevel + ' + Me.ucrChkIncludeLevel.AutoSize = True + Me.ucrChkIncludeLevel.Checked = True + Me.ucrChkIncludeLevel.Location = New System.Drawing.Point(6, 90) + Me.ucrChkIncludeLevel.Name = "ucrChkIncludeLevel" + Me.ucrChkIncludeLevel.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeLevel.TabIndex = 19 + ' + 'ucrChkIncludeElementAbbrv + ' + Me.ucrChkIncludeElementAbbrv.AutoSize = True + Me.ucrChkIncludeElementAbbrv.Checked = True + Me.ucrChkIncludeElementAbbrv.Location = New System.Drawing.Point(6, 42) + Me.ucrChkIncludeElementAbbrv.Name = "ucrChkIncludeElementAbbrv" + Me.ucrChkIncludeElementAbbrv.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeElementAbbrv.TabIndex = 18 + ' + 'ucrChkIncludeStationName + ' + Me.ucrChkIncludeStationName.AutoSize = True + Me.ucrChkIncludeStationName.Checked = True + Me.ucrChkIncludeStationName.Location = New System.Drawing.Point(6, 20) + Me.ucrChkIncludeStationName.Name = "ucrChkIncludeStationName" + Me.ucrChkIncludeStationName.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeStationName.TabIndex = 17 + ' + 'ucrChkIncludeAquistion + ' + Me.ucrChkIncludeAquistion.AutoSize = True + Me.ucrChkIncludeAquistion.Checked = True + Me.ucrChkIncludeAquistion.Location = New System.Drawing.Point(6, 66) + Me.ucrChkIncludeAquistion.Name = "ucrChkIncludeAquistion" + Me.ucrChkIncludeAquistion.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeAquistion.TabIndex = 16 + ' + 'ucrChkIncludeEntryForm + ' + Me.ucrChkIncludeEntryForm.AutoSize = True + Me.ucrChkIncludeEntryForm.Checked = True + Me.ucrChkIncludeEntryForm.Location = New System.Drawing.Point(6, 114) + Me.ucrChkIncludeEntryForm.Name = "ucrChkIncludeEntryForm" + Me.ucrChkIncludeEntryForm.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeEntryForm.TabIndex = 15 + ' + 'ucrChkIncludeFlag + ' + Me.ucrChkIncludeFlag.AutoSize = True + Me.ucrChkIncludeFlag.Checked = True + Me.ucrChkIncludeFlag.Location = New System.Drawing.Point(7, 210) + Me.ucrChkIncludeFlag.Name = "ucrChkIncludeFlag" + Me.ucrChkIncludeFlag.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeFlag.TabIndex = 14 + ' + 'ucrChkImportElementsMetadata + ' + Me.ucrChkImportElementsMetadata.AutoSize = True + Me.ucrChkImportElementsMetadata.Checked = True + Me.ucrChkImportElementsMetadata.Location = New System.Drawing.Point(0, 46) + Me.ucrChkImportElementsMetadata.Name = "ucrChkImportElementsMetadata" + Me.ucrChkImportElementsMetadata.Size = New System.Drawing.Size(315, 23) + Me.ucrChkImportElementsMetadata.TabIndex = 20 + ' + 'ucrChkImportStationsMetadata + ' + Me.ucrChkImportStationsMetadata.AutoSize = True + Me.ucrChkImportStationsMetadata.Checked = True + Me.ucrChkImportStationsMetadata.Location = New System.Drawing.Point(0, 22) + Me.ucrChkImportStationsMetadata.Name = "ucrChkImportStationsMetadata" + Me.ucrChkImportStationsMetadata.Size = New System.Drawing.Size(315, 23) + Me.ucrChkImportStationsMetadata.TabIndex = 19 + ' + 'sdgClimsoft + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(417, 348) + Me.Controls.Add(Me.ucrBaseSubdialog) + Me.Controls.Add(Me.tbpMoreOptions) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow + Me.Name = "sdgClimsoft" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "More Climsoft Options" + Me.tbpTitles.ResumeLayout(False) + Me.grpMetadataToImport.ResumeLayout(False) + Me.grpMetadataToImport.PerformLayout() + Me.tbColumns.ResumeLayout(False) + Me.grpColumnsToInclude.ResumeLayout(False) + Me.grpColumnsToInclude.PerformLayout() + Me.tbpMoreOptions.ResumeLayout(False) + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents ucrBaseSubdialog As ucrButtonsSubdialogue + Friend WithEvents tbpTitles As TabPage + Friend WithEvents grpMetadataToImport As GroupBox + Friend WithEvents tbColumns As TabPage + Friend WithEvents ucrChkIncludeQCStatus As ucrCheck + Friend WithEvents tbpMoreOptions As TabControl + Friend WithEvents grpColumnsToInclude As GroupBox + Friend WithEvents ucrChkIncludeFlag As ucrCheck + Friend WithEvents ucrChkIncludeAquistion As ucrCheck + Friend WithEvents ucrChkIncludeEntryForm As ucrCheck + Friend WithEvents ucrChkIncludeElementAbbrv As ucrCheck + Friend WithEvents ucrChkIncludeStationName As ucrCheck + Friend WithEvents ucrChkImportElementsMetadata As ucrCheck + Friend WithEvents ucrChkImportStationsMetadata As ucrCheck + Friend WithEvents ucrChkIncludeCapturedBy As ucrCheck + Friend WithEvents ucrChkIncludeLevel As ucrCheck + Friend WithEvents ucrChkIncludeQCLog As ucrCheck +End Class \ No newline at end of file diff --git a/instat/sdgClimsoft.vb b/instat/sdgClimsoft.vb new file mode 100644 index 00000000000..d6a61a9bb2a --- /dev/null +++ b/instat/sdgClimsoft.vb @@ -0,0 +1,112 @@ +' R- Instat +' Copyright (C) 2015-2017 +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License +' along with this program. If not, see . +Imports instat.Translations + +Public Class sdgClimsoft + + Private bControlsInitialised As Boolean = False + Private Sub sdgClimsoft_Load(sender As Object, e As EventArgs) Handles MyBase.Load + autoTranslate(Me) + End Sub + + Private Sub InitialiseControls() + + If bControlsInitialised Then + Exit Sub + End If + + 'Columns to include + '--------------------------------------- + ucrChkIncludeStationName.SetText("Station Name") + ucrChkIncludeStationName.SetParameter(New RParameter("include_station_name", 13)) + ucrChkIncludeStationName.SetRDefault("TRUE") + + ucrChkIncludeElementAbbrv.SetText("Element Abbreviation") + ucrChkIncludeElementAbbrv.SetParameter(New RParameter("include_element_abbreviation", 14)) + ucrChkIncludeElementAbbrv.SetRDefault("TRUE") + + ucrChkIncludeAquistion.SetText("Acquisition Type") + ucrChkIncludeAquistion.SetParameter(New RParameter("include_acquisition_type", 15)) + ucrChkIncludeAquistion.SetRDefault("TRUE") + + ucrChkIncludeLevel.SetText("Level") + ucrChkIncludeLevel.SetParameter(New RParameter("include_level", 16)) + ucrChkIncludeLevel.SetRDefault("TRUE") + + ucrChkIncludeEntryForm.SetText("Entry Form") + ucrChkIncludeEntryForm.SetParameter(New RParameter("include_entry_form", 17)) + ucrChkIncludeEntryForm.SetRDefault("TRUE") + + ucrChkIncludeCapturedBy.SetText("Captured By (user)") + ucrChkIncludeCapturedBy.SetParameter(New RParameter("include_captured_by", 18)) + ucrChkIncludeCapturedBy.SetRDefault("TRUE") + + ucrChkIncludeQCStatus.SetText("QC Status") + ucrChkIncludeQCStatus.SetParameter(New RParameter("include_qc_status", 19)) + ucrChkIncludeQCStatus.SetRDefault("TRUE") + + ucrChkIncludeQCLog.SetText("QC Log") + ucrChkIncludeQCLog.SetParameter(New RParameter("include_qc_log", 20)) + ucrChkIncludeQCLog.SetRDefault("TRUE") + + ucrChkIncludeFlag.SetText("Flag") + ucrChkIncludeFlag.SetParameter(New RParameter("include_flag", 21)) + ucrChkIncludeFlag.SetRDefault("TRUE") + + '--------------------------------------- + + 'Metadata + '--------------------------------------- + ucrChkImportStationsMetadata.SetText("Selected Stations") + ucrChkImportStationsMetadata.SetParameter(New RParameter("import_selected_stations_metadata", 12)) + ucrChkImportStationsMetadata.SetRDefault("TRUE") + + ucrChkImportElementsMetadata.SetText("Selected Elements") + ucrChkImportElementsMetadata.SetParameter(New RParameter("import_selected_elements_metadata", 13)) + ucrChkImportElementsMetadata.SetRDefault("TRUE") + '--------------------------------------- + + bControlsInitialised = True + + End Sub + + Public Sub SetRCode(clsRFunction As RFunction, Optional bReset As Boolean = True) + 'initialise controls if not initialised + InitialiseControls() + + 'Columns + '--------------------------------------- + ucrChkIncludeStationName.SetRCode(clsRFunction, bReset) + ucrChkIncludeElementAbbrv.SetRCode(clsRFunction, bReset) + ucrChkIncludeAquistion.SetRCode(clsRFunction, bReset) + ucrChkIncludeLevel.SetRCode(clsRFunction, bReset) + ucrChkIncludeEntryForm.SetRCode(clsRFunction, bReset) + ucrChkIncludeCapturedBy.SetRCode(clsRFunction, bReset) + ucrChkIncludeQCStatus.SetRCode(clsRFunction, bReset) + ucrChkIncludeQCLog.SetRCode(clsRFunction, bReset) + ucrChkIncludeFlag.SetRCode(clsRFunction, bReset) + '--------------------------------------- + + 'Metadata + '--------------------------------------- + ucrChkImportStationsMetadata.SetRCode(clsRFunction, bReset) + ucrChkImportElementsMetadata.SetRCode(clsRFunction, bReset) + '--------------------------------------- + + End Sub + + +End Class \ No newline at end of file diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 7bf6274f247..95c44c5c065 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -1848,6 +1848,248 @@ DataBook$set("public", "database_disconnect", function() { } ) +#Gets the row count of the table. +DataBook$set("public", "get_db_table_row_count", function(tableName, query_condition = NULL) { + con <- self$get_database_connection() + if(is.null(con)){ + stop("No database connection") + } + + if(is.null(query_condition)){ + query_condition <- "" + } + + out <- DBI::dbGetQuery(con, paste0("SELECT COUNT(*) as result FROM ",tableName," ", query_condition, ";" )) + return(out$result) + +}) + +#Imports Climsoft metadata. +DataBook$set("public", "import_climsoft_metadata", function(import_stations = FALSE, import_elements = FALSE, import_flags = FALSE) { + + if(!import_stations || !import_elements){ + stop("No metadata selected for import") + } + + con <- self$get_database_connection() + if(is.null(con)){ + stop("No database connection") + } + + #imports metadata + #-------------------------------- + data_list <- list() + + if(import_stations){ + stations_metadata_name <- next_default_item("stations_metadata", self$get_data_names(), include_index = FALSE) + #todo.(22/03/2023) 2 fields have been intentionally left out because they are yet to be released to Climsoft users. Namely; wsi and gtsWSI + #include them once the new Climsoft release has been supplied to users + data_list[[stations_metadata_name]] <- DBI::dbGetQuery(con, "SELECT stationId AS station_id, stationName AS station_name, wmoid, icaoid, latitude, longitude, elevation, qualifier, geoLocationMethod AS geo_location_method, geoLocationAccuracy AS geo_location_accuracy, openingDatetime AS opening_date_time, closingDatetime AS closing_date_time, authority, adminRegion AS admin_region, drainageBasin AS drainage_basin, wacaSelection AS waca_selection, cptSelection AS cpt_selection, stationOperational AS station_Operational, country AS country FROM station;") + } + + if(import_elements){ + elements_metadata_name <- next_default_item("elements_metadata", self$get_data_names(), include_index = FALSE) + data_list[[elements_metadata_name]] <- DBI::dbGetQuery(con, "SELECT elementId AS element_id, elementName AS element_name, abbreviation, description, elementtype AS element_type, upperLimit AS upper_limit , lowerLimit AS lower_limit, units FROM obselement;") + } + + if(import_flags){ + flags_metadata_name <- next_default_item("flags_metadata", self$get_data_names(), include_index = FALSE) + data_list[[flags_metadata_name]] <- DBI::dbGetQuery(con, "SELECT characterSymbol AS flag_name, description FROM flags;") + + } + + self$import_data(data_tables = data_list) + #-------------------------------- + + #transform imported metadata + #-------------------------------- + if(import_stations){ + self$convert_column_to_type(data_name = stations_metadata_name, col_names = c("station_id","station_name","qualifier","authority","admin_region","drainage_basin","station_Operational","country"), to_type = "factor") + } + + if(import_elements){ + self$convert_column_to_type(data_name = elements_metadata_name, col_names = c("element_id","element_name","abbreviation","element_type"), to_type = "factor") + } + + if(import_flags){ + self$convert_column_to_type(data_name = flags_metadata_name, col_names = c("flag_name"), to_type = "factor") + } + #-------------------------------- + +}) + + +#imports data from climsoft observation tables; initial or final. +#imports selected stations and elements metadata +DataBook$set("public", "import_climsoft_data", function(tableName, + station_filter_column, stations = c(), + element_filter_column, elements = c(), + qc_status = -1, start_date = NULL, end_date = NULL, + include_station_name = TRUE, include_element_abbreviation = TRUE, include_qc_status = TRUE, + include_acquisition_type = TRUE, include_flag = TRUE, include_entry_form = TRUE, + include_qc_log = TRUE, include_captured_by = TRUE, include_level = TRUE, + import_selected_stations_metadata = TRUE, import_selected_elements_metadata = TRUE) { + #connection and parameter checks + #-------------------------------- + con <- self$get_database_connection() + if(is.null(con)){ + stop("No database connection") + } + + if(missing(tableName) || missing(station_filter_column) || missing(element_filter_column) || length(stations) == 0 || length(elements) == 0){ + stop("Missing parameters. tableName, station_filter_column, element_filter_column, stations and elements must be supplied") + } + + if (!is.null(start_date) && !lubridate::is.Date(start_date) ) { + stop("start_date must be of type Date.") + } + + if (!is.null(end_date) && !lubridate::is.Date(end_date) ) { + stop("start_date must be of type Date.") + } + #-------------------------------- + + #selects + #-------------------------------- + sql_select <- paste0(tableName,".recordedFrom AS station_id") + + if(include_station_name){ + sql_select <-paste0(sql_select,", station.stationName AS station_name") + } + + sql_select <-paste0(sql_select, ", ", tableName,".describedBy AS element_id") + + if(include_element_abbreviation){ + sql_select <-paste0(sql_select,", obselement.abbreviation AS element_abbrv") + } + + if(include_acquisition_type){ + sql_select <-paste0(sql_select,", ", tableName,".acquisitionType"," AS acquisition_type") + } + + if(include_level){ + sql_select <-paste0(sql_select,", ", tableName,".obsLevel"," AS level") + } + + if(include_entry_form){ + sql_select <-paste0(sql_select,", ", tableName,".dataForm"," AS entry_form") + } + + if(include_captured_by){ + sql_select <-paste0(sql_select,", ", tableName,".capturedBy"," AS captured_by") + } + + if(include_qc_status){ + sql_select <-paste0(sql_select,", ", tableName,".qcStatus"," AS qc_status") + } + + sql_select <-paste0(sql_select,", ", tableName,".obsDatetime AS date_time") + + if(include_qc_log){ + sql_select <-paste0(sql_select,", ", tableName,".qcTypeLog"," AS qc_log") + } + + if(include_flag){ + sql_select <-paste0(sql_select,", ", tableName,".flag"," AS flag") + } + + sql_select <-paste0(sql_select,", ", tableName,".obsValue AS value") + + sql_select<- paste0("SELECT ", sql_select, " FROM ", tableName, + " INNER JOIN station ON ", tableName, ".recordedFrom = station.stationId", + " INNER JOIN obselement ON ",tableName,".describedBy = obselement.elementId") + #-------------------------------- + + #filters + #-------------------------------- + sql_stations_filter <- paste0(" station.", station_filter_column, " IN ", paste0("(", paste0("'", stations, "'", collapse = ", "), ")")) + sql_elements_filter <- paste0(" obselement.", element_filter_column, " IN ", paste0("(", paste0("'", elements, "'", collapse = ", "), ")")) + + sql_filter <- sql_stations_filter + sql_filter <- paste0(sql_filter," AND ",sql_elements_filter) + + if(qc_status>-1){ + sql_filter <- paste0(sql_filter," AND qcStatus = ", qc_status) + } + + if (!is.null(start_date)) { + sql_filter = paste0(sql_filter," AND obsDatetime >= ", sQuote(format(start_date, format = "%Y-%m-%d"))) + } + + if (!is.null(end_date)) { + sql_filter <- paste0(sql_filter," AND obsDatetime <=", sQuote(format(end_date, format = "%Y-%m-%d"))) + } + + sql_filter<- paste0(" WHERE ",sql_filter) + #-------------------------------- + + #order by + #-------------------------------- + sql_order_by <- paste0(" ORDER BY ",tableName,".recordedFrom, ",tableName, ".describedBy, ",tableName, ".obsDatetime",";") + #-------------------------------- + + #import data + #-------------------------------- + data_list <- list() + + if(import_selected_stations_metadata){ + stations_metadata_name <- next_default_item("stations_metadata", self$get_data_names(), include_index = FALSE) + data_list[[stations_metadata_name]] <- DBI::dbGetQuery(con, paste0("SELECT * FROM station WHERE", sql_stations_filter)) + } + + if(import_selected_elements_metadata){ + elements_metadata_name <- next_default_item("elements_metadata", self$get_data_names(), include_index = FALSE) + data_list[[elements_metadata_name]] <- DBI::dbGetQuery(con, paste0("SELECT * FROM obselement WHERE", sql_elements_filter)) + } + + observations_data_name <- next_default_item("observations_data", self$get_data_names(), include_index = FALSE) + data_list[[observations_data_name]] <- DBI::dbGetQuery(con,paste0(sql_select, sql_filter, sql_order_by)) + + + self$import_data(data_tables = data_list) + #-------------------------------- + + #transform imported data + #-------------------------------- + self$convert_column_to_type(data_name = observations_data_name, col_names = c("station_id","element_id"), to_type = "factor") + + if(include_station_name){ + self$convert_column_to_type(data_name = observations_data_name, col_names = "station_name", to_type = "factor") + } + + if(include_element_abbreviation){ + self$convert_column_to_type(data_name = observations_data_name, col_names = "element_abbrv", to_type = "factor") + } + + if(include_qc_status){ + self$convert_column_to_type(data_name = observations_data_name, col_names = "qc_status", to_type = "factor") + } + + if(include_acquisition_type){ + self$convert_column_to_type(data_name = observations_data_name, col_names = "acquisition_type", to_type = "factor") + } + + if(include_level){ + self$convert_column_to_type(data_name = observations_data_name, col_names = "level", to_type = "factor") + } + + if(include_flag){ + self$convert_column_to_type(data_name = observations_data_name, col_names = "flag", to_type = "factor") + } + + if(include_entry_form){ + self$convert_column_to_type(data_name = observations_data_name, col_names = "entry_form", to_type = "factor") + } + + #todo. should this be done at this point?? Keeping in mind that we may have hourly data + #create a plain date column from the observation data datetime column values + obsdate <- self$get_columns_from_data(data_name = observations_data_name, col_names = "date_time", use_current_filter = FALSE) + self$add_columns_to_data(data_name = observations_data_name, col_name = "date", col_data = as.Date(x = obsdate), before = FALSE, adjacent_column = "date_time") + #-------------------------------- + +}) + +#TODO. Deprecated. Delete this after after deleting the import from climsoft wizard dialog DataBook$set("public", "import_from_climsoft", function(stationfiltercolumn = "stationId", stations = c(), elementfiltercolumn = "elementId", elements = c(), include_observation_data = FALSE, include_observation_flags = FALSE, unstack_data = FALSE, include_elements_info = FALSE, start_date = NULL, end_date = NULL) { #need to perform checks here con <- self$get_database_connection() From 4f3e7db7c0c67131fd2f9f0c464c1744e5c002ff Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Fri, 19 Jul 2024 15:05:52 +0300 Subject: [PATCH 02/13] changes to the code --- .../dlgExportClimaticDefinitions.Designer.vb | 154 +++++++----------- instat/dlgExportClimaticDefinitions.vb | 42 ++--- 2 files changed, 81 insertions(+), 115 deletions(-) diff --git a/instat/dlgExportClimaticDefinitions.Designer.vb b/instat/dlgExportClimaticDefinitions.Designer.vb index 0e33704c4e6..d29ab990892 100644 --- a/instat/dlgExportClimaticDefinitions.Designer.vb +++ b/instat/dlgExportClimaticDefinitions.Designer.vb @@ -22,10 +22,9 @@ Partial Class dlgExportClimaticDefinitions 'Do not modify it using the code editor. _ Private Sub InitializeComponent() - Me.lblStationID = New System.Windows.Forms.Label() + Me.lblStation = New System.Windows.Forms.Label() Me.lblCountry = New System.Windows.Forms.Label() Me.ucrInputCountry = New instat.ucrInputTextBox() - Me.ucrInputStationID = New instat.ucrInputTextBox() Me.ucrChkSeasonStartProp = New instat.ucrCheck() Me.ucrChkExtremes = New instat.ucrCheck() Me.ucrChkCropSuccessProp = New instat.ucrCheck() @@ -42,9 +41,7 @@ Partial Class dlgExportClimaticDefinitions Me.lblDataByYearMonth = New System.Windows.Forms.Label() Me.lblDataByYear = New System.Windows.Forms.Label() Me.lblRain = New System.Windows.Forms.Label() - Me.lblData = New System.Windows.Forms.Label() Me.ucrReceiverRain = New instat.ucrReceiverSingle() - Me.ucrReceiverData = New instat.ucrReceiverSingle() Me.ucrSelectorExportDefinitions = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() Me.ucrReceiverDataYear = New instat.ucrReceiverSingle() @@ -56,27 +53,28 @@ Partial Class dlgExportClimaticDefinitions Me.cmdDefine = New System.Windows.Forms.Button() Me.lblDefinitionsID = New System.Windows.Forms.Label() Me.ucrInputDefinitionsID = New instat.ucrInputTextBox() + Me.ucrReceiverStation = New instat.ucrReceiverSingle() Me.grpSummaries.SuspendLayout() Me.SuspendLayout() ' - 'lblStationID + 'lblStation ' - Me.lblStationID.AutoSize = True - Me.lblStationID.Location = New System.Drawing.Point(498, 259) - Me.lblStationID.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) - Me.lblStationID.Name = "lblStationID" - Me.lblStationID.Size = New System.Drawing.Size(85, 20) - Me.lblStationID.TabIndex = 9 - Me.lblStationID.Text = "Station ID:" + Me.lblStation.AutoSize = True + Me.lblStation.Location = New System.Drawing.Point(498, 25) + Me.lblStation.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) + Me.lblStation.Name = "lblStation" + Me.lblStation.Size = New System.Drawing.Size(64, 20) + Me.lblStation.TabIndex = 1 + Me.lblStation.Text = "Station:" ' 'lblCountry ' Me.lblCountry.AutoSize = True - Me.lblCountry.Location = New System.Drawing.Point(498, 321) + Me.lblCountry.Location = New System.Drawing.Point(498, 492) Me.lblCountry.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.lblCountry.Name = "lblCountry" Me.lblCountry.Size = New System.Drawing.Size(68, 20) - Me.lblCountry.TabIndex = 11 + Me.lblCountry.TabIndex = 17 Me.lblCountry.Text = "Country:" ' 'ucrInputCountry @@ -85,23 +83,11 @@ Partial Class dlgExportClimaticDefinitions Me.ucrInputCountry.AutoSize = True Me.ucrInputCountry.IsMultiline = False Me.ucrInputCountry.IsReadOnly = False - Me.ucrInputCountry.Location = New System.Drawing.Point(498, 346) + Me.ucrInputCountry.Location = New System.Drawing.Point(498, 517) Me.ucrInputCountry.Margin = New System.Windows.Forms.Padding(14) Me.ucrInputCountry.Name = "ucrInputCountry" Me.ucrInputCountry.Size = New System.Drawing.Size(177, 32) - Me.ucrInputCountry.TabIndex = 12 - ' - 'ucrInputStationID - ' - Me.ucrInputStationID.AddQuotesIfUnrecognised = True - Me.ucrInputStationID.AutoSize = True - Me.ucrInputStationID.IsMultiline = False - Me.ucrInputStationID.IsReadOnly = False - Me.ucrInputStationID.Location = New System.Drawing.Point(498, 284) - Me.ucrInputStationID.Margin = New System.Windows.Forms.Padding(14) - Me.ucrInputStationID.Name = "ucrInputStationID" - Me.ucrInputStationID.Size = New System.Drawing.Size(177, 32) - Me.ucrInputStationID.TabIndex = 10 + Me.ucrInputCountry.TabIndex = 18 ' 'ucrChkSeasonStartProp ' @@ -208,7 +194,7 @@ Partial Class dlgExportClimaticDefinitions Me.ucrChkIncludeSummaryData.Margin = New System.Windows.Forms.Padding(9) Me.ucrChkIncludeSummaryData.Name = "ucrChkIncludeSummaryData" Me.ucrChkIncludeSummaryData.Size = New System.Drawing.Size(332, 48) - Me.ucrChkIncludeSummaryData.TabIndex = 26 + Me.ucrChkIncludeSummaryData.TabIndex = 20 ' 'grpSummaries ' @@ -223,7 +209,7 @@ Partial Class dlgExportClimaticDefinitions Me.grpSummaries.Name = "grpSummaries" Me.grpSummaries.Padding = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.grpSummaries.Size = New System.Drawing.Size(470, 177) - Me.grpSummaries.TabIndex = 25 + Me.grpSummaries.TabIndex = 19 Me.grpSummaries.TabStop = False Me.grpSummaries.Text = "Summaries" ' @@ -240,79 +226,56 @@ Partial Class dlgExportClimaticDefinitions 'lblCropData ' Me.lblCropData.AutoSize = True - Me.lblCropData.Location = New System.Drawing.Point(498, 505) + Me.lblCropData.Location = New System.Drawing.Point(498, 376) Me.lblCropData.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.lblCropData.Name = "lblCropData" Me.lblCropData.Size = New System.Drawing.Size(86, 20) - Me.lblCropData.TabIndex = 17 + Me.lblCropData.TabIndex = 13 Me.lblCropData.Text = "Crop Data:" ' 'lblDataByYearMonth ' Me.lblDataByYearMonth.AutoSize = True - Me.lblDataByYearMonth.Location = New System.Drawing.Point(498, 444) + Me.lblDataByYearMonth.Location = New System.Drawing.Point(498, 315) Me.lblDataByYearMonth.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.lblDataByYearMonth.Name = "lblDataByYearMonth" Me.lblDataByYearMonth.Size = New System.Drawing.Size(188, 20) - Me.lblDataByYearMonth.TabIndex = 15 + Me.lblDataByYearMonth.TabIndex = 11 Me.lblDataByYearMonth.Text = "Data By Year and Month:" ' 'lblDataByYear ' Me.lblDataByYear.AutoSize = True - Me.lblDataByYear.Location = New System.Drawing.Point(498, 383) + Me.lblDataByYear.Location = New System.Drawing.Point(498, 254) Me.lblDataByYear.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.lblDataByYear.Name = "lblDataByYear" Me.lblDataByYear.Size = New System.Drawing.Size(108, 20) - Me.lblDataByYear.TabIndex = 13 + Me.lblDataByYear.TabIndex = 9 Me.lblDataByYear.Text = "Data By Year:" ' 'lblRain ' Me.lblRain.AutoSize = True - Me.lblRain.Location = New System.Drawing.Point(498, 566) + Me.lblRain.Location = New System.Drawing.Point(498, 198) Me.lblRain.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.lblRain.Name = "lblRain" Me.lblRain.Size = New System.Drawing.Size(46, 20) - Me.lblRain.TabIndex = 19 + Me.lblRain.TabIndex = 7 Me.lblRain.Text = "Rain:" ' - 'lblData - ' - Me.lblData.AutoSize = True - Me.lblData.Location = New System.Drawing.Point(498, 14) - Me.lblData.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) - Me.lblData.Name = "lblData" - Me.lblData.Size = New System.Drawing.Size(48, 20) - Me.lblData.TabIndex = 1 - Me.lblData.Text = "Data:" - ' 'ucrReceiverRain ' Me.ucrReceiverRain.AutoSize = True Me.ucrReceiverRain.frmParent = Me - Me.ucrReceiverRain.Location = New System.Drawing.Point(498, 591) + Me.ucrReceiverRain.Location = New System.Drawing.Point(498, 223) Me.ucrReceiverRain.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverRain.Name = "ucrReceiverRain" Me.ucrReceiverRain.Selector = Nothing Me.ucrReceiverRain.Size = New System.Drawing.Size(180, 31) Me.ucrReceiverRain.strNcFilePath = "" - Me.ucrReceiverRain.TabIndex = 20 + Me.ucrReceiverRain.TabIndex = 8 Me.ucrReceiverRain.ucrSelector = Nothing ' - 'ucrReceiverData - ' - Me.ucrReceiverData.AutoSize = True - Me.ucrReceiverData.frmParent = Me - Me.ucrReceiverData.Location = New System.Drawing.Point(498, 39) - Me.ucrReceiverData.Margin = New System.Windows.Forms.Padding(0) - Me.ucrReceiverData.Name = "ucrReceiverData" - Me.ucrReceiverData.Selector = Nothing - Me.ucrReceiverData.Size = New System.Drawing.Size(180, 31) - Me.ucrReceiverData.strNcFilePath = "" - Me.ucrReceiverData.TabIndex = 2 - Me.ucrReceiverData.ucrSelector = Nothing - ' 'ucrSelectorExportDefinitions ' Me.ucrSelectorExportDefinitions.AutoSize = True @@ -328,70 +291,70 @@ Partial Class dlgExportClimaticDefinitions 'ucrBase ' Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(6, 684) + Me.ucrBase.Location = New System.Drawing.Point(6, 622) Me.ucrBase.Margin = New System.Windows.Forms.Padding(6) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(615, 92) - Me.ucrBase.TabIndex = 31 + Me.ucrBase.TabIndex = 25 ' 'ucrReceiverDataYear ' Me.ucrReceiverDataYear.AutoSize = True Me.ucrReceiverDataYear.frmParent = Me - Me.ucrReceiverDataYear.Location = New System.Drawing.Point(498, 408) + Me.ucrReceiverDataYear.Location = New System.Drawing.Point(498, 279) Me.ucrReceiverDataYear.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverDataYear.Name = "ucrReceiverDataYear" Me.ucrReceiverDataYear.Selector = Nothing Me.ucrReceiverDataYear.Size = New System.Drawing.Size(180, 31) Me.ucrReceiverDataYear.strNcFilePath = "" - Me.ucrReceiverDataYear.TabIndex = 14 + Me.ucrReceiverDataYear.TabIndex = 10 Me.ucrReceiverDataYear.ucrSelector = Nothing ' 'ucrReceiverDataYearMonth ' Me.ucrReceiverDataYearMonth.AutoSize = True Me.ucrReceiverDataYearMonth.frmParent = Me - Me.ucrReceiverDataYearMonth.Location = New System.Drawing.Point(498, 469) + Me.ucrReceiverDataYearMonth.Location = New System.Drawing.Point(498, 340) Me.ucrReceiverDataYearMonth.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverDataYearMonth.Name = "ucrReceiverDataYearMonth" Me.ucrReceiverDataYearMonth.Selector = Nothing Me.ucrReceiverDataYearMonth.Size = New System.Drawing.Size(180, 31) Me.ucrReceiverDataYearMonth.strNcFilePath = "" - Me.ucrReceiverDataYearMonth.TabIndex = 16 + Me.ucrReceiverDataYearMonth.TabIndex = 12 Me.ucrReceiverDataYearMonth.ucrSelector = Nothing ' 'ucrReceiverCropData ' Me.ucrReceiverCropData.AutoSize = True Me.ucrReceiverCropData.frmParent = Me - Me.ucrReceiverCropData.Location = New System.Drawing.Point(498, 530) + Me.ucrReceiverCropData.Location = New System.Drawing.Point(498, 401) Me.ucrReceiverCropData.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverCropData.Name = "ucrReceiverCropData" Me.ucrReceiverCropData.Selector = Nothing Me.ucrReceiverCropData.Size = New System.Drawing.Size(180, 31) Me.ucrReceiverCropData.strNcFilePath = "" - Me.ucrReceiverCropData.TabIndex = 18 + Me.ucrReceiverCropData.TabIndex = 14 Me.ucrReceiverCropData.ucrSelector = Nothing ' 'lblExport ' Me.lblExport.AutoSize = True Me.lblExport.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblExport.Location = New System.Drawing.Point(14, 645) + Me.lblExport.Location = New System.Drawing.Point(14, 579) Me.lblExport.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.lblExport.Name = "lblExport" Me.lblExport.Size = New System.Drawing.Size(57, 20) - Me.lblExport.TabIndex = 28 + Me.lblExport.TabIndex = 22 Me.lblExport.Text = "Token:" ' 'cmdChooseFile ' Me.cmdChooseFile.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.cmdChooseFile.Location = New System.Drawing.Point(384, 638) + Me.cmdChooseFile.Location = New System.Drawing.Point(384, 571) Me.cmdChooseFile.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.cmdChooseFile.Name = "cmdChooseFile" Me.cmdChooseFile.Size = New System.Drawing.Size(120, 35) - Me.cmdChooseFile.TabIndex = 30 + Me.cmdChooseFile.TabIndex = 24 Me.cmdChooseFile.Text = "Browse" Me.cmdChooseFile.UseVisualStyleBackColor = True ' @@ -401,11 +364,11 @@ Partial Class dlgExportClimaticDefinitions Me.ucrInputTokenPath.AutoSize = True Me.ucrInputTokenPath.IsMultiline = False Me.ucrInputTokenPath.IsReadOnly = False - Me.ucrInputTokenPath.Location = New System.Drawing.Point(84, 641) + Me.ucrInputTokenPath.Location = New System.Drawing.Point(84, 575) Me.ucrInputTokenPath.Margin = New System.Windows.Forms.Padding(9, 12, 9, 12) Me.ucrInputTokenPath.Name = "ucrInputTokenPath" Me.ucrInputTokenPath.Size = New System.Drawing.Size(287, 32) - Me.ucrInputTokenPath.TabIndex = 29 + Me.ucrInputTokenPath.TabIndex = 23 ' 'cmdDefine ' @@ -414,18 +377,18 @@ Partial Class dlgExportClimaticDefinitions Me.cmdDefine.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.cmdDefine.Name = "cmdDefine" Me.cmdDefine.Size = New System.Drawing.Size(120, 45) - Me.cmdDefine.TabIndex = 27 + Me.cmdDefine.TabIndex = 21 Me.cmdDefine.Text = "Define" Me.cmdDefine.UseVisualStyleBackColor = True ' 'lblDefinitionsID ' Me.lblDefinitionsID.AutoSize = True - Me.lblDefinitionsID.Location = New System.Drawing.Point(503, 198) + Me.lblDefinitionsID.Location = New System.Drawing.Point(505, 433) Me.lblDefinitionsID.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.lblDefinitionsID.Name = "lblDefinitionsID" Me.lblDefinitionsID.Size = New System.Drawing.Size(109, 20) - Me.lblDefinitionsID.TabIndex = 7 + Me.lblDefinitionsID.TabIndex = 15 Me.lblDefinitionsID.Text = "Definitions ID:" ' 'ucrInputDefinitionsID @@ -434,28 +397,41 @@ Partial Class dlgExportClimaticDefinitions Me.ucrInputDefinitionsID.AutoSize = True Me.ucrInputDefinitionsID.IsMultiline = False Me.ucrInputDefinitionsID.IsReadOnly = False - Me.ucrInputDefinitionsID.Location = New System.Drawing.Point(498, 222) + Me.ucrInputDefinitionsID.Location = New System.Drawing.Point(500, 457) Me.ucrInputDefinitionsID.Margin = New System.Windows.Forms.Padding(14) Me.ucrInputDefinitionsID.Name = "ucrInputDefinitionsID" Me.ucrInputDefinitionsID.Size = New System.Drawing.Size(177, 32) - Me.ucrInputDefinitionsID.TabIndex = 8 + Me.ucrInputDefinitionsID.TabIndex = 16 + ' + 'ucrReceiverStation + ' + Me.ucrReceiverStation.AutoSize = True + Me.ucrReceiverStation.frmParent = Me + Me.ucrReceiverStation.Location = New System.Drawing.Point(498, 45) + Me.ucrReceiverStation.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverStation.Name = "ucrReceiverStation" + Me.ucrReceiverStation.Selector = Nothing + Me.ucrReceiverStation.Size = New System.Drawing.Size(180, 31) + Me.ucrReceiverStation.strNcFilePath = "" + Me.ucrReceiverStation.TabIndex = 2 + Me.ucrReceiverStation.ucrSelector = Nothing ' 'dlgExportClimaticDefinitions ' Me.AutoScaleDimensions = New System.Drawing.SizeF(9.0!, 20.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.AutoSize = True - Me.ClientSize = New System.Drawing.Size(688, 772) + Me.ClientSize = New System.Drawing.Size(688, 713) + Me.Controls.Add(Me.ucrReceiverStation) Me.Controls.Add(Me.lblDefinitionsID) Me.Controls.Add(Me.ucrInputDefinitionsID) Me.Controls.Add(Me.cmdDefine) Me.Controls.Add(Me.lblExport) Me.Controls.Add(Me.cmdChooseFile) Me.Controls.Add(Me.ucrInputTokenPath) - Me.Controls.Add(Me.lblStationID) + Me.Controls.Add(Me.lblStation) Me.Controls.Add(Me.lblCountry) Me.Controls.Add(Me.ucrInputCountry) - Me.Controls.Add(Me.ucrInputStationID) Me.Controls.Add(Me.lblMonth) Me.Controls.Add(Me.lblYear) Me.Controls.Add(Me.ucrReceiverMonth) @@ -466,9 +442,7 @@ Partial Class dlgExportClimaticDefinitions Me.Controls.Add(Me.lblDataByYearMonth) Me.Controls.Add(Me.lblDataByYear) Me.Controls.Add(Me.lblRain) - Me.Controls.Add(Me.lblData) Me.Controls.Add(Me.ucrReceiverRain) - Me.Controls.Add(Me.ucrReceiverData) Me.Controls.Add(Me.ucrSelectorExportDefinitions) Me.Controls.Add(Me.ucrBase) Me.Controls.Add(Me.ucrReceiverDataYear) @@ -488,10 +462,9 @@ Partial Class dlgExportClimaticDefinitions End Sub - Friend WithEvents lblStationID As Label + Friend WithEvents lblStation As Label Friend WithEvents lblCountry As Label Friend WithEvents ucrInputCountry As ucrInputTextBox - Friend WithEvents ucrInputStationID As ucrInputTextBox Friend WithEvents ucrChkSeasonStartProp As ucrCheck Friend WithEvents ucrChkExtremes As ucrCheck Friend WithEvents ucrChkCropSuccessProp As ucrCheck @@ -508,9 +481,7 @@ Partial Class dlgExportClimaticDefinitions Friend WithEvents lblDataByYearMonth As Label Friend WithEvents lblDataByYear As Label Friend WithEvents lblRain As Label - Friend WithEvents lblData As Label Friend WithEvents ucrReceiverRain As ucrReceiverSingle - Friend WithEvents ucrReceiverData As ucrReceiverSingle Friend WithEvents ucrSelectorExportDefinitions As ucrSelectorByDataFrameAddRemove Friend WithEvents ucrBase As ucrButtons Friend WithEvents ucrReceiverDataYear As ucrReceiverSingle @@ -522,4 +493,5 @@ Partial Class dlgExportClimaticDefinitions Friend WithEvents cmdDefine As Button Friend WithEvents lblDefinitionsID As Label Friend WithEvents ucrInputDefinitionsID As ucrInputTextBox + Friend WithEvents ucrReceiverStation As ucrReceiverSingle End Class diff --git a/instat/dlgExportClimaticDefinitions.vb b/instat/dlgExportClimaticDefinitions.vb index 76f0e71db2c..723aba5fe08 100644 --- a/instat/dlgExportClimaticDefinitions.vb +++ b/instat/dlgExportClimaticDefinitions.vb @@ -39,13 +39,12 @@ Public Class dlgExportClimaticDefinitions End Sub Private Sub InitialiseDialog() - - ucrReceiverData.SetParameter(New RParameter("data", 0)) - ucrReceiverData.Selector = ucrSelectorExportDefinitions - ucrReceiverData.SetParameterIsString() - ucrReceiverData.SetMeAsReceiver() - ucrReceiverData.SetItemType("dataframe") - ucrReceiverData.strSelectorHeading = "Data Sets" + ucrReceiverStation.SetParameter(New RParameter("station", 0)) + ucrReceiverStation.Selector = ucrSelectorExportDefinitions + ucrReceiverStation.SetParameterIsString() + ucrReceiverStation.SetMeAsReceiver() + ucrReceiverStation.SetClimaticType("station") + ucrReceiverStation.bAutoFill = True ucrReceiverDataYear.SetParameter(New RParameter("data_by_year", 1)) ucrReceiverDataYear.Selector = ucrSelectorExportDefinitions @@ -71,16 +70,22 @@ Public Class dlgExportClimaticDefinitions ucrReceiverRain.SetParameter(New RParameter("rain", 6)) ucrReceiverRain.Selector = ucrSelectorExportDefinitions ucrReceiverRain.SetParameterIsString() + ucrReceiverRain.SetClimaticType("rain") + ucrReceiverRain.bAutoFill = True ucrReceiverRain.SetLinkedDisplayControl(lblRain) ucrReceiverYear.SetParameter(New RParameter("year", 7)) ucrReceiverYear.Selector = ucrSelectorExportDefinitions ucrReceiverYear.SetParameterIsString() + ucrReceiverYear.SetClimaticType("year") + ucrReceiverYear.bAutoFill = True ucrReceiverYear.SetLinkedDisplayControl(lblYear) ucrReceiverMonth.SetParameter(New RParameter("month", 8)) ucrReceiverMonth.Selector = ucrSelectorExportDefinitions ucrReceiverMonth.SetParameterIsString() + ucrReceiverMonth.SetClimaticType("month") + ucrReceiverMonth.bAutoFill = True ucrReceiverMonth.SetLinkedDisplayControl(lblMonth) ucrChkAnnualRainfall.SetText("Annual Rainfall") @@ -112,7 +117,6 @@ Public Class dlgExportClimaticDefinitions ucrChkIncludeSummaryData.SetValuesCheckedAndUnchecked("TRUE", "FALSE") ucrChkIncludeSummaryData.SetRDefault("FALSE") - ucrInputStationID.SetParameter(New RParameter("station_id", 18)) ucrInputDefinitionsID.SetParameter(New RParameter("definitions_id", 19)) ucrInputCountry.SetParameter(New RParameter("country", 20)) @@ -176,7 +180,7 @@ Public Class dlgExportClimaticDefinitions Private Sub SetRCodeForControls(bReset As Boolean) ucrReceiverCropData.SetRCode(clsExportRinstatToBucketFunction, bReset) - ucrReceiverData.SetRCode(clsExportRinstatToBucketFunction, bReset) + ucrReceiverStation.SetRCode(clsExportRinstatToBucketFunction, bReset) ucrReceiverDataYear.SetRCode(clsExportRinstatToBucketFunction, bReset) ucrReceiverDataYearMonth.SetRCode(clsExportRinstatToBucketFunction, bReset) ucrReceiverMonth.SetRCode(clsExportRinstatToBucketFunction, bReset) @@ -185,7 +189,6 @@ Public Class dlgExportClimaticDefinitions ucrSelectorExportDefinitions.SetRCode(clsExportRinstatToBucketFunction) ucrInputTokenPath.SetRCode(ClsGcsAuthFileFunction, bReset) - ucrInputStationID.SetRCode(clsExportRinstatToBucketFunction, bReset) ucrInputDefinitionsID.SetRCode(clsExportRinstatToBucketFunction, bReset) ucrInputCountry.SetRCode(clsExportRinstatToBucketFunction, bReset) ucrChkIncludeSummaryData.SetRCode(clsExportRinstatToBucketFunction, bReset) @@ -202,10 +205,9 @@ Public Class dlgExportClimaticDefinitions End Sub Private Sub TestOkEnabled() - If Not ucrReceiverData.IsEmpty AndAlso + If Not ucrReceiverStation.IsEmpty AndAlso Not ucrReceiverYear.IsEmpty AndAlso Not ucrInputCountry.IsEmpty AndAlso - Not ucrInputStationID.IsEmpty AndAlso Not ucrInputDefinitionsID.IsEmpty AndAlso Not ucrInputTokenPath.IsEmpty Then @@ -325,14 +327,6 @@ Public Class dlgExportClimaticDefinitions End If End Sub - Private Sub ucrInputStationID_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputStationID.ControlValueChanged - If Not ucrInputStationID.IsEmpty Then - clsExportRinstatToBucketFunction.AddParameter("station_id", Chr(34) & ucrInputStationID.GetText & Chr(34), iPosition:=18) - Else - clsExportRinstatToBucketFunction.RemoveParameterByName("station_id") - End If - End Sub - Private Sub ucrInputDefinitionsID_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputDefinitionsID.ControlValueChanged If Not ucrInputDefinitionsID.IsEmpty Then clsExportRinstatToBucketFunction.AddParameter("definitions_id", Chr(34) & ucrInputDefinitionsID.GetText & Chr(34), iPosition:=19) @@ -367,13 +361,13 @@ Public Class dlgExportClimaticDefinitions End Sub - Private Sub ucrReceiverData_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverData.ControlContentsChanged, ucrReceiverRain.ControlContentsChanged, ucrReceiverCropData.ControlContentsChanged, ucrReceiverDataYearMonth.ControlContentsChanged, ucrReceiverDataYear.ControlContentsChanged, - ucrReceiverMonth.ControlContentsChanged, ucrReceiverYear.ControlContentsChanged, ucrChkSeasonStartProp.ControlContentsChanged, ucrInputCountry.ControlContentsChanged, ucrInputStationID.ControlContentsChanged, ucrInputDefinitionsID.ControlContentsChanged, ucrChkIncludeSummaryData.ControlContentsChanged, + Private Sub ucrReceiverData_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverRain.ControlContentsChanged, ucrReceiverCropData.ControlContentsChanged, ucrReceiverDataYearMonth.ControlContentsChanged, ucrReceiverDataYear.ControlContentsChanged, ucrReceiverStation.ControlContentsChanged, + ucrReceiverMonth.ControlContentsChanged, ucrReceiverYear.ControlContentsChanged, ucrChkSeasonStartProp.ControlContentsChanged, ucrInputCountry.ControlContentsChanged, ucrInputDefinitionsID.ControlContentsChanged, ucrChkIncludeSummaryData.ControlContentsChanged, ucrChkMonthlyTemp.ControlContentsChanged, ucrChkCropSuccessProp.ControlContentsChanged, ucrChkAnnualTemp.ControlContentsChanged, ucrChkAnnualRainfall.ControlContentsChanged, ucrInputTokenPath.ControlContentsChanged, ucrSelectorExportDefinitions.ControlContentsChanged TestOkEnabled() End Sub - Private Sub ucrReceiverData_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverData.ControlValueChanged - ucrReceiverData.SetMeAsReceiver() + Private Sub ucrSelectorExportDefinitions_DataFrameChanged() Handles ucrSelectorExportDefinitions.DataFrameChanged + TestOkEnabled() End Sub End Class \ No newline at end of file From 98304697bf40d6e69b0b5278444c400d21800fe1 Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Sat, 20 Jul 2024 08:40:42 +0200 Subject: [PATCH 03/13] Added epicawrap package into R-instat --- instat/static/InstatObject/R/InstallPackages.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/static/InstatObject/R/InstallPackages.R b/instat/static/InstatObject/R/InstallPackages.R index c1e29a3c110..a85dbafe642 100644 --- a/instat/static/InstatObject/R/InstallPackages.R +++ b/instat/static/InstatObject/R/InstallPackages.R @@ -161,4 +161,4 @@ devtools::install_github("ianmoran11/mmtable2") devtools::install_github("michael-franke/aida-package") devtools::install_github("rijaf-iri/CDT") devtools::install_github("IDEMSInternational/rapidpror") - +devtools::install_github("IDEMSInternational/epicsawrap") From d1af34c2291218f54467d081b7ce6db8508b6a04 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 23 Jul 2024 05:23:02 +0300 Subject: [PATCH 04/13] Made suggested changes --- instat/dlgClimSoft.Designer.vb | 34 ++-- instat/dlgClimSoft.vb | 15 +- instat/instat.vbproj | 3 + instat/sdgClimsoft.Designer.vb | 156 ++++++++++++------ instat/sdgClimsoft.resx | 120 ++++++++++++++ instat/sdgClimsoft.vb | 62 ++++--- .../static/InstatObject/R/instat_object_R6.R | 58 ++++--- 7 files changed, 336 insertions(+), 112 deletions(-) create mode 100644 instat/sdgClimsoft.resx diff --git a/instat/dlgClimSoft.Designer.vb b/instat/dlgClimSoft.Designer.vb index 18e11098e6a..1c5b32afda8 100644 --- a/instat/dlgClimSoft.Designer.vb +++ b/instat/dlgClimSoft.Designer.vb @@ -67,6 +67,7 @@ Partial Class dlgClimSoft Me.ucrReceiverMultipleElements = New instat.ucrReceiverMultiple() Me.ucrReceiverMultipleStations = New instat.ucrReceiverMultiple() Me.ucrBase = New instat.ucrButtons() + Me.ucrChKUnstackData = New instat.ucrCheck() Me.SuspendLayout() ' 'btnConnection @@ -126,7 +127,7 @@ Partial Class dlgClimSoft ' Me.ucrChkDataDate.AutoSize = True Me.ucrChkDataDate.Checked = False - Me.ucrChkDataDate.Location = New System.Drawing.Point(9, 289) + Me.ucrChkDataDate.Location = New System.Drawing.Point(9, 317) Me.ucrChkDataDate.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) Me.ucrChkDataDate.Name = "ucrChkDataDate" Me.ucrChkDataDate.Size = New System.Drawing.Size(169, 23) @@ -138,7 +139,7 @@ Partial Class dlgClimSoft Me.ucrDtpEndDataDate.AutoSize = True Me.ucrDtpEndDataDate.DateValue = New Date(2021, 5, 18, 16, 45, 8, 379) Me.ucrDtpEndDataDate.Format = "dd MMM yyyy" - Me.ucrDtpEndDataDate.Location = New System.Drawing.Point(156, 312) + Me.ucrDtpEndDataDate.Location = New System.Drawing.Point(156, 340) Me.ucrDtpEndDataDate.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) Me.ucrDtpEndDataDate.MaxDate = New Date(9998, 12, 31, 0, 0, 0, 0) Me.ucrDtpEndDataDate.MinDate = New Date(1753, 1, 1, 0, 0, 0, 0) @@ -152,7 +153,7 @@ Partial Class dlgClimSoft Me.ucrDtpStartDataDate.AutoSize = True Me.ucrDtpStartDataDate.DateValue = New Date(2021, 5, 18, 16, 45, 8, 408) Me.ucrDtpStartDataDate.Format = "dd MMM yyyy" - Me.ucrDtpStartDataDate.Location = New System.Drawing.Point(23, 313) + Me.ucrDtpStartDataDate.Location = New System.Drawing.Point(23, 341) Me.ucrDtpStartDataDate.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) Me.ucrDtpStartDataDate.MaxDate = New Date(9998, 12, 31, 0, 0, 0, 0) Me.ucrDtpStartDataDate.MinDate = New Date(1753, 1, 1, 0, 0, 0, 0) @@ -187,7 +188,7 @@ Partial Class dlgClimSoft ' Me.lblToDataDate.AutoSize = True Me.lblToDataDate.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblToDataDate.Location = New System.Drawing.Point(130, 315) + Me.lblToDataDate.Location = New System.Drawing.Point(130, 345) Me.lblToDataDate.Name = "lblToDataDate" Me.lblToDataDate.Size = New System.Drawing.Size(20, 13) Me.lblToDataDate.TabIndex = 20 @@ -218,7 +219,7 @@ Partial Class dlgClimSoft 'btnCheckRecords ' Me.btnCheckRecords.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.btnCheckRecords.Location = New System.Drawing.Point(6, 376) + Me.btnCheckRecords.Location = New System.Drawing.Point(6, 404) Me.btnCheckRecords.Name = "btnCheckRecords" Me.btnCheckRecords.Size = New System.Drawing.Size(139, 23) Me.btnCheckRecords.TabIndex = 28 @@ -230,7 +231,7 @@ Partial Class dlgClimSoft Me.lblRecordsNum.AutoSize = True Me.lblRecordsNum.ForeColor = System.Drawing.Color.Red Me.lblRecordsNum.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblRecordsNum.Location = New System.Drawing.Point(156, 380) + Me.lblRecordsNum.Location = New System.Drawing.Point(156, 408) Me.lblRecordsNum.Name = "lblRecordsNum" Me.lblRecordsNum.Size = New System.Drawing.Size(64, 13) Me.lblRecordsNum.TabIndex = 29 @@ -239,11 +240,11 @@ Partial Class dlgClimSoft 'btnMoreOptions ' Me.btnMoreOptions.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.btnMoreOptions.Location = New System.Drawing.Point(5, 345) + Me.btnMoreOptions.Location = New System.Drawing.Point(5, 373) Me.btnMoreOptions.Name = "btnMoreOptions" Me.btnMoreOptions.Size = New System.Drawing.Size(139, 23) Me.btnMoreOptions.TabIndex = 31 - Me.btnMoreOptions.Text = "More options" + Me.btnMoreOptions.Text = "Options" Me.btnMoreOptions.UseVisualStyleBackColor = True ' 'rdoMetadata @@ -378,18 +379,30 @@ Partial Class dlgClimSoft ' Me.ucrBase.AutoSize = True Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(9, 407) + Me.ucrBase.Location = New System.Drawing.Point(9, 444) Me.ucrBase.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(408, 52) Me.ucrBase.TabIndex = 14 ' + 'ucrChKUnstackData + ' + Me.ucrChKUnstackData.AutoSize = True + Me.ucrChKUnstackData.Checked = False + Me.ucrChKUnstackData.Location = New System.Drawing.Point(8, 289) + Me.ucrChKUnstackData.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) + Me.ucrChKUnstackData.Name = "ucrChKUnstackData" + Me.ucrChKUnstackData.Size = New System.Drawing.Size(169, 23) + Me.ucrChKUnstackData.TabIndex = 38 + Me.ttClimsoft.SetToolTip(Me.ucrChKUnstackData, "Select Observation Data Date Range") + ' 'dlgClimSoft ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True - Me.ClientSize = New System.Drawing.Size(438, 464) + Me.ClientSize = New System.Drawing.Size(438, 505) + Me.Controls.Add(Me.ucrChKUnstackData) Me.Controls.Add(Me.ucrChkImportFlagsMetadata) Me.Controls.Add(Me.ucrChkImportElementsMetadata) Me.Controls.Add(Me.ucrChkImportStationsMetadata) @@ -456,4 +469,5 @@ Partial Class dlgClimSoft Friend WithEvents ucrChkImportElementsMetadata As ucrCheck Friend WithEvents ucrChkImportStationsMetadata As ucrCheck Friend WithEvents ucrChkImportFlagsMetadata As ucrCheck + Friend WithEvents ucrChKUnstackData As ucrCheck End Class \ No newline at end of file diff --git a/instat/dlgClimSoft.vb b/instat/dlgClimSoft.vb index c6113117e85..b448a049de6 100644 --- a/instat/dlgClimSoft.vb +++ b/instat/dlgClimSoft.vb @@ -109,9 +109,16 @@ Public Class dlgClimSoft ucrCboQCStatus.SetLinkedDisplayControl(lblSelectQCStatus) '--------------------------------------- + 'Unstack data + '--------------------------------------- + ucrChKUnstackData.SetText("Unstack Data") + ucrChKUnstackData.SetParameter(New RParameter("unstack_data", 13)) + ucrChKUnstackData.SetRDefault("FALSE") + '--------------------------------------- + 'date range '--------------------------------------- - ucrChkDataDate.SetText("Select Data Date") + ucrChkDataDate.SetText("Select Dates") ucrDtpStartDataDate.SetParameter(New RParameter("start_date", 6)) ucrDtpStartDataDate.SetParameterIsRDate() @@ -147,7 +154,7 @@ Public Class dlgClimSoft ucrPnlOptions.AddFunctionNamesCondition(rdoMetadata, frmMain.clsRLink.strInstatDataObject & "$import_climsoft_metadata") - ucrPnlOptions.AddToLinkedControls({ucrCboTable, ucrCboQCStatus, ucrSelectorForClimSoft, ucrReceiverMultipleStations, ucrReceiverMultipleElements, ucrCboStations, ucrCboElements, ucrChkDataDate}, + ucrPnlOptions.AddToLinkedControls({ucrCboTable, ucrCboQCStatus, ucrSelectorForClimSoft, ucrReceiverMultipleStations, ucrReceiverMultipleElements, ucrCboStations, ucrCboElements, ucrChkDataDate, ucrChKUnstackData}, {rdoData}, bNewLinkedAddRemoveParameter:=False, bNewLinkedHideIfParameterMissing:=True) ucrPnlOptions.AddToLinkedControls({ucrChkImportStationsMetadata, ucrChkImportElementsMetadata, ucrChkImportFlagsMetadata}, {rdoMetadata}, bNewLinkedAddRemoveParameter:=False, bNewLinkedHideIfParameterMissing:=True) @@ -163,7 +170,7 @@ Public Class dlgClimSoft 'data command '--------------------------------------- clsRImportClimsoftData.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$import_climsoft_data") - clsRImportClimsoftData.AddParameter(strParameterName:="table", strParameterValue:=Chr(34) & "observationinitial" & Chr(34), iPosition:=0) + clsRImportClimsoftData.AddParameter(strParameterName:="table", strParameterValue:=Chr(34) & "observationfinal" & Chr(34), iPosition:=0) clsRImportClimsoftData.AddParameter(strParameterName:="station_filter_column", strParameterValue:=Chr(34) & "stationId" & Chr(34), iPosition:=1) clsRImportClimsoftData.AddParameter(strParameterName:="element_filter_column", strParameterValue:=Chr(34) & "elementId" & Chr(34), iPosition:=3) '--------------------------------------- @@ -193,6 +200,8 @@ Public Class dlgClimSoft ucrCboTable.SetRCode(clsRImportClimsoftData, bReset) + ucrChKUnstackData.SetRCode(clsRImportClimsoftData, bReset) + ucrCboQCStatus.SetRCode(clsRImportClimsoftData, bReset) ucrDtpStartDataDate.SetRCode(clsRImportClimsoftData, bReset) diff --git a/instat/instat.vbproj b/instat/instat.vbproj index ac9774d99bb..7670f979bf2 100644 --- a/instat/instat.vbproj +++ b/instat/instat.vbproj @@ -3206,6 +3206,9 @@ dlgThreeVariablePivotTable.vb + + sdgClimsoft.vb + sdgDefineAnnualRainfall.vb diff --git a/instat/sdgClimsoft.Designer.vb b/instat/sdgClimsoft.Designer.vb index 0dc1103611d..66902102eb5 100644 --- a/instat/sdgClimsoft.Designer.vb +++ b/instat/sdgClimsoft.Designer.vb @@ -24,10 +24,10 @@ Partial Class sdgClimsoft Private Sub InitializeComponent() Me.tbpTitles = New System.Windows.Forms.TabPage() Me.grpMetadataToImport = New System.Windows.Forms.GroupBox() + Me.ucrChkImportElementsMetadata = New instat.ucrCheck() + Me.ucrChkImportStationsMetadata = New instat.ucrCheck() Me.tbColumns = New System.Windows.Forms.TabPage() Me.grpColumnsToInclude = New System.Windows.Forms.GroupBox() - Me.tbpMoreOptions = New System.Windows.Forms.TabControl() - Me.ucrBaseSubdialog = New instat.ucrButtonsSubdialogue() Me.ucrChkIncludeQCLog = New instat.ucrCheck() Me.ucrChkIncludeCapturedBy = New instat.ucrCheck() Me.ucrChkIncludeQCStatus = New instat.ucrCheck() @@ -37,8 +37,12 @@ Partial Class sdgClimsoft Me.ucrChkIncludeAquistion = New instat.ucrCheck() Me.ucrChkIncludeEntryForm = New instat.ucrCheck() Me.ucrChkIncludeFlag = New instat.ucrCheck() - Me.ucrChkImportElementsMetadata = New instat.ucrCheck() - Me.ucrChkImportStationsMetadata = New instat.ucrCheck() + Me.tbpMoreOptions = New System.Windows.Forms.TabControl() + Me.ucrBaseSubdialog = New instat.ucrButtonsSubdialogue() + Me.ucrChkIncludeElementId = New instat.ucrCheck() + Me.ucrChkIncludeStationId = New instat.ucrCheck() + Me.ucrChkIncludeDateTime = New instat.ucrCheck() + Me.ucrChkIncludeElementName = New instat.ucrCheck() Me.tbpTitles.SuspendLayout() Me.grpMetadataToImport.SuspendLayout() Me.tbColumns.SuspendLayout() @@ -52,7 +56,7 @@ Partial Class sdgClimsoft Me.tbpTitles.Location = New System.Drawing.Point(4, 22) Me.tbpTitles.Name = "tbpTitles" Me.tbpTitles.Padding = New System.Windows.Forms.Padding(3) - Me.tbpTitles.Size = New System.Drawing.Size(409, 281) + Me.tbpTitles.Size = New System.Drawing.Size(409, 303) Me.tbpTitles.TabIndex = 2 Me.tbpTitles.Tag = "" Me.tbpTitles.Text = "Metadata" @@ -69,13 +73,31 @@ Partial Class sdgClimsoft Me.grpMetadataToImport.TabStop = False Me.grpMetadataToImport.Text = "Metadata to Import" ' + 'ucrChkImportElementsMetadata + ' + Me.ucrChkImportElementsMetadata.AutoSize = True + Me.ucrChkImportElementsMetadata.Checked = False + Me.ucrChkImportElementsMetadata.Location = New System.Drawing.Point(0, 46) + Me.ucrChkImportElementsMetadata.Name = "ucrChkImportElementsMetadata" + Me.ucrChkImportElementsMetadata.Size = New System.Drawing.Size(315, 23) + Me.ucrChkImportElementsMetadata.TabIndex = 20 + ' + 'ucrChkImportStationsMetadata + ' + Me.ucrChkImportStationsMetadata.AutoSize = True + Me.ucrChkImportStationsMetadata.Checked = False + Me.ucrChkImportStationsMetadata.Location = New System.Drawing.Point(0, 22) + Me.ucrChkImportStationsMetadata.Name = "ucrChkImportStationsMetadata" + Me.ucrChkImportStationsMetadata.Size = New System.Drawing.Size(315, 23) + Me.ucrChkImportStationsMetadata.TabIndex = 19 + ' 'tbColumns ' Me.tbColumns.Controls.Add(Me.grpColumnsToInclude) Me.tbColumns.Location = New System.Drawing.Point(4, 22) Me.tbColumns.Name = "tbColumns" Me.tbColumns.Padding = New System.Windows.Forms.Padding(3) - Me.tbColumns.Size = New System.Drawing.Size(409, 281) + Me.tbColumns.Size = New System.Drawing.Size(409, 367) Me.tbColumns.TabIndex = 3 Me.tbColumns.Tag = "" Me.tbColumns.Text = "Data" @@ -83,6 +105,10 @@ Partial Class sdgClimsoft ' 'grpColumnsToInclude ' + Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeElementName) + Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeDateTime) + Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeElementId) + Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeStationId) Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeQCLog) Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeCapturedBy) Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeQCStatus) @@ -94,34 +120,16 @@ Partial Class sdgClimsoft Me.grpColumnsToInclude.Controls.Add(Me.ucrChkIncludeFlag) Me.grpColumnsToInclude.Location = New System.Drawing.Point(8, 10) Me.grpColumnsToInclude.Name = "grpColumnsToInclude" - Me.grpColumnsToInclude.Size = New System.Drawing.Size(394, 265) + Me.grpColumnsToInclude.Size = New System.Drawing.Size(394, 351) Me.grpColumnsToInclude.TabIndex = 32 Me.grpColumnsToInclude.TabStop = False Me.grpColumnsToInclude.Text = "Columns to Include" ' - 'tbpMoreOptions - ' - Me.tbpMoreOptions.Controls.Add(Me.tbColumns) - Me.tbpMoreOptions.Controls.Add(Me.tbpTitles) - Me.tbpMoreOptions.Location = New System.Drawing.Point(-1, 4) - Me.tbpMoreOptions.Name = "tbpMoreOptions" - Me.tbpMoreOptions.SelectedIndex = 0 - Me.tbpMoreOptions.Size = New System.Drawing.Size(417, 307) - Me.tbpMoreOptions.TabIndex = 2 - ' - 'ucrBaseSubdialog - ' - Me.ucrBaseSubdialog.AutoSize = True - Me.ucrBaseSubdialog.Location = New System.Drawing.Point(88, 315) - Me.ucrBaseSubdialog.Name = "ucrBaseSubdialog" - Me.ucrBaseSubdialog.Size = New System.Drawing.Size(224, 29) - Me.ucrBaseSubdialog.TabIndex = 3 - ' 'ucrChkIncludeQCLog ' Me.ucrChkIncludeQCLog.AutoSize = True - Me.ucrChkIncludeQCLog.Checked = True - Me.ucrChkIncludeQCLog.Location = New System.Drawing.Point(6, 186) + Me.ucrChkIncludeQCLog.Checked = False + Me.ucrChkIncludeQCLog.Location = New System.Drawing.Point(6, 294) Me.ucrChkIncludeQCLog.Name = "ucrChkIncludeQCLog" Me.ucrChkIncludeQCLog.Size = New System.Drawing.Size(295, 23) Me.ucrChkIncludeQCLog.TabIndex = 21 @@ -129,8 +137,8 @@ Partial Class sdgClimsoft 'ucrChkIncludeCapturedBy ' Me.ucrChkIncludeCapturedBy.AutoSize = True - Me.ucrChkIncludeCapturedBy.Checked = True - Me.ucrChkIncludeCapturedBy.Location = New System.Drawing.Point(6, 138) + Me.ucrChkIncludeCapturedBy.Checked = False + Me.ucrChkIncludeCapturedBy.Location = New System.Drawing.Point(6, 243) Me.ucrChkIncludeCapturedBy.Name = "ucrChkIncludeCapturedBy" Me.ucrChkIncludeCapturedBy.Size = New System.Drawing.Size(295, 23) Me.ucrChkIncludeCapturedBy.TabIndex = 20 @@ -138,8 +146,8 @@ Partial Class sdgClimsoft 'ucrChkIncludeQCStatus ' Me.ucrChkIncludeQCStatus.AutoSize = True - Me.ucrChkIncludeQCStatus.Checked = True - Me.ucrChkIncludeQCStatus.Location = New System.Drawing.Point(6, 162) + Me.ucrChkIncludeQCStatus.Checked = False + Me.ucrChkIncludeQCStatus.Location = New System.Drawing.Point(6, 269) Me.ucrChkIncludeQCStatus.Name = "ucrChkIncludeQCStatus" Me.ucrChkIncludeQCStatus.Size = New System.Drawing.Size(295, 23) Me.ucrChkIncludeQCStatus.TabIndex = 0 @@ -147,8 +155,8 @@ Partial Class sdgClimsoft 'ucrChkIncludeLevel ' Me.ucrChkIncludeLevel.AutoSize = True - Me.ucrChkIncludeLevel.Checked = True - Me.ucrChkIncludeLevel.Location = New System.Drawing.Point(6, 90) + Me.ucrChkIncludeLevel.Checked = False + Me.ucrChkIncludeLevel.Location = New System.Drawing.Point(6, 196) Me.ucrChkIncludeLevel.Name = "ucrChkIncludeLevel" Me.ucrChkIncludeLevel.Size = New System.Drawing.Size(295, 23) Me.ucrChkIncludeLevel.TabIndex = 19 @@ -174,8 +182,8 @@ Partial Class sdgClimsoft 'ucrChkIncludeAquistion ' Me.ucrChkIncludeAquistion.AutoSize = True - Me.ucrChkIncludeAquistion.Checked = True - Me.ucrChkIncludeAquistion.Location = New System.Drawing.Point(6, 66) + Me.ucrChkIncludeAquistion.Checked = False + Me.ucrChkIncludeAquistion.Location = New System.Drawing.Point(6, 168) Me.ucrChkIncludeAquistion.Name = "ucrChkIncludeAquistion" Me.ucrChkIncludeAquistion.Size = New System.Drawing.Size(295, 23) Me.ucrChkIncludeAquistion.TabIndex = 16 @@ -183,8 +191,8 @@ Partial Class sdgClimsoft 'ucrChkIncludeEntryForm ' Me.ucrChkIncludeEntryForm.AutoSize = True - Me.ucrChkIncludeEntryForm.Checked = True - Me.ucrChkIncludeEntryForm.Location = New System.Drawing.Point(6, 114) + Me.ucrChkIncludeEntryForm.Checked = False + Me.ucrChkIncludeEntryForm.Location = New System.Drawing.Point(6, 220) Me.ucrChkIncludeEntryForm.Name = "ucrChkIncludeEntryForm" Me.ucrChkIncludeEntryForm.Size = New System.Drawing.Size(295, 23) Me.ucrChkIncludeEntryForm.TabIndex = 15 @@ -192,35 +200,71 @@ Partial Class sdgClimsoft 'ucrChkIncludeFlag ' Me.ucrChkIncludeFlag.AutoSize = True - Me.ucrChkIncludeFlag.Checked = True - Me.ucrChkIncludeFlag.Location = New System.Drawing.Point(7, 210) + Me.ucrChkIncludeFlag.Checked = False + Me.ucrChkIncludeFlag.Location = New System.Drawing.Point(7, 321) Me.ucrChkIncludeFlag.Name = "ucrChkIncludeFlag" Me.ucrChkIncludeFlag.Size = New System.Drawing.Size(295, 23) Me.ucrChkIncludeFlag.TabIndex = 14 ' - 'ucrChkImportElementsMetadata + 'tbpMoreOptions ' - Me.ucrChkImportElementsMetadata.AutoSize = True - Me.ucrChkImportElementsMetadata.Checked = True - Me.ucrChkImportElementsMetadata.Location = New System.Drawing.Point(0, 46) - Me.ucrChkImportElementsMetadata.Name = "ucrChkImportElementsMetadata" - Me.ucrChkImportElementsMetadata.Size = New System.Drawing.Size(315, 23) - Me.ucrChkImportElementsMetadata.TabIndex = 20 + Me.tbpMoreOptions.Controls.Add(Me.tbColumns) + Me.tbpMoreOptions.Controls.Add(Me.tbpTitles) + Me.tbpMoreOptions.Location = New System.Drawing.Point(-1, 4) + Me.tbpMoreOptions.Name = "tbpMoreOptions" + Me.tbpMoreOptions.SelectedIndex = 0 + Me.tbpMoreOptions.Size = New System.Drawing.Size(417, 393) + Me.tbpMoreOptions.TabIndex = 2 ' - 'ucrChkImportStationsMetadata + 'ucrBaseSubdialog ' - Me.ucrChkImportStationsMetadata.AutoSize = True - Me.ucrChkImportStationsMetadata.Checked = True - Me.ucrChkImportStationsMetadata.Location = New System.Drawing.Point(0, 22) - Me.ucrChkImportStationsMetadata.Name = "ucrChkImportStationsMetadata" - Me.ucrChkImportStationsMetadata.Size = New System.Drawing.Size(315, 23) - Me.ucrChkImportStationsMetadata.TabIndex = 19 + Me.ucrBaseSubdialog.AutoSize = True + Me.ucrBaseSubdialog.Location = New System.Drawing.Point(88, 397) + Me.ucrBaseSubdialog.Name = "ucrBaseSubdialog" + Me.ucrBaseSubdialog.Size = New System.Drawing.Size(224, 29) + Me.ucrBaseSubdialog.TabIndex = 3 + ' + 'ucrChkIncludeElementId + ' + Me.ucrChkIncludeElementId.AutoSize = True + Me.ucrChkIncludeElementId.Checked = False + Me.ucrChkIncludeElementId.Location = New System.Drawing.Point(7, 116) + Me.ucrChkIncludeElementId.Name = "ucrChkIncludeElementId" + Me.ucrChkIncludeElementId.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeElementId.TabIndex = 23 + ' + 'ucrChkIncludeStationId + ' + Me.ucrChkIncludeStationId.AutoSize = True + Me.ucrChkIncludeStationId.Checked = False + Me.ucrChkIncludeStationId.Location = New System.Drawing.Point(7, 92) + Me.ucrChkIncludeStationId.Name = "ucrChkIncludeStationId" + Me.ucrChkIncludeStationId.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeStationId.TabIndex = 22 + ' + 'ucrChkIncludeDateTime + ' + Me.ucrChkIncludeDateTime.AutoSize = True + Me.ucrChkIncludeDateTime.Checked = True + Me.ucrChkIncludeDateTime.Location = New System.Drawing.Point(7, 66) + Me.ucrChkIncludeDateTime.Name = "ucrChkIncludeDateTime" + Me.ucrChkIncludeDateTime.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeDateTime.TabIndex = 24 + ' + 'ucrChkIncludeElementName + ' + Me.ucrChkIncludeElementName.AutoSize = True + Me.ucrChkIncludeElementName.Checked = False + Me.ucrChkIncludeElementName.Location = New System.Drawing.Point(7, 141) + Me.ucrChkIncludeElementName.Name = "ucrChkIncludeElementName" + Me.ucrChkIncludeElementName.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeElementName.TabIndex = 25 ' 'sdgClimsoft ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(417, 348) + Me.ClientSize = New System.Drawing.Size(417, 434) Me.Controls.Add(Me.ucrBaseSubdialog) Me.Controls.Add(Me.tbpMoreOptions) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow @@ -256,4 +300,8 @@ Partial Class sdgClimsoft Friend WithEvents ucrChkIncludeCapturedBy As ucrCheck Friend WithEvents ucrChkIncludeLevel As ucrCheck Friend WithEvents ucrChkIncludeQCLog As ucrCheck + Friend WithEvents ucrChkIncludeElementId As ucrCheck + Friend WithEvents ucrChkIncludeStationId As ucrCheck + Friend WithEvents ucrChkIncludeDateTime As ucrCheck + Friend WithEvents ucrChkIncludeElementName As ucrCheck End Class \ No newline at end of file diff --git a/instat/sdgClimsoft.resx b/instat/sdgClimsoft.resx new file mode 100644 index 00000000000..1af7de150c9 --- /dev/null +++ b/instat/sdgClimsoft.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/sdgClimsoft.vb b/instat/sdgClimsoft.vb index d6a61a9bb2a..c1a48427aa3 100644 --- a/instat/sdgClimsoft.vb +++ b/instat/sdgClimsoft.vb @@ -31,52 +31,65 @@ Public Class sdgClimsoft 'Columns to include '--------------------------------------- ucrChkIncludeStationName.SetText("Station Name") - ucrChkIncludeStationName.SetParameter(New RParameter("include_station_name", 13)) - ucrChkIncludeStationName.SetRDefault("TRUE") + ucrChkIncludeStationName.Enabled = False ucrChkIncludeElementAbbrv.SetText("Element Abbreviation") - ucrChkIncludeElementAbbrv.SetParameter(New RParameter("include_element_abbreviation", 14)) - ucrChkIncludeElementAbbrv.SetRDefault("TRUE") + ucrChkIncludeElementAbbrv.Enabled = False + + ucrChkIncludeDateTime.SetText("Date Time") + ucrChkIncludeDateTime.Enabled = False + + ucrChkIncludeStationId.SetText("Station Id") + ucrChkIncludeStationId.SetParameter(New RParameter("include_station_id", 13)) + ucrChkIncludeStationId.SetRDefault("FALSE") + + ucrChkIncludeElementId.SetText("Element Id") + ucrChkIncludeElementId.SetParameter(New RParameter("include_element_id", 14)) + ucrChkIncludeElementId.SetRDefault("FALSE") + + ucrChkIncludeElementName.SetText("Element Name") + ucrChkIncludeElementName.SetParameter(New RParameter("include_element_name", 15)) + ucrChkIncludeElementName.SetRDefault("FALSE") ucrChkIncludeAquistion.SetText("Acquisition Type") - ucrChkIncludeAquistion.SetParameter(New RParameter("include_acquisition_type", 15)) - ucrChkIncludeAquistion.SetRDefault("TRUE") + ucrChkIncludeAquistion.SetParameter(New RParameter("include_acquisition_type", 16)) + ucrChkIncludeAquistion.SetRDefault("FALSE") ucrChkIncludeLevel.SetText("Level") - ucrChkIncludeLevel.SetParameter(New RParameter("include_level", 16)) - ucrChkIncludeLevel.SetRDefault("TRUE") + ucrChkIncludeLevel.SetParameter(New RParameter("include_level", 17)) + ucrChkIncludeLevel.SetRDefault("FALSE") ucrChkIncludeEntryForm.SetText("Entry Form") - ucrChkIncludeEntryForm.SetParameter(New RParameter("include_entry_form", 17)) - ucrChkIncludeEntryForm.SetRDefault("TRUE") + ucrChkIncludeEntryForm.SetParameter(New RParameter("include_entry_form", 18)) + ucrChkIncludeEntryForm.SetRDefault("FALSE") ucrChkIncludeCapturedBy.SetText("Captured By (user)") - ucrChkIncludeCapturedBy.SetParameter(New RParameter("include_captured_by", 18)) - ucrChkIncludeCapturedBy.SetRDefault("TRUE") + ucrChkIncludeCapturedBy.SetParameter(New RParameter("include_captured_by", 19)) + ucrChkIncludeCapturedBy.SetRDefault("FALSE") ucrChkIncludeQCStatus.SetText("QC Status") - ucrChkIncludeQCStatus.SetParameter(New RParameter("include_qc_status", 19)) - ucrChkIncludeQCStatus.SetRDefault("TRUE") + ucrChkIncludeQCStatus.SetParameter(New RParameter("include_qc_status", 20)) + ucrChkIncludeQCStatus.SetRDefault("FALSE") ucrChkIncludeQCLog.SetText("QC Log") - ucrChkIncludeQCLog.SetParameter(New RParameter("include_qc_log", 20)) - ucrChkIncludeQCLog.SetRDefault("TRUE") + ucrChkIncludeQCLog.SetParameter(New RParameter("include_qc_log", 21)) + ucrChkIncludeQCLog.SetRDefault("FALSE") ucrChkIncludeFlag.SetText("Flag") - ucrChkIncludeFlag.SetParameter(New RParameter("include_flag", 21)) - ucrChkIncludeFlag.SetRDefault("TRUE") + ucrChkIncludeFlag.SetParameter(New RParameter("include_flag", 22)) + ucrChkIncludeFlag.SetRDefault("FALSE") '--------------------------------------- 'Metadata '--------------------------------------- ucrChkImportStationsMetadata.SetText("Selected Stations") - ucrChkImportStationsMetadata.SetParameter(New RParameter("import_selected_stations_metadata", 12)) - ucrChkImportStationsMetadata.SetRDefault("TRUE") + ucrChkImportStationsMetadata.SetParameter(New RParameter("import_selected_stations_metadata", 23)) + ucrChkImportStationsMetadata.SetRDefault("FALSE") ucrChkImportElementsMetadata.SetText("Selected Elements") - ucrChkImportElementsMetadata.SetParameter(New RParameter("import_selected_elements_metadata", 13)) - ucrChkImportElementsMetadata.SetRDefault("TRUE") + ucrChkImportElementsMetadata.SetParameter(New RParameter("import_selected_elements_metadata", 24)) + ucrChkImportElementsMetadata.SetRDefault("FALSE") '--------------------------------------- bControlsInitialised = True @@ -89,8 +102,9 @@ Public Class sdgClimsoft 'Columns '--------------------------------------- - ucrChkIncludeStationName.SetRCode(clsRFunction, bReset) - ucrChkIncludeElementAbbrv.SetRCode(clsRFunction, bReset) + ucrChkIncludeStationId.SetRCode(clsRFunction, bReset) + ucrChkIncludeElementId.SetRCode(clsRFunction, bReset) + ucrChkIncludeElementName.SetRCode(clsRFunction, bReset) ucrChkIncludeAquistion.SetRCode(clsRFunction, bReset) ucrChkIncludeLevel.SetRCode(clsRFunction, bReset) ucrChkIncludeEntryForm.SetRCode(clsRFunction, bReset) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 95c44c5c065..78fe1743d8b 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -1867,7 +1867,7 @@ DataBook$set("public", "get_db_table_row_count", function(tableName, query_condi #Imports Climsoft metadata. DataBook$set("public", "import_climsoft_metadata", function(import_stations = FALSE, import_elements = FALSE, import_flags = FALSE) { - if(!import_stations || !import_elements){ + if(!import_stations && !import_elements){ stop("No metadata selected for import") } @@ -1918,17 +1918,16 @@ DataBook$set("public", "import_climsoft_metadata", function(import_stations = FA }) - -#imports data from climsoft observation tables; initial or final. +#imports data from Climsoft observation tables; initial or final. #imports selected stations and elements metadata DataBook$set("public", "import_climsoft_data", function(tableName, station_filter_column, stations = c(), element_filter_column, elements = c(), - qc_status = -1, start_date = NULL, end_date = NULL, - include_station_name = TRUE, include_element_abbreviation = TRUE, include_qc_status = TRUE, - include_acquisition_type = TRUE, include_flag = TRUE, include_entry_form = TRUE, - include_qc_log = TRUE, include_captured_by = TRUE, include_level = TRUE, - import_selected_stations_metadata = TRUE, import_selected_elements_metadata = TRUE) { + qc_status = -1, start_date = NULL, end_date = NULL, unstack_data = FALSE, + include_station_id = FALSE, include_element_id = FALSE, include_element_name = FALSE, + include_acquisition_type = FALSE, include_level = FALSE, include_entry_form = FALSE, include_captured_by = FALSE, + include_qc_status = FALSE, include_qc_log = FALSE, include_flag = FALSE, + import_selected_stations_metadata = FALSE, import_selected_elements_metadata = FALSE) { #connection and parameter checks #-------------------------------- con <- self$get_database_connection() @@ -1951,16 +1950,24 @@ DataBook$set("public", "import_climsoft_data", function(tableName, #selects #-------------------------------- - sql_select <- paste0(tableName,".recordedFrom AS station_id") + + sql_select<- "" - if(include_station_name){ + if(include_station_id){ + sql_select <- paste0(tableName,".recordedFrom AS station_id") sql_select <-paste0(sql_select,", station.stationName AS station_name") + }else{ + sql_select <-"station.stationName AS station_name" + } + + if(include_element_id){ + sql_select <-paste0(sql_select, ", ", tableName,".describedBy AS element_id") } - sql_select <-paste0(sql_select, ", ", tableName,".describedBy AS element_id") + sql_select <-paste0(sql_select,", obselement.abbreviation AS element_abbrv") - if(include_element_abbreviation){ - sql_select <-paste0(sql_select,", obselement.abbreviation AS element_abbrv") + if(include_element_name){ + sql_select <-paste0(sql_select,", obselement.elementName AS element_name") } if(include_acquisition_type){ @@ -2045,20 +2052,29 @@ DataBook$set("public", "import_climsoft_data", function(tableName, observations_data_name <- next_default_item("observations_data", self$get_data_names(), include_index = FALSE) data_list[[observations_data_name]] <- DBI::dbGetQuery(con,paste0(sql_select, sql_filter, sql_order_by)) + if(unstack_data){ + observations_unstacked_data_name <- next_default_item("observations_unstacked_data", self$get_data_names(), include_index = FALSE) + data_list[[observations_unstacked_data_name]] <- reshape2::dcast(data = data_list[[observations_data_name]], formula = station_name + date_time ~ element_abbrv, value.var = "value") + } + self$import_data(data_tables = data_list) #-------------------------------- #transform imported data #-------------------------------- - self$convert_column_to_type(data_name = observations_data_name, col_names = c("station_id","element_id"), to_type = "factor") + self$convert_column_to_type(data_name = observations_data_name, col_names = c("station_name","element_abbrv"), to_type = "factor") + + if(include_station_id){ + self$convert_column_to_type(data_name = observations_data_name, col_names = "station_id", to_type = "factor") + } - if(include_station_name){ - self$convert_column_to_type(data_name = observations_data_name, col_names = "station_name", to_type = "factor") + if(include_element_id){ + self$convert_column_to_type(data_name = observations_data_name, col_names = "element_id", to_type = "factor") } - if(include_element_abbreviation){ - self$convert_column_to_type(data_name = observations_data_name, col_names = "element_abbrv", to_type = "factor") + if(include_element_name){ + self$convert_column_to_type(data_name = observations_data_name, col_names = "element_name", to_type = "factor") } if(include_qc_status){ @@ -2083,13 +2099,13 @@ DataBook$set("public", "import_climsoft_data", function(tableName, #todo. should this be done at this point?? Keeping in mind that we may have hourly data #create a plain date column from the observation data datetime column values - obsdate <- self$get_columns_from_data(data_name = observations_data_name, col_names = "date_time", use_current_filter = FALSE) - self$add_columns_to_data(data_name = observations_data_name, col_name = "date", col_data = as.Date(x = obsdate), before = FALSE, adjacent_column = "date_time") + #obsdate <- self$get_columns_from_data(data_name = observations_data_name, col_names = "date_time", use_current_filter = FALSE) + #self$add_columns_to_data(data_name = observations_data_name, col_name = "date", col_data = as.Date(x = obsdate), before = FALSE, adjacent_column = "date_time") #-------------------------------- }) -#TODO. Deprecated. Delete this after after deleting the import from climsoft wizard dialog +#TODO. Deprecated. Delete this after after deleting the import from Climsoft wizard dialog DataBook$set("public", "import_from_climsoft", function(stationfiltercolumn = "stationId", stations = c(), elementfiltercolumn = "elementId", elements = c(), include_observation_data = FALSE, include_observation_flags = FALSE, unstack_data = FALSE, include_elements_info = FALSE, start_date = NULL, end_date = NULL) { #need to perform checks here con <- self$get_database_connection() From 41315e226b84934e74b8648aad36d5fc3278e837 Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Tue, 23 Jul 2024 10:13:23 +0300 Subject: [PATCH 05/13] changes --- instat/sdgDefineAnnualRainfall.vb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/instat/sdgDefineAnnualRainfall.vb b/instat/sdgDefineAnnualRainfall.vb index bf4f6bf23c8..6c09e8f7df9 100644 --- a/instat/sdgDefineAnnualRainfall.vb +++ b/instat/sdgDefineAnnualRainfall.vb @@ -44,10 +44,14 @@ Public Class sdgDefineAnnualRainfall ucrReceiverStation.SetParameter(New RParameter("station_col", 1)) ucrReceiverStation.Selector = ucrSelectorDefineAnnualRain ucrReceiverStation.SetParameterIsString() + ucrReceiverStation.SetClimaticType("station") + ucrReceiverStation.bAutoFill = True ucrReceiverYear.SetParameter(New RParameter("year_col", 2)) ucrReceiverYear.Selector = ucrSelectorDefineAnnualRain ucrReceiverYear.SetParameterIsString() + ucrReceiverYear.SetClimaticType("year") + ucrReceiverYear.bAutoFill = True ucrReceiverStartRainDOY.SetParameter(New RParameter("start_rains_doy_col", 3)) ucrReceiverStartRainDOY.Selector = ucrSelectorDefineAnnualRain @@ -108,6 +112,8 @@ Public Class sdgDefineAnnualRainfall ucrReceiverStationCrop.SetParameter(New RParameter("station_col", 1)) ucrReceiverStationCrop.Selector = ucrSelectorCropProp ucrReceiverStationCrop.SetParameterIsString() + ucrReceiverStationCrop.SetClimaticType("station") + ucrReceiverStationCrop.bAutoFill = True ucrReceiverTotalRain.SetParameter(New RParameter("total_rain_col", 2)) ucrReceiverTotalRain.Selector = ucrSelectorCropProp @@ -129,10 +135,14 @@ Public Class sdgDefineAnnualRainfall ucrReceiverSeasonStationProb.SetParameter(New RParameter("station_col", 1)) ucrReceiverSeasonStationProb.Selector = ucrSelectorSeasonStartProp ucrReceiverSeasonStationProb.SetParameterIsString() + ucrReceiverSeasonStationProb.SetClimaticType("station") + ucrReceiverSeasonStationProb.bAutoFill = True ucrReceiverSeasonYear.SetParameter(New RParameter("year_col", 2)) ucrReceiverSeasonYear.Selector = ucrSelectorSeasonStartProp ucrReceiverSeasonYear.SetParameterIsString() + ucrReceiverSeasonYear.SetClimaticType("year") + ucrReceiverSeasonYear.bAutoFill = True ucrReceiverSeasonPlantingDay.SetParameter(New RParameter("plant_day_col", 3)) ucrReceiverSeasonPlantingDay.Selector = ucrSelectorSeasonStartProp @@ -146,10 +156,14 @@ Public Class sdgDefineAnnualRainfall ucrReceiverAnnualTempStation.SetParameter(New RParameter("station_col", 1)) ucrReceiverAnnualTempStation.Selector = ucrSelectorAnnualTemp ucrReceiverAnnualTempStation.SetParameterIsString() + ucrReceiverAnnualTempStation.SetClimaticType("station") + ucrReceiverAnnualTempStation.bAutoFill = True ucrReceiverAnnualTempYr.SetParameter(New RParameter("year_col", 2)) ucrReceiverAnnualTempYr.Selector = ucrSelectorAnnualTemp ucrReceiverAnnualTempYr.SetParameterIsString() + ucrReceiverAnnualTempYr.SetClimaticType("year") + ucrReceiverAnnualTempYr.bAutoFill = True ucrReceiverMeanAnnual.SetParameter(New RParameter("mean_tmin_col", 3)) ucrReceiverMeanAnnual.Selector = ucrSelectorAnnualTemp @@ -179,14 +193,20 @@ Public Class sdgDefineAnnualRainfall ucrReceiverMonthlyTemp.SetParameter(New RParameter("station_col", 1)) ucrReceiverMonthlyTemp.Selector = ucrSelecetorMonthlyTemp ucrReceiverMonthlyTemp.SetParameterIsString() + ucrReceiverMonthlyTemp.SetClimaticType("station") + ucrReceiverMonthlyTemp.bAutoFill = True ucrReceiverYearMonthly.SetParameter(New RParameter("year_col", 2)) ucrReceiverYearMonthly.Selector = ucrSelecetorMonthlyTemp ucrReceiverYearMonthly.SetParameterIsString() + ucrReceiverYearMonthly.SetClimaticType("year") + ucrReceiverYearMonthly.bAutoFill = True ucrReceiverMonthMonthly.SetParameter(New RParameter("month_col", 3)) ucrReceiverMonthMonthly.Selector = ucrSelecetorMonthlyTemp ucrReceiverMonthMonthly.SetParameterIsString() + ucrReceiverMonthMonthly.SetClimaticType("month") + ucrReceiverMonthMonthly.bAutoFill = True ucrReceiverMeanminMontly.SetParameter(New RParameter("mean_tmin_col", 4)) ucrReceiverMeanminMontly.Selector = ucrSelecetorMonthlyTemp From 4a1048799bc8a2d63d1b2e963fb9e86fe12d5870 Mon Sep 17 00:00:00 2001 From: Fidel365 <107605960+Fidel365@users.noreply.github.com> Date: Sat, 27 Jul 2024 05:09:46 +0300 Subject: [PATCH 06/13] data view changes --- instat/dlgCalculator.vb | 10 ++- instat/frmMain.Designer.vb | 112 +++++++++++++++++-------------- instat/frmMain.vb | 4 ++ instat/ucrCalculator.Designer.vb | 4 +- instat/ucrCalculator.vb | 2 +- instat/ucrDataView.Designer.vb | 30 ++++----- 6 files changed, 86 insertions(+), 76 deletions(-) diff --git a/instat/dlgCalculator.vb b/instat/dlgCalculator.vb index ad2f1dc9777..b12f61d9ae4 100644 --- a/instat/dlgCalculator.vb +++ b/instat/dlgCalculator.vb @@ -44,7 +44,7 @@ Public Class dlgCalculator SetDefaults() bFirstLoad = False End If - SetHelpOptions() + SetStructuredMenu() ReopenDialog() TestOKEnabled() autoTranslate(Me) @@ -75,7 +75,7 @@ Public Class dlgCalculator bInsertColumnBefore:=ucrBase.clsRsyntax.clsBaseCommandString.bInsertColumnBefore, bRequireCorrectLength:=ucrBase.clsRsyntax.clsBaseCommandString.bRequireCorrectLength) ucrBase.Visible = True - SetHelpOptions() + SetStructuredMenu() End Sub Private Sub ReopenDialog() @@ -261,10 +261,8 @@ Public Class dlgCalculator End If End Sub - Private Sub SetHelpOptions() + Private Sub SetStructuredMenu() Select Case enumCalculatorMode - Case CalculatorMode.Prepare - ucrBase.iHelpTopicID = 14 Case CalculatorMode.Structured ucrCalc.ucrInputCalOptions.SetName("Circular") ucrBase.iHelpTopicID = 677 @@ -324,7 +322,7 @@ Public Class dlgCalculator Case "Symbols" Me.Width = iBasicWidth * 2.56 Case "Goodness of Fit" - Me.Width = iBasicWidth * 1.27 + Me.Width = iBasicWidth * 1.25 ucrBase.iHelpTopicID = 717 Case "Integer" Me.Width = iBasicWidth * 1.5 diff --git a/instat/frmMain.Designer.vb b/instat/frmMain.Designer.vb index 949f21f824a..d5ee6c5c3fb 100644 --- a/instat/frmMain.Designer.vb +++ b/instat/frmMain.Designer.vb @@ -700,6 +700,7 @@ Partial Class frmMain Me.mnuDataFrameMetadata = New System.Windows.Forms.ToolStripMenuItem() Me.mnuScriptFile = New System.Windows.Forms.ToolStripMenuItem() Me.mnuLogFile = New System.Windows.Forms.ToolStripMenuItem() + Me.RInstatResourcesSiteToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.stsStrip.SuspendLayout() Me.Tool_strip.SuspendLayout() Me.mnuBar.SuspendLayout() @@ -1549,7 +1550,7 @@ Partial Class frmMain ' 'mnuHelp ' - Me.mnuHelp.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuHelpHelpIntroduction, Me.mnuHelpFAQ, Me.mnuHelpGetingStarted, Me.mnuHelpData, Me.ToolStripSeparator28, Me.mnuHelpWindows, Me.ToolStripSeparator81, Me.mnuHelpMenus, Me.mnuHelpAboutR, Me.mnuHelpLearningStatistics, Me.mnuHelpRPackages, Me.mnuHelpGlossary, Me.mnuHelpLicence, Me.ToolStripSeparator29, Me.mnuHelpPackagesDocumentation}) + Me.mnuHelp.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuHelpHelpIntroduction, Me.mnuHelpFAQ, Me.mnuHelpGetingStarted, Me.mnuHelpData, Me.ToolStripSeparator28, Me.mnuHelpWindows, Me.ToolStripSeparator81, Me.mnuHelpMenus, Me.mnuHelpAboutR, Me.mnuHelpLearningStatistics, Me.mnuHelpRPackages, Me.mnuHelpGlossary, Me.mnuHelpLicence, Me.ToolStripSeparator29, Me.RInstatResourcesSiteToolStripMenuItem, Me.mnuHelpPackagesDocumentation}) Me.mnuHelp.Name = "mnuHelp" Me.mnuHelp.Size = New System.Drawing.Size(44, 22) Me.mnuHelp.Tag = "Help" @@ -1599,90 +1600,90 @@ Partial Class frmMain ' Me.mnuHelpMenus.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.MenusAndDialogsToolStripMenuItem, Me.ToolStripSeparator82, Me.FileToolStripMenuItem, Me.EditToolStripMenuItem, Me.PrepareToolStripMenuItem, Me.DescribeToolStripMenuItem, Me.ModelToolStripMenuItem, Me.ToolStripSeparator83, Me.StructuredToolStripMenuItem, Me.ClimaticToolStripMenuItem, Me.ProcurementToolStripMenuItem, Me.ExperimentsToolStripMenuItem, Me.ToolsToolStripMenuItem, Me.ViewToolStripMenuItem}) Me.mnuHelpMenus.Name = "mnuHelpMenus" - Me.mnuHelpMenus.Size = New System.Drawing.Size(218, 22) + Me.mnuHelpMenus.Size = New System.Drawing.Size(230, 22) Me.mnuHelpMenus.Text = "Menus and Dialogs" ' 'MenusAndDialogsToolStripMenuItem ' Me.MenusAndDialogsToolStripMenuItem.Name = "MenusAndDialogsToolStripMenuItem" - Me.MenusAndDialogsToolStripMenuItem.Size = New System.Drawing.Size(175, 22) - Me.MenusAndDialogsToolStripMenuItem.Text = "Menus and Dialogs" + Me.MenusAndDialogsToolStripMenuItem.Size = New System.Drawing.Size(184, 22) + Me.MenusAndDialogsToolStripMenuItem.Text = "Menus and Dialogs..." ' 'ToolStripSeparator82 ' Me.ToolStripSeparator82.Name = "ToolStripSeparator82" - Me.ToolStripSeparator82.Size = New System.Drawing.Size(172, 6) + Me.ToolStripSeparator82.Size = New System.Drawing.Size(181, 6) ' 'FileToolStripMenuItem ' Me.FileToolStripMenuItem.Name = "FileToolStripMenuItem" - Me.FileToolStripMenuItem.Size = New System.Drawing.Size(175, 22) - Me.FileToolStripMenuItem.Text = "File" + Me.FileToolStripMenuItem.Size = New System.Drawing.Size(184, 22) + Me.FileToolStripMenuItem.Text = "File..." ' 'EditToolStripMenuItem ' Me.EditToolStripMenuItem.Name = "EditToolStripMenuItem" - Me.EditToolStripMenuItem.Size = New System.Drawing.Size(175, 22) - Me.EditToolStripMenuItem.Text = "Edit" + Me.EditToolStripMenuItem.Size = New System.Drawing.Size(184, 22) + Me.EditToolStripMenuItem.Text = "Edit..." ' 'PrepareToolStripMenuItem ' Me.PrepareToolStripMenuItem.Name = "PrepareToolStripMenuItem" - Me.PrepareToolStripMenuItem.Size = New System.Drawing.Size(175, 22) - Me.PrepareToolStripMenuItem.Text = "Prepare" + Me.PrepareToolStripMenuItem.Size = New System.Drawing.Size(184, 22) + Me.PrepareToolStripMenuItem.Text = "Prepare..." ' 'DescribeToolStripMenuItem ' Me.DescribeToolStripMenuItem.Name = "DescribeToolStripMenuItem" - Me.DescribeToolStripMenuItem.Size = New System.Drawing.Size(175, 22) - Me.DescribeToolStripMenuItem.Text = "Describe" + Me.DescribeToolStripMenuItem.Size = New System.Drawing.Size(184, 22) + Me.DescribeToolStripMenuItem.Text = "Describe..." ' 'ModelToolStripMenuItem ' Me.ModelToolStripMenuItem.Name = "ModelToolStripMenuItem" - Me.ModelToolStripMenuItem.Size = New System.Drawing.Size(175, 22) - Me.ModelToolStripMenuItem.Text = "Model" + Me.ModelToolStripMenuItem.Size = New System.Drawing.Size(184, 22) + Me.ModelToolStripMenuItem.Text = "Model..." ' 'ToolStripSeparator83 ' Me.ToolStripSeparator83.Name = "ToolStripSeparator83" - Me.ToolStripSeparator83.Size = New System.Drawing.Size(172, 6) + Me.ToolStripSeparator83.Size = New System.Drawing.Size(181, 6) ' 'StructuredToolStripMenuItem ' Me.StructuredToolStripMenuItem.Name = "StructuredToolStripMenuItem" - Me.StructuredToolStripMenuItem.Size = New System.Drawing.Size(175, 22) - Me.StructuredToolStripMenuItem.Text = "Structured" + Me.StructuredToolStripMenuItem.Size = New System.Drawing.Size(184, 22) + Me.StructuredToolStripMenuItem.Text = "Structured..." ' 'ClimaticToolStripMenuItem ' Me.ClimaticToolStripMenuItem.Name = "ClimaticToolStripMenuItem" - Me.ClimaticToolStripMenuItem.Size = New System.Drawing.Size(175, 22) - Me.ClimaticToolStripMenuItem.Text = "Climatic" + Me.ClimaticToolStripMenuItem.Size = New System.Drawing.Size(184, 22) + Me.ClimaticToolStripMenuItem.Text = "Climatic..." ' 'ProcurementToolStripMenuItem ' Me.ProcurementToolStripMenuItem.Name = "ProcurementToolStripMenuItem" - Me.ProcurementToolStripMenuItem.Size = New System.Drawing.Size(175, 22) - Me.ProcurementToolStripMenuItem.Text = "Procurement" + Me.ProcurementToolStripMenuItem.Size = New System.Drawing.Size(184, 22) + Me.ProcurementToolStripMenuItem.Text = "Procurement..." ' 'ExperimentsToolStripMenuItem ' Me.ExperimentsToolStripMenuItem.Name = "ExperimentsToolStripMenuItem" - Me.ExperimentsToolStripMenuItem.Size = New System.Drawing.Size(175, 22) - Me.ExperimentsToolStripMenuItem.Text = "Experiments" + Me.ExperimentsToolStripMenuItem.Size = New System.Drawing.Size(184, 22) + Me.ExperimentsToolStripMenuItem.Text = "Experiments..." ' 'ToolsToolStripMenuItem ' Me.ToolsToolStripMenuItem.Name = "ToolsToolStripMenuItem" - Me.ToolsToolStripMenuItem.Size = New System.Drawing.Size(175, 22) - Me.ToolsToolStripMenuItem.Text = "Tools" + Me.ToolsToolStripMenuItem.Size = New System.Drawing.Size(184, 22) + Me.ToolsToolStripMenuItem.Text = "Tools..." ' 'ViewToolStripMenuItem ' Me.ViewToolStripMenuItem.Name = "ViewToolStripMenuItem" - Me.ViewToolStripMenuItem.Size = New System.Drawing.Size(175, 22) - Me.ViewToolStripMenuItem.Text = "View" + Me.ViewToolStripMenuItem.Size = New System.Drawing.Size(184, 22) + Me.ViewToolStripMenuItem.Text = "View..." ' 'mnuHelpAboutR ' @@ -1725,8 +1726,8 @@ Partial Class frmMain 'mnuHelpPackagesDocumentation ' Me.mnuHelpPackagesDocumentation.Name = "mnuHelpPackagesDocumentation" - Me.mnuHelpPackagesDocumentation.Size = New System.Drawing.Size(218, 22) - Me.mnuHelpPackagesDocumentation.Text = "Packages Documentation..." + Me.mnuHelpPackagesDocumentation.Size = New System.Drawing.Size(230, 22) + Me.mnuHelpPackagesDocumentation.Text = "R-Packages Documentation..." ' 'ToolStripSeparator16 ' @@ -3523,7 +3524,7 @@ Partial Class frmMain ' Me.mnuPrepareDataFrame.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareDataFrameViewData, Me.mnuPrepareDataFrameRenameColumn, Me.mnuPrepareDataFrameDuplicateColumn, Me.mnuPrepareDataFrameRowNumbersNames, Me.ToolStripSeparator1, Me.mnuPrepareDataFrameSort, Me.mnuPrepareDataFrameFilterRows, Me.mnuPrepareDataFrameSelectColumns, Me.mnuPrepareDataFrameReplaceValues, Me.mnuPrepareDataFrameConvertColumns, Me.ToolStripSeparator2, Me.mnuPrepareDataFrameReorderColumns, Me.mnuPrepareDataFrameAddMergeColumns, Me.mnuPrepareDataFrameInsertColumnsRows, Me.mnuPrepareDataFrameDeleteColumnsRows, Me.mnuPrepareDataFrameProtectColumn, Me.mnuPrepareDataFrameFreezeColumns, Me.mnuPrepareDataframeColourByProperty}) Me.mnuPrepareDataFrame.Name = "mnuPrepareDataFrame" - Me.mnuPrepareDataFrame.Size = New System.Drawing.Size(180, 22) + Me.mnuPrepareDataFrame.Size = New System.Drawing.Size(169, 22) Me.mnuPrepareDataFrame.Tag = "Data_Frame" Me.mnuPrepareDataFrame.Text = "Data Frame" ' @@ -3654,7 +3655,7 @@ Partial Class frmMain Me.mnuPrepareCheckData.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right Me.mnuPrepareCheckData.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareCheckDataVisualiseData, Me.mnuPrepareCheckDataPivotTable, Me.ToolStripSeparator50, Me.mnuPrepareCheckDataDuplicates, Me.mnuPrepareCheckDataCompareColumns, Me.mnuPrepareCheckDataNonNumericCases, Me.ToolStripSeparator49, Me.mnuPrepareCheckDataBoxplot, Me.mnuPrepareCheckDataOneVariableSummarise, Me.mnuPrepareCheckDataOneVariableGraph, Me.mnuPrepareCheckDataOneWayFrequencies, Me.mnuPrepareCheckDataViewDeleteLabels, Me.ToolStripSeparator41, Me.mnuPrepareCheckDataExportOpenRefine, Me.mnuPrepareCheckDataImportOpenRefine, Me.ToolStripSeparator40, Me.mnuPreparePrepareToShareJitter, Me.mnuPrepareCheckDataPrePareToShareSdcPackage, Me.mnuPrepareCheckDataAnonymiseIDColumn}) Me.mnuPrepareCheckData.Name = "mnuPrepareCheckData" - Me.mnuPrepareCheckData.Size = New System.Drawing.Size(180, 22) + Me.mnuPrepareCheckData.Size = New System.Drawing.Size(169, 22) Me.mnuPrepareCheckData.Text = "Check Data" ' 'mnuPrepareCheckDataVisualiseData @@ -3775,25 +3776,25 @@ Partial Class frmMain 'ToolStripSeparator6 ' Me.ToolStripSeparator6.Name = "ToolStripSeparator6" - Me.ToolStripSeparator6.Size = New System.Drawing.Size(177, 6) + Me.ToolStripSeparator6.Size = New System.Drawing.Size(166, 6) ' 'mnuPrepareCalculator ' Me.mnuPrepareCalculator.Name = "mnuPrepareCalculator" - Me.mnuPrepareCalculator.Size = New System.Drawing.Size(180, 22) + Me.mnuPrepareCalculator.Size = New System.Drawing.Size(169, 22) Me.mnuPrepareCalculator.Tag = "Calculator..." Me.mnuPrepareCalculator.Text = "Calculator..." ' 'ToolStripSeparator79 ' Me.ToolStripSeparator79.Name = "ToolStripSeparator79" - Me.ToolStripSeparator79.Size = New System.Drawing.Size(177, 6) + Me.ToolStripSeparator79.Size = New System.Drawing.Size(166, 6) ' 'mnuPrepareColumnCalculate ' Me.mnuPrepareColumnCalculate.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareColumnNumericRegularSequence, Me.mnuPrepareColumnNumericEnter, Me.ToolStripSeparator25, Me.mnuPrepareColumnNumericRowSummaries, Me.mnuPrepareColumnNumericTransform, Me.mnuPrepareColumnNumericPolynomials, Me.ToolStripSeparator56, Me.mnuPrepareColumnNumericRandomSamples, Me.mnuPrepareColumnNumericPermuteRows}) Me.mnuPrepareColumnCalculate.Name = "mnuPrepareColumnCalculate" - Me.mnuPrepareColumnCalculate.Size = New System.Drawing.Size(180, 22) + Me.mnuPrepareColumnCalculate.Size = New System.Drawing.Size(169, 22) Me.mnuPrepareColumnCalculate.Tag = "Column:_Calculate" Me.mnuPrepareColumnCalculate.Text = "Column: Numeric" ' @@ -3858,7 +3859,7 @@ Partial Class frmMain ' Me.mnuPrepareColumnFactor.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareColumnFactorConvertToFactor, Me.mnuPrepareColumnFactorRecodeNumeric, Me.mnuPrepareColumnFactorCountInFactor, Me.ToolStripSeparator12, Me.mnuPrepareColumnFactorRecodeFactor, Me.mnuPrepareColumnFactorCombineFactors, Me.mnuPrepareColumnFactorDummyVariables, Me.ToolStripSeparator14, Me.mnuPrepareColumnFactorLevelsLabels, Me.mnuPrepareColumnFactorReorderLevels, Me.mnuPrepareColumnFactorReferenceLevel, Me.mnuPrepareColumnFactorUnusedLevels, Me.mnuPrepareColumnFactorContrasts, Me.ToolStripSeparator19, Me.mnuPrepareColumnFactorFactorDataFrame}) Me.mnuPrepareColumnFactor.Name = "mnuPrepareColumnFactor" - Me.mnuPrepareColumnFactor.Size = New System.Drawing.Size(180, 22) + Me.mnuPrepareColumnFactor.Size = New System.Drawing.Size(169, 22) Me.mnuPrepareColumnFactor.Tag = "Column:_Factor" Me.mnuPrepareColumnFactor.Text = "Column: Factor" ' @@ -3964,7 +3965,7 @@ Partial Class frmMain ' Me.mnuPrepareColumnText.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareColumnTextFindReplace, Me.mnuPrepareColumnTextSearch, Me.mnuPrepareColumnTextTransform, Me.mnuPrepareColumnTextSplit, Me.mnuPrepareColumnTextCombine, Me.mnuPrepareColumnTextMatch, Me.mnuPrepareColumnTextDistance}) Me.mnuPrepareColumnText.Name = "mnuPrepareColumnText" - Me.mnuPrepareColumnText.Size = New System.Drawing.Size(180, 22) + Me.mnuPrepareColumnText.Size = New System.Drawing.Size(169, 22) Me.mnuPrepareColumnText.Tag = "Column:_Text" Me.mnuPrepareColumnText.Text = "Column: Text" ' @@ -4023,7 +4024,7 @@ Partial Class frmMain ' Me.mnuPrepareColumnDate.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareColumnDateGenerateDate, Me.mnuPrepareColumnDateMakeDate, Me.mnuPrepareColumnDateInfillMissingDates, Me.mnuPrepareColumnDateUseDate, Me.mnuPrepareColumnDateMakeTime, Me.mnuPrepareColumnDateUseTime}) Me.mnuPrepareColumnDate.Name = "mnuPrepareColumnDate" - Me.mnuPrepareColumnDate.Size = New System.Drawing.Size(180, 22) + Me.mnuPrepareColumnDate.Size = New System.Drawing.Size(169, 22) Me.mnuPrepareColumnDate.Text = "Column: Date" ' 'mnuPrepareColumnDateGenerateDate @@ -4070,7 +4071,7 @@ Partial Class frmMain ' Me.mnuPrepareColumnDefine.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareColumnDefineConvertColumns, Me.ToolStripSeparator55, Me.mnuPrepareColumnDefineCircular}) Me.mnuPrepareColumnDefine.Name = "mnuPrepareColumnDefine" - Me.mnuPrepareColumnDefine.Size = New System.Drawing.Size(180, 22) + Me.mnuPrepareColumnDefine.Size = New System.Drawing.Size(169, 22) Me.mnuPrepareColumnDefine.Text = "Column: Define" ' 'mnuPrepareColumnDefineConvertColumns @@ -4093,13 +4094,13 @@ Partial Class frmMain 'ToolStripSeparator4 ' Me.ToolStripSeparator4.Name = "ToolStripSeparator4" - Me.ToolStripSeparator4.Size = New System.Drawing.Size(177, 6) + Me.ToolStripSeparator4.Size = New System.Drawing.Size(166, 6) ' 'mnuPrepareDataReshape ' Me.mnuPrepareDataReshape.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareColumnReshapeColumnSummaries, Me.mnuPrepareColumnReshapeGeneralSummaries, Me.ToolStripSeparator10, Me.mnuPrepareColumnReshapeStack, Me.mnuPrepareColumnReshapeUnstack, Me.mnuPrepareColumnReshapeMerge, Me.ToolStripSeparator11, Me.mnuPrepareAppendDataFrame, Me.mnuPrepareColumnReshapeSubset, Me.mnuPrepareColumnReshapeRandomSubset, Me.mnuPrepareColumnReshapeTranspose, Me.mnuPrepareDataReshapeScaleOrDistance, Me.mnuPrepareDataReshapeRandomSplit}) Me.mnuPrepareDataReshape.Name = "mnuPrepareDataReshape" - Me.mnuPrepareDataReshape.Size = New System.Drawing.Size(180, 22) + Me.mnuPrepareDataReshape.Size = New System.Drawing.Size(169, 22) Me.mnuPrepareDataReshape.Tag = "" Me.mnuPrepareDataReshape.Text = "Data Reshape" ' @@ -4189,13 +4190,13 @@ Partial Class frmMain 'ToolStripSeparator7 ' Me.ToolStripSeparator7.Name = "ToolStripSeparator7" - Me.ToolStripSeparator7.Size = New System.Drawing.Size(177, 6) + Me.ToolStripSeparator7.Size = New System.Drawing.Size(166, 6) ' 'mnuPrepareKeysAndLinks ' Me.mnuPrepareKeysAndLinks.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareKeysAndLinksAddKey, Me.mnuPrepareKeysAndLinksViewAndRemoveKey, Me.mnuPrepareKeysAndLinksAddLink, Me.mnuPrepareKeysAndLinksViewAndRemoveKeys, Me.mnuPrepareKeysAndLinksAddComment}) Me.mnuPrepareKeysAndLinks.Name = "mnuPrepareKeysAndLinks" - Me.mnuPrepareKeysAndLinks.Size = New System.Drawing.Size(180, 22) + Me.mnuPrepareKeysAndLinks.Size = New System.Drawing.Size(169, 22) Me.mnuPrepareKeysAndLinks.Text = "Keys and Links" ' 'mnuPrepareKeysAndLinksAddKey @@ -4232,7 +4233,7 @@ Partial Class frmMain ' Me.mnuPrepareDataBook.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareDataObjectDataFrameMetadata, Me.mnuPrepareDataObjectRenameDataFrame, Me.mnuPrepareDataObjectReorderDataFrames, Me.mnuPrepareDataObjectCopyDataFrame, Me.mnuPrepareDataObjectDeleteDataFrame, Me.ToolStripSeparator21, Me.mnuPrepareDataObjectHideDataframes, Me.mnuPrepareDataObjectMetadata, Me.mnuPrepareDataObjectRenameMetadata, Me.mnuPrepareDataObjectReorderMetadata, Me.mnuPrepareDataObjectDeleteMetadata}) Me.mnuPrepareDataBook.Name = "mnuPrepareDataBook" - Me.mnuPrepareDataBook.Size = New System.Drawing.Size(180, 22) + Me.mnuPrepareDataBook.Size = New System.Drawing.Size(169, 22) Me.mnuPrepareDataBook.Tag = "Data_Object" Me.mnuPrepareDataBook.Text = "Data Book" ' @@ -4322,7 +4323,7 @@ Partial Class frmMain ' Me.mnuPrepareRObjects.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareRObjectsView, Me.mnuPrepareRObjectsRename, Me.mnuPrepareRObjectsReorder, Me.mnuPrepareRObjectsDelete}) Me.mnuPrepareRObjects.Name = "mnuPrepareRObjects" - Me.mnuPrepareRObjects.Size = New System.Drawing.Size(180, 22) + Me.mnuPrepareRObjects.Size = New System.Drawing.Size(169, 22) Me.mnuPrepareRObjects.Tag = "R_Objects" Me.mnuPrepareRObjects.Text = "R Objects" ' @@ -4819,7 +4820,7 @@ Partial Class frmMain ' Me.mnuOptionsByContextCheckData.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuOptionsByContextCheckDataDuplicateRows, Me.mnuOptionsByContextCheckDataCompareColumns, Me.ToolStripSeparator47, Me.mnuOptionsByContextCheckDataOneVariableSummarise, Me.mnuOptionsByContextCheckDataOneVariableGraph, Me.mnuOptionsByContextCheckDataOneVariableFrequencies}) Me.mnuOptionsByContextCheckData.Name = "mnuOptionsByContextCheckData" - Me.mnuOptionsByContextCheckData.Size = New System.Drawing.Size(180, 22) + Me.mnuOptionsByContextCheckData.Size = New System.Drawing.Size(137, 22) Me.mnuOptionsByContextCheckData.Text = "Check Data" ' 'mnuOptionsByContextCheckDataDuplicateRows @@ -4861,7 +4862,7 @@ Partial Class frmMain ' Me.mnuOptionsByContextDefine.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuOptionsByContextDefineOnStation, Me.mnuOptionsByContextDefineOnFarm}) Me.mnuOptionsByContextDefine.Name = "mnuOptionsByContextDefine" - Me.mnuOptionsByContextDefine.Size = New System.Drawing.Size(180, 22) + Me.mnuOptionsByContextDefine.Size = New System.Drawing.Size(137, 22) Me.mnuOptionsByContextDefine.Text = "Define" ' 'mnuOptionsByContextDefineOnStation @@ -4880,7 +4881,7 @@ Partial Class frmMain ' Me.mnuOptionsByContextPrepare.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuOptionsByContextPrepareCalculateDIfferenceBetweenOptions, Me.ToolStripSeparator48, Me.mnuOptionsByContextMergeAdditionalData, Me.mnuOptionsByContextPrepareStack, Me.mnuOptionsByContextPrepareUnstack}) Me.mnuOptionsByContextPrepare.Name = "mnuOptionsByContextPrepare" - Me.mnuOptionsByContextPrepare.Size = New System.Drawing.Size(180, 22) + Me.mnuOptionsByContextPrepare.Size = New System.Drawing.Size(137, 22) Me.mnuOptionsByContextPrepare.Text = "Prepare" ' 'mnuOptionsByContextPrepareCalculateDIfferenceBetweenOptions @@ -4916,7 +4917,7 @@ Partial Class frmMain ' Me.mnuOptionsByContextDescribe.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuOptionsByContextDescribeCompareTwoTreatments, Me.mnuOptionsByContextDescribeCompareMultipleTreatments, Me.mnuOptionsByContextDescribeBoxplot}) Me.mnuOptionsByContextDescribe.Name = "mnuOptionsByContextDescribe" - Me.mnuOptionsByContextDescribe.Size = New System.Drawing.Size(180, 22) + Me.mnuOptionsByContextDescribe.Size = New System.Drawing.Size(137, 22) Me.mnuOptionsByContextDescribe.Text = "Describe" ' 'mnuOptionsByContextDescribeCompareTwoTreatments @@ -4942,7 +4943,7 @@ Partial Class frmMain ' Me.mnuOptionsByContextModel.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuOptionsByContextModelFitModel, Me.mnuOptionsByContextGeneralFitModel}) Me.mnuOptionsByContextModel.Name = "mnuOptionsByContextModel" - Me.mnuOptionsByContextModel.Size = New System.Drawing.Size(180, 22) + Me.mnuOptionsByContextModel.Size = New System.Drawing.Size(137, 22) Me.mnuOptionsByContextModel.Text = "Model" ' 'mnuOptionsByContextModelFitModel @@ -4961,7 +4962,7 @@ Partial Class frmMain ' Me.mnuOptionsByContextCropModel.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuOptionsByContextCropModelApsimxExamples}) Me.mnuOptionsByContextCropModel.Name = "mnuOptionsByContextCropModel" - Me.mnuOptionsByContextCropModel.Size = New System.Drawing.Size(180, 22) + Me.mnuOptionsByContextCropModel.Size = New System.Drawing.Size(137, 22) Me.mnuOptionsByContextCropModel.Text = "Crop Model" ' 'mnuOptionsByContextCropModelApsimxExamples @@ -5225,6 +5226,12 @@ Partial Class frmMain Me.mnuLogFile.Text = "Log Window..." Me.mnuLogFile.ToolTipText = "Log Window" ' + 'RInstatResourcesSiteToolStripMenuItem + ' + Me.RInstatResourcesSiteToolStripMenuItem.Name = "RInstatResourcesSiteToolStripMenuItem" + Me.RInstatResourcesSiteToolStripMenuItem.Size = New System.Drawing.Size(230, 22) + Me.RInstatResourcesSiteToolStripMenuItem.Text = "R-Instat Resources Site" + ' 'frmMain ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) @@ -5944,4 +5951,5 @@ Partial Class frmMain Friend WithEvents ViewToolStripMenuItem As ToolStripMenuItem Friend WithEvents mnuSwapDataLogScript As ToolStripMenuItem Friend WithEvents mnuSwapDataMetadata As ToolStripMenuItem + Friend WithEvents RInstatResourcesSiteToolStripMenuItem As ToolStripMenuItem End Class diff --git a/instat/frmMain.vb b/instat/frmMain.vb index ab2ebb686d0..5dcc43a4420 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -2843,4 +2843,8 @@ Public Class frmMain UpdateSwapDataAndScript() UpdateLayout() End Sub + + Private Sub RInstatResourcesSiteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RInstatResourcesSiteToolStripMenuItem.Click + Process.Start("https://ecampus.r-instat.org/course/view.php?id=14") + End Sub End Class diff --git a/instat/ucrCalculator.Designer.vb b/instat/ucrCalculator.Designer.vb index 53d3cf0f929..91563cf0e2c 100644 --- a/instat/ucrCalculator.Designer.vb +++ b/instat/ucrCalculator.Designer.vb @@ -764,7 +764,7 @@ Partial Class ucrCalculator Me.cmdClear.Location = New System.Drawing.Point(150, 72) Me.cmdClear.Margin = New System.Windows.Forms.Padding(2) Me.cmdClear.Name = "cmdClear" - Me.cmdClear.Size = New System.Drawing.Size(50, 58) + Me.cmdClear.Size = New System.Drawing.Size(50, 59) Me.cmdClear.TabIndex = 190 Me.cmdClear.Text = "Clear" Me.cmdClear.UseVisualStyleBackColor = True @@ -823,7 +823,7 @@ Partial Class ucrCalculator Me.cmdPlus.Location = New System.Drawing.Point(113, 101) Me.cmdPlus.Margin = New System.Windows.Forms.Padding(2) Me.cmdPlus.Name = "cmdPlus" - Me.cmdPlus.Size = New System.Drawing.Size(38, 29) + Me.cmdPlus.Size = New System.Drawing.Size(38, 30) Me.cmdPlus.TabIndex = 130 Me.cmdPlus.Text = "+" Me.cmdPlus.UseVisualStyleBackColor = True diff --git a/instat/ucrCalculator.vb b/instat/ucrCalculator.vb index 889c1529593..3c948ec3073 100644 --- a/instat/ucrCalculator.vb +++ b/instat/ucrCalculator.vb @@ -1047,7 +1047,7 @@ Public Class ucrCalculator grpList.Visible = False cmdRhelpList.Visible = False cmdRhelpFunctions.Visible = False - Me.Size = New Size(iBasicWidth * 1.27, iBaseHeight) + Me.Size = New Size(iBasicWidth * 1.25, iBaseHeight) Case "Integer" strPackageName = "gmp" grpFunctions.Visible = False diff --git a/instat/ucrDataView.Designer.vb b/instat/ucrDataView.Designer.vb index 98725d1c360..72b122e3328 100644 --- a/instat/ucrDataView.Designer.vb +++ b/instat/ucrDataView.Designer.vb @@ -684,7 +684,7 @@ Partial Class ucrDataView Me.panelSectionAdvanced.Controls.Add(Me.lblAdvanced) Me.panelSectionAdvanced.Controls.Add(Me.linkStartRestoreBackup) Me.panelSectionAdvanced.Controls.Add(Me.linkStartPasteScriptfromClipboard) - Me.panelSectionAdvanced.Location = New System.Drawing.Point(27, 410) + Me.panelSectionAdvanced.Location = New System.Drawing.Point(27, 412) Me.panelSectionAdvanced.Name = "panelSectionAdvanced" Me.panelSectionAdvanced.Size = New System.Drawing.Size(374, 83) Me.panelSectionAdvanced.TabIndex = 12 @@ -697,10 +697,10 @@ Partial Class ucrDataView Me.linkStartAddRPackage.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline Me.linkStartAddRPackage.Location = New System.Drawing.Point(5, 64) Me.linkStartAddRPackage.Name = "linkStartAddRPackage" - Me.linkStartAddRPackage.Size = New System.Drawing.Size(182, 13) + Me.linkStartAddRPackage.Size = New System.Drawing.Size(187, 13) Me.linkStartAddRPackage.TabIndex = 6 Me.linkStartAddRPackage.TabStop = True - Me.linkStartAddRPackage.Text = "Add R package to R-Instat... (Online)" + Me.linkStartAddRPackage.Text = "Add R Package To R-Instat... (Online)" ' 'lblAdvanced ' @@ -721,10 +721,10 @@ Partial Class ucrDataView Me.linkStartRestoreBackup.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline Me.linkStartRestoreBackup.Location = New System.Drawing.Point(5, 47) Me.linkStartRestoreBackup.Name = "linkStartRestoreBackup" - Me.linkStartRestoreBackup.Size = New System.Drawing.Size(142, 13) + Me.linkStartRestoreBackup.Size = New System.Drawing.Size(145, 13) Me.linkStartRestoreBackup.TabIndex = 4 Me.linkStartRestoreBackup.TabStop = True - Me.linkStartRestoreBackup.Text = "Restore Data from Backup..." + Me.linkStartRestoreBackup.Text = "Restore Data From Backup..." ' 'linkStartPasteScriptfromClipboard ' @@ -734,10 +734,10 @@ Partial Class ucrDataView Me.linkStartPasteScriptfromClipboard.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline Me.linkStartPasteScriptfromClipboard.Location = New System.Drawing.Point(5, 30) Me.linkStartPasteScriptfromClipboard.Name = "linkStartPasteScriptfromClipboard" - Me.linkStartPasteScriptfromClipboard.Size = New System.Drawing.Size(134, 13) + Me.linkStartPasteScriptfromClipboard.Size = New System.Drawing.Size(137, 13) Me.linkStartPasteScriptfromClipboard.TabIndex = 5 Me.linkStartPasteScriptfromClipboard.TabStop = True - Me.linkStartPasteScriptfromClipboard.Text = "Paste Script from Clipboard" + Me.linkStartPasteScriptfromClipboard.Text = "Paste Script From Clipboard" ' 'panelSectionHelp ' @@ -758,10 +758,10 @@ Partial Class ucrDataView Me.linkHelpData.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline Me.linkHelpData.Location = New System.Drawing.Point(5, 47) Me.linkHelpData.Name = "linkHelpData" - Me.linkHelpData.Size = New System.Drawing.Size(30, 13) + Me.linkHelpData.Size = New System.Drawing.Size(39, 13) Me.linkHelpData.TabIndex = 12 Me.linkHelpData.TabStop = True - Me.linkHelpData.Text = "Data" + Me.linkHelpData.Text = "Data..." ' 'linkHelpGettingStarted ' @@ -771,10 +771,10 @@ Partial Class ucrDataView Me.linkHelpGettingStarted.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline Me.linkHelpGettingStarted.Location = New System.Drawing.Point(5, 30) Me.linkHelpGettingStarted.Name = "linkHelpGettingStarted" - Me.linkHelpGettingStarted.Size = New System.Drawing.Size(78, 13) + Me.linkHelpGettingStarted.Size = New System.Drawing.Size(87, 13) Me.linkHelpGettingStarted.TabIndex = 11 Me.linkHelpGettingStarted.TabStop = True - Me.linkHelpGettingStarted.Text = "Getting Started" + Me.linkHelpGettingStarted.Text = "Getting Started..." ' 'lblHelp ' @@ -820,10 +820,10 @@ Partial Class ucrDataView Me.linkStartPasteData.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline Me.linkStartPasteData.Location = New System.Drawing.Point(5, 81) Me.linkStartPasteData.Name = "linkStartPasteData" - Me.linkStartPasteData.Size = New System.Drawing.Size(136, 13) + Me.linkStartPasteData.Size = New System.Drawing.Size(142, 13) Me.linkStartPasteData.TabIndex = 7 Me.linkStartPasteData.TabStop = True - Me.linkStartPasteData.Text = "Paste data from clipboard..." + Me.linkStartPasteData.Text = "Paste Data From Clipboard..." ' 'lblStart ' @@ -842,7 +842,7 @@ Partial Class ucrDataView Me.linkStartNewDataFrame.AutoSize = True Me.linkStartNewDataFrame.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.linkStartNewDataFrame.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline - Me.linkStartNewDataFrame.Location = New System.Drawing.Point(5, 47) + Me.linkStartNewDataFrame.Location = New System.Drawing.Point(5, 30) Me.linkStartNewDataFrame.Name = "linkStartNewDataFrame" Me.linkStartNewDataFrame.Size = New System.Drawing.Size(96, 13) Me.linkStartNewDataFrame.TabIndex = 3 @@ -855,7 +855,7 @@ Partial Class ucrDataView Me.linkStartOpenFile.AutoSize = True Me.linkStartOpenFile.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.linkStartOpenFile.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline - Me.linkStartOpenFile.Location = New System.Drawing.Point(5, 30) + Me.linkStartOpenFile.Location = New System.Drawing.Point(5, 47) Me.linkStartOpenFile.Name = "linkStartOpenFile" Me.linkStartOpenFile.Size = New System.Drawing.Size(90, 13) Me.linkStartOpenFile.TabIndex = 4 From 43744fb7df8443a5e95065c80d18bd9645eed9da Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Wed, 31 Jul 2024 13:16:04 +0100 Subject: [PATCH 07/13] Change made --- instat/static/InstatObject/R/data_object_R6.R | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 8ab9363348a..5444243e367 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -3292,13 +3292,8 @@ DataSheet$set("public","infill_missing_dates", function(date_name, factors, star col_names_exp[[i]] <- lazyeval::interp(~ var, var = as.name(col_name)) } all_factors <- self$get_columns_from_data(factors, use_current_filter = FALSE) - factor_combinations <- combn(names(all_factors), 2, simplify = FALSE) - for (combo in factor_combinations) { - factors_check <- all_factors[, combo] - if (nrow(unique(factors_check)) != nrow(unique(all_factors))) { - stop("Two factors are essentially the same variable.") - } - } + first_factor <- self$get_columns_from_data(factors[1], use_current_filter = FALSE) + if(dplyr::n_distinct(interaction(all_factors, drop = TRUE))!= dplyr::n_distinct(first_factor)) stop("The multiple factor variables are not in sync. Should have same number of levels.") grouped_data <- self$get_data_frame(use_current_filter = FALSE) %>% dplyr::group_by_(.dots = col_names_exp) date_ranges <- grouped_data %>% dplyr::summarise_(.dots = setNames(list(lazyeval::interp(~ min(var), var = as.name(date_name)), lazyeval::interp(~ max(var), var = as.name(date_name))), c("min_date", "max_date"))) date_lengths <- grouped_data %>% dplyr::summarise(count = n()) From 63baf2c0b13ce264e701365743b1923b3254d693 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Mon, 5 Aug 2024 13:06:46 +0300 Subject: [PATCH 08/13] more climsoft import changes --- .../static/InstatObject/R/instat_object_R6.R | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 78fe1743d8b..a72e46b36b8 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -1991,6 +1991,7 @@ DataBook$set("public", "import_climsoft_data", function(tableName, } sql_select <-paste0(sql_select,", ", tableName,".obsDatetime AS date_time") + sql_select <-paste0(sql_select,", DATE(", tableName,".obsDatetime) AS date") if(include_qc_log){ sql_select <-paste0(sql_select,", ", tableName,".qcTypeLog"," AS qc_log") @@ -2052,56 +2053,61 @@ DataBook$set("public", "import_climsoft_data", function(tableName, observations_data_name <- next_default_item("observations_data", self$get_data_names(), include_index = FALSE) data_list[[observations_data_name]] <- DBI::dbGetQuery(con,paste0(sql_select, sql_filter, sql_order_by)) - if(unstack_data){ - observations_unstacked_data_name <- next_default_item("observations_unstacked_data", self$get_data_names(), include_index = FALSE) - data_list[[observations_unstacked_data_name]] <- reshape2::dcast(data = data_list[[observations_data_name]], formula = station_name + date_time ~ element_abbrv, value.var = "value") - } + #-------------------------------- + # transform imported data + # -------------------------------- - self$import_data(data_tables = data_list) - #-------------------------------- + observations_df <- data_list[[observations_data_name]] - #transform imported data - #-------------------------------- - self$convert_column_to_type(data_name = observations_data_name, col_names = c("station_name","element_abbrv"), to_type = "factor") + # Convert station name and abbreviation columns to factor + mandatory_columns_to_convert <- c("station_name", "element_abbrv") + observations_df[mandatory_columns_to_convert] <- lapply(observations_df[mandatory_columns_to_convert], as.factor) + + # convert the date column to date format + observations_df$date <- as.Date(x = observations_df$date) + + # Convert the date_time column to POSIXct (date-time) format + observations_df$date_time <- as.POSIXct(observations_df$date_time, format = "%Y-%m-%d %H:%M:%S") if(include_station_id){ - self$convert_column_to_type(data_name = observations_data_name, col_names = "station_id", to_type = "factor") + observations_df$station_id <- as.factor(observations_df$station_id) } if(include_element_id){ - self$convert_column_to_type(data_name = observations_data_name, col_names = "element_id", to_type = "factor") + observations_df$element_id <- as.factor(observations_df$element_id) } if(include_element_name){ - self$convert_column_to_type(data_name = observations_data_name, col_names = "element_name", to_type = "factor") + observations_df$element_name <- as.factor(observations_df$element_name) } if(include_qc_status){ - self$convert_column_to_type(data_name = observations_data_name, col_names = "qc_status", to_type = "factor") + observations_df$qc_status <- as.factor(observations_df$qc_status) } if(include_acquisition_type){ - self$convert_column_to_type(data_name = observations_data_name, col_names = "acquisition_type", to_type = "factor") + observations_df$acquisition_type <- as.factor(observations_df$acquisition_type) } if(include_level){ - self$convert_column_to_type(data_name = observations_data_name, col_names = "level", to_type = "factor") + observations_df$level <- as.factor(observations_df$level) } if(include_flag){ - self$convert_column_to_type(data_name = observations_data_name, col_names = "flag", to_type = "factor") + observations_df$flag <- as.factor(observations_df$flag) } if(include_entry_form){ - self$convert_column_to_type(data_name = observations_data_name, col_names = "entry_form", to_type = "factor") + observations_df$entry_form <- as.factor(observations_df$entry_form) } - #todo. should this be done at this point?? Keeping in mind that we may have hourly data - #create a plain date column from the observation data datetime column values - #obsdate <- self$get_columns_from_data(data_name = observations_data_name, col_names = "date_time", use_current_filter = FALSE) - #self$add_columns_to_data(data_name = observations_data_name, col_name = "date", col_data = as.Date(x = obsdate), before = FALSE, adjacent_column = "date_time") - #-------------------------------- + if(unstack_data){ + observations_unstacked_data_name <- next_default_item("observations_unstacked_data", self$get_data_names(), include_index = FALSE) + data_list[[observations_unstacked_data_name]] <- tidyr::pivot_wider(data = observations_df, names_from=element_abbrv, values_from=value) + } + + self$import_data(data_tables = data_list) }) From 08c99057d6524d46b05901b993ce15b334301656 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 6 Aug 2024 09:02:54 +0300 Subject: [PATCH 09/13] made changes to import from climsoft R function --- .../static/InstatObject/R/instat_object_R6.R | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index a72e46b36b8..a9e604c7196 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2036,10 +2036,12 @@ DataBook$set("public", "import_climsoft_data", function(tableName, sql_order_by <- paste0(" ORDER BY ",tableName,".recordedFrom, ",tableName, ".describedBy, ",tableName, ".obsDatetime",";") #-------------------------------- - #import data - #-------------------------------- + # Data list to store all the imported data frames data_list <- list() + #import metadata + #-------------------------------- + if(import_selected_stations_metadata){ stations_metadata_name <- next_default_item("stations_metadata", self$get_data_names(), include_index = FALSE) data_list[[stations_metadata_name]] <- DBI::dbGetQuery(con, paste0("SELECT * FROM station WHERE", sql_stations_filter)) @@ -2050,26 +2052,25 @@ DataBook$set("public", "import_climsoft_data", function(tableName, data_list[[elements_metadata_name]] <- DBI::dbGetQuery(con, paste0("SELECT * FROM obselement WHERE", sql_elements_filter)) } - observations_data_name <- next_default_item("observations_data", self$get_data_names(), include_index = FALSE) - data_list[[observations_data_name]] <- DBI::dbGetQuery(con,paste0(sql_select, sql_filter, sql_order_by)) - - #-------------------------------- + #-------------------------------- - # transform imported data + # import and transform observations data data # -------------------------------- - observations_df <- data_list[[observations_data_name]] + # Get observations data from database + observations_df <- DBI::dbGetQuery(con, paste0(sql_select, sql_filter, sql_order_by)) # Convert station name and abbreviation columns to factor mandatory_columns_to_convert <- c("station_name", "element_abbrv") observations_df[mandatory_columns_to_convert] <- lapply(observations_df[mandatory_columns_to_convert], as.factor) - # convert the date column to date format - observations_df$date <- as.Date(x = observations_df$date) - # Convert the date_time column to POSIXct (date-time) format observations_df$date_time <- as.POSIXct(observations_df$date_time, format = "%Y-%m-%d %H:%M:%S") + # convert the date column to date format + observations_df$date <- as.Date(x = observations_df$date) + #observations_df$date <- as.Date(x = observations_df$date_time) + if(include_station_id){ observations_df$station_id <- as.factor(observations_df$station_id) } @@ -2102,11 +2103,19 @@ DataBook$set("public", "import_climsoft_data", function(tableName, observations_df$entry_form <- as.factor(observations_df$entry_form) } + #-------------------------------- + + # Add observations data to list of data to be imported + # -------------------------------- + observations_data_name <- next_default_item("observations_data", self$get_data_names(), include_index = FALSE) + data_list[[observations_data_name]] <- observations_df + if(unstack_data){ observations_unstacked_data_name <- next_default_item("observations_unstacked_data", self$get_data_names(), include_index = FALSE) data_list[[observations_unstacked_data_name]] <- tidyr::pivot_wider(data = observations_df, names_from=element_abbrv, values_from=value) } + # Import list of data frames to data book self$import_data(data_tables = data_list) }) From 0b1d5c0ec96f59ebd3b38f74404efcd13f1f5f93 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 6 Aug 2024 10:15:20 +0300 Subject: [PATCH 10/13] added region fields and removed error in importing metadata --- .../static/InstatObject/R/instat_object_R6.R | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index a9e604c7196..d0e1538e90d 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -1881,40 +1881,38 @@ DataBook$set("public", "import_climsoft_metadata", function(import_stations = FA data_list <- list() if(import_stations){ - stations_metadata_name <- next_default_item("stations_metadata", self$get_data_names(), include_index = FALSE) - #todo.(22/03/2023) 2 fields have been intentionally left out because they are yet to be released to Climsoft users. Namely; wsi and gtsWSI - #include them once the new Climsoft release has been supplied to users - data_list[[stations_metadata_name]] <- DBI::dbGetQuery(con, "SELECT stationId AS station_id, stationName AS station_name, wmoid, icaoid, latitude, longitude, elevation, qualifier, geoLocationMethod AS geo_location_method, geoLocationAccuracy AS geo_location_accuracy, openingDatetime AS opening_date_time, closingDatetime AS closing_date_time, authority, adminRegion AS admin_region, drainageBasin AS drainage_basin, wacaSelection AS waca_selection, cptSelection AS cpt_selection, stationOperational AS station_Operational, country AS country FROM station;") + # TODO.(22/03/2023) 2 fields have been intentionally left out because they are yet to be released to Climsoft users. Namely; wsi and gtsWSI + # include them once the new Climsoft release has been supplied to users + stations_df <- DBI::dbGetQuery(con, "SELECT stationId AS station_id, stationName AS station_name, wmoid, icaoid, latitude, longitude, elevation, qualifier, geoLocationMethod AS geo_location_method, geoLocationAccuracy AS geo_location_accuracy, openingDatetime AS opening_date_time, closingDatetime AS closing_date_time, wacaSelection AS waca_selection, cptSelection AS cpt_selection, stationOperational AS station_operational, drainageBasin AS drainage_basin, country AS country, authority, adminRegion AS admin_region_1, adminRegion2 AS admin_region_2, adminRegion3 AS admin_region_3, adminRegion4 AS admin_region_4 FROM station;") + + columns_to_convert <- c("station_id","station_name","qualifier", "station_operational", "drainage_basin", "country", "authority", "admin_region_1", "admin_region_2", "admin_region_3", "admin_region_4") + stations_df[columns_to_convert] <- lapply(stations_df[columns_to_convert], as.factor) + + stations_df_name <- next_default_item("stations_metadata", self$get_data_names(), include_index = FALSE) + data_list[[stations_df_name]] <- stations_df } if(import_elements){ - elements_metadata_name <- next_default_item("elements_metadata", self$get_data_names(), include_index = FALSE) - data_list[[elements_metadata_name]] <- DBI::dbGetQuery(con, "SELECT elementId AS element_id, elementName AS element_name, abbreviation, description, elementtype AS element_type, upperLimit AS upper_limit , lowerLimit AS lower_limit, units FROM obselement;") + elements_df <- DBI::dbGetQuery(con, "SELECT elementId AS element_id, elementName AS element_name, abbreviation, description, elementtype AS element_type, upperLimit AS upper_limit , lowerLimit AS lower_limit, units FROM obselement;") + + columns_to_convert <- c("element_id","element_name","abbreviation","element_type") + elements_df[columns_to_convert] <- lapply(elements_df[columns_to_convert], as.factor) + + elements_df_name <- next_default_item("elements_metadata", self$get_data_names(), include_index = FALSE) + data_list[[elements_df_name]] <- elements_df } if(import_flags){ - flags_metadata_name <- next_default_item("flags_metadata", self$get_data_names(), include_index = FALSE) - data_list[[flags_metadata_name]] <- DBI::dbGetQuery(con, "SELECT characterSymbol AS flag_name, description FROM flags;") + flags_df <- DBI::dbGetQuery(con, "SELECT characterSymbol AS flag_name, description FROM flags;") + + flags_df$flag_name <- as.factor(flags_df$flag_name) + flags_df_name <- next_default_item("flags_metadata", self$get_data_names(), include_index = FALSE) + data_list[[flags_df_name]] <- flags_df } + # Import the data frames into the data book self$import_data(data_tables = data_list) - #-------------------------------- - - #transform imported metadata - #-------------------------------- - if(import_stations){ - self$convert_column_to_type(data_name = stations_metadata_name, col_names = c("station_id","station_name","qualifier","authority","admin_region","drainage_basin","station_Operational","country"), to_type = "factor") - } - - if(import_elements){ - self$convert_column_to_type(data_name = elements_metadata_name, col_names = c("element_id","element_name","abbreviation","element_type"), to_type = "factor") - } - - if(import_flags){ - self$convert_column_to_type(data_name = flags_metadata_name, col_names = c("flag_name"), to_type = "factor") - } - #-------------------------------- }) @@ -2061,8 +2059,8 @@ DataBook$set("public", "import_climsoft_data", function(tableName, observations_df <- DBI::dbGetQuery(con, paste0(sql_select, sql_filter, sql_order_by)) # Convert station name and abbreviation columns to factor - mandatory_columns_to_convert <- c("station_name", "element_abbrv") - observations_df[mandatory_columns_to_convert] <- lapply(observations_df[mandatory_columns_to_convert], as.factor) + columns_to_convert <- c("station_name", "element_abbrv") + observations_df[columns_to_convert] <- lapply(observations_df[columns_to_convert], as.factor) # Convert the date_time column to POSIXct (date-time) format observations_df$date_time <- as.POSIXct(observations_df$date_time, format = "%Y-%m-%d %H:%M:%S") From a331ce366c59b3ceb6004608923d3b5d4468fb13 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 6 Aug 2024 15:20:31 +0300 Subject: [PATCH 11/13] made station id compulsory --- instat/sdgClimsoft.Designer.vb | 86 +++++++++---------- instat/sdgClimsoft.vb | 8 +- .../static/InstatObject/R/instat_object_R6.R | 18 +--- 3 files changed, 49 insertions(+), 63 deletions(-) diff --git a/instat/sdgClimsoft.Designer.vb b/instat/sdgClimsoft.Designer.vb index 66902102eb5..a615738425c 100644 --- a/instat/sdgClimsoft.Designer.vb +++ b/instat/sdgClimsoft.Designer.vb @@ -28,6 +28,10 @@ Partial Class sdgClimsoft Me.ucrChkImportStationsMetadata = New instat.ucrCheck() Me.tbColumns = New System.Windows.Forms.TabPage() Me.grpColumnsToInclude = New System.Windows.Forms.GroupBox() + Me.ucrChkIncludeElementName = New instat.ucrCheck() + Me.ucrChkIncludeDateTime = New instat.ucrCheck() + Me.ucrChkIncludeElementId = New instat.ucrCheck() + Me.ucrChkIncludeStationId = New instat.ucrCheck() Me.ucrChkIncludeQCLog = New instat.ucrCheck() Me.ucrChkIncludeCapturedBy = New instat.ucrCheck() Me.ucrChkIncludeQCStatus = New instat.ucrCheck() @@ -39,10 +43,6 @@ Partial Class sdgClimsoft Me.ucrChkIncludeFlag = New instat.ucrCheck() Me.tbpMoreOptions = New System.Windows.Forms.TabControl() Me.ucrBaseSubdialog = New instat.ucrButtonsSubdialogue() - Me.ucrChkIncludeElementId = New instat.ucrCheck() - Me.ucrChkIncludeStationId = New instat.ucrCheck() - Me.ucrChkIncludeDateTime = New instat.ucrCheck() - Me.ucrChkIncludeElementName = New instat.ucrCheck() Me.tbpTitles.SuspendLayout() Me.grpMetadataToImport.SuspendLayout() Me.tbColumns.SuspendLayout() @@ -56,7 +56,7 @@ Partial Class sdgClimsoft Me.tbpTitles.Location = New System.Drawing.Point(4, 22) Me.tbpTitles.Name = "tbpTitles" Me.tbpTitles.Padding = New System.Windows.Forms.Padding(3) - Me.tbpTitles.Size = New System.Drawing.Size(409, 303) + Me.tbpTitles.Size = New System.Drawing.Size(409, 367) Me.tbpTitles.TabIndex = 2 Me.tbpTitles.Tag = "" Me.tbpTitles.Text = "Metadata" @@ -125,6 +125,42 @@ Partial Class sdgClimsoft Me.grpColumnsToInclude.TabStop = False Me.grpColumnsToInclude.Text = "Columns to Include" ' + 'ucrChkIncludeElementName + ' + Me.ucrChkIncludeElementName.AutoSize = True + Me.ucrChkIncludeElementName.Checked = False + Me.ucrChkIncludeElementName.Location = New System.Drawing.Point(7, 141) + Me.ucrChkIncludeElementName.Name = "ucrChkIncludeElementName" + Me.ucrChkIncludeElementName.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeElementName.TabIndex = 25 + ' + 'ucrChkIncludeDateTime + ' + Me.ucrChkIncludeDateTime.AutoSize = True + Me.ucrChkIncludeDateTime.Checked = True + Me.ucrChkIncludeDateTime.Location = New System.Drawing.Point(7, 89) + Me.ucrChkIncludeDateTime.Name = "ucrChkIncludeDateTime" + Me.ucrChkIncludeDateTime.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeDateTime.TabIndex = 24 + ' + 'ucrChkIncludeElementId + ' + Me.ucrChkIncludeElementId.AutoSize = True + Me.ucrChkIncludeElementId.Checked = False + Me.ucrChkIncludeElementId.Location = New System.Drawing.Point(7, 116) + Me.ucrChkIncludeElementId.Name = "ucrChkIncludeElementId" + Me.ucrChkIncludeElementId.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeElementId.TabIndex = 23 + ' + 'ucrChkIncludeStationId + ' + Me.ucrChkIncludeStationId.AutoSize = True + Me.ucrChkIncludeStationId.Checked = True + Me.ucrChkIncludeStationId.Location = New System.Drawing.Point(7, 19) + Me.ucrChkIncludeStationId.Name = "ucrChkIncludeStationId" + Me.ucrChkIncludeStationId.Size = New System.Drawing.Size(295, 23) + Me.ucrChkIncludeStationId.TabIndex = 22 + ' 'ucrChkIncludeQCLog ' Me.ucrChkIncludeQCLog.AutoSize = True @@ -165,7 +201,7 @@ Partial Class sdgClimsoft ' Me.ucrChkIncludeElementAbbrv.AutoSize = True Me.ucrChkIncludeElementAbbrv.Checked = True - Me.ucrChkIncludeElementAbbrv.Location = New System.Drawing.Point(6, 42) + Me.ucrChkIncludeElementAbbrv.Location = New System.Drawing.Point(6, 65) Me.ucrChkIncludeElementAbbrv.Name = "ucrChkIncludeElementAbbrv" Me.ucrChkIncludeElementAbbrv.Size = New System.Drawing.Size(295, 23) Me.ucrChkIncludeElementAbbrv.TabIndex = 18 @@ -174,7 +210,7 @@ Partial Class sdgClimsoft ' Me.ucrChkIncludeStationName.AutoSize = True Me.ucrChkIncludeStationName.Checked = True - Me.ucrChkIncludeStationName.Location = New System.Drawing.Point(6, 20) + Me.ucrChkIncludeStationName.Location = New System.Drawing.Point(6, 43) Me.ucrChkIncludeStationName.Name = "ucrChkIncludeStationName" Me.ucrChkIncludeStationName.Size = New System.Drawing.Size(295, 23) Me.ucrChkIncludeStationName.TabIndex = 17 @@ -224,42 +260,6 @@ Partial Class sdgClimsoft Me.ucrBaseSubdialog.Size = New System.Drawing.Size(224, 29) Me.ucrBaseSubdialog.TabIndex = 3 ' - 'ucrChkIncludeElementId - ' - Me.ucrChkIncludeElementId.AutoSize = True - Me.ucrChkIncludeElementId.Checked = False - Me.ucrChkIncludeElementId.Location = New System.Drawing.Point(7, 116) - Me.ucrChkIncludeElementId.Name = "ucrChkIncludeElementId" - Me.ucrChkIncludeElementId.Size = New System.Drawing.Size(295, 23) - Me.ucrChkIncludeElementId.TabIndex = 23 - ' - 'ucrChkIncludeStationId - ' - Me.ucrChkIncludeStationId.AutoSize = True - Me.ucrChkIncludeStationId.Checked = False - Me.ucrChkIncludeStationId.Location = New System.Drawing.Point(7, 92) - Me.ucrChkIncludeStationId.Name = "ucrChkIncludeStationId" - Me.ucrChkIncludeStationId.Size = New System.Drawing.Size(295, 23) - Me.ucrChkIncludeStationId.TabIndex = 22 - ' - 'ucrChkIncludeDateTime - ' - Me.ucrChkIncludeDateTime.AutoSize = True - Me.ucrChkIncludeDateTime.Checked = True - Me.ucrChkIncludeDateTime.Location = New System.Drawing.Point(7, 66) - Me.ucrChkIncludeDateTime.Name = "ucrChkIncludeDateTime" - Me.ucrChkIncludeDateTime.Size = New System.Drawing.Size(295, 23) - Me.ucrChkIncludeDateTime.TabIndex = 24 - ' - 'ucrChkIncludeElementName - ' - Me.ucrChkIncludeElementName.AutoSize = True - Me.ucrChkIncludeElementName.Checked = False - Me.ucrChkIncludeElementName.Location = New System.Drawing.Point(7, 141) - Me.ucrChkIncludeElementName.Name = "ucrChkIncludeElementName" - Me.ucrChkIncludeElementName.Size = New System.Drawing.Size(295, 23) - Me.ucrChkIncludeElementName.TabIndex = 25 - ' 'sdgClimsoft ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) diff --git a/instat/sdgClimsoft.vb b/instat/sdgClimsoft.vb index c1a48427aa3..e23c63a5b8f 100644 --- a/instat/sdgClimsoft.vb +++ b/instat/sdgClimsoft.vb @@ -30,6 +30,9 @@ Public Class sdgClimsoft 'Columns to include '--------------------------------------- + ucrChkIncludeStationId.SetText("Station Id") + ucrChkIncludeStationId.Enabled = False + ucrChkIncludeStationName.SetText("Station Name") ucrChkIncludeStationName.Enabled = False @@ -39,10 +42,6 @@ Public Class sdgClimsoft ucrChkIncludeDateTime.SetText("Date Time") ucrChkIncludeDateTime.Enabled = False - ucrChkIncludeStationId.SetText("Station Id") - ucrChkIncludeStationId.SetParameter(New RParameter("include_station_id", 13)) - ucrChkIncludeStationId.SetRDefault("FALSE") - ucrChkIncludeElementId.SetText("Element Id") ucrChkIncludeElementId.SetParameter(New RParameter("include_element_id", 14)) ucrChkIncludeElementId.SetRDefault("FALSE") @@ -102,7 +101,6 @@ Public Class sdgClimsoft 'Columns '--------------------------------------- - ucrChkIncludeStationId.SetRCode(clsRFunction, bReset) ucrChkIncludeElementId.SetRCode(clsRFunction, bReset) ucrChkIncludeElementName.SetRCode(clsRFunction, bReset) ucrChkIncludeAquistion.SetRCode(clsRFunction, bReset) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index d0e1538e90d..ee580e5519a 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -1922,7 +1922,7 @@ DataBook$set("public", "import_climsoft_data", function(tableName, station_filter_column, stations = c(), element_filter_column, elements = c(), qc_status = -1, start_date = NULL, end_date = NULL, unstack_data = FALSE, - include_station_id = FALSE, include_element_id = FALSE, include_element_name = FALSE, + include_element_id = FALSE, include_element_name = FALSE, include_acquisition_type = FALSE, include_level = FALSE, include_entry_form = FALSE, include_captured_by = FALSE, include_qc_status = FALSE, include_qc_log = FALSE, include_flag = FALSE, import_selected_stations_metadata = FALSE, import_selected_elements_metadata = FALSE) { @@ -1949,14 +1949,7 @@ DataBook$set("public", "import_climsoft_data", function(tableName, #selects #-------------------------------- - sql_select<- "" - - if(include_station_id){ - sql_select <- paste0(tableName,".recordedFrom AS station_id") - sql_select <-paste0(sql_select,", station.stationName AS station_name") - }else{ - sql_select <-"station.stationName AS station_name" - } + sql_select<- paste0(tableName,".recordedFrom AS station_id",", station.stationName AS station_name") if(include_element_id){ sql_select <-paste0(sql_select, ", ", tableName,".describedBy AS element_id") @@ -2059,7 +2052,7 @@ DataBook$set("public", "import_climsoft_data", function(tableName, observations_df <- DBI::dbGetQuery(con, paste0(sql_select, sql_filter, sql_order_by)) # Convert station name and abbreviation columns to factor - columns_to_convert <- c("station_name", "element_abbrv") + columns_to_convert <- c("station_id", "station_name", "element_abbrv") observations_df[columns_to_convert] <- lapply(observations_df[columns_to_convert], as.factor) # Convert the date_time column to POSIXct (date-time) format @@ -2067,11 +2060,6 @@ DataBook$set("public", "import_climsoft_data", function(tableName, # convert the date column to date format observations_df$date <- as.Date(x = observations_df$date) - #observations_df$date <- as.Date(x = observations_df$date_time) - - if(include_station_id){ - observations_df$station_id <- as.factor(observations_df$station_id) - } if(include_element_id){ observations_df$element_id <- as.factor(observations_df$element_id) From df6561f72f1b171fadcfda3389873b3ae9fcd945 Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:37:35 +0200 Subject: [PATCH 12/13] Added the Option of Loading and Saving Json Files in the R script window --- instat/ucrScript.vb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/instat/ucrScript.vb b/instat/ucrScript.vb index ebfb3d73b3e..8f1cad6613d 100644 --- a/instat/ucrScript.vb +++ b/instat/ucrScript.vb @@ -214,12 +214,10 @@ Public Class ucrScript Using dlgSave As New SaveFileDialog dlgSave.Title = "Save " & If(bIsLog, "Log", "Script") & " To File" - dlgSave.Filter = "R Script File (*.R)|*.R|Text File (*.txt)|*.txt" + dlgSave.Filter = "R Script File (*.R)|*.R|Text File (*.txt)|*.txt|JSON File (*.json)|*.json" dlgSave.FileName = Path.GetFileName(TabControl.SelectedTab.Text) - 'Ensure that dialog opens in correct folder. - 'In theory, we should be able to use `dlgLoad.RestoreDirectory = True` but this does - 'not work (I think a bug in WinForms).So we need to use static variables instead. + ' Ensure that dialog opens in the correct folder. Static strInitialDirectory As String = frmMain.clsInstatOptions.strWorkingDirectory Static strInitialDirectoryLog As String = frmMain.clsInstatOptions.strWorkingDirectory dlgSave.InitialDirectory = If(bIsLog, strInitialDirectoryLog, strInitialDirectory) @@ -232,6 +230,7 @@ Public Class ucrScript TabControl.SelectedTab.Text = System.IO.Path.GetFileNameWithoutExtension(dlgSave.FileName) frmMain.clsRecentItems.addToMenu(Replace(Path.Combine(Path.GetFullPath(strInitialDirectory), System.IO.Path.GetFileName(dlgSave.FileName)), "\", "/")) frmMain.bDataSaved = True + If bIsLog Then strInitialDirectoryLog = Path.GetDirectoryName(dlgSave.FileName) Else @@ -239,8 +238,8 @@ Public Class ucrScript End If Catch MsgBox("Could not save the " & If(bIsLog, "Log", "Script") & " file." & Environment.NewLine & - "The file may be in use by another program or you may not have access to write to the specified location.", - vbExclamation, "Save " & If(bIsLog, "Log", "Script")) + "The file may be in use by another program or you may not have access to write to the specified location.", + vbExclamation, "Save " & If(bIsLog, "Log", "Script")) End Try End If End Using @@ -530,9 +529,9 @@ Public Class ucrScript Using dlgLoad As New OpenFileDialog dlgLoad.Title = "Load Script From Text File" - dlgLoad.Filter = "Text & R Script Files (*.txt,*.R)|*.txt;*.R|R Script File (*.R)|*.R|Text File (*.txt)|*.txt" + dlgLoad.Filter = "Text & R Script Files (*.txt, *.R, *.json)|*.txt;*.R;*.json|R Script File (*.R)|*.R|Text File (*.txt)|*.txt|JSON File (*.json)|*.json" - 'Ensure that dialog opens in correct folder. + ' Ensure that dialog opens in the correct folder. 'In theory, we should be able to use `dlgLoad.RestoreDirectory = True` but this does 'not work (I think a bug in WinForms).So we need to use a static variable instead. Static strInitialDirectory As String = frmMain.clsInstatOptions.strWorkingDirectory From ffc8089c7497974957c76c533e8326686dd4082a Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Thu, 8 Aug 2024 13:43:38 +0300 Subject: [PATCH 13/13] changes to the code --- .../dlgExportClimaticDefinitions.Designer.vb | 699 ++++++++++++------ instat/dlgExportClimaticDefinitions.vb | 190 ++++- 2 files changed, 610 insertions(+), 279 deletions(-) diff --git a/instat/dlgExportClimaticDefinitions.Designer.vb b/instat/dlgExportClimaticDefinitions.Designer.vb index d29ab990892..a699e015eac 100644 --- a/instat/dlgExportClimaticDefinitions.Designer.vb +++ b/instat/dlgExportClimaticDefinitions.Designer.vb @@ -22,21 +22,31 @@ Partial Class dlgExportClimaticDefinitions 'Do not modify it using the code editor. _ Private Sub InitializeComponent() + Me.ucrReceiverYear = New instat.ucrReceiverSingle() + Me.lblExport = New System.Windows.Forms.Label() + Me.cmdChooseFile = New System.Windows.Forms.Button() + Me.ucrInputTokenPath = New instat.ucrInputTextBox() + Me.rdoUploadSummaries = New System.Windows.Forms.RadioButton() + Me.rdoUpdateMetadata = New System.Windows.Forms.RadioButton() + Me.ucrPnlExportGoogle = New instat.UcrPanel() + Me.ucrReceiverStation = New instat.ucrReceiverSingle() + Me.lblDefinitionsID = New System.Windows.Forms.Label() + Me.ucrInputDefinitionsID = New instat.ucrInputTextBox() + Me.cmdDefine = New System.Windows.Forms.Button() Me.lblStation = New System.Windows.Forms.Label() Me.lblCountry = New System.Windows.Forms.Label() Me.ucrInputCountry = New instat.ucrInputTextBox() - Me.ucrChkSeasonStartProp = New instat.ucrCheck() - Me.ucrChkExtremes = New instat.ucrCheck() - Me.ucrChkCropSuccessProp = New instat.ucrCheck() - Me.ucrChkAnnualTemp = New instat.ucrCheck() - Me.ucrChkAnnualRainfall = New instat.ucrCheck() Me.lblMonth = New System.Windows.Forms.Label() Me.lblYear = New System.Windows.Forms.Label() Me.ucrReceiverMonth = New instat.ucrReceiverSingle() - Me.ucrReceiverYear = New instat.ucrReceiverSingle() Me.ucrChkIncludeSummaryData = New instat.ucrCheck() Me.grpSummaries = New System.Windows.Forms.GroupBox() Me.ucrChkMonthlyTemp = New instat.ucrCheck() + Me.ucrChkSeasonStartProp = New instat.ucrCheck() + Me.ucrChkExtremes = New instat.ucrCheck() + Me.ucrChkCropSuccessProp = New instat.ucrCheck() + Me.ucrChkAnnualTemp = New instat.ucrCheck() + Me.ucrChkAnnualRainfall = New instat.ucrCheck() Me.lblCropData = New System.Windows.Forms.Label() Me.lblDataByYearMonth = New System.Windows.Forms.Label() Me.lblDataByYear = New System.Windows.Forms.Label() @@ -47,34 +57,167 @@ Partial Class dlgExportClimaticDefinitions Me.ucrReceiverDataYear = New instat.ucrReceiverSingle() Me.ucrReceiverDataYearMonth = New instat.ucrReceiverSingle() Me.ucrReceiverCropData = New instat.ucrReceiverSingle() - Me.lblExport = New System.Windows.Forms.Label() - Me.cmdChooseFile = New System.Windows.Forms.Button() - Me.ucrInputTokenPath = New instat.ucrInputTextBox() - Me.cmdDefine = New System.Windows.Forms.Button() - Me.lblDefinitionsID = New System.Windows.Forms.Label() - Me.ucrInputDefinitionsID = New instat.ucrInputTextBox() - Me.ucrReceiverStation = New instat.ucrReceiverSingle() + Me.lblDistrict = New System.Windows.Forms.Label() + Me.lblElavation = New System.Windows.Forms.Label() + Me.lblLatitude = New System.Windows.Forms.Label() + Me.lblLongitude = New System.Windows.Forms.Label() + Me.ucrReceiverLongititude = New instat.ucrReceiverSingle() + Me.ucrReceiverLatitude = New instat.ucrReceiverSingle() + Me.ucrReceiverElavation = New instat.ucrReceiverSingle() + Me.ucrReceiverDistrict = New instat.ucrReceiverSingle() + Me.ucrReceiverStationName = New instat.ucrReceiverSingle() + Me.lblStationName = New System.Windows.Forms.Label() + Me.lblCountryMetada = New System.Windows.Forms.Label() + Me.ucrInputCountryMetadata = New instat.ucrInputTextBox() Me.grpSummaries.SuspendLayout() Me.SuspendLayout() ' + 'ucrReceiverYear + ' + Me.ucrReceiverYear.AutoSize = True + Me.ucrReceiverYear.frmParent = Me + Me.ucrReceiverYear.Location = New System.Drawing.Point(330, 126) + Me.ucrReceiverYear.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverYear.Name = "ucrReceiverYear" + Me.ucrReceiverYear.Selector = Nothing + Me.ucrReceiverYear.Size = New System.Drawing.Size(120, 20) + Me.ucrReceiverYear.strNcFilePath = "" + Me.ucrReceiverYear.TabIndex = 52 + Me.ucrReceiverYear.ucrSelector = Nothing + ' + 'lblExport + ' + Me.lblExport.AutoSize = True + Me.lblExport.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblExport.Location = New System.Drawing.Point(64, 46) + Me.lblExport.Name = "lblExport" + Me.lblExport.Size = New System.Drawing.Size(41, 13) + Me.lblExport.TabIndex = 81 + Me.lblExport.Text = "Token:" + ' + 'cmdChooseFile + ' + Me.cmdChooseFile.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.cmdChooseFile.Location = New System.Drawing.Point(311, 40) + Me.cmdChooseFile.Name = "cmdChooseFile" + Me.cmdChooseFile.Size = New System.Drawing.Size(80, 23) + Me.cmdChooseFile.TabIndex = 83 + Me.cmdChooseFile.Text = "Browse" + Me.cmdChooseFile.UseVisualStyleBackColor = True + ' + 'ucrInputTokenPath + ' + Me.ucrInputTokenPath.AddQuotesIfUnrecognised = True + Me.ucrInputTokenPath.AutoSize = True + Me.ucrInputTokenPath.IsMultiline = False + Me.ucrInputTokenPath.IsReadOnly = False + Me.ucrInputTokenPath.Location = New System.Drawing.Point(111, 43) + Me.ucrInputTokenPath.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) + Me.ucrInputTokenPath.Name = "ucrInputTokenPath" + Me.ucrInputTokenPath.Size = New System.Drawing.Size(191, 21) + Me.ucrInputTokenPath.TabIndex = 82 + ' + 'rdoUploadSummaries + ' + Me.rdoUploadSummaries.Appearance = System.Windows.Forms.Appearance.Button + Me.rdoUploadSummaries.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoUploadSummaries.FlatAppearance.BorderSize = 2 + Me.rdoUploadSummaries.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoUploadSummaries.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.rdoUploadSummaries.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.rdoUploadSummaries.Location = New System.Drawing.Point(227, 7) + Me.rdoUploadSummaries.Name = "rdoUploadSummaries" + Me.rdoUploadSummaries.Size = New System.Drawing.Size(122, 27) + Me.rdoUploadSummaries.TabIndex = 47 + Me.rdoUploadSummaries.Text = "Upload Summaries" + Me.rdoUploadSummaries.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + Me.rdoUploadSummaries.UseVisualStyleBackColor = True + ' + 'rdoUpdateMetadata + ' + Me.rdoUpdateMetadata.Appearance = System.Windows.Forms.Appearance.Button + Me.rdoUpdateMetadata.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoUpdateMetadata.FlatAppearance.BorderSize = 2 + Me.rdoUpdateMetadata.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoUpdateMetadata.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.rdoUpdateMetadata.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.rdoUpdateMetadata.Location = New System.Drawing.Point(114, 7) + Me.rdoUpdateMetadata.Name = "rdoUpdateMetadata" + Me.rdoUpdateMetadata.Size = New System.Drawing.Size(116, 27) + Me.rdoUpdateMetadata.TabIndex = 46 + Me.rdoUpdateMetadata.Text = "Update Metadata" + Me.rdoUpdateMetadata.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + Me.rdoUpdateMetadata.UseVisualStyleBackColor = True + ' + 'ucrPnlExportGoogle + ' + Me.ucrPnlExportGoogle.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrPnlExportGoogle.Location = New System.Drawing.Point(111, 2) + Me.ucrPnlExportGoogle.Margin = New System.Windows.Forms.Padding(6) + Me.ucrPnlExportGoogle.Name = "ucrPnlExportGoogle" + Me.ucrPnlExportGoogle.Size = New System.Drawing.Size(249, 33) + Me.ucrPnlExportGoogle.TabIndex = 45 + ' + 'ucrReceiverStation + ' + Me.ucrReceiverStation.AutoSize = True + Me.ucrReceiverStation.frmParent = Me + Me.ucrReceiverStation.Location = New System.Drawing.Point(330, 92) + Me.ucrReceiverStation.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverStation.Name = "ucrReceiverStation" + Me.ucrReceiverStation.Selector = Nothing + Me.ucrReceiverStation.Size = New System.Drawing.Size(120, 20) + Me.ucrReceiverStation.strNcFilePath = "" + Me.ucrReceiverStation.TabIndex = 50 + Me.ucrReceiverStation.ucrSelector = Nothing + ' + 'lblDefinitionsID + ' + Me.lblDefinitionsID.AutoSize = True + Me.lblDefinitionsID.Location = New System.Drawing.Point(335, 344) + Me.lblDefinitionsID.Name = "lblDefinitionsID" + Me.lblDefinitionsID.Size = New System.Drawing.Size(73, 13) + Me.lblDefinitionsID.TabIndex = 63 + Me.lblDefinitionsID.Text = "Definitions ID:" + ' + 'ucrInputDefinitionsID + ' + Me.ucrInputDefinitionsID.AddQuotesIfUnrecognised = True + Me.ucrInputDefinitionsID.AutoSize = True + Me.ucrInputDefinitionsID.IsMultiline = False + Me.ucrInputDefinitionsID.IsReadOnly = False + Me.ucrInputDefinitionsID.Location = New System.Drawing.Point(331, 359) + Me.ucrInputDefinitionsID.Margin = New System.Windows.Forms.Padding(9) + Me.ucrInputDefinitionsID.Name = "ucrInputDefinitionsID" + Me.ucrInputDefinitionsID.Size = New System.Drawing.Size(118, 21) + Me.ucrInputDefinitionsID.TabIndex = 64 + ' + 'cmdDefine + ' + Me.cmdDefine.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.cmdDefine.Location = New System.Drawing.Point(223, 397) + Me.cmdDefine.Name = "cmdDefine" + Me.cmdDefine.Size = New System.Drawing.Size(80, 29) + Me.cmdDefine.TabIndex = 69 + Me.cmdDefine.Text = "Define" + Me.cmdDefine.UseVisualStyleBackColor = True + ' 'lblStation ' Me.lblStation.AutoSize = True - Me.lblStation.Location = New System.Drawing.Point(498, 25) - Me.lblStation.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) + Me.lblStation.Location = New System.Drawing.Point(330, 79) Me.lblStation.Name = "lblStation" - Me.lblStation.Size = New System.Drawing.Size(64, 20) - Me.lblStation.TabIndex = 1 + Me.lblStation.Size = New System.Drawing.Size(43, 13) + Me.lblStation.TabIndex = 49 Me.lblStation.Text = "Station:" ' 'lblCountry ' Me.lblCountry.AutoSize = True - Me.lblCountry.Location = New System.Drawing.Point(498, 492) - Me.lblCountry.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) + Me.lblCountry.Location = New System.Drawing.Point(330, 384) Me.lblCountry.Name = "lblCountry" - Me.lblCountry.Size = New System.Drawing.Size(68, 20) - Me.lblCountry.TabIndex = 17 + Me.lblCountry.Size = New System.Drawing.Size(46, 13) + Me.lblCountry.TabIndex = 65 Me.lblCountry.Text = "Country:" ' 'ucrInputCountry @@ -83,118 +226,52 @@ Partial Class dlgExportClimaticDefinitions Me.ucrInputCountry.AutoSize = True Me.ucrInputCountry.IsMultiline = False Me.ucrInputCountry.IsReadOnly = False - Me.ucrInputCountry.Location = New System.Drawing.Point(498, 517) - Me.ucrInputCountry.Margin = New System.Windows.Forms.Padding(14) + Me.ucrInputCountry.Location = New System.Drawing.Point(330, 400) + Me.ucrInputCountry.Margin = New System.Windows.Forms.Padding(9) Me.ucrInputCountry.Name = "ucrInputCountry" - Me.ucrInputCountry.Size = New System.Drawing.Size(177, 32) - Me.ucrInputCountry.TabIndex = 18 - ' - 'ucrChkSeasonStartProp - ' - Me.ucrChkSeasonStartProp.AutoSize = True - Me.ucrChkSeasonStartProp.Checked = False - Me.ucrChkSeasonStartProp.Location = New System.Drawing.Point(236, 71) - Me.ucrChkSeasonStartProp.Margin = New System.Windows.Forms.Padding(9) - Me.ucrChkSeasonStartProp.Name = "ucrChkSeasonStartProp" - Me.ucrChkSeasonStartProp.Size = New System.Drawing.Size(226, 52) - Me.ucrChkSeasonStartProp.TabIndex = 3 - ' - 'ucrChkExtremes - ' - Me.ucrChkExtremes.AutoSize = True - Me.ucrChkExtremes.Checked = False - Me.ucrChkExtremes.Location = New System.Drawing.Point(236, 120) - Me.ucrChkExtremes.Margin = New System.Windows.Forms.Padding(9) - Me.ucrChkExtremes.Name = "ucrChkExtremes" - Me.ucrChkExtremes.Size = New System.Drawing.Size(220, 52) - Me.ucrChkExtremes.TabIndex = 5 - Me.ucrChkExtremes.Visible = False - ' - 'ucrChkCropSuccessProp - ' - Me.ucrChkCropSuccessProp.AutoSize = True - Me.ucrChkCropSuccessProp.Checked = False - Me.ucrChkCropSuccessProp.Location = New System.Drawing.Point(236, 28) - Me.ucrChkCropSuccessProp.Margin = New System.Windows.Forms.Padding(9) - Me.ucrChkCropSuccessProp.Name = "ucrChkCropSuccessProp" - Me.ucrChkCropSuccessProp.Size = New System.Drawing.Size(230, 52) - Me.ucrChkCropSuccessProp.TabIndex = 1 - ' - 'ucrChkAnnualTemp - ' - Me.ucrChkAnnualTemp.AutoSize = True - Me.ucrChkAnnualTemp.Checked = False - Me.ucrChkAnnualTemp.Location = New System.Drawing.Point(12, 71) - Me.ucrChkAnnualTemp.Margin = New System.Windows.Forms.Padding(9) - Me.ucrChkAnnualTemp.Name = "ucrChkAnnualTemp" - Me.ucrChkAnnualTemp.Size = New System.Drawing.Size(224, 52) - Me.ucrChkAnnualTemp.TabIndex = 2 - ' - 'ucrChkAnnualRainfall - ' - Me.ucrChkAnnualRainfall.AutoSize = True - Me.ucrChkAnnualRainfall.Checked = False - Me.ucrChkAnnualRainfall.Location = New System.Drawing.Point(12, 28) - Me.ucrChkAnnualRainfall.Margin = New System.Windows.Forms.Padding(9) - Me.ucrChkAnnualRainfall.Name = "ucrChkAnnualRainfall" - Me.ucrChkAnnualRainfall.Size = New System.Drawing.Size(224, 52) - Me.ucrChkAnnualRainfall.TabIndex = 0 + Me.ucrInputCountry.Size = New System.Drawing.Size(118, 21) + Me.ucrInputCountry.TabIndex = 66 ' 'lblMonth ' Me.lblMonth.AutoSize = True - Me.lblMonth.Location = New System.Drawing.Point(498, 136) - Me.lblMonth.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) + Me.lblMonth.Location = New System.Drawing.Point(330, 151) Me.lblMonth.Name = "lblMonth" - Me.lblMonth.Size = New System.Drawing.Size(58, 20) - Me.lblMonth.TabIndex = 5 + Me.lblMonth.Size = New System.Drawing.Size(40, 13) + Me.lblMonth.TabIndex = 53 Me.lblMonth.Text = "Month:" ' 'lblYear ' Me.lblYear.AutoSize = True - Me.lblYear.Location = New System.Drawing.Point(498, 75) - Me.lblYear.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) + Me.lblYear.Location = New System.Drawing.Point(330, 111) Me.lblYear.Name = "lblYear" - Me.lblYear.Size = New System.Drawing.Size(47, 20) - Me.lblYear.TabIndex = 3 + Me.lblYear.Size = New System.Drawing.Size(32, 13) + Me.lblYear.TabIndex = 51 Me.lblYear.Text = "Year:" ' 'ucrReceiverMonth ' Me.ucrReceiverMonth.AutoSize = True Me.ucrReceiverMonth.frmParent = Me - Me.ucrReceiverMonth.Location = New System.Drawing.Point(498, 161) + Me.ucrReceiverMonth.Location = New System.Drawing.Point(330, 167) Me.ucrReceiverMonth.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverMonth.Name = "ucrReceiverMonth" Me.ucrReceiverMonth.Selector = Nothing - Me.ucrReceiverMonth.Size = New System.Drawing.Size(180, 31) + Me.ucrReceiverMonth.Size = New System.Drawing.Size(120, 20) Me.ucrReceiverMonth.strNcFilePath = "" - Me.ucrReceiverMonth.TabIndex = 6 + Me.ucrReceiverMonth.TabIndex = 54 Me.ucrReceiverMonth.ucrSelector = Nothing ' - 'ucrReceiverYear - ' - Me.ucrReceiverYear.AutoSize = True - Me.ucrReceiverYear.frmParent = Me - Me.ucrReceiverYear.Location = New System.Drawing.Point(498, 100) - Me.ucrReceiverYear.Margin = New System.Windows.Forms.Padding(0) - Me.ucrReceiverYear.Name = "ucrReceiverYear" - Me.ucrReceiverYear.Selector = Nothing - Me.ucrReceiverYear.Size = New System.Drawing.Size(180, 31) - Me.ucrReceiverYear.strNcFilePath = "" - Me.ucrReceiverYear.TabIndex = 4 - Me.ucrReceiverYear.ucrSelector = Nothing - ' 'ucrChkIncludeSummaryData ' Me.ucrChkIncludeSummaryData.AutoSize = True Me.ucrChkIncludeSummaryData.Checked = False - Me.ucrChkIncludeSummaryData.Location = New System.Drawing.Point(6, 513) - Me.ucrChkIncludeSummaryData.Margin = New System.Windows.Forms.Padding(9) + Me.ucrChkIncludeSummaryData.Location = New System.Drawing.Point(2, 398) + Me.ucrChkIncludeSummaryData.Margin = New System.Windows.Forms.Padding(6) Me.ucrChkIncludeSummaryData.Name = "ucrChkIncludeSummaryData" - Me.ucrChkIncludeSummaryData.Size = New System.Drawing.Size(332, 48) - Me.ucrChkIncludeSummaryData.TabIndex = 20 + Me.ucrChkIncludeSummaryData.Size = New System.Drawing.Size(221, 31) + Me.ucrChkIncludeSummaryData.TabIndex = 68 ' 'grpSummaries ' @@ -204,12 +281,10 @@ Partial Class dlgExportClimaticDefinitions Me.grpSummaries.Controls.Add(Me.ucrChkCropSuccessProp) Me.grpSummaries.Controls.Add(Me.ucrChkAnnualTemp) Me.grpSummaries.Controls.Add(Me.ucrChkAnnualRainfall) - Me.grpSummaries.Location = New System.Drawing.Point(6, 325) - Me.grpSummaries.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) + Me.grpSummaries.Location = New System.Drawing.Point(2, 264) Me.grpSummaries.Name = "grpSummaries" - Me.grpSummaries.Padding = New System.Windows.Forms.Padding(4, 5, 4, 5) - Me.grpSummaries.Size = New System.Drawing.Size(470, 177) - Me.grpSummaries.TabIndex = 19 + Me.grpSummaries.Size = New System.Drawing.Size(313, 116) + Me.grpSummaries.TabIndex = 67 Me.grpSummaries.TabStop = False Me.grpSummaries.Text = "Summaries" ' @@ -217,63 +292,110 @@ Partial Class dlgExportClimaticDefinitions ' Me.ucrChkMonthlyTemp.AutoSize = True Me.ucrChkMonthlyTemp.Checked = False - Me.ucrChkMonthlyTemp.Location = New System.Drawing.Point(12, 120) - Me.ucrChkMonthlyTemp.Margin = New System.Windows.Forms.Padding(9) + Me.ucrChkMonthlyTemp.Location = New System.Drawing.Point(8, 77) + Me.ucrChkMonthlyTemp.Margin = New System.Windows.Forms.Padding(6) Me.ucrChkMonthlyTemp.Name = "ucrChkMonthlyTemp" - Me.ucrChkMonthlyTemp.Size = New System.Drawing.Size(220, 52) + Me.ucrChkMonthlyTemp.Size = New System.Drawing.Size(147, 34) Me.ucrChkMonthlyTemp.TabIndex = 4 ' + 'ucrChkSeasonStartProp + ' + Me.ucrChkSeasonStartProp.AutoSize = True + Me.ucrChkSeasonStartProp.Checked = False + Me.ucrChkSeasonStartProp.Location = New System.Drawing.Point(157, 44) + Me.ucrChkSeasonStartProp.Margin = New System.Windows.Forms.Padding(6) + Me.ucrChkSeasonStartProp.Name = "ucrChkSeasonStartProp" + Me.ucrChkSeasonStartProp.Size = New System.Drawing.Size(151, 34) + Me.ucrChkSeasonStartProp.TabIndex = 3 + ' + 'ucrChkExtremes + ' + Me.ucrChkExtremes.AutoSize = True + Me.ucrChkExtremes.Checked = False + Me.ucrChkExtremes.Location = New System.Drawing.Point(157, 77) + Me.ucrChkExtremes.Margin = New System.Windows.Forms.Padding(6) + Me.ucrChkExtremes.Name = "ucrChkExtremes" + Me.ucrChkExtremes.Size = New System.Drawing.Size(147, 34) + Me.ucrChkExtremes.TabIndex = 5 + Me.ucrChkExtremes.Visible = False + ' + 'ucrChkCropSuccessProp + ' + Me.ucrChkCropSuccessProp.AutoSize = True + Me.ucrChkCropSuccessProp.Checked = False + Me.ucrChkCropSuccessProp.Location = New System.Drawing.Point(157, 13) + Me.ucrChkCropSuccessProp.Margin = New System.Windows.Forms.Padding(6) + Me.ucrChkCropSuccessProp.Name = "ucrChkCropSuccessProp" + Me.ucrChkCropSuccessProp.Size = New System.Drawing.Size(153, 34) + Me.ucrChkCropSuccessProp.TabIndex = 1 + ' + 'ucrChkAnnualTemp + ' + Me.ucrChkAnnualTemp.AutoSize = True + Me.ucrChkAnnualTemp.Checked = False + Me.ucrChkAnnualTemp.Location = New System.Drawing.Point(8, 45) + Me.ucrChkAnnualTemp.Margin = New System.Windows.Forms.Padding(6) + Me.ucrChkAnnualTemp.Name = "ucrChkAnnualTemp" + Me.ucrChkAnnualTemp.Size = New System.Drawing.Size(149, 34) + Me.ucrChkAnnualTemp.TabIndex = 2 + ' + 'ucrChkAnnualRainfall + ' + Me.ucrChkAnnualRainfall.AutoSize = True + Me.ucrChkAnnualRainfall.Checked = False + Me.ucrChkAnnualRainfall.Location = New System.Drawing.Point(8, 13) + Me.ucrChkAnnualRainfall.Margin = New System.Windows.Forms.Padding(6) + Me.ucrChkAnnualRainfall.Name = "ucrChkAnnualRainfall" + Me.ucrChkAnnualRainfall.Size = New System.Drawing.Size(149, 34) + Me.ucrChkAnnualRainfall.TabIndex = 0 + ' 'lblCropData ' Me.lblCropData.AutoSize = True - Me.lblCropData.Location = New System.Drawing.Point(498, 376) - Me.lblCropData.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) + Me.lblCropData.Location = New System.Drawing.Point(330, 307) Me.lblCropData.Name = "lblCropData" - Me.lblCropData.Size = New System.Drawing.Size(86, 20) - Me.lblCropData.TabIndex = 13 + Me.lblCropData.Size = New System.Drawing.Size(58, 13) + Me.lblCropData.TabIndex = 61 Me.lblCropData.Text = "Crop Data:" ' 'lblDataByYearMonth ' Me.lblDataByYearMonth.AutoSize = True - Me.lblDataByYearMonth.Location = New System.Drawing.Point(498, 315) - Me.lblDataByYearMonth.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) + Me.lblDataByYearMonth.Location = New System.Drawing.Point(330, 267) Me.lblDataByYearMonth.Name = "lblDataByYearMonth" - Me.lblDataByYearMonth.Size = New System.Drawing.Size(188, 20) - Me.lblDataByYearMonth.TabIndex = 11 + Me.lblDataByYearMonth.Size = New System.Drawing.Size(127, 13) + Me.lblDataByYearMonth.TabIndex = 59 Me.lblDataByYearMonth.Text = "Data By Year and Month:" ' 'lblDataByYear ' Me.lblDataByYear.AutoSize = True - Me.lblDataByYear.Location = New System.Drawing.Point(498, 254) - Me.lblDataByYear.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) + Me.lblDataByYear.Location = New System.Drawing.Point(330, 227) Me.lblDataByYear.Name = "lblDataByYear" - Me.lblDataByYear.Size = New System.Drawing.Size(108, 20) - Me.lblDataByYear.TabIndex = 9 + Me.lblDataByYear.Size = New System.Drawing.Size(73, 13) + Me.lblDataByYear.TabIndex = 57 Me.lblDataByYear.Text = "Data By Year:" ' 'lblRain ' Me.lblRain.AutoSize = True - Me.lblRain.Location = New System.Drawing.Point(498, 198) - Me.lblRain.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) + Me.lblRain.Location = New System.Drawing.Point(330, 191) Me.lblRain.Name = "lblRain" - Me.lblRain.Size = New System.Drawing.Size(46, 20) - Me.lblRain.TabIndex = 7 + Me.lblRain.Size = New System.Drawing.Size(32, 13) + Me.lblRain.TabIndex = 55 Me.lblRain.Text = "Rain:" ' 'ucrReceiverRain ' Me.ucrReceiverRain.AutoSize = True Me.ucrReceiverRain.frmParent = Me - Me.ucrReceiverRain.Location = New System.Drawing.Point(498, 223) + Me.ucrReceiverRain.Location = New System.Drawing.Point(330, 207) Me.ucrReceiverRain.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverRain.Name = "ucrReceiverRain" Me.ucrReceiverRain.Selector = Nothing - Me.ucrReceiverRain.Size = New System.Drawing.Size(180, 31) + Me.ucrReceiverRain.Size = New System.Drawing.Size(120, 20) Me.ucrReceiverRain.strNcFilePath = "" - Me.ucrReceiverRain.TabIndex = 8 + Me.ucrReceiverRain.TabIndex = 56 Me.ucrReceiverRain.ucrSelector = Nothing ' 'ucrSelectorExportDefinitions @@ -282,160 +404,219 @@ Partial Class dlgExportClimaticDefinitions Me.ucrSelectorExportDefinitions.bDropUnusedFilterLevels = False Me.ucrSelectorExportDefinitions.bShowHiddenColumns = False Me.ucrSelectorExportDefinitions.bUseCurrentFilter = True - Me.ucrSelectorExportDefinitions.Location = New System.Drawing.Point(6, 12) + Me.ucrSelectorExportDefinitions.Location = New System.Drawing.Point(2, 78) Me.ucrSelectorExportDefinitions.Margin = New System.Windows.Forms.Padding(0) Me.ucrSelectorExportDefinitions.Name = "ucrSelectorExportDefinitions" - Me.ucrSelectorExportDefinitions.Size = New System.Drawing.Size(320, 282) - Me.ucrSelectorExportDefinitions.TabIndex = 0 + Me.ucrSelectorExportDefinitions.Size = New System.Drawing.Size(213, 183) + Me.ucrSelectorExportDefinitions.TabIndex = 48 ' 'ucrBase ' Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(6, 622) - Me.ucrBase.Margin = New System.Windows.Forms.Padding(6) + Me.ucrBase.Location = New System.Drawing.Point(2, 438) + Me.ucrBase.Margin = New System.Windows.Forms.Padding(4) Me.ucrBase.Name = "ucrBase" - Me.ucrBase.Size = New System.Drawing.Size(615, 92) - Me.ucrBase.TabIndex = 25 + Me.ucrBase.Size = New System.Drawing.Size(410, 60) + Me.ucrBase.TabIndex = 70 ' 'ucrReceiverDataYear ' Me.ucrReceiverDataYear.AutoSize = True Me.ucrReceiverDataYear.frmParent = Me - Me.ucrReceiverDataYear.Location = New System.Drawing.Point(498, 279) + Me.ucrReceiverDataYear.Location = New System.Drawing.Point(330, 244) Me.ucrReceiverDataYear.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverDataYear.Name = "ucrReceiverDataYear" Me.ucrReceiverDataYear.Selector = Nothing - Me.ucrReceiverDataYear.Size = New System.Drawing.Size(180, 31) + Me.ucrReceiverDataYear.Size = New System.Drawing.Size(120, 20) Me.ucrReceiverDataYear.strNcFilePath = "" - Me.ucrReceiverDataYear.TabIndex = 10 + Me.ucrReceiverDataYear.TabIndex = 58 Me.ucrReceiverDataYear.ucrSelector = Nothing ' 'ucrReceiverDataYearMonth ' Me.ucrReceiverDataYearMonth.AutoSize = True Me.ucrReceiverDataYearMonth.frmParent = Me - Me.ucrReceiverDataYearMonth.Location = New System.Drawing.Point(498, 340) + Me.ucrReceiverDataYearMonth.Location = New System.Drawing.Point(330, 283) Me.ucrReceiverDataYearMonth.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverDataYearMonth.Name = "ucrReceiverDataYearMonth" Me.ucrReceiverDataYearMonth.Selector = Nothing - Me.ucrReceiverDataYearMonth.Size = New System.Drawing.Size(180, 31) + Me.ucrReceiverDataYearMonth.Size = New System.Drawing.Size(120, 20) Me.ucrReceiverDataYearMonth.strNcFilePath = "" - Me.ucrReceiverDataYearMonth.TabIndex = 12 + Me.ucrReceiverDataYearMonth.TabIndex = 60 Me.ucrReceiverDataYearMonth.ucrSelector = Nothing ' 'ucrReceiverCropData ' Me.ucrReceiverCropData.AutoSize = True Me.ucrReceiverCropData.frmParent = Me - Me.ucrReceiverCropData.Location = New System.Drawing.Point(498, 401) + Me.ucrReceiverCropData.Location = New System.Drawing.Point(330, 323) Me.ucrReceiverCropData.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverCropData.Name = "ucrReceiverCropData" Me.ucrReceiverCropData.Selector = Nothing - Me.ucrReceiverCropData.Size = New System.Drawing.Size(180, 31) + Me.ucrReceiverCropData.Size = New System.Drawing.Size(120, 20) Me.ucrReceiverCropData.strNcFilePath = "" - Me.ucrReceiverCropData.TabIndex = 14 + Me.ucrReceiverCropData.TabIndex = 62 Me.ucrReceiverCropData.ucrSelector = Nothing ' - 'lblExport - ' - Me.lblExport.AutoSize = True - Me.lblExport.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblExport.Location = New System.Drawing.Point(14, 579) - Me.lblExport.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) - Me.lblExport.Name = "lblExport" - Me.lblExport.Size = New System.Drawing.Size(57, 20) - Me.lblExport.TabIndex = 22 - Me.lblExport.Text = "Token:" - ' - 'cmdChooseFile - ' - Me.cmdChooseFile.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.cmdChooseFile.Location = New System.Drawing.Point(384, 571) - Me.cmdChooseFile.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) - Me.cmdChooseFile.Name = "cmdChooseFile" - Me.cmdChooseFile.Size = New System.Drawing.Size(120, 35) - Me.cmdChooseFile.TabIndex = 24 - Me.cmdChooseFile.Text = "Browse" - Me.cmdChooseFile.UseVisualStyleBackColor = True - ' - 'ucrInputTokenPath - ' - Me.ucrInputTokenPath.AddQuotesIfUnrecognised = True - Me.ucrInputTokenPath.AutoSize = True - Me.ucrInputTokenPath.IsMultiline = False - Me.ucrInputTokenPath.IsReadOnly = False - Me.ucrInputTokenPath.Location = New System.Drawing.Point(84, 575) - Me.ucrInputTokenPath.Margin = New System.Windows.Forms.Padding(9, 12, 9, 12) - Me.ucrInputTokenPath.Name = "ucrInputTokenPath" - Me.ucrInputTokenPath.Size = New System.Drawing.Size(287, 32) - Me.ucrInputTokenPath.TabIndex = 23 - ' - 'cmdDefine - ' - Me.cmdDefine.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.cmdDefine.Location = New System.Drawing.Point(338, 512) - Me.cmdDefine.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) - Me.cmdDefine.Name = "cmdDefine" - Me.cmdDefine.Size = New System.Drawing.Size(120, 45) - Me.cmdDefine.TabIndex = 21 - Me.cmdDefine.Text = "Define" - Me.cmdDefine.UseVisualStyleBackColor = True - ' - 'lblDefinitionsID - ' - Me.lblDefinitionsID.AutoSize = True - Me.lblDefinitionsID.Location = New System.Drawing.Point(505, 433) - Me.lblDefinitionsID.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) - Me.lblDefinitionsID.Name = "lblDefinitionsID" - Me.lblDefinitionsID.Size = New System.Drawing.Size(109, 20) - Me.lblDefinitionsID.TabIndex = 15 - Me.lblDefinitionsID.Text = "Definitions ID:" - ' - 'ucrInputDefinitionsID - ' - Me.ucrInputDefinitionsID.AddQuotesIfUnrecognised = True - Me.ucrInputDefinitionsID.AutoSize = True - Me.ucrInputDefinitionsID.IsMultiline = False - Me.ucrInputDefinitionsID.IsReadOnly = False - Me.ucrInputDefinitionsID.Location = New System.Drawing.Point(500, 457) - Me.ucrInputDefinitionsID.Margin = New System.Windows.Forms.Padding(14) - Me.ucrInputDefinitionsID.Name = "ucrInputDefinitionsID" - Me.ucrInputDefinitionsID.Size = New System.Drawing.Size(177, 32) - Me.ucrInputDefinitionsID.TabIndex = 16 - ' - 'ucrReceiverStation - ' - Me.ucrReceiverStation.AutoSize = True - Me.ucrReceiverStation.frmParent = Me - Me.ucrReceiverStation.Location = New System.Drawing.Point(498, 45) - Me.ucrReceiverStation.Margin = New System.Windows.Forms.Padding(0) - Me.ucrReceiverStation.Name = "ucrReceiverStation" - Me.ucrReceiverStation.Selector = Nothing - Me.ucrReceiverStation.Size = New System.Drawing.Size(180, 31) - Me.ucrReceiverStation.strNcFilePath = "" - Me.ucrReceiverStation.TabIndex = 2 - Me.ucrReceiverStation.ucrSelector = Nothing + 'lblDistrict + ' + Me.lblDistrict.AutoSize = True + Me.lblDistrict.Location = New System.Drawing.Point(324, 270) + Me.lblDistrict.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0) + Me.lblDistrict.Name = "lblDistrict" + Me.lblDistrict.Size = New System.Drawing.Size(39, 13) + Me.lblDistrict.TabIndex = 79 + Me.lblDistrict.Text = "District" + ' + 'lblElavation + ' + Me.lblElavation.AutoSize = True + Me.lblElavation.Location = New System.Drawing.Point(323, 222) + Me.lblElavation.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0) + Me.lblElavation.Name = "lblElavation" + Me.lblElavation.Size = New System.Drawing.Size(51, 13) + Me.lblElavation.TabIndex = 77 + Me.lblElavation.Text = "Elevation" + ' + 'lblLatitude + ' + Me.lblLatitude.AutoSize = True + Me.lblLatitude.Location = New System.Drawing.Point(322, 173) + Me.lblLatitude.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0) + Me.lblLatitude.Name = "lblLatitude" + Me.lblLatitude.Size = New System.Drawing.Size(45, 13) + Me.lblLatitude.TabIndex = 75 + Me.lblLatitude.Text = "Latitude" + ' + 'lblLongitude + ' + Me.lblLongitude.AutoSize = True + Me.lblLongitude.Location = New System.Drawing.Point(321, 123) + Me.lblLongitude.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0) + Me.lblLongitude.Name = "lblLongitude" + Me.lblLongitude.Size = New System.Drawing.Size(57, 13) + Me.lblLongitude.TabIndex = 73 + Me.lblLongitude.Text = "Longitude " + ' + 'ucrReceiverLongititude + ' + Me.ucrReceiverLongititude.AutoSize = True + Me.ucrReceiverLongititude.frmParent = Me + Me.ucrReceiverLongititude.Location = New System.Drawing.Point(319, 140) + Me.ucrReceiverLongititude.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverLongititude.Name = "ucrReceiverLongititude" + Me.ucrReceiverLongititude.Selector = Nothing + Me.ucrReceiverLongititude.Size = New System.Drawing.Size(120, 23) + Me.ucrReceiverLongititude.strNcFilePath = "" + Me.ucrReceiverLongititude.TabIndex = 74 + Me.ucrReceiverLongititude.ucrSelector = Nothing + ' + 'ucrReceiverLatitude + ' + Me.ucrReceiverLatitude.AutoSize = True + Me.ucrReceiverLatitude.frmParent = Me + Me.ucrReceiverLatitude.Location = New System.Drawing.Point(319, 192) + Me.ucrReceiverLatitude.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverLatitude.Name = "ucrReceiverLatitude" + Me.ucrReceiverLatitude.Selector = Nothing + Me.ucrReceiverLatitude.Size = New System.Drawing.Size(120, 25) + Me.ucrReceiverLatitude.strNcFilePath = "" + Me.ucrReceiverLatitude.TabIndex = 76 + Me.ucrReceiverLatitude.ucrSelector = Nothing + ' + 'ucrReceiverElavation + ' + Me.ucrReceiverElavation.AutoSize = True + Me.ucrReceiverElavation.frmParent = Me + Me.ucrReceiverElavation.Location = New System.Drawing.Point(319, 240) + Me.ucrReceiverElavation.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverElavation.Name = "ucrReceiverElavation" + Me.ucrReceiverElavation.Selector = Nothing + Me.ucrReceiverElavation.Size = New System.Drawing.Size(120, 23) + Me.ucrReceiverElavation.strNcFilePath = "" + Me.ucrReceiverElavation.TabIndex = 78 + Me.ucrReceiverElavation.ucrSelector = Nothing + ' + 'ucrReceiverDistrict + ' + Me.ucrReceiverDistrict.AutoSize = True + Me.ucrReceiverDistrict.frmParent = Me + Me.ucrReceiverDistrict.Location = New System.Drawing.Point(319, 289) + Me.ucrReceiverDistrict.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverDistrict.Name = "ucrReceiverDistrict" + Me.ucrReceiverDistrict.Selector = Nothing + Me.ucrReceiverDistrict.Size = New System.Drawing.Size(120, 28) + Me.ucrReceiverDistrict.strNcFilePath = "" + Me.ucrReceiverDistrict.TabIndex = 80 + Me.ucrReceiverDistrict.ucrSelector = Nothing + ' + 'ucrReceiverStationName + ' + Me.ucrReceiverStationName.AutoSize = True + Me.ucrReceiverStationName.frmParent = Me + Me.ucrReceiverStationName.Location = New System.Drawing.Point(319, 93) + Me.ucrReceiverStationName.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverStationName.Name = "ucrReceiverStationName" + Me.ucrReceiverStationName.Selector = Nothing + Me.ucrReceiverStationName.Size = New System.Drawing.Size(120, 27) + Me.ucrReceiverStationName.strNcFilePath = "" + Me.ucrReceiverStationName.TabIndex = 72 + Me.ucrReceiverStationName.ucrSelector = Nothing + ' + 'lblStationName + ' + Me.lblStationName.AutoSize = True + Me.lblStationName.Location = New System.Drawing.Point(321, 78) + Me.lblStationName.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0) + Me.lblStationName.Name = "lblStationName" + Me.lblStationName.Size = New System.Drawing.Size(71, 13) + Me.lblStationName.TabIndex = 71 + Me.lblStationName.Text = "Station Name" + ' + 'lblCountryMetada + ' + Me.lblCountryMetada.AutoSize = True + Me.lblCountryMetada.Location = New System.Drawing.Point(323, 316) + Me.lblCountryMetada.Name = "lblCountryMetada" + Me.lblCountryMetada.Size = New System.Drawing.Size(46, 13) + Me.lblCountryMetada.TabIndex = 85 + Me.lblCountryMetada.Text = "Country:" + ' + 'ucrInputCountryMetadata + ' + Me.ucrInputCountryMetadata.AddQuotesIfUnrecognised = True + Me.ucrInputCountryMetadata.AutoSize = True + Me.ucrInputCountryMetadata.IsMultiline = False + Me.ucrInputCountryMetadata.IsReadOnly = False + Me.ucrInputCountryMetadata.Location = New System.Drawing.Point(319, 334) + Me.ucrInputCountryMetadata.Margin = New System.Windows.Forms.Padding(9) + Me.ucrInputCountryMetadata.Name = "ucrInputCountryMetadata" + Me.ucrInputCountryMetadata.Size = New System.Drawing.Size(118, 21) + Me.ucrInputCountryMetadata.TabIndex = 84 ' 'dlgExportClimaticDefinitions ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(9.0!, 20.0!) + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.AutoSize = True - Me.ClientSize = New System.Drawing.Size(688, 713) + Me.ClientSize = New System.Drawing.Size(459, 500) + Me.Controls.Add(Me.ucrReceiverYear) + Me.Controls.Add(Me.lblExport) + Me.Controls.Add(Me.cmdChooseFile) + Me.Controls.Add(Me.ucrInputTokenPath) + Me.Controls.Add(Me.rdoUploadSummaries) + Me.Controls.Add(Me.rdoUpdateMetadata) + Me.Controls.Add(Me.ucrPnlExportGoogle) Me.Controls.Add(Me.ucrReceiverStation) Me.Controls.Add(Me.lblDefinitionsID) Me.Controls.Add(Me.ucrInputDefinitionsID) Me.Controls.Add(Me.cmdDefine) - Me.Controls.Add(Me.lblExport) - Me.Controls.Add(Me.cmdChooseFile) - Me.Controls.Add(Me.ucrInputTokenPath) Me.Controls.Add(Me.lblStation) Me.Controls.Add(Me.lblCountry) Me.Controls.Add(Me.ucrInputCountry) Me.Controls.Add(Me.lblMonth) Me.Controls.Add(Me.lblYear) Me.Controls.Add(Me.ucrReceiverMonth) - Me.Controls.Add(Me.ucrReceiverYear) Me.Controls.Add(Me.ucrChkIncludeSummaryData) Me.Controls.Add(Me.grpSummaries) Me.Controls.Add(Me.lblCropData) @@ -448,8 +629,19 @@ Partial Class dlgExportClimaticDefinitions Me.Controls.Add(Me.ucrReceiverDataYear) Me.Controls.Add(Me.ucrReceiverDataYearMonth) Me.Controls.Add(Me.ucrReceiverCropData) + Me.Controls.Add(Me.lblDistrict) + Me.Controls.Add(Me.lblElavation) + Me.Controls.Add(Me.lblLatitude) + Me.Controls.Add(Me.lblLongitude) + Me.Controls.Add(Me.ucrReceiverLongititude) + Me.Controls.Add(Me.ucrReceiverLatitude) + Me.Controls.Add(Me.ucrReceiverElavation) + Me.Controls.Add(Me.ucrReceiverDistrict) + Me.Controls.Add(Me.ucrReceiverStationName) + Me.Controls.Add(Me.lblStationName) + Me.Controls.Add(Me.lblCountryMetada) + Me.Controls.Add(Me.ucrInputCountryMetadata) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow - Me.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "dlgExportClimaticDefinitions" @@ -462,21 +654,31 @@ Partial Class dlgExportClimaticDefinitions End Sub + Friend WithEvents ucrReceiverYear As ucrReceiverSingle + Friend WithEvents lblExport As Label + Friend WithEvents cmdChooseFile As Button + Friend WithEvents ucrInputTokenPath As ucrInputTextBox + Friend WithEvents rdoUploadSummaries As RadioButton + Friend WithEvents rdoUpdateMetadata As RadioButton + Friend WithEvents ucrPnlExportGoogle As UcrPanel + Friend WithEvents ucrReceiverStation As ucrReceiverSingle + Friend WithEvents lblDefinitionsID As Label + Friend WithEvents ucrInputDefinitionsID As ucrInputTextBox + Friend WithEvents cmdDefine As Button Friend WithEvents lblStation As Label Friend WithEvents lblCountry As Label Friend WithEvents ucrInputCountry As ucrInputTextBox - Friend WithEvents ucrChkSeasonStartProp As ucrCheck - Friend WithEvents ucrChkExtremes As ucrCheck - Friend WithEvents ucrChkCropSuccessProp As ucrCheck - Friend WithEvents ucrChkAnnualTemp As ucrCheck - Friend WithEvents ucrChkAnnualRainfall As ucrCheck Friend WithEvents lblMonth As Label Friend WithEvents lblYear As Label Friend WithEvents ucrReceiverMonth As ucrReceiverSingle - Friend WithEvents ucrReceiverYear As ucrReceiverSingle Friend WithEvents ucrChkIncludeSummaryData As ucrCheck Friend WithEvents grpSummaries As GroupBox Friend WithEvents ucrChkMonthlyTemp As ucrCheck + Friend WithEvents ucrChkSeasonStartProp As ucrCheck + Friend WithEvents ucrChkExtremes As ucrCheck + Friend WithEvents ucrChkCropSuccessProp As ucrCheck + Friend WithEvents ucrChkAnnualTemp As ucrCheck + Friend WithEvents ucrChkAnnualRainfall As ucrCheck Friend WithEvents lblCropData As Label Friend WithEvents lblDataByYearMonth As Label Friend WithEvents lblDataByYear As Label @@ -487,11 +689,16 @@ Partial Class dlgExportClimaticDefinitions Friend WithEvents ucrReceiverDataYear As ucrReceiverSingle Friend WithEvents ucrReceiverDataYearMonth As ucrReceiverSingle Friend WithEvents ucrReceiverCropData As ucrReceiverSingle - Friend WithEvents lblExport As Label - Friend WithEvents cmdChooseFile As Button - Friend WithEvents ucrInputTokenPath As ucrInputTextBox - Friend WithEvents cmdDefine As Button - Friend WithEvents lblDefinitionsID As Label - Friend WithEvents ucrInputDefinitionsID As ucrInputTextBox - Friend WithEvents ucrReceiverStation As ucrReceiverSingle + Friend WithEvents lblDistrict As Label + Friend WithEvents lblElavation As Label + Friend WithEvents lblLatitude As Label + Friend WithEvents lblLongitude As Label + Friend WithEvents ucrReceiverLongititude As ucrReceiverSingle + Friend WithEvents ucrReceiverLatitude As ucrReceiverSingle + Friend WithEvents ucrReceiverElavation As ucrReceiverSingle + Friend WithEvents ucrReceiverDistrict As ucrReceiverSingle + Friend WithEvents ucrReceiverStationName As ucrReceiverSingle + Friend WithEvents lblStationName As Label + Friend WithEvents lblCountryMetada As Label + Friend WithEvents ucrInputCountryMetadata As ucrInputTextBox End Class diff --git a/instat/dlgExportClimaticDefinitions.vb b/instat/dlgExportClimaticDefinitions.vb index 723aba5fe08..2ca03ba31ea 100644 --- a/instat/dlgExportClimaticDefinitions.vb +++ b/instat/dlgExportClimaticDefinitions.vb @@ -21,7 +21,9 @@ Public Class dlgExportClimaticDefinitions Private bReset As Boolean = True Private bResetSubdialog As Boolean = False Private clsDummyFunction As New RFunction - Public clsExportRinstatToBucketFunction, ClsGcsAuthFileFunction, clsSummariesFunction As New RFunction + Private clsGetDataFrameFunction, clsUpdateMetadataInfoFunction, ClsGcsAuthFileFunction As New RFunction + Public clsRsyntax As New RSyntax + Public clsExportRinstatToBucketFunction, clsSummariesFunction As New RFunction Public clsReforMattAnnualSummariesFunction, clsReformatCropSuccessFunction, clsReformatSeasonStartFunction, clsReformatTempSummariesFunction, clsReformatMonthlyTempSummaries As New RFunction Private Sub dlgExportClimaticDefinitions_Load(sender As Object, e As EventArgs) Handles MyBase.Load @@ -36,15 +38,21 @@ Public Class dlgExportClimaticDefinitions bReset = False TestOkEnabled() autoTranslate(Me) + DialogSize() End Sub Private Sub InitialiseDialog() + ucrPnlExportGoogle.AddRadioButton(rdoUpdateMetadata) + ucrPnlExportGoogle.AddRadioButton(rdoUploadSummaries) + ucrPnlExportGoogle.AddParameterValuesCondition(rdoUpdateMetadata, "checked", "metadata") + ucrPnlExportGoogle.AddParameterValuesCondition(rdoUploadSummaries, "checked", "summary") + ucrReceiverStation.SetParameter(New RParameter("station", 0)) ucrReceiverStation.Selector = ucrSelectorExportDefinitions ucrReceiverStation.SetParameterIsString() - ucrReceiverStation.SetMeAsReceiver() ucrReceiverStation.SetClimaticType("station") ucrReceiverStation.bAutoFill = True + ucrReceiverStation.SetLinkedDisplayControl(lblStation) ucrReceiverDataYear.SetParameter(New RParameter("data_by_year", 1)) ucrReceiverDataYear.Selector = ucrSelectorExportDefinitions @@ -118,10 +126,56 @@ Public Class dlgExportClimaticDefinitions ucrChkIncludeSummaryData.SetRDefault("FALSE") ucrInputDefinitionsID.SetParameter(New RParameter("definitions_id", 19)) + ucrInputDefinitionsID.SetLinkedDisplayControl(lblDefinitionsID) + ucrInputCountry.SetParameter(New RParameter("country", 20)) + ucrInputCountry.SetLinkedDisplayControl(lblCountry) ucrInputTokenPath.SetParameter(New RParameter("filename", 0)) - + ucrInputTokenPath.SetLinkedDisplayControl(lblExport) + + ucrReceiverStationName.SetParameter(New RParameter("station_var", 1)) + ucrReceiverStationName.Selector = ucrSelectorExportDefinitions + ucrReceiverStationName.SetParameterIsString() + ucrReceiverStationName.SetClimaticType("station") + ucrReceiverStationName.bAutoFill = True + ucrReceiverStationName.SetLinkedDisplayControl(lblStationName) + + ucrReceiverLongititude.SetParameter(New RParameter("longitude_var", 2)) + ucrReceiverLongititude.Selector = ucrSelectorExportDefinitions + ucrReceiverLongititude.SetParameterIsString() + ucrReceiverLongititude.SetClimaticType("lon") + ucrReceiverLongititude.bAutoFill = True + ucrReceiverLongititude.SetLinkedDisplayControl(lblLongitude) + + ucrReceiverLatitude.SetParameter(New RParameter("latitude_var", 3)) + ucrReceiverLatitude.Selector = ucrSelectorExportDefinitions + ucrReceiverLatitude.SetParameterIsString() + ucrReceiverLatitude.SetClimaticType("lat") + ucrReceiverLatitude.bAutoFill = True + ucrReceiverLatitude.SetLinkedDisplayControl(lblLatitude) + + ucrReceiverElavation.SetParameter(New RParameter("elevation_var", 4)) + ucrReceiverElavation.Selector = ucrSelectorExportDefinitions + ucrReceiverElavation.SetParameterIsString() + ucrReceiverElavation.SetClimaticType("alt") + ucrReceiverElavation.bAutoFill = True + ucrReceiverElavation.SetLinkedDisplayControl(lblElavation) + + ucrReceiverDistrict.SetParameter(New RParameter("district_var", 5)) + ucrReceiverDistrict.Selector = ucrSelectorExportDefinitions + ucrReceiverDistrict.SetParameterIsString() + ucrReceiverDistrict.SetClimaticType("district") + ucrReceiverDistrict.bAutoFill = True + ucrReceiverDistrict.SetLinkedDisplayControl(lblDistrict) + + ucrInputCountryMetadata.SetParameter(New RParameter("country", 6)) + ucrInputCountryMetadata.SetLinkedDisplayControl(lblCountryMetada) + + ucrPnlExportGoogle.AddToLinkedControls({ucrReceiverMonth, ucrReceiverYear, ucrReceiverStation}, {rdoUploadSummaries}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrPnlExportGoogle.AddToLinkedControls({ucrReceiverDistrict, ucrReceiverElavation, ucrReceiverLatitude, ucrInputCountryMetadata, ucrReceiverLongititude, ucrReceiverStationName}, {rdoUpdateMetadata}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrPnlExportGoogle.AddToLinkedControls({ucrInputCountry, ucrChkIncludeSummaryData, ucrInputDefinitionsID}, {rdoUploadSummaries}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + DialogSize() End Sub Private Sub SetDefaults() @@ -133,7 +187,9 @@ Public Class dlgExportClimaticDefinitions clsReforMattAnnualSummariesFunction = New RFunction clsReformatTempSummariesFunction = New RFunction ClsGcsAuthFileFunction = New RFunction + clsUpdateMetadataInfoFunction = New RFunction clsDummyFunction = New RFunction + clsGetDataFrameFunction = New RFunction bResetSubdialog = True ucrSelectorExportDefinitions.Reset() @@ -144,6 +200,9 @@ Public Class dlgExportClimaticDefinitions clsDummyFunction.AddParameter("extrem", "False", iPosition:=3) clsDummyFunction.AddParameter("season", "False", iPosition:=4) clsDummyFunction.AddParameter("crop", "False", iPosition:=5) + clsDummyFunction.AddParameter("checked", "metadata", iPosition:=6) + + clsGetDataFrameFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_data_frame") clsReformatTempSummariesFunction.SetPackageName("epicsawrap") clsReformatTempSummariesFunction.SetRCommand("reformat_temperature_summaries") @@ -173,9 +232,9 @@ Public Class dlgExportClimaticDefinitions ClsGcsAuthFileFunction.SetPackageName("epicsawrap") ClsGcsAuthFileFunction.SetRCommand("gcs_auth_file") + clsUpdateMetadataInfoFunction.SetPackageName("epicsawrap") + clsUpdateMetadataInfoFunction.SetRCommand("update_metadata_info") ucrBase.clsRsyntax.ClearCodes() - ucrBase.clsRsyntax.AddToBeforeCodes(ClsGcsAuthFileFunction, 0) - ucrBase.clsRsyntax.SetBaseRFunction(clsExportRinstatToBucketFunction) End Sub Private Sub SetRCodeForControls(bReset As Boolean) @@ -192,6 +251,14 @@ Public Class dlgExportClimaticDefinitions ucrInputDefinitionsID.SetRCode(clsExportRinstatToBucketFunction, bReset) ucrInputCountry.SetRCode(clsExportRinstatToBucketFunction, bReset) ucrChkIncludeSummaryData.SetRCode(clsExportRinstatToBucketFunction, bReset) + + ucrReceiverDistrict.SetRCode(clsUpdateMetadataInfoFunction, bReset) + ucrReceiverElavation.SetRCode(clsUpdateMetadataInfoFunction, bReset) + ucrReceiverLatitude.SetRCode(clsUpdateMetadataInfoFunction, bReset) + ucrReceiverLongititude.SetRCode(clsUpdateMetadataInfoFunction, bReset) + ucrReceiverStationName.SetRCode(clsUpdateMetadataInfoFunction, bReset) + ucrInputCountryMetadata.SetRCode(clsUpdateMetadataInfoFunction, bReset) + If bReset Then ucrChkAnnualRainfall.SetRCode(clsDummyFunction, bReset) ucrChkAnnualTemp.SetRCode(clsDummyFunction, bReset) @@ -199,36 +266,45 @@ Public Class dlgExportClimaticDefinitions ucrChkExtremes.SetRCode(clsDummyFunction, bReset) ucrChkMonthlyTemp.SetRCode(clsDummyFunction, bReset) ucrChkSeasonStartProp.SetRCode(clsDummyFunction, bReset) + ucrPnlExportGoogle.SetRCode(clsDummyFunction, bReset) End If AddRemoveSummary() EnableDisableDefineButton() End Sub Private Sub TestOkEnabled() - If Not ucrReceiverStation.IsEmpty AndAlso + If rdoUploadSummaries.Checked Then + If Not ucrReceiverStation.IsEmpty AndAlso Not ucrReceiverYear.IsEmpty AndAlso Not ucrInputCountry.IsEmpty AndAlso Not ucrInputDefinitionsID.IsEmpty AndAlso Not ucrInputTokenPath.IsEmpty Then - If (ucrChkCropSuccessProp.Checked OrElse ucrChkSeasonStartProp.Checked) AndAlso - Not ucrReceiverCropData.IsEmpty Then - ucrBase.OKEnabled(True) - ElseIf ucrChkAnnualRainfall.Checked AndAlso - Not ucrReceiverRain.IsEmpty Then - ucrBase.OKEnabled(True) - ElseIf (ucrChkAnnualRainfall.Checked OrElse ucrChkAnnualTemp.Checked) AndAlso - Not ucrReceiverDataYear.IsEmpty Then - ucrBase.OKEnabled(True) - ElseIf ucrChkMonthlyTemp.Checked AndAlso - Not ucrReceiverMonth.IsEmpty AndAlso - Not ucrReceiverDataYearMonth.IsEmpty Then - ucrBase.OKEnabled(True) + If (ucrChkCropSuccessProp.Checked OrElse ucrChkSeasonStartProp.Checked) AndAlso + Not ucrReceiverCropData.IsEmpty Then + ucrBase.OKEnabled(True) + ElseIf ucrChkAnnualRainfall.Checked AndAlso + Not ucrReceiverRain.IsEmpty Then + ucrBase.OKEnabled(True) + ElseIf (ucrChkAnnualRainfall.Checked OrElse ucrChkAnnualTemp.Checked) AndAlso + Not ucrReceiverDataYear.IsEmpty Then + ucrBase.OKEnabled(True) + ElseIf ucrChkMonthlyTemp.Checked AndAlso + Not ucrReceiverMonth.IsEmpty AndAlso + Not ucrReceiverDataYearMonth.IsEmpty Then + ucrBase.OKEnabled(True) + Else + ucrBase.OKEnabled(False) + End If Else ucrBase.OKEnabled(False) End If Else - ucrBase.OKEnabled(False) + If Not ucrReceiverStationName.IsEmpty AndAlso Not ucrInputTokenPath.IsEmpty AndAlso Not ucrInputCountryMetadata.IsEmpty Then + ucrBase.OKEnabled(True) + Else + ucrBase.OKEnabled(False) + End If End If End Sub @@ -336,18 +412,21 @@ Public Class dlgExportClimaticDefinitions End Sub Private Sub EnableDisableDefineButton() - ucrReceiverDataYearMonth.Visible = ucrChkMonthlyTemp.Checked - ucrReceiverDataYear.Visible = ucrChkAnnualRainfall.Checked OrElse ucrChkAnnualTemp.Checked - ucrReceiverRain.Visible = ucrChkAnnualRainfall.Checked - ucrReceiverCropData.Visible = ucrChkCropSuccessProp.Checked OrElse ucrChkSeasonStartProp.Checked - - End Sub + If rdoUploadSummaries.Checked Then + ucrReceiverDataYearMonth.Visible = ucrChkMonthlyTemp.Checked + ucrReceiverDataYear.Visible = ucrChkAnnualRainfall.Checked OrElse ucrChkAnnualTemp.Checked + ucrReceiverRain.Visible = ucrChkAnnualRainfall.Checked + ucrReceiverCropData.Visible = ucrChkCropSuccessProp.Checked OrElse ucrChkSeasonStartProp.Checked + Else + ucrReceiverDataYearMonth.Visible = False + ucrReceiverDataYear.Visible = False + ucrReceiverRain.Visible = False + ucrReceiverCropData.Visible = False + End If - Private Sub ucrChkIncludeSummaryData_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkIncludeSummaryData.ControlValueChanged - EnableDisableDefineButton() End Sub - Private Sub cmdChooseFile_Click(sender As Object, e As EventArgs) Handles cmdChooseFile.Click + Private Sub cmdChooseFile_Click_1(sender As Object, e As EventArgs) Handles cmdChooseFile.Click Using dlgOpen As New OpenFileDialog dlgOpen.Filter = "JSON Files|*.json" dlgOpen.Title = "Import JSON File" @@ -358,16 +437,61 @@ Public Class dlgExportClimaticDefinitions ucrInputTokenPath.SetName(Replace(dlgOpen.FileName, "\", "/")) End If End Using + End Sub + Private Sub ucrChkIncludeSummaryData_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkIncludeSummaryData.ControlValueChanged + EnableDisableDefineButton() End Sub - Private Sub ucrReceiverData_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverRain.ControlContentsChanged, ucrReceiverCropData.ControlContentsChanged, ucrReceiverDataYearMonth.ControlContentsChanged, ucrReceiverDataYear.ControlContentsChanged, ucrReceiverStation.ControlContentsChanged, - ucrReceiverMonth.ControlContentsChanged, ucrReceiverYear.ControlContentsChanged, ucrChkSeasonStartProp.ControlContentsChanged, ucrInputCountry.ControlContentsChanged, ucrInputDefinitionsID.ControlContentsChanged, ucrChkIncludeSummaryData.ControlContentsChanged, - ucrChkMonthlyTemp.ControlContentsChanged, ucrChkCropSuccessProp.ControlContentsChanged, ucrChkAnnualTemp.ControlContentsChanged, ucrChkAnnualRainfall.ControlContentsChanged, ucrInputTokenPath.ControlContentsChanged, ucrSelectorExportDefinitions.ControlContentsChanged + Private Sub ucrSelectorExportDefinitions_DataFrameChanged() Handles ucrSelectorExportDefinitions.DataFrameChanged TestOkEnabled() End Sub - Private Sub ucrSelectorExportDefinitions_DataFrameChanged() Handles ucrSelectorExportDefinitions.DataFrameChanged + Private Sub ucrPnlExportGoogle_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlExportGoogle.ControlValueChanged, ucrInputTokenPath.ControlValueChanged + ucrBase.clsRsyntax.AddToBeforeCodes(ClsGcsAuthFileFunction, 0) + If rdoUpdateMetadata.Checked Then + grpSummaries.Visible = False + cmdDefine.Visible = False + ucrBase.clsRsyntax.SetBaseRFunction(clsUpdateMetadataInfoFunction) + ucrReceiverStationName.SetMeAsReceiver() + Else + grpSummaries.Visible = True + cmdDefine.Visible = True + ucrBase.clsRsyntax.SetBaseRFunction(clsExportRinstatToBucketFunction) + ucrReceiverStation.SetMeAsReceiver() + End If + EnableDisableDefineButton() + DialogSize() TestOkEnabled() End Sub + + Private Sub DialogSize() + If rdoUpdateMetadata.Checked Then + Me.Size = New Size(475, 455) + Me.ucrBase.Location = New Point(4, 360) + Else + Me.Size = New Size(475, 539) + Me.ucrBase.Location = New Point(4, 434) + End If + End Sub + + Private Sub ucrSelectorExportDefinitions_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrSelectorExportDefinitions.ControlValueChanged + clsGetDataFrameFunction.AddParameter("data_name", Chr(34) & ucrSelectorExportDefinitions.strCurrentDataFrame & Chr(34), iPosition:=0) + clsGetDataFrameFunction.SetAssignTo(ucrSelectorExportDefinitions.ucrAvailableDataFrames.cboAvailableDataFrames.Text) + clsUpdateMetadataInfoFunction.AddParameter("metadata_data", clsRFunctionParameter:=clsGetDataFrameFunction, iPosition:=0) + End Sub + + Private Sub ucrReceiverData_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverRain.ControlContentsChanged, ucrReceiverCropData.ControlContentsChanged, ucrReceiverDataYearMonth.ControlContentsChanged, ucrReceiverDataYear.ControlContentsChanged, ucrReceiverStation.ControlContentsChanged, ucrInputTokenPath.ControlContentsChanged, ucrInputCountryMetadata.ControlContentsChanged, + ucrReceiverMonth.ControlContentsChanged, ucrReceiverYear.ControlContentsChanged, ucrChkSeasonStartProp.ControlContentsChanged, ucrInputCountry.ControlContentsChanged, ucrInputDefinitionsID.ControlContentsChanged, ucrChkIncludeSummaryData.ControlContentsChanged, ucrReceiverLongititude.ControlContentsChanged, ucrReceiverLatitude.ControlContentsChanged, + ucrChkMonthlyTemp.ControlContentsChanged, ucrChkCropSuccessProp.ControlContentsChanged, ucrChkAnnualTemp.ControlContentsChanged, ucrChkAnnualRainfall.ControlContentsChanged, ucrSelectorExportDefinitions.ControlContentsChanged, ucrReceiverElavation.ControlContentsChanged, ucrReceiverDistrict.ControlContentsChanged, ucrReceiverStationName.ControlContentsChanged + TestOkEnabled() + End Sub + + Private Sub ucrInputCountryMetadata_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputCountryMetadata.ControlValueChanged + If Not ucrInputCountryMetadata.IsEmpty Then + clsUpdateMetadataInfoFunction.AddParameter("country", Chr(34) & ucrInputCountryMetadata.GetText & Chr(34), iPosition:=6) + Else + clsUpdateMetadataInfoFunction.RemoveParameterByName("country") + End If + End Sub End Class \ No newline at end of file