|
Systems like this already exist. Alteris by Symantec and System Center Configuration Management from Microsoft, among others.
The problem you're describing is far more complex than you realize. You need a client running on each machine, reporting back to a central server what it's IP currently is along with some identifier that uniquely ID's that machine.
Why? Laptops. Laptops can change IP addresses just by popping the machine out of the docking station. The DNS infrastructure will not update the change in IP address instantly, so when your server tries to contact the machine using DNS information, it won't get a response.
More problems consist of how you're going to sync up content between the server and the clients? How is the client going to know what it has to install and what it already installed? How is the content going to be transferred from the server to the clients for installation? How is the client going to verify that it has all the content for an installation?
What happens if the client or the server drops off the network in the middle of a content transfer? How are you going to recover from this situation?
No, you cannot run all installers from a server location. Some installers just don't tolerate that while others cannot be installed by multiple machines at the same time. It will work for most installers, but there's always one that will bite you in the ass. Trust me, I've been there.
If you think commercial software packages are too expensive to justify this, think about how much you get paid by the hour and how long it's going to take you to write both the server and client ends of this system and completely test it. I guarantee you it'll be more expensive than using an off-the-shelf solution.
|
|
|
|
|
Think about this. Why is it you don't already see a tool out there doing this?
Because what you want to do isn't possible without having some tool already running on the target machine.
On top of that, it's a MASSIVE security risk.
What you want to do isn't possible.
|
|
|
|
|
Dave Kreskowiak wrote: What you want to do isn't possible.
In theory, it is - you can use a Group Policy Startup Script[^] and push it to all PC's in the group.
I've not tried it, but it should work in a well controlled corporate environment. Nasty though!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
If the machine is already in AD and has an O/S on it, yeah it works. All actions run under the Local System account.
I'm approaching from the standpoint of a bare metal machine. No O/S, no anything on it.
|
|
|
|
|
So was I, but he replied with "In case my systems already have OS : My tool has to give me list ..." which changed it all a bit.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Problem Background:
In my WPF application, in one of the window/page contains 3 List Boxes and 1 ComboBox. These 3 ListBoxes are binded with XML dataprovider and there is no issues. I mean when 1st listbox selection changes automatically updates listbox2. In the same way, listbox3 updates as listbox2 changes. These are all worked out in XAMl file alone and there is code-behind except InitializeComponent() and few lines of code for loading this XAML file dynamically using XAMLReader(this is my requirement)
Problem facing Requirement:
OnSelection change event of any of the ListBox, need to populate ComboBox data dynamically( it will fire webservices which is based on above mentioned 3 LisBox selection). For this purpose, in SelectionChange I am trying to get
ListBoxObj.SelectedItem - Always contains XML tree.(i.e) of type XMLElement
I have tried all possiblities, everywhere I am getting only XML tree.
Anyone have any idea, how to extract ListBox selected Item Text from XMLElement?
Thanks
|
|
|
|
|
Try setting the SelectedValuePath[^] property to the XPath expression of the value you need to extract, and then reading the SelectedValue[^] property.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have two buttons (button1 and button2), a List<int> and a database. When form is loading, it selects a row from database with some values and assign them value to some labels and int variables. When I click on button1, the id of the row is inserted in list as an int value (idintrebare). In List can be maximum 26 elements. Here is my problem: when I click on button2, I want to select from database, rows where idintrebare is equal with id field from table (questions), but only one row per click, and assing to the same labels and int variables values from table. If all elements from list were selected, application will exit. Here is what I tried:
First I have the list:
List<int> coada = new List<int>(26);
Function for select data:
private void selectCoada()
{
using (Conexiune.getConnection())
{
foreach (int idi in coada)
{
string select = "SELECT DISTINCT * FROM questions WHERE id = '" + idi + "' LIMIT 1";
SQLiteCommand cmd = new SQLiteCommand(select, Conexiune.getConnection());
cmd.CommandType = CommandType.Text;
SQLiteDataReader rdra = cmd.ExecuteReader(CommandBehavior.CloseConnection);
try
{
while (rdra.Read())
{
textBox1.Text = rdra["question"].ToString();
textBox2.Text = rdra["answer1"].ToString();
textBox3.Text = rdra["answer2"].ToString();
textBox4.Text = rdra["answer3"].ToString();
r1 = (int)rdra["option1"];
r2 = (int)rdra["option2"];
r3 = (int)rdra["option3"];
idintrebare = Convert.ToInt32(rdra["id"]);
SimulatorManager.Intrebare = textBox1.Text;
}
}
catch (InvalidOperationException ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
In button1 I have just:
coada.add(idintrebare);
In button2 I have:
selectCoada();
The problem is that it selects only one value from list. I tried to use a for like this:
private void selectCoada()
{
using (Conexiune.getConnection())
{
for(int i=0;i<=coada.Count;i++) {
foreach (int idi in coada)
{
string select = "SELECT DISTINCT * FROM questions WHERE id = '" + idi + "' LIMIT 1";
SQLiteCommand cmd = new SQLiteCommand(select, Conexiune.getConnection());
cmd.CommandType = CommandType.Text;
SQLiteDataReader rdra = cmd.ExecuteReader(CommandBehavior.CloseConnection);
try
{
while (rdra.Read())
{
textBox1.Text = rdra["question"].ToString();
textBox2.Text = rdra["answer1"].ToString();
textBox3.Text = rdra["answer2"].ToString();
textBox4.Text = rdra["answer3"].ToString();
r1 = (int)rdra["option1"];
r2 = (int)rdra["option2"];
r3 = (int)rdra["option3"];
idintrebare = Convert.ToInt32(rdra["id"]);
SimulatorManager.Intrebare = textBox1.Text;
}
}
catch (InvalidOperationException ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
}
, but also didn't worked.
|
|
|
|
|
If you want to select one row each time button2 is clicked, and move through the rows in order:
private List<int> coada = new List<int>(26);
private currentIdi = 0;
if(coada.Count < 27) coada.add(idintrebare);
if(currentIdi == coada.Count || currentIdi == 25) Application.Exit;
currentIdi++;
selectCoada(coada[currentIdi]);
private void selectCoada(int idi)
{
using (Conexiune.getConnection())
{
string select = "SELECT DISTINCT * FROM questions WHERE id = '" + idi + "' LIMIT 1";
}
}
Comment: I think it's always a good idea to disable Controls when their use would cause an error, or when their use is irrelevant because the app is "not ready" to handle them. You might think about disabling 'button2 until clicking on it really can do something without an error.
«To kill an error's as good a service, sometimes better than, establishing new truth or fact.» Charles Darwin in "Prospero's Precepts"
|
|
|
|
|
I receive:
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
|
|
|
|
|
Code is good, but when all item have been passed and should show finish message, I receive that
|
|
|
|
|
It's ok, I fixed it. Thank you very much for your help, I understand now
|
|
|
|
|
Good
«To kill an error's as good a service, sometimes better than, establishing new truth or fact.» Charles Darwin in "Prospero's Precepts"
|
|
|
|
|
Unfortunately, I still have a problem. I thought I fixed it, but I was wrong. I understand why I receive that, but I don't know how to fix it. Can you help me with that?
|
|
|
|
|
If the problem you have now is a totally new kind of problem you haven't mentioned before, then I suggest you start a new question and include code samples, error messages, etc.
If it's the same problem you've discussed already, I suggest you add a new post to this thread and describe exactly what's not working the way you expect.
Have you stepped through your code with the debugger and isolated where the problem occurs ?
«To kill an error's as good a service, sometimes better than, establishing new truth or fact.» Charles Darwin in "Prospero's Precepts"
|
|
|
|
|
Aaaa sorry, I thought you might know what problem can appear in that case. Well, On button2, you know that I call select function. Well, after last id was selected from list, I receive that error message about index. That means that the list is empty and currentIdi can't have a negative value.
modified 5-Apr-15 9:36am.
|
|
|
|
|
Put a breakpoint in your code, and when you hit the breakpoint, use F11 to single-step through the code, observe where the error occurs.
Analyze what happened that caused the error, and then fix your code.
I think you have everything you need to get this fixed.
«To kill an error's as good a service, sometimes better than, establishing new truth or fact.» Charles Darwin in "Prospero's Precepts"
|
|
|
|
|
I solved it. Sorry and thank you for your time
|
|
|
|
|
Your code is vulnerable to SQL Injection[^].
NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
string select = "SELECT DISTINCT * FROM questions WHERE id = @id LIMIT 1";
SQLiteCommand cmd = new SQLiteCommand(select, Conexiune.getConnection());
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@id", idi);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
I have a new file every few seconds that looks like this: 23 45 21 1 9 23 42 22 40 11 33 32 18 11 12 32 22 7 37 30 in this text file to be read there is one number per line that will be between 1-40. these files are generated several times a minute. I am trying to order them ascending with stringreader and writer. my logic must be flawed as nothing shows up in this file i intended to send it to, i selected append= true but still nothing is populated in my sorted file. the goal was to read from the text file with the for loop which contains 1-40 int variables and compare that to each string or int from the file read and when found copy that from the read file into the sorted file in sorted order,I have been looking at it for a while and it should work but does not please help i have hit a brick wall and don't see why it does not work. would this be easier with the file reader/writer classes or streamreader/writer as i have done,thanks
public static void ProcessDirectory()
{
int variable1;
StreamReader readToSort = new StreamReader(@"C:write.txt");
StreamWriter writeSorted = new StreamWriter(@"C:Sorted_File.txt", true);
for (int i = 1; i > 41; i++)
{
variable1 = (readToSort.Read());
while (!readToSort.EndOfStream)
{
if (variable1 == i)
{
writeSorted.Write(i.ToString() + "\n");
}
}
MessageBox.Show("processing #" + variable1);
}
readToSort.Close();
writeSorted.Close();
}
modified 4-Apr-15 14:02pm.
|
|
|
|
|
|
sorry my bad not intentional
|
|
|
|
|
Assume you have a Class named 'TheClass : here's what you might call a 'normal' ctor:
public class TheClass
{
public string Name { private set; get; }
public List<int> TheClassList { private set; get; }
public TheClass(string name, int init, int inc, int last)
{
Name = name;
TheClassList = new List<int>;
for (int i = init; i < last; i+= inc)
{
TheClassList.Add(i);
}
}
} Now you decide that you want to give the user the option to inject a function into ctor that will modify the generation of values in the 'for loop: so you write a Function:
public Func<int, int> Generator1 = (value) => (value * value); And, you modify the class to pass the Function as a parameter to the ctor, and use it:
public class TheClass
{
public string Name { private set; get; }
public List<int> TheClassList { private set; get; }
public TheClass(string name, int init, int inc, int last, Func<int,int> Generator = null)
{
Name = name;
TheClassList = new List<int>;
if(Generator == null)
{
for (int i = init; i < last; i+= inc)
{
TheClassList.Add(i);
}
}
else
{
for (int i = init; i < last; i+= inc)
{
TheClassList.Add(Generator(i));
}
}
}
} All this is, imho, passable; my question regards what happens when you have many optional types of Functions (or Actions) that you want to be used in the ctor ... so that if you made all of those Funcs (or Actions) part of the ctor parameter list (with 'null as their default value) you'd get a very unwieldy ctor, and/or complex logic in the ctor to decide which functions passed as parameters are invoked.
Here's what I see as the alternatives:
I. define a separate ctor for each possible use case (my current choice).
public TheClass(string name, int init, int inc, int last);
public TheClass(string name, int init, int inc, int last, Func<int,int> Generator1);
public TheClass(string name, int init, int inc, int last, Func<int,int,int, List<int>> Generator2);
II. break-out the code in the ctor in two parts: one that handles everything but the generation of values; put the code for all possible value generation scenarios (and its logic) into a separate 'Initialize function that must be called after the call to the ctor.
III. define the most common (default) initialization method in the ctor, and pass a boolean flag as a parameter to the ctor: if the flag is true, initialization is performed in the ctor, else defer initialization to a call to an 'Initialize function.
Appreciate your thoughts !
«To kill an error's as good a service, sometimes better than, establishing new truth or fact.» Charles Darwin in "Prospero's Precepts"
modified 4-Apr-15 12:58pm.
|
|
|
|
|
Of those, I prefer 1, but they all do too much; a constructor should do very little.
Better to have the constructor receive the List rather than build it. If you do, you might want to make a copy.
A benefit of this technique is that it allows the caller to instantiate your class multiple times with the same data without generating it more than once.
And consider using params :
public TheClass(string name, params int[] List)
{
Name = name;
TheClassList = new List<int> { List };
The caller can use this with the values he wants:
TheClass a = new TheClass ( "A" , 1 , 2 , 3 ) ;
int[] l = new int[] { 1 , 2 , 3 } ;
TheClass b = new TheClass ( "B" , l ) ;
Basically, generating the list is not the constructor's concern.
Having said that... I'm reminded of a Pool<T> class I wrote. Its constructor takes a delegate that constructs one item for the pool and the number of items it should manage. Maybe I should change it to follow my advice above.
[System.ObsoleteAttribute("Don't use this constructor",true)]
public Pool
(
int Capacity
,
Delegate Creator
)
{
this.pool = new T[Capacity];
for (int i = 0; i < this.pool.Length; i++)
{
this.pool[i] = Creator();
}
return;
}
public Pool
(
params T[] Pool
)
{
this.pool = Pool;
return;
}
Modularity, single-responsibility, etc.
modified 4-Apr-15 13:10pm.
|
|
|
|
|