public JsonResult DnBDirectLicense(CleanseMatchSettingsModel model, string btnSubmit = null) { SettingFacade fac = new SettingFacade(this.CurrentClient.ApplicationDBConnectionString); CleanseMatchSettingsModel oldmodel = new CleanseMatchSettingsModel(); oldmodel.Settings = fac.GetCleanseMatchSettings(); GetSettingIDs(oldmodel); try { model.Settings[oldmodel.DNB_PASSWORD].SettingValue = SBISCCMWeb.Utility.Utility.GetDecryptedString(model.Settings[model.DNB_PASSWORD].SettingValue); } catch { model.Settings[oldmodel.DNB_PASSWORD].SettingValue = model.Settings[oldmodel.DNB_PASSWORD].SettingValue; } oldmodel.Settings[oldmodel.DNB_USERNAME].SettingValue = model.Settings[oldmodel.DNB_USERNAME].SettingValue; oldmodel.Settings[oldmodel.DNB_PASSWORD].SettingValue = model.Settings[oldmodel.DNB_PASSWORD].SettingValue; oldmodel.Settings[oldmodel.API_LAYER].SettingValue = ApiLayerType.Direct20.ToString(); //check DnB Credentials is validate or not. string Message = fac.ValidateDnBLogin(oldmodel.Settings[oldmodel.DNB_USERNAME].SettingValue, oldmodel.Settings[oldmodel.DNB_PASSWORD].SettingValue); if (Message.ToLower() == MessageCollection.ValidCredential) { RestfulHttpClient <AuthResponse, string> authClient = new RestfulHttpClient <AuthResponse, string>(Helper.AuthURL, string.Empty, oldmodel.Settings[oldmodel.DNB_USERNAME].SettingValue, oldmodel.Settings[oldmodel.DNB_PASSWORD].SettingValue, Helper.JsonMediaType); var responseData = authClient.GetAuthResponse(); if (responseData != null) { if (responseData.TransactionResult.ResultID != "CM000") { Helper.ApiToken = null; } else { Helper.ApiToken = responseData.AuthenticationDetail.Token; } } else { Helper.ApiToken = null; } //update DnBDirectLicense Credentials fac.UpdateCleanseMatchSettings(oldmodel.Settings); fac.UpdateCleanseMatchSettingsAPIFamily(ApiLayerType.Direct20.ToString()); Message = MessageCollection.SettingUpdate; } model.Settings = fac.GetCleanseMatchSettings(); GetSettingIDs(model); SetMatchGradeContent(model); Clear(model); TempData["ApiLayer"] = ApiLayerType.Direct20.ToString(); Helper.APILAYER = ApiLayerType.Direct20.ToString(); string Data = Message; return(Json(Data)); }
public JsonResult MixModeAPICredentials(FormCollection model) { try { SettingFacade fac = new SettingFacade(this.CurrentClient.ApplicationDBConnectionString); CleanseMatchSettingsModel oldmodel = new CleanseMatchSettingsModel(); oldmodel.Settings = fac.GetCleanseMatchSettings(); GetSettingIDs(oldmodel); string APIFamily = model["APIFamily"]; //DnB Direct License username & password string DnBDirectLicenseuserName = model["Settings[" + oldmodel.DNB_USERNAME + "].SettingValue"]; string DnBDirectLicensePassword = model["Settings[" + oldmodel.DNB_PASSWORD + "].SettingValue"]; try { DnBDirectLicensePassword = SBISCCMWeb.Utility.Utility.GetDecryptedString(DnBDirectLicensePassword); } catch { DnBDirectLicensePassword = DnBDirectLicensePassword.ToString(); } // Direct+ API Credentials username & password string DirectPlusAPIuserName = model["Settings[" + oldmodel.DNB_PLUS_KEY + "].SettingValue"]; string DirectPlusAPIPassword = model["Settings[" + oldmodel.DNB_PLUS_SECRET + "].SettingValue"]; try { DirectPlusAPIPassword = SBISCCMWeb.Utility.Utility.GetDecryptedString(DirectPlusAPIPassword); } catch { DirectPlusAPIPassword = DirectPlusAPIPassword.ToString(); } oldmodel.Settings[oldmodel.DNB_PLUS_KEY].SettingValue = DirectPlusAPIuserName; oldmodel.Settings[oldmodel.DNB_PLUS_SECRET].SettingValue = DirectPlusAPIPassword; oldmodel.Settings[oldmodel.DNB_USERNAME].SettingValue = DnBDirectLicenseuserName; oldmodel.Settings[oldmodel.DNB_PASSWORD].SettingValue = DnBDirectLicensePassword; oldmodel.Settings[oldmodel.API_LAYER].SettingValue = ApiLayerType.MixMode.ToString(); //update MixModeAPI Credentials fac.UpdateCleanseMatchSettings(oldmodel.Settings); fac.UpdateCleanseMatchSettingsAPIFamily(APIFamily); TempData["ApiLayer"] = ApiLayerType.MixMode.ToString(); CompanyFacade fcd = new CompanyFacade(this.CurrentClient.ApplicationDBConnectionString, Helper.UserName); APIFamily = fcd.GetAPILayer("Match and Cleanse"); Helper.APILAYER = ApiLayerType.MixMode.ToString(); var Result = new { Message = MessageCollection.SettingUpdate, APIFamily = APIFamily }; return(Json(Result)); } catch (Exception) { return(Json(MessageCollection.SettingNotUpdate)); } }
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)); }