コード例 #1
0
        // Gets the DLL version for the SDK -----------------------------------------------------------------
        public string GetSDKVersion()
        {
            ZBRPrinter prn = null;

            int engLevel, major, minor;

            string version = "";

            try
            {
                prn = new ZBRPrinter();

                prn.GetSDKVer(out major, out minor, out engLevel);

                if ((major + minor + engLevel) > 0)
                {
                    version = major.ToString() + "." + minor.ToString() + "." + engLevel.ToString();
                }
            }
            catch (Exception ex)
            {
                version = ex.ToString();
            }
            finally
            {
                prn = null;
            }
            return(version);
        }
コード例 #2
0
        private void WaitForJobToComplete(string printerName, int jobID, out string status)
        {
            status = string.Empty;
            SampleCodeGraphics g       = null;
            ZBRPrinter         printer = null;

            try
            {
                int errValue = 0;
                g       = new SampleCodeGraphics();
                printer = new ZBRPrinter();

                while (true)
                {
                    bool ready = g.IsPrinterReady(printerName, 60, out status);
                    if (!ready && string.IsNullOrEmpty(status))
                    {
                        if (printer.IsPrinterInErrorMode(out errValue))
                        {
                            status = "Printer in error mode: " + Convert.ToString(errValue);
                            break;
                        }
                    }
                    else if (ready) //print job completed
                    {
                        if (printer.IsPrinterInErrorMode(out errValue))
                        {
                            status = "Printer in error mode: " + Convert.ToString(errValue);
                            break;
                        }
                        status = "Success";
                        break;
                    }
                    else if (!string.IsNullOrEmpty(status))
                    {
                        string temp = string.Empty;
                        g.CancelJob(printerName, jobID, out temp);
                        status += " " + temp;
                        break;
                    }

                    if (printer.IsPrinterInErrorMode(out errValue))
                    {
                        status = "Printer in error mode: " + Convert.ToString(errValue);
                        break;
                    }

                    Thread.Sleep(1000);
                }
            }
            catch (Exception e)
            {
                status = "WaitForJobToComplete exception: " + e.Message;
            }
            finally
            {
                g       = null;
                printer = null;
            }
        }