Пример #1
0
        private static ResponseBundle ProcessResponse(string sResponse)
        {
            var rbReturn = new ResponseBundle();

            var xd = XDocument.Parse(sResponse, LoadOptions.None);

            if (xd.Root.Element("Status").Value == "FAILED")
            {
                rbReturn.bHasErrors = true;

                var errors = xd.Root.Element("Errors").Elements("Message");

                foreach (var item in errors)
                {
                    rbReturn.sErrors += item.Value.Replace("<", "&lt;").Replace(">", "&gt;") + "<br>";
                }
            }
            else if (xd.Root.Element("Status").Value == "ERROR")
            {
                rbReturn.bHasErrors = true;

                var errors = xd.Root.Elements("Message");

                foreach (var item in errors)
                {
                    rbReturn.sErrors += item.Value.Replace("<", "&lt;").Replace(">", "&gt;") + "<br>";
                }
            }
            else
            {
                if (xd.Root.Element("Order").Element("ReportLink") != null)
                {
                    rbReturn.bHasInstant = true;
                    rbReturn.sReportLink = xd.Root.Element("Order").Element("ReportLink").Value;
                }

                string sReportID = xd.Root.Element("ReferenceNumber").Value;
                if (sReportID != null)
                {
                    rbReturn.sReportID = sReportID;
                }
            }

            return(rbReturn);
        }
Пример #2
0
        private static ResponseBundle ProcessResponse(string response)
        {
            var bundle = new ResponseBundle();

            var xmldoc = XDocument.Parse(response, LoadOptions.None);

            if (xmldoc.Root.Element("Status").Value == "FAILED")
            {
                bundle.bHasErrors = true;

                var errors = xmldoc.Root.Element("Errors").Elements("Message");

                foreach (var error in errors)
                {
                    bundle.sErrors += HttpUtility.HtmlEncode(error.Value) + "<br>";
                }
            }
            else if (xmldoc.Root.Element("Status").Value == "ERROR")
            {
                bundle.bHasErrors = true;

                var errors = xmldoc.Root.Elements("Message");

                foreach (var error in errors)
                {
                    bundle.sErrors += HttpUtility.HtmlEncode(error.Value) + "<br>";
                }
            }
            else
            {
                if (xmldoc.Root.Element("Order").Element("ReportLink") != null)
                {
                    bundle.bHasInstant = true;
                    bundle.sReportLink = xmldoc.Root.Element("Order").Element("ReportLink").Value;
                }

                string reportId = xmldoc.Root.Element("ReferenceNumber").Value;
                if (reportId != null)
                {
                    bundle.sReportID = reportId;
                }
            }

            return(bundle);
        }
