添加编译指令

This commit is contained in:
gongxh
2022-01-18 20:20:10 +08:00
parent a7ef9c7b54
commit 89f1bb0536
5 changed files with 707 additions and 640 deletions

View File

@@ -2832,7 +2832,12 @@ namespace CleanMachineHMI.FrmUserControl
} }
//自动模式下,打印结束操控 M231 交替 别名: PrintFinish /// <summary>
/// 自动模式下,打印结束操控 M231 交替 别名: PrintFinish
/// 打印不成功时候按这个重新向PLC发这个指令
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void kryptonButton7_Click(object sender, EventArgs e) private void kryptonButton7_Click(object sender, EventArgs e)
{ {
if (isManualStatus()) if (isManualStatus())

File diff suppressed because it is too large Load Diff

View File

@@ -372,7 +372,7 @@ namespace CleanMachineHMI
PlcItem md = PlcItemMdList.Find(x => x.PlcItemCode == item["PLC_ITEM_CODE"].ToString()); PlcItem md = PlcItemMdList.Find(x => x.PlcItemCode == item["PLC_ITEM_CODE"].ToString());
if (md != null) if (md != null)
{ {
md.PlcItemId =item["PLC_ITEM_ID"].ToString(); md.PlcItemId = item["PLC_ITEM_ID"].ToString();
md.PlcItemCode = item["PLC_ITEM_CODE"].ToString(); md.PlcItemCode = item["PLC_ITEM_CODE"].ToString();
md.PlcItemName = item["PLC_ITEM_NAME"].ToString(); md.PlcItemName = item["PLC_ITEM_NAME"].ToString();
md.PlcItemType = Convert.ToInt32(item["PLC_ITEM_TYPE"].ToString()); md.PlcItemType = Convert.ToInt32(item["PLC_ITEM_TYPE"].ToString());
@@ -484,169 +484,174 @@ namespace CleanMachineHMI
long lastTick = DateTime.Now.Ticks; long lastTick = DateTime.Now.Ticks;
while (GlobalHelper.SysThIsRunFlag) while (GlobalHelper.SysThIsRunFlag)
{ {
#if !DEBUG
try try
{ {
#region 定时器运行函数 #endif
//当前托报废率超过10%,则提示 #region 定时器运行函数
string sql_CurrPalletmsg = $@"SELECT * FROM CM_WORKING_PALLET WHERE WORKING_STATUS = 0"; //当前托报废率超过10%,则提示
DataTable dt_CurrPalletmsg = LeadDbHelperSQLite.Query(sql_CurrPalletmsg).Tables[0]; string sql_CurrPalletmsg = $@"SELECT * FROM CM_WORKING_PALLET WHERE WORKING_STATUS = 0";
if (dt_CurrPalletmsg != null && dt_CurrPalletmsg.Rows.Count > 0) DataTable dt_CurrPalletmsg = LeadDbHelperSQLite.Query(sql_CurrPalletmsg).Tables[0];
if (dt_CurrPalletmsg != null && dt_CurrPalletmsg.Rows.Count > 0)
{
string palletCodeMsg = dt_CurrPalletmsg.Rows[0]["WORKING_PALLET_CODE"].ToString();
string sqlCurrPalletScrapNumMsg = $@"SELECT CURRENT_NUMBER FROM VW_WORKING_PALLET_MSG WHERE WORKING_PALLET_CODE = '{palletCodeMsg}' AND CONTAMINATION_DTL_CODE = 'MoistureOrWet'";
string sqlCurrPalletCountNumMsg = $@"SELECT SUM(CURRENT_NUMBER) FROM VW_WORKING_PALLET_MSG WHERE WORKING_PALLET_CODE = '{palletCodeMsg}'";
DataTable dt_CurrPalletScrapNumMsg = LeadDbHelperSQLite.Query(sqlCurrPalletScrapNumMsg).Tables[0];
DataTable dt_CurrPalletCountNumMsg = LeadDbHelperSQLite.Query(sqlCurrPalletCountNumMsg).Tables[0];
if (dt_CurrPalletScrapNumMsg != null && dt_CurrPalletScrapNumMsg.Rows.Count > 0 && dt_CurrPalletCountNumMsg != null && dt_CurrPalletCountNumMsg.Rows.Count > 0)
{ {
string palletCodeMsg = dt_CurrPalletmsg.Rows[0]["WORKING_PALLET_CODE"].ToString(); int ScrapNumMsg = Convert.ToInt32(dt_CurrPalletScrapNumMsg.Rows[0][0]);
string sqlCurrPalletScrapNumMsg = $@"SELECT CURRENT_NUMBER FROM VW_WORKING_PALLET_MSG WHERE WORKING_PALLET_CODE = '{palletCodeMsg}' AND CONTAMINATION_DTL_CODE = 'MoistureOrWet'"; int CountNumMsg = Convert.ToInt32(dt_CurrPalletCountNumMsg.Rows[0][0]);
string sqlCurrPalletCountNumMsg = $@"SELECT SUM(CURRENT_NUMBER) FROM VW_WORKING_PALLET_MSG WHERE WORKING_PALLET_CODE = '{palletCodeMsg}'"; if (CountNumMsg == 0 || ScrapNumMsg == 0)
DataTable dt_CurrPalletScrapNumMsg = LeadDbHelperSQLite.Query(sqlCurrPalletScrapNumMsg).Tables[0];
DataTable dt_CurrPalletCountNumMsg = LeadDbHelperSQLite.Query(sqlCurrPalletCountNumMsg).Tables[0];
if (dt_CurrPalletScrapNumMsg != null && dt_CurrPalletScrapNumMsg.Rows.Count > 0 && dt_CurrPalletCountNumMsg != null && dt_CurrPalletCountNumMsg.Rows.Count > 0)
{ {
int ScrapNumMsg = Convert.ToInt32(dt_CurrPalletScrapNumMsg.Rows[0][0]); BeginInvoke(new Action(() => { label1.Visible = false; }));
int CountNumMsg = Convert.ToInt32(dt_CurrPalletCountNumMsg.Rows[0][0]); }
if (CountNumMsg == 0 || ScrapNumMsg == 0) else
{
int scrapRate = Convert.ToInt32(Math.Round(decimal.Parse(((decimal)ScrapNumMsg / (decimal)CountNumMsg).ToString("0.000")), 2) * 100);
if (scrapRate >= 10)
{ {
BeginInvoke(new Action(() => { label1.Visible = false; })); BeginInvoke(new Action(() => { label1.Visible = false; }));
} }
else else
{ {
int scrapRate = Convert.ToInt32(Math.Round(decimal.Parse(((decimal)ScrapNumMsg / (decimal)CountNumMsg).ToString("0.000")), 2) * 100); BeginInvoke(new Action(() => { label1.Visible = false; }));
if (scrapRate >= 10)
{
BeginInvoke(new Action(() => { label1.Visible = false; }));
}
else
{
BeginInvoke(new Action(() => { label1.Visible = false; }));
}
} }
} }
else
{
BeginInvoke(new Action(() => { label1.Visible = false; }));
}
} }
else
string sqlParam = $@"SELECT * FROM SYS_PARAMETER";
DataTable dtParam = LeadDbHelperSQLite.Query(sqlParam).Tables[0];
if (dtParam != null && dtParam.Rows.Count > 0)
{ {
int sysRuningTimeLen = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'SysRuningTimeLen'")[0]["PARAMETER_VALUE"]); BeginInvoke(new Action(() => { label1.Visible = false; }));
int scrapRate = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'ScrapRate'")[0]["PARAMETER_VALUE"]); }
int maintainItemTime = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainItemTime'")[0]["PARAMETER_VALUE"]); }
int maintainAlarmTime = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainAlarmTime'")[0]["PARAMETER_VALUE"]);
int maintainQuitTime = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainQuitTime'")[0]["PARAMETER_VALUE"]); string sqlParam = $@"SELECT * FROM SYS_PARAMETER";
int maintainFlag = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainFlag'")[0]["PARAMETER_VALUE"]); DataTable dtParam = LeadDbHelperSQLite.Query(sqlParam).Tables[0];
string maintainRelieveCode = dtParam.Select("PARAMETER_CODE = 'MaintainRelieveCode'")[0]["PARAMETER_VALUE"].ToString(); if (dtParam != null && dtParam.Rows.Count > 0)
if (maintainFlag == 0) {
int sysRuningTimeLen = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'SysRuningTimeLen'")[0]["PARAMETER_VALUE"]);
int scrapRate = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'ScrapRate'")[0]["PARAMETER_VALUE"]);
int maintainItemTime = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainItemTime'")[0]["PARAMETER_VALUE"]);
int maintainAlarmTime = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainAlarmTime'")[0]["PARAMETER_VALUE"]);
int maintainQuitTime = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainQuitTime'")[0]["PARAMETER_VALUE"]);
int maintainFlag = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainFlag'")[0]["PARAMETER_VALUE"]);
string maintainRelieveCode = dtParam.Select("PARAMETER_CODE = 'MaintainRelieveCode'")[0]["PARAMETER_VALUE"].ToString();
if (maintainFlag == 0)
{
bool isRun = (bool)PlcOperationHelper.Instance.ReadPlcItem("CleanMacRunStatusNew", PlcItemTypeDesc.M);
if (isRun)
{ {
bool isRun = (bool)PlcOperationHelper.Instance.ReadPlcItem("CleanMacRunStatusNew", PlcItemTypeDesc.M);
if (isRun) if (timerRunNUm == 60)
{ {
sysRuningTimeLen++;
if (timerRunNUm == 60) if (sysRuningTimeLen < maintainItemTime)
{ {
sysRuningTimeLen++; //pictureBox1.Visible = false;
if (sysRuningTimeLen < maintainItemTime) BeginInvoke(new Action(() => { pictureBox1.Visible = false; }));
}
else if (sysRuningTimeLen >= maintainItemTime && sysRuningTimeLen < maintainAlarmTime)
{
//pictureBox1.Visible = true;
BeginInvoke(new Action(() => { pictureBox1.Visible = true; }));
}
else if (sysRuningTimeLen >= maintainAlarmTime && sysRuningTimeLen < maintainQuitTime)
{
BeginInvoke(new Action(() =>
{ {
//pictureBox1.Visible = false; pictureBox1.Visible = true;
BeginInvoke(new Action(() => { pictureBox1.Visible = false; })); if (!sysAlarmFrmShowFlag)
} {
else if (sysRuningTimeLen >= maintainItemTime && sysRuningTimeLen < maintainAlarmTime) sysAlarmFrmShowFlag = true;
{ frmSysExitAlarm frm = new frmSysExitAlarm();
//pictureBox1.Visible = true; //frm.showMsg = "机器即将于" + (maintainQuitTime - sysRuningTimeLen) + "分钟后退出。";
BeginInvoke(new Action(() => { pictureBox1.Visible = true; })); frm.showMsg = $"The machine will exit in {(maintainQuitTime - sysRuningTimeLen)} minutes.";
} frm.TopLevel = true;
else if (sysRuningTimeLen >= maintainAlarmTime && sysRuningTimeLen < maintainQuitTime) frm.ShowDialog();
{ }
BeginInvoke(new Action(() => }));
}
else if (sysRuningTimeLen >= maintainQuitTime)
{
BeginInvoke(new Action(() =>
{
pictureBox1.Visible = true;
string sql = "SELECT 1 FROM CM_WORKING_PALLET WHERE WORKING_STATUS = 0";
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{ {
pictureBox1.Visible = true;
if (!sysAlarmFrmShowFlag) if (!sysAlarmFrmShowFlag)
{ {
sysAlarmFrmShowFlag = true; sysAlarmFrmShowFlag = true;
frmSysExitAlarm frm = new frmSysExitAlarm(); frmSysExitAlarm frm = new frmSysExitAlarm();
//frm.showMsg = "机器即将于" + (maintainQuitTime - sysRuningTimeLen) + "分钟后退出。"; frm.showMsg = $"The machine maintenance time has exceeded: [{(maintainQuitTime - sysRuningTimeLen)}] minutes, please complete the current operation tray as soon as possible, and carry out equipment maintenance !!!!!!";
frm.showMsg = $"The machine will exit in {(maintainQuitTime - sysRuningTimeLen)} minutes.";
frm.TopLevel = true; frm.TopLevel = true;
frm.ShowDialog(); frm.ShowDialog();
} }
})); }
} else
else if (sysRuningTimeLen >= maintainQuitTime)
{
BeginInvoke(new Action(() =>
{ {
pictureBox1.Visible = true; string sqlUpdateParam = $@"update SYS_PARAMETER set PARAMETER_VALUE = '1' WHERE PARAMETER_CODE = 'MaintainFlag'";
string sql = "SELECT 1 FROM CM_WORKING_PALLET WHERE WORKING_STATUS = 0"; LeadDbHelperSQLite.ExecuteSql(sqlUpdateParam);
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0]; PlcOperationHelper.Instance.WritePlcItem("StopSys", "True", PlcItemTypeDesc.M);
if (dt != null && dt.Rows.Count > 0) PlcOperationHelper.Instance.WritePlcItem("StopSys", "False", PlcItemTypeDesc.M);
{ PlcOperationHelper.Instance.WritePlcItem("ResetSys", "True", PlcItemTypeDesc.M);
if (!sysAlarmFrmShowFlag) PlcOperationHelper.Instance.WritePlcItem("ResetSys", "False", PlcItemTypeDesc.M);
{ Environment.Exit(0);
sysAlarmFrmShowFlag = true; }
frmSysExitAlarm frm = new frmSysExitAlarm();
frm.showMsg = $"The machine maintenance time has exceeded: [{(maintainQuitTime - sysRuningTimeLen)}] minutes, please complete the current operation tray as soon as possible, and carry out equipment maintenance !!!!!!";
frm.TopLevel = true;
frm.ShowDialog();
}
}
else
{
string sqlUpdateParam = $@"update SYS_PARAMETER set PARAMETER_VALUE = '1' WHERE PARAMETER_CODE = 'MaintainFlag'";
LeadDbHelperSQLite.ExecuteSql(sqlUpdateParam);
PlcOperationHelper.Instance.WritePlcItem("StopSys", "True", PlcItemTypeDesc.M);
PlcOperationHelper.Instance.WritePlcItem("StopSys", "False", PlcItemTypeDesc.M);
PlcOperationHelper.Instance.WritePlcItem("ResetSys", "True", PlcItemTypeDesc.M);
PlcOperationHelper.Instance.WritePlcItem("ResetSys", "False", PlcItemTypeDesc.M);
Environment.Exit(0);
}
}));
}
string sqlUpdateRunTimeLen = $@"UPDATE SYS_PARAMETER set PARAMETER_VALUE = '{sysRuningTimeLen}' WHERE PARAMETER_CODE = 'SysRuningTimeLen'";
LeadDbHelperSQLite.ExecuteSql(sqlUpdateRunTimeLen);
BeginInvoke(new Action(() =>
{
kryptonLabel1.Text = sysRuningTimeLen + " Minutes";
})); }));
timerRunNUm = 1;
} }
else string sqlUpdateRunTimeLen = $@"UPDATE SYS_PARAMETER set PARAMETER_VALUE = '{sysRuningTimeLen}' WHERE PARAMETER_CODE = 'SysRuningTimeLen'";
LeadDbHelperSQLite.ExecuteSql(sqlUpdateRunTimeLen);
BeginInvoke(new Action(() =>
{ {
timerRunNUm++; kryptonLabel1.Text = sysRuningTimeLen + " Minutes";
BeginInvoke(new Action(() => }));
{ timerRunNUm = 1;
kryptonLabel1.Text = sysRuningTimeLen + " Minutes";
}));
}
} }
else
}
else
{
BeginInvoke(new Action(() =>
{ {
pictureBox1.Visible = true; timerRunNUm++;
})); BeginInvoke(new Action(() =>
{
kryptonLabel1.Text = sysRuningTimeLen + " Minutes";
}));
}
} }
}
else
{
BeginInvoke(new Action(() =>
{
pictureBox1.Visible = true;
}));
} }
#region 定期清理历史业务数据 -- 数据保存2个月
string sqlZbkWorkingPallet = $@"DELETE FROM ZBK_WORKING_PALLET WHERE julianday('now') - julianday(UPDATE_TIME) > 30";
string sqlZbkWorkingPalletDtl = $@"DELETE FROM ZBK_WORKING_PALLET_DTL WHERE julianday('now') - julianday(UPDATE_TIME) > 30";
LeadDbHelperSQLite.ExecuteSql(sqlZbkWorkingPallet);
LeadDbHelperSQLite.ExecuteSql(sqlZbkWorkingPalletDtl);
#endregion
PlcOperationHelper.Instance.HeartbeatDetection();
#endregion
} }
#region 定期清理历史业务数据 -- 数据保存2个月
string sqlZbkWorkingPallet = $@"DELETE FROM ZBK_WORKING_PALLET WHERE julianday('now') - julianday(UPDATE_TIME) > 30";
string sqlZbkWorkingPalletDtl = $@"DELETE FROM ZBK_WORKING_PALLET_DTL WHERE julianday('now') - julianday(UPDATE_TIME) > 30";
LeadDbHelperSQLite.ExecuteSql(sqlZbkWorkingPallet);
LeadDbHelperSQLite.ExecuteSql(sqlZbkWorkingPalletDtl);
#endregion
PlcOperationHelper.Instance.HeartbeatDetection();
#endregion
#if !DEBUG
}
catch (Exception ex) catch (Exception ex)
{ {
LogHelper.WriteLog($"定时器运行函数发生异常:【{ex.Message}】", LogTypeEum.Err); LogHelper.WriteLog($"定时器运行函数发生异常:【{ex.Message}】", LogTypeEum.Err);
} }
#endif
Thread.Sleep(1000); Thread.Sleep(1000);
} }
} }
@@ -770,8 +775,8 @@ namespace CleanMachineHMI
if (isPlcConnStatus) if (isPlcConnStatus)
{ {
// 断开PLC连接 // 断开PLC连接
PlcOperationHelper.Instance.ClosePlcConn(); PlcOperationHelper.Instance.ClosePlcConn();
isPlcConnStatus = false; isPlcConnStatus = false;
} }
if (GlobalHelper.PopupWarningMsgForm != null) if (GlobalHelper.PopupWarningMsgForm != null)

View File

@@ -28,25 +28,28 @@ namespace LeadDataBaseUtility
public static int ExecuteSql(string sql) public static int ExecuteSql(string sql)
{ {
int affectedRows = 0; int affectedRows = 0;
#if !DEBUG
try try
{ {
using (SQLiteConnection conn = new SQLiteConnection(connectionString)) #endif
using (SQLiteConnection conn = new SQLiteConnection(connectionString))
{
conn.Open();
using (SQLiteCommand cmd = new SQLiteCommand(conn))
{ {
conn.Open(); cmd.CommandText = sql;
using (SQLiteCommand cmd = new SQLiteCommand(conn)) affectedRows = cmd.ExecuteNonQuery();
{
cmd.CommandText = sql;
affectedRows = cmd.ExecuteNonQuery();
}
conn.Close();
} }
conn.Close();
} }
#if !DEBUG
}
catch (Exception e) catch (Exception e)
{ {
LogHelper.WriteLog($"数据库运行异常:【{e.Message}】。SQL语句:【{sql}】。", LogTypeEum.DbErr); LogHelper.WriteLog($"数据库运行异常:【{e.Message}】。SQL语句:【{sql}】。", LogTypeEum.DbErr);
} }
#endif
return affectedRows; return affectedRows;
} }
/// <summary> /// <summary>
@@ -59,17 +62,21 @@ namespace LeadDataBaseUtility
using (SQLiteConnection connection = new SQLiteConnection(connectionString)) using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{ {
DataSet ds = new DataSet(); DataSet ds = new DataSet();
#if !DEBUG
try try
{ {
connection.Open(); #endif
SQLiteDataAdapter command = new SQLiteDataAdapter(SQLString, connection); connection.Open();
command.Fill(ds, "ds"); SQLiteDataAdapter command = new SQLiteDataAdapter(SQLString, connection);
connection.Close(); command.Fill(ds, "ds");
} connection.Close();
#if !DEBUG
}
catch (Exception e) catch (Exception e)
{ {
LogHelper.WriteLog($"数据库运行异常:【{e.Message}】。SQL语句:【{SQLString}】。", LogTypeEum.DbErr); LogHelper.WriteLog($"数据库运行异常:【{e.Message}】。SQL语句:【{SQLString}】。", LogTypeEum.DbErr);
} }
#endif
return ds; return ds;
} }
} }
@@ -84,27 +91,31 @@ namespace LeadDataBaseUtility
{ {
using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection)) using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection))
{ {
#if !DEBUG
try try
{ {
connection.Open(); #endif
object obj = cmd.ExecuteScalar(); connection.Open();
if ((Equals(obj, null)) || (Equals(obj, System.DBNull.Value))) object obj = cmd.ExecuteScalar();
{ if ((Equals(obj, null)) || (Equals(obj, System.DBNull.Value)))
connection.Close();
return null;
}
else
{
connection.Close();
return obj;
}
}
catch (System.Data.SQLite.SQLiteException e)
{ {
connection.Close(); connection.Close();
LogHelper.WriteLog($"数据库运行异常:【{e.Message}】。SQL语句:【{SQLString}】。", LogTypeEum.DbErr);
return null; return null;
} }
else
{
connection.Close();
return obj;
}
#if !DEBUG
}
catch (System.Data.SQLite.SQLiteException e)
{
connection.Close();
LogHelper.WriteLog($"数据库运行异常:【{e.Message}】。SQL语句:【{SQLString}】。", LogTypeEum.DbErr);
return null;
}
#endif
} }
} }
} }

