|
|
MrSmoofy wrote: Also where the application is installed won't always have internet access to access such a webservice.
Someone forgot to think - did a "manager" describe these restrictions?
How would Microsoft be able to provide updates (aka maintain the list) on a server where there's no internet access? If you can't maintain it, they can't either.
Bastard Programmer from Hell
|
|
|
|
|
Through windows update services. Which would be received from an internal network update server.
So the server is maintained just not directly via the internet to microsoft it's maintained by a central internal update server where the customer controls what windows updates the companies computers get.
|
|
|
|
|
MrSmoofy wrote: So the server is maintained just not directly via the internet to microsoft it's maintained by a central internal update server where the customer controls what windows updates the companies computers get.
Generate the textfile from that server, and distribute it? That way you're not "maintaining" it, and still have it propagate to the rest of the network.
I still doubt that Windows Update actually ever touches that particular registry-key.
Bastard Programmer from Hell
|
|
|
|
|
MrSmoofy wrote: Microsoft is already maintaining the list. We simply want access to that list.
Microsoft provides the list, I doubt that they're adding/removing entries on every Windows update. I'd check that assumption before embarking on a voyage
If they do, then you won't be able to filter out non-countries, as they might add "New York" whenever they feel like it. You'd still need access to the ISO-list to verify whether the new entry is a country or not.
Bastard Programmer from Hell
|
|
|
|
|
I agree with you but those above me maintain that if MS has a list we should be able to use it. My hands are tied on that.
|
|
|
|
|
Technology nor Windows will change to fit the desire of management. They can have the static list that Microsoft provides, or provide their own.
..or they'll have to contact Microsoft and ask for a version that can update the country-list without an internet-connection. Aw, and it should notify your application whenever it downloads a new one.
My apologies for being rude, but this is the fastest way to explain that management is asking for something that's going to be hard to provide, and I think it's relative unfair that they demand something without consulting the expert (that's you) on whether it's possible or desireable.
Bastard Programmer from Hell
|
|
|
|
|
Eddy Vluggen wrote: Microsoft provides the list, I doubt that they're adding/removing entries on
every Windows update.
Can't speak to that list nor to the "every" part but I do know that windows updates change the timezone information. Not just actual hour changes but renaming zones, removing, adding, etc.
And it happens on a fairly regular basis as well although it isn't clear to me why it changes so often.
|
|
|
|
|
jschell wrote: And it happens on a fairly regular basis as well although it isn't clear to me why it changes so often
Geopolitics, countries die and are born constantly.
You got me curious on how you noticed the differences - you comparing registry-snapshots, or did you move from one zone to another during one of those updates?
Bastard Programmer from Hell
|
|
|
|
|
Eddy Vluggen wrote: You got me curious on how you noticed the differences
I needed to insure that a mapped (config) value continued to map against the windows timezones, regardless of how they changed.
So I checked the map against the last map I had. Every time it changed it would produce an error.
|
|
|
|
|
Cool, noted for the next time
Bastard Programmer from Hell
|
|
|
|
|
MrSmoofy wrote: maintain that XML if and when countries change
How often does this happen?
|
|
|
|
|
So what happens in your app when someone selected country 'X' in March 2011 and in April of 2012 country 'X' no longer appears at all in the list that you extract from Windows?
|
|
|
|
|
That's a very very good point thank you. Not sure why I didn't think of that. Maybe that will finally get my way and have the ISO data in a table.
Thanks!
|
|
|
|
|
According to this[^] site (with example code), you should be able to find the conutry names you're looking for in the System.Globalization namespace, using the RegionInfo class.
Will Rogers never met me.
|
|
|
|
|
I send web requests and read data web response:
using (Stream stream = response.GetResponseStream())
{
Data = new byte[response.ContentLength];
int offset = 0;
int count = (int)response.ContentLength;
int nBytes = 0;
int nTotalBytes = 0;
while ((nBytes = stream.Read(Data, offset, count)) > 0)
{
offset += nBytes;
count -= nBytes;
nTotalBytes += nBytes;
}
}
If internet connection is suddenyl down Read() function blocks forever.
Is there a way to avoid it using the same Read() method?
Чесноков
|
|
|
|
|
It won't block forever, only until your network stack notices that the stream is no longer valid. But that can be quite a long time .
The short answer is no, Read is a blocking call. If you want to protect yourself from this possibility, you should do I/O in a background thread, or use asynchronous socket calls (Begin/EndRead etc).
|
|
|
|
|
As Bob already said, Read() is blocking.
As the operation can be long-winding due to the amount of data, the lack of speed of the connection, or the potential failure of the transmission, you should be doing this on a background thread, allowing your app to continue its normal operation (at the bare minimum take care of the GUI), and possibly also allowing you to give up and maybe retry.
BTW: I don't think every data source has to know and provide a ContentLength beforehand, so your approach with a pre-allocated byte array may fail for some sources. The alternative is to capture the data in a more dynamic structure (e.g. a list of arrays, each array holding one Read result) and then rearrange it if necessary. You could use this scheme when ContentLength returns abnormal values, such as zero.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.4
|
|
|
|
|
I already do the reading in the thread.
The problem discovered with wifi internet connection type.
Once the wifi is off Read blocks.
How can I return from the background worker if it is blocked in the Read() method call?
It was supposed to quit the thread if any error happen as it is with internet plugged into LAN.
But wireless somehow blocks the method.
Чесноков
|
|
|
|
|
Have you tried setting Stream.ReadTimeout? Not sure if it will help, but I think it should.
BTW: don't read Stream.ContentLength twice, defensive programming dictates you read it once and store it in a local variable. If it were to change, for whatever reason, your code could be in a lot of trouble.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.4
|
|
|
|
|
yes, thanks, that was the variable to set to, stream.TimeOut
by default it is 5 minutes to read and write, quite large value.
I would never discover the problem had it not been to wifi connection.
It is surprising that ordinary landline disconnection immediatly result in Read() failure but with wifi it waits entire timeout.
Чесноков
|
|
|
|
|
The is no way for TCP to recognize that the other end no longer exists when it is waiting for a response.
So the same is true for any protocol built on it.
There might be situations where some sort of exception results. Maybe. For example I am not sure what the windows IP stack might do if you pull your network cable.
But if you want to deal with all situations and not a just a few then you need to set up a timeout. Either via the protocol itself or via a secondary thread.
|
|
|
|
|
jschell wrote: But if you want to deal with all situations and not a just a few then you need
to set up a timeout. Either via the protocol itself or via a secondary thread
I do set timeout in web request but I do not know how to set it for Read() operation as it just blocks.
Чесноков
|
|
|
|
|
Hello,
Instead of on the aspx page, to have this code on the server side. Can we do this? Especially for the email check and decimals check? Like for the email check i have this set up on the page aspx, \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*? Can add it the same way on the server page, meaning .cs page?
Thanks!
|
|
|
|
|
Do you mean add a RegularExpressionValidator control to the page from the code-behind? If so then yes.
RegularExpressionValidator validator = new RegularExpressionValidator();
validator.ValidationExpression = "...";
Controls.Add(validator);
If you mean can you valid a string in the code-behind, then again yes.
Regex.IsMatch("pattern", stringToCheck);
I know the language. I've read a book. - _Madmatt
|
|
|
|