|
 |
|
WinForm ไม่ขึ้นใน Event Logs หลังจากส่ง Event ข้ามมาที่เครื่อง |
|
 |
|
|
 |
 |
|
รบกวนสอบถามหน่อยครับพอดีผมเขียน Service Event Log แล้วโปรแกรมไม่ Bug ไม่ error แต่ทำไม่มันไม่ขึ้นโชว์ผมเขียนผิดตรงไหนรึป่าว มันเป็น Service เมื่อมีการรับค่าและส่งการทำงานต่ออะคับ
Code (C#)
public class handleClinet
{
writeLog log = new writeLog();
TcpClient clientSocket;
string clNo;
public void startClient(TcpClient inClientSocket, string clineNo)
{
try
{
this.clientSocket = inClientSocket;
this.clNo = clineNo;
Thread ctThread = new Thread(receiveMessage);
ctThread.Start();
}
catch (Exception ex)
{
log.writeApplicationError(System.DateTime.Now, ex.Message);
}
}
private void receiveMessage()
{
//EventLog eventLog1 = new EventLog();
//eventLog1.Source = "SourceDPSSServiceAgent";
//eventLog1.Log = "DPSS Service Agent";
try
{
byte[] rec = new byte[1];
string line = String.Empty;
using (NetworkStream myStream = clientSocket.GetStream())
{
bool flag = true;
line = String.Empty;
for (int i = 0; i <= 5000 && flag == true; i++) //read until find <end> or string long over 5000
{
myStream.Read(rec, 0, rec.Length);
line += System.Text.Encoding.Default.GetString(rec);
if (line.Contains("<end>"))
flag = false;
}
myStream.Close();
}
clientSocket.Close();
line = line.Trim();
//eventLog1.WriteEntry("line: " + line);
string[] data = Regex.Split(line.Replace("<end>", ""), "<value>");
if (data.Length == 4)
{
string clientUsername = data[0].Contains(",") ? data[0].Substring(0, data[0].IndexOf(',')) : data[0];
clientUsername = clientUsername.ToLower().Replace("uid=", "");
if (clientUsername.Contains(","))
clientUsername = (data[0].Substring(0, data[0].IndexOf(',')).ToLower()).Replace("uid=", "");
string clientPassword = data[1];
string clientType = data[2];
string clientTimestamp = data[3];
DateTime date = new DateTime();
try
{
date = new DateTime(
Convert.ToInt32(clientTimestamp.Substring(0, 4)), Convert.ToInt32(clientTimestamp.Substring(4, 2)),
Convert.ToInt32(clientTimestamp.Substring(6, 2)), Convert.ToInt32(clientTimestamp.Substring(8, 2)),
Convert.ToInt32(clientTimestamp.Substring(10, 2)), Convert.ToInt32(clientTimestamp.Substring(12, 2)));
}
catch (Exception ex)
{
date = System.DateTime.Now;
}
//remove old Temp User before insert new
log.removeUserTemp(clientUsername);
//send to function for reset password and write log
if (manageResetPassword(clientUsername, clientPassword, clientType, date, false))
{
//reset password success then read all old Temp Users and try to reset again
object[,] users = log.readAllTempUser();
for (int i = 0; i < users.GetLength(0); i++)
{
manageResetPassword(users[i, 0].ToString(), users[i, 1].ToString(), users[i, 2].ToString(), Convert.ToDateTime(users[i, 3]), true);
}
}
}
}
catch (Exception ex)
{
log.writeApplicationError(System.DateTime.Now, ex.Message);
//Thread.CurrentThread.Abort();
}
finally
{
Thread.CurrentThread.Abort();
}
return;
}
Tag : .NET, Ms SQL Server 2008, C#, VS 2010 (.NET 4.x)

|
|
 |
 |
 |
 |
Date :
2014-05-29 14:13:29 |
By :
offonepoint |
View :
738 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วเข้ามันเงื่อนไขที่จะทำงานหรือเปล่าครับ ได้ลอง Debug ดู ?
|
 |
 |
 |
 |
Date :
2014-05-29 17:49:20 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|