Merge branch 'dev' into auto-merge/rel-6-0/1304

pull/13809/head
maliming 3 years ago committed by GitHub
commit 4b625d3b27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -397,6 +397,8 @@
"BookDiscountDeletionConfirmationMessage": "Are you sure you want to delete this book discount?",
"CustomPaymentFlexSwitchDescription": "With license",
"AllowFeatureUpgradeOnLicenseExpire": "Allow feature upgrade on license expire",
"Deleted{0}": "[Deleted {0}]"
"Deleted{0}": "[Deleted {0}]",
"Tags": "Tags",
"SetTagsInfo": "Tags should be comma-separated. Eg: CSharp, Entity Framework"
}
}

@ -30,7 +30,7 @@
"NugetPackageDeletionWarningMessage": "Sunteţi sigur(ă) că doriţi să ştergeţi acest pachet de tip Nuget?",
"ModuleDeletionWarningMessage": "Sunteţi sigur(ă) că doriţi să ştergeţi acest modul?",
"Name": "Nume",
"DisplayName": "Nume de afişare",
"DisplayName": "Nume afişat",
"ShortDescription": "Descriere scurtă",
"NameFilter": "Nume",
"CreationTime": "Data şi ora creării",
@ -317,7 +317,7 @@
"TrialLicenseStartDateFilter": "Data de început",
"TrialLicenseEndDateFilter": "Data de încheiere",
"FirsName": "Nume",
"LastName": "Nume",
"LastName": "Nume de familie",
"StartDate": "Data de început",
"EndDate": "Data de încheiere",
"PurchasedDate": "Data achiziției",
@ -350,4 +350,4 @@
"Volo.AbpIo.Commercial:030010": "Pentru a achiziționa licența de probă, mai întâi trebuie să vă activați licența de probă!",
"Volo.AbpIo.Commercial:030011": "Nu puteți șterge o licență de probă atunci când este achiziționată!"
}
}
}

@ -73,6 +73,7 @@
"DeveloperFocused": "Developer Focused",
"ShareYourExperiences": "Share your experiences with the ABP Framework",
"LatestPosts": "Latest Posts",
"LatestVideos": "Latest Videos",
"Views": "Views",
"LearnLatestNewsAboutABPFramework": "Get information about happenings in ABP like new releases, free sources, posts, and more.",
"DeveloperTools": "Developer Tools",
@ -98,6 +99,7 @@
"Logout": "Logout",
"Home": "Home",
"Posts": "Posts",
"Videos": "Videos",
"JoinTheABPCommunity": "Join the ABP Community",
"SubmitYourPost": "Submit Your Post",
"Modules": "Modules",
@ -164,6 +166,17 @@
"Books": "Books",
"ABPDiscordServer": "ABP Discord Server",
"ABPCommunityTalks": "ABP Community Talks",
"ABPCommunityPosts": "ABP Community Posts"
"ABPCommunityPosts": "ABP Community Posts",
"BuyAndGetMonths": "BUY 12 MONTHS, <span class=\"text-info\">GET 14 MONTHS!</span>",
"GetYourDeal": "Get Your Deal",
"BuyOrRenewLicense": "Buy or Renew License Now and Get 2 Extra Months!",
"BuyOrRenewLicenseToGetExtra2Months": "Buy or Renew License Now and Get 2 Extra Months! HURRY UP! ⏰ Last Day: {0}",
"HurryUp": "HURRY UP!",
"LastDay": "Last Day: {0}",
"BuyNewLicenseBetweenDatesToGetBenefit": "Buy a new license between {0} and {1} to get benefit for extra 2 months!",
"CheckAllCommunityTalks": "Check All Community Posts",
"ReadMore": "Read More",
"Post": "Post",
"ExploreTheContentsCreatedByTheCoreABPTeamAndTheABPCommunity": "Explore the contents created by the core ABP team and the ABP community."
}
}

@ -73,6 +73,7 @@
"DeveloperFocused": "以开发者为中心",
"ShareYourExperiences": "分享您使用 ABP 框架的经验",
"LatestPosts": "最新的帖子",
"LatestVideos": "最新的视频",
"Views": "意见",
"LearnLatestNewsAboutABPFramework": "获取有关 ABP 的最新相关信息,例如新版本、免费资源、帖子等。",
"DeveloperTools": "开发者工具",
@ -98,6 +99,7 @@
"Logout": "登出",
"Home": "主页",
"Posts": "帖子",
"Videos": "视频",
"JoinTheABPCommunity": "加入 ABP 社区",
"SubmitYourPost": "提交您的帖子",
"Modules": "模块",
@ -161,6 +163,17 @@
"Error_Page_500_Title": "好像出了什么问题!",
"Error_Page_500_Description_1": "我们会自动跟踪这些错误,但如果问题仍然存在,请随时 <br /> 联系我们。 与此同时,尝试刷新。",
"Error_Page_500_Description_2": "通过 <a href=\"mailto:info@abp.io\" target=\"_blank\">info@abp.io</a> 与我们联系。",
"Books": "书籍"
"Books": "书籍",
"BuyAndGetMonths": "购买 12 个月,<span class=\"text-info\">获得 14 个月!</span>",
"GetYourDeal": "得到你的交易",
"BuyOrRenewLicense": "立即购买或续订许可证并额外获得 2 个月!",
"BuyOrRenewLicenseToGetExtra2Months": "立即购买或续订 ABP 商业许可证(适用于所有版本)并额外获得 2 个月!",
"HurryUp": "赶快下单!",
"LastDay": "活动截止日期: {0}",
"BuyNewLicenseBetweenDatesToGetBenefit": "在 {0} 和 {1} 之间购买一个新的许可证以获得额外 2 个月的收益!",
"CheckAllCommunityTalks": "检查所有社区帖子",
"ReadMore": "阅读更多",
"Post": "邮政",
"ExploreTheContentsCreatedByTheCoreABPTeamAndTheABPCommunity": "探索核心 ABP 团队和 ABP 社区创建的内容。"
}
}

@ -89,7 +89,7 @@
"Blogging": "التدوين",
"Identity": "هوية",
"IdentityServer": "خادم الهوية",
"Saas": "ساس",
"Saas": "البرمجيات كخدمة",
"LanguageManagement": "إدارة اللغة",
"TextTemplateManagement": "إدارة قالب النص",
"See All Modules": "انظر جميع الوحدات",
@ -382,4 +382,4 @@
"RenewLicenseEarly": "إذا قمت بتجديد رخصتي في وقت مبكر ، هل سأحصل على السنة كاملة؟",
"RenewLicenseEarylExplanation": "عند تجديد الترخيص الخاص بك قبل تاريخ انتهاء الترخيص الخاص بك ، ستتم إضافة سنة واحدة إلى تاريخ انتهاء الترخيص الخاص بك. على سبيل المثال ، إذا انتهت صلاحية ترخيصك في {0} -06-06 وقمت بتجديده في {0} -01-01 ، فسيكون تاريخ انتهاء صلاحية الترخيص الجديد {1} -06-06."
}
}
}

@ -735,6 +735,14 @@
"ConfirmedEmailAddressRequiredToStartTrial": "You should have a confirmed email address in order to start a trial license.",
"EmailVerificationMailNotSent": "Email verification mail couldn't send.",
"GetConfirmationEmail": "<a href=\"javascript:void(0);\" id=\"{0}\">Click here to get a confirmation email</a> if you haven't got it before.",
"WhichLicenseTypeYouAreInterestedIn": "Which license type you are interested in?"
"WhichLicenseTypeYouAreInterestedIn": "Which license type you are interested in?",
"DontTakeOurWordForIt": "Don't take our word for it...",
"ReadAbpCommercialUsersWantYouToKnow": "Read what ABP Commercial users want you to know",
"Testimonial_ShortDescription_1": "The modularity of ABP made it possible for the team to deliver in time.",
"Testimonial_ShortDescription_2": "Build new features faster than before.",
"Testimonial_ShortDescription_3": "We start from out-of-the-box features and just focus on what we really need to write.",
"Testimonial_ShortDescription_4": "ABP Commercial was the best fit for our needs.",
"OnlineReviewersOnAbpCommercial": "Online Reviews on ABP Commercial",
"SeeWhatToldAboutAbpCommercial": "See what has been told about ABP Commercial and write your thoughts if you want."
}
}

@ -341,7 +341,7 @@
"SignIn": "Autentificare",
"Or": "Sau",
"TellUsAboutYourself": "Spuneţi-ne despre dumneavoastră",
"Surname": "Nume",
"Surname": "Nume de familie",
"DoYouAgreePrivacyPolicy": "Sunt de acord cu <a href=\"/TermsConditions\">Termenii şi condiţiile<a/> şi <a href=\"/Privacy\">Politica de confidenţialitate</a>.",
"VolosoftMarketingInformationMessage": "Sunt de acord să primesc informaţii, sfaturi şi oferte despre soluţii pentru afaceri şi organizaţii şi alte produse şi servicii Volosoft.",
"VolosoftSharingInformationMessage": "Sunt de acord ca Volosoft să partajeze informaţiile mele cu partenerii selectaţi astfel încât să primesc informaţii relevante despre produsele şi serviciile lor.",
@ -380,4 +380,4 @@
"TrialLicenseExpiredInfo": "Perioada de licență de probă a expirat!",
"CommercialNewsletterConfirmationMessage": "Sunt de acord cu <a href=\"https://commercial.abp.io/TermsConditions\">Termenii și condițiile</a> și cu <a href=\"https://commercial.abp.io/Privacy\">Politica de confidențialitate </a>."
}
}
}

@ -565,7 +565,7 @@
"PrePayment_IyzicoRedirectionInfo": "您将被重定向到 Iyzico 支付网关以安全地完成您的购买。",
"PrePayment_IyzicoAcceptVisaAndMasterCard": "Iyzico 接受 Visa 和 MasterCard。",
"Purchase": "购买",
"AcceptTermsAndConditions": "我已阅读、理解并接受<a href=\"{0}\" target=\"_blank\" class=\"text-primary\" rel=\"noopener\">隐私政策</a> <a href=\"{1}\" target=\"_blank\" class=\"text-primary\" rel=\"noopener\">条款和条件</a>和<a href=\"{ 2}\" target=\"_blank\" class=\"text-primary\"> EULA。</a>",
"AcceptTermsAndConditions": "我已阅读、理解并接受<a href=\"{0}\" target=\"_blank\" class=\"text-primary\" rel=\"noopener\">隐私政策</a> <a href=\"{1}\" target=\"_blank\" class=\"text-primary\" rel=\"noopener\">条款和条件</a>和<a href=\"{2}\" target=\"_blank\" class=\"text-primary\"> EULA。</a>",
"AcceptTermsAndConditionsWarningMessage": "请接受隐私政策和条款和条件",
"SelectGatewayToContinue": "请选择一个网关以继续!",
"GatewaySelection_SelectGateway": "选择支付网关",

@ -150,7 +150,6 @@
"GetStarted": "Get Started",
"SourceCode": "Source Code",
"LeaveComment": "Leave Comment",
"ReadMore": "Read more",
"ShowMore": "Show More",
"NoPublishedPostsYet": "No published posts yet.",
"Name": "Name",
@ -184,6 +183,7 @@
"Post_Index_Page_MetaDescription": "ABP Community's purpose is to create a contribution environment for developers who use the ABP framework.",
"Layout_Title": "{0} | ABP Community",
"Layout_MetaDescription": "ABP Community is an environment where people can share posts about ABP framework and follows the projects.",
"Index_Page_CommunityIntroduction": "This is a hub for ABP Framework, .NET and software development. You can read the articles, watch the video tutorials, get informed about ABPs development progress and ABP-related events, help other developers and share your expertise with the ABP community."
"Index_Page_CommunityIntroduction": "This is a hub for ABP Framework, .NET and software development. You can read the articles, watch the video tutorials, get informed about ABPs development progress and ABP-related events, help other developers and share your expertise with the ABP community.",
"TagsInArticle": "Tags in article"
}
}

@ -150,7 +150,6 @@
"GetStarted": "开始使用",
"SourceCode": "源代码",
"LeaveComment": "发表评论",
"ReadMore": "阅读更多",
"ShowMore": "展示更多",
"NoPublishedPostsYet": "还没有发布的帖子。",
"Name": "名字",

