|
If WMI won't show you the right value, I would suspect that nor will the managed methods to query that kind of thing, as they are probably a thin cover.
|
|
|
|
|
Hi Bob,
Thanks. Any idea on how to obtain that information with unmanaged code? I've noticed that the registry does not contain it either, although I found a key that contains part of the information
HKLM\System\CurrentControlSet\Enum\PCI\VEN_8086&DEV_105E&SUBSYS_135E8086&REV_06\FF[last six of MAC here]00
Any idea how intel is using this to create the entire 12 character MAC address?
|
|
|
|
|
Sorry but no, I've not done anything like this.
|
|
|
|
|
In case anyone else runs into this ... Intel creates its own WMI entries.
They are available at root\IntelNCS2, if you do an enumeration of all values you can find just about all you need with the following select * where :
IANet_PhysicalEthernetAdapter
IANet_EthernetAdapter
IANet_LogicalEthernetAdapter
IANet_Setting
IANet_TeamedMemberAdapter
IANet_TeamOfAdapters
IANet_TeamSettingEnum
By doing this, you can get MAC's, names, display names, etc.
I found this by enumerating through all of the wmi classes on this box by tweaking the code below, and then searching for the IntelNCS2 classes once I identified the Intel namespace.
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
namespace MyConsoleApplication
{
class Program
{
static private void GetWmiNameSpaces(string root)
{
try
{
ManagementClass nsClass = new ManagementClass( new ManagementScope(root), new ManagementPath("__namespace"), null);
foreach (ManagementObject ns in nsClass.GetInstances())
{
string namespaceName = root + "\\" + ns["Name"].ToString();
Console.WriteLine(namespaceName);
GetWmiNameSpaces(namespaceName);
}
}
catch (ManagementException e)
{
Console.WriteLine(e.Message);
}
}
static void Main(string[] args)
{
GetWmiNameSpaces("root");
Console.ReadKey();
}
}
}
|
|
|
|
|
hi
how we can add two number with n digit?
|
|
|
|
|
Please tell me you are not asking how to add two numbers. Please clarify
No comment
modified on Wednesday, August 24, 2011 10:22 AM
|
|
|
|
|
Break the number up into machine size chunks, start with the least-significant chunks, add those up. If they overflow, carry the overflow to the next two chunks in line: add those up, and add 1 for the overflow from the previous if applicable.
Repeat this process until you have reached n bits.
|
|
|
|
|
At some point in this process, it may be necessary to remove shoes in order to continue the algorithm.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Giving you the benefit of the doubt that this isn't an idiot question and you're asking about numbers that would overflow ulong: use BigInteger. It has arbitrary precision, so you can use it to do arithmetic on numbers of any size.
|
|
|
|
|
BobJanova wrote: It has arbitrary precision
I prefer "almost unlimited" precision, makes the results more trustworthy.
|
|
|
|
|
Hi
I have following loop. With one of the workflow, rangeDataMappingsToClear gets 100,000 records and rangeKeyMappings gets 10,000 records. This is taking long time hence application hangs.
How to simplify this loop?
List<string> rangeDataMappingsToClear= new List<string>();
Dictionary<string, object> rangeDataMappings = new Dictionary<string, object>();
Dictionary<string, List<string>> rangeKeyMappings = new Dictionary<string, List<string>>();
foreach (string key in rangeDataMappingsToClear)
{
rangeDataMappings.Remove(key);
foreach (List<string> formulaKeys in rangeKeyMappings.Values)
{
while (formulaKeys.Remove(key)) { }
}
}
rangeDataMappingsToClear.Clear();
|
|
|
|
|
you seem to need two nested loops, nothing can remedy that, unless your problem would allow for a different data structure altogether.
However, if you have 100K rangeDataMappingsToClear elements, and only 10K rangeKeyMappings elements, that would indicate rangeDataMappingsToClear holds lots of duplicates; the first step would be to simplify rangeDataMappingsToClear, eliminating the duplicates. Either make sure you don't cause duplicates (that is the cheapest solution), or create a new collection holding all the distinct elements just once; a Dictionary or HashSet could simplify this step.
|
|
|
|
|
As Luc has alluded to, if one of the issues is that the rangeDataMappingsToClear list does contain a lot of duplicates, a quick and dirty fix could be to use the Distinct method
foreach (string key in rangeDataMappingsToClear.Distinct())
"You get that on the big jobs."
|
|
|
|
|
I'm not sure, but you could perhaps create a new list from rangeKeyMappings by applying a lambda expression on it that does not take the values containing a key. Wild guess though.
V.
|
|
|
|
|
Do you have to use List? Or can you use Hashset?
|
|
|
|
|
Hello Experts,
I would like to ask if what are some easier ways preventing multiple log in of account to my web application.
I tried creating a flag field to my database that check the user if he or she is log in but its not good way because if he/she is not properly log out then the account will be lock and I will need to open his/her account manually. Done a couple of research but still I'm not able to.
Here is that code I manage to covert that previously in vb.net not sure though if my code 100% corrent or my conversion of the is ok. The code I managed to find is here http://forums.asp.net/t/1196897.aspx[^]
My code in Global.asax
protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
if (HttpContext.Current.Session != null)
{
Response.Write("SessionID:" + Session.SessionID.ToString() + "User Key:" +(string)Session["users"]);
if (Session["users"] != null)
{
String sKey= (string)Session["users"];
string sUser = (String)HttpContext.Current.Cache[sKey];
}
else
{
foreach (DictionaryEntry dEntry in HttpContext.Current.Cache)
{
HttpContext.Current.Cache.Remove(dEntry.Key.ToString());
}
}
}
}
Below is my code after the user successfully log in
String sKey = Login1.UserName + Login1.Password;
string sUser = Convert.ToString(Cache[sKey]);
if (sUser == null || sUser==" ")
{
TimeSpan sesstimeout = new TimeSpan(0, 0, HttpContext.Current.Session.Timeout, 0, 0);
HttpContext.Current.Cache.Insert(sKey, sKey, null, DateTime.MaxValue, sesstimeout, System.Web.Caching.CacheItemPriority.NotRemovable, null);
Session["user"] = Login1.UserName + Login1.Password;
}
else
{
HttpContext.Current.Response.Write("User is already Login");
}
After the code every time I login it always says that the user is already login now.
Stuck to my thesis because this
Any Help is so much appreciated.
DANDAN
|
|
|
|
|
This should probably have been posten in the ASP.NET forum.
In any case I suppose you could add a dictionary to which you at add the the user and current session, when a user logs on. You remove it when the session times out or the user logs off.
Then if an already logged in user, user logs on from another session you have 3 options as I see it:
1) Don't allow the user to logon.
2) Allow the user to logon and then logoff the same user on the other session.
3) let the user choose between 1) and 2)
|
|
|
|
|
Hello,
My apology for miss placing question.
About the idea I will try what you have given.
Thanks.
|
|
|
|
|
The item is being removed from the Cache after the default 20 minutes? Are you removing it somewhere prior to this? If you are attempting to login during this time period then it is correct.
Just personal preference I guess but I would rather use String.IsNullOrEmpty or String.IsNullOrWhiteSpace rather than this
if (sUser == null || sUser==" ")
Less typing and more clear as to what condition you are testing.
No comment
|
|
|
|
|
Hello,
Yup I set it to default, few question why does if I tried other account it still says that the accout is already login.
|
|
|
|
|
akosidandan wrote: if I tried other account it still says that the accout is already login
That part wasn't clear in your question. Have you debugged it? What is in your Cache? Code is stupid, it only does what it is told, unless you tell it to insert the user it won't be there, ergo, you must be adding it to the cache at some point.
No comment
|
|
|
|
|
Hello,
My apology about that, the code was orginally in vb.net in the link of my main post. I just managed and tried converting it myself thats why I dont have 100% idea about to code logic.
"After the code every time I login it always says that the user is already login now" <- it was a follow up question for this.
|
|
|
|
|
The main question here is: why would you want to do that? In 99% of cases it is a pure annoyance with no functional benefit (as well as being rather difficult to do well because of the nature of HTTP and session management).
|
|
|
|
|
Hello,
I know its hard and really annoying but still what if the my boss want it that way then I have no choice but to do it or else I will be kicked out.
Seems I have no choice but no to add it if I can't managed to do it, I guess
|
|
|
|
|
akosidandan wrote: what if the my boss want it that way
So this functionality isn't part of the specifications? Then why do it? Many man-years have been wasted on projects providing functionality that was never requested. If you think it has added benefit to the application then present your idea to your boss.
You are worried about being "kicked out" for not doing something that was not requested. I'd be more concerned about being "kicked out" for spending time on functionality not requested.
No comment
|
|
|
|