Thursday, February 6, 2020

How to using AWSSDK.Extensions.NETCore.Setup

Nowadays from .net developer company want they have experience in .net core + AWS .So i am thinking to share my knowledge with my friends. I will show you demo how to Configuring the AWS SDK for .NET with .NET Core.
One of the biggest changes in .NET Core is the removal of ConfigurationManager and the standard app.config and web.config files that were used with .NET Framework and ASP.NET applications.
Configuration in .NET Core is based on key-value pairs established by configuration providers. Configuration providers read configuration data into key-value pairs from a variety of configuration sources, including command-line arguments, directory files, environment variables, and settings files.
To make it easy to use the AWS SDK for .NET with .NET Core, you can use the AWSSDK.Extensions.NETCore.Setup NuGet package. Like many .NET Core libraries, it adds extension methods to the IConfiguration interface to make getting the AWS configuration seamless.

Using AWSSDK.Extensions.NETCore.Setup

When you create an ASP.NET Core MVC application in Visual Studio, the constructor for Startup.cs handles configuration by reading in various input sources from configuration providers, such as reading appsettings.json.
public Startup(IConfiguration configuration) { Configuration = configuration; }
To use the Configuration object to get the AWS options, first add the AWSSDK.Extensions.NETCore.Setup NuGet package. Then, add your options to the configuration file. Notice one of the files added to the ConfigurationBuilder is called $"appsettings.{env.EnvironmentName}.json". If you look at the Debug tab in your project’s properties, you can see this file is set to Development. This works great for local testing because you can put your configuration in the appsettings.Development.json file, which is read-only during local testing. When you deploy an Amazon EC2 instance that has EnvironmentName set to Production, this file is ignored and the AWS SDK for .NET falls back to the IAM credentials and region configured for the Amazon EC2 instance.
The following configuration settings show examples of the values you can add in the appsettings.Development.json file in your project to supply AWS settings.
{ "AWS": { "Profile": "local-test-profile", "Region": "us-west-2" }, "SupportEmail": "TechSupport@example.com" }
To access a setting in an CSHTML file, use the Configuration directive:
@using Microsoft.Extensions.Configuration @inject IConfiguration Configuration <h1>Contact</h1> <p> <strong>Support:</strong> <a href='mailto:@Configuration["SupportEmail"]'>@Configuration["SupportEmail"]</a><br /> </p>
To access the AWS options set in the file from code, call the GetAWSOptions extension method added on IConfiguration.
To construct a service client from these options, call CreateServiceClient. The following example code shows how to create an Amazon S3 service client.
var options = Configuration.GetAWSOptions(); IAmazonS3 client = options.CreateServiceClient<IAmazonS3>();
You can also create multiple service clients with incompatible settings using multiple entries in the appsettings.Development.json file, as shown in the following examples where the configuration for service1 includes the us-west-2 Region and the configuration for service2 includes the special endpoint URL.
{ "service1": { "Profile": "default", "Region": "us-west-2" }, "service2": { "Profile": "default", "ServiceURL": "URL" } }
You can then get the options for a specific service by using the entry in the JSON file. For example, to get the settings for service1:
var options = Configuration.GetAWSOptions("service1");


Thank you hope it is will help you.

  

Sunday, January 19, 2020

Query to list number of records in each table in a database

Hi Friend,

Using the below query you can get all rows, indexName, etc you can change the query according to your need.

SELECT 
    t.NAME AS TableName,
    i.name as indexName,
    p.[Rows],
    sum(a.total_pages) as TotalPages, 
    sum(a.used_pages) as UsedPages, 
    sum(a.data_pages) as DataPages,
    (sum(a.total_pages) * 8) / 1024 as TotalSpaceMB, 
    (sum(a.used_pages) * 8) / 1024 as UsedSpaceMB, 
    (sum(a.data_pages) * 8) / 1024 as DataSpaceMB
FROM 
    sys.tables t
INNER JOIN      
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN 
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN 
    sys.allocation_units a ON p.partition_id = a.container_id
WHERE 
    t.NAME NOT LIKE 'dt%' AND
    i.OBJECT_ID > 255 AND   
    i.index_id <= 1
GROUP BY 
    t.NAME, i.object_id, i.index_id, i.name, p.[Rows]
ORDER BY 
    object_name(i.object_id) 

If you want only table name and records then go with the below query.
SELECT t.NAME TableName, i.ROWS Records
FROM sysobjects t, sysindexes i
WHERE t.xtype = 'U' and i.id = t.id and i.indid in (0,1)
order by TableName;

The result areas above.

Thank you for your valuable time keep in touch.

Tuesday, January 14, 2020

vendor.bundle.js size is around 10 MB when we deployed angular 6 project.

Hi All,

when you are new in angular so this is the correct place for you here we will learn how to deploy our angular project.

1st used

ng build

ng build --prod --aot

ng build --prod --aot --vendor-chunk --common-chunk --delete-output-path --buildOptimizer


Thank you Hope it is useful for you.

wagah border (entertainment)

Hi Friend ,

Today i am upload videos from wagah boarder.




Tuesday, January 7, 2020

How to enable developer mode windows 10?

If you want to activate developer mode in window 10 you are in the correct place.

Let's start

Go to Windows Settings



When you click on settings the below window is open.

Click on the "update and security" tab the below screen see than click on "For developers" tab Than you can able to see all mode.
Thank you hope it helps you .

TypeScript: sleep a thread

Hi All,

Today i am stuck in one functionality so using the thread in typescript i a solve it so thing share Knowledge to all people.

Sometimes you see within the second your method code is executed and you not understand how to stop our method so the simple idea is to use thread.

If we need to sleep e thread, we can implements a delay method that returns a Promise object (which represents the eventual completion, or failure, of an asynchronous operation, and its resulting value) and through the setTimeout method (that sets a timer which executes a function or specified piece of code once after the timer expires) resolve the Promise.

private delay(ms: number)
{
  return new Promise(resolve => setTimeout(resolve, ms));
}


Now we can call the delay method where we need to sleep the thread. To call the delay function we have to use the keyword await, so we must declare the method where we will make the call as async.

async downloadMyFile(id: number) {
    this.isLoadingSpring = true;
    const link = document.createElement('a');
    link.setAttribute('target', '_blank');
    link.setAttribute('href', '/assets/files/' + id + '/Year-Book.pdf');
    await link.setAttribute('download', 'Year-Book.pdf');
    document.body.appendChild(link);
    link.click();
    link.remove();
    await this.delay(3000);
    this.isLoadingSpring = false;
  }


Thank you for your valuable time hope it will help you 

Sunday, December 29, 2019

angular installation guide

Hi All,

This is an installation guide of angular.
Before creating our first Angular app, first, we’ll see how to install Angular on a Windows system.

Step 1 - Install NodeJS
Follow the link - https://nodejs.org/en/download/
Download the node.js installer for Windows and install it.

To check the installed version of Node.js, open the command prompt.
Type the “npm -v” command to check the Node.js installation and version.

Step 2 - Install TypeScript
Open the link https://www.npmjs.com/package/typescript

Copy the above command “npm install -g typescript” and run it on command prompt.
Step 3 - Install Angular CLI (Angular command line interface)
Open the link https://cli.angular.io/ and follow the instructions to install Angular CLI and to create your first  Angular app.
1)Type the command “npm install -g @angular/cli” on the command prompt and press enter to install Angular cli.
2)Type “ng new hello-world” and hit enter to create the Hello World app.

Thank you,
Arjun Walmiki