Tuesday, September 22, 2020

How to integrate Angular 9 with an ASP.NET Core Project

The best article for updating angular to the latest version(yes it work and for Angular 10).

I had issue after update from Angular 8(from Microsoft template) to 9 and 10, by the way this issue with one string "ng serve --verbose"

Sometimes this brings more happiness:  ' "start": "echo Starting... && ng serve" '

Thursday, September 10, 2020

Steeltoe

I liked this project and the ideas it offers

    Steeltoe makes programming .NET quicker, easier, and safer for everybody. Steeltoe’s focus on speed, simplicity, and productivity has made it one of the world's most popular .NET frameworks.

    Steeltoe makes building web applications fast and hassle-free. By removing much of the boilerplate code and configuration associated with web development, you get a modern web programming model that streamlines the development of server-side HTML applications, REST APIs, and bidirectional, event-based systems. 

Steeltoe is proven
Steeltoe’s libraries are trusted by developers all over the world. Steeltoe delivers delightful experiences to millions of end-users every day. Steeltoe also has contributions from development teams at Microsoft, and more.
Steeltoe is flexible
Steeltoe’s flexible and comprehensive set of extensions and third-party libraries let developers build almost any web application imaginable. At its core, Steeltoe Framework’s features provide the foundation for a wide-ranging set of features and functionality. Whether you’re building secure, cloud-based microservices for the web, or complex streaming data flows for the enterprise, Steeltoe has the tools to help.
Steeltoe is productive
Steeltoe transforms how you approach .NET programming tasks, radically streamlining your experience. To go even faster, you can use Steeltoe with Spring Cloud’s rich set of supporting libraries, servers, patterns, and templates, to safely deploy entire microservices-based architectures into the cloud, in record time.
Steeltoe is fast
Developer productivity is one of Steeltoe’s superpowers. Steeltoe helps developers build applications with ease and with far less toil than other competing paradigms. You can even start a new Steeltoe project in seconds, with the Steeltoe Initializr at start.Steeltoe.io
Steeltoe is secure
Steeltoe has a proven track record of remediating security issues quickly and responsibly. The Steeltoe committers work with security professionals to patch and test any reported vulnerabilities. Third-party dependencies are also monitored closely, and regular updates are issued to help keep your data and applications as safe as possible. In addition, Steeltoe Security makes it easier for you to integrate with industry-standard security schemes and deliver trustworthy solutions that are secure by default.
Steeltoe is supportive
The Steeltoe community is global, diverse, and spans folks of all ages and capabilities, from complete beginners to seasoned pros. No matter where you are on your journey, you can find the support and resources you need to get you to the next level: quickstarts, guides & tutorials, videos, support, or even formal training and certification.

Secrets of a .NET Professional

Secrets of a .NET Professional 
Briefly on the topic
  1. The common language runtime conserves string storage by maintaining a table, called the intern pool, that contains a single reference to each unique literal string declared or created programmatically in your program.
  2. Reading more code makes us better developers.
  3. Nothing is free, and it always costs us something.
  4. Task.Awesome
  5. Learn LINQ
  6. Take It Easy On The Patterns
  7. One Project Is Fine*
  8. one good integration test is worth 1,000 unit tests
  9. Use Tools Other Than .NET
  10. A cohesive team with dated technology will outperform a dysfunctional team with the latest tech every time

Best way to create an empty collection (array and list) in C# (.NET)

very helpful article on initializing arrays and lists
For array will be the best - new TestArray[] { }
For list - new List()

Wednesday, April 15, 2020

Cool highlighter for many languages and tools

I like it

windows container in docker

One of my tasks is to run Windows containers in docker.
Also, need to manage IIS.
I took part of the code here

The Dockerfile install aspnet windows container with 4.6.2 (because I using old code in my projects), enable in container IIS remote management and binding 443 port with SSL certificate
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.6.2
ARG source
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN Install-WindowsFeature -Name Web-Mgmt-Service
RUN New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force
#RUN New-NetFirewallRule -Action Allow -Direction Inbound -DisplayName IISManagement -Service WMSVC
RUN set-service -Name WMSVC -StartupType Automatic
RUN Get-Service -Name WMSVC | Start-Service
RUN net user admin 6H%*!k0*/I /ADD
RUN net localgroup administrators admin /add
#RUN New-WebBinding -Name 'Default Web Site' -IP '*' -Port 443 -Protocol https
RUN $newCert=New-SelfSignedCertificate -DnsName 'localhost' -CertStoreLocation cert:\LocalMachine\My; \
  New-WebBinding -Name 'Default Web Site' -Protocol 'https'; \
  $binding=Get-WebBinding -Name 'Default Web Site' -Protocol 'https'; \
  $binding.AddSslCertificate($newCert.GetCertHashString(),'my')
EXPOSE 80 443
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .

Thursday, February 20, 2020

GitInfo. How using versioning from Git Tag and C# projects (frameworks and core)

In all big or small companies, you might be using versioning, I recommend using GitInfo, because it is a simple project that will help you be more advance.

A huge plus of GitInfo project is that besides the library itself you don’t need anything else


For dotnet core projects, I enable support Git and make the first commit and after I add Git Tag "0.1.0".

Then I add NuGet package "GitInfo"

Next step you need to add AssemblyInfo.cs, better to Properties folder

using System.Reflection;

[assembly: AssemblyVersion (ThisAssembly.Git.BaseVersion.Major + "." + ThisAssembly.Git.BaseVersion.Minor + "." + ThisAssembly.Git.BaseVersion.Patch)]

