예제 #1
0
            public ConnecttionJob tryToConnect(Int32 port, string deviceAdress, int timeout, PrinterZebra.EPrinterConnectionType connType)
            {
                Logger.Write("tryToConnect: " + port.ToString() + ", " + deviceAdress + ", " + timeout.ToString());

                ConnecttionJob job = new ConnecttionJob();

                job.MaxTimeoutForRead     = 0;
                job.TimeToWaitForMoreData = 0;
                job.Port           = port;
                job.Address        = deviceAdress;
                job.ConnectionType = connType;

                job.Connect(timeout);

                return(job);
            }
예제 #2
0
        public ConnecttionJob tryToConnect(Int32 port, string deviceAdress, int timeout, PrinterZebra.EPrinterConnectionType connType)
        {
            Logger.Write("tryToConnect: " + port.ToString() + ", " + deviceAdress + ", " + timeout.ToString());

            ConnecttionJob job = new ConnecttionJob();

            job.MaxTimeoutForRead     = 0;
            job.TimeToWaitForMoreData = 0;
            job.Port                  = port;
            job.Address               = deviceAdress;
            job.ConnectionType        = connType;

            job.Connect(timeout);

            return job;
        }
예제 #3
0
        public void connectWithOptions(IReadOnlyDictionary<string, string> options, IMethodResult oResult)
        {
            Logger.Write("connectWithOptions call");
            Logger.Write("options:", options);

            string valueObj = null;
            Int32  connectionTimeout = 0;

            if (m_connection != null && m_connection.IsConnected() && m_printer != null)
            {
                m_connection.Close();

                Thread.Sleep(1000);

                m_connection = null;
                m_printer    = null;
            }

            if (options.ContainsKey(ZebraConstants.HK_TIMEOUT))
            {
                valueObj = options[ZebraConstants.HK_TIMEOUT];

                if ((valueObj != null) && (valueObj is String))
                {
                    try
                    {
                        connectionTimeout = Int32.Parse(valueObj.ToString());
                    }
                    catch (System.FormatException)
                    {
                        m_maxTimeoutForRead = 0;
                    }
                }
            }

            if (options.ContainsKey(ZebraConstants.PROPERTY_MAX_TIMEOUT_FOR_READ))
            {
                valueObj = options[ZebraConstants.PROPERTY_MAX_TIMEOUT_FOR_READ];
                
                if ((valueObj != null) && (valueObj is String))
                {
                    try
                    {
                        m_maxTimeoutForRead = Int32.Parse(valueObj.ToString());
                    }
                    catch (System.FormatException)
                    {
                        m_maxTimeoutForRead = 0;
                    }
                }
            }

            if (options.ContainsKey(ZebraConstants.PROPERTY_TIME_TO_WAIT_FOR_MORE_DATA))
            {
                valueObj = options[ZebraConstants.PROPERTY_TIME_TO_WAIT_FOR_MORE_DATA];

                if ((valueObj != null) && (valueObj is String))
                {
                    try
                    {
                        m_timeToWaitForMoreData = Int32.Parse(valueObj.ToString());
                    }
                    catch (System.FormatException)
                    {
                        m_maxTimeoutForRead = 0;
                    }
                }
            }
            
            ConnecttionJob job = new ConnecttionJob();

            job.Address               = ID;
            job.Port                  = Port;
            job.ConnectionType        = connectionType;
            job.MaxTimeoutForRead     = m_maxTimeoutForRead;
            job.TimeToWaitForMoreData = m_timeToWaitForMoreData;

            if (connectionTimeout == 0)
            {
                job.Connect();
            }
            else
            {
                if (!job.Connect(connectionTimeout))
                {
                    oResult.set(ZebraConstants.PRINTER_STATUS_ERR_TIMEOUT);
                    return;
                }
            }
            
            if (job.Connection != null && job.Printer != null)
            {
                m_connection = job.Connection;
                m_printer    = job.Printer;

                oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS);
                return;
            }

            oResult.set(ZebraConstants.PRINTER_STATUS_ERR_NOT_CONNECTED);
        }
예제 #4
0
            public void connectWithOptions(IReadOnlyDictionary <string, string> options, IMethodResult oResult)
            {
                Logger.Write("connectWithOptions call");
                Logger.Write("options:", options);

                string valueObj          = null;
                Int32  connectionTimeout = 0;

                if (m_connection != null && m_connection.IsConnected() && m_printer != null)
                {
                    m_connection.Close();

                    Thread.Sleep(1000);

                    m_connection = null;
                    m_printer    = null;
                }

                if (options.ContainsKey(ZebraConstants.HK_TIMEOUT))
                {
                    valueObj = options[ZebraConstants.HK_TIMEOUT];

                    if ((valueObj != null) && (valueObj is String))
                    {
                        try
                        {
                            connectionTimeout = Int32.Parse(valueObj.ToString());
                        }
                        catch (System.FormatException)
                        {
                            m_maxTimeoutForRead = 0;
                        }
                    }
                }

                if (options.ContainsKey(ZebraConstants.PROPERTY_MAX_TIMEOUT_FOR_READ))
                {
                    valueObj = options[ZebraConstants.PROPERTY_MAX_TIMEOUT_FOR_READ];

                    if ((valueObj != null) && (valueObj is String))
                    {
                        try
                        {
                            m_maxTimeoutForRead = Int32.Parse(valueObj.ToString());
                        }
                        catch (System.FormatException)
                        {
                            m_maxTimeoutForRead = 0;
                        }
                    }
                }

                if (options.ContainsKey(ZebraConstants.PROPERTY_TIME_TO_WAIT_FOR_MORE_DATA))
                {
                    valueObj = options[ZebraConstants.PROPERTY_TIME_TO_WAIT_FOR_MORE_DATA];

                    if ((valueObj != null) && (valueObj is String))
                    {
                        try
                        {
                            m_timeToWaitForMoreData = Int32.Parse(valueObj.ToString());
                        }
                        catch (System.FormatException)
                        {
                            m_maxTimeoutForRead = 0;
                        }
                    }
                }

                ConnecttionJob job = new ConnecttionJob();

                job.Address               = ID;
                job.Port                  = Port;
                job.ConnectionType        = connectionType;
                job.MaxTimeoutForRead     = m_maxTimeoutForRead;
                job.TimeToWaitForMoreData = m_timeToWaitForMoreData;

                if (connectionTimeout == 0)
                {
                    job.Connect();
                }
                else
                {
                    if (!job.Connect(connectionTimeout))
                    {
                        oResult.set(ZebraConstants.PRINTER_STATUS_ERR_TIMEOUT);
                        return;
                    }
                }

                if (job.Connection != null && job.Printer != null)
                {
                    m_connection = job.Connection;
                    m_printer    = job.Printer;

                    oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS);
                    return;
                }

                oResult.set(ZebraConstants.PRINTER_STATUS_ERR_NOT_CONNECTED);
            }