Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CB] Print버튼누르면 인쇄.(Unhook()) #14

Open
jongwuner opened this issue Nov 12, 2019 · 17 comments
Open

[CB] Print버튼누르면 인쇄.(Unhook()) #14

jongwuner opened this issue Nov 12, 2019 · 17 comments
Assignees
Labels
question Further information is requested
Projects
Milestone

Comments

@jongwuner
Copy link
Collaborator

CB상에서 인쇄

호출과정 : Server-Service -> InterruptLogin -> CB

Server-service에서 하는게 제일깔끔하긴 한데..

@jongwuner jongwuner added the question Further information is requested label Nov 12, 2019
@jongwuner jongwuner self-assigned this Nov 12, 2019
@jongwuner jongwuner added this to the 1.1.0 first-confirm milestone Nov 12, 2019
@jongwuner
Copy link
Collaborator Author

jongwuner commented Nov 12, 2019

사전에 TotalPage수 모두 파악

  • WMI에 TotalPage
  • PDF로 StartPagePrinter 후 실제 Print
  • PrintTicket ?

@jongwuner
Copy link
Collaborator Author

CB상에서 인쇄,

  • CB Socket이용해서 Data받아온다.
  • if( >=0 ) unhook()

@jongwuner jongwuner removed this from the 1.1.0 first-confirm milestone Nov 14, 2019
@jongwuner
Copy link
Collaborator Author

jongwuner commented Nov 14, 2019

CB Socket에서 로직을 조금 추가해야 겠다.

  • loop 형태도 만들고, if(잔여 프린트물)
  • 지금 현재 마일리지 값을 서버로 전송/수신 해주고,

@jongwuner jongwuner reopened this Nov 14, 2019
@jongwuner jongwuner changed the title CB상에서 마일리지 - 인쇄비 >= 0 일 경우, 인쇄 CB상에서 if(마일리지 - 인쇄비 >= 0) 일 경우, 인쇄 Nov 14, 2019
@jongwuner jongwuner added this to in progress in typress Nov 14, 2019
@jongwuner jongwuner changed the title CB상에서 if(마일리지 - 인쇄비 >= 0) 일 경우, 인쇄 CB상에서 Print버튼누르면 인쇄.(Unhook()) Nov 17, 2019
@jongwuner jongwuner changed the title CB상에서 Print버튼누르면 인쇄.(Unhook()) [CB] Print버튼누르면 인쇄.(Unhook()) Nov 17, 2019
@jongwuner jongwuner added this to the 1.1.0 milestone Nov 18, 2019
@jongwuner
Copy link
Collaborator Author

jongwuner commented Nov 18, 2019

사용하지 않고 있는 PrinterSocket을 여기서 사용하면 될듯 하다.

  • MyService : Hook 코드 안에 PrinterSocket.Receive()으로 대기
  • CB : Print -> PrinterSocket.Send()

그러면 CB상에서 Socket 2개 필요한가?

  • CB자체 소켓.
  • PrinterSocket 송신용 소켓.

@jongwuner
Copy link
Collaborator Author

마일리지가 부족할 경우, Print를 아예 취소할 수도 있어야 한다.

@jongwuner
Copy link
Collaborator Author

jongwuner commented Nov 22, 2019

