多租户ASP.net MVC

来源:互联网 发布:王者荣耀类似源码 编辑:程序博客网 时间:2024/04/28 20:09

确实如我们所接触的,使用asp.net的人,分享的内容复杂度,频度多不如开源型,例如java/php之类。那多租户mvc实现,在08或10年某位大牛。。http://codeofrob.com/  其实我很喜欢他写的介绍,很明显,this is a tech guy and enojoy life guy,我们看到切换的技术很多。

I'm Rob Ashton, a freelance software developer from Britain but currently operating in Belgium.

I like delivering, and I like helping teams deliver - I am often found leading technical teams on technical products, and spend a lot of my time mentoring and coaching teams to deliver more effective code.

I believe that the best code is code that can be maintained by others, I don't believe in black boxes, I don't believe in magic tricks and I think that the most direct route to a solution is often the best one.

I have contributed code to a number of OSS projects, most notably RavenDB but these days I focus my efforts on games development in Javascript - because it's fun. I like having fun.

然后我们看到另外一个家伙,总之就是认为自己提出的方案更好,并且是实际应用中实施了,那我想我还是看后人吧,一般巨人肩膀上的蚂蚁也比巨人高啊

http://weblogs.asp.net/zowens/archive/2010/05.aspx

 

This project is an example of multi-tenancy on ASP.NET MVC 2.0 using Visual Studio 2010. This sample utilizes the following utilities:- Visual Studio 2010- ASP.NET MVC 2.0- .NET 4.0- IIS7- StructureMap (lib folder)- xUnit.NET (lib folder)

 

https://github.com/zowens/Multi-tenancy-Sample就我个人认为,这个是值得一看的,anyway,使得文章血肉丰满一些,我们还是要努力学习的

a “tenant” to me is simply a client. This client has a few different attributes that are reflected in the model. Here’s the interface I use to describe a tenant. 租户是一个子系统的使用,子系统提供给它的用户使用。需要描述租户,从基本概念已经应用程序出租的概念:

public interface IApplicationTenant
{
    string ApplicationName { get; }
    IFeatureRegistry EnabledFeatures { get; }
    IEnumerable<string> UrlPaths { get; }
    IContainer DependencyContainer { get; }
    IViewEngine ViewEngine { get; }
}

看来学习Ioc DI是绝对需要提上日程了。

我们通过features列表,来控制是否可以看到/使用 app feature,设计上很简单,feature path,其实就是树形结构的功能节点。。。

a tenant has a list of features that are enabled by the tenant, called a feature registry. The feature registry is responsible for describing which features are enabled and which features the tenant is allowed to utilize. Here’s some relevant code for features:

 

在一个多层的系统中,什么才是租户,多租户系统是否必须提供一个包租婆管理的入口,如果提供入口是否应该是多租户的后台呢?

包租婆管理:

XXX.com/admin====

租户1的访问地址

site1.xxx.com===

如果租户一下面又是多租户的?Question?是多用户还是多租户?如何区分用户和租户(各自有自己的数据/配置--看起来)

难道我们应该提供如下的?

site1.xxx.com/subsite1 & site1.xxx.com/subsite2

三层结构下,方案一,一切为混合,例如租户的管理/租户下面的小租户管理,在整个系统中,看不出差别,也就是不通过URL来区分,层次关系。subsite1.xxx.com,我们通过账号一下子把二房东,租户给区分出来。

方案二,系统的多租户只针对二房东。但二房东如何管理,在自己的内部实现,也就是一个二房东,一套系统。

//无限深层次的菜单选项

public interface IComplexFeature : IFeature
{
    IEnumerable<IFeature> SubFeatures { get; }
}

 

 

 

 

 

原创粉丝点击