Click here to Skip to main content
12,816,406 members (29,510 online)

Comments by John Simmons / outlaw programmer (Top 200 by date)

   
If you have the xaml way to do it, it's a reasonably simple matter to convert that to c# because XAML is just a markup for the classes that are used.

Voting my answer a one does not compel me to help you further.
   
One solution is to stop using Log4Net.
   
I don't have the file you're working with. I don't have the desire/time to create one. You, on the other hand, have made no visible attempt to try to resolve your issue short of copy/pasting code that understandably may not work for you specifically.

If you expect every solution you get here to fit neatly into what you call "code", you're in for a rude awakening.
   
How to fix it? Hire a programmer.

Have you though of - oh, I don't know - using the debugger to see why it's throwing the exception?
   
What is the error, and when is it thrown?
   
So do you still have a question?
   
Are you using WPF? And BTW, "Control" is a terrible name for a variable. Use "ctrl", or something like that.
   
Updated my answer.
   
The filename has NOTHING to do with the enum as far as parsing dates is concerned.
   
Well, he didn't give us an example of the filename, so how are we supposed to come to that conclusion?
   
Are you sure your user name should include the word "xpert"?
   
Your question is VERY poorly worded, and having an enum has NOTHING to do with what you appear to be asking.
   
I don't think this is gonna help him. Modern versions of Windows sets up barriers between processes to specifically prohibit that kind of access
   
I'm all about instant gratification.
   
What are you using to read the excel file? Every library/framework does it a little differently.
   
He could have a valid business case for this. I needed to do this at work once.
   
You're not going to get two apps that write to the console 200k times to finish in 21 seconds. I got it down to 0.002 seconds only writing to the console one time at the end of the loop. That is your best option if you're looking for performance. In short, stop dickin' around with the console.
   
What is the additional data you're getting that you're not expecting?
   
I don't know what makes you think I don't get reported for being abusive. The number of freakin snowflakes on this site grows exponentially every day.
   
I'd rather be the voice of doom, which is the voice you hear after ignoring the voice of reason.
   
It might help if you metion the fact that you're using the ExcelQueryFactory library, and then what you've actually tried soe that someone can give an answer that gets you where you want to go.
   
Seriously? You down-voted the only answer you got so far from someone with more years of WPF experience than you have in the industry?
   
There is no screenshot.
   
Werd
   
Deleted
https://www.codeproject.com/Answers/1157983/How-to-exclude-lunch-time-from-shifts
   
I changed my answer. Go to the link and scroll down to my answer to that question. There's a class there that should help. Assuming you have the correct connection string, you should be good to go with that code.
   
How to get what?
   
Pay attention to your intellisense. The error it gives you will be explicit and well-targeted.
   
Being a "noob" doesn't excuse laziness (learn to use google, or pay attention to the intellisense popups). I updated my answer.
   
You're either gonna have to use a CSV parser like the one cited in my answer, or you're gonna have to write more code. Doing a simple split won't help you. You haven't really provided enough info to allow anyone to help you.
   
The manifest file doesn't match the dll. Make sure you're adding a reference that has the correct manifest file in the same folder. It's best to delete the reference, get the assembly from nuget, and let it add the reference for you.
   
Maybe Marc can do this in COBOL.
   
I try to answer as many questions as possible with one answer.
   
Try using google translate - type your question in your native language and let google translate it to English. Copy/paste the English translation to your question. DO NOT CREATE A NEW QUESTION. Click the Improve Question link and edit your question.
   
I'm not going to download the necessary code library to find out something you can easily do yourself (since you already have the library in question). I still don't even know what you're asking?
   
Why are all of your classes abstract? In fact, why are ANY of them abstract?
   
Regex? Really? That's kinda like killing a flea with a sledge hammer.
   
You might be able to hook the listview item selection event in the file selection dialog box, but you'd have to google how to do that. I would recommend loading the WindowsAPICodePack with Nuget. They might have a way already built in to do what you need.

   
Seriously man, you gotta at least put some effort into learning about the .net framework.

I edited my response.
   