[assembly: AssemblyFileVersion (ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch)]

[assembly: AssemblyInformationalVersion (
    ThisAssembly.Git.SemVer.Major + "." + 
    ThisAssembly.Git.SemVer.Minor + "." + 
    ThisAssembly.Git.Commits + "-" + 
    ThisAssembly.Git.Branch + "+" + 
    ThisAssembly.Git.Commit)]




And last step change csproj, you need add 3 rows

<PropertyGroup>
        <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    </PropertyGroup>

After that, you can use GitInfo and versioning anywhere

Good luck!!!

Thursday, January 24, 2019

Dynamic ASP.NET Core Configurations 🗒️ With Consul KV

It's Very nice post about konsul.

Background

Usually, the configurations in .NET and .NET Core apps are stored in the configuration files, such as App.config and Web.config, or appsettings.json; however, all of them have some disadvantages.
hard-coded configuration files
difficult to manage
For example, if we need to frequently change the configuration files due to some reasons, how can we solve this problem? We cannot modify them one by one if there are lots of machines!

What we want is managing the configuration in one place, the "configuration center". Here are some awesome projects that can help us solve this problem, such as Apollo, Consul, etc.

And in this article, I will introduce three ways using Consul KV store.

Thursday, November 8, 2018

MSSQL search and replace value in all tables

It's little script for replace value in database


declare @from as nvarchar(50);
declare @to as nvarchar(50);

set @from  =[dbo].[getstringUUIDFromString] ('c3a5fb3e-745a-11e8-a209-0050568411f7'); 
set @to  =[dbo].[getstringUUIDFromString] ('c3a5fb3e-745a-11e8-a209-0050568411f7'); 



DECLARE @CURSOR CURSOR;DECLARE @script AS NVARCHAR(MAX);
SET @CURSOR = CURSOR SCROLL
FOR
 SELECT 
 '
 if exists (select top 1 * from  ['+isc.TABLE_CATALOG+'].['+isc.TABLE_SCHEMA+'].['+isc.TABLE_NAME+'] where '+isc.COLUMN_NAME + ' in ('+@from+'))
 begin
 print ''['+isc.TABLE_CATALOG+'].['+isc.TABLE_SCHEMA+'].['+isc.TABLE_NAME+']'';

 
 update ['+isc.TABLE_CATALOG+'].['+isc.TABLE_SCHEMA+'].['+isc.TABLE_NAME+']
 set '+isc.COLUMN_NAME + ' = '+@to+'
 where '+isc.COLUMN_NAME + ' in ('+@from+')
end;
 '
FROM information_schema.columns  isc
where  TABLE_CATALOG='DiachokERP' and TABLE_SCHEMA='dbo'
and data_type = 'binary' and CHARACTER_MAXIMUM_LENGTH=16

OPEN @CURSOR

FETCH NEXT
FROM @CURSOR
INTO @script
 

WHILE @@FETCH_STATUS = 0
BEGIN

 EXEC(@script);
 --print @script
 FETCH NEXT
 FROM @CURSOR
 INTO @script
END
CLOSE @CURSOR
DEALLOCATE @CURSOR;


and converting string from uid to uuid

CREATE function [dbo].[getstringUUIDFromString](@stringUUID as varchar(50))
returns nvarchar(50)
as
begin
--Возврат Сред(GUID, 20, 4) + Прав(GUID, 12) + Сред(GUID, 15, 4) + Сред(GUID, 10, 4) + Лев(GUID, 8);
declare @buffer nvarchar(50)
select @buffer ='0x'+ substring(@stringUUID,20,4)+right(@stringUUID,12)+substring(@stringUUID,15,4)+substring(@stringUUID,10,4)+left(@stringUUID,8)

return @buffer
end

GO

Saturday, October 13, 2018

add packages gdi plus to net core on macos

brew install mono-libgdiplus


I took it here

Sunday, September 2, 2018

Core install

install old drivers

pnputil.exe -i -a .\driversname.inf


install certs

Set-Location -Path Cert:\LocalMachine\Root\
Import-Certificate -FilePath "C:\install\FOR_SQL_1C\certnameshutdown -r.cer"

mount iso with show disk

Mount-DiskImage -ImagePath 'D:\ISO\Windows Server 2012 Trial\9200.16384.WIN8_RTM.120725-1247_X64FRE_SERVER_EVAL_EN-US-HRM_SSS_X64FREE_EN-US_DV5.ISO' -StorageType ISO -PassThru | Get-Volume


update SQL

.\setup.exe /Q /IACCEPTSQLSERVERLICENSETERMS /Action=Upgrade /InstanceName=MSSQLServer

update key(licence) SQL

.\setup.exe /q /ACTION=EditionUpgrade /INSTANCENAME=MSSQLSERVER /PID="insert your key" /IACCEPTSQLSERVERLICENSETERMS

Install patch

.\SQLServer2017-KB4464082-x64.exe /qs /IAcceptSQLServerLicenseTerms /Action=Patch /AllInstances

Sunday, August 5, 2018

Arduino

If You have next error in VS Code
"sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\preproc\ctags_target_for_gcc_minus_e.cpp: The system cannot find the path specified.
[Error] Exit with code=1"

information this https://github.com/Microsoft/vscode/issues/38985
you need change setting.json.
Set "output": "../build"


{
"sketch": "app.ino",
"board": "arduino:avr:leonardoeth",
"output": "../build"
}


and delete all folders in folder "build/sketch"