/// <summary> /// This is the method to ger user information from efm asynchronously /// </summary> /// <param name="username">filer email address to authenticate before getting data</param> /// <param name="password">filer password to authenticate</param> /// <param name="EfmId">efm id for searching filers data</param> /// <returns>returns Filer obect </returns> public async Task <FilerModel> GetUserFromEFMAsync(string username, string password, string EfmId) { //_logger.LogTrace(string.Format("Getting User info for {0}", EfmId));//this is for tracing purpose try { //_efmUserService = new EfmUserServiceClient(); //add authentication data to the client Util.AddAuthInfoToClient((EfmUserServiceClient)_efmUserService, username, password); //get user response from efm var response = await _efmUserService.GetUserAsync(new GetUserRequestType { UserID = EfmId }); if (response.Error.ErrorCode != "0")//raise app exception if any errors in response object { throw new AppException(response.Error.ErrorText, false, AppExceptionType.EFM); } return(MapGetUserResponseToFiler(response.User)); //map user data and send as Filer object } catch (TimeoutException te) // this is to handle timeout exceptions while interacting wiht EFM { ((EfmUserServiceClient)_efmUserService).Abort(); throw new Exception( "The state eFiling system has stopped responding. We cannot proceed. Your information has been saved as a draft. You may continue this filing later.", te); } catch (CommunicationException ce) // this is to handle communication exceptions while interacting with EFM { throw Util.BuildWcfException((EfmUserServiceClient)_efmUserService, ce); } catch (Exception e) // this is to handle general exceptions while interacting wiht EFM { ((EfmUserServiceClient)_efmUserService).Abort(); if (e.Message.ToLower().Contains("unknown error"))//if error message has unknown error throw it as technical issue. { throw new AppException("eFile manager is experiencing technical issues. Please try again later.", true, AppExceptionType.EFM, e); } throw new AppException(e.Message, true, AppExceptionType.EFM, e); } //finally //{ // try // { // if ((_efmUserService) != null) // { // //((EfmUserServiceClient)_efmUserService).Close(); // } // } // catch (Exception exception) // { // throw Util.BuildWcfException((EfmUserServiceClient)_efmUserService, exception); // } //} }
/// <summary> /// This is the method to update notification preferences data of a filer /// </summary> /// <param name="filer">filer object with data to authenticate the user</param> public void UpdateNotificationPreferences(FilerModel filer) { try { //add authentication data to the client Util.AddAuthInfoToClient((EfmUserServiceClient)_efmUserService, filer.EmailAddress, filer.Password); //create instance var UpdateNotificationPreferencesRequestType = new UpdateNotificationPreferencesRequestType(); var notificationTypeList = new List <NotificationType>(); //check fier has notifications data if (!string.IsNullOrEmpty(filer.eFileTexasNotiPref)) { string[] spiltNotiPref = filer.EFMNotificationPreference.Split(','); //split data by comma if (spiltNotiPref != null && spiltNotiPref.Length > 0) //if length is greater than zero { foreach (var splt in spiltNotiPref) //loop all preferences and add to the list { if (!string.IsNullOrEmpty(splt)) { if (filer.eFileTexasNotiPref.Contains(splt)) { notificationTypeList.Add(new NotificationType() { Code = splt, IsActive = true }); } else { notificationTypeList.Add(new NotificationType() { Code = splt, IsActive = false }); } } } } } //assign notification list to the request object and update in efm UpdateNotificationPreferencesRequestType.Notification = notificationTypeList.ToArray(); //get notifications response from efm var response = _efmUserService.UpdateNotificationPreferences(UpdateNotificationPreferencesRequestType); if (response.Error.ErrorCode != "0")//send error message if response has errors { throw new AppException(response.Error.ErrorText, false, AppExceptionType.EFM); } } catch (TimeoutException te)// this is to handle timeout exceptions while interacting wiht EFM { ((EfmUserServiceClient)_efmUserService).Abort(); throw new Exception("The state eFiling system has stopped responding. We cannot proceed. Your information has been saved as a draft. You may continue this filing later.", te); } catch (CommunicationException ce) // this is to handle communication exceptions while interacting with EFM { throw Util.BuildWcfException((EfmUserServiceClient)_efmUserService, ce); } catch (Exception e)// this is to handle general exceptions while interacting wiht EFM { ((EfmUserServiceClient)_efmUserService).Abort(); if (e.Message.ToLower().Contains("unknown error"))//if error message has unknown error throw it as technical issue. { throw new AppException("eFile manager is experiencing technical issues. Please try again later.", true, AppExceptionType.EFM, e); } throw new AppException(e.Message, true, AppExceptionType.EFM, e); } //finally //{ // try // { // if ((_efmUserService) != null) // { // //((EfmUserServiceClient)_efmUserService).Close(); // } // } // catch (Exception exception)// this is to handle general exceptions while interacting wiht EFM // { // throw Util.BuildWcfException((EfmUserServiceClient)_efmUserService, exception); // } //} }
/// <summary> /// This is the method to filer notification Preferencess data /// </summary> /// <param name="filer">filer object to get data</param> /// <returns>returns List<eFileTexasNotification> of notification preferencess</returns> public List <eFileTexasNotificationModel> GetNotificationPreferences(FilerModel filer) { try { //add authentication data to the client Util.AddAuthInfoToClient((EfmUserServiceClient)_efmUserService, filer.EmailAddress, filer.Password); //get notifications response from efm var response = _efmUserService.GetNotificationPreferences(); if (response.Error.ErrorCode != "0")//raise app exception if any errors in response object { throw new AppException(response.Error.ErrorText, false, AppExceptionType.EFM); } if (response.Notification != null)//check //get Notification data is there or not { var eFileTexasNotificationList = new List <eFileTexasNotificationModel>(); foreach (var notificationItem in response.Notification) //loop Notification data and add to the list { eFileTexasNotificationList.Add(new eFileTexasNotificationModel() {//assign data to all required properties Code = notificationItem.Code, Description = notificationItem.Description, IsSelected = notificationItem.IsActive, }); } return(eFileTexasNotificationList); // return Notification list } else { return(new List <eFileTexasNotificationModel>()); } } catch (TimeoutException te)// this is to handle timeout exceptions while interacting wiht EFM { ((EfmUserServiceClient)_efmUserService).Abort(); throw new Exception( "The state eFiling system has stopped responding. We cannot proceed. Your information has been saved as a draft. You may continue this filing later.", te); } catch (CommunicationException ce) // this is to handle communication exceptions while interacting with EFM { throw Util.BuildWcfException((EfmUserServiceClient)_efmUserService, ce); } catch (Exception e) // this is to handle general exceptions while interacting wiht EFM { ((EfmUserServiceClient)_efmUserService).Abort(); if (e.Message.ToLower().Contains("unknown error"))//if error message has unknown error throw it as technical issue. { throw new AppException("eFile manager is experiencing technical issues. Please try again later.", true, AppExceptionType.EFM, e); } throw new AppException(e.Message, true, AppExceptionType.EFM, e); } //finally //{ // try // { // if ((_efmUserService) != null) // { // //((EfmUserServiceClient)_efmUserService).Close(); // } // } // catch (Exception exception) // { // throw Util.BuildWcfException((EfmUserServiceClient)_efmUserService, exception); // } //} }
/// <summary> /// This is the method to change password of the filer /// </summary> /// <param name="filer">filer details to know before procedding </param> /// <param name="password">old password details</param> /// <param name="newPassword">new password details</param> /// <param name="question">security question</param> /// <param name="answer">security answer</param> /// <returns>returns PasswordHash value</returns> public string ChangePassword(FilerModel filer, string password, string newPassword, string question, string answer) { // _logger.LogTrace(string.Format("changing password for {0}", filer.EmailAddress));//this is for tracing purpose try { _efmUserService = new EfmUserServiceClient();// create istance to the user service client //add authentication data to the client Util.AddAuthInfoToClient((EfmUserServiceClient)_efmUserService, filer.EmailAddress, filer.Password); //get response of changepassword call var response = _efmUserService.ChangePassword(new ChangePasswordRequestType { PasswordQuestion = "question", PasswordAnswer = "answer", NewPassword = newPassword, OldPassword = password }); if (response.Error.ErrorText == "Old Password does not match existing password.") { response.Error.ErrorText = "Current Password does not match existing password."; } if (response.Error.ErrorCode != "0")//raise app exception if any errors in response object { throw new AppException(response.Error.ErrorText, false, AppExceptionType.EFM); } return(response.PasswordHash); //return the response } catch (TimeoutException te) // this is to handle timeout exceptions while interacting wiht EFM { ((EfmUserServiceClient)_efmUserService).Abort(); throw new Exception( "The state eFiling system has stopped responding. We cannot proceed. Your information has been saved as a draft. You may continue this filing later.", te); } catch (CommunicationException ce) // this is to handle communication exceptions while interacting with EFM { throw Util.BuildWcfException((EfmUserServiceClient)_efmUserService, ce); } catch (Exception e) // this is to handle general exceptions while interacting wiht EFM { ((EfmUserServiceClient)_efmUserService).Abort(); if (e.Message.ToLower().Contains("unknown error"))//if error message has unknown error throw it as technical issue. { throw new AppException("eFile manager is experiencing technical issues. Please try again later.", true, AppExceptionType.EFM, e); } throw new AppException(e.Message, true, AppExceptionType.EFM, e); } finally { try { if ((_efmUserService) != null)//finally try to close the wrapper instance if not null { ((EfmUserServiceClient)_efmUserService).Close(); } } catch (Exception exception)//throw wcf exceptions { throw Util.BuildWcfException((EfmUserServiceClient)_efmUserService, exception); } } }