|
Thank you, Xmen, but the PowerOff and ForcedPowerOff enum values are deceptive. Yes, they do power off the computer, but they also shut down Windows before then. I was looking for a way to power off the computer without wasting time shutting down Windows (the computer just goes silent right after I double-click something.exe on my desktop). But, thanks anyway!
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Hi all, quick question, using the following
using(DataModel.DatabaseDataContext context = GetDatabaseContext())<br />
var result = from b in context.Branches<br />
where b.Id == id<br />
select new Branch()<br />
{<br />
Id = b.Id,<br />
RowVersion = b.RowVersion.ToArray(),<br />
Name = b.Name,<br />
Description = b.Description<br />
};
I get a compiler error stating that an embedded statement cannot be a declaration or labbeled statement. I believe this is related to the return type from the Linq statement.
Is anybody able to point me in the correct direction of what this type should be? I have tried several types and get the impression that I have a fundamental misunderstanding.
Just racking up the postings
|
|
|
|
|
Did I understand correctly that you're querying for branches which have a specific id? I that's correct, I think it could be something like:
using(DataModel.DatabaseDataContext context = GetDatabaseContext()) {
var result = from b in context.Branches
where b.Id == id
select b;
foreach(Branch branch in result) {
...
}
}
|
|
|
|
|
How to have access the drivers and API?
|
|
|
|
|
|
|
I got a gridview with 12 unbound columns that is gonna be exported to Excel document. The exporting is already done but here is where im failing. Some cells can be empty in the gridview and trying to get its value will result in error: "Object reference not set to an instance of an object". Value property doesnt even seem to exist if its an empty cell.
This is how i do it now. Im sending the gridviews rowcollection to the method that exports it to excel. There i get the value from a cell with rows[index].Cells["columnname"].Value. Temporarily fixed it now with a try catch for every column as i got tired of it, but there must be another way.
|
|
|
|
|
I just did this a couple of days ago. Check for rows[i].Cells[j].Value == null. If my whole row is null I don't send that row since the gridview automatically creates the row and I may not have used it. Otherwise, set the data for that cell to "" so it doesn't cause an error.
string getCellValue(int row, int cell)
{
string rtn = "";
if (dataGridView1.Rows[row].Cells[0].Value != null) {
rtn = dataGridView1.Rows[i].Cells[0].Value.ToString();
}
return rtn;
}
But I like this better
string getCellValue(DataGridViewCell cell)
{
return (cell.Value != null ? cell.Value.ToString() : "");
}
SS => Qualified in Submarines
"We sleep soundly in our beds because rough men stand ready in the night to visit violence on those who would do us harm". Winston Churchill
|
|
|
|
|
I am creating a program that will simulate the functions of a robot by parsing a log file created by another program for a school placement. The problem here is I'm not really a programmer, I am a hardware/network guy but they assigned me this task anyways. If anyone can help with some resources that would help me out with this would be grateful.
|
|
|
|
|
There are many tool available in the market to read the log files.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
What format are your log files in, do you know? By that I meant do you know what program wrote them? or where they handwritten so to speak? If manual, do they follow a schema? (I'm thinking XML here)
|
|
|
|
|
The log is actually not really a file but created in ram and shown in a console like interface. However, I am not getting into that mess and have decided that the process to get the simulation running would be done by simply copying the log and pasting into a notepad document and saving. Short answer: txt. The logs are very structured and follow strict set of rules. I made a short set of instructions and this is what was spit out:
D 10:44:57 Starting program "Prog1" (lines 1 to 5)
A 10:44:57 initializing instrument
E 10:44:57 Line 1 : Dispense
tip 1 : dispense 0.00nl 1, 1 Deep Well, landscape [1,1]
10.00µl ">> Water << 23" Fixed <3 - 50µl> Single
E 10:44:59 Line 2 : Aspirate
tip 1 : aspirate 0.00nl 4, 5 Deep Well, landscape [1,2]
0.00nl "Water" Fixed <all volumes> Single
E 10:45:01 Line 3 : Aspirate
tip 1 : aspirate 10.56µl 4, 4 Deep Well, landscape [1,2]
10.00µl "Water" Fixed <3 - 50µl> Single
E 10:45:03 Line 4 : Dispense
tip 1 : dispense 20.56µl 6, 3 Deep Well, landscape [1,1]
10.00µl ">> Water << 23" Fixed <3 - 50µl> Single
E 10:45:05 Line 5 : Wash Tips
wash (2ml + 1ml), grid 20 and grid 20
|
|
|
|
|
To do it in a hurry, just infer what it looks like and parse it manually. If you want a more robust solution, write out a formal grammar for it, and use something like Percenburg Grammatica.
Theres another nice one whose name escapes me, which is used declaratively instead of using a grammar file and codegen. Argh. Ahah. Irony. Thank you CP search :P
|
|
|
|
|
Sorry about that. Time difference and everything.
Do you have a formal structure for it? If you do, its real easy to translate that into an XSD (XML Schema Document) after which you'd write a DOM parser (there are lots of free tools that can do it for you so you don't have to muck around with actually writing the parser), if you don't then there's no easy way about this and you're going to have to write your own parser.
|
|
|
|
|
|
|
|
I don't know about anybody else, but I use a transparent Panel to select the area of the screen to capture, then:
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap
(
this.pPanel.Width
,
this.pPanel.Height
) ;
using ( System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage ( bitmap ) )
{
gr.CopyFromScreen
(
this.pPanel.PointToScreen ( new System.Drawing.Point ( 0 , 0 ) )
,
new System.Drawing.Point ( 0 , 0 )
,
this.pPanel.Size
) ;
try
{
System.IO.StreamWriter sw = new System.IO.StreamWriter
(
new System.IO.FileStream
(
this.dlgFileSave.FileName
,
System.IO.FileMode.Create
,
System.IO.FileAccess.Write
,
System.IO.FileShare.None
)
) ;
bitmap.Save ( sw.BaseStream , System.Drawing.Imaging.ImageFormat.Png ) ;
sw.Close() ;
}
catch ( System.Exception err )
{
System.Windows.Forms.MessageBox.Show
(
"Could not open file\n" +
err.Message
,
"File open error"
,
System.Windows.Forms.MessageBoxButtons.OK
,
System.Windows.Forms.MessageBoxIcon.Exclamation
) ;
}
}
|
|
|
|
|
|
You don't - if you didn't get an answer you're happy with, then you probably won't get a better one this time around
|
|
|
|
|
|
And what if I started a discussion, and made some progress since and want to ask further related question? what would you suggest?
|
|
|
|
|
If you reply to someone, they'll get an email notifying them of the reply.
If you've got a whole new question to ask, then it's fine to post this as a new thread - it's mostly protection against the idiots who post stupid / impossible questions, and would just constantly bump their thread to the top if given the chance (they already try reposting the same question over and over, but that's easier to ignore)
|
|
|
|
|
By bouncing do you mean stopping a service/thread and then restarting it?
If no, then you need to explain what bounce is.
If yes, then if you're momentarily halting the thread, like pressing the pause button, then you could use Thread.Sleep()/Interrupt()/Join(), more on that here: http://msdn.microsoft.com/en-us/library/system.threading.thread_members.aspx[^]
If you mean pausing the application mid activity and then closing it and once the application is run again you would expect the system to pick up from where you left off, you'll need to save state and that would at the least require serialization.
|
|
|
|
|
I think he means "bump" a thread as in a forum post. As in bring it back to the top. As in the thing we hate and pour scorn on whoever does it.
|
|
|
|