private async Task SignInAsync(IdentityUser user, bool isPersistent) { try { Logger.Current.Informational("Logging out..user id: " + user.Id); AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); HttpCookie CartCookie = new HttpCookie("IsPersistent", isPersistent.ToString()); CartCookie.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(CartCookie); string accountLogoUrl = "false"; ClaimsIdentity claimsIdentity = await user.GenerateUserIdentityAsync(UserManager); GetAccountImageStorageNameResponse response = accountService.GetStorageName(new GetAccountImageStorageNameRequest() { AccountId = user.AccountID }); if (response != null) { accountLogoUrl = response.AccountLogoInfo.StorageName != null?urlService.GetUrl(user.AccountID, ImageCategory.AccountLogo, response.AccountLogoInfo.StorageName) : accountLogoUrl; claimsIdentity.AddClaim(new Claim("AccountLogoUrl", accountLogoUrl)); claimsIdentity.AddClaim(new Claim("AccountName", response.AccountLogoInfo.AccountName)); HttpCookie helpURL = new HttpCookie("helpURL", response.AccountLogoInfo.HelpURL); helpURL.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(helpURL); } AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, claimsIdentity); } catch (Exception ex) { ExceptionHandler.Current.HandleException(ex, DefaultExceptionPolicies.LOG_ONLY_POLICY); } }
private string GetBody(int neverBounceRequestID, int accountId, int userId) { string body = string.Empty; string accountLogo = string.Empty; string accountName = string.Empty; string accountImage = string.Empty; if (neverBounceRequestID != 0) { var primaryEmail = userRepository.GetUserPrimaryEmail(userId); string userName = userRepository.GetUserName(userId); NeverBounceEmailDataResponse response = accountService.GetEmailData(new NeverBounceEmailDataRequest() { NeverBounceRequestID = neverBounceRequestID }); string accountAddress = accountService.GetPrimaryAddress(new GetAddressRequest() { AccountId = accountId }).Address; string accountPhoneNumber = accountService.GetPrimaryPhone(new GetPrimaryPhoneRequest() { AccountId = accountId }).PrimaryPhone; GetAccountImageStorageNameResponse imgStorage = accountService.GetStorageName(new GetAccountImageStorageNameRequest() { AccountId = accountId }); if (imgStorage.AccountLogoInfo != null) { if (!String.IsNullOrEmpty(imgStorage.AccountLogoInfo.StorageName)) { accountLogo = urlService.GetUrl(accountId, ImageCategory.AccountLogo, imgStorage.AccountLogoInfo.StorageName); } else { accountLogo = ""; } accountName = imgStorage.AccountLogoInfo.AccountName; } if (!string.IsNullOrEmpty(accountLogo)) { accountImage = accountImage + "<td align='right' valign='center' style='margin:0px;padding:0px 0px 25px 0px;'><img src='" + accountLogo + "' alt='" + accountName + "' style='width:100px;' width='100'></td>"; } if (response.Data != null) { string entityName = response.Data.EntityID == 1 ? "File Name" : response.Data.EntityID == 2 ? "Tag Name(s)" : response.Data.EntityID == 3 ? "Search Definition Name(s)" : ""; string filename = EmailTemplate.NeverBounceBadEmailsTemplate.ToString() + ".txt"; string savedFileName = Path.Combine(ConfigurationManager.AppSettings["EMAILTEMPLATES_PHYSICAL_PATH"].ToString(), filename); using (StreamReader reader = new StreamReader(savedFileName)) { do { body = reader.ReadToEnd().Replace("[AccountName]", accountName).Replace("[AccountImage]", accountImage).Replace("[TotalImported]", response.Data.ImportTotal.ToString()) .Replace("[BadEmailsCount]", response.Data.BadEmails.ToString()).Replace("[GoodEmailsCount]", response.Data.GoodEmails.ToString()) .Replace("[ADDRESS]", accountAddress).Replace("[PHONE]", accountPhoneNumber).Replace("[UserName]", userName).Replace("[UserEmail]", primaryEmail) .Replace("[FileData]", response.Data.EntityNames).Replace("[FileName]", entityName); } while (!reader.EndOfStream); } } } return(body); }