Beispiel #1
0
        /// <summary>
        /// repeatedly check job status until the job is complete - failed or not.
        /// </summary>
        public static void PollForJobCompletion(BidiSplWrap bidiSpl, int printerJobID)
        {
            const int pollSleepMilliseconds = 2000;

            while (true)
            {
                string printerStatusXML = bidiSpl.GetPrinterData(strings.PRINTER_MESSAGES);
                PrinterStatusValues printerStatusValues = Util.ParsePrinterStatusXML(printerStatusXML);

                if ((0 != printerStatusValues._errorCode) && (printerJobID == printerStatusValues._printerJobID))
                {
                    string message = string.Format("{0} severity: {1}", printerStatusValues._errorString, printerStatusValues._errorSeverity);
                    throw new BidiException(message, printerStatusValues._printerJobID, printerStatusValues._errorCode);
                }

                string          jobStatusRequest = strings.JOB_STATUS_XML;
                string          jobInfoXML       = string.Format(jobStatusRequest, printerJobID);
                string          jobStatusXML     = bidiSpl.GetPrinterData(strings.JOB_STATUS, jobInfoXML);
                JobStatusValues jobStatusValues  = Util.ParseJobStatusXML(jobStatusXML);

                Console.WriteLine("Printer job ID: {0} {1}", printerJobID, jobStatusValues._jobState);

                if (strings.JOB_ACTIVE != jobStatusValues._jobState)
                {
                    return;
                }

                Thread.Sleep(pollSleepMilliseconds);
            }
        }
Beispiel #2
0
        public static JobStatusValues ParseJobStatusXML(string jobStatusValues)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(jobStatusValues);

            JobStatusValues jobStatusXML = new JobStatusValues();

            jobStatusXML._clientID        = StringFromXml(doc, "JobStatus/ClientID");
            jobStatusXML._jobRestartCount = IntFromXml(doc, "JobStatus/JobRestartCount");
            jobStatusXML._jobState        = StringFromXml(doc, "JobStatus/JobState");
            jobStatusXML._printerJobID    = IntFromXml(doc, "JobStatus/PrinterJobID");
            jobStatusXML._windowsJobID    = IntFromXml(doc, "JobStatus/WindowsJobID");

            return(jobStatusXML);
        }