Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Windows Service which can run in three locations - London, Hong Kong or Singapore. This is new, previously it was just London or Hong Kong, and to determine which I looked at the local timezone. This worked well.

Hong Kong and Singapore share the same timezone though so this method can't distinguish the two.

Any ideas for a simple strategy to tell where the service is running?

(btw - I'm ruling out using IP configuration)
Posted
Updated 13-Jan-15 23:29pm
v2
Comments
[no name] 14-Jan-15 5:36am    
A pragmatic Approach: Plug in an GPS USB Stick ....
Rob Philpott 14-Jan-15 5:38am    
Good idea. Server is likely to be in some underground bunker without clear site of satellites/won't satisfy management though, I suspect.

1 solution

 
Share this answer
 
Comments
Rob Philpott 14-Jan-15 5:43am    
Sweet. Will investigate this and get back to you. I think I can actually do it using timezones as it turns out. Hong Kong is 'China Standard Time' whereas Singapore is 'Malay Peninsula Standard Time', but this might be better...
Rob Philpott 14-Jan-15 5:54am    
OK, this is undoubtedly the way to do it - in a normal place. RegionInfo.CurrentRegion.DisplayName would seem to be ideal, except that for London I get 'United Kingdom', Hong Kong 'United States', and Singapore 'United Kingdom'

I can well believe the servers aren't set up correctly. For this reason I think Timezone is probably more reliable, if that's wrong the time is likely to be wrong and picked up on, but being configured towards the UK/US is probably accidental or just normal.

Thanks for the answer.
E.F. Nijboer 14-Jan-15 8:22am    
I personally would go with the TwoLetterISORegionName or ThreeLetterISORegionName. Also, even though a server might be configured towards UK/US, they might have certain settings configured more local. Maybe a check on currency could help out for example because they both have a different kind of dollar. Just another idea you might want to consider. It might also be helpfull to get send RegionInfo and CultureInfo from all the servers and compare and analyze them.
Rob Philpott 14-Jan-15 8:35am    
Worth a try. Unfortunately the same story though GBR/USA/GBR. If that's the way the server has been configured then that's that really.

So if UTC offset < 8, then London else if Timezone contains the world 'Malay' Singapore else HK. Grubby, but seems to work.
E.F. Nijboer 14-Jan-15 12:11pm    
Ah, you already used the TwoLetterISO. But if the current method works it works :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900