View File

@@ -36,6 +36,14 @@ namespace NX_LogUtility
} }
public static class LogHelper public static class LogHelper
{ {
private readonly static System.Collections.Concurrent.BlockingCollection<string> messages = new System.Collections.Concurrent.BlockingCollection<string>();
#region 记录日志为文本文档形式 #region 记录日志为文本文档形式
/// <summary> /// <summary>
/// 记录日志类 /// 记录日志类
@@ -75,47 +83,54 @@ namespace NX_LogUtility
Task.Run(() => Task.Run(() =>
{ {
#if !DEBUG
try try
{ {
lock (lockobj) #endif
lock (lockobj)
{
if (!Directory.Exists(strDir))//如果日志文件存放的文件夹不存在,就新建一个文件夹。
{ {
if (!Directory.Exists(strDir))//如果日志文件存放的文件夹不存在,就新建一个文件夹。 Directory.CreateDirectory(strDir);
{
Directory.CreateDirectory(strDir);
}
if (File.Exists(filePath))//日志文件存放路径存在,向日志文件追加记录。
{
fs = new FileStream(filePath, FileMode.Append);
}
else//日志文件存放路径不存在,创建日志文件。
{
fs = new FileStream(filePath, FileMode.Create);
}
sw = new StreamWriter(fs);
//开始写入
sw.Write(txt);
//清空缓冲区
sw.Flush();
//关闭流
sw.Close();
fs.Close();
} }
if (File.Exists(filePath))//日志文件存放路径存在,向日志文件追加记录。
{
fs = new FileStream(filePath, FileMode.Append);
}
else//日志文件存放路径不存在,创建日志文件。
{
fs = new FileStream(filePath, FileMode.Create);
}
sw = new StreamWriter(fs);
//开始写入
sw.Write(txt);
//清空缓冲区
sw.Flush();
//关闭流
sw.Close();
fs.Close();
} }
#if !DEBUG
}
catch (Exception) catch (Exception)
{ {
;
} }
finally finally
{ {
if (sw != null) #endif
sw.Close(); if (sw != null)
if (fs != null) sw.Close();
fs.Close(); if (fs != null)
fs.Close();
#if !DEBUG
} }
#endif
}); });