Пример #3
0
        public static ResponseBundle processResponse(string sResponse)
        {
            ResponseBundle sReturn = new ResponseBundle();

            XDocument xd = XDocument.Parse(sResponse, LoadOptions.None);

            if (xd.Root.Element("Status").Value == "FAILED")
            {
                sReturn.bHasErrors = true;

                var errors = xd.Root.Element("Errors").Elements("Message");

                foreach (var item in errors)
                {
                    sReturn.sErrors += item.Value.Replace("<", "&lt;").Replace(">", "&gt;") + "<br>";
                }
            }
            else if (xd.Root.Element("Status").Value == "ERROR")
            {
                sReturn.bHasErrors = true;

                var errors = xd.Root.Elements("Message");

                foreach (var item in errors)
                {
                    sReturn.sErrors += item.Value.Replace("<", "&lt;").Replace(">", "&gt;") + "<br>";
                }
            }
            else
            {
                string sReportID = xd.Root.Element("ReferenceNumber").Value;

                if (sReportID != null)
                {
                    sReturn.sReportID = sReportID;
                }
            }

            return(sReturn);
        }
        public static bool submit(int iRequestID, string sSSN, string sDLN, string sResponseURL, int iStateID, string sUser, string sPassword, string sPlusCounty, string sPlusState)
        {
            if (sUser == null || sPassword == null)
            {
                return(false);
            }

            // Get the already created (via create()) background check request
            BackgroundCheck bc = (from e in DbUtil.Db.BackgroundChecks
                                  where e.Id == iRequestID
                                  select e).Single();

            if (bc == null)
            {
                return(false);
            }

            // Create XML
            XmlWriterSettings xws = new XmlWriterSettings();

            xws.Indent = false;
            xws.NewLineOnAttributes = false;
            xws.NewLineChars        = "";

            // Create Bundle
            SubmitBundle sb = new SubmitBundle();

            sb.iPeopleID         = bc.PeopleID;
            sb.sUser             = sUser;
            sb.sPassword         = sPassword;
            sb.sBillingReference = bc.Id.ToString();
            sb.sSSN         = sSSN;
            sb.sServiceCode = bc.ServiceCode;
            sb.sResponseURL = sResponseURL;
            sb.bTestMode    = (DbUtil.Db.Setting("PMMTestMode", "false") == "true");
            sb.sPlusCounty  = sPlusCounty;
            sb.sPlusState   = sPlusState;

            // Get State (if MVR)
            if (bc.ServiceCode == "MVR" && iStateID > 0)
            {
                BackgroundCheckMVRCode bcmc = (from e in DbUtil.Db.BackgroundCheckMVRCodes
                                               where e.Id == iStateID
                                               select e).Single();

                if (bcmc == null)
                {
                    return(false);
                }

                sb.sDNL       = sDLN;
                sb.sStateCode = bcmc.Code;
                sb.sStateAbbr = bcmc.StateAbbr;
            }

            // Main Request
            MemoryStream msRequest = new MemoryStream();
            XmlWriter    xwWriter  = XmlWriter.Create(msRequest, xws);

            xmlCreate(xwWriter, sb);
            string sXML = Encoding.UTF8.GetString(msRequest.ToArray()).Substring(1);

            msRequest.Close();

            // Submit Request to PMM
            var fields = new NameValueCollection();

            fields.Add("REQUEST", sXML);

            WebClient wc = new WebClient();

            wc.Encoding = System.Text.Encoding.UTF8;
            var response = Encoding.UTF8.GetString(wc.UploadValues(PMM_URL, "POST", fields));

            ResponseBundle rbResponse = processResponse(response);

            if (rbResponse.bHasErrors)
            {
                bc.StatusID      = 0;
                bc.ErrorMessages = rbResponse.sErrors;
            }
            else
            {
                if (rbResponse.bHasInstant)
                {
                    bc.StatusID      = 3;
                    bc.ErrorMessages = "";
                    bc.ReportID      = Int32.Parse(rbResponse.sReportID);
                    bc.ReportLink    = rbResponse.sReportLink;
                }
                else
                {
                    bc.StatusID      = 2;
                    bc.ErrorMessages = "";
                    bc.ReportID      = Int32.Parse(rbResponse.sReportID);
                }
            }

            DbUtil.Db.SubmitChanges();
            return(true);
        }
        private static ResponseBundle ProcessResponse(string sResponse)
        {
            var rbReturn = new ResponseBundle();

            var xd = XDocument.Parse(sResponse, LoadOptions.None);

            if (xd.Root.Element("Status").Value == "FAILED")
            {
                rbReturn.bHasErrors = true;

                var errors = xd.Root.Element("Errors").Elements("Message");

                foreach (var item in errors)
                {
                    rbReturn.sErrors += item.Value.Replace("<", "&lt;").Replace(">", "&gt;") + "<br>";
                }
            }
            else if (xd.Root.Element("Status").Value == "ERROR")
            {
                rbReturn.bHasErrors = true;

                var errors = xd.Root.Elements("Message");

                foreach (var item in errors)
                {
                    rbReturn.sErrors += item.Value.Replace("<", "&lt;").Replace(">", "&gt;") + "<br>";
                }
            }
            else
            {
                if (xd.Root.Element("Order").Element("ReportLink") != null)
                {
                    rbReturn.bHasInstant = true;
                    rbReturn.sReportLink = xd.Root.Element("Order").Element("ReportLink").Value;
                }

                string sReportID = xd.Root.Element("ReferenceNumber").Value;
                if (sReportID != null) rbReturn.sReportID = sReportID;
            }

            return rbReturn;
        }
Пример #6
0
        public static ResponseBundle processResponse(string sResponse)
        {
            ResponseBundle sReturn = new ResponseBundle();

            XDocument xd = XDocument.Parse(sResponse, LoadOptions.None);

            if (xd.Root.Element("Status").Value == "FAILED")
            {
                sReturn.bHasErrors = true;

                var errors = xd.Root.Element("Errors").Elements("Message");

                foreach (var item in errors)
                {
                    sReturn.sErrors += item.Value.Replace("<", "&lt;").Replace(">", "&gt;") + "<br>";
                }
            }
            else if (xd.Root.Element("Status").Value == "ERROR")
            {
                sReturn.bHasErrors = true;

                var errors = xd.Root.Elements("Message");

                foreach (var item in errors)
                {
                    sReturn.sErrors += item.Value.Replace("<", "&lt;").Replace(">", "&gt;") + "<br>";
                }
            }
            else
            {
                string sReportID = xd.Root.Element("ReferenceNumber").Value;

                if (sReportID != null) sReturn.sReportID = sReportID;
            }

            return sReturn;
        }