AdhocAdam / smletsexchangeconnector

SMLets PowerShell based Exchange Connector for controlling Microsoft System Center Service Manager 2016+
https://adhocadam.github.io/smletsexchangeconnector/
GNU General Public License v3.0
29 stars 19 forks source link

Regional decimal delimiter when validating Min File Attachments size #217

Closed alexaxb closed 3 years ago

alexaxb commented 3 years ago

Describe the bug A clear and concise description of what the bug is. The textbox validation for File Attachments expects a dot as decimal delimiter. However, in some regional settings (Swedish for example) the decimal limiter is a comma. So everytime the Settings form is opened, the console will use a comma in the File Attachments value textbox (since that is the regional setting in windows) and the validation will throw a red star cause it cannot find a dot in the textbox.

Help us reproduce the bug Version of the connector you are using: 2.3 Features/variables you have enabled (i.e. $enableAzureCognitiveServicesForNewWI):

Expected behavior A clear and concise description of what you expected to happen. The validation needs to look for the current decimal delimiter that is used in windows.

Location and Environment Where are you running this from? Task Scheduler? SMA? Workflow server?: Task Scheduler What SCSM version are you running? (i.e. 2012R2, 2016, 2016 UR3, 1801, etc.): 2019

Additional context Add any other context about the problem here.

AdhocAdam commented 3 years ago

I went to Region settings, Additional Settings, changed the Decimal symbol to a different character, and then re-opened the SCSM Console. I was unable to save the form as the validation regex in the XAML is only looking for numbers and .

https://github.com/AdhocAdam/smletsexchangeconnector/blob/1ec9a6ccc89cd302d5f8fda6f73ef160e8276923/ManagementPack/2016/SMLetsExchangeConnectorSettingsUI/Forms/FileAttachmentForm.xaml#L18

Thank you for bringing this up and making me just a little less ignorant on this front. I look forward to overcoming this challenge 😄

alexaxb commented 3 years ago

Shouldn't this work as regex: ^^[.,][0-9]+$|^[0-9][.,]{0,1}[0-9]$ However, I'm not sure if there are more decimal chars out there :D

AdhocAdam commented 3 years ago

I had the identical thought process. "Oh I'll regex for . or ," and then "But there are probably more characters out there by virtue of what Alex has said."

AdhocAdam commented 3 years ago

Doing some research and came across this Microsoft doc on the topic. If you scroll down to the Examples section, it deals with what appears to be the core of what you've raised.

While I haven't attempted anything yet, I'm thinking perhaps the regex simply get's dropped from the UI and then the commit in AdminSettingsWizardData.cs performs the validation. Something to the effect of:

If the validation doesn't pass it just sets a default value like 5.0 or something. That way the pwsh can continue to run/process like it has since v1. Again, not committed to anything yet but this feels like a path forward.

AdhocAdam commented 3 years ago

This fix will be released via #226 shortly