if i dont use the async then the await operators thorws a error.
I changed my code to send the email after the using block. Nowit works fine. But is that a good way to do a task outside the using statement?
[UnitOfWork]
protected override async void DoWork()
{
//disable filter to get all user data
using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant))
{
//list to hold the missing documents
IList<MissingDocumentDto> missingDocumentDtos = new List<MissingDocumentDto>();
//get all non profits and uploaded documents
IList<NonProfit> nonProfits = _nonProfitRepository.GetAllIncluding(np => np.Documents).ToList();
//loop through the non profits
foreach (NonProfit nonProfit in nonProfits)
{
//get tenant id for the non profit.
int nonProfitTenantId = nonProfit.TenantId;
//get the required document types for the tenant
IList<DocumentType> requiredDocumentTypes = _documentTypeRepository.GetAllList(np =>
np.TenantId == nonProfitTenantId &&
np.Required == true);
IList<long> missingDocumentIds = new List<long>();
//get the list of required documents not uploaded or commented by the non profit
requiredDocumentTypes.ToList().ForEach(rd =>
{
var document = nonProfit.Documents.Where(d => d.DocumentTypeId == rd.Id && d.IsDeleted == false).FirstOrDefault();
if (document == null)
{
//has not uploaded the document. add to the list
missingDocumentIds.Add(rd.Id);
}
else
{
//check if the document has been marked does not exist
if (document.DoesNotExist)
{
//not uploaded the document. add to the list
missingDocumentIds.Add(rd.Id);
}
}
});
//add to the missing list
if (missingDocumentIds.Count > 0)
{
missingDocumentDtos.Add(new MissingDocumentDto
{
NonProfit = nonProfit,
MissingDoucmentsIds = missingDocumentIds
});
}
}
//send the email
//await SendEmailAsync(missingDocumentDtos);
string apiKey = await _settingManager.GetSettingValueAsync(AppSettings.SendGridManagement.SendGridAPIKey);
string adminEmailAddress = await _settingManager.GetSettingValueAsync(AppSettings.SendGridManagement.AdminEmailAddress);
string subject = await _settingManager.GetSettingValueAsync(AppSettings.SendGridManagement.Subject);
//get the email template
string emailTemplate = GetEmailTemplate();
//replace the body
emailTemplate = emailTemplate.Replace("{EMAIL_TITLE}", subject)
.Replace("{EMAIL_SUB_TITLE}", subject)
.Replace("{EMAIL_BODY}", "test");
SendGridMessage message = MailHelper.CreateSingleEmail(
new EmailAddress(adminEmailAddress),
new EmailAddress("[email protected]")
, subject
, "Email"
, emailTemplate);
var client = new SendGridClient(apiKey);
**await client.SendEmailAsync(message);**
await CurrentUnitOfWork.SaveChangesAsync();
}
}
shared the code
I have a written a background worker to send email notifications to my users periodically using send grid. I followed the following example in your documetation.
https://aspnetboilerplate.com/Pages/Documents/v1.0.0.0/Background-Jobs-And-Workers
I am using the Send Grid nuget package to send emails. The CurrentUnitOfWork becomes null after i call the sendgrids,
await client.SendEmailAsync(message);
method. There for the below line fails in the worker class,
await CurrentUnitOfWork.SaveChangesAsync();
Can you please let me know why this happens and how to overcome this problem.
Thanks, Firnas
Thanks. But the problem here is the error when reloading the page (by F5 or refresh icon click)
We are trying to remove the # from url in MVC angularjs project. Below steps we followed
After these changes we can able to remove the # from url. Application works fine as SPA. But when reload the page that giving below error.
Server Error in '/' Application The resource cannot be found. HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
To fix this we added below rewrite rule in web.config
<rewrite> <rules> <rule name="Main Rule" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="/" /> </rule> </rules> </rewrite>
This giving too_many_redirects issue.
To over come from this we added below routing rule in routeConfig.cs
routes.MapRoute(
name: "Default",
url: "{*url}",
defaults: new { controller = "Home", action = "Index" },
namespaces: new[] { "NetScribe.Web.Controllers" });
But this also not helping.
Please help with any working methods to achieve this.
I have a asp zero angular 2 project created back in year 2017. No development was done for this project after mid of 2018 and lived in our repo. I downloaded the source code and installed the node modules using yarn. When i run the angular project using npm start i get the below error,
ERROR in Metadata version mismatch for module D:/TactCards/TactCardProject/tact.cards/trunk-sapphire/src/tactcards.Web.Host/node_modules/abp-ng2-module/node_modules/@angular/http/http.d.ts, found version 4, expected 3, resolving symbol ABP_HTTP_PROVIDER in D:/TactCards/TactCardProject/tact.cards/trunk-sapphire/src/tactcards.Web.Host/node_modules/abp-ng2-module/src/abp.module.ts, resolving symbol RootModule in D:/TactCards/TactCardProject/tact.cards/trunk-sapphire/src/tactcards.Web.Host/src/root.module.ts, resolving symbol RootModule in D:/TactCards/TactCardProject/tact.cards/trunk-sapphire/src/tactcards.Web.Host/src/root.module.ts
Can you please let me know why i am getting this error? I googled the error which led me to this linke https://github.com/aspnetboilerplate/module-zero-core-template/issues/141
i changed the @angular/http versiong to 4.3.6 but still the above error occures. Can anyone please help me to resolve this issue?
I figured it out. I havent set the isVisibleToClient parameter when adding the setting to the settings manager.
I have created a xamarin mobile app and it calls the "AbpUserConfiguration/GetAll" to get all settings. How can i add a new setting to this array returned?
I found the below link which solved my problem,
https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1971
Hope it will help anyone who is facing my issue.
I have a mobile application that allows user registration. When registering the user from the API, I set the "User" role to the new user created. The user can log in to the mobile application once the "User" role is set.
If i try to log in to the angular web site using the credentials used to create the new user, the user can log in to the application. I need to disable this functionality. The mobile created users should not log in to the angular web application. The web application acts as the admin site.
How can i disable mobile created users from logging into the web application?