Ejemplo n.º 1
0
        public static void ListenRemotePrintBlocking(RemotePrinterHandlerDelegate processPrinting)
        {
            String user        = "";
            String printerName = "";
            String jobId       = "";
            String path        = "";

            try
            {
                SeapClient sClient = SeapClient.GetTrapInstance();
                Logger.GetInstance().Debug("TRAP");
                String   response;
                String[] splitResp;

                response  = sClient.sendMessage("TRAP");
                splitResp = response.Split(' ');
                if (!splitResp[0].Equals("OK"))
                {
                    return;
                }
                if (splitResp[1].StartsWith("retrap"))
                {
                    return;
                }
                else if (splitResp[1].StartsWith("print"))
                {
                    path = splitResp[2];
                    for (int i = 3; i < splitResp.Length; i++)
                    {
                        int    idx = splitResp[i].IndexOf('=');
                        String key = splitResp[i].Substring(0, idx);
                        String val = splitResp[i].Substring(idx + 1);
                        val = qpDecode(val);
                        if (key == "user")
                        {
                            user = val;
                        }
                        else if (key == "user")
                        {
                            user = val;
                        }
                        else if (key == "printerName")
                        {
                            printerName = val;
                        }
                        else if (key == "jobId")
                        {
                            jobId = val;
                        }
                    }
                    Logger.GetInstance().Info("Handling remte print on server for remote user:"******" printerName: " + printerName + " jobId: " + jobId + " path: " + path);
                    processPrinting(jobId, path, printerName);
                }
            }
            catch (Exception e)
            {
                Logger.GetInstance().Error(e);
            }
        }
        public static void ListenRemotePrintBlocking(RemotePrinterHandlerDelegate processPrinting)
        {
            String user = "";
            String printerName = "";
            String jobId = "";
            String path = "";

            try
            {
                SeapClient sClient = SeapClient.GetTrapInstance();
                Logger.GetInstance().Debug("TRAP");
                String response;
                String[] splitResp;

                response = sClient.sendMessage("TRAP");
                splitResp = response.Split(' ');
                if (!splitResp[0].Equals("OK"))
                {
                    return;
                }
                if (splitResp[1].StartsWith("retrap"))
                {
                    return;
                }
                else if (splitResp[1].StartsWith("print"))
                {
                    path = splitResp[2];
                    for (int i = 3; i < splitResp.Length; i++)
                    {
                        int idx = splitResp[i].IndexOf('=');
                        String key = splitResp[i].Substring(0, idx);
                        String val = splitResp[i].Substring(idx + 1);
                        val = qpDecode(val);
                        if (key == "user") user = val;
                        else if (key == "user") user = val;
                        else if (key == "printerName") printerName = val;
                        else if (key == "jobId") jobId = val;
                    }
                    Logger.GetInstance().Info("Handling remte print on server for remote user:"******" printerName: " + printerName + " jobId: " + jobId + " path: " + path);
                    processPrinting(jobId, path, printerName);
                }
            }
            catch (Exception e)
            {
                Logger.GetInstance().Error(e);
            }
        }