fixed CREW/PAS import for variable locode selection
This commit is contained in:
parent
a3019b7a30
commit
d96979a939
@ -25,7 +25,7 @@
|
||||
<TextBlock FontWeight="DemiBold" VerticalAlignment="Center" Name="textBlockType" Grid.Row="0" Grid.Column="1">bla</TextBlock>
|
||||
<TextBlock FontWeight="DemiBold" VerticalAlignment="Center" Name="textBlockValue" Grid.Row="1" Grid.Column="1">bla</TextBlock>
|
||||
<xctk:WatermarkComboBox Grid.Column="1" Grid.Row="2" x:Name="comboBoxValues" IsTextSearchEnabled="True" SelectedValuePath="Key" DisplayMemberPath="Value" Margin="2" IsEditable="True" Watermark="Select an appropriate value" />
|
||||
|
||||
<enictrl:LocodeControl Grid.Column="1" Grid.Row="2" x:Name="locodeControl" Visibility="Hidden" />
|
||||
|
||||
</Grid>
|
||||
</enictrl:EditWindowBase>
|
||||
|
||||
@ -15,13 +15,24 @@ namespace ENI2.EditControls
|
||||
{
|
||||
public FixImportDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public bool LocodeMode
|
||||
{
|
||||
get { return this.locodeControl.Visibility == Visibility.Visible; }
|
||||
set
|
||||
{
|
||||
this.locodeControl.Visibility = value ? Visibility.Visible : Visibility.Hidden;
|
||||
this.comboBoxValues.Visibility = value ? Visibility.Hidden : Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
public string SelectedValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (LocodeMode) return this.locodeControl.LocodeValue;
|
||||
return this.comboBoxValues.SelectedValue as string;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2521,47 +2521,61 @@ namespace ENI2.Excel
|
||||
|
||||
val = val.ToUpper();
|
||||
|
||||
if (val.IsNullOrEmpty()) return val;
|
||||
|
||||
// check if this is a legitimate Locode
|
||||
if (!LocodeDB.LocationNameFromLocode(val).IsNullOrEmpty()) return val;
|
||||
|
||||
string portName = LocodeDB.PortNameFromLocode(val);
|
||||
if (portName.IsNullOrEmpty())
|
||||
{
|
||||
// _log.WarnFormat("unknown Locode {0}", val);
|
||||
// reverse search: if this is a name lookup port code
|
||||
List<string> possibleLocodes = LocodeDB.AllLocodesForCityName(val);
|
||||
// check if it is a port that we already know
|
||||
|
||||
// _log.WarnFormat("unknown Locode {0}", val);
|
||||
// reverse search: if this is a name lookup port code
|
||||
List<string> possibleLocodes = LocodeDB.AllLocodesForCityName(val);
|
||||
|
||||
if(possibleLocodes.Count > 1)
|
||||
if(possibleLocodes.Count > 1)
|
||||
{
|
||||
if (!_locodeImportDict.ContainsKey(val))
|
||||
{
|
||||
if (!_locodeImportDict.ContainsKey(val))
|
||||
FixImportDialog fid = new FixImportDialog();
|
||||
fid.Value = val;
|
||||
fid.ValueType = "Locode";
|
||||
Dictionary<string, string> ld = new Dictionary<string, string>();
|
||||
foreach (string locode in possibleLocodes)
|
||||
ld[locode] = locode;
|
||||
fid.SelectionValues = ld;
|
||||
if (fid.ShowDialog() ?? false)
|
||||
{
|
||||
FixImportDialog fid = new FixImportDialog();
|
||||
fid.Value = val;
|
||||
fid.ValueType = "Locode";
|
||||
Dictionary<string, string> ld = new Dictionary<string, string>();
|
||||
foreach (string locode in possibleLocodes)
|
||||
ld[locode] = locode;
|
||||
fid.SelectionValues = ld;
|
||||
if (fid.ShowDialog() ?? false)
|
||||
{
|
||||
_locodeImportDict[val] = fid.SelectedValue;
|
||||
}
|
||||
_locodeImportDict[val] = fid.SelectedValue;
|
||||
}
|
||||
}
|
||||
if(_locodeImportDict.ContainsKey(val))
|
||||
result = _locodeImportDict[val];
|
||||
}
|
||||
else if(possibleLocodes.Count == 1)
|
||||
}
|
||||
else if(possibleLocodes.Count == 1)
|
||||
{
|
||||
result = possibleLocodes[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_locodeImportDict.ContainsKey(val))
|
||||
{
|
||||
result = possibleLocodes[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
// nothing found
|
||||
// nothing found, let the user pick a locode by himself
|
||||
FixImportDialog fid = new FixImportDialog();
|
||||
fid.Value = val;
|
||||
fid.ValueType = "Locode";
|
||||
fid.LocodeMode = true;
|
||||
if (fid.ShowDialog() ?? false)
|
||||
{
|
||||
_locodeImportDict[val] = fid.SelectedValue;
|
||||
}
|
||||
}
|
||||
if (_locodeImportDict.ContainsKey(val))
|
||||
result = _locodeImportDict[val];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user