// Opens OI Build List Search public ActionResult Search() { Utility.Utility api = new Utility.Utility(); OIBuildListSearchModelEntity model = new OIBuildListSearchModelEntity(); model.request_fields = new RequestFields(); Session["OIBuildDataRequestFields"] = null; return(View("~/Views/OI/OIBuildList/Search.cshtml", model)); }
public async Task <IActionResult> Login(string userName, string password) { var loginSuccess = await new Utility.ApiUtility(_configuration).Login(userName, password); if (bool.Parse(loginSuccess)) { var bearerTokenString = new Utility.Utility(_configuration).GenerateJSONToken(); HttpContext.Session.SetString("BearerToken", bearerTokenString); return(RedirectToAction("Index", "Home")); } ViewBag.Message = "Sorry, username and password are wrong. Please try again."; return(View()); }
public ActionResult AddDUNSMonitoringPlus(string RegistrationsName, HttpPostedFileBase file, string AuthToken) { if (file != null && CommonMethod.CheckFileType(".txt", file.FileName.ToLower())) { if (file.ContentLength > 0) { string path = string.Empty; string url = Request.Url.Authority; string tempDirectory = "~/Upload/MonitoringDirectPlusAddDuns/" + url; string directory = Server.MapPath(tempDirectory.Replace(":", "")); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } string FileName = System.DateTime.Now.Ticks + "_" + file.FileName; path = Path.Combine(directory, Path.GetFileName(FileName)); file.SaveAs(path); path = CheckNumberOfLinesINDUNSRegistration(path); Utility.Utility utility = new Utility.Utility(); AddRemoveDUNSToMonitoringResponse addDUNsToMonitoringResponse = utility.AddDunsToMonitoring(RegistrationsName, path, AuthToken); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } if (addDUNsToMonitoringResponse.information != null && !string.IsNullOrEmpty(addDUNsToMonitoringResponse.information.message)) { return(Json(new { result = false, message = addDUNsToMonitoringResponse.information.message }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { result = false, message = addDUNsToMonitoringResponse.error.errorMessage }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { result = false, message = CommonMessagesLang.msgCommanFileEmpty }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { result = false, message = CommonMessagesLang.msgInvalidFile }, JsonRequestBehavior.AllowGet)); } }
public JsonResult DirectPlusAPICredentials(FormCollection model) { SettingFacade fac = new SettingFacade(this.CurrentClient.ApplicationDBConnectionString); CleanseMatchSettingsModel oldmodel = new CleanseMatchSettingsModel(); oldmodel.Settings = fac.GetCleanseMatchSettings(); GetSettingIDs(oldmodel); // Direct+ API Credentials username & password string consumerKey = model["Settings[" + oldmodel.DNB_PLUS_KEY + "].SettingValue"]; string consumerSecret = model["Settings[" + oldmodel.DNB_PLUS_SECRET + "].SettingValue"]; try { consumerSecret = SBISCCMWeb.Utility.Utility.GetDecryptedString(consumerSecret); } catch { consumerSecret = consumerSecret.ToString(); } oldmodel.Settings[oldmodel.DNB_PLUS_KEY].SettingValue = consumerKey; oldmodel.Settings[oldmodel.DNB_PLUS_SECRET].SettingValue = consumerSecret; oldmodel.Settings[oldmodel.API_LAYER].SettingValue = ApiLayerType.Directplus.ToString(); ////check DirectPlusAPI Credentials is validate or not. string Result = "", ErrorMessage = ""; Utility.Utility api = new Utility.Utility(); dnb_Authentication dnb_authentication = new dnb_Authentication(); dnb_authentication = api.DirectPlusAuth(consumerKey, consumerSecret, out Result, out ErrorMessage); if (dnb_authentication != null && string.IsNullOrEmpty(dnb_authentication.errorMessage)) { Helper.DirectPlusApiToken = "Bearer " + dnb_authentication.access_token; //update DirectPlusAPI Credentials fac.UpdateCleanseMatchSettings(oldmodel.Settings); fac.UpdateCleanseMatchSettingsAPIFamily(ApiLayerType.Directplus.ToString()); TempData["ApiLayer"] = ApiLayerType.Directplus.ToString(); Helper.APILAYER = ApiLayerType.Directplus.ToString(); return(Json(MessageCollection.SettingUpdate)); } return(Json(MessageCollection.InvalidCredential)); }
public JsonResult SuppUnsuppDUNS(string Parameters) { string referenceName = string.Empty; string AuthToken = string.Empty; bool isSuprressed = false; if (!string.IsNullOrEmpty(Parameters)) { Parameters = StringCipher.Decrypt(Parameters.Replace(Utility.Utility.urlseparator, "+"), General.passPhrase); referenceName = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 0, 1); isSuprressed = Convert.ToBoolean(Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 1, 1)); AuthToken = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 2, 1); } Utility.Utility utility = new Utility.Utility(); utility.SuppressUnSupressRegistration(referenceName, !isSuprressed, AuthToken); SettingFacade fac = new SettingFacade(this.CurrentClient.ApplicationDBConnectionString); //Suprressed and Unsuprressed DUNS fac.SuppressUnSupressNotifications(referenceName, !isSuprressed); return(Json(new { result = true, message = CommonMessagesLang.msgSuccess }, JsonRequestBehavior.AllowGet)); }
public JsonResult Search(BuildListSearchModel model, int?page, int?sortby, int?sortorder, int?pagevalue) { Response response = new Response(); try { #region pagination if (!(sortby.HasValue && sortby.Value > 0)) { sortby = 1; } if (!(sortorder.HasValue && sortorder.Value > 0)) { sortorder = 2; } int currentPageIndex = page.HasValue ? page.Value : 1; int pageSize = pagevalue.HasValue ? pagevalue.Value : 20; #endregion #region Set Viewbag ViewBag.SortBy = sortby; ViewBag.SortOrder = sortorder; ViewBag.pageno = currentPageIndex; ViewBag.pagevalue = pageSize; SessionHelper.BuildList_pageno = Convert.ToString(currentPageIndex); #endregion Utility.Utility api = new Utility.Utility(); model.Request.pageSize = ViewBag.pagevalue; model.Request.pageNumber = ViewBag.pageno; if (model.Request.usSicV4.Any()) { model.Request.usSicV4 = null; } if (model.Request.registrationNumbers.Any()) { model.Request.registrationNumbers = null; } model.Request.businessEntityType = null; model.Request.familytreeRolesPlayed = null; if (model.Request.locationRadius.lat == 0 && model.Request.locationRadius.lon == 0 && model.Request.locationRadius.radius == 0 && string.IsNullOrEmpty(model.Request.locationRadius.unit)) { model.Request.locationRadius = null; } if (!model.Request.yearlyRevenue.maximumValue.HasValue && !model.Request.yearlyRevenue.minimumValue.HasValue) { model.Request.yearlyRevenue = null; } if (model.Request.globalUltimateFamilyTreeMembersCount.maximumValue == 0 && model.Request.globalUltimateFamilyTreeMembersCount.minimumValue == 0) { model.Request.globalUltimateFamilyTreeMembersCount = null; } if (model.Request.numberOfEmployees.informationScope == 0 && model.Request.numberOfEmployees.maximumValue == null && model.Request.numberOfEmployees.minimumValue == null) { model.Request.numberOfEmployees = null; } if (model.Request.registrationNumbers.Count == 0) { model.Request.registrationNumbers = null; } if (model.Request.usSicV4.Count == 0) { model.Request.usSicV4 = null; } DateTime dtRequestedTime = DateTime.Now; DateTime?dtResponseTime = null; bool IsFetchData = true; List <SearchCandidate> lstsesstion = new List <SearchCandidate>(); // Checking APIType is there or not string APItype = CommonMethod.GetThirdPartyProperty(ThirdPartyCode.DNB_BUILD_A_LIST.ToString(), ThirdPartyProperties.APIType.ToString()); if (APItype != "") { for (int i = 1; i <= (model.NoOfRecored / 20); i++) { if (IsFetchData) { model.Request.pageNumber = i; model.Request.pageSize = 20; SearchCriteriaResponse objResponse = api.BuildAList(model.Request); if (objResponse.searchCandidates != null) { lstsesstion.AddRange(objResponse.searchCandidates); if ((i * 20) >= objResponse.candidatesMatchedQuantity) { IsFetchData = false; } } else { if (i == 1) { response.Success = false; response.ResponseString = objResponse.error != null ? objResponse.error.errorMessage : string.Empty; } IsFetchData = false; } } } } dtResponseTime = DateTime.Now; if (lstsesstion.Any()) { SessionHelper.BuildList_Data = JsonConvert.SerializeObject(lstsesstion); CompanyFacade fac = new CompanyFacade(this.CurrentClient.ApplicationDBConnectionString, Helper.UserName); var RequestJson = new JavaScriptSerializer().Serialize(model); var ResponseJson = new JavaScriptSerializer().Serialize(lstsesstion); object obj = fac.InsertBuildSearch(Helper.oUser.UserId, RequestJson, ResponseJson, dtRequestedTime, dtResponseTime); Session["Id"] = Convert.ToInt64(obj); } if (lstsesstion.Any()) { var skip = pageSize * (currentPageIndex - 1); IPagedList <SearchCandidate> pglstpagedMonitorProfile = new StaticPagedList <SearchCandidate>(lstsesstion.Skip(skip).Take(pageSize).ToList(), currentPageIndex, pageSize, lstsesstion.Count); dtResponseTime = DateTime.Now; response.Success = true; response.ResponseString = RenderViewAsString.RenderPartialViewToString(this, "~/Views/BuildList/SearchGrid.cshtml", pglstpagedMonitorProfile); } else { if (APItype == "") { response.Success = false; response.ResponseString = CommonMessagesLang.msgNoDefaultKeyForSearch; } } return(Json(response)); } catch (Exception ex) { response.Success = false; response.ResponseString = ex.Message; return(Json(response)); } }
public ActionResult RegistrationNumberPopup(string Parameters) { MainMatchEntity mainMatchEntity = new MainMatchEntity(); mainMatchEntity.lstMatches = new List <MatchEntity>(); //Resert values for Display Input field in match detail view(popup) Helper.CompanyName = ""; Helper.Address = ""; Helper.City = ""; Helper.State = ""; Helper.PhoneNbr = ""; Helper.Zip = ""; Helper.Address1 = ""; string RegistrationNoValue = string.Empty, type = string.Empty, CountryCode = string.Empty, SrcRecId = string.Empty, InputId = string.Empty; bool IsCleanSearch = false; CompanyFacade fcd = new CompanyFacade(this.CurrentClient.ApplicationDBConnectionString, Helper.UserName); if (!string.IsNullOrEmpty(Parameters)) { Parameters = StringCipher.Decrypt(Parameters.Replace(Utility.Utility.urlseparator, "+"), General.passPhrase); RegistrationNoValue = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 0, 1); type = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 1, 1); IsCleanSearch = Convert.ToBoolean(Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 2, 1)); CountryCode = Convert.ToString(Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 3, 1)); SrcRecId = Convert.ToString(Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 4, 1)); InputId = Convert.ToString(Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 5, 1)); } CommonMethod objCommon = new CommonMethod(); Utility.Utility api = new Utility.Utility(); var objResult = objCommon.LoadCleanseMatchSettings(this.CurrentClient.ApplicationDBConnectionString); bool IsGlobal = true; string LOBTag = null; int PageSize = 10, PageNumber = 1, SortOrder = 0; int totalCount = 0; DataTable lstThirdPartyAPICredentials = new DataTable(); ThirdPartyAPICredentialsFacade fac = new ThirdPartyAPICredentialsFacade(this.CurrentClient.ApplicationDBConnectionString); lstThirdPartyAPICredentials = fac.GetMinConfidenceSettingsListPaging(IsGlobal, LOBTag); int confidenceLowerLevelThresholdValue = 0; foreach (DataRow row in lstThirdPartyAPICredentials.Rows) { confidenceLowerLevelThresholdValue = Convert.ToInt32(row["MinConfidenceCode"]); } List <MatchEntity> lstMatchEntity = new List <MatchEntity>(); IPagedList <MatchEntity> pagedSearch = new StaticPagedList <MatchEntity>(lstMatchEntity, 1, 1, 1); string APItype = CommonMethod.GetThirdPartyProperty(ThirdPartyCode.DNB_SINGLE_ENTITY_SEARCH.ToString(), ThirdPartyProperties.APIType.ToString()); try // Validate Api Family is DirectPlus or Direct20 than according to API family call method for response. { if (APItype.ToLower() == ApiLayerType.Directplus.ToString().ToLower()) { response = api.GetMatchByRegistrationNoDirectPlus(CountryCode, this.CurrentClient.ApplicationDBConnectionString, RegistrationNoValue); } else if (APItype.ToLower() == ApiLayerType.Direct20.ToString().ToLower()) { response = api.GetMatchByRegistrationNo(CountryCode, this.CurrentClient.ApplicationDBConnectionString, RegistrationNoValue); } else { mainMatchEntity.ResponseErroeMessage = CommonMessagesLang.msgNoDefaultKeyForSearch; } } catch (WebException webEx) { using (var stream = webEx.Response.GetResponseStream()) using (var streamReader = new StreamReader(stream)) { var result = streamReader.ReadToEnd(); if (result != null) { var serializer = new JavaScriptSerializer(); if (APItype.ToLower() == ApiLayerType.Directplus.ToString().ToLower()) { var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; IdentityResolutionResponse objResponse = JsonConvert.DeserializeObject <IdentityResolutionResponse>(result, settings); if (objResponse != null) { mainMatchEntity.ResponseErroeMessage = objResponse.error.errorMessage; objCommon.InsertAPILogs(this.CurrentClient.ApplicationDBConnectionString, objResponse.transactionDetail.transactionID, Convert.ToDateTime(objResponse.transactionDetail.transactionTimestamp), null, null, objResponse.error.errorMessage, null, 0, null); } } else if (APItype.ToLower() == ApiLayerType.Direct20.ToString().ToLower()) { GetCleanseMatchResponseMain objResponse = serializer.Deserialize <GetCleanseMatchResponseMain>(result); if (objResponse != null && objResponse.GetCleanseMatchResponse != null && objResponse.GetCleanseMatchResponse.TransactionResult != null) { mainMatchEntity.ResponseErroeMessage = objResponse.GetCleanseMatchResponse.TransactionResult.ResultText; } } } } } if (response != null) { objCommon.InsertAPILogs(response.TransactionResponseDetail, this.CurrentClient.ApplicationDBConnectionString); fcd.InsertCleanseMatchCallResults(SrcRecId, response.ResponseJSON, response.APIRequest, Helper.oUser.UserId, InputId); int Count = Convert.ToInt32(response.MatchEntities.Count()) + 1; SessionHelper.SearchMatch = JsonConvert.SerializeObject(response.MatchEntities); SessionHelper.SearchMatches = JsonConvert.SerializeObject(response.MatchEntities); //lstMatchEntity = new List<MatchEntity>(response.MatchEntities); mainMatchEntity.lstMatches = response.MatchEntities; if (!string.IsNullOrEmpty(response?.ResponseJSON)) { dynamic data = JObject.Parse(response.ResponseJSON); if (data.error != null && !string.IsNullOrEmpty(data.error.errorMessage.Value)) { mainMatchEntity.ResponseErroeMessage = data.error.errorMessage.Value; } } } if (IsCleanSearch) { return(PartialView("~/Views/BadInputData/_SearchData.cshtml", mainMatchEntity)); } else { ViewBag.SearchedRegNum = RegistrationNoValue; ViewBag.SearchedWebsite = ""; return(PartialView("_Index", mainMatchEntity)); } }