|
Ahh... and it is by design. A little further reading indicates that when redirecting io the underlying io and error streams Console object has NOTHING to do with the console screen that might be displayed albeit blank. This was lost on me initially.
Console class members that work normally when the underlying stream is directed to a console might throw an exception if the stream is redirected, for example, to a file. Consequently, program your application to catch System.IO..::.IOException if you redirect a standard stream.
http://msdn.microsoft.com/en-us/library/system.console.aspx[^]
|
|
|
|
|
Console has a LargestWindowWidth property, you could try to check what value has when RedirectStandardOutput is true.
|
|
|
|
|
string dateStr = DateTime.Now.Day.ToString("00") + DateTime.Now.Month.ToString("00") + DateTime.Now.Year.ToString();
string timeStr = DateTime.Now.TimeOfDay.Hours.ToString("00") + DateTime.Now.TimeOfDay.Minutes.ToString("00") + DateTime.Now.TimeOfDay.Seconds.ToString("00");
string path = FileOutputDir + GetProviderName() + "-Summary-" + dateStr + "-" + timeStr + ".csv";
Another gem, from the gem of a project I've inherited. Now:
string path = string.Format("{0}{1}-Summary-{2}", FileOutputDir, GetProviderName(), DateTime.Now.ToString("ddMMyyyy-HHmmss") + ".csv");
[Edit]
I've now just discovered the method containing this code never gets called. Its a good job wwe don't have any unit tests, or I'de have to remove those too.....
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Given the number of posts about DateTime and its formats posted here, I am totally unsurprised.
|
|
|
|
|
i get that a lot from ppl that "think" they know how to code... rather than taking the shorter quicker way to do it they take the longer, "Look at all the code ive wrote to look cool" way of doing it in the off chance it baffles with obsufacation...
View my CodePlex Projects here -> http://www.codeplex.com/site/users/view/john_crocker
|
|
|
|
|
string.Format("{0}{1}-Summary-{2:ddMMyyyy-HHmmss}.csv", ...
But please use an ISO 8601 compliant format: yyyyMMdd
|
|
|
|
|
Yep (& I should have spotted it ), except for the ISO 8061 bit, that's out of my hands...
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
OK I understand whats wrong with those:
string dateStr = DateTime.Now.Day.ToString("00") + DateTime.Now.Month.ToString("00") + DateTime.Now.Year.ToString();
string timeStr = DateTime.Now.TimeOfDay.Hours.ToString("00") + DateTime.Now.TimeOfDay.Minutes.ToString("00") + DateTime.Now.TimeOfDay.Seconds.ToString("00");
I would have been easier to do: DateTime.Now.ToString("mmDDYYYY") or whatever the format string was.
But I'm not quite sure what's wrong with these:
string path = FileOutputDir + GetProviderName() + "-Summary-" + dateStr + "-" + timeStr + ".csv";
string path = string.Format("{0}{1}-Summary-{2}", FileOutputDir, GetProviderName(), DateTime.Now.ToString("ddMMyyyy-HHmmss") + ".csv");
|
|
|
|
|
I think that the OP is saying that he replaced the first example block of code with the second. The first block is what it used to do; the second block is what it does now. Although, apparently it never gets called anyway so the whole thing is academic.
|
|
|
|
|
Exactly so!
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
That's nothing. Check this piece of pure art.
public static string GetStringDate(DateTime dt)
{
StringBuilder sb = new StringBuilder();
int mnth = dt.Month;
if (mnth < 10)
{
sb.Append('0');
sb.Append(mnth);
sb.Append('_');
}
else
{
sb.Append(mnth);
sb.Append('_');
}
int day = dt.Day;
if (day < 10)
{
sb.Append('0');
sb.Append(day);
sb.Append('_');
}
else
{
sb.Append(day);
sb.Append('_');
}
sb.Append(dt.Year);
return sb.ToString();
}
Among other spectacular utilities
|
|
|
|
|
Epic! Especially the sb.Append('_');
|
|
|
|
|
final boolean bKVSatzInklSonderbeitragProperty = getModulContext().isKVSatzInklSonderbeitrag();
final boolean bKVSatzInklSonderbeitrag = m_oKV_SatzInklSonderbeitrag.isTrue();
if(!(bKVSatzInklSonderbeitragProperty && bKVSatzInklSonderbeitrag
|| !bKVSatzInklSonderbeitragProperty && !bKVSatzInklSonderbeitrag)) {
if(bKVSatzInklSonderbeitragProperty) {
m_oKVSatzNeu.setDouble(m_oKVSatzNeu.getDouble() + 0.9);
}
else {
m_oKVSatzNeu.setDouble(m_oKVSatzNeu.getDouble() - 0.9);
}
}
return m_oKVSatzNeu;
I never finish anyth...
|
|
|
|
|
|
Or even:
if (bKVSatzInklSonderbeitragProperty ^ bKVSatzInklSonderbeitrag)
{
double dSatz = m_oKVSatzNeu.getDouble();
dSatz += 0.9;
if (bKVSatzInklSonderbeitrag)
dSatz -= 1.8;
m_oKVSatzNeu.setDouble( dSatz );
}
else
throw ArgumentException("Ha ha, see how smart my validation code is, eh?");
Greetings - Jacek
|
|
|
|
|
I think he's trying to do an exclusive or. If I'm interpreting that right, it boils down to:
NOT (both true OR both false)
|
|
|
|
|
yes, think so too. unfortunatly he managed to compare one boolean with itself, which makes it nonfunctional.
I never finish anyth...
|
|
|
|
|
I agree with KarstenK
it boils down to:
if(A!=B)
{
if(A)
{//do stuff}
else
{// do something else}
}
|
|
|
|
|
TorstenH. wrote: yes, think so too. unfortunatly he managed to compare one boolean with itself, which makes it nonfunctional.
It looks like he's comparing two similarly-named but different properties (bKVSatzInklSonderbeitragProperty and bKVSatzInklSonderbeitrag). The code is redundant in that it would be more efficient to say:
if (a && !b)
action1();
else if (b && !a)
action2();
than to say
if (!!(a) != !!(b))
{
if (a)
action1();
else
action2();
}
which is what the latter effectively does. On the other hand, the latter formulation would allow code to be executed before or after action1/action2 any time either was executed (e.g. if action1 or action2 set a visual property for a control, one could use common code to force a refresh).
|
|
|
|
|
nop, it was the exact same boolean, read from an property-file. He just needed to name it different due to some strange java code convention
so in this case it comes to:
if(!(bConditiontrue && bConditiontrue || bConditionfalse && bConditionfalse)) {
if(bConditiontrue) {
doSomething();
}
else {
doOpposite();
}
}
or simpler:
if (bConditiontrue) dosomething();
I never finish anyth...
|
|
|
|
|
nop, it was the exact same boolean, read from an property-file.
One of them seems to have been accessed via getModulContext(), and the other one not, so I don't see that it's obvious from the code snippet posted that they would always return the same thing (both with the code as it is, and with adaptations that might occur to various other parts of the code).
|
|
|
|
|
I tell people and tell people and tell people to use parens and not assume people know operator precedence.
People tell me I'm stupid. I choose to believe they mean for saying use parens.
Walk through it and change the values in the debugger and make a state table.
I also go with the XOR interpretation.
Opacity, the new Transparency.
|
|
|
|
|
We have a webpage that contains a table with collapsible sections. Straightforwardly, the code behind the show/hide links took the approach of (1) searching for the tr elements that need to be toggled, and (2) changing the .style.display property to "" or "none" as appropriate.
Less straightforwardly, step #1 was implemented not with DOM methods, but by searching the innerHTML for a string starting with "<TR ID=DISPFILE_". In uppercase, so it wouldn't work on Firefox which normalizes the tag names to lowercase.
At least the original programmer was consistent: Step #2 was implement by a similar text search for "STYLE='display: none'".
|
|
|
|
|
Firstly, -10 points for using nulls on a green field development in my book.
Then I found these fields at the top of the class:
internal class BarHelper : FooHelper
{
decimal? _decimalNull = null;
short? _shortNull = null;
int? _intNull = null;
bool? _boolNull = null;
DateTime? _dateTimeNull = null;
}
What are these for I wondered? A find reference on _decimalNull yeilds:
_bazTableAdapter.InsertRow(
cashbackAmount != null ? cashbackAmount.ValueAsDecimal : _decimalNull,
cashbackAmount != null ? cashbackAmount.CurrencyAsShort : _shortNull,
billAmount != null ? billAmount.ValueAsDecimal : _decimalNull,
billAmount != null ? billAmount.CurrencyAsShort : _shortNull,
billAmount != null ? billAmount.ConversionRateAsDecimal : _decimalNull);
It's all just wrong (including the DataSets and Table adapters) and just makes me want to weep. Even just using cashbackAmount != null ? cashbackAmount.ValueAsDecimal : new Nullable<decimal>() would have been an improvement. On the plus side, as I'm being repeatedly told, we don't have time to do it properly.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Awesome code. Can I use it in my application or is it licensed?
Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|