简体   繁体   English

内部网上的多租户或多实例应用程序

[英]multi tenant or multi instance application on intranet

I have an existing MVC app which will be utlized by another user group in the near future. 我有一个现有的MVC应用程序,不久以后将由另一个用户组使用。 Both the existing and new user group/program will have independant data. 现有用户组和新用户组/程序都将具有独立的数据。 I was just thinking to add flags in the tables to distinguish between the two user group/programs and do some routing when they access the application to pull up respective data. 我只是想在表中添加标志以区分两个用户组/程序,并在它们访问应用程序以提取各自的数据时进行一些路由。

Now when it comes to code customization, for instance one group/program wants to have extra fields on a page which the first group does not want or the process flow of the application is seperate between the two user groups. 现在,在代码自定义方面,例如,一个组/程序想要在页面上具有第一个组不需要的额外字段,或者应用程序的处理流程在两个用户组之间分开。

If the above two scenarios will occur frequently, should I just do a new web and database instance rather than customizing the code for each program/user group. 如果以上两种情况经常发生,我应该只是做一个新的Web和数据库实例,而不是为每个程序/用户组自定义代码。 This way both of my customers/user groups will have flexibility to add different logic/fields to the application. 这样,我的两个客户/用户组都可以灵活地向应用程序添加不同的逻辑/字段。

The only con I see with the non-multi tenant approach is the time effort by the developer to maintain two seperate applications. 我看到的非多租户方法的唯一弊端是开发人员花费时间来维护两个单独的应用程序。 I am scared of adding contional logic to customize the same code base for each different user group/program. 我害怕添加条件逻辑来为每个不同的用户组/程序自定义相同的代码库。 Cost of infrastructure is not an issue. 基础设施成本不是问题。 Also I do not forsee this application to be used by more than 2 user groups/programs at any time. 我也不希望这个应用程序在任何时候被两个以上的用户组/程序使用。 So what do you guys think which apporach i should take and why? 那么,你们认为我应该采取哪种方式,为什么呢? thanks all in advance 提前谢谢大家

PS The users arent any ninjas who will try to hack the site to see the other tenants data. PS用户没有忍者将试图破解该站点以查看其他租户数据。 They are corporate users. 他们是公司用户。 Theyd rather not use this application but its part of the process so they have to use it. 他们宁愿不使用此应用程序,而是使用过程的一部分,因此必须使用它。

It's worth taking a look at microsoft's article on multi-tenancy. 值得一看一下微软关于多租户的文章

I'm also working on trying to design an mvc app with such an architecture where each client can have separate fields and customised screens. 我也在努力设计一种具有这种架构的mvc应用程序,其中每个客户端可以具有单独的字段和自定义屏幕。

The conclusion that I have come to is that using an IOC container with multi-tenancy support will probably make the whole thing a lot easier. 我得出的结论是,使用具有多租户支持的IOC容器可能会使整个过程变得容易得多。

Autofac has built in multi-tenancy support . Autofac内置了多租户支持

In terms of having logic for clients in each view I believe that if you go down the IOC path you can have a controller for each tenant and in that case hard coding such client specific logic isn't necessarily as bad as it would be having it hard coded all into a shared controller. 关于在每个视图中为客户提供逻辑,我相信如果沿着IOC路径,您可以为每个租户拥有一个控制器,在这种情况下,硬编码此类特定于客户的逻辑并不一定要像拥有它那样糟糕全部硬编码到共享控制器中。 In essence I believe when writing a component that is for a particular tenant you can switch you mindset to writing as if that tenant was the only one using the system. 本质上,我相信当编写用于特定租户的组件时,您可以将思维方式切换为编写,就好像该租户是使用该系统的唯一租户一样。

The other solution I have landed in for customising views is to use a variation of the RazorGenerator approach for compiled views where I have each tenants views compiled into a separate assembly and have created my own view engine (based on this ) where I can swap out the assembly that I look for views in depending on a value in the routing parameters. 我采用的另一种用于自定义视图的解决方案是对已编译的视图使用RazorGenerator方法的一种变体,其中我将每个租户的视图编译到一个单独的程序集中,并创建了自己的视图引擎(基于 ),在这里我可以换出我要寻找的装配体,取决于布线参数中的值。

Of course I'm still exploring this approach and haven't fully flushed it out in order to find out where it may fall short. 当然,我仍在探索这种方法,并没有完全冲洗掉它以找出可能的不足之处。

If the difference in the 2 users' requirements is more than 10% of the screens/functionality then you better have 2 databases and apps. 如果两个用户需求的差异超过屏幕/功能的10%,则最好拥有两个数据库和应用程序。 If it is expected to be less than 10% then just write separate actions (possibly with different prefixes or suffixes in Action names) for where the functionality differs. 如果预计少于10%,则只需针对功能不同之处编写单独的操作(可能在操作名称中使用不同的前缀或后缀)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM