Exemplo n.º 1
0
        public OutputStreetAddress[] VerifyAndCleanAddress(InputStreetAddress[] inputAddressArray)
        {
            Logger.Info(String.Format("total number of vouchers to clean {0} ", inputAddressArray.Count()));


            var o = new List<OutputStreetAddress>();
            
            int i = 0;
            int arrayOffset = 0;

            if (inputAddressArray.Length <= MaxArraySize)
                return VerifyAndCleanAddressBatch(inputAddressArray).ToArray();
            i = MaxArraySize;
            while (o.Count  < inputAddressArray.Length)
            {
                var l = inputAddressArray.Skip(arrayOffset).Take(i);
                o.AddRange(VerifyAndCleanAddressBatch(l.ToArray()));
                arrayOffset = o.Count() -1 ;
                i = ((inputAddressArray.Length - arrayOffset) < MaxArraySize)
                    ? inputAddressArray.Length - arrayOffset
                    : MaxArraySize;
            }
            return o.ToArray();
        }
Exemplo n.º 2
0
        protected OutputStreetAddress[] VerifyAndCleanAddressBatch(InputStreetAddress[] inputAddressArray)
        {
            Logger.Info(String.Format("Number of vouchers in batch to clean {0} ", inputAddressArray.Count()));

            if (inputAddressArray.Length > MaxArraySize)
                throw new Exception(String.Format("Too Many Items in Request maximum number is {0}", MaxArraySize));
            _arraysize = inputAddressArray.Length;
            var rra = new RequestRecord[_arraysize];
            var x = 0;
            foreach (var i in inputAddressArray)
                rra[x++] = new RequestRecord(i);
            _req.Records = rra;

            try
            {
                // the transmission results tell us if we got far enough to process records. if it is blank the answer is yes 
                // if we got transmission results we have a broke - connection and or configuration 
                _resp = _action.doContactVerify(_req);

                if (_resp.TransmissionResults.Trim() == "")
                {
                    var o = new OutputStreetAddress[_resp.Records.Length];
                    int i = 0;
                    foreach (var r in _resp.Records)
                    {
                        o[i++] = ResponseToOutputStreetAddressConverter.ProcessResponseRecord(r, _msgDict);
                    }

                    Logger.Info(String.Format("Number of vouchers cleaned {0} ", o.Count()));
                    return o;
                }
                var t = GetTransmissionErrors();
                string exText = null;
                foreach (var a in t)
                    exText += a.ToString() + Environment.NewLine;
                throw new Exception(exText);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                throw;
            }

        }