@ -1,5 +1,8 @@
namespace AbpIoLocalization.Www
using Volo.Abp.Localization;
namespace AbpIoLocalization.Www
{
[LocalizationResourceName("AbpIoWww")]
public class AbpIoWwwResource
{

@ -293,7 +293,6 @@
"ExploreDocumentationAndGuides": "Explore the comprehensive documentation and guides.",
"Documentations": "Documentation",
"Views": "Views",
"ReadMore": "Read More",
"EnterYouEmailToGetNews": "Enter your email to get the latest news about the ABP Framework",
"Tiered": "Tiered",
"SeparateIdentityServer": "Separate Identity Server",
@ -372,6 +371,27 @@
"MasteringAbpFramework_Book_What_You_Will_Learn_8": "Write unit, integration, and UI tests using ABP Framework.",
"MasteringAbpFramework_Book_WhoIsThisBookFor": "Who's this book for",
"MasteringAbpFramework_Book_WhoIsThisBookFor_Description": "This book is for web developers who want to learn software architectures and best practices for building\n maintainable web-based solutions using Microsoft technologies and ABP Framework. Basic knowledge of C#\n and ASP.NET Core is necessary to get started with this book.",
"ComputersAndTechnology": "Computers & Technology"
"ComputersAndTechnology": "Computers & Technology",
"BuildingMicroserviceSolutions": "Building Microservice Solutions",
"MicroserviceBookPracticalGuide": "This book is a reference guide for developing and managing microservice-based applications using the ABP Framework. It references the <strong>.NET Microservice Sample Reference Application</strong>: eShopOnContainers and discusses the architectural design and implementation approaches using the ABP Framework. By the end of this book, you'll learn how ABP approaches the common microservice complexities such as authorization, distributed transactions, inter-microservice communications, deployment, etc.",
"IntroducingTheSolution": "Introducing the eShopOnAbp Solution",
"RunningTheSolution": "Running the Solution",
"UnderstandingTheAuthenticationSystem": "Understanding the Authentication System",
"ExploringTheApplications": "Exploring the Applications",
"UnderstandingTheAPIGateways": "Understanding the API Gateways",
"DevelopingTheMicroservices": "Developing the Microservices",
"UnderstandingTheInfrastructure": "Understanding the Infrastructure",
"DiggingInTheUseCases": "Digging in the Use Cases",
"DeployingTheSolution": "Deploying the Solution",
"ThisBookIsInDraftStageAndIsNotCompletedYet": "This book is in draft stage and is not completed yet.",
"Authors": "Authors",
"MicroserviceEBook": "Microservice E-Book",
"SelectUITheme": "Select UI Theme",
"LeptonXLiteTheme": "LeptonX Lite Theme",
"BasicTheme": "Basic Theme",
"LeptonXLiteThemeInfo": " A modern and stylish Bootstrap UI theme. Ideal if you want to have a production ready UI theme. This is the newest theme and is the default.",
"BasicThemeInfo": "Minimalist UI theme with plain Bootstrap colors and styles. Ideal if you will build your own UI theme.",
"SeeDocumentation": "See <a href='{0}' target='_blank'>documentation</a>.",
"SeeFullScreen": "<a href='{0}' target='_blank'>🖼️ See the screenshot</a>"
}
}

@ -253,18 +253,18 @@
"Or": "Sau",
"TellUsAboutYourself": "Spuneţi-ne un pic despre dumneavoastră",
"Name": "Nume",
"Surname": "Nume",
"Surname": "Nume de familie",
"CompanyName": "Nume companie",
"DoYouAgreePrivacyPolicy": "Sunt de acord cu <a href=\"https://account.abp.io/Account/TermsConditions\">Termenii & condiţiile</a> şi <a href=\"https://account.abp.io/Account/Privacy\">Politica de confidenţialitate</a>.",
"Free": "Gratuit",
"DDDEBook": "E-book DDD",
"PracticalGuideForImplementingDDD": "Această carte este un ghid practic pentru implementarea Domain Driven Design în framework-ul ABP.",
"IntroducingDDD": "Introducere în Domain Driven Design",
"DDDLayersAndCleanArchitecture": "Straturile DDD & Arhitectură curată",
"DDDLayersAndCleanArchitecture": "Straturile DDD şi Arhitectură curată",
"LayeringOfADotnetSolution": "Stratificarea unei soluţii .NET",
"ImplementingDDDBuildingBlocks": "Implementând DDD Building Blocks",
"DomainVsApplicationLogic": "Domain Logic vs Application Logic",
"SamplesAndDiscussions": "Exemple & Discuţii",
"SamplesAndDiscussions": "Exemple şi Discuţii",
"EmailNotValid": "Vă rugăm să introduceţi o adresa de email validă.",
"WeWillSendYouADownloadLink": "Un link care conţine e-book-ul a fost trimis către {0}. Verificaţi-vă folderele de inbox, junk sau spam!",
"GoHome": "Pagina principală",

@ -279,6 +279,7 @@
"SubscribeToNewsletter": "ABP.IO Platform'u ile ilgili yeni haberler, makaleler, teklifler ve daha fazlası gibi gelişmeler hakkında bilgi almak için bültene abone olun.",
"FirstEdition": "İlk Baskı",
"ThankYou": "Teşekkürler!",
"CheckboxMandatory": "Devam etmek için bunu kontrol etmeniz gerekiyor!"
"CheckboxMandatory": "Devam etmek için bunu kontrol etmeniz gerekiyor!",
"ThisBookIsInDraftStageAndIsNotCompletedYet": "Bu kitap taslak aşamasındadır ve henüz tamamlanmamıştır."
}
}

@ -293,7 +293,6 @@
"ExploreDocumentationAndGuides": "探索全面的文档和指南。",
"Documentations": "文档",
"Views": "意见",
"ReadMore": "阅读更多",
"EnterYouEmailToGetNews": "输入您的电子邮件以获取有关 ABP 框架的最新消息",
"Tiered": "分层",
"SeparateIdentityServer": "独立的身份服务器",
@ -372,6 +371,7 @@
"MasteringAbpFramework_Book_What_You_Will_Learn_8": "使用 ABP 框架编写单元、集成和 UI 测试。",
"MasteringAbpFramework_Book_WhoIsThisBookFor": "这本书是给谁看的",
"MasteringAbpFramework_Book_WhoIsThisBookFor_Description": "本书适用于希望学习软件架构和最佳实践的 Web 开发人员,以使用 Microsoft 技术和 ABP 框架构建\n 可维护的基于 Web 的解决方案。 C#\n 和 ASP.NET Core 的基本知识是开始阅读本书所必需的。",
"ComputersAndTechnology": "计算机与技术"
"ComputersAndTechnology": "计算机与技术",
"ThisBookIsInDraftStageAndIsNotCompletedYet": "这本书正在草案阶段,还没有完成。"
}
}

@ -38,5 +38,6 @@
<s:Boolean x:Key="/Default/Environment/TypeNameHintsOptions/ShowTypeNameHintsForLambdaExpressionParameters/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/Environment/TypeNameHintsOptions/ShowTypeNameHintsForLinqQueryRangeVariables/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/Environment/TypeNameHintsOptions/ShowTypeNameHintsForPatternMatchingExpressions/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dapr/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Volo/@EntryIndexedValue">True</s:Boolean>
</wpf:ResourceDictionary>

@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Version>6.0.0-rc.3</Version>
<Version>7.0.0</Version>
<NoWarn>$(NoWarn);CS1591;CS0436</NoWarn>
<PackageIconUrl>https://abp.io/assets/abp_nupkg.png</PackageIconUrl>
<PackageProjectUrl>https://abp.io/</PackageProjectUrl>

@ -126,25 +126,31 @@ By default, all the job types use the `Default` RabbitMQ connection.
Configure<AbpRabbitMqBackgroundJobOptions>(options =>
{
options.DefaultQueueNamePrefix = "my_app_jobs.";
options.DefaultDelayedQueueNamePrefix = "my_app_jobs.delayed"
options.PrefetchCount = 1;
options.JobQueues[typeof(EmailSendingArgs)] =
new JobQueueConfiguration(
typeof(EmailSendingArgs),
queueName: "my_app_jobs.emails",
connectionName: "SecondConnection"
connectionName: "SecondConnection",
delayedQueueName:"my_app_jobs.emails.delayed"
);
});
````
* This example sets the default queue name prefix to `my_app_jobs.`. If different applications use the same RabbitMQ server, it would be important to use different prefixes for each application to not consume jobs of each other.
* This example sets the default queue name prefix to `my_app_jobs.` and default delayed queue name prefix to `my_app_jobs.delayed`. If different applications use the same RabbitMQ server, it would be important to use different prefixes for each application to not consume jobs of each other.
* Sets `PrefetchCount` for all queues.
* Also specifies a different connection string for the `EmailSendingArgs`.
`JobQueueConfiguration` class has some additional options in its constructor;
* `queueName`: The queue name that is used for this job. The prefix is not added, so you need to specify the full name of the queue.
* `DelayedQueueName`: The delayed queue name that is used for delayed execution of job. The prefix is not added, so you need to specify the full name of the queue.
* `connectionName`: The RabbitMQ connection name (see the connection configuration above). This is optional and the default value is `Default`.
* `durable` (optional, default: `true`).
* `exclusive` (optional, default: `false`).
* `autoDelete` (optional, default: `false`)
* `autoDelete` (optional, default: `false`).
* `PrefetchCount` (optional, default: null)
See the RabbitMQ documentation if you want to understand the `durable`, `exclusive` and `autoDelete` options better, while most of the times the default configuration is what you want.

