report logging  
Author Message
rizaR9





PostPosted: Visual C# General, report logging Top

hey guys, i'm relatively new to c# and i've got a important project using c#.. why blame my school..

anyway, the project i'm working on, involves the saving of Logs.. for reference..

however, these logs only store 1 entry at any given time.

should there be more than one user accessing the database at one time, it might cause the system to crash.

it'll be so darn helpful if anyone can tell me what method i should do and stuff. or perhaps a certain phrase i can use to search up on relevant information.

i'm in need of help badly..

thanks in advance.




Visual C#5  
 
 
GavH





PostPosted: Visual C# General, report logging Top

Is your report in a file, or in a database




 
 
rizaR9





PostPosted: Visual C# General, report logging Top

the report.. or logs, are stored as text files.. these text files are time stamped..

example,

2006-12-14 16:25:19.34 ****** Using '********.DLL' version '*.*.***'.
2006-12-14 16:25:19.34 ****** Starting up database 'model'.
2006-12-14 16:25:19.34 ****** Starting up database 'msdb'.

such entries will continue to be logged.. including those done by users.. currently the system only takes one entry at a time.. it cannot support multiple entry at any one time..

hope you can help.. thanks.



 
 
ahmedilyas





PostPosted: Visual C# General, report logging Top

my suggestion, if you can, move to a database. It's what its designed for, for things such as this. :-)

 
 
rizaR9





PostPosted: Visual C# General, report logging Top

but the system is already a done up project.. i can only continue on it and find suitable methods to "queue" the users' processes and then one by one enter into log files..

 
 
ahmedilyas





PostPosted: Visual C# General, report logging Top

you can probably easily create the methods to insert data into the database....

create a method that splits the entries into fields by the comma seperator for example, then for each item in the string array, create a parameter, add it to the SQL parameter collection and executeNonQuery, clear the parameter collection and keep doing this until no more items in the string[] array. Of course the number of fields must match up the fields in the database table, or should I say there should be no less than the number of fields from the textfile or there can be more but having the fields not a required field.

you are going to face perf issues as logs get filled up into the file...better start now than later



 
 
GavH





PostPosted: Visual C# General, report logging Top

If you absolutley must use a flat file then you need to research file locking, the is sometimes performed by creating a lock file with the data file, such as data.lock.

The idea being something like this:

PROC WriteLogOutPut
IF EXISTS LockFile
WAIT
ELSE
CREATE lockfile
OUTPUT dataFile entry
DELETE lockfile
END PROC

you can perform a similare scenaroe by opening the file exclusivley, which will cause other attempts to open the file to fail, you can then wait until you can get to the file, however both of these methods are invitations to infinate looping, and process locking if more than process uses the file.

Regards