This has absolutely nothing to do with your original question. If my code answered your question, why did you unmark it as the answer?
   
I have absolutely no freakin idea what you're asking for...
   
If it's solved, mark your solution as the answer.
   
This is NOT a C# question. Pay attention to your tags so you get the appropriate people looking at your question.
   
0) Does your stored procedure work in your database?

1) Didn't your copy of Visual Studio come with a debugger?
   
This is a duplicate of your previous attempt to ask this question (as already cited by Richard). GO BACK to your original question, and click "Improve Question" to update it.

FWIW, I already told you how to load a text file in your previous question. Your stated requirements are all but unintelligible, so your best bet is to also provide an example of the file you're loading - NOT THE ENTIRE FILE, but a representative portion of it. Maybe then, we might be able to make sense out of your apparent gibberish.
   
I'm sure the stuff you're trying would work if you were doing it right. However, there's no way we can help you because you haven't shown us your code.
   
My guess is that all of the files are different, so even if he does figure it out, he'll be back.
   
What would they call oranges if they were a different color?
   
He hasn't tried anything.
He's stuck in a job he can't perform because he probably significantly exaggerated his skill set.
He wants us to write his code for him - for free.
   
Dude. This question is almost 6 years old. Pay attention.
   
Can your client app decrypt the encrypted text?
   
BTW, if you're going to post code snippets, ensure that the code is syntactically correct. Nobody will be able to copy/paste the code you posted without having to edit it once it's in the IDE. That's a pain, and most folks don't want to have to deal with it. Your XAML is not correct since none of the elements names are properly cased.
   
Of course I did. Either way, it ain't gonna work the way you're trying to do it. See my solution.
   
This is not about C#.
   
I don't see how the example you provided that "works" will work. I tried doing that in an app, and it the designer complained about the preview event handler .
   
When you paste it, paste it as a code block, and it should determine the correct language automatically. If it doesn't, make sure the "lang" element is set to "XML".
   
How are you able to generate that output. It's malformed XML. Further, your variable names quite frankly suck since we don't know what "a" is a type of, nor the properties within it, nor why you're using a dictionary.
   
If a sledgehammer does the job, and you have one handy, there's no point in rifling through a drawer to find a nut cracker. I wanted to make sure the process was dead. As a doornail. Besides, there have been reports that the ReleaseComObject call doesn't always work, but that killing the process *does* always work. Either way, my method works just fine.
   
I just kill the appropriate Excel process (see my Close method). That also takes care of it.
   
You have to add a reference to the desired version of the assembly. I have two versions on my work computer - 14 and 15.
   
I think you meant to say that "I'm not doing it right".
   
He's using the Excel.Interop library.
   
I updated my reply to explain in more detail.
   
Try changing the targeted framework in the project using the attribute to 4.5 and see if it still wants a colon.
   
For crap sake, I gotta tell you to do mytime.ToString("HHmm") ? Can't you infer that from my answer?
   
I would do pretty much anything to avoid using Access... and Crystal Reports. Crystal Reports will connect to Sql Server (dont know if it cares WHICH sql server).

Have you considered MySql? It's query syntax is very similar to Sql Server, and I think it comes in various sizes as well - AND it's free.
   
First - do not post your question as an answer.

Second - the op probably won't answer you. This question is more than a year old.
   
Compiler directives are not an indication of the environment under which the application is running. It merely indicates that debug symbols are available. Besides that, you might be running the release version in Visual Studio, and the DEBUG directive won't be present.
   
That doesn't explain why you can't use it. Excel supports 1,048,576 rows by 16,384 columns per worksheet. If your dataset has more rows than that, you're gonna have to break it up into more manageable chunks.
   
Don't ask the same question two different ways.
   
I have no idea what you're asking.
   
I dunno - I was in the middle on own work, and was kinda distracted.
   
I would use various File.IO.Path.Getxxx methods to break the filename apart instead of hard-coding ".csv", but other than that, this is the answer.
   
What do you mean you want all OUs in hierarchical order?
   
