diff --git a/instat/dlgClimSoft.Designer.vb b/instat/dlgClimSoft.Designer.vb index aa14f7e0879..1c5b32afda8 100644 --- a/instat/dlgClimSoft.Designer.vb +++ b/instat/dlgClimSoft.Designer.vb @@ -39,202 +39,311 @@ 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.ucrChKUnstackData = New instat.ucrCheck() 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, 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) + 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, 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) + 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, 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) + 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, 345) + 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, 404) + 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, 408) + 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, 373) + Me.btnMoreOptions.Name = "btnMoreOptions" + Me.btnMoreOptions.Size = New System.Drawing.Size(139, 23) + Me.btnMoreOptions.TabIndex = 31 + Me.btnMoreOptions.Text = "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 +353,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 +366,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,36 +379,56 @@ 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, 444) 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 ' + '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(408, 459) - Me.Controls.Add(Me.ucrChkUnstackData) - Me.Controls.Add(Me.ucrChkFlagsData) + 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) + 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 +442,32 @@ 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 + Friend WithEvents ucrChKUnstackData As ucrCheck +End Class \ No newline at end of file diff --git a/instat/dlgClimSoft.vb b/instat/dlgClimSoft.vb index fd5aeac8f7a..b448a049de6 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,296 @@ 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) + '--------------------------------------- + + 'Unstack data + '--------------------------------------- + ucrChKUnstackData.SetText("Unstack Data") + ucrChKUnstackData.SetParameter(New RParameter("unstack_data", 13)) + ucrChKUnstackData.SetRDefault("FALSE") + '--------------------------------------- + + 'date range + '--------------------------------------- + ucrChkDataDate.SetText("Select Dates") + + 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, ucrChKUnstackData}, + {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) & "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) + '--------------------------------------- + + '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) + + ucrChKUnstackData.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 +345,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/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 diff --git a/instat/instat.vbproj b/instat/instat.vbproj index 741d4f7da58..7670f979bf2 100644 --- a/instat/instat.vbproj +++ b/instat/instat.vbproj @@ -313,6 +313,12 @@ + + sdgClimsoft.vb + + + Form + sdgDefineAnnualRainfall.vb @@ -3200,6 +3206,9 @@ dlgThreeVariablePivotTable.vb + + sdgClimsoft.vb + sdgDefineAnnualRainfall.vb diff --git a/instat/sdgClimsoft.Designer.vb b/instat/sdgClimsoft.Designer.vb new file mode 100644 index 00000000000..a615738425c --- /dev/null +++ b/instat/sdgClimsoft.Designer.vb @@ -0,0 +1,307 @@ + +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.ucrChkImportElementsMetadata = New instat.ucrCheck() + 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() + 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.tbpMoreOptions = New System.Windows.Forms.TabControl() + Me.ucrBaseSubdialog = New instat.ucrButtonsSubdialogue() + 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, 367) + 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" + ' + '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, 367) + Me.tbColumns.TabIndex = 3 + Me.tbColumns.Tag = "" + Me.tbColumns.Text = "Data" + Me.tbColumns.UseVisualStyleBackColor = True + ' + '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) + 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, 351) + Me.grpColumnsToInclude.TabIndex = 32 + 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 + 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 + ' + 'ucrChkIncludeCapturedBy + ' + Me.ucrChkIncludeCapturedBy.AutoSize = True + 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 + ' + 'ucrChkIncludeQCStatus + ' + Me.ucrChkIncludeQCStatus.AutoSize = True + 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 + ' + 'ucrChkIncludeLevel + ' + Me.ucrChkIncludeLevel.AutoSize = True + 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 + ' + 'ucrChkIncludeElementAbbrv + ' + Me.ucrChkIncludeElementAbbrv.AutoSize = True + Me.ucrChkIncludeElementAbbrv.Checked = True + 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 + ' + 'ucrChkIncludeStationName + ' + Me.ucrChkIncludeStationName.AutoSize = True + Me.ucrChkIncludeStationName.Checked = True + 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 + ' + 'ucrChkIncludeAquistion + ' + Me.ucrChkIncludeAquistion.AutoSize = True + 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 + ' + 'ucrChkIncludeEntryForm + ' + Me.ucrChkIncludeEntryForm.AutoSize = True + 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 + ' + 'ucrChkIncludeFlag + ' + Me.ucrChkIncludeFlag.AutoSize = True + 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 + ' + '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, 393) + Me.tbpMoreOptions.TabIndex = 2 + ' + 'ucrBaseSubdialog + ' + 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 + ' + '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, 434) + 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 + 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 new file mode 100644 index 00000000000..e23c63a5b8f --- /dev/null +++ b/instat/sdgClimsoft.vb @@ -0,0 +1,124 @@ +' 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 + '--------------------------------------- + ucrChkIncludeStationId.SetText("Station Id") + ucrChkIncludeStationId.Enabled = False + + ucrChkIncludeStationName.SetText("Station Name") + ucrChkIncludeStationName.Enabled = False + + ucrChkIncludeElementAbbrv.SetText("Element Abbreviation") + ucrChkIncludeElementAbbrv.Enabled = False + + ucrChkIncludeDateTime.SetText("Date Time") + ucrChkIncludeDateTime.Enabled = 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", 16)) + ucrChkIncludeAquistion.SetRDefault("FALSE") + + ucrChkIncludeLevel.SetText("Level") + ucrChkIncludeLevel.SetParameter(New RParameter("include_level", 17)) + ucrChkIncludeLevel.SetRDefault("FALSE") + + ucrChkIncludeEntryForm.SetText("Entry Form") + ucrChkIncludeEntryForm.SetParameter(New RParameter("include_entry_form", 18)) + ucrChkIncludeEntryForm.SetRDefault("FALSE") + + ucrChkIncludeCapturedBy.SetText("Captured By (user)") + ucrChkIncludeCapturedBy.SetParameter(New RParameter("include_captured_by", 19)) + ucrChkIncludeCapturedBy.SetRDefault("FALSE") + + ucrChkIncludeQCStatus.SetText("QC Status") + ucrChkIncludeQCStatus.SetParameter(New RParameter("include_qc_status", 20)) + ucrChkIncludeQCStatus.SetRDefault("FALSE") + + ucrChkIncludeQCLog.SetText("QC Log") + ucrChkIncludeQCLog.SetParameter(New RParameter("include_qc_log", 21)) + ucrChkIncludeQCLog.SetRDefault("FALSE") + + ucrChkIncludeFlag.SetText("Flag") + ucrChkIncludeFlag.SetParameter(New RParameter("include_flag", 22)) + ucrChkIncludeFlag.SetRDefault("FALSE") + + '--------------------------------------- + + 'Metadata + '--------------------------------------- + ucrChkImportStationsMetadata.SetText("Selected Stations") + ucrChkImportStationsMetadata.SetParameter(New RParameter("import_selected_stations_metadata", 23)) + ucrChkImportStationsMetadata.SetRDefault("FALSE") + + ucrChkImportElementsMetadata.SetText("Selected Elements") + ucrChkImportElementsMetadata.SetParameter(New RParameter("import_selected_elements_metadata", 24)) + ucrChkImportElementsMetadata.SetRDefault("FALSE") + '--------------------------------------- + + bControlsInitialised = True + + End Sub + + Public Sub SetRCode(clsRFunction As RFunction, Optional bReset As Boolean = True) + 'initialise controls if not initialised + InitialiseControls() + + 'Columns + '--------------------------------------- + ucrChkIncludeElementId.SetRCode(clsRFunction, bReset) + ucrChkIncludeElementName.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/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 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()) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 7bf6274f247..ee580e5519a 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -1848,6 +1848,265 @@ 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){ + # 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_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_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) + +}) + +#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, unstack_data = 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() + 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",", station.stationName AS station_name") + + if(include_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_name){ + sql_select <-paste0(sql_select,", obselement.elementName AS element_name") + } + + 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") + sql_select <-paste0(sql_select,", DATE(", tableName,".obsDatetime) AS date") + + 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",";") + #-------------------------------- + + # 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)) + } + + 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)) + } + + #-------------------------------- + + # import and transform observations data data + # -------------------------------- + + # 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 + 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 + 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) + + if(include_element_id){ + observations_df$element_id <- as.factor(observations_df$element_id) + } + + if(include_element_name){ + observations_df$element_name <- as.factor(observations_df$element_name) + } + + if(include_qc_status){ + observations_df$qc_status <- as.factor(observations_df$qc_status) + } + + if(include_acquisition_type){ + observations_df$acquisition_type <- as.factor(observations_df$acquisition_type) + } + + if(include_level){ + observations_df$level <- as.factor(observations_df$level) + } + + if(include_flag){ + observations_df$flag <- as.factor(observations_df$flag) + } + + if(include_entry_form){ + 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) + +}) + +#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() 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