简体   繁体   English

C#MVC4应用程序的不同版本,一项

[英]C# MVC4 Different versions of the application, one entry

I hope some people can give me some advice / help me point in the right direction. 我希望有人能给我一些建议/帮助我指出正确的方向。 I develop a application. 我开发一个应用程序。 Application is written in c# and using MVC 4. The application is has multi-tenancy databases. 应用程序使用c#编写,并使用MVC 4编写。该应用程序具有多租户数据库。 So the information of customer A is in own database, not not accessable for customer B. Further is the membership stored in the customer database. 因此,客户A的信息在自己的数据库中,客户B不可访问。此外,成员身份存储在客户数据库中。 So the users of A are in database of A, and users of B are in database of B. 因此,A的用户位于A的数据库中,而B的用户位于B的数据库中。

The application will have sometimes pilots. 该应用程序有时会有试点。 In that case we have 2 versions. 在这种情况下,我们有2个版本。 For example: Version 1 contains customer A and B Version 2 contains customer C 例如:版本1包含客户A和B版本2包含客户C

What I want is something where I have one entry, but the pages are version specific. 我想要的东西只有一个条目,但是页面是特定于版本的。

My idea was to create a proxy or something which has knowlege that customer A and B are running version 1 and customer C running version 2. So when a user of customer A wants to login, he give his companynumber, username and password. 我的想法是创建一个代理或具有客户A和B正在运行版本1且客户C正在运行版本2的知识。因此,当客户A的用户要登录时,他会提供其公司编号,用户名和密码。 The proxy checks where the database of customer A is located and checks if username and password are valid. 代理检查客户A数据库的位置,并检查用户名和密码是否有效。

I dont want to send the user to a subdomain or something. 我不想将用户发送到子域或其他内容。 So the url stays: http://www.domain.com . 因此该网址保持不变: http : //www.domain.com (Can contain actions like domain.com/controller/action, but not something like http://customer-a.domain.com ) (可以包含domain.com/controller/action之类的操作,但不能包含http://customer-a.domain.com之类的操作

I hope some can give me some advice. 我希望有人能给我一些建议。 I tried with a console app and HttpListner but didnt work. 我尝试使用控制台应用程序和HttpListner,但没有用。 Examples would be appreciated. 例子将不胜感激。

Like they say there are nine ways to skin a cat. 就像他们说的那样,有九种方法可以给猫皮。 I would of course make use of entity framework and the repository design pattern to work around this problem. 我当然会利用实体框架和存储库设计模式来解决此问题。

I would do the following, 我会做以下事情,

  • Create the 2 .edmx files needed to access the databases using entity framework 使用实体框架创建访问数据库所需的2个.edmx文件
  • Implement the repository design pattern. 实现存储库设计模式。

You will for instance have a CustomerRepository that would contain the logic to retrieve the appropriate data from the correct database. 例如,您将拥有一个CustomerRepository,其中将包含从正确的数据库检索适当数据的逻辑。

Without any in depth knowledge of the applications business rules however it is difficult to provide you with a solution that will 100% suit your needs and you will unfortunately have to figure that out on your own. 但是,如果没有对应用程序业务规则的任何深入了解,很难为您提供一个100%满足您需求的解决方案,并且您将不得不自己解决这个问题。 But like you said, you just want someone to point you into a direction. 但是就像您说的那样,您只希望某人将您指向一个方向。

If you are unfamiliar with entity framework and the repository design pattern, here are some useful links you can use to read up on it, 如果您不熟悉实体框架和存储库设计模式,可以使用以下有用的链接进行阅读,

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

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