My dad made the switch from Windows to Linux in his 50's and he's so happy he did. We've been using Windows since 3.1 days, and I never would have thought he'd switch to Linux but he's a full convert now and keeps trying to drag me in with him. I keep trying to like Linux, but I suppose i just dont have the time right now with 3 young kids to sit down and use it enough to feel comfortable with it. I guess I'll just around to it, when i'm in my 50's ;-). So, No you're never too old to learn something new.
Buck_Murdock
Posts
-
Is 50 too old to be learning Linux -
Removing a duplicate row C# and WMII've built an InfoPath form that queries WMI data and displays it in the form so that we can submit the info to a SharePoint list. I'm putting on the final touches and am having problems with one small section. When i query the RAM, i have it display the information into a repeating table. The problem is when i create the repeating table for some reason it duplicates the first row. I found an article on how to remove the first row (http://www.bizsupportonline.net/infopath2007/programmatically-delete-first-row-repeating-table-infopath.htm) I use this same bit of code to remove the first row from another section and it works just fine, but for some reason when i do this very same thing it deletes the first 2 rows. I can't figure out why it works fine in one section but not in the other section, i copied and pasted the same bit of code so it should work the same. If someone could help me figure out what's going on here i'd appreciate it. code sample:
using Microsoft.Office.InfoPath;
using System;
using System.Xml;
using System.Xml.XPath;
using System.Management;
using System.Net.NetworkInformation;
namespace Inventory_Rev1
{
public partial class FormCode
{
// Member variables are not supported in browser-enabled forms.
// Instead, write and read these values from the FormState
// dictionary using code such as the following:
//
// private object _memberVariable
// {
// get
// {
// return FormState["_memberVariable"];
// }
// set
// {
// FormState["_memberVariable"] = value;
// }
// }
// NOTE: The following procedure is required by Microsoft Office InfoPath.
// It can be modified using Microsoft Office InfoPath.
ManagementObjectSearcher searcherMemory =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_PhysicalMemory");
public void InternalStartup()
{
EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading);
}
public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
foreach (ManagementObject queryObj in searcherMemory.Get())
{
int counter = 1;
{
string slot = queryObj["DeviceLocator"].ToString();
string capacity = queryObj["Capacity"].ToString();
string speed = queryObj["Speed"].ToString();
// Create an XPathNavigator to walk the main data source
// of the form.
XPathNavigator xnMyForm = this.CreateNavigator();
XmlNamespaceManager ns = this.NamespaceManager;
// Set the fields in the form.
xnMyForm.SelectSi
-
Unable to get IP Address using WMI and C#I'm working on an InfoPath form that is going to have a repeating table. In this form i'm using C# and WMI to retrieve hardware information for an inventory database. I've managed to figure out how to populate each row with the Network Interface and MAC Address, but i'm having difficulty when trying to get the IP Address, and I suspect i'll have the same problem trying to get the Subnet Mask, so if i can solve one i'll be able to solve the other. The code i'm using is listed below (i stripped out the other code in there for the hardware not related to the Network Info), but when i use this code, in the IP Address field, it shows "System.String[]" instead of displaying the actual IP Address. Can some one please help me? I got my code samples from the WMI Code Creator and manipulated it to fit in with my existing code. It's pretty ugly right now, but so long as it works i dont care.
using Microsoft.Office.InfoPath;
using System;
using System.Xml;
using System.Xml.XPath;
using System.Management;
namespace Inventory_Rev1
{
public partial class FormCode
{
ManagementObjectSearcher searcherNetwork =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_NetworkAdapterConfiguration");
public void InternalStartup()
{
EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading);
}
public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
foreach (ManagementObject queryObj in searcherNetwork.Get())
{
int counter = 1;
//while (rows.MoveNext())
{
string nicName = queryObj["Description"].ToString();
string nicMac = (queryObj.Properties["MACAddress"].Value != null) ? queryObj.Properties["MACAddress"].Value.ToString() : "";
string nicIp = (queryObj.Properties["IPAddress"].Value != null) ? queryObj.Properties["IPAddress"].Value.ToString() : "";
// Create an XPathNavigator to walk the main data source
// of the form.
XPathNavigator xnMyForm = this.CreateNavigator();
XmlNamespaceManager ns = this.NamespaceManager;
xnMyForm.SelectSingleNode("/my:myFields/my:Network/my:AdapterInfo/my:nicName", ns)
.SetValue(nicName);
xnMyForm.SelectSingleNode("/my:myFields/my:Network/my:AdapterInfo/my:nicMac", ns)
.SetValue(nicMac);
xnMyForm.SelectSingleNode("/my:myFields/my:Network/my:AdapterInfo/my:nicIp", ns)
.SetValue(nicIp);
// Increment the counter
counter++;
// Add the item to the repeating table
AddItem(nicName, nicMac, nicIp);
// Remove the first empty item from
-
Help cleaning up C# Code (WMI code) - NeewbieI'm not a programmer by any measure so I'm turning to you all for help. I'm creating an InfoPath form which is housing some C# code to run WMI queries when the form is entered. The user will then enter in a few bits of information about them self and submit the form to a SharePoint library to help keep track of our users inventory. My question is can someone help me clean up this code before i get too far into it? I've been using the WMI Code Creator from Microsoft's Website to get the code samples and by brut force I've gotten them to start to pull the information i'm looking for, but the code seems a little ugly and messy for me. I'm sure there has to be a way to condense some of this code and make it easier to manage and i want to start to figure that out before i get too far, once I see how it's done I should be able to figure it out from there. My code sample just has the video card and the sound card query, but eventually i'll have RAM, Hard drive, CPU, etc. Code Sample:
using Microsoft.Office.InfoPath;
using System;
using System.Xml;
using System.Xml.XPath;
using System.Management;
//using System.Windows.Forms;namespace Inventory_Rev1
{
public partial class FormCode
{
// Member variables are not supported in browser-enabled forms.
// Instead, write and read these values from the FormState
// dictionary using code such as the following:
//
// private object _memberVariable
// {
// get
// {
// return FormState["_memberVariable"];
// }
// set
// {
// FormState["_memberVariable"] = value;
// }
// }// NOTE: The following procedure is required by Microsoft Office InfoPath. // It can be modified using Microsoft Office InfoPath. public void InternalStartup() { EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents\_Loading); } public void FormEvents\_Loading(object sender, LoadingEventArgs e) { ManagementObjectSearcher searcherRAM = new ManagementObjectSearcher("root\\\\CIMV2", "SELECT \* FROM Win32\_PhysicalMemory"); //ManagementObjectCollection oReturnCollection = searcher.Get(); ManagementObjectSearcher searcherDisplay = new ManagementObjectSearcher("root\\\\CIMV2", "SELECT \* FROM Win32\_VideoController