@ -0,0 +1,690 @@
# How to Design Multi-Lingual Entity
## Introduction
If you want to open up to the global market these days, end-to-end localization is a must. ABP provides an already established infrastructure for static texts. However, this may not be sufficient for many applications. You may need to fully customize your app for a particular language and region.
Let's take a look at a few quotes from Christian Arno's article "[How Foreign-Language Internet Strategies Boost Sales](https://www.mediapost.com/publications/article/155250/how-foreign-language-internet-strategies-boost-sal.html)" to better understand the impact of this:
- 82% of European consumers are less likely to buy online if the site is not in their native tongue ([Eurobarometer survey](http://europa.eu/rapid/pressReleasesAction.do?reference=IP/11/556)).
- 72.4% of global consumers are more likely to buy a product if the information is available in their own language ([Common Sense Advisory](http://www.commonsenseadvisory.com/)).
- The English language currently only accounts for 31% of all online use, and more than half of all searches are in languages other than English.
- Today, 42% of all Internet users are in Asia, while almost one-quarter are in Europe and just over 10% are in Latin America.
- Foreign languages have experienced exponential growth in online usage in the past decade -- with Chinese now officially the [second-most-prominent-language](http://english.peopledaily.com.cn/90001/90776/90882/7438489.html) on the Web. [Arabic](http://www.internetworldstats.com/stats7.htm) has increased by a whopping 2500%, while English has only risen by 204%
If you are looking for ways to expand your market share by fully customizing your application for a particular language and region, in this article I will explain how you can do it with ABP framework.
### Source Code
You can find the source code of the application at [abpframework/abp-samples](https://github.com/abpframework/abp-samples/tree/master/AcmeBookStoreMultiLingual).
### Demo of the Final Application
At the end of this article, we will have created an application same as in the gif below.
![data-model](./result.gif)
## Development
In order to keep the article short and get rid of unrelated information in the article (like defining entities etc.), we'll be using the [BookStore](https://github.com/abpframework/abp-samples/tree/master/BookStore-Mvc-EfCore) example, which is used in the "[Web Application Development Tutorial](https://docs.abp.io/en/abp/latest/Tutorials/Part-1?UI=MVC&DB=EF)" documentation of ABP Framework and we will make the Book entity as multi-lingual. If you do not want to finish this tutorial, you can find the application [here](https://github.com/abpframework/abp-samples/tree/master/BookStore-Mvc-EfCore).
### Determining the data model
We need a robust, maintainable, and efficient data model to store content in multiple languages.
> I read many articles to determine the data model correctly, and as a result, I decided to use one of the many approaches that suit us.
> However, as in everything, there is a trade-off here. If you are wondering about the advantages and disadvantages of the model we will implement compared to other models, I recommend you to read [this article](https://vertabelo.com/blog/data-modeling-for-multiple-languages-how-to-design-a-localization-ready-system/).
![data-model](./data-model.png)
As a result of the tutorial, we already have the `Book` and `Author` entities, as an extra, we will just add the `BookTranslation`.
> In the article, we will make the Name property of the Book entity multi-lingual, but the article is independent of the Book entity, you can make the entity you want multi-lingual with similar codes according to your requirements.
#### Acme.BookStore.Domain.Shared
Create a folder named `MultiLingualObjects` and create the following interfaces in its contents.
We will use the `IObjectTranslation` interface to mark the translation of a multi-lingual entity:
```csharp
public interface IObjectTranslation
{
string Language { get; set; }
}
```
We will use the `IMultiLingualObject<TTranslation>` interface to mark multi-lingual entities:
```csharp
public interface IMultiLingualObject<TTranslation>
where TTranslation : class, IObjectTranslation
{
ICollection<TTranslation> Translations { get; set; }
}
```
#### Acme.BookStore.Domain
In the `Books` folder, create the `BookTranslation` class as follows:
```csharp
public class BookTranslation : Entity, IObjectTranslation
{
public Guid BookId { get; set; }
public string Name { get; set; }
public string Language { get; set; }
public override object[] GetKeys()
{
return new object[] {BookId, Language};
}
}
```
`BookTranslation` contains the `Language` property, which contains a language code for translation and a reference to the multi-lingual entity. We also have the `BookId` foreign key to help us know which book is translated.
Implement `IMultiLingualObject` in the `Book` class as follows:
```csharp
public class Book : AuditedAggregateRoot<Guid>, IMultiLingualObject<BookTranslation>
{
public Guid AuthorId { get; set; }
public string Name { get; set; }
public BookType Type { get; set; }
public DateTime PublishDate { get; set; }
public float Price { get; set; }
public ICollection<BookTranslation> Translations { get; set; }
}
```
Create a folder named `MultiLingualObjects` and add the following class inside of this folder:
```csharp
public class MultiLingualObjectManager : ITransientDependency
{
protected const int MaxCultureFallbackDepth = 5;
public async Task<TTranslation> FindTranslationAsync<TMultiLingual, TTranslation>(
TMultiLingual multiLingual,
string culture = null,
bool fallbackToParentCultures = true)
where TMultiLingual : IMultiLingualObject<TTranslation>
where TTranslation : class, IObjectTranslation
{
culture ??= CultureInfo.CurrentUICulture.Name;
if (multiLingual.Translations.IsNullOrEmpty())
{
return null;
}
var translation = multiLingual.Translations.FirstOrDefault(pt => pt.Language == culture);
if (translation != null)
{
return translation;
}
if (fallbackToParentCultures)
{
translation = GetTranslationBasedOnCulturalRecursive(
CultureInfo.CurrentUICulture.Parent,
multiLingual.Translations,
0
);
if (translation != null)
{
return translation;
}
}
return null;
}
protected TTranslation GetTranslationBasedOnCulturalRecursive<TTranslation>(
CultureInfo culture, ICollection<TTranslation> translations, int currentDepth)
where TTranslation : class, IObjectTranslation
{
if (culture == null ||
culture.Name.IsNullOrWhiteSpace() ||
translations.IsNullOrEmpty() ||
currentDepth > MaxCultureFallbackDepth)
{
return null;
}
var translation = translations.FirstOrDefault(pt => pt.Language.Equals(culture.Name, StringComparison.OrdinalIgnoreCase));
return translation ?? GetTranslationBasedOnCulturalRecursive(culture.Parent, translations, currentDepth + 1);
}
}
```
With `MultiLingualObjectManager`'s `FindTranslationAsync` method, we get the translated version of the book according to `CurrentUICulture`. If no translation of culture is found, we return null.
> Every thread in .NET has `CurrentCulture` and `CurrentUICulture` objects.
#### Acme.BookStore.EntityFrameworkCore
In the `OnModelCreating` method of the `BookStoreDbContext` class, configure the `BookTranslation` as follows:
```csharp
builder.Entity<BookTranslation>(b =>
{
b.ToTable(BookStoreConsts.DbTablePrefix + "BookTranslations",
BookStoreConsts.DbSchema);
b.ConfigureByConvention();
b.HasKey(x => new {x.BookId, x.Language});
});
```
> I haven't explicitly set up a one-to-many relationship between `Book` and `BookTranslation` here, but the entity framework will do it for us.
After that, you can just run the following command in a command-line terminal to add a new database migration (in the directory of the `EntityFrameworkCore` project):
```bash
dotnet ef migrations add Added_BookTranslation
```
This will add a new migration class to your project. You can then run the following command (or run the `.DbMigrator` application) to apply changes to the database:
```bash
dotnet ef database update
```
Add the following code to the `ConfigureServices` method of the `BookStoreEntityFrameworkCoreModule`:
```csharp
Configure<AbpEntityOptions>(options =>
{
options.Entity<Book>(bookOptions =>
{
bookOptions.DefaultWithDetailsFunc = query => query.Include(o => o.Translations);
});
});
```
Now we can use `WithDetailsAsync` without any parameters on `BookAppService` knowing that `Translations` will be included.
#### Acme.BookStore.Application.Contracts
Implement `IObjectTranslation` in the `BookDto` class as follows:
```csharp
public class BookDto : AuditedEntityDto<Guid>, IObjectTranslation
{
public Guid AuthorId { get; set; }
public string AuthorName { get; set; }
public string Name { get; set; }
public BookType Type { get; set; }
public DateTime PublishDate { get; set; }
public float Price { get; set; }
public string Language { get; set; }
}
```
`Language` property is required to understand which language the translated book name belongs to in the UI.
Create the `AddBookTranslationDto` class in the `Books` folder as follows:
```csharp
public class AddBookTranslationDto : IObjectTranslation
{
[Required]
public string Language { get; set; }
[Required]
public string Name { get; set; }
}
```
Add the `AddTranslationsAsync` method to the `IBookAppService` as follows:
```csharp
public interface IBookAppService :
ICrudAppService<
BookDto,
Guid,
PagedAndSortedResultRequestDto,
CreateUpdateBookDto>
{
Task<ListResultDto<AuthorLookupDto>> GetAuthorLookupAsync();
Task AddTranslationsAsync(Guid id, AddBookTranslationDto input); // added this line
}
```
#### Acme.BookStore.Application
Now, we need to implement the `AddTranslationsAsync` method in `BookAppService` and include `Translations` in the `Book` entity, for this you can change the `BookAppService` as follows:
```csharp
[Authorize(BookStorePermissions.Books.Default)]
public class BookAppService :
CrudAppService<
Book, //The Book entity
BookDto, //Used to show books
Guid, //Primary key of the book entity
PagedAndSortedResultRequestDto, //Used for paging/sorting
CreateUpdateBookDto>, //Used to create/update a book
IBookAppService //implement the IBookAppService
{
private readonly IAuthorRepository _authorRepository;
public BookAppService(
IRepository<Book, Guid> repository,
IAuthorRepository authorRepository)
: base(repository)
{
_authorRepository = authorRepository;
GetPolicyName = BookStorePermissions.Books.Default;
GetListPolicyName = BookStorePermissions.Books.Default;
CreatePolicyName = BookStorePermissions.Books.Create;
UpdatePolicyName = BookStorePermissions.Books.Edit;
DeletePolicyName = BookStorePermissions.Books.Create;
}
public override async Task<BookDto> GetAsync(Guid id)
{
//Get the IQueryable<Book> from the repository
var queryable = await Repository.WithDetailsAsync(); // this line changed
//Prepare a query to join books and authors
var query = from book in queryable
join author in await _authorRepository.GetQueryableAsync() on book.AuthorId equals author.Id
where book.Id == id
select new { book, author };
//Execute the query and get the book with author
var queryResult = await AsyncExecuter.FirstOrDefaultAsync(query);
if (queryResult == null)
{
throw new EntityNotFoundException(typeof(Book), id);
}
var bookDto = ObjectMapper.Map<Book, BookDto>(queryResult.book);
bookDto.AuthorName = queryResult.author.Name;
return bookDto;
}
public override async Task<PagedResultDto<BookDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
//Get the IQueryable<Book> from the repository
var queryable = await Repository.WithDetailsAsync(); // this line changed
//Prepare a query to join books and authors
var query = from book in queryable
join author in await _authorRepository.GetQueryableAsync() on book.AuthorId equals author.Id
select new {book, author};
//Paging
query = query
.OrderBy(NormalizeSorting(input.Sorting))
.Skip(input.SkipCount)
.Take(input.MaxResultCount);
//Execute the query and get a list
var queryResult = await AsyncExecuter.ToListAsync(query);
//Convert the query result to a list of BookDto objects
var bookDtos = queryResult.Select(x =>
{
var bookDto = ObjectMapper.Map<Book, BookDto>(x.book);
bookDto.AuthorName = x.author.Name;
return bookDto;
}).ToList();
//Get the total count with another query
var totalCount = await Repository.GetCountAsync();
return new PagedResultDto<BookDto>(
totalCount,
bookDtos
);
}
public async Task<ListResultDto<AuthorLookupDto>> GetAuthorLookupAsync()
{
var authors = await _authorRepository.GetListAsync();
return new ListResultDto<AuthorLookupDto>(
ObjectMapper.Map<List<Author>, List<AuthorLookupDto>>(authors)
);
}
public async Task AddTranslationsAsync(Guid id, AddBookTranslationDto input)
{
var queryable = await Repository.WithDetailsAsync();
var book = await AsyncExecuter.FirstOrDefaultAsync(queryable, x => x.Id == id);
if (book.Translations.Any(x => x.Language == input.Language))
{
throw new UserFriendlyException($"Translation already available for {input.Language}");
}
book.Translations.Add(new BookTranslation
{
BookId = book.Id,
Name = input.Name,
Language = input.Language
});
await Repository.UpdateAsync(book);
}
private static string NormalizeSorting(string sorting)
{
if (sorting.IsNullOrEmpty())
{
return $"book.{nameof(Book.Name)}";
}
if (sorting.Contains("authorName", StringComparison.OrdinalIgnoreCase))
{
return sorting.Replace(
"authorName",
"author.Name",
StringComparison.OrdinalIgnoreCase
);
}
return $"book.{sorting}";
}
}
```
Create the `MultiLingualBookObjectMapper` class as follows:
```csharp
public class MultiLingualBookObjectMapper : IObjectMapper<Book, BookDto>, ITransientDependency
{
private readonly MultiLingualObjectManager _multiLingualObjectManager;
private readonly ISettingProvider _settingProvider;
public MultiLingualBookObjectMapper(
MultiLingualObjectManager multiLingualObjectManager,
ISettingProvider settingProvider)
{
_multiLingualObjectManager = multiLingualObjectManager;
_settingProvider = settingProvider;
}
public BookDto Map(Book source)
{
var translation = AsyncHelper.RunSync(() =>
_multiLingualObjectManager.FindTranslationAsync<Book, BookTranslation>(source));
return new BookDto
{
Id = source.Id,
AuthorId = source.AuthorId,
Type = source.Type,
Name = translation?.Name ?? source.Name,
PublishDate = source.PublishDate,
Price = source.Price,
Language = translation?.Language ?? AsyncHelper.RunSync(() => _settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage)),
CreationTime = source.CreationTime,
CreatorId = source.CreatorId,
LastModificationTime = source.LastModificationTime,
LastModifierId = source.LastModifierId
};
}
public BookDto Map(Book source, BookDto destination)
{
return default;
}
}
```
To map the multi-lingual `Book` entity to `BookDto`, we implement custom mapping using the `IObjectMapper<TSource, TDestination>` interface. If no translation is found, default values are returned.
So far we have created the entire infrastructure. We don't need to change anything in the UI, if there is a translation according to the language chosen by the user, the list view will change. However, I want to create a simple modal where we can add new translations to an existing book in order to see what we have done.
#### Acme.BookStore.Web
Create a new razor page named `AddTranslationModal` in the `Books` folder as below.
**View**
```html
@page
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
@model Acme.BookStore.Web.Pages.Books.AddTranslationModal
@{
Layout = null;
}
<form asp-page="/Books/AddTranslationModal">
<abp-modal>
<abp-modal-header>Translations</abp-modal-header>
<abp-modal-body>
<abp-input asp-for="Id"></abp-input>
<abp-select asp-for="@Model.TranslationViewModel.Language" asp-items="Model.Languages" class="form-select">
<option selected value="">Pick a language</option>
</abp-select>
<abp-input asp-for="TranslationViewModel.Name"></abp-input>
</abp-modal-body>
<abp-modal-footer buttons="@(AbpModalButtons.Cancel | AbpModalButtons.Save)"></abp-modal-footer>
</abp-modal>
</form>
```
**Model**
```csharp
public class AddTranslationModal : BookStorePageModel
{
[HiddenInput]
[BindProperty(SupportsGet = true)]
public Guid Id { get; set; }
public List<SelectListItem> Languages { get; set; }
[BindProperty]
public BookTranslationViewModel TranslationViewModel { get; set; }
private readonly IBookAppService _bookAppService;
private readonly ILanguageProvider _languageProvider;
public AddTranslationModal(
IBookAppService bookAppService,
ILanguageProvider languageProvider)
{
_bookAppService = bookAppService;
_languageProvider = languageProvider;
}
public async Task OnGetAsync()
{
Languages = await GetLanguagesSelectItem();
TranslationViewModel = new BookTranslationViewModel();
}
public async Task<IActionResult> OnPostAsync()
{
await _bookAppService.AddTranslationsAsync(Id, ObjectMapper.Map<BookTranslationViewModel, AddBookTranslationDto>(TranslationViewModel));
return NoContent();
}
private async Task<List<SelectListItem>> GetLanguagesSelectItem()
{
var result = await _languageProvider.GetLanguagesAsync();
return result.Select(
languageInfo => new SelectListItem
{
Value = languageInfo.CultureName,
Text = languageInfo.DisplayName + " (" + languageInfo.CultureName + ")"
}
).ToList();
}
public class BookTranslationViewModel
{
[Required]
[SelectItems(nameof(Languages))]
public string Language { get; set; }
[Required]
public string Name { get; set; }
}
}
```
Then, we can open the `BookStoreWebAutoMapperProfile` class and define the required mapping as follows:
```csharp
CreateMap<AddTranslationModal.BookTranslationViewModel, AddBookTranslationDto>();
```
Finally, change the content of `index.js` in the `Books` folder as follows:
```javascript
$(function () {
var l = abp.localization.getResource('BookStore');
var createModal = new abp.ModalManager(abp.appPath + 'Books/CreateModal');
var editModal = new abp.ModalManager(abp.appPath + 'Books/EditModal');
var addTranslationModal = new abp.ModalManager(abp.appPath + 'Books/AddTranslationModal'); // added this line
var dataTable = $('#BooksTable').DataTable(
abp.libs.datatables.normalizeConfiguration({
serverSide: true,
paging: true,
order: [[1, "asc"]],
searching: false,
scrollX: true,
ajax: abp.libs.datatables.createAjax(acme.bookStore.books.book.getList),
columnDefs: [
{
title: l('Actions'),
rowAction: {
items:
[
{
text: l('Edit'),
visible: abp.auth.isGranted('BookStore.Books.Edit'),
action: function (data) {
editModal.open({ id: data.record.id });
}
},
{
text: l('Add Translation'), // added this action
visible: abp.auth.isGranted('BookStore.Books.Edit'),
action: function (data) {
addTranslationModal.open({ id: data.record.id });
}
},
{
text: l('Delete'),
visible: abp.auth.isGranted('BookStore.Books.Delete'),
confirmMessage: function (data) {
return l(
'BookDeletionConfirmationMessage',
data.record.name
);
},
action: function (data) {
acme.bookStore.books.book
.delete(data.record.id)
.then(function() {
abp.notify.info(
l('SuccessfullyDeleted')
);
dataTable.ajax.reload();
});
}
}
]
}
},
{
title: l('Name'),
data: "name"
},
{
title: l('Author'),
data: "authorName"
},
{
title: l('Type'),
data: "type",
render: function (data) {
return l('Enum:BookType:' + data);
}
},
{
title: l('PublishDate'),
data: "publishDate",
render: function (data) {
return luxon
.DateTime
.fromISO(data, {
locale: abp.localization.currentCulture.name
}).toLocaleString();
}
},
{
title: l('Price'),
data: "price"
},
{
title: l('CreationTime'),
data: "creationTime",
render: function (data) {
return luxon
.DateTime
.fromISO(data, {
locale: abp.localization.currentCulture.name
}).toLocaleString(luxon.DateTime.DATETIME_SHORT);
}
}
]
})
);
createModal.onResult(function () {
dataTable.ajax.reload();
});
editModal.onResult(function () {
dataTable.ajax.reload();
});
$('#NewBookButton').click(function (e) {
e.preventDefault();
createModal.open();
});
});
```
## Conclusion
With a multi-lingual application, you can expand your market share, but if not designed well, may your application will be unusable. So, I've tried to explain how to design a sustainable multi-lingual entity in this article.
### Source Code
You can find source code of the example solution used in this article [here](https://github.com/abpframework/abp-samples/tree/master/AcmeBookStoreMultiLingual).

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

@ -1,9 +1,13 @@
# How to Add Custom Properties to the User Entity
> **Note:** If your application is greater than version 4.3.3, please follow [this article](../2022-07-19-How-To-Add-Custom-Property-To-The-User-Entity/How-To-Add-Custom-Property-To-The-User-Entity.md).
## Introduction
In this step-by-step article, I will explain how you can customize the user entity class, which is available in every web application you create using the ABP framework, according to your needs. When you read this article, you will learn how to override the services of built-in modules, extend the entities, extend data transfer objects and customize the user interface in the applications you develop using the ABP framework.
> **Note:** This article is not about customizing the `Login` page. If you have such a need, please follow [this article](../2020-05-09-Customize-the-Login-Page-for-MVC-Razor-Page-Applications/POST.md).
You can see the screenshots below which we will reach at the end of the article.
![custom-identity-user-list](./custom-identity-user-list.png)

@ -0,0 +1,154 @@
# How to Add Custom Properties to the User Entity
> **Note:** If your application is less than version 4.4.x, please follow [this article](../2020-10-08-How-To-Add-Custom-Property-To-The-User-Entity/How-To-Add-Custom-Property-To-The-User-Entity.md).
## Introduction
In this step-by-step article, I will explain how you can customize the user entity class, which is available in every web application you create using the ABP framework, according to your needs. When you read this article, you will learn how to override the services of built-in modules, extend the entities, extend data transfer objects and customize the user interface in the applications you develop using the ABP framework.
> **Note:** This article is not about customizing the `Login` page. If you have such a need, please follow [this article](../2020-05-09-Customize-the-Login-Page-for-MVC-Razor-Page-Applications/POST.md).
You can see the screenshots below which we will reach at the end of the article.
![custom-identity-user-list](./custom-identity-user-list.png)
![new-user](./new-user.png)
## Preparing the Project
### Startup template and the initial run
Abp Framework offers startup templates to get into the work faster. We can create a new startup template using Abp CLI:
`abp new CustomizeUserDemo`
> In this article, I will go through the MVC application, but it will work also in the [Angular](https://docs.abp.io/en/abp/latest/Getting-Started?UI=NG&DB=EF&Tiered=No), [Blazor Server](https://docs.abp.io/en/abp/latest/Getting-Started?UI=BlazorServer&DB=EF&Tiered=No), and [Blazor WebAssembly](https://docs.abp.io/en/abp/latest/Getting-Started?UI=Blazor&DB=EF&Tiered=No) application.
After the download is finished, we can run **CustomizeUserDemo.DbMigrator** project to create the database migrations and seed the initial data (admin user, role, etc). Then we can run `CustomizeUserDemo.Web` to see that our application is working.
> Default admin username is **admin** and password is **1q2w3E\***
![initial-project](./initial-project.png)
In this article, we will go through a scenario together and find the solutions to our questions through this scenario. However, since the scenario is not a real-life scenario, it may be strange, please don't get too about this issue :)
## Step-1
Create the Users folder in the **CustomizeUserDemo.Domain.Shared** project, create the class `UserConsts` inside the folder and update the class you created as below:
```csharp
public static class UserConsts
{
public const string TitlePropertyName = "Title";
public const string ReputationPropertyName = "Reputation";
public const int MaxTitleLength = 64;
public const double MaxReputationValue = 1_000;
public const double MinReputationValue = 1;
}
```
## Step-2
Update the `CustomizeUserDemoEfCoreEntityExtensionMappings` class in the **CustomizeUserDemo.EntityFramework** project in the EntityFrameworkCore folder as below:
```csharp
public static class CustomizeUserDemoEfCoreEntityExtensionMappings
{
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
public static void Configure()
{
CustomizeUserDemoGlobalFeatureConfigurator.Configure();
CustomizeUserDemoModuleExtensionConfigurator.Configure();
OneTimeRunner.Run(() =>
{
ObjectExtensionManager.Instance
.MapEfCoreProperty<IdentityUser, string>(
UserConsts.TitlePropertyName,
(_, propertyBuilder) =>
{
propertyBuilder.HasDefaultValue("");
propertyBuilder.HasMaxLength(UserConsts.MaxTitleLength);
}
).MapEfCoreProperty<IdentityUser, int>(
UserConsts.ReputationPropertyName,
(_, propertyBuilder) =>
{
propertyBuilder.HasDefaultValue(UserConsts.MinReputationValue);
}
);
});
}
}
```
This class can be used to map these extra properties to table fields in the database. Please read [this](https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities) article to improve your understanding of what we are doing.
So far, we have added our extra features to the `User` entity and matched these features with the `ef core`.
Now we need to add migration to see what has changed in our database. This for, open the Package Manager Console (PMC) under the menu Tools > NuGet Package Manager.
![nuget-package-manager](./nuget-package-manager.png)
Select the **CustomizeUserDemo.EntityFramework** as the **default project** and execute the following command:
```bash
Add-Migration "Updated-User-Entity"
```
![added-new-migration](./added-new-migration.png)
This will create a new migration class inside the `Migrations` folder of the **CustomizeUserDemo.EntityFrameworkCore** project.
> If you are using another IDE than the Visual Studio, you can use `dotnet-ef` tool as [documented here](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli#create-a-migration).
Finally, run the **CustomizeUserDemo.DbMigrator** project to update the database.
When we updated the database, you can see that the `Title` and `Reputation` columns are added to the `Users` table.
![user-table](./user-table.png)
## Step-3
Open the `CustomizeUserDemoModuleExtensionConfigurator` in the **CustomizeUserDemo.Domain.Shared** project, and change the contents of the `ConfigureExtraProperties` method as shown below:
```csharp
private static void ConfigureExtraProperties()
{
ObjectExtensionManager.Instance.Modules().ConfigureIdentity(identity =>
{
identity.ConfigureUser(user =>
{
user.AddOrUpdateProperty<string>(
UserConsts.TitlePropertyName,
options =>
{
options.Attributes.Add(new RequiredAttribute());
options.Attributes.Add(
new StringLengthAttribute(UserConsts.MaxTitleLength)
);
}
);
user.AddOrUpdateProperty<int>(
UserConsts.ReputationPropertyName,
options =>
{
options.DefaultValue = UserConsts.MinReputationValue;
options.Attributes.Add(
new RangeAttribute(UserConsts.MinReputationValue, UserConsts.MaxReputationValue)
);
}
);
});
});
}
```
That's it. Now let's run the application and look at the Identity user page. You can also try to edit and recreate a record if you want, it will work even though we haven't done anything extra. Here is the magic code behind ABP framework.
If there is a situation you want to add, you can click the contribute button or make a comment. Also, if you like the article, don't forget to share it :)
Happy coding :)

@ -0,0 +1,452 @@
# Deploying ABP Project to Azure App Service
In this document, you will learn how to create and deploy your first ABP web app to [Azure App Service](https://docs.microsoft.com/en-us/azure/app-service/overview). The App Service supports various versions of .NET apps, and provides a highly scalable, self-patching web hosting service. ABP web apps are cross-platform and can be hosted on Linux, Windows or MacOS.
****Prerequisites****
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/dotnet).
- A GitHub account [Create an account for free](http://github.com/).
## Creating a new ABP application
Create a repository on [GitHub.com](https://github.com/) (keep all settings as default).
Open the command prompt and clone the repository into a folder on your computer
```bash
git clone https://github.com/your-username/your-repository-name.git
```
Check your dotnet version. It should be at least 3.1.x
```bash
dotnet --version
```
Install or update the [ABP CLI](https://docs.abp.io/en/abp/latest/cli) with the following command:
```bash
dotnet tool install -g Volo.Abp.Cli || dotnet tool update -g Volo.Abp.Cli
```
Open the command prompt in the *GitHub repository folder* and create a new ABP Blazor solution with the command below:
```bash
abp new YourAppName -u blazor
```
## Running the application
Open the command prompt in the *[YourAppName].DbMigrator* project and enter the command below to apply the database migrations:
```bash
dotnet run
```
Open the command prompt in the *[YourAppName].HttpApi.Host* project to run the API project:
```bash
dotnet run
```
Navigate to the *applicationUrl* specified in *the launchSettings.json* file of the *[YourAppName].HttpApi.Host project*. You should get the *Swagger window*
Open the command prompt in the *[YourAppName].Blazor* folder and enter the command below to run the Blazor project:
```bash
dotnet run
```
Navigate to the *applicationUrl* specified in the *launchSettings.json* file of the *[YourAppName].Blazor* project and you should see the landing page.
Stop both the *API* and the *Blazor* project by pressing **CTRL+C**
## Committing to GitHub
Before the GitHub commit, you have to delete the line "**/wwwroot/libs/*" at *.gitignore* file.
![azdevops-23](images/azdevops-23.png)
Open the command prompt in the root folder of your project and *add, commit and push* all your changes to your GitHub repository:
```bash
git add .
git commit -m initialcommit
git push
```
## Configuring Azure database connection string
Create a SQL database on Azure and change the connection string in all the *appsettings.json* files.
* Login into [Azure Portal](https://portal.azure.com/)
* Click **Create a resource**
* Search for *SQL Database*
* Click the **Create** button in the *SQL Database window*
* Create a new resource group. Name it *rg[YourAppName]*
* Enter *[YourAppName]Db* as database name
* Create a new Server and name it *[yourappname]server*
* Enter a serveradmin login and passwords. Click the **OK** button
* Select your *Location*
* Check *Allow Azure services to access server*
* Click **Configure database**. Go to the *Basic* version and click the **Apply** button
* Click the **Review + create** button. Click **Create**
* Click **Go to resource** and click **SQL server** when the SQL Database is created
* Click **Networking** under Security left side menu
* Select **Selected networks** and click **Add your client IP$ address** at the Firewall rules
* Select **Allow Azure and resources to access this seerver** and save
* Go to your **SQL database**, click **Connection strings** and copy the connection string
* Copy/paste the *appsettings.json* files of the *[YourAppName].HttpApi.Host* and the *[YourAppName].DbMigrator* project
* Do not forget to replace {your_password} with the correct server password you entered in Azure SQL Database
## Running DB Migrations
Open the command prompt in the *[YourAppName].DbMigrator* project again and enter the command below to apply the database migrations:
```bash
dotnet run
```
Open the command prompt in the *[YourAppName].HttpApi.Host* project and enter the command below to check your API is working:
```bash
dotnet run
```
Stop the *[YourAppName].HttpApi.Host* by pressing CTRL+C.
## Committing to GitHub
Open the command prompt in the root folder of your project and add, commit and push all your changes to your GitHub repository
```bash
git add .
git commit -m initialcommit
git push
```
## Setting up the Build pipeline in AzureDevops and publish the Build Artifacts
* Sign in Azure DevOps
* Click **New organization** and follow the steps to create a new organisation. Name it [YourAppName]org
* Enter [YourAppName]Proj as project name in the ***Create a project to get started*** window
* Select **Public visibility** and click the **Create project** button
* Click the **Pipelines** button to continue
* Click the **Create Pipeline** button
Select GitHub in the Select your repository window
![azdevops-1](images/azdevops-1.png)
* Enter the Connection name. *[YourAppName]GitHubConnection* and click **Authorize using OAuth**
* Select your **GitHub** [YourAppName]repo and click Continue
* Search for **ASP.NET** in the ***Select a template*** window
![azdevops-2](images/azdevops-2.png)
* Select the ASP.NET Core template and click the **Apply** button
* Add the below commands block as a first step in the pipeline
```
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '6.0.106'
```
![azdevops-18](images/azdevops-18.png)
* Select **Settings** on the second task(Nugetcommand@2) in the pipeline
* Select **Feeds in my Nuget.config** and type **Nuget.config** in the text box
![azdevops-3](images/azdevops-3.png)
* Add the below commands block to the end of the pipeline
```
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: '$(Parameters.ArtifactName)'
condition: succeededOrFailed()
```
![azdevops-4](images/azdevops-4.png)
```
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
trigger:
- main
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '6.0.106'
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '$(solution)'
feedsToUse: 'config'
nugetConfigPath: 'NuGet.config'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: '$(Parameters.ArtifactName)'
publishLocation: 'Container'
condition: succeededOrFailed()
```
* Click **Save & queue** in the top menu. Click **Save & queue** again and click **Save and run** to run the Build pipeline
* When the Build pipeline has finished. Click **1 published; 1 consumed**
## Creating a Web App in the Azure Portal to deploy [YourAppName].HttpApi.Host project
* Search for Web App in the *Search the Marketplace* field
* Click the **Create** button in the Web App window
* Select rg[YourAppName] in the *Resource Group* dropdown
* Enter [YourAppName]API in the *Name input* field
* Select code, .NET Core 3.1 (LTS) and windows as *Operating System*
* Enter [YourAppName]API in the *Name input* field
* Select .NET Core 3.1 (LTS) in the *Runtime stack* dropdown
* Select Windows as *Operating System*
* Select the same *Region* as in the SQL server you created in Part 3
![azdevops-5](images/azdevops-5.png)
* Click **Create new** in the Windows Plan. Name it [YourAppName]ApiWinPlan
* Click **Change size** in Sku and size. Go to the Dev/Test Free F1 version and click the **Apply** button
![azdevops-6](images/azdevops-6.png)
* Click the **Review + create** button. Click the **Create** button
* Click **Go to resource** when the Web App has been created
## Creating a release pipeline in the AzureDevops and deploy [YourAppName].HttpApi.Host project
* Sign in into [Azure DevOps](https://azure.microsoft.com/en-us/services/devops/)
* Click [YourAppName]Proj and click **Releases** in the *Pipelines* menu
* Click the **New pipeline** button in the *No release pipelines found* window
* Select *Azure App Service deployment* and click the **Apply** button
![azdevops-7](images/azdevops-7.png)
* Enter *[YourAppName]staging* in the *Stage name* field in the *Stage* window. And close the window
* Click **+ Add an artifact** in the *Pipeline* tab
* Select the **Build** icon as *Source type* in the *Add an artifact* window
* Select Build pipeline in the *Source (build pipeline)* dropdown and click the **Add** button
![azdevops-8](images/azdevops-8.png)
* Click the **Continuous deployment trigger (thunderbolt icon)**
* Set the toggle to **Enabled** in the the *Continuous deployment trigger* window
* Click **+ Add** in *No filters added*. Select **Include** in the *Type* dropdown. Select your branch in the *Build branch* dropdown and close the window
![azdevops-9](images/azdevops-9.png)
* Click **the little red circle with the exclamation mark** in the *Tasks* tab menu
* Select your subscription in the *Azure subscription* dropdown.
![azdevops-10](images/azdevops-10.png)
* Click **Authorize** and enter your credentials in the next screens
* After Authorization, select the **[YourAppName]API** in the *App service name* dropdown
* Click the **Deploy Azure App Service** task
* Select **[YourAppName].HttpApi.Host.zip** in the *Package or folder* input field
![azdevops-11](images/azdevops-11.png)
* Click the **Save** icon in the top menu and click **OK**
* Click **Create release** in the top menu. Click **Create** to create a release
* Click the *Pipeline* tab and wait until the Deployment succeeds
![azdevops-12](images/azdevops-12.png)
* Open a browser and navigate to the URL of your Web App
```
https://[YourAppName]api.azurewebsites.net
```
![azdevops-13](images/azdevops-13.png)
## Creating a Web App in Azure Portal to deploy [YourAppName].Blazor project
* Login into [Azure Portal](https://portal.azure.com/)
* Click **Create a resource**
* Search for *Web App* in the *Search the Marketplace* field
* Click the **Create** button in the *Web App* window
* Select *rg[YourAppName]* in the *Resource Group* dropdown
* Enter *[YourAppName]Blazor* in the *Name* input field
* Select *.NET Core 3.1 (LTS)* in the *Runtime stack* dropdown
* Select *Windows* as *Operating System*
* Select the same region as the SQL server you created in Part 3
* Select the [YourAppName]ApiWinPlan in the *Windows Plan* dropdown
![azdevops-14](images/azdevops-14.png)
* Click the **Review + create** button. Click **Create** button
* Click **Go to resource** when the Web App has been created
* Copy the URL of the Blazor Web App for later use
```
https://[YourAppName]blazor.azurewebsites.net
```
## Changing the Web App configuration for the Azure App Service
Copy the URL of the Api Host and Blazor Web App. Change appsettings.json files in the Web App as follows images.
![azdevops-19](images/azdevops-19.png)
![azdevops-20](images/azdevops-20.png)
![azdevops-21](images/azdevops-21.png)
## Adding an extra Stage in the Release pipeline in the AzureDevops to deploy [YourAppName].Blazor project
* Go to the *Release* pipeline in [Azure DevOps](https://azure.microsoft.com/en-us/services/devops/) and click **Edit**
* Click the **+ Add** link and add a **New Stage**
![azdevops-15](images/azdevops-15.png)
* Select *Azure App Service deployment* and click the **Apply** button
* Enter *BlazorDeployment* in the *Stage name* input field and close the *Stage* window
* Click the **little red circle with the exclamation mark** in the BlazorDeployment stage
* Select your subscription in the *Azure subscription* dropdown
* Select your Blazor Web App in the *App service name* dropdown
* Click the **Deploy Azure App Service task**
* Select *[YourAppName].Blazor.zip* in the *Package or folder* input field
![azdevops-16](images/azdevops-16.png)
* Click **Save** in the top menu and click the **OK** button after
* Click **Create release** in the top menu and click the **Create** button
![azdevops-17](images/azdevops-17.png)
![azdevops-22](images/azdevops-22.png)

@ -141,13 +141,14 @@ Configure<AbpRabbitMqOptions>(options =>
});
````
**Example: Configure the client and exchange names**
**Example: Configure the client, exchange names and prefetchCount**
````csharp
Configure<AbpRabbitMqEventBusOptions>(options =>
{
options.ClientName = "TestApp1";
options.ExchangeName = "TestMessages";
options.PrefetchCount = 1;
});
````

@ -0,0 +1,140 @@
# Empezando con ABP y una Aplicacion AspNet Core MVC Web
Este tutorial explica como empezar una aplicacion ABP desde cero usando las dependencias minimas. Uno generalmente desea
empezar con la **[plantilla de inicio](Getting-Started-AspNetCore-MVC-Template.md)**.
## Crea un Proyecto Nuevo
1. Crea una Aplicacion Web AspNet Core nueva usando Visual Studio 2022 (17.0.0+):
![](images/create-new-aspnet-core-application-v2.png)
2. Configura el nuevo proyecto:
![](images/select-empty-web-application-v2.png)
3. Presione el boton Create:
![create-aspnet-core-application](images/create-aspnet-core-application.png)
## Instale el paquete Volo.Abp.AspNetCore.Mvc
Volo.Abp.AspNetCore.Mvc es el paquete de integracion con AspNet Core MVC para ABP. Siendo asi, instalalo en su proyecto:
````
Install-Package Volo.Abp.AspNetCore.Mvc
````
## Crea el primer modulo ABP
ABP es un marco de referencia modular y require una clase de **inicio (raíz) tipo modulo** derivada de ``AbpModule``:
````C#
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Hosting;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Modularity;
namespace BasicAspNetCoreApplication
{
[DependsOn(typeof(AbpAspNetCoreMvcModule))]
public class AppModule : AbpModule
{
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
// Configura la canalización de peticiones HTTP.
if (env.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// El valor por defecto de HSTS es 30 dias. Debes cambiar esto en ambientes productivos. Referencia https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseConfiguredEndpoints();
}
}
}
````
``AppModule`` es un buen nombre para el modulo de inicio de una aplicacion.
Los paquetes de ABP definen clases de tipo modulo y cada modulo puede depender de otro.
En el codigo anterior, el ``AppModule`` depende de el modulo ``AbpAspNetCoreMvcModule`` (definido por el paquete [Volo.Abp.AspNetCore.Mvc](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc)). Es comun agregar el atributo ``DependsOn`` despues de instalar un paquete ABP nuevo.
En vez de la clase de inicion Startup, estamos configurando una canalizacion de ASP.NET Core en este modulo.
## La clase Program
El proximo paso es modificar la clase Program para integrate el sistema de modulos ABP:
````C#
using BasicAspNetCoreApplication;
var builder = WebApplication.CreateBuilder(args);
await builder.Services.AddApplicationAsync<AppModule>();
var app = builder.Build();
await app.InitializeApplicationAsync();
await app.RunAsync();
````
``builder.Services.AddApplicationAsync<AppModule>();`` Agrega todos los servicios definidos en todos los modulos empezando desde ``AppModule``.
``app.InitializeApplicationAsync()`` inicializa y empieza la aplicacion.
## Ejecutar la Aplicación
Es todo! Ejecuta la aplicación, debe funcionar como esperado.
## Uso de Autofac como Marco de Inyección de Dependencia
Mientras el sistema de Inyección de Dependencia de ASP.NET Core es suficiente para requerimientos basico, [Autofac](https://autofac.org/) proporciona características avanzadas como Inyección de Propiedades e Intercepcion de Metodos, los cuales son necesarios para que ABP pueda llevar a cabo funciones avanzadas.
El acto de remplazar el sistema DI de ASP.NET Core por Autofac e integrarlo con ABP es facil.
1. Instala el paquete [Volo.Abp.Autofac](https://www.nuget.org/packages/Volo.Abp.Autofac)
````
Install-Package Volo.Abp.Autofac
````
2. Agrega la dependencia sobre el modulo ``AbpAutofacModule``
````C#
[DependsOn(typeof(AbpAspNetCoreMvcModule))]
[DependsOn(typeof(AbpAutofacModule))] //Agrega la dependencia sobre el modulo ABP Autofac
public class AppModule : AbpModule
{
...
}
````
3. Actualiza `Program.cs` para que use Autofac:
````C#
using BasicAspNetCoreApplication;
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseAutofac(); //Agrega esta linea
await builder.Services.AddApplicationAsync<AppModule>();
var app = builder.Build();
await app.InitializeApplicationAsync();
await app.RunAsync();
````
## Codigo fuente
Obten el codigo fuente del ejemplo creado en este tutorial de [aqui](https://github.com/abpframework/abp-samples/tree/master/BasicAspNetCoreApplication).

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

@ -126,25 +126,31 @@ Configure<AbpRabbitMqOptions>(options =>
Configure<AbpRabbitMqBackgroundJobOptions>(options =>
{
options.DefaultQueueNamePrefix = "my_app_jobs.";
options.DefaultDelayedQueueNamePrefix = "my_app_jobs.delayed"
options.PrefetchCount = 1;
options.JobQueues[typeof(EmailSendingArgs)] =
new JobQueueConfiguration(
typeof(EmailSendingArgs),
queueName: "my_app_jobs.emails",
connectionName: "SecondConnection"
connectionName: "SecondConnection",
delayedQueueName:"my_app_jobs.emails.delayed"
);
});
```
- 这个示例将默认的队列名前缀设置为 `my_app_jobs.`,如果多个项目都使用的同一个 RabbitMQ 服务,设置不同的前缀可以避免执行其他项目的后台作业.
- 这个示例将默认的队列名前缀设置为 `my_app_jobs.`并且设置默认的延迟队列名为 `my_app_jobs.delayed`,如果多个项目都使用的同一个 RabbitMQ 服务,设置不同的前缀可以避免执行其他项目的后台作业.
- 设置了预取数量, 用于所有队列.
- 这里还设置了 `EmailSendingArgs` 绑定的 RabbitMQ 连接.
`JobQueueConfiguration` 类的构造函数中,还有一些其他的可选参数.
- `queueName`: 指定后台作业对应的队列名称(全名).
* `DelayedQueueName`: 指定后台延迟执行的作业对于的队列名称(全名).
- `connectionName`: 后台作业对应的 RabbitMQ 连接名称,默认是 `Default`.
- `durable`: 可选参数,默认为 `true`.
- `exclusive`: 可选参数,默认为 `false`.
- `autoDelete`: 可选参数,默认为 `false`.
* `PrefetchCount` (可选参数, 默认为: null)
如果你想要更多地了解 `durable`,`exclusive`,`autoDelete` 的用法,请阅读 RabbitMQ 提供的文档.

@ -141,13 +141,14 @@ Configure<AbpRabbitMqOptions>(options =>
});
````
**示例: 配置客户端和交换机名称**
**示例: 配置客户端,交换机名称和预取数量**
````csharp
Configure<AbpRabbitMqEventBusOptions>(options =>
{
options.ClientName = "TestApp1";
options.ExchangeName = "TestMessages";
options.PrefetchCount = 1;
});
````

@ -409,6 +409,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.RemoteServices", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.PlugIn", "test\Volo.Abp.AspNetCore.Mvc.PlugIn\Volo.Abp.AspNetCore.Mvc.PlugIn.csproj", "{C6D6D878-208A-4FD2-822E-365545D8681B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Dapr", "src\Volo.Abp.Dapr\Volo.Abp.Dapr.csproj", "{192A829F-D608-4E41-8DE0-058E943E453F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.EventBus.Dapr", "src\Volo.Abp.EventBus.Dapr\Volo.Abp.EventBus.Dapr.csproj", "{DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Http.Client.Dapr", "src\Volo.Abp.Http.Client.Dapr\Volo.Abp.Http.Client.Dapr.csproj", "{18B796D2-D45D-41AE-9A42-75C9B14B20DF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.Dapr", "src\Volo.Abp.AspNetCore.Mvc.Dapr\Volo.Abp.AspNetCore.Mvc.Dapr.csproj", "{5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.Dapr.EventBus", "src\Volo.Abp.AspNetCore.Mvc.Dapr.EventBus\Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj", "{B02EF042-C39E-45C4-A92D-BF7554E1889D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.DistributedLocking.Dapr", "src\Volo.Abp.DistributedLocking.Dapr\Volo.Abp.DistributedLocking.Dapr.csproj", "{CAE48068-233C-47A9-BEAB-DDF521730E7A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -1219,6 +1231,30 @@ Global
{C6D6D878-208A-4FD2-822E-365545D8681B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6D6D878-208A-4FD2-822E-365545D8681B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6D6D878-208A-4FD2-822E-365545D8681B}.Release|Any CPU.Build.0 = Release|Any CPU
{192A829F-D608-4E41-8DE0-058E943E453F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{192A829F-D608-4E41-8DE0-058E943E453F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{192A829F-D608-4E41-8DE0-058E943E453F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{192A829F-D608-4E41-8DE0-058E943E453F}.Release|Any CPU.Build.0 = Release|Any CPU
{DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Release|Any CPU.Build.0 = Release|Any CPU
{18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Release|Any CPU.Build.0 = Release|Any CPU
{5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Release|Any CPU.Build.0 = Release|Any CPU
{B02EF042-C39E-45C4-A92D-BF7554E1889D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B02EF042-C39E-45C4-A92D-BF7554E1889D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B02EF042-C39E-45C4-A92D-BF7554E1889D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B02EF042-C39E-45C4-A92D-BF7554E1889D}.Release|Any CPU.Build.0 = Release|Any CPU
{CAE48068-233C-47A9-BEAB-DDF521730E7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CAE48068-233C-47A9-BEAB-DDF521730E7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CAE48068-233C-47A9-BEAB-DDF521730E7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CAE48068-233C-47A9-BEAB-DDF521730E7A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1425,6 +1461,12 @@ Global
{3683340D-92F5-4B14-B77B-34A163333309} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{EDFFDA74-090D-439C-A58D-06CCF86D4423} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{C6D6D878-208A-4FD2-822E-365545D8681B} = {447C8A77-E5F0-4538-8687-7383196D04EA}
{192A829F-D608-4E41-8DE0-058E943E453F} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{DCC41E99-EBC7-4F19-BA0D-A6F770D8E431} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{18B796D2-D45D-41AE-9A42-75C9B14B20DF} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{B02EF042-C39E-45C4-A92D-BF7554E1889D} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{CAE48068-233C-47A9-BEAB-DDF521730E7A} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5}

@ -3,16 +3,17 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars;
public class PageToolbarManager : IPageToolbarManager, ITransientDependency
{
protected IHybridServiceScopeFactory ServiceScopeFactory { get; }
protected IServiceScopeFactory ServiceScopeFactory { get; }
public PageToolbarManager(
IHybridServiceScopeFactory serviceScopeFactory)
IServiceScopeFactory serviceScopeFactory)
{
ServiceScopeFactory = serviceScopeFactory;
}

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.Dapr\Volo.Abp.AspNetCore.Mvc.Dapr.csproj" />
<ProjectReference Include="..\Volo.Abp.EventBus.Dapr\Volo.Abp.EventBus.Dapr.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,29 @@
using Microsoft.AspNetCore.Http.Json;
using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.SystemTextJson;
using Volo.Abp.EventBus.Dapr;
using Volo.Abp.Json.SystemTextJson;
using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus;
[DependsOn(
typeof(AbpAspNetCoreMvcDaprModule),
typeof(AbpEventBusDaprModule)
)]
public class AbpAspNetCoreMvcDaprEventBusModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
// TODO: Add NewtonsoftJson json converter.
Configure<JsonOptions>(options =>
{
options.SerializerOptions.Converters.Add(new AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter());
});
Configure<AbpSystemTextJsonSerializerOptions>(options =>
{
options.JsonSerializerOptions.Converters.Add(new AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter());
});
}
}

@ -0,0 +1,11 @@
namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus;
public class AbpAspNetCoreMvcDaprEventBusOptions
{
public List<IAbpAspNetCoreMvcDaprPubSubProviderContributor> Contributors { get; }
public AbpAspNetCoreMvcDaprEventBusOptions()
{
Contributors = new List<IAbpAspNetCoreMvcDaprPubSubProviderContributor>();
}
}

@ -0,0 +1,8 @@
namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus;
public class AbpAspNetCoreMvcDaprPubSubConsts
{
public const string DaprSubscribeUrl = "dapr/subscribe";
public const string DaprEventCallbackUrl = "api/abp/dapr/event";
}

@ -0,0 +1,63 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus;
using Volo.Abp.EventBus.Dapr;
using Volo.Abp.EventBus.Distributed;
namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus;
public class AbpAspNetCoreMvcDaprPubSubProvider : ITransientDependency
{
protected IServiceProvider ServiceProvider { get; }
protected AbpAspNetCoreMvcDaprEventBusOptions AspNetCoreMvcDaprEventBusOptions { get; }
protected AbpDaprEventBusOptions DaprEventBusOptions { get; }
protected AbpDistributedEventBusOptions DistributedEventBusOptions { get; }
public AbpAspNetCoreMvcDaprPubSubProvider(
IServiceProvider serviceProvider,
IOptions<AbpAspNetCoreMvcDaprEventBusOptions> aspNetCoreDaprEventBusOptions,
IOptions<AbpDaprEventBusOptions> daprEventBusOptions,
IOptions<AbpDistributedEventBusOptions> distributedEventBusOptions)
{
ServiceProvider = serviceProvider;
AspNetCoreMvcDaprEventBusOptions = aspNetCoreDaprEventBusOptions.Value;
DaprEventBusOptions = daprEventBusOptions.Value;
DistributedEventBusOptions = distributedEventBusOptions.Value;
}
public virtual async Task<List<AbpAspNetCoreMvcDaprSubscriptionDefinition>> GetSubscriptionsAsync()
{
var subscriptions = new List<AbpAspNetCoreMvcDaprSubscriptionDefinition>();
foreach (var handler in DistributedEventBusOptions.Handlers)
{
foreach (var @interface in handler.GetInterfaces().Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IDistributedEventHandler<>)))
{
var eventType = @interface.GetGenericArguments()[0];
var eventName = EventNameAttribute.GetNameOrDefault(eventType);
subscriptions.Add(new AbpAspNetCoreMvcDaprSubscriptionDefinition()
{
PubSubName = DaprEventBusOptions.PubSubName,
Topic = eventName,
Route = AbpAspNetCoreMvcDaprPubSubConsts.DaprEventCallbackUrl
});
}
}
if (AspNetCoreMvcDaprEventBusOptions.Contributors.Any())
{
using (var scope = ServiceProvider.CreateScope())
{
var context = new AbpAspNetCoreMvcDaprPubSubProviderContributorContext(scope.ServiceProvider, subscriptions);
foreach (var contributor in AspNetCoreMvcDaprEventBusOptions.Contributors)
{
await contributor.ContributeAsync(context);
}
}
}
return subscriptions;
}
}

@ -0,0 +1,16 @@
using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models;
namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus;
public class AbpAspNetCoreMvcDaprPubSubProviderContributorContext
{
public IServiceProvider ServiceProvider { get; }
public List<AbpAspNetCoreMvcDaprSubscriptionDefinition> Subscriptions { get; }
public AbpAspNetCoreMvcDaprPubSubProviderContributorContext(IServiceProvider serviceProvider, List<AbpAspNetCoreMvcDaprSubscriptionDefinition> daprSubscriptionModels)
{
ServiceProvider = serviceProvider;
Subscriptions = daprSubscriptionModels;
}
}

@ -0,0 +1,36 @@
using System.Text.Json;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models;
using Volo.Abp.Dapr;
using Volo.Abp.EventBus.Dapr;
namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Controllers;
[Area("abp")]
[RemoteService(Name = "abp")]
public class AbpAspNetCoreMvcDaprPubSubController : AbpController
{
[HttpGet(AbpAspNetCoreMvcDaprPubSubConsts.DaprSubscribeUrl)]
public virtual async Task<List<AbpAspNetCoreMvcDaprSubscriptionDefinition>> SubscribeAsync()
{
return await HttpContext.RequestServices.GetRequiredService<AbpAspNetCoreMvcDaprPubSubProvider>().GetSubscriptionsAsync();
}
[HttpPost(AbpAspNetCoreMvcDaprPubSubConsts.DaprEventCallbackUrl)]
public virtual async Task<IActionResult> EventsAsync()
{
var bodyJsonDocument = await JsonDocument.ParseAsync(HttpContext.Request.Body);
var request = JsonSerializer.Deserialize<AbpAspNetCoreMvcDaprSubscriptionRequest>(bodyJsonDocument.RootElement.GetRawText(),
HttpContext.RequestServices.GetRequiredService<IOptions<JsonOptions>>().Value.JsonSerializerOptions);
var distributedEventBus = HttpContext.RequestServices.GetRequiredService<DaprDistributedEventBus>();
var daprSerializer = HttpContext.RequestServices.GetRequiredService<IDaprSerializer>();
var eventData = daprSerializer.Deserialize(bodyJsonDocument.RootElement.GetProperty("data").GetRawText(), distributedEventBus.GetEventType(request.Topic));
await distributedEventBus.TriggerHandlersAsync(distributedEventBus.GetEventType(request.Topic), eventData);
return Ok();
}
}

@ -0,0 +1,6 @@
namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus;
public interface IAbpAspNetCoreMvcDaprPubSubProviderContributor
{
Task ContributeAsync(AbpAspNetCoreMvcDaprPubSubProviderContributorContext context);
}

@ -0,0 +1,10 @@
namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models;
public class AbpAspNetCoreMvcDaprSubscriptionDefinition
{
public string PubSubName { get; set; }
public string Topic { get; set; }
public string Route { get; set; }
}

@ -0,0 +1,8 @@
namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models;
public class AbpAspNetCoreMvcDaprSubscriptionRequest
{
public string PubSubName { get; set; }
public string Topic { get; set; }
}

@ -0,0 +1,11 @@
using System.Text.Json;
namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.SystemTextJson;
public class AbpAspNetCoreMvcDaprPubSubJsonNamingPolicy : JsonNamingPolicy
{
public override string ConvertName(string name)
{
return name.ToLower();
}
}

@ -0,0 +1,25 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models;
namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.SystemTextJson;
public class AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter : JsonConverter<AbpAspNetCoreMvcDaprSubscriptionDefinition>
{
private JsonSerializerOptions _writeJsonSerializerOptions;
public override AbpAspNetCoreMvcDaprSubscriptionDefinition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
throw new NotSupportedException();
}
public override void Write(Utf8JsonWriter writer, AbpAspNetCoreMvcDaprSubscriptionDefinition value, JsonSerializerOptions options)
{
_writeJsonSerializerOptions ??= JsonSerializerOptionsHelper.Create(new JsonSerializerOptions(options)
{
PropertyNamingPolicy = new AbpAspNetCoreMvcDaprPubSubJsonNamingPolicy()
}, x => x == this);
JsonSerializer.Serialize(writer, value, _writeJsonSerializerOptions);
}
}

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" />
<ProjectReference Include="..\Volo.Abp.Dapr\Volo.Abp.Dapr.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Dapr.AspNetCore" Version="1.8.0" />
</ItemGroup>
</Project>

@ -0,0 +1,13 @@
using Volo.Abp.Dapr;
using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Mvc.Dapr;
[DependsOn(
typeof(AbpAspNetCoreMvcModule),
typeof(AbpDaprModule)
)]
public class AbpAspNetCoreMvcDaprModule : AbpModule
{
}

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
@ -10,11 +11,11 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars;
public class PageToolbarManager : IPageToolbarManager, ITransientDependency
{
protected AbpPageToolbarOptions Options { get; }
protected IHybridServiceScopeFactory ServiceScopeFactory { get; }
protected IServiceScopeFactory ServiceScopeFactory { get; }
public PageToolbarManager(
IOptions<AbpPageToolbarOptions> options,
IHybridServiceScopeFactory serviceScopeFactory)
IServiceScopeFactory serviceScopeFactory)
{
Options = options.Value;
ServiceScopeFactory = serviceScopeFactory;

@ -9,7 +9,7 @@ public static class AbpHostingEnvironmentExtensions
this IWebHostEnvironment env,
AbpConfigurationBuilderOptions options = null)
{
options = options ?? new AbpConfigurationBuilderOptions();
options ??= new AbpConfigurationBuilderOptions();
if (options.BasePath.IsNullOrEmpty())
{

@ -1,52 +0,0 @@
using System;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.DependencyInjection;
[ExposeServices(
typeof(IHybridServiceScopeFactory),
typeof(HttpContextServiceScopeFactory)
)]
[Dependency(ReplaceServices = true)]
public class HttpContextServiceScopeFactory : IHybridServiceScopeFactory, ITransientDependency
{
protected IHttpContextAccessor HttpContextAccessor { get; }
protected IServiceScopeFactory ServiceScopeFactory { get; }
public HttpContextServiceScopeFactory(
IHttpContextAccessor httpContextAccessor,
IServiceScopeFactory serviceScopeFactory)
{
HttpContextAccessor = httpContextAccessor;
ServiceScopeFactory = serviceScopeFactory;
}
public virtual IServiceScope CreateScope()
{
var httpContext = HttpContextAccessor.HttpContext;
if (httpContext == null)
{
return ServiceScopeFactory.CreateScope();
}
return new NonDisposedHttpContextServiceScope(httpContext.RequestServices);
}
protected class NonDisposedHttpContextServiceScope : IServiceScope
{
public IServiceProvider ServiceProvider { get; }
public NonDisposedHttpContextServiceScope(IServiceProvider serviceProvider)
{
ServiceProvider = serviceProvider;
}
public void Dispose()
{
}
}
}

@ -10,7 +10,7 @@ public interface IDeletionAuditedObject : IHasDeletionTime
/// <summary>
/// Id of the deleter user.
/// </summary>
Guid? DeleterId { get; set; }
Guid? DeleterId { get; }
}
/// <summary>
@ -22,5 +22,5 @@ public interface IDeletionAuditedObject<TUser> : IDeletionAuditedObject
/// <summary>
/// Reference to the deleter user.
/// </summary>
TUser Deleter { get; set; }
TUser Deleter { get; }
}

@ -11,5 +11,5 @@ public interface IHasDeletionTime : ISoftDelete
/// <summary>
/// Deletion time.
/// </summary>
DateTime? DeletionTime { get; set; }
DateTime? DeletionTime { get; }
}

@ -10,5 +10,5 @@ public interface IHasModificationTime
/// <summary>
/// The last modified time for this entity.
/// </summary>
DateTime? LastModificationTime { get; set; }
DateTime? LastModificationTime { get; }
}

@ -10,7 +10,7 @@ public interface IModificationAuditedObject : IHasModificationTime
/// <summary>
/// Last modifier user for this entity.
/// </summary>
Guid? LastModifierId { get; set; }
Guid? LastModifierId { get; }
}
/// <summary>
@ -22,5 +22,5 @@ public interface IModificationAuditedObject<TUser> : IModificationAuditedObject
/// <summary>
/// Reference to the last modifier user of this entity.
/// </summary>
TUser LastModifier { get; set; }
TUser LastModifier { get; }
}

@ -99,7 +99,7 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
{
if (targetObject is IHasModificationTime objectWithModificationTime)
{
objectWithModificationTime.LastModificationTime = Clock.Now;
ObjectHelper.TrySetProperty(objectWithModificationTime, x => x.LastModificationTime, () => Clock.Now);
}
}
@ -112,7 +112,7 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
if (!CurrentUser.Id.HasValue)
{
modificationAuditedObject.LastModifierId = null;
ObjectHelper.TrySetProperty(modificationAuditedObject, x => x.LastModifierId, () => null);
return;
}
@ -120,7 +120,7 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
{
if (multiTenantEntity.TenantId != CurrentUser.TenantId)
{
modificationAuditedObject.LastModifierId = null;
ObjectHelper.TrySetProperty(modificationAuditedObject, x => x.LastModifierId, () => null);
return;
}
}
@ -134,7 +134,7 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
}
*/
modificationAuditedObject.LastModifierId = CurrentUser.Id;
ObjectHelper.TrySetProperty(modificationAuditedObject, x => x.LastModifierId, () => CurrentUser.Id);
}
protected virtual void SetDeletionTime(object targetObject)
@ -143,7 +143,7 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
{
if (objectWithDeletionTime.DeletionTime == null)
{
objectWithDeletionTime.DeletionTime = Clock.Now;
ObjectHelper.TrySetProperty(objectWithDeletionTime, x => x.DeletionTime, () => Clock.Now);
}
}
}
@ -162,7 +162,7 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
if (!CurrentUser.Id.HasValue)
{
deletionAuditedObject.DeleterId = null;
ObjectHelper.TrySetProperty(deletionAuditedObject, x => x.DeleterId, () => null);
return;
}
@ -170,11 +170,11 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
{
if (multiTenantEntity.TenantId != CurrentUser.TenantId)
{
deletionAuditedObject.DeleterId = null;
ObjectHelper.TrySetProperty(deletionAuditedObject, x => x.DeleterId, () => null);
return;
}
}
deletionAuditedObject.DeleterId = CurrentUser.Id;
ObjectHelper.TrySetProperty(deletionAuditedObject, x => x.DeleterId, () => CurrentUser.Id);
}
}

@ -19,6 +19,8 @@ public class AbpRabbitMqBackgroundJobOptions
/// Default value: "AbpBackgroundJobsDelayed."
/// </summary>
public string DefaultDelayedQueueNamePrefix { get; set; }
public ushort? PrefetchCount { get; set; }
public AbpRabbitMqBackgroundJobOptions()
{

@ -66,7 +66,8 @@ public class JobQueue<TArgs> : IJobQueue<TArgs>
new JobQueueConfiguration(
typeof(TArgs),
AbpRabbitMqBackgroundJobOptions.DefaultQueueNamePrefix + JobConfiguration.JobName,
AbpRabbitMqBackgroundJobOptions.DefaultDelayedQueueNamePrefix + JobConfiguration.JobName
AbpRabbitMqBackgroundJobOptions.DefaultDelayedQueueNamePrefix + JobConfiguration.JobName,
prefetchCount: AbpRabbitMqBackgroundJobOptions.PrefetchCount
);
}
@ -140,9 +141,14 @@ public class JobQueue<TArgs> : IJobQueue<TArgs>
if (AbpBackgroundJobOptions.IsJobExecutionEnabled)
{
if (QueueConfiguration.PrefetchCount.HasValue)
{
ChannelAccessor.Channel.BasicQos(0, QueueConfiguration.PrefetchCount.Value, false);
}
Consumer = new AsyncEventingBasicConsumer(ChannelAccessor.Channel);
Consumer.Received += MessageReceived;
//TODO: What BasicConsume returns?
ChannelAccessor.Channel.BasicConsume(
queue: QueueConfiguration.QueueName,

@ -20,12 +20,14 @@ public class JobQueueConfiguration : QueueDeclareConfiguration
string connectionName = null,
bool durable = true,
bool exclusive = false,
bool autoDelete = false)
bool autoDelete = false,
ushort? prefetchCount = null)
: base(
queueName,
durable,
exclusive,
autoDelete)
autoDelete,
prefetchCount)
{
JobArgsType = jobArgsType;
ConnectionName = connectionName;

@ -15,18 +15,18 @@ namespace Volo.Abp.Caching.StackExchangeRedis;
[DisableConventionalRegistration]
public class AbpRedisCache : RedisCache, ICacheSupportsMultipleItems
{
protected static readonly string SetScript;
protected static readonly string AbsoluteExpirationKey;
protected static readonly string SlidingExpirationKey;
protected static readonly string DataKey;
protected static readonly long NotPresent;
private static readonly FieldInfo RedisDatabaseField;
private static readonly MethodInfo ConnectMethod;
private static readonly MethodInfo ConnectAsyncMethod;
private static readonly MethodInfo MapMetadataMethod;
private static readonly MethodInfo GetAbsoluteExpirationMethod;
private static readonly MethodInfo GetExpirationInSecondsMethod;
private readonly static FieldInfo SetScriptField;
private readonly static FieldInfo RedisDatabaseField;
private readonly static MethodInfo ConnectMethod;
private readonly static MethodInfo ConnectAsyncMethod;
private readonly static MethodInfo MapMetadataMethod;
private readonly static MethodInfo GetAbsoluteExpirationMethod;
private readonly static MethodInfo GetExpirationInSecondsMethod;
protected IDatabase RedisDatabase => GetRedisDatabase();
private IDatabase _redisDatabase;
@ -36,9 +36,11 @@ public class AbpRedisCache : RedisCache, ICacheSupportsMultipleItems
static AbpRedisCache()
{
var type = typeof(RedisCache);
RedisDatabaseField = type.GetField("_cache", BindingFlags.Instance | BindingFlags.NonPublic);
SetScriptField = type.GetField("_setScript", BindingFlags.Instance | BindingFlags.NonPublic);
ConnectMethod = type.GetMethod("Connect", BindingFlags.Instance | BindingFlags.NonPublic);
ConnectAsyncMethod = type.GetMethod("ConnectAsync", BindingFlags.Instance | BindingFlags.NonPublic);
@ -51,9 +53,6 @@ public class AbpRedisCache : RedisCache, ICacheSupportsMultipleItems
GetExpirationInSecondsMethod =
type.GetMethod("GetExpirationInSeconds", BindingFlags.Static | BindingFlags.NonPublic);
SetScript = type.GetField("SetScript", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null)
.ToString();
AbsoluteExpirationKey = type.GetField("AbsoluteExpirationKey", BindingFlags.Static | BindingFlags.NonPublic)
?.GetValue(null).ToString();
@ -83,14 +82,14 @@ public class AbpRedisCache : RedisCache, ICacheSupportsMultipleItems
ConnectMethod.Invoke(this, Array.Empty<object>());
}
protected virtual Task ConnectAsync(CancellationToken token = default)
protected virtual async Task ConnectAsync(CancellationToken token = default)
{
if (GetRedisDatabase() != null)
{
return Task.CompletedTask;
return;
}
return (Task)ConnectAsyncMethod.Invoke(this, new object[] { token });
await (Task)ConnectAsyncMethod.Invoke(this, new object[] { token });
}
public byte[][] GetMany(
@ -283,7 +282,7 @@ public class AbpRedisCache : RedisCache, ICacheSupportsMultipleItems
for (var i = 0; i < itemArray.Length; i++)
{
tasks[i] = RedisDatabase.ScriptEvaluateAsync(SetScript, new RedisKey[] { Instance + itemArray[i].Key },
tasks[i] = RedisDatabase.ScriptEvaluateAsync(GetSetScript(), new RedisKey[] { Instance + itemArray[i].Key },
new RedisValue[]
{
absoluteExpiration?.Ticks ?? NotPresent,
@ -333,4 +332,9 @@ public class AbpRedisCache : RedisCache, ICacheSupportsMultipleItems
return _redisDatabase;
}
private string GetSetScript()
{
return SetScriptField?.GetValue(this).ToString();
}
}

@ -16,6 +16,8 @@ public class AbpCliOptions
/// Default value: "CLI".
/// </summary>
public string ToolName { get; set; } = "CLI";
public bool AlwaysHideExternalCommandOutput { get; set; }
public AbpCliOptions()
{

@ -1,4 +1,5 @@
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Volo.Abp.Cli.ServiceProxying;
using Volo.Abp.DependencyInjection;
@ -13,7 +14,7 @@ public class GenerateProxyCommand : ProxyCommandBase<GenerateProxyCommand>
public GenerateProxyCommand(
IOptions<AbpCliServiceProxyOptions> serviceProxyOptions,
IHybridServiceScopeFactory serviceScopeFactory)
IServiceScopeFactory serviceScopeFactory)
: base(serviceProxyOptions, serviceScopeFactory)
{
}

@ -2,6 +2,7 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
@ -19,11 +20,11 @@ public abstract class ProxyCommandBase<T> : IConsoleCommand, ITransientDependenc
protected AbpCliServiceProxyOptions ServiceProxyOptions { get; }
protected IHybridServiceScopeFactory ServiceScopeFactory { get; }
protected IServiceScopeFactory ServiceScopeFactory { get; }
public ProxyCommandBase(
IOptions<AbpCliServiceProxyOptions> serviceProxyOptions,
IHybridServiceScopeFactory serviceScopeFactory)
IServiceScopeFactory serviceScopeFactory)
{
ServiceScopeFactory = serviceScopeFactory;
ServiceProxyOptions = serviceProxyOptions.Value;

@ -1,4 +1,5 @@
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Volo.Abp.Cli.ServiceProxying;
using Volo.Abp.DependencyInjection;
@ -13,7 +14,7 @@ public class RemoveProxyCommand : ProxyCommandBase<RemoveProxyCommand>
public RemoveProxyCommand(
IOptions<AbpCliServiceProxyOptions> serviceProxyOptions,
IHybridServiceScopeFactory serviceScopeFactory)
IServiceScopeFactory serviceScopeFactory)
: base(serviceProxyOptions, serviceScopeFactory)
{
}

@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Cli.Utils;
@ -10,6 +11,13 @@ public class CmdHelper : ICmdHelper, ITransientDependency
{
private const int SuccessfulExitCode = 0;
protected AbpCliOptions CliOptions { get; }
public CmdHelper(IOptionsSnapshot<AbpCliOptions> cliOptions)
{
CliOptions = cliOptions.Value;
}
public void OpenWebPage(string url)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@ -27,10 +35,15 @@ public class CmdHelper : ICmdHelper, ITransientDependency
}
}
public void Run(string file, string arguments)
{
var procStartInfo = new ProcessStartInfo(file, arguments);
if (CliOptions.AlwaysHideExternalCommandOutput)
{
HideNewCommandWindow(procStartInfo);
}
Process.Start(procStartInfo)?.WaitForExit();
}
@ -46,6 +59,11 @@ public class CmdHelper : ICmdHelper, ITransientDependency
GetArguments(command)
);
if (CliOptions.AlwaysHideExternalCommandOutput)
{
HideNewCommandWindow(procStartInfo);
}
if (!string.IsNullOrEmpty(workingDirectory))
{
procStartInfo.WorkingDirectory = workingDirectory;
@ -66,10 +84,14 @@ public class CmdHelper : ICmdHelper, ITransientDependency
GetArguments(command)
);
if (CliOptions.AlwaysHideExternalCommandOutput)
{
HideNewCommandWindow(procStartInfo);
}
if (!string.IsNullOrEmpty(workingDirectory))
{
procStartInfo.WorkingDirectory = workingDirectory;
procStartInfo.CreateNoWindow = false;
}
return Process.Start(procStartInfo);
@ -98,6 +120,7 @@ public class CmdHelper : ICmdHelper, ITransientDependency
Arguments = GetArguments(command),
UseShellExecute = false,
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardOutput = true,
RedirectStandardError = true
};
@ -137,6 +160,11 @@ public class CmdHelper : ICmdHelper, ITransientDependency
{
procStartInfo.WorkingDirectory = workingDirectory;
}
if (CliOptions.AlwaysHideExternalCommandOutput)
{
HideNewCommandWindow(procStartInfo);
}
Process.Start(procStartInfo);
Environment.Exit(0);
@ -178,4 +206,10 @@ public class CmdHelper : ICmdHelper, ITransientDependency
$"Framework: {System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription} | " +
$"Process Architecture{System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture}");
}
private void HideNewCommandWindow(ProcessStartInfo procStartInfo)
{
procStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
procStartInfo.CreateNoWindow = true;
}
}

@ -21,6 +21,16 @@ public class AbpConfigurationBuilderOptions
/// </summary>
public string FileName { get; set; } = "appsettings";
/// <summary>
/// Whether the file is optional, Default value: true.
/// </summary>
public bool Optional { get; set; } = true;
/// <summary>
/// Whether the configuration should be reloaded if the file changes, Default value: true.
/// </summary>
public bool ReloadOnChange { get; set; } = true;
/// <summary>
/// Environment name. Generally used "Development", "Staging" or "Production".
/// </summary>

@ -9,7 +9,7 @@ public static class ConfigurationHelper
AbpConfigurationBuilderOptions options = null,
Action<IConfigurationBuilder> builderAction = null)
{
options = options ?? new AbpConfigurationBuilderOptions();
options ??= new AbpConfigurationBuilderOptions();
if (options.BasePath.IsNullOrEmpty())
{
@ -18,11 +18,11 @@ public static class ConfigurationHelper
var builder = new ConfigurationBuilder()
.SetBasePath(options.BasePath)
.AddJsonFile(options.FileName + ".json", optional: true, reloadOnChange: true);
.AddJsonFile(options.FileName + ".json", optional: options.Optional, reloadOnChange: options.ReloadOnChange);
if (!options.EnvironmentName.IsNullOrEmpty())
{
builder = builder.AddJsonFile($"{options.FileName}.{options.EnvironmentName}.json", optional: true, reloadOnChange: true);
builder = builder.AddJsonFile($"{options.FileName}.{options.EnvironmentName}.json", optional: options.Optional, reloadOnChange: options.ReloadOnChange);
}
if (options.EnvironmentName == "Development")

@ -1,22 +0,0 @@
using Microsoft.Extensions.DependencyInjection;
namespace Volo.Abp.DependencyInjection;
[ExposeServices(
typeof(IHybridServiceScopeFactory),
typeof(DefaultServiceScopeFactory)
)]
public class DefaultServiceScopeFactory : IHybridServiceScopeFactory, ITransientDependency
{
protected IServiceScopeFactory Factory { get; }
public DefaultServiceScopeFactory(IServiceScopeFactory factory)
{
Factory = factory;
}
public IServiceScope CreateScope()
{
return Factory.CreateScope();
}
}

@ -1,8 +0,0 @@
using Microsoft.Extensions.DependencyInjection;
namespace Volo.Abp.DependencyInjection;
public interface IHybridServiceScopeFactory : IServiceScopeFactory
{
}

@ -9,7 +9,7 @@
public interface ISoftDelete
{
/// <summary>
/// Used to mark an Entity as 'Deleted'.
/// Used to mark an Entity as 'Deleted'.
/// </summary>
bool IsDeleted { get; set; }
bool IsDeleted { get; }
}

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.Json\Volo.Abp.Json.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Dapr.Client" Version="1.8.0" />
</ItemGroup>
</Project>

@ -0,0 +1,48 @@
using System.Collections.Concurrent;
using System.Text.Json;
using Dapr.Client;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Json.SystemTextJson;
namespace Volo.Abp.Dapr;
public class AbpDaprClientFactory : ITransientDependency
{
protected AbpDaprOptions Options { get; }
protected AbpSystemTextJsonSerializerOptions SystemTextJsonSerializerOptions { get; }
public AbpDaprClientFactory(
IOptions<AbpDaprOptions> options,
IOptions<AbpSystemTextJsonSerializerOptions> systemTextJsonSerializerOptions)
{
Options = options.Value;
SystemTextJsonSerializerOptions = systemTextJsonSerializerOptions.Value;
}
public virtual async Task<DaprClient> CreateAsync()
{
var builder = new DaprClientBuilder()
.UseJsonSerializationOptions(await CreateJsonSerializerOptions());
if (!Options.HttpEndpoint.IsNullOrWhiteSpace())
{
builder.UseHttpEndpoint(Options.HttpEndpoint);
}
if (!Options.GrpcEndpoint.IsNullOrWhiteSpace())
{
builder.UseGrpcEndpoint(Options.GrpcEndpoint);
}
return builder.Build();
}
private readonly static ConcurrentDictionary<string, JsonSerializerOptions> JsonSerializerOptionsCache = new ConcurrentDictionary<string, JsonSerializerOptions>();
protected virtual Task<JsonSerializerOptions> CreateJsonSerializerOptions()
{
return Task.FromResult(JsonSerializerOptionsCache.GetOrAdd(nameof(AbpDaprClientFactory),
_ => new JsonSerializerOptions(SystemTextJsonSerializerOptions.JsonSerializerOptions)));
}
}

@ -0,0 +1,15 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Json;
using Volo.Abp.Modularity;
namespace Volo.Abp.Dapr;
[DependsOn(typeof(AbpJsonModule))]
public class AbpDaprModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
Configure<AbpDaprOptions>(configuration.GetSection("Dapr"));
}
}

@ -0,0 +1,10 @@
namespace Volo.Abp.Dapr;
public class AbpDaprOptions
{
public string AppId { get; set; }
public string HttpEndpoint { get; set; }
public string GrpcEndpoint { get; set; }
}

@ -0,0 +1,16 @@
namespace Volo.Abp.Dapr;
public interface IDaprSerializer
{
byte[] Serialize(object obj);
object Deserialize(byte[] value, Type type);
T Deserialize<T>(byte[] value);
string SerializeToString(object obj);
object Deserialize(string value, Type type);
T Deserialize<T>(string value);
}

@ -0,0 +1,45 @@
using System.Text;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Json;
namespace Volo.Abp.Dapr;
public class Utf8JsonDaprSerializer : IDaprSerializer, ITransientDependency
{
private readonly IJsonSerializer _jsonSerializer;
public Utf8JsonDaprSerializer(IJsonSerializer jsonSerializer)
{
_jsonSerializer = jsonSerializer;
}
public byte[] Serialize(object obj)
{
return Encoding.UTF8.GetBytes(_jsonSerializer.Serialize(obj));
}
public object Deserialize(byte[] value, Type type)
{
return _jsonSerializer.Deserialize(type, Encoding.UTF8.GetString(value));
}
public T Deserialize<T>(byte[] value)
{
return _jsonSerializer.Deserialize<T>(Encoding.UTF8.GetString(value));
}
public string SerializeToString(object obj)
{
return _jsonSerializer.Serialize(obj);
}
public object Deserialize(string value, Type type)
{
return _jsonSerializer.Deserialize(type, value);
}
public T Deserialize<T>(string value)
{
return _jsonSerializer.Deserialize<T>(value);
}
}

@ -42,18 +42,6 @@ public class EntityChangeEventHelper : IEntityChangeEventHelper, ITransientDepen
Logger = NullLogger<EntityChangeEventHelper>.Instance;
}
public virtual void PublishEntityCreatingEvent(object entity)
{
TriggerEventWithEntity(
LocalEventBus,
#pragma warning disable 618
typeof(EntityCreatingEventData<>),
#pragma warning restore 618
entity,
entity
);
}
public virtual void PublishEntityCreatedEvent(object entity)
{
TriggerEventWithEntity(
@ -89,18 +77,6 @@ public class EntityChangeEventHelper : IEntityChangeEventHelper, ITransientDepen
);
}
public virtual void PublishEntityUpdatingEvent(object entity)
{
TriggerEventWithEntity(
LocalEventBus,
#pragma warning disable 618
typeof(EntityUpdatingEventData<>),
#pragma warning restore 618
entity,
entity
);
}
public virtual void PublishEntityUpdatedEvent(object entity)
{
TriggerEventWithEntity(
@ -125,18 +101,6 @@ public class EntityChangeEventHelper : IEntityChangeEventHelper, ITransientDepen
}
}
public virtual void PublishEntityDeletingEvent(object entity)
{
TriggerEventWithEntity(
LocalEventBus,
#pragma warning disable 618
typeof(EntityDeletingEventData<>),
#pragma warning restore 618
entity,
entity
);
}
public virtual void PublishEntityDeletedEvent(object entity)
{
TriggerEventWithEntity(

@ -1,23 +0,0 @@
using System;
namespace Volo.Abp.Domain.Entities.Events;
/// <summary>
/// Used to pass data for an event when an entity (<see cref="IEntity"/>) is being changed (creating, updating or deleting).
/// See <see cref="EntityCreatingEventData{TEntity}"/>, <see cref="EntityDeletingEventData{TEntity}"/> and <see cref="EntityUpdatingEventData{TEntity}"/> classes.
/// </summary>
/// <typeparam name="TEntity">Entity type</typeparam>
[Serializable]
[Obsolete("This event is no longer needed and identical to EntityChangedEventData. Please use EntityChangedEventData instead.")]
public class EntityChangingEventData<TEntity> : EntityEventData<TEntity>
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="entity">Changing entity in this event</param>
public EntityChangingEventData(TEntity entity)
: base(entity)
{
}
}

@ -1,22 +0,0 @@
using System;
namespace Volo.Abp.Domain.Entities.Events;
/// <summary>
/// This type of event is used to notify just before creation of an Entity.
/// </summary>
/// <typeparam name="TEntity">Entity type</typeparam>
[Serializable]
[Obsolete("This event is no longer needed and identical to EntityCreatedEventData. Please use EntityCreatedEventData instead.")]
public class EntityCreatingEventData<TEntity> : EntityChangingEventData<TEntity>
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="entity">The entity which is being created</param>
public EntityCreatingEventData(TEntity entity)
: base(entity)
{
}
}

@ -1,22 +0,0 @@
using System;
namespace Volo.Abp.Domain.Entities.Events;
/// <summary>
/// This type of event is used to notify just before deletion of an Entity.
/// </summary>
/// <typeparam name="TEntity">Entity type</typeparam>
[Serializable]
[Obsolete("This event is no longer needed and identical to EntityDeletedEventData. Please use EntityDeletedEventData instead.")]
public class EntityDeletingEventData<TEntity> : EntityChangingEventData<TEntity>
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="entity">The entity which is being deleted</param>
public EntityDeletingEventData(TEntity entity)
: base(entity)
{
}
}

@ -1,22 +0,0 @@
using System;
namespace Volo.Abp.Domain.Entities.Events;
/// <summary>
/// This type of event is used to notify just before update of an Entity.
/// </summary>
/// <typeparam name="TEntity">Entity type</typeparam>
[Serializable]
[Obsolete("This event is no longer needed and identical to EntityUpdatedEventData. Please use EntityUpdatedEventData instead.")]
public class EntityUpdatingEventData<TEntity> : EntityChangingEventData<TEntity>
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="entity">The entity which is being updated</param>
public EntityUpdatingEventData(TEntity entity)
: base(entity)
{
}
}

@ -5,12 +5,9 @@ namespace Volo.Abp.Domain.Entities.Events;
/// </summary>
public interface IEntityChangeEventHelper
{
void PublishEntityCreatingEvent(object entity);
void PublishEntityCreatedEvent(object entity);
void PublishEntityUpdatingEvent(object entity);
void PublishEntityUpdatedEvent(object entity);
void PublishEntityDeletingEvent(object entity);
void PublishEntityDeletedEvent(object entity);
}

@ -14,26 +14,14 @@ public class NullEntityChangeEventHelper : IEntityChangeEventHelper
{
}
public void PublishEntityCreatingEvent(object entity)
{
}
public void PublishEntityCreatedEvent(object entity)
{
}
public void PublishEntityUpdatingEvent(object entity)
{
}
public void PublishEntityUpdatedEvent(object entity)
{
}
public void PublishEntityDeletingEvent(object entity)
{
}
public void PublishEntityDeletedEvent(object entity)
{
}

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.Dapr\Volo.Abp.Dapr.csproj" />
<ProjectReference Include="..\Volo.Abp.DistributedLocking.Abstractions\Volo.Abp.DistributedLocking.Abstractions.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,13 @@
namespace Volo.Abp.DistributedLocking.Dapr;
public class AbpDistributedLockDaprOptions
{
public string StoreName { get; set; }
public TimeSpan DefaultTimeout { get; set; }
public AbpDistributedLockDaprOptions()
{
DefaultTimeout = TimeSpan.FromSeconds(30);
}
}

@ -0,0 +1,11 @@
using Volo.Abp.Dapr;
using Volo.Abp.Modularity;
namespace Volo.Abp.DistributedLocking.Dapr;
[DependsOn(
typeof(AbpDistributedLockingAbstractionsModule),
typeof(AbpDaprModule))]
public class AbpDistributedLockingDaprModule : AbpModule
{
}

@ -0,0 +1,50 @@
using Microsoft.Extensions.Options;
using Volo.Abp.Dapr;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.DistributedLocking.Dapr;
[Dependency(ReplaceServices = true)]
public class DaprAbpDistributedLock : IAbpDistributedLock, ITransientDependency
{
protected AbpDaprClientFactory DaprClientFactory { get; }
protected AbpDistributedLockDaprOptions DistributedLockDaprOptions { get; }
protected AbpDaprOptions DaprOptions { get; }
public DaprAbpDistributedLock(
AbpDaprClientFactory daprClientFactory,
IOptions<AbpDistributedLockDaprOptions> distributedLockDaprOptions,
IOptions<AbpDaprOptions> daprOptions)
{
DaprClientFactory = daprClientFactory;
DaprOptions = daprOptions.Value;
DistributedLockDaprOptions = distributedLockDaprOptions.Value;
}
public async Task<IAbpDistributedLockHandle> TryAcquireAsync(
string name,
TimeSpan timeout = default,
CancellationToken cancellationToken = default)
{
if (timeout == default)
{
timeout = DistributedLockDaprOptions.DefaultTimeout;
}
var daprClient = await DaprClientFactory.CreateAsync();
var lockResponse = await daprClient.Lock(
DistributedLockDaprOptions.StoreName,
name,
DaprOptions.AppId,
(int)timeout.TotalSeconds,
cancellationToken);
if (lockResponse == null || !lockResponse.Success)
{
return null;
}
return new DaprAbpDistributedLockHandle(lockResponse);
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save