Try doing a clean/build entire solution for progA. After that, I'm out of ideas.
   
You still haven't said what isn't correct (that I've seen).
   
Well, I don't jave any idea why it's not working and what you're expecting as far as "matching". IO just tried it in the app I'm writing right now, and the FileVersionInfo data that I get matches what Windows Explorer returns (Explorer doesn't return all of the properties, BTW, but the ones it does return matches just fine).
   
Also, why are you even messing with the file version info in the rc file? The compiler handles all that for you.
   
Are you actually running ProgA when you do this?
   
DO NOT add answers unless it's an answer. MODIFY YOUR ORIGINAL QUESTION.
   
Why did you mark this as the solution when your problem persists? Nobody else (or very few) will look at the question if they think its been answered.
   
Oops - fixed it. That's what I get for typing code directly into the editor instead of using VS and then copy/pasting...
   
So, essentially, you want us to help you fulfill the requirements of your contract? For free?
   
The veracity of your user ID comes immediately into question.
   
Why hit the database again? He has all the info he needs in the datatable object.
   
My solution is a lot like the Kobiashi-Maru hack - it had the benefit of never having been tried before. :)
   
Good answer - there's even sample code.
   
Looking at your data, you won't be able to serialize it to csv format without doing some stuff manually in order to flatten the hierarchy.
   
If you would post this as an answer, I'd give you a five. :)
   
I contacted my spirit animal and even HE doesn't know what you're asking.
   
Do NOT use text speak in your answers. Spell the entire word. Also, an ellipse is almost never the appropriate punctuation with which to end a sentence. Finally, format your code blocks appropriately.
   
Check the source code you pasted. It looks like it got all jumbled up.
   
right
   
I updated my answer.
   
Edit your question to show the entire style for both the base and the derived style.
   
"You can't just dump some bytes into a file and expect that they magically become something else."

Hillary Clinton seems to be able to pull it off...
   
No self-respecting Ford owner would ever put Ferrari badges on their car.

I think FFMPEG will do what he wants.
   
Well then, you also have to parse the make file(s) for include paths. My advice is to find a tool that's already available.
   
Ya know, you'd probably be done with your code if you developed some basic google skills:

https://www.google.com/search?q=sql+get+id+of+last+inserted+record&ie=utf-8&oe=utf-8
   
What code?
   
FWIW, I cannot go to the link you provided (disallowed by our switch configuration). IMHO, your "desired output" is too long and just clutters up your question. A simpler format would go a long way to getting your question answered.

Lastly, it doesn't appear as if you have really tried anything. You've simply posted code that "doesn't apply", but no code showing your attempt at the desired recursive solution.
   
The "why" of it is not relevant, IMHO.
   
If this is the solution to your problem, mark it as the answer.
   
TimeSpan doesn't count months.
   
Is the unmodified query, or the one you "changed the join" on? If it's not the original query *WHICH* join did you change?
   
Maybe your accent is throwing it off.
   
Why do you keep marking my solution as the answer, and then un-marking it?
   
Solution 3 is the answer you want.
   
Better answer than mine. BTW, you can probably resolve the math-induced accuracy problems by rounding the result:

value = Math.Round(Math.Floor(value*100d)/100d, 2);

Also, if the value you're starting with is negative, you have to call Math.Ceiling instead.

value = Math.Round(((value >= 0d) ? Math.Floor(value * 100d) : Math.Ceiling(value * 100d)) / 100d, 2);
   
If your value is 18.1151, what value do you ultimately want to see? According to the way you stated your question, you're expecting "18.11". Is that correct?
   
According to his example and stated requirements, the code I provided is fine. If he needs culture-specific code, I'm sure he'll ask here before trying to figure it out on his own.
   
That's not what he wants (if I'm reading his question correctly). If his value is "18.12345", he'll get "18.00" if he does it your way. He wants "18.12".
   
Then improve your question. When you say "toggle button in a toggle button", I am assuming that you're setting the toggle buttons Content property to another toggle button. If that's NOT what you're doing, then what I suggested will of course not work.
   
