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 var bc = (from e in DbUtil.Db.BackgroundChecks where e.Id == iRequestID select e).Single(); if (bc == null) { return(false); } // Create XML var xws = new XmlWriterSettings(); xws.Indent = false; xws.NewLineOnAttributes = false; xws.NewLineChars = ""; // Create Bundle var 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) { var 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 string sXML; using (var msRequest = new MemoryStream()) using (var xwWriter = XmlWriter.Create(msRequest, xws)) { XmlCreate(xwWriter, sb); sXML = Encoding.UTF8.GetString(msRequest.ToArray()).Substring(1); } // Submit Request to PMM var fields = new NameValueCollection(); fields.Add("REQUEST", sXML); string response; using (var wc = new WebClient()) { wc.Encoding = System.Text.Encoding.UTF8; response = Encoding.UTF8.GetString(wc.UploadValues(PMM_URL, "POST", fields)); } var rbResponse = ProcessResponse(response); if (rbResponse.bHasErrors) { bc.StatusID = 0; bc.ErrorMessages = rbResponse.sErrors; } else { if (rbResponse.bHasInstant) { bc.StatusID = 3; bc.ErrorMessages = ""; bc.ReportID = int.Parse(rbResponse.sReportID); bc.ReportLink = rbResponse.sReportLink; } else { bc.StatusID = 2; bc.ErrorMessages = ""; bc.ReportID = int.Parse(rbResponse.sReportID); } } DbUtil.Db.SubmitChanges(); return(true); }
private static void XmlCreate(XmlWriter xwWriter, SubmitBundle sb) { // Get Person Information var pPerson = (from e in DbUtil.Db.People where e.PeopleId == sb.iPeopleID select e).FirstOrDefault(); // Compile Birthday per requested format var iBirthMonth = pPerson.BirthMonth ?? 0; var iBirthDay = pPerson.BirthDay ?? 0; var iBirthYear = pPerson.BirthYear ?? 0; var sDOB = iBirthMonth.ToString("D2") + "/" + iBirthDay.ToString("D2") + "/" + iBirthYear.ToString("D4"); // Create OrderId var sOrderID = DateTime.Now.ToString("yyyyMMddHHmmssfff"); // Open Document xwWriter.WriteStartDocument(); // Open OrderXML xwWriter.WriteStartElement("OrderXML"); // Method (Inside OrderXML) xwWriter.WriteElementString("Method", "SEND ORDER"); // Authentication Section (Inside OrderXML) xwWriter.WriteStartElement("Authentication"); xwWriter.WriteElementString("Username", sb.sUser); xwWriter.WriteElementString("Password", sb.sPassword); xwWriter.WriteFullEndElement(); if (sb.bTestMode) { xwWriter.WriteElementString("TestMode", "YES"); } // Return URL (Inside OrderXML) xwWriter.WriteElementString("ReturnResultURL", sb.sResponseURL); // Order Section (Inside OrderXML) xwWriter.WriteStartElement("Order"); // Our Billing Reference Code (Inside Order Section) xwWriter.WriteElementString("BillingReferenceCode", sb.sBillingReference); // Subject Section (Inside Order Section) xwWriter.WriteStartElement("Subject"); xwWriter.WriteElementString("Firstname", pPerson.FirstName); if (pPerson.MiddleName != null) { xwWriter.WriteElementString("Middlename", pPerson.MiddleName); } xwWriter.WriteElementString("Lastname", pPerson.LastName); if (pPerson.SuffixCode != null) { xwWriter.WriteElementString("Generation", pPerson.SuffixCode); } xwWriter.WriteElementString("DOB", sDOB); xwWriter.WriteElementString("SSN", sb.sSSN); xwWriter.WriteElementString("Gender", pPerson.Gender.Description); //xwWriter.WriteElementString("Ethnicity", "Caucasian"); // MVR Option if (sb.sServiceCode == "MVR") { xwWriter.WriteElementString("DLNumber", sb.sDNL); } xwWriter.WriteElementString("ApplicantPosition", "Volunteer"); // CurrentAddress Section (Inside Subject Section) xwWriter.WriteStartElement("CurrentAddress"); xwWriter.WriteElementString("StreetAddress", pPerson.PrimaryAddress); xwWriter.WriteElementString("City", pPerson.PrimaryCity); xwWriter.WriteElementString("State", pPerson.PrimaryState); xwWriter.WriteElementString("Zipcode", pPerson.PrimaryZip); xwWriter.WriteFullEndElement(); // Close Subject Section xwWriter.WriteFullEndElement(); if (sb.sServiceCode == "Combo") { // Package Service Code - Only if a package (BASIC,PLUS) (Inside Order Section) xwWriter.WriteStartElement("PackageServiceCode"); xwWriter.WriteAttributeString("OrderId", sOrderID); xwWriter.WriteString("Basic"); xwWriter.WriteFullEndElement(); } else if (sb.sServiceCode == "ComboPC" || sb.sServiceCode == "ComboPS") { // Package Service Code - Only if a package (BASIC,PLUS) (Inside Order Section) xwWriter.WriteStartElement("PackageServiceCode"); xwWriter.WriteAttributeString("OrderId", sOrderID); xwWriter.WriteString("PLUS"); xwWriter.WriteFullEndElement(); } if (sb.sServiceCode == "ComboPC" || sb.sServiceCode == "ComboPS") { // Basic Package xwWriter.WriteStartElement("OrderDetail"); xwWriter.WriteAttributeString("serviceCode", "Combo"); xwWriter.WriteAttributeString("OrderId", sOrderID); xwWriter.WriteEndElement(); // Plus Package xwWriter.WriteStartElement("OrderDetail"); if (sb.sServiceCode == "ComboPC") { xwWriter.WriteAttributeString("serviceCode", "CountyCrim"); } if (sb.sServiceCode == "ComboPS") { xwWriter.WriteAttributeString("serviceCode", "StateCriminal"); } xwWriter.WriteAttributeString("OrderId", sOrderID); if (sb.sServiceCode == "ComboPC") { xwWriter.WriteElementString("County", sb.sPlusCounty); } xwWriter.WriteElementString("State", sb.sPlusState); } else { // Basic Package xwWriter.WriteStartElement("OrderDetail"); xwWriter.WriteAttributeString("serviceCode", sb.sServiceCode); xwWriter.WriteAttributeString("OrderId", sOrderID); } // MVR Option if (sb.sServiceCode == "MVR") { xwWriter.WriteElementString("JurisdictionCode", sb.sStateCode); xwWriter.WriteElementString("State", sb.sStateAbbr); } xwWriter.WriteEndElement(); // Close Order Section xwWriter.WriteFullEndElement(); // Close OrderXML Section xwWriter.WriteFullEndElement(); // Close Document xwWriter.WriteEndDocument(); xwWriter.Flush(); }
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 var bc = (from e in DbUtil.Db.BackgroundChecks where e.Id == iRequestID select e).Single(); if (bc == null) return false; // Create XML var xws = new XmlWriterSettings(); xws.Indent = false; xws.NewLineOnAttributes = false; xws.NewLineChars = ""; // Create Bundle var 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"); sb.sPlusCounty = sPlusCounty; sb.sPlusState = sPlusState; // Get State (if MVR) if (bc.ServiceCode == "MVR" && iStateID > 0) { var 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 string sXML; using (var msRequest = new MemoryStream()) using (var xwWriter = XmlWriter.Create(msRequest, xws)) { XmlCreate(xwWriter, sb); sXML = Encoding.UTF8.GetString(msRequest.ToArray()).Substring(1); } // Submit Request to PMM var fields = new NameValueCollection(); fields.Add("REQUEST", sXML); string response; using (var wc = new WebClient()) { wc.Encoding = System.Text.Encoding.UTF8; response = Encoding.UTF8.GetString(wc.UploadValues(PMM_URL, "POST", fields)); } var rbResponse = ProcessResponse(response); if (rbResponse.bHasErrors) { bc.StatusID = 0; bc.ErrorMessages = rbResponse.sErrors; } else { if (rbResponse.bHasInstant) { bc.StatusID = 3; bc.ErrorMessages = ""; bc.ReportID = int.Parse(rbResponse.sReportID); bc.ReportLink = rbResponse.sReportLink; } else { bc.StatusID = 2; bc.ErrorMessages = ""; bc.ReportID = int.Parse(rbResponse.sReportID); } } DbUtil.Db.SubmitChanges(); return true; }
private static void XmlCreate(XmlWriter xwWriter, SubmitBundle sb) { // Get Person Information var pPerson = (from e in DbUtil.Db.People where e.PeopleId == sb.iPeopleID select e).FirstOrDefault(); // Compile Birthday per requested format var iBirthMonth = pPerson.BirthMonth ?? 0; var iBirthDay = pPerson.BirthDay ?? 0; var iBirthYear = pPerson.BirthYear ?? 0; var sDOB = iBirthMonth.ToString("D2") + "/" + iBirthDay.ToString("D2") + "/" + iBirthYear.ToString("D4"); // Create OrderId var sOrderID = DateTime.Now.ToString("yyyyMMddHHmmssfff"); // Open Document xwWriter.WriteStartDocument(); // Open OrderXML xwWriter.WriteStartElement("OrderXML"); // Method (Inside OrderXML) xwWriter.WriteElementString("Method", "SEND ORDER"); // Authentication Section (Inside OrderXML) xwWriter.WriteStartElement("Authentication"); xwWriter.WriteElementString("Username", sb.sUser); xwWriter.WriteElementString("Password", sb.sPassword); xwWriter.WriteFullEndElement(); if (sb.bTestMode) xwWriter.WriteElementString("TestMode", "YES"); // Return URL (Inside OrderXML) xwWriter.WriteElementString("ReturnResultURL", sb.sResponseURL); // Order Section (Inside OrderXML) xwWriter.WriteStartElement("Order"); // Our Billing Reference Code (Inside Order Section) xwWriter.WriteElementString("BillingReferenceCode", sb.sBillingReference); // Subject Section (Inside Order Section) xwWriter.WriteStartElement("Subject"); xwWriter.WriteElementString("Firstname", pPerson.FirstName); if (pPerson.MiddleName != null) xwWriter.WriteElementString("Middlename", pPerson.MiddleName); xwWriter.WriteElementString("Lastname", pPerson.LastName); if (pPerson.SuffixCode != null) xwWriter.WriteElementString("Generation", pPerson.SuffixCode); xwWriter.WriteElementString("DOB", sDOB); xwWriter.WriteElementString("SSN", sb.sSSN); xwWriter.WriteElementString("Gender", pPerson.Gender.Description); //xwWriter.WriteElementString("Ethnicity", "Caucasian"); // MVR Option if (sb.sServiceCode == "MVR") { xwWriter.WriteElementString("DLNumber", sb.sDNL); } xwWriter.WriteElementString("ApplicantPosition", "Volunteer"); // CurrentAddress Section (Inside Subject Section) xwWriter.WriteStartElement("CurrentAddress"); xwWriter.WriteElementString("StreetAddress", pPerson.PrimaryAddress); xwWriter.WriteElementString("City", pPerson.PrimaryCity); xwWriter.WriteElementString("State", pPerson.PrimaryState); xwWriter.WriteElementString("Zipcode", pPerson.PrimaryZip); xwWriter.WriteFullEndElement(); // Close Subject Section xwWriter.WriteFullEndElement(); if (sb.sServiceCode == "Combo") { // Package Service Code - Only if a package (BASIC,PLUS) (Inside Order Section) xwWriter.WriteStartElement("PackageServiceCode"); xwWriter.WriteAttributeString("OrderId", sOrderID); xwWriter.WriteString("Basic"); xwWriter.WriteFullEndElement(); } else if (sb.sServiceCode == "ComboPC" || sb.sServiceCode == "ComboPS") { // Package Service Code - Only if a package (BASIC,PLUS) (Inside Order Section) xwWriter.WriteStartElement("PackageServiceCode"); xwWriter.WriteAttributeString("OrderId", sOrderID); xwWriter.WriteString("PLUS"); xwWriter.WriteFullEndElement(); } if (sb.sServiceCode == "ComboPC" || sb.sServiceCode == "ComboPS") { // Basic Package xwWriter.WriteStartElement("OrderDetail"); xwWriter.WriteAttributeString("serviceCode", "Combo"); xwWriter.WriteAttributeString("OrderId", sOrderID); xwWriter.WriteEndElement(); // Plus Package xwWriter.WriteStartElement("OrderDetail"); if (sb.sServiceCode == "ComboPC") xwWriter.WriteAttributeString("serviceCode", "CountyCrim"); if (sb.sServiceCode == "ComboPS") xwWriter.WriteAttributeString("serviceCode", "StateCriminal"); xwWriter.WriteAttributeString("OrderId", sOrderID); if (sb.sServiceCode == "ComboPC") xwWriter.WriteElementString("County", sb.sPlusCounty); xwWriter.WriteElementString("State", sb.sPlusState); } else { // Basic Package xwWriter.WriteStartElement("OrderDetail"); xwWriter.WriteAttributeString("serviceCode", sb.sServiceCode); xwWriter.WriteAttributeString("OrderId", sOrderID); } // MVR Option if (sb.sServiceCode == "MVR") { xwWriter.WriteElementString("JurisdictionCode", sb.sStateCode); xwWriter.WriteElementString("State", sb.sStateAbbr); } xwWriter.WriteEndElement(); // Close Order Section xwWriter.WriteFullEndElement(); // Close OrderXML Section xwWriter.WriteFullEndElement(); // Close Document xwWriter.WriteEndDocument(); xwWriter.Flush(); }
public static bool Submit(int requestId, string SSN, string driversLicenseNumber, string responseURL, int stateId, string username, string password, string plusCounty, string plusState) { if (username == null || password == null) { return(false); } var db = DbUtil.Db; // Get the already created (via create()) background check request var backgroundCheck = db.BackgroundChecks.Single(e => e.Id == requestId); var bgCheckLabel = db.BackgroundCheckLabels.FirstOrDefault(l => l.Id == backgroundCheck.ReportLabelID); if (backgroundCheck == null) { return(false); } // Create XML var xws = new XmlWriterSettings { Indent = false, NewLineOnAttributes = false, NewLineChars = "" }; // Create Bundle var bundle = new SubmitBundle { iPeopleID = backgroundCheck.PeopleID, sUser = username, sPassword = password, sBillingReference = bgCheckLabel == null?backgroundCheck.Id.ToString() : bgCheckLabel.Code, sSSN = SSN, sServiceCode = backgroundCheck.ServiceCode, sResponseURL = responseURL, bTestMode = db.Setting("PMMTestMode"), sPlusCounty = plusCounty, sPlusState = plusState }; // Get State (if MVR) if (backgroundCheck.ServiceCode == "MVR" && stateId > 0) { var bcmc = (from e in db.BackgroundCheckMVRCodes where e.Id == stateId select e).Single(); if (bcmc == null) { return(false); } bundle.sDNL = driversLicenseNumber; bundle.sStateCode = bcmc.Code; bundle.sStateAbbr = bcmc.StateAbbr; } // Main Request string sXML; using (var request = new MemoryStream()) { using (var xwWriter = XmlWriter.Create(request, xws)) { XmlCreate(xwWriter, bundle); sXML = Encoding.UTF8.GetString(request.ToArray()).Substring(1); } } // Submit Request to PMM var fields = new NameValueCollection(); fields.Add("REQUEST", sXML); string response; using (var wc = new WebClient()) { wc.Encoding = System.Text.Encoding.UTF8; response = Encoding.UTF8.GetString(wc.UploadValues(PMM_URL, "POST", fields)); } var rbResponse = ProcessResponse(response); if (rbResponse.bHasErrors) { backgroundCheck.StatusID = 0; backgroundCheck.ErrorMessages = rbResponse.sErrors; } else { if (rbResponse.bHasInstant) { backgroundCheck.StatusID = 3; backgroundCheck.ErrorMessages = ""; backgroundCheck.ReportID = int.Parse(rbResponse.sReportID); backgroundCheck.ReportLink = rbResponse.sReportLink; } else { backgroundCheck.StatusID = 2; backgroundCheck.ErrorMessages = ""; backgroundCheck.ReportID = int.Parse(rbResponse.sReportID); } } db.SubmitChanges(); return(true); }