083 Preparing the Lookup resource application to run - chempkovsky/CS82ANGULAR GitHub Wiki

Notes

  • Since, it's a demo project, we did not create separate WebApi app for the PhbkEmployeeView Lookup resource services, though it is highly recommended.
    • instead, we created a separate Dbcontext for the PhbkEmployeeView Lookup resource
    • instead, we created a separate consumer
    • instead, we will create a separate copy of the Service Bus in the LpPhBkWebApp-app with a separate section in the appsettings.json.
  • Having three "instead", it'll be very easy to migrate to the separate WebApi app for the PhbkEmployeeView Lookup resource services.
  • Detailed comments about configuration have already been made in the article 46
  • We do not describe step by step instructions in this article
    • the only information summary will be presented

Set up LpPhBkWebApp

appsettings json for LpPhBkWebApp

  • the following elements must be added to the appsettings.json file

    • connection string for the LpEmpPhBkContext dbcontext
    • PhbkEmployeeViewExtForLkUpConf-section to configure second instance of the Service Bus
  • We introduce ConnectionStrings:LpEmpPhBkConnection-item to configure LpEmpPhBkContext-DbContext

Click to show the code
  "ConnectionStrings": {
    "LpPhnPhBkConnection": "Data Source=SVR2016SQL2017;Initial Catalog=LpPhnPhBkDbDef;Persist Security Info=True;User ID=sa;Password=your_password_heer",
    "LpEmpPhBkConnection": "Data Source=SVR2016SQL2017;Initial Catalog=LpEmpPhBkDbDef;Persist Security Info=True;User ID=sa;Password=your_password_heer",
    "LpPhBkConnection": "Data Source=SVR2016SQL2017;Initial Catalog=LpPhBkDbDef;Persist Security Info=True;User ID=sa;Password=your_password_heer",
  },
  • open phbk-phone-view.extforlkup.interface.cs mentioned in the article 077. In the end of the file you will find the PhbkPhoneViewExtForLkUpConf-class along with the instructions on how to use it
Click to show the code
/*
  In appsettings.json it must be added the section like below.
  1. If a RabbitMq cluster is present:

  "PhbkPhoneViewExtForLkUpConf": {
    "HostName ": "192.168.100.3",
    "Username": "Admin",
    "Password": "Admin",
    "VirtualHostName": "phbkhost",
    "ClusterIpAddresses": [
      "192.168.100.4",
      "192.168.100.5",
      "192.168.100.6"
    ]
  }


  2. If a RabbitMq cluster is not present:

  "PhbkPhoneViewExtForLkUpConf": {
    "HostName ": "192.168.100.3",
    "Username": "Admin",
    "Password": "Admin",
    "VirtualHostName": "phbkhost",
    "ClusterIpAddresses": []
  }

  3. In the Program.cs file add the code like below:

  var builder = WebApplication.CreateBuilder(args);
  ...
  ConfigurationManager configuration = builder.Configuration;
   ...
  var myOptions = new PhbkPhoneViewExtForLkUpConf();
  configuration.GetSection(PhbkPhoneViewExtForLkUpConf.ConfName).Bind(myOptions);
   ...

*/

    public class PhbkPhoneViewExtForLkUpConf {
        public static string ConfName = "PhbkPhoneViewExtForLkUpConf";
        public string HostName { get; set; } = String.Empty;
        public string Username { get; set; } = String.Empty;
        public string Password { get; set; } = String.Empty;
        public string VirtualHostName { get; set; } = String.Empty;
        public string[] ClusterIpAddresses { get; set; } = null!;
    }
  • We will use the same RabbitMq server, Vhost, user as those desribed in the article 046. Thus, the PhbkPhoneViewExtForLkUpConf-section will be identical to the PhbkDivisionViewExtForLkUpConf-section.
Click to show the code
  "PhbkDivisionViewExtForLkUpConf": {
    "HostName": "192.168.100.3",
    "Username": "admin",
    "Password": "admin",
    "VirtualHostName": "phbkhost",
    "ClusterIpAddresses": []
  },
  "PhbkEmployeeViewExtForLkUpConf": {
    "HostName": "192.168.100.3",
    "Username": "admin",
    "Password": "admin",
    "VirtualHostName": "phbkhost",
    "ClusterIpAddresses": []
  },
  "PhbkPhoneViewExtForLkUpConf": {
    "HostName": "192.168.100.3",
    "Username": "admin",
    "Password": "admin",
    "VirtualHostName": "