I updated my solution.
   
Your code is wrong. It doesn't match your data.
   
This is a C# question, not a C++ question. Your answer is irrelevant.
   
Why aren't you just doing this?

string serialNumber = "h193227" + char(22);
byte[] packet = Encoding.Default.GetBytes(serialNumber);
ns.Write(packet, 0, packet.Length);
   
You have to show us the code you wrote that isn't working. Further, it's not a C# question, so you have at least one invalid tag.
   
List ALL of the things you tried so we don't have to guess and suggest things you've already tried. Saying you "tried many solutions" is absolutely useless.
   
I don't think he wants to change the language for the entire OS, just his app.
   
I wasn't aware that Management Studio could even connect to MySQL databases...
   
Localization is more for things like datetime formatting, currency symbols, etc.

The OS itself determines what language to present to the user, based on user settings.
   
Did you ask the original developer for help?
   
What do you mean by "remove an attribute"?
   
"I tried something but it doesn't work."

BWA HA HA HA HA!
   
Why did you give him a c++ answer?
   
Didn't your instructor show you how to use threads before he gave you this assignment?
   
He was looking for something that would extract the actual customer ID regardless of the inclusion/location of spaces in the string being parsed. See my solution.
   
Why did you mark my solution as the answer, and then unmark it as the answer?
   
However, what RyanDev suggested is the most correct approach. You should be returning the result to the client for processing. That would resolve the issue straight away.
   
It's homework. He may not have a choice, and he instructor probably wants him to come up with his own non-Timer code.
   
How do you know for sure what year the date is?
   
I commented the code in my solution.
   
No, it's executing the action at the randomly selected index. If that happens to be the same value all the time, that's merely an indication of the poorly implemented "random" class in dotnet. Furthermore, it looked like you wanted to remove the action once it was executed. This further reduces the range of values that the random.Next method can return, thus increasing the odds that the randomly selected index will be the same pretty much every time.
   
You haven't actually tried *anything*. The entire class should be highlighted in red in Visual Studio.
   
I tried to format the code block, but CP kept crashing every time I tried.
   
Well, I suppose you would convert the deserialized data to a datatable. I updated my answer to include a method I found using google (google access is free, you should try it).
   
There's more wrong with his code than that.
   
Then you have to know the network (IP) address or machine name of the SQL server you want to connect to, and include that address (along with the name of the sql server instance) in your connection string.
   
So what you're saying is that he can't follow written instructions.
   
Why are you asking this question again?
   
Put a try/catch block around the code and see what's happening in the debugger.
   
His instructor probably told him to use arraylist.
   
FYI, I went to the URL you're using, and the following URLs return the same content:

http://www.realtor.com/realestateagents/New-York_NY/photo-1
http://www.realtor.com/realestateagents/New-York_NY/photo-1/pg-1

That means your if block should probably be "if pagenum >= 2".

See my updated solution message.
   
It goes without saying that we know nothing about the particulars about your setup, but IMHO, y'all need a new DBA and system administrator. Who the f*ck intentionally designs something like that, and who in their right mind would allow that from a sys admin point of view?
   
My point is that you need to change the tag. I did it for you.
   
Where is contentType defined? Are you sure bmpInfo is a valid object?
   
Why is this tagges as a C# question. It has absolutely nothing to do with C#.
   
I was merely giving him the answer he was looking for. I'm not concerned with "efficiency" because it's not *my* code. The call to ToList() isn't even necessary, but that's what he was doing, so that's what I did. As for using linq, linq is known to be slower , especially is you start stacking subsequent linq calls on each other. So, you can see that I'm perfectly aware of the "efficiencies", but chose to ignore them.

TECHNICALLY, my answer is appropriate, and does not warrant your 2-vote. BTW, I didn't notice an answer from you for this question - just criticism of the answers that were already here.

Finally, I know exactly what data he is working with because I answered an earlier question of his regarding the same data set.
   
His problem is that homework is a true bitch when you don't listen in class.
   
escape them by use < and >
   
