Пример #1
0
        /// <summary>
        /// Gets the manager status. Useful after getting a non-success return code.
        /// </summary>
        /// <returns></returns>
        public TW_STATUS GetStatus()
        {
            TW_STATUS stat = default;
            var       rc   = DGControl.Status.Get(ref stat, null);

            return(stat);
        }
Пример #2
0
 public static extern ReturnCode DsmWin32(
     [In, Out] TW_IDENTITY origin,
     [In, Out] TW_IDENTITY destination,
     DataGroups dg,
     DataArgumentType dat,
     Message msg,
     ref TW_STATUS data);
Пример #3
0
        /// <summary>
        /// Gets the source status. Useful after getting a non-success return code.
        /// </summary>
        /// <returns></returns>
        public TW_STATUS GetStatus()
        {
            TW_STATUS stat = default;
            var       rc   = Session.DGControl.Status.Get(ref stat, this);

            return(stat);
        }
Пример #4
0
        public ReturnCode Get(ref TW_STATUS status, DataSource source, out string message)
        {
            message = null;
            var rc = ReturnCode.Failure;

            TW_STATUSUTF8 real = new TW_STATUSUTF8 {
                Status = status
            };

            if (Is32Bit)
            {
                if (IsWin)
                {
                    rc = NativeMethods.DsmWin32(Session.Config.App32, source?.Identity32,
                                                DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get, ref real);
                }
                else if (IsLinux)
                {
                    rc = NativeMethods.DsmLinux32(Session.Config.App32, source?.Identity32,
                                                  DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get, ref real);
                }
                else if (IsMac)
                {
                    rc = NativeMethods.DsmMac32(Session.Config.App32, source?.Identity32,
                                                DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get, ref real);
                }
            }
            else
            {
                if (IsWin)
                {
                    rc = NativeMethods.DsmWin64(Session.Config.App32, source?.Identity32,
                                                DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get, ref real);
                }
                else if (IsLinux)
                {
                    rc = NativeMethods.DsmLinux64(Session.Config.App32, source?.Identity32,
                                                  DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get, ref real);
                }
                else if (IsMac)
                {
                    rc = NativeMethods.DsmMac64(Session.Config.App32, source?.Identity32,
                                                DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get, ref real);
                }
            }

            if (rc == ReturnCode.Success)
            {
                message = ReadUtf8String(ref real);
            }

            return(rc);
        }
