diff --git a/ControlBlock/ControlBlock/ViewModel/ControlBlockViewModel.cs b/ControlBlock/ControlBlock/ViewModel/ControlBlockViewModel.cs
index 469f1ef..17a768c 100644
--- a/ControlBlock/ControlBlock/ViewModel/ControlBlockViewModel.cs
+++ b/ControlBlock/ControlBlock/ViewModel/ControlBlockViewModel.cs
@@ -77,7 +77,7 @@ private void ExecuteCloseWindow(object obj)
// Close 버튼
App.SendPacketToServer(new DataPacket());
- if (System.Windows.Forms.MessageBox.Show("로그아웃 하시겠습니까?", "TYPRESS Logout", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ if (System.Windows.Forms.MessageBox.Show("프린트를 중단하고, 로그아웃 하시겠습니까?", "TYPRESS Logout", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
System.Windows.Forms.MessageBox.Show("로그아웃을 하였습니다 :)");
System.Environment.Exit(1);
diff --git a/Server-Service/MyService/DvPrinter.cs b/Server-Service/MyService/DvPrinter.cs
index 5d9dfc8..015e1eb 100644
--- a/Server-Service/MyService/DvPrinter.cs
+++ b/Server-Service/MyService/DvPrinter.cs
@@ -17,6 +17,12 @@ namespace MyService
class DvPrinter
{
+ public enum PRINTOPT
+ {
+ PRINT_OPT_LISTEN = 0,
+ PRINT_OPT_CANCLE = 1,
+ PRINT_OPT_PRINT = 2
+ }
#region Monitor private variables
private IntPtr _printerHandle = IntPtr.Zero;
private IntPtr _changeHandle = IntPtr.Zero;
@@ -231,6 +237,7 @@ private void OnFunctionCalledPrinterEnd(INktHook hhook, INktProcess proc, INktHo
#region PrintStart
public void MonitorStart()
{
+ System.Diagnostics.Debugger.Launch();
// out _printerHandle을 통해, 이름이 _spoolerName인 프린터의 제어권을 얻어온다.
OpenPrinter(_spoolerName, out _printerHandle, 0);
@@ -291,7 +298,7 @@ public void PrinterNotifyWaitCallback(Object state, bool timedOut)
Console.WriteLine("pdwChange : {0} / pNotifiyInfo : {1}", pdwChange, pNotifyInfo);
//If the Printer Change Notification Call did not give data, exit code
- if ((bResult == false) || (((int)pNotifyInfo) == 0)) return;
+ if ((bResult == false) || (pNotifyInfo.ToInt64() == 0)) return;
//If the Change Notification was not relgated to job, exit code
//Job이 ADDJOB, 이딴게 맞는지 한번 보는 것!!
@@ -302,21 +309,11 @@ public void PrinterNotifyWaitCallback(Object state, bool timedOut)
if (!bJobRelatedChange) return;
#endregion
- #region Interrupt Catch!!!!!!
- if (bJobRelatedChange == ((pdwChange & PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB) == PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB))
- {
- Console.WriteLine("☆☆☆☆☆☆☆☆ Login Auth ☆☆☆☆☆☆☆☆");
- // if(로그인 여부 -> Login 성공 -> CB) 프린터 계속 진행.
- // if(종료) 함수종료.
-
- }
- #endregion
-
#region populate Notification Information
//Now, let us initialize and populate the Notify Info data
PRINTER_NOTIFY_INFO info = (PRINTER_NOTIFY_INFO)Marshal.PtrToStructure(pNotifyInfo, typeof(PRINTER_NOTIFY_INFO));
- int pData = (int)pNotifyInfo + Marshal.SizeOf(typeof(PRINTER_NOTIFY_INFO));
+ Int64 pData = pNotifyInfo.ToInt64() + Marshal.SizeOf(typeof(PRINTER_NOTIFY_INFO));
PRINTER_NOTIFY_INFO_DATA[] data = new PRINTER_NOTIFY_INFO_DATA[info.Count];
for (uint i = 0; i < info.Count; i++)
{
@@ -347,10 +344,26 @@ public void PrinterNotifyWaitCallback(Object state, bool timedOut)
if (bJobRelatedChange == ((pdwChange & PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB) == PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB))
{
- Console.WriteLine("★★★★★★★★ Print Out [First] ★★★★★★★★");
+ //Console.WriteLine("★★★★★★★★ Print Out [First] ★★★★★★★★");
// Print 시작 ~ 종료까지 Thread 대기 걸고.
// Print Real Page Count 넣어야 한다.
- pji.Cancel();
+
+ // while(ThreadHandler.PrintedOpt == 0 && cnt <= 60){
+ // Thread.Sleep(1000);
+ // cnt++;
+ //
+ // }
+ // if(cnt >= 60) pji.Cancle();
+ // if(ThreadHandler.PrintedOpt == 1) pji.Cancle();
+ //
+ int ThreadTimer = 0;
+ while (ThreadHandler.PrintedOpt == (int)PRINTOPT.PRINT_OPT_LISTEN && ThreadTimer <= 60)
+ {
+ Thread.Sleep(1000);
+ ThreadTimer++;
+ }
+ if(ThreadHandler.PrintedOpt == (int)PRINTOPT.PRINT_OPT_CANCLE || ThreadTimer >= 60) pji.Cancel();
+ ThreadHandler.PrintedOpt = (int)PRINTOPT.PRINT_OPT_LISTEN;
}
}
catch
diff --git a/Server-Service/MyService/Handler/Handler_Socket/SocketHandler5002CB.cs b/Server-Service/MyService/Handler/Handler_Socket/SocketHandler5002CB.cs
index f518061..a61bc6d 100644
--- a/Server-Service/MyService/Handler/Handler_Socket/SocketHandler5002CB.cs
+++ b/Server-Service/MyService/Handler/Handler_Socket/SocketHandler5002CB.cs
@@ -49,7 +49,7 @@ public void ServerOpenCB(object port)
//System.Diagnostics.Debugger.Launch();
//while (ThreadHandler.MainPacket.IsLogin && !Exit)
//{
- ReceivePacketFromClientCBClientDBUpdate();
+ ReceivePacketFromClientCBClientDBUpdate();
//}
}
catch (SocketException socketEx)
@@ -172,19 +172,21 @@ public static void ReceivePacketFromClientCBClientDBUpdate()
//}
// 마일리지, 인쇄수 Update
- if(packet.Opt == 0)
+ if(packet.Opt == 0) // Close
{
ThreadHandler.MainPacket = new DataPacket();
+ ThreadHandler.PrintedOpt = 1; // 1 : Cancle
return;
}
int c = 0;
- while (packet.Opt == 1 && DvPrinter.PageCntData == 0 && c < 60)
+ while (packet.Opt == 1 && DvPrinter.PageCntData == 0 && c < 60) // Print
{
c++;
Thread.Sleep(1000);
}
if (c >= 60) return;
+ if (packet.Money < 0) return;
packet = UpdateMileage(packet, DvPrinter.PageCntData);
diff --git a/Server-Service/MyService/Handler/Handler_Thread/ThreadHandler.cs b/Server-Service/MyService/Handler/Handler_Thread/ThreadHandler.cs
index 6d3fb7e..90b902b 100644
--- a/Server-Service/MyService/Handler/Handler_Thread/ThreadHandler.cs
+++ b/Server-Service/MyService/Handler/Handler_Thread/ThreadHandler.cs
@@ -21,6 +21,7 @@ class ThreadHandler
public static DataPacket MainPacket = new DataPacket();
public static PrintedPacket PrintPacket = new PrintedPacket();
+ public static int PrintedOpt; // 0 : 수신중 / 1 : Pass / 2 : Cancle
public DvPrinter dv = new DvPrinter();
public SocketHandler LoginSocketHandler = new SocketHandler();
public SocketHandler MainSocketHandler = new SocketHandler();
diff --git a/Server-Service/MyService/MyService.csproj b/Server-Service/MyService/MyService.csproj
index 5a757c4..2884069 100644
--- a/Server-Service/MyService/MyService.csproj
+++ b/Server-Service/MyService/MyService.csproj
@@ -78,6 +78,7 @@
+
@@ -95,6 +96,8 @@
+
+
Component