If you insist on doing it that way, You're going to have to scan the folder manually either before or after firing up the FileSystemWatcher.
   
Sending email from the database itself is bad practice. You can spoof the entire message. I was working at one place where the DBA was pranking a bunch of female employees and setting the from field to other people's email addresses. In today's overly sensitive office environments, that could get someone fired, or worse.
   
I think he wants to send email from the database instead of from the form. Of course, it's hard to say due to his mangling of the English language.
   
You don't use voting for that.
   
Why did you vote 1 on my answer?
   
I update my solution to include some sample SQL.
   
What have you tried? NOTHING
Where are you stuck? EVERYWHERE
What help do you need? SEND ME THE CODEZ!!!!
   
This question has absolutely NOTHING to do with programming.
   
It's a wonder what things you find if you just perform a simple search. Beyond that, it sounds like homework.
   
I updated my answer.
   
To include < and > in a message here, you have to use standard html notation of &lt; and &gt;

I went ahead and fixed your "what I tried" stuff.
   
I haven't done anything. I suspect the last time I visited the question was 5 years ago. I suspect the hamsters are on drugs. Again.
   
It's there, the cut/paste is screwed up on this system (DoD computer on a clown-based network) - I can't paste at all into some sites, and on some sites, it doesn't always paste all the copied text.
   
The connection string is not the problem.

<add name="DevConnection" connectionString="SERVER=[servername];Initial Catalog=[databasename];Integrated Security=SSPI" providerName="System.Data.SqlClient" />

Actual server/db names aren't necessary, and both the server and database in that sql instance exist (I'm sitting here looking at the database in SqlManager right now).

SqlServer 2008 R2.

Like I said, all other database access performed with that connection string work fine.
   
The connection string IS NOT the problem. It works elsewhere in the code, and is not mangled in any way before I use it.
   
Wow. I see the f*cktards are still using the site. Both my question and this solution were down-voted. F*ckin amazing... Don't get me wrong, I don't give a f*ck about the points, but some people really need to grow the f*ck up.
   
And no search engines are displaying - at all - so I can't even continue my search for a solution... I hate having to work on DoD networks...
   
Well, the listboxitem and treeview item styles are in the same file, and they're working. I just added comboboxitem and it ain't workin either...
   
Yeah I know. My problem is that the style override is being ignored (I even tried changing it to the way you have it on the off chance that it would make a diff).
   
I said I'm new to MVC, not a complete f*ckin idiot. I have an existing MVC web site (or app or whatever you feel like calling it). I don't want to lose that site. Can I add something like smartstore to it without overwriting the existing folders/files?
   
I actually came back to say I was missing the css for the various jQuery controls. Added a new bundle for it, and everything is fine (relative term of course, as well as being subject to change).
   
Yes, it's in a {} block. I fingered out what i was doing wrong - I forgot to put , new { @class = "date-picker" } in my TextBoxFor method call. I now have a new problem. The calendar is displayed, but there appears to be no containing div/border.
   
That didn't fix it. :(
   
Changed it to the following, and it still appears to work:

<pre lang="csharp">
static void Main(string[] args)
{
Task[] tasks = new Task[]{CreateTask("Task1", 1), CreateTask("Task2", 5)};
// wait for them
Task.WaitAll(tasks);
}

private static Task CreateTask(string name, int interval)
{
Task task = null;
TaskCreationOptions taskOptions = TaskCreationOptions.LongRunning;
CancellationTokenSource tokenSource = new CancellationTokenSource();
CancellationToken cancelToken = tokenSource.Token;
cancelToken.ThrowIfCancellationRequested();

try
{
task = Task.Factory.StartNew((Object stateObj)=>DoWork(name, interval, cancelToken), taskOptions, cancelToken);
}
catch (AggregateException aggEx)
{
}
catch(Exception ex)
{
}
finally
{
}
return task;
}
</pre>
   
0) Each task has to be run on a different thread.

1) I might need to know when each thread is canceled. Having a single cancel token for each task won't allow that, will it?

2) I thought that I should specify longrunning on threads that run for more than a second or so. Each thread will be running until cancelled by an external source (for days/weeks/months/years).

