|
i don't want to change it if it's overwriting by default, actually that's what i want, just to overwrite because I don't want any message to show to the user...
|
|
|
|
|
Changing system settings is rarely the right answer. As a user, I don't want to find out that I have settings in place that some application decides should be different. If all you want to do is write to a log of some description, then why not use a logging mechanism such as log4net, and output to a log file.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
soif you had an option to use the windows event log or a text file output log, then which one you'll choose? and why plz?
|
|
|
|
|
jrahma wrote: soif you had an option to use the windows event log or a text file output log, then which one you'll choose? and why plz?
- If it's an enterprise-application, the eventlog. Most sysadmins know how to manage those.
- If it's to run on Linux, then Log4Net.
- If it's a new application; a strategy pattern, making the choice a configurational option.
I are Troll
|
|
|
|
|
Eddy Vluggen wrote: If it's a new application; a strategy pattern, making the choice a configurational option.
Or use log4net which has configurable ouput choices such as email, file, event log (or other ones that you could write yourself). I'm not sure why you chose Linux for the log4net choice - perhaps you're thinking of log4j.
BTW - log4net allows you to target multiple sources simultaneously, and is very configurable.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete O'Hanlon wrote: Or use log4net which has configurable ouput choices such as email, file, event log (or other ones that you could write yourself).
Since the EventLog is included already in log4net, I'd have to admit that it would be redundant to include an extra option to write directly to it.
Pete O'Hanlon wrote: BTW - log4net allows you to target multiple sources simultaneously, and is very configurable.
Good arguments, for both which and why
I are Troll
|
|
|
|
|
as you seen worried about size, I'll assume your logging is more of a technical nature, rather than an application-level statistic or audit trail, and I recommend a do-it-yourself approach, rather than using EventLog which would be rather expensive and cumbersome. See here[^].
|
|
|
|
|
jrahma wrote: i never seen any application showing such message in my life!! what's the best to work wit this?
There's a reason for that. The default size on Windows 7 is 20MB. If your application creates that many entries, you've got a bigger problem than managing the size of the log.
Really, your application shouldn't care about the size of the event logs at all. This is best left up to corporate policies and LAN Admins. There is no guarantee that what your application does to the event logs is going to stick because of policies.
|
|
|
|
|
then i think it's better to go for the local log file.. thx...
|
|
|
|
|
This idea is totally correct, I cannot agree with many of the other posts here. We have seen that happening on some of our customer's computers at the first (!) start of our applications - our LicenseServer writes one entry to the event log telling that it successfully read / or failed to read the license file. And here it crashed. Because the event log was full - since a long time already... It is really not uncommon.
Best to add some try/catch around your event log entries, so it won't crash your programs.
|
|
|
|
|
I want to know how can I create help for my application to be the same as MSDN library layout, I think it's using something called Microsoft Document Explorer
|
|
|
|
|
I am using C# and I want to know how can I change the caption of the MesageBox when MessageBox.Show, for example if I want to change the Ok button caption to WoW!!
|
|
|
|
|
There is not an easy way to achieve this. Better create your own customizable messagebox.
See here[^] for creation details.
Or you can use a ready customizable messagebox clone presented here[^] on CP.
|
|
|
|
|
Hello to All
I want to change the name of my process or hide it from task manager.
also do you think that the anti viruses warn about it?
Best regards
|
|
|
|
|
mobasher wrote: I want to change the name of my process
Change the name of your executable.
mobasher wrote: or hide it from task manager
Why? The user usually owns the machine that he/she is using, and would have every right to see what is running in his/her system.
mobasher wrote: also do you think that the anti viruses warn about it?
Yes, but merely as being "malware", not a virus.
I are Troll
|
|
|
|
|
There is only one method to do this, but I'm not saying what it is.
mobasher wrote: also do you think that the anti viruses warn about it?
No, but, coming from a LAN Admin background, there is no legitimate reason to do this. If I caught your app doing it, it would be, at my highest priority, uninstalled and the systems rebuilt from scratch. Only malware would ever want to do this.
|
|
|
|
|
I have many parameters in my system_parameters table in SQL and I am populating into a hashtable but it seems it's not reading all (and no error raised!).. it's reading 19 out of 68.. this is my code to read from the sql:
while (sql_reader.Read())
{
if (_system_parameters_hash.ContainsKey(sql_reader["system_param_name"])) return;
if (sql_reader["system_param_value"] == DBNull.Value)
{
_system_parameters_hash.Add(sql_reader["system_param_name"].ToString(), null);
}
else
{
if ((string)sql_reader["system_param_type"] == "bit") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToBoolean(sql_reader["system_param_value"]));
else if ((string)sql_reader["system_param_type"] == "string") _system_parameters_hash.Add((string)sql_reader["system_param_name"], (string)sql_reader["system_param_value"]);
else if ((string)sql_reader["system_param_type"] == "int") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToInt32(sql_reader["system_param_value"]));
else if ((string)sql_reader["system_param_type"] == "int64") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToInt64(sql_reader["system_param_value"]));
else if ((string)sql_reader["system_param_type"] == "short") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToInt16(sql_reader["system_param_value"]));
}
}
and this is a sample rows (parameter name, parameter value then parameter type)
APPOINTMENT_DEFAULT_CLINIC 2 int
APPOINTMENT_DEFAULT_DOCTOR 3 int
BACKUP_DESTINATION_FOLDER C:\Temp\cure.bak string
BACKUP_SCHEDULE_DURATION DAILY string
BACKUP_SCHEDULE_ENABLED True bit
what can I do?
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:24am.
|
|
|
|
|
i did but still the same with no error
and my select statement is SELECT * FROM system_parameters
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:23am.
|
|
|
|
|
what's the use of breakpoint if no error and no problem running the application? were do you want me to set the break point?
|
|
|
|
|
The breakpoint that was mentioned by someone you should place at the begin of the while loop
As to the error without exception. In this line:
if (_system_parameters_hash.ContainsKey(sql_reader["system_param_name"])) return;
you return from method. Are you sure names aren't duplicated at least once... in 20th row returned from your command?
This is something you could discover by debugging your code
|
|
|
|
|
start debugging: do NOT set a breakpoint, observe closely what happens, add code to improve visibility; add a try-catch and show Exception.ToString, add an else clause that counts how many entries contain unrecognized types, look at the actual data of the very first row that does not make it to the ArrayList, consider what happens when a DBNull occurs, start thinking and acting.
|
|
|
|
|
i did all that but it's still not working... it's actually existing the while loop when it reaches count 19 with no errors as if my total count in the database table is 19 only!!
any duplicates in the table? that was your question? no, duplicates, I already checked and I have also copied the entire table as excel format in this link:
system_parameters table[^]
this is my full code which I am using:
public void get_system_properties()
{
try
{
_system_parameters_hash = new Hashtable();
_system_parameters_hash.Add("SQL_SERVER_CONNECTION", null);
_system_parameters_hash.Add("SQL_SERVER_DATABASE", "Cure");
_system_parameters_hash.Add("EVENT_LOG_DESCRIPTION", null);
_system_parameters_hash["SQL_SERVER_CONNECTION"] = "Data Source=";
_system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLServer").ToString();
_system_parameters_hash["SQL_SERVER_CONNECTION"] += ";initial catalog=";
_system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLDatabase").ToString();
_system_parameters_hash["SQL_SERVER_CONNECTION"] += ";User Id=";
_system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLUser").ToString();
_system_parameters_hash["SQL_SERVER_CONNECTION"] += ";Password=";
_system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLPassword").ToString();
_system_parameters_hash["SQL_SERVER_CONNECTION"] += ";Connection Timeout=";
_system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLTimeout").ToString();
sql_connection = new SqlConnection((string)_system_parameters_hash["SQL_SERVER_CONNECTION"]);
sql_connection.Open();
sql_command = new SqlCommand("sp_get_system_parameters", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_reader = sql_command.ExecuteReader();
while (sql_reader.Read())
{
if (_system_parameters_hash.ContainsKey(sql_reader["system_param_name"])) return;
if (sql_reader["system_param_value"] == DBNull.Value)
{
_system_parameters_hash.Add(sql_reader["system_param_name"].ToString(), null);
}
else
{
if ((string)sql_reader["system_param_type"] == "bit") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToBoolean(sql_reader["system_param_value"]));
else if ((string)sql_reader["system_param_type"] == "string") _system_parameters_hash.Add((string)sql_reader["system_param_name"], (string)sql_reader["system_param_value"]);
else if ((string)sql_reader["system_param_type"] == "int") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToInt32(sql_reader["system_param_value"]));
else if ((string)sql_reader["system_param_type"] == "int64") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToInt64(sql_reader["system_param_value"]));
else if ((string)sql_reader["system_param_type"] == "short") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToInt16(sql_reader["system_param_value"]));
}
}
Trace.Write(_system_parameters_hash.Count);
}
catch (Exception exp)
{
create_event("System", "Error populating system properties!!", exp, EventLogEntryType.Error, 1000, false);
MessageBox.Show("Error populating system properties!!" + Environment.NewLine + "Please contact your system administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
finally
{
if (sql_reader != null) sql_reader.Close();
if (sql_connection != null)
{
if (sql_connection.State == ConnectionState.Open)
sql_connection.Close();
}
}
}
|
|
|
|
|
one of the recommendations I made was "add code to improve visibility", I see none of that.
before the reading loop, add code to show the number of rows returned, so you can check that number right away; identify the last row added, or better yet, the first one missing. Would it perhaps be the first one with type "short"? does that ring a bell?
|
|
|
|