PrintController.Receive(); <--- Socket을 통한 대기

  1. if(pk.IsPrint == true) ----잔액확인---> Unhook();
  2. `else printJob.Cancle(); <----잔액없을 경우 || 2분이 초과된 경우
  3. 신호가 장시간 동안 오지 않는 경우 ---> Socket에 2분정도의 시간제한을 걸어야겠다.
    -> Thread.Sleep() 을 통한 Count로 break문 걸면 된다.

@jongwuner
Copy link
Collaborator Author

PrinterServer (.NET)

  • Network Server
  • Local Server

@jongwuner
Copy link
Collaborator Author

#25

@jongwuner
Copy link
Collaborator Author

  1. Service에서 PrintSocket 대기
  2. Hooking 함수에서 Receive
  • WaitForSingleObject()
  • Bit 주는 방식

jongwuner added a commit that referenced this issue Nov 30, 2019
#14 에서 부분적 해결(Print버튼 누르면 Unhook 구현)

# CB : PrintSocket 사용해서, Button을 눌러주면 Sever로 PrintPacket전송

# DataPacket : 여기에 PrintedPacket을 추가함

# Server : ManualResetEvent 활용해서 비동기 관리
- SocketHandler5003 : Packet받으면 PrintBit.Set
@jongwuner
Copy link
Collaborator Author

Return Value를 통해 경우를 조금 더 줄여보자.

image

@jongwuner
Copy link
Collaborator Author

jongwuner commented Nov 30, 2019

To-do 정리

  • Real PrintCnt 를 언제 넘겨주어야 하는지? ------> 후불제
  • Real PrintCnt 를 실셈하는 모듈 구현해보기? ----> 후불제
  • PrintJob.Cancle 모듈 구현하기
  • 로그인창이 중도에 끊겼을때, 어떻게 처리할 것인가?
    • Return Value 를 이용할 것인가?
    • Timer을 이용할 것인가?
      -> Thread.Sleep(1000) 을 통한 Cnt++

@jongwuner
Copy link
Collaborator Author

PrintJob.Cancle 구현 성공.

#25 참고
image

@jongwuner
Copy link
Collaborator Author

후불제를 했을 때 생기는 문제점

image

  • 지금 현재 UI의 구성을 바꿔야 한다. ------> 이것을 바꾸면 너무 조잡해지지 않나 싶다.
  • DB업데이트를 서버자체에서 해줘야한다. -----> 이정도는 수정 가능.
private void ExecutePrint(object obj)
        {
            if (System.Windows.Forms.MessageBox.Show("출력할 인쇄물이 남았습니까?", "TYPRESS Print", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                System.Windows.Forms.MessageBox.Show("출력을 진행합니다.");

                App.PrintSocketConnect();
                UpdateDB();

                dp.Opt = 1; // 소켓 종료 메세지
                App.SendPacketToServer(dp);
                dp.Opt = 0;

                pp.IsPrinted = true;
                App.SendPrintPacketToServer(pp);
                pp.IsPrinted = false;

                System.Environment.Exit(0);
            }
            else
            {
                App.SendPacketToServer(new DataPacket());
                System.Windows.Forms.MessageBox.Show("로그아웃");
                ViewHandler.OpenLoginViewFromMain();
                System.Environment.Exit(1);
            }
        } 

jongwuner added a commit that referenced this issue Dec 1, 2019
#14

# CB
- cnt를 추가해서 default가 1인것으로 수정

# DataPacket
- ThisPrintJobCnt 추가
- ThisPrintJob.Cancle() 부분 추가
  - 추후에 Merge 해야함.
jongwuner added a commit that referenced this issue Dec 3, 2019
#17 #14

# 실제 프린터매수를 CB에서 볼 필요가 있을까 하는 의문이 들었음.
- 구현을 하기가 상당히 까다롭고, 그 비용에 비해서 얻는 이익이 적다는 판단으로,
이렇게 코딩하게 되었음.
@jongwuner
Copy link
Collaborator Author

jongwuner commented Dec 3, 2019

UI 수정필요

image

  • View Main을 Print위로 합친다.
  • UI상에서 단위를 명확하게 하자. (레이아웃 구성때문에 내가 직접 수정하지 않았음.)

jongwuner added a commit that referenced this issue Dec 3, 2019
#14
# Printer 매수 반영하긴 하는데, 무한루프 문제 발생.
* 이런 시나리오가 없긴 한데, 그래도 가능은 해야 할 듯.

-> 무한루프 탈출시키는 로직을 추가시켜야 함.
jongwuner added a commit that referenced this issue Dec 3, 2019
#14  로그아웃 잘되게끔

- packet.Opt == 0 : 로그아웃
- packet.Opt == 1 : 계속 Print 하겠다.
jongwuner added a commit that referenced this issue Dec 3, 2019
#14
# Printer 매수 반영하긴 하는데, 무한루프 문제 발생.
* 이런 시나리오가 없긴 한데, 그래도 가능은 해야 할 듯.

-> 무한루프 탈출시키는 로직을 추가시켜야 함.
jongwuner added a commit that referenced this issue Dec 3, 2019
#14  로그아웃 잘되게끔

- packet.Opt == 0 : 로그아웃
- packet.Opt == 1 : 계속 Print 하겠다.
jongwuner added a commit that referenced this issue Dec 4, 2019
#25 #14

# DvPrinter, PrintJobChangeEventArgs, PrintSpoolAPI
- Monitor 병합 부분 (아직 Test는 못해봤음.)

# To-do
- ThreadHandler.PrintedOpt 값을 어디선가 바꿔줄 부분이 필요함.
- 주석으로 작성해두었음.
- 상호배제 등 공유자원 방지를 할 수 있게끔 조치가 필요.
@jongwuner
Copy link
Collaborator Author

jongwuner commented Dec 4, 2019

ThreadHandler.PrintedOpt

  • 일단 Monitor는 별도의 스레드로 진행이 된다.
  • Monitor Thread : AddJob을 잡아내고나서, 거기에서 ThreadHandler.PrintedOpt의 값을 기다리며(Timer), Cancle시키는지, Pass하는지(그대로 Print를 하는지)를 기다림.

  • Print를 클릭했는지 ----> 잔액이 남아있는지 -----> 남아있다면 Pass
    -----> 잔액이 없다면 Cancle()
  • Cancle을 클릭했는지 -------------------------------> Cancle()
  • 시간초과, 오류로 연결끊어짐 등 -------------------> Cancle()

@jongwuner
Copy link
Collaborator Author

jongwuner commented Dec 5, 2019

To-do (상수화 필요)

  • packet.Opt
  • PrintedOpt
    image
  • MessageBox UI에서 볼 수 있도록 해야 함.

@jongwuner
Copy link
Collaborator Author

jongwuner commented Dec 5, 2019

Cancle 시, Hooking 함수에서 WaitOne을 해결해주어야 함.

image

  • Cancle시 무한루프 발생
  • DataPacket에서 bool IsPrinted;를 Int형으로 변환해서 선택지를 늘려야할 듯 하다.
  • Cancle마일리지 부족의 경우에 PrintSocket쪽에 패킷을 전달해주어야 한다.

DvPrinter.Monitor

  • 이 쪽에서 반응을 안한다는 뜻
  • Monitor에서 잡히긴 하는데, if문에 걸리지가 않음.
                        if (bJobRelatedChange == ((pdwChange & PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB) == PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB))
                        {
                            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;
                        }
    public class PRINTER_CHANGES
    {
        public const uint PRINTER_CHANGE_ADD_PRINTER = 1;
        public const uint PRINTER_CHANGE_SET_PRINTER = 2;
        public const uint PRINTER_CHANGE_DELETE_PRINTER = 4;
        public const uint PRINTER_CHANGE_FAILED_CONNECTION_PRINTER = 8;
        public const uint PRINTER_CHANGE_PRINTER = 0xFF;
        public const uint PRINTER_CHANGE_ADD_JOB = 0x100;
        public const uint PRINTER_CHANGE_SET_JOB = 0x200;
        public const uint PRINTER_CHANGE_DELETE_JOB = 0x400;
        public const uint PRINTER_CHANGE_WRITE_JOB = 0x800;
        public const uint PRINTER_CHANGE_JOB = 0xFF00;
        public const uint PRINTER_CHANGE_ADD_FORM = 0x10000;
        public const uint PRINTER_CHANGE_SET_FORM = 0x20000;
        public const uint PRINTER_CHANGE_DELETE_FORM = 0x40000;
        public const uint PRINTER_CHANGE_FORM = 0x70000;
        public const uint PRINTER_CHANGE_ADD_PORT = 0x100000;
        public const uint PRINTER_CHANGE_CONFIGURE_PORT = 0x200000;
        public const uint PRINTER_CHANGE_DELETE_PORT = 0x400000;
        public const uint PRINTER_CHANGE_PORT = 0x700000;
        public const uint PRINTER_CHANGE_ADD_PRINT_PROCESSOR = 0x1000000;
        public const uint PRINTER_CHANGE_DELETE_PRINT_PROCESSOR = 0x4000000;
        public const uint PRINTER_CHANGE_PRINT_PROCESSOR = 0x7000000;
        public const uint PRINTER_CHANGE_ADD_PRINTER_DRIVER = 0x10000000;
        public const uint PRINTER_CHANGE_SET_PRINTER_DRIVER = 0x20000000;
        public const uint PRINTER_CHANGE_DELETE_PRINTER_DRIVER = 0x40000000;
        public const uint PRINTER_CHANGE_PRINTER_DRIVER = 0x70000000;
        public const uint PRINTER_CHANGE_TIMEOUT = 0x80000000;
        public const uint PRINTER_CHANGE_ALL = 0x7777FFFF;
    }

  • Cancle 버튼만 눌렀을때, back-end랑 front-end랑 잘 안맞는 부분이 있는 것 같다.
  • 한글 무한루프

jongwuner added a commit that referenced this issue Dec 5, 2019
#14

# CB에서 VM수정
- UI 문구
- CB의 본질적인 목적이 무엇일까 생각해보자.

# DvPrinter
- ToInt64()로 바꾸니, Overflow 해결
- PRINT_OPT에 따라 pji.Cancle() 적용.
* 지금 제대로 작동하지는 않는다.

# CBSocket
- (189) Money가 0보다 작으면, Cancle()시키려는 의도.
- Todo : UI에서 MessageBox 보여줘야함.

# ThreadHandler
- PrintedOpt 변수에 대한 설명 주석 추가
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
typress
in progress
Development

No branches or pull requests

1 participant