|
jdunlap's correct. Unless the UPS is connected to your computer by something other than your computer's power cord, there's no way for your computer to know.
Old UPS's used serial ports, and a lot of the newer ones use USB, but in either case the UPS has to "tell" the computer. Take a look at the documentation for your UPS.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
I am trying to add an arraylist to a datatable. The ArrayList contains a struct and the the struct basically holds several object variables. I use a foreach statement to loop through the arraylist and add the data to a datarow then add the datarow to a datatable. However, when I try to add the second datarow I get an error message saying 'This row already belongs to this table'. Even though I know the data has changed the it is a completely different row. I am including my code snippet, any suggestions is appreciated:
r = DataSet.Tables["TradeOrderFills"].NewRow();
theData = (ArrayList) oFills.GetByIndex(0);
Console.WriteLine("theData count "+theData.Count);
foreach(TradeData td in theData)
{
Console.WriteLine("Adding Row to DataTable");
Console.WriteLine(td.ticker);
r["preTicker"] = (string)td.ticker;
Console.WriteLine("column value "+r["preTicker"]);
Console.WriteLine(td.transactionType);
r["preTransType"] = (string)td.transactionType;
Console.WriteLine("column value "+r["preTransType"]);
r["preOrderTime"] = (string)td.orderTime;
r["prePrice"] = Convert.ToSingle(td.price);
r["preQ"] = Convert.ToSingle(td.fillQ);
r["preAccount"] = (string)td.account;
r["preBroker"] = (string)td.broker;
r["preStatus"] = (string)td.status;
DataSet.Tables["TradeOrderFills"].Rows.Add(r); //THIS IS WHERE THE ERROR OCCURS ON THE 2nd ITERATION
Console.WriteLine("Number of Rows "+DataSet.Tables["TradeOrderFills"].Rows.Count);
}
|
|
|
|
|
Move your first line:
r = DataSet.Tables["TradeOrderFills"].NewRow();
inside the foreach loop.
What you were doing is inserting the same physical row each time, but just changing the data it contained. You need to create a new physical row on each iteration.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|
|
How do I create a new GUID using C#?
I tried this but it shows up as 00000000-0000-0000-0000-000000000000.
Guid guid = new Guid();
Console.WriteLine( guid );
|
|
|
|
|
Try the static method Guid.NewGuid()
You can find more information on MSDN[^]
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|
|
Thanks!
|
|
|
|
|
I have a class library project that gets its configuration from a customm configuration section (using the System.Configuration.IConfigurationSectionHandler interface and friends). When I want to access my configuration section, I make a call to ConfigurationSettings.GetConfig("BarcodeLoggingConfig") and voilà !
This morning my boss asked me if I could make it dynamic, meaning that if somebody changes the configuration, the client application updates itself (like a service that you don't have to restart if you change the config).
Is there such functionality in the .NET Configuration?
I know that I could use the FileSystemWatcher and easily figure out the configuration file name, but what if the application is ASP.NET and has a hierarchy of web.config files?
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
You could setup a file dependency on the config file.
As for ASP.NET, the changes will happen automatically the next time the user reloads or refreashes the page.
|
|
|
|
|
This isn't the only thing that needs to be done, though. Yes, you could use a FileSystemWatcher to watch the .config file for changes, but once an AppDomain has been created and the config file read, it won't get read again (it's cached). Instead, you have to have a separate process (or use the same process, which must start your main app in a separate AppDomain ) that watches for changes, notifies your app to quit (or have your main app watch for changes, and the loader restart it when the app exits with a certain exit code). It creates the AppDomain with your custom AppDomainSetup for the AppDomain.SetupInformation , launches your process using AppDomain.ExecuteAssembly , and, thus, respawns your process.
I have covered this in more depth before. Please search the forum comments for keywords like AppDomainSetup for more information.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is it a bug of a feature that AcceptButton only seems to work with Form.ShowDialog() and not with Form.Show()? That is, when a form is displayed with Show(), the Enter key is ignored, but with ShowDialog(), the Enter key causes the form to be accepted (OK).
Arun
|
|
|
|
|
Hmm... would that be because the modal nature of a dialog box? It seems logical to me that a modal dialog could be dismissed with an accept button, but not necessarily a modeless form.
|
|
|
|
|
I think that it has to do with the ShowDialog [^] form being modal, and that Show [^] is inherited from Control [^], which only makes the Form visible. When it's modal, it's usually a form in which the user has to give some input, and press Enter to accept (or Esc to cancel).
- Daniël Pelsmaeker
There are 10 kinds of people in the world. Those that understand binary and those that do not.
|
|
|
|
|
I have a worker thread that is implementing a TcpListener socket. The Thread is blocking on the AcceptSocket method of TcpListener, which is fine. My problem is closing the blocked thread. I'm using:
Thread.Abort() and Thread.Join() to attemp to stop the thread and wait for it's termination but it apears that the Abort method does not throw the ThreadAbortException that it is supposed to. Any thoughts ?
|
|
|
|
|
Take a look at this.
Basically, all bets are off on aborting threads using certain system resources, like sockets. That's probably why it's not working, but I'm not sure of the best solution for you (would need some more info I think).
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Hello all, I am writing a windows service that I plan to run in a machine that has the .net framework but without the .net ide. I am curious as to how i will go about installing the service if i can not access the visual studio .net command prompt? Any help would be appreciated...
Frank
|
|
|
|
|
All tools for installing .NET services are in the .NET Framework. InstallUtil.exe is the one you want. located in:
%WINDIR%\Microsoft.NET\Framework\%version%\InstallUtil.exe
Jonathan 'nonny' Newman
blog.nonny.com [^]
|
|
|
|
|
Besides what Johnny said, you'll also need to implement an Installer class that uses the ServiceInstaller and the ServiceProcessInstaller . If you use the VS.NET designer to create this, they should already be there. Just tweak the properties to get what you want (like a display name and under which credentials to run it). If you didn't use VS.NET to create this (using the Add->Windows Service method), you'll need to create these yourself, but it isn't hard. See the documentation for these two classes for examples.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I like to serialize user entries to an xml-file. Therefore i ceated a xml-serializable class.
Cause I have to deal with more than one user I have to store different user entries.
Therefore I want to "collect" all user's entries in the same xml-file.
Then that i can navigate through my single xml-file and fetch all informations applying to the current user.
I haven't found an answer yet. Is it possible at all? Or have i to serialize "manually", meaning append nodes and elements by the xml-document-methods to the xml-file?
I hope i could figure out my problem understandingly.
|
|
|
|
|
Serialize to a MemoryStream , then get the child nodes of the document element and append them to the document element of your existing file.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I've been all over the MSDN library looking for a list of all the available built-in attributes and what thay do. I found a bunch of stuff about what they are and how to make my own but very little about the pre-defined ones.
Anybody know where to look?
Thanks,
Ken Galer
Electrical Engineer
Preferred Utilities Corp.
Danbury, CT 06810
|
|
|
|
|
Look at the documentation for the System.Attribute class. It has a Derived Classes link that gives all the direct derivitives, which you can then recurse into and find their derivitives, and so on.
As far as component development goes, a lot of useful attributes (probably the majority of the attributes you would use when creating a control library) are in the System.ComponentModel namespace.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Found it! Thank you.
In fact, I was there at one time and didn't reconize it.
Ken
Ken Galer
Electrical Engineer
Preferred Utilities Corp.
Danbury, CT 06810
|
|
|
|
|
First of all, hi to everybody, it´s my first post And sorry for my english I am from Spain.
Well I am making a little app that write questions with their answers into an xml file. I am using a treeview to display the data.
The question is the top node, and in it there are subnodes each for an answer.
I know how to see which node was selected with this code:
<br />
if(this.IsNode(tree.GetNodeAt(this.tree.PointToClient(Cursor.Position)))==true)<br />
Where IsNode is:
<br />
private bool IsNode(TreeNode node)<br />
{<br />
try<br />
{<br />
string foo = node.Text;<br />
return true;<br />
}<br />
catch<br />
{<br />
return false;<br />
}<br />
}<br />
My question is:
How can I see if an subnode is selected or an node? I want to show an menu for answers and another for question.
Thanks a lot
|
|
|
|
|
You are doing it the hard way.
There is an easier way to get what you want, by using the TreeView.SelectedNode [^] property. This property returns the currently selected TreeNode , or null if no node is selected.
Now you can test whether the returned TreeNode is a subnode. Remember that a root node doesn't have a Parent node, so we test that:
public bool IsSubnodeSelected()
{
TreeNode selected = MyTreeView.SelectedNode;
if (selected != null)
{
if (selected.Parent != null)
return true;
}
return false;
}
The above method would return true if a subnode is selected, and false when a rootnode or no node is selected.
- Daniël Pelsmaeker
|
|
|
|
|
Thanks a lot, it works but SelectedNode doesn´t work with right click so I use:
<br />
private bool IsSubNode()<br />
{<br />
TreeNode selected =treeview.GetNodeAt(this.treeview.PointToClient(Cursor.Position));<br />
if (selected != null) <br />
{<br />
if (selected.Parent != null)<br />
return true;<br />
}<br />
return false;<br />
}<br />
GetNoteAt with Current Mouse Position works with right click, now subnode works, and I can follow with my little app, thank you
|
|
|
|