Пример #5
0
        public ReturnCode Get(ref TW_STATUS status, DataSource source)
        {
            if (Is32Bit)
            {
                if (IsWin)
                {
                    return(NativeMethods.DsmWin32(Session.Config.App32, source?.Identity32,
                                                  DataGroups.Control, DataArgumentType.Status, Message.Get, ref status));
                }
                if (IsLinux)
                {
                    return(NativeMethods.DsmLinux32(Session.Config.App32, source?.Identity32,
                                                    DataGroups.Control, DataArgumentType.Status, Message.Get, ref status));
                }
                if (IsMac)
                {
                    return(NativeMethods.DsmMac32(Session.Config.App32, source?.Identity32,
                                                  DataGroups.Control, DataArgumentType.Status, Message.Get, ref status));
                }
            }
            if (IsWin)
            {
                return(NativeMethods.DsmWin64(Session.Config.App32, source?.Identity32,
                                              DataGroups.Control, DataArgumentType.Status, Message.Get, ref status));
            }
            if (IsLinux)
            {
                return(NativeMethods.DsmLinux64(Session.Config.App32, source?.Identity32,
                                                DataGroups.Control, DataArgumentType.Status, Message.Get, ref status));
            }
            if (IsMac)
            {
                return(NativeMethods.DsmMac64(Session.Config.App32, source?.Identity32,
                                              DataGroups.Control, DataArgumentType.Status, Message.Get, ref status));
            }

            return(ReturnCode.Failure);
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransferErrorEventArgs"/> class.
 /// </summary>
 /// <param name="code">The code.</param>
 /// <param name="status">The status.</param>
 public TransferErrorEventArgs(ReturnCode code, TW_STATUS status)
 {
     ReturnCode   = code;
     SourceStatus = status;
 }
Пример #7
0
        /// <summary>
        /// Automatically collect the condition code for TWRC_FAILURE's...
        /// </summary>
        /// <param name="a_sts">The return code from the last operation</param>
        /// <returns>The final statue return</returns>
        private STS AutoDatStatus(STS a_sts)
        {
            STS sts;
            TW_STATUS twstatus = new TW_STATUS();

            // Automatic system is off, or the status is not TWRC_FAILURE, so just return the status we got...
            if (!m_blAutoDatStatus || (a_sts != STS.FAILURE))
            {
                return (a_sts);
            }

            // Windows...
            if (ms_platform == Platform.WINDOWS)
            {
                // Issue the command...
                try
                {
                    if (m_blUseLegacyDSM)
                    {
                        sts = (STS)WindowsTwain32DsmEntryStatus(ref m_twidentitylegacyApp, ref m_twidentitylegacyDs, DG.CONTROL, DAT.STATUS, MSG.GET, ref twstatus);
                    }
                    else
                    {
                        sts = (STS)WindowsTwaindsmDsmEntryStatus(ref m_twidentitylegacyApp, ref m_twidentitylegacyDs, DG.CONTROL, DAT.STATUS, MSG.GET, ref twstatus);
                    }
                }
                catch
                {
                    // The driver crashed...
                    TWAINWorkingGroup.Log.Error("Driver crash...");
                    return (STS.BUMMER);
                }
            }

            // Linux...
            else if (ms_platform == Platform.LINUX)
            {
                // Issue the command...
                try
                {
                    sts = (STS)LinuxDsmEntryStatus(ref m_twidentitylegacyApp, ref m_twidentitylegacyDs, DG.CONTROL, DAT.STATUS, MSG.GET, ref twstatus);
                }
                catch
                {
                    // The driver crashed...
                    TWAINWorkingGroup.Log.Error("Driver crash...");
                    return (STS.BUMMER);
                }
            }

            // Mac OS X, which has to be different...
            else if (ms_platform == Platform.MACOSX)
            {
                // Issue the command...
                try
                {
                    sts = (STS)MacosxDsmEntryStatus(ref m_twidentitymacosxApp, ref m_twidentitymacosxDs, DG.CONTROL, DAT.STATUS, MSG.GET, ref twstatus);
                }
                catch
                {
                    // The driver crashed...
                    TWAINWorkingGroup.Log.Error("Driver crash...");
                    return (STS.BUMMER);
                }
            }

            // Uh-oh...
            else
            {
                TWAINWorkingGroup.Log.Assert("Unsupported platform..." + ms_platform);
                return (STS.BUMMER);
            }

            // Uh-oh, the status call failed...
            if (sts != STS.SUCCESS)
            {
                return (a_sts);
            }

            // All done...
            return ((STS)(STSCC + twstatus.ConditionCode));
        }
Пример #8
0
        /// <summary>
        /// Gets the translated string for a <see cref="TW_STATUS"/>.
        /// </summary>
        /// <param name="status"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public string GetLocalizedStatus(ref TW_STATUS status, DataSource source = null)
        {
            var rc = DGControl.StatusUtf8.Get(ref status, source, out string message);

            return(message);
        }
Пример #9
0
 private static extern UInt16 MacosxDsmEntryStatus
 (
     ref TW_IDENTITY_MACOSX origin,
     ref TW_IDENTITY_MACOSX dest,
     DG dg,
     DAT dat,
     MSG msg,
     ref TW_STATUS twstatus
 );
Пример #10
0
 private static extern UInt16 Linux64DsmEntryStatus
 (
     ref TW_IDENTITY origin,
     ref TW_IDENTITY dest,
     DG dg,
     DAT dat,
     MSG msg,
     ref TW_STATUS twstatus
 );
Пример #11
0
 private static extern UInt16 WindowsTwaindsmDsmEntryStatus
 (
     ref TW_IDENTITY_LEGACY origin,
     ref TW_IDENTITY_LEGACY dest,
     DG dg,
     DAT dat,
     MSG msg,
     ref TW_STATUS twstatus
 );