Пример #1
0
        private static void SetCheckData(ref CheckData checkData)
        {
            int           nRet;
            StringBuilder strResponse = new StringBuilder();

            strResponse.Capacity = 4096;
            int    nResponseLength = 4096;
            string strTmp;

            if (SelectedDocType == DocType.MSR)
            {
                checkData.OtherData     = string.Empty;
                checkData.RoutingNumber = string.Empty;
                checkData.AccountNumber = string.Empty;
                checkData.CheckNumber   = string.Empty;
            }
            else
            {
                nRet   = MTMICRGetValue(DocInfo, "DocInfo", "MICRRaw", strResponse, ref nResponseLength);
                strTmp = strResponse.ToString();
                checkData.ScannedCheckMicrData = strTmp;

                nRet   = MTMICRGetValue(DocInfo, "DocInfo", "MICRTransit", strResponse, ref nResponseLength);
                strTmp = strResponse.ToString();
                checkData.RoutingNumber = strTmp;

                nRet   = MTMICRGetValue(DocInfo, "DocInfo", "MICRAcct", strResponse, ref nResponseLength);
                strTmp = strResponse.ToString();
                checkData.AccountNumber = strTmp;

                nRet   = MTMICRGetValue(DocInfo, "DocInfo", "MICRSerNum", strResponse, ref nResponseLength);
                strTmp = strResponse.ToString();
                checkData.CheckNumber = strTmp;
            }
        }
Пример #2
0
        private static void SetImageData(ref CheckData checkData)
        {
            int           nRet;
            StringBuilder strResponse = new StringBuilder();

            strResponse.Capacity = 4096;
            int    nResponseLength = 4096;
            int    nImageSize;
            string strTmp;
            string strImageID;


            nRet       = MTMICRGetIndexValue(DocInfo, "ImageInfo", "ImageSize", 1, strResponse, ref nResponseLength);
            strTmp     = strResponse.ToString();
            nImageSize = Convert.ToInt32(strTmp);

            if (nImageSize > 0)
            {
                nRet       = MTMICRGetIndexValue(DocInfo, "ImageInfo", "ImageURL", 1, strResponse, ref nResponseLength);
                strImageID = strResponse.ToString();
                string strLog = "Image size =" + nImageSize + "ImageID = " + strImageID;
                Trace.WriteLine(strLog);

                byte[] imageBuf = new byte[nImageSize];

                nRet = MTMICRGetImage(CurrentDeviceName, strImageID, imageBuf, ref nImageSize);
                if (nRet == ( int )MICR_ST_OK)
                {
                    checkData.ImageData = imageBuf;
                    int nActualSize = nImageSize;
                    strLog = "NumOfBytes to write =" + nActualSize;

                    Trace.WriteLine(strLog);

                    IntPtr pOverlapped = IntPtr.Zero;
                }
                else
                {
                    Debug.WriteLine($"GetImage FAILED {( ( ImageSafeConst ) nRet ).ConvertToString()}");
                }
            }
        }
Пример #3
0
        public static void ProcessDocument(Action <CheckData> callback)
        {
            var checkData = new CheckData();

            SelectedDocType = DocType.CHECK;

            //Process Document
            if (OpenDevice())
            {
                int    nRet;
                string strLog;
                string strTmp;

                nRet = SetupOptions();

                if (nRet != MICR_ST_OK)
                {
                    strLog                 = "Setup Options FAILED...";
                    checkData.HasError     = true;
                    checkData.ErrorMessage = strLog;
                }

                StringBuilder strResponse = new StringBuilder();
                strResponse.Capacity = 4096;
                int nResponseLength = 4096;
                DocInfo = "";
                nRet    = MTMICRProcessCheck(CurrentDeviceName, Options, strResponse, ref nResponseLength);

                if (nRet == ( int )MICR_ST_OK)
                {
                    DocInfo = strResponse.ToString();


                    nRet   = MTMICRGetValue(DocInfo, "CommandStatus", "ReturnCode", strResponse, ref nResponseLength);
                    strTmp = strResponse.ToString();

                    int nReturnCode = Convert.ToInt32(strTmp);
                    strLog = "Process Check return code " + nReturnCode;



                    if (nReturnCode == 0)
                    {
                        if (SelectedDocType == DocType.CHECK)
                        {
                            SetImageData(ref checkData);
                            SetCheckData(ref checkData);
                            callback.DynamicInvoke(checkData);
                            return;
                        }
                        else
                        {
                            checkData.HasError     = true;
                            checkData.ErrorMessage = strLog;
                            callback.DynamicInvoke(checkData);
                            //this.HandleError(handler, "Process Check Feeder not Set to Check.", checkData);
                            return;
                        }
                    }
                    else if (nReturnCode == 250)
                    {
                        checkData.HasError     = true;
                        checkData.ErrorMessage = "Check Waiting Timeout";
                        callback.DynamicInvoke(checkData);

                        return;
                    }
                    else
                    {
                        checkData.HasError     = true;
                        checkData.ErrorMessage = "Process Check Failed";
                        callback.DynamicInvoke(checkData);
                        //this.HandleError(handler, strLog, checkData);
                        return;
                    }
                }
                else
                {
                    strLog = "MTMICRProcessCheck return code " + nRet;
                    ImageSafeConst status = ( ImageSafeConst )nRet;
                    checkData.HasError     = true;
                    checkData.ErrorMessage = $"Unable to connect to scanner ( {status.ConvertToString()})";
                    callback.DynamicInvoke(checkData);

                    //this.HandleError(handler, strLog, checkData);
                    return;
                }
            }
            callback.DynamicInvoke(checkData);
            //HandleError(handler, "No Current Device Name found.", checkData);
        }