3) I honestly don't see how this is easier than the classic threading model (something everyone seems to say). Like I said, I haven't been able to find a decent article on TPL (one that explains it in a way I can understand).

I updated my question (after the code block).
   
A task isn't necessarily a thread, and I need them to run at the same time. They don't have to interact, but they do need to run side-by-side.
   
WTF are you talking about?
   
Erp - found it - I had an extra parenthesis
   
It's been modified to fit my table/column names, but when I copy paste direct from your answer, it works...
   
i did, and now i'm getting "incorrect syntax near T"

(I wanted to make sure I hadn't missed anything before posting this)
   
yeah - colons for eveyone :)
   
Yeah - it's the typical useless "problem by xyz" error
   
Deleted
sql server 2008R2 - i don't think it supports partition_fragment_id
   
works great for old dates that have no values for some names, but if I use 12 and 2014, if should give me the next earliest value (11 2014).
   
Honestly, I don't know how to approach it. I'm not even sure how to ask the freakin question (makes it real hard to google). My brain is completely failing to engage... :)


Yes on the year for Don. Not all names will have a changed value in a given year, and I wanted to return a valid row for each name regardless of stupid user tricks.
Further, new names might be added in the future which of course won't have past values.
   
I already solved the problem. Read the first soltuion.
   
Not in this case, no.

   
I suppose that kinda makes sense...
I took out the code I thought might be the culprit, and no change...
   
I also tried it, and it almost matches. I have an intranet site up, and the innermost child window in the client area (it's a Internet Explorer_Server class) isn't being enumerated, but I think getting the parent TabWindowClass window will be sufficient.
   
I tried putting a Thread.Sleep(5000) after the process was started and went into InputIdle, and BEFORE calling EnumChildWindows. It didn't change the behavior.
   
EnumChildWindows is *supposed* to enumerate all child windows and their children - if you recurse, you'll get all the windows more than once. My problem is that it's not even getting all of the main IE window's child windows. I don't know if this has anything to do with it, but it only found child windows that don't have their own child windows. These child windows are also the first two I see with Spy++.

If you open IE and then inspect the window with Spy++, you'll see what I mean.
   
If you're not going to answer the question, STFU.
   
Nope, spent the last couple of days putting together screen shot code. Gonna try it on Monday. :/
   
I can't install any new software (I'm on a DoD system), so even if it worked, I can't use it.
   
I'm on Win7 running IE9 on a DoD system. I can't upgrade, and my end user(s) are in the same boat.



It's starting to look like I have to take screen shots and compare them for differences... Not happy about that...


Have I mentioned yet that I hate flash?
   
Fiddler doesn't show *any* traffic once I get to the site. I hate flash...

I just checked DevTools and all it shows on the page is a clsid...
   
0) I have a project originally started in VS2012

1) I added a User Control to the app project

2) I compiled the solution

3) I added the new user control to the mainwindow xaml

4) I added the namespace definition ( xmlns:local="clr-namespace:myproject" )

5) I get the "error" stating the name can't be found in the namespace

6) App compiles and runs despite that "error" (WTF #1)

7) I changed the namespace declaration to include the assembly name

8) The "name doesn't exist" error went away, only to be replaced by "the tag "controlname" doesn't exist in the XML namespace" (WTF #2)

9) The app will now not compile.

10) I'm pissed off.

   
WTF are you talking about? Why would you think even for a second that I didn't "make a selection"? Intellisense sees it - I select it - code doesn't f*ckin compile (or I get an error and it compiles any way). Where's the logic in that?
   
No, I don't get it - not at all. If intellisense can find it when I actually add it to the XAML, why doesn't it compile? We're talking about controls here that are nothing more than the template code provided by VS, and I'm not getting errors regarding those controls. Further, they are in the same assembly AND namespace as the main window whch is actually hosting the control. The entire soution is essentially a flat hierarchy with no additional projects or folders (yet).

I had to remove the xaml that uses the controls so I could code other parts of the app.

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid