Coronavirus – What we are doing at SSW

This weekend I saw Coogee Beach packed to the rafters with parties. I also saw that The Oaks Hotel in Neutral Bay and The Coogee Bay Hotel were full of people who are either oblivious or stupid.
Note: Sadly, the Australian numbers are now much worse than below explained by this .gif:

2 weeks ago I spoke to each SSW office individually via Microsoft Teams and gave the following advice to all SSW employees to navigate Coronavirus. I am sharing this – I hope it helps:

From: Adam Cogan
Hi SSWAll,
The COVID-19 numbers are increasing every day – it is time to be worried and make some changes. Today NSW is the worst state at 171 cases (more numbers below).
Let’s focus on staying healthy for now. We can navigate the upcoming business challenges after that.
Stay home!
Over the next 8 weeks stay at home as your first option.  The incubation period for COVID-19 is around 2-8 days. The next 8 weeks are the most critical time for people to stay at home. Note: The average incubation period is 5.2 days. (Source: Prevention and control plan of new coronavirus pneumonia (fourth edition) issued by the National Health Commission of China).
Be safe!
There are going to be asymptomatic carriers – people who are infected, contagious, and don’t know it.
Practice social distancing over the next 8 weeks – by then you will know most of the people who became infected because they will be sick. (However, some people will have it, but show no or little symptoms). At this time, it will be easier to avoid infected people. Wait for them to get better and we can neutralize the spread of the virus. 
We won’t be as lucky as SSW China!
No-one in SSW China got the disease. And I think we can say it is under control in Hangzhou. Only 2 cases in the last 24 days in Hangzhou (pop. 13 million). But they were hardcore at their isolation. In Australia, the govt is softer and Aussies are more cavalier. She’ll be right mate!
This is going to be rough. Don’t go on public transport, drink at bars, eat at restaurants, work out at gyms, etc. You likely will contract the virus and the number of oblivious asymptomatic carriers will grow at a nasty rate. The best thing you can do is wash your hands regularly and especially before eating… Oh and don’t touch your face.
I don’t believe we will be able to contain the disease in Australia. It will wreak havoc on everyone’s lives. Our medical system will not be able to keep up with the onslaught of cases. The economic catastrophe will grow as we have never seen.
Work from home!
If you have a home office with internet, and a good mic and camera then you can and should work from home. Check your background and do a test with a colleague that you look and sound great. Clients still come first and for some, this will be a tricky balance. I don’t think we have too many clients that do not understand the situation. If the clients are not cool about remote meetings, then talk to your SSW State Manager.
Stay home and you will help doctors!
My neighbor is a doctor… he has been working long hours testing 150 patients each day for Coronavirus…. for the last 3 weeks! Not one positive yet for him. However, he says he has been ignoring all his normal sick patients. He is exhausted and sad.
Think about what you can do to help others!
SSW is experienced and set up for remote working – not every business is. Technology can help people. Keep your eyes and ears open to businesses who have unproductive staff and let them know how you work and what software we use eg. Azure DevOps, Microsoft Teams, SugarLearning, etc.
Call any friends you know who have just started Work From Home. Test their mic and camera placement. On so many of my calls, I am discovering not many people are equipped well to WFH, nor know basic mic/camera placement tips. Help everyone you can.
Have fun too – E.g. I love the Wuhan Shake:
[embedded content]
The numbers
Last Friday, I send you the free lunch email with:

Today the updated data is:
NSW: 171 (2 deaths)
Victoria: 71
Queensland: 68
Hangzhou: 170 total cases 167 recovered 
And sadly the Economic Pandemic is just getting started:
Australian dollar dropped to a 12-year low of 61.1 US cents.
Australian Stock market plunged 9 percent to record the heaviest loss since the 1987 crashOuch!
-aAdam Cogan

Coronavirus protocol at SSW – Help us avoid any spread of the coronavirus at SSW
Before SSW
Working from home is preferred at this time.
If you are using public transport please avoid coming to SSW.
If you (or your partner) are sick, stay at home. Seek medical attention.
Avoid Public transport – it is one of the worst places to be during an epidemic as diseases can spread easily on planes, buses, and trains. Again Work From Home #WFH.
If you have been overseas, self-isolate for 14 days.
The new Coronavirus remains on plastics and stainless steel (surviving for up to 72 hours). If you have to go public, try to avoid directly touching the metallic surfaces e.g. elevator buttons, bus handrails, etc. More info https://www.medrxiv.org 
Be a watchdog and say something when people ignoring the pandemic situation we are facing eg. “Want to go to the pub?” Say “No let’s be responsible and have a beer over skype tomorrow”
If you have been in contact with someone with the virus please do not come to SSW. Email your SSW State Manager and Cc Adam
At SSW
If you must come to the office, please wash your hands for 20 seconds with soap + clean your phone. It is filthy.
Wash your hands before eating.
Dry your hands properly – it is just as important as washing them properly. Read Not Drying Hands Thoroughly After Washing Could Aid Bacterial Transfer
Avoid touching your face
No handshakes, hugging, etc. Go for the Wuhan Shake.
Face mask where you can – In China they are required to wear a face mask in public and in the office – seems to help them.
Turn off the central air-conditioning – again a Chinese recommendation
If you use the toilet in the bathroom please only flush with the seat down.
Please cough or sneeze only in your elbows, shirt or a tissue.
Ensure that after a cough or sneeze clean and disinfect the desk surface.
Please maintain a social distancing of 1.5 meters.
Thank you for your help and cooperation in this difficult time 😀
Hygiene Enhancements
I have already spoken to the Sydney, Melbourne, and Brisbane cleaners and they are all doing extra cleaning and disinfecting all knobs, etc.I forgot to include the fingerprint scanner until it was pointed out to me 🙂
Figure: 8 Steps of washing your hands ✔
Summary
COVID-19 (Coronavirus) is going to have big implications for all of us. For now please focus on the tips for hygiene + the social distancing rules. The next few months will be tough and scary. However, there will be good that comes of this too. Working from home will become more acceptable to our clients. This is going to be the largest work from home experiment the world has ever seen.
For March and April and likely beyond we are only going do SSW events online. Losing our in-person Superpowers training is painful. My daughter has just started university and as it now closed, her first 2 weeks already have been via online classes. SSW TV becomes even more important to us.
I think we have plenty of new data – a great A / B test if you will – and we will see what good the reduction of travel has done for our environment. I think we will lose some clients and gain others.
I know this is going to be a disruption to SSW and our customers. Stay strong and learn a lot!
-aAdam Cogan

Read More

Technology in a Pandemic – Helping Control Coronavirus

SSW China have been working closely with the District Government in China to develop an application that will help reduce the spread of Coronavirus. Split into two smaller apps, it has revolutionised reporting during this deadly outbreak.The Government called us during the Lunar New Year, and commissioned SSW to build this with absolute urgency. The 1st application, is a Quarantine Reporting System. Built in React and .NET Core, the application helps residents report their symptoms, apply for leave passes and gain government help and resources when they need it, without having to leave home. It means that they can self quarantine without being assessed and do not need to worry about going outside for supplies, which should drastically reduce the risk of others being infected.The 2nd application is a Government Service System that allows people who are returning to work to do so easily. There are many construction sites facing the scary task of re-opening as the pressure to return to work gets bigger. The construction industry is labour-intensive, and the workers are almost all migrants. In order to help control the epidemic and prevent the potential spread of the virus, the government has introduced strict regulations for the returning work population.
Figure: The Coronavirus App in action
In the past, the process has required individuals to submit paperwork, a *lot* of paperwork. It was labour-intensive, slow and frustrating for operators and staff. Now they can do everything in one place, online, with no paperwork to do. It has revolutionised the return to work system, making it so much easier for both employees and business owners.
The SSW China team have put in some crazy overtime (hundreds of hours in the last month) building this application but they are so proud of the results!
Lessons from China – Controlling the spread of Coronavirus
[embedded content]
Like many other offices in China, many of the SSW guys went back to their hometown to visit family for the Lunar New Year. When they returned back to SSW Hangzhou, they all had to go through a mandatory quarantine period, where they had to stay home and not go out for 14 days (some of them more depending on where they had been).
To make sure our team were protected, we gave them an extra week off, and a week to work from home. Developers are so lucky, these days we can work from anywhere! It meant we could continue to work for our main clients, even when many staff members were still in quarantine.
Some of the team have now been allowed to return to work at the SSW China office, but they have a crazy routine to follow in order to comply with the government rules and to help protect themselves from the virus. Check out their daily routine in this fun video by SSW Admin Sharon Du.
How is it affecting Australia?
Just as Australia started to recover from the devastating bushfires, we were hit by floods, and now, like 60 other countries around the world, we are dealing with the threat of Novel Coronavirus (COVID19).

People have been behaving very strangely, and it’s not because they have the virus. The panic of a potential quarantine has driven people to start stock piling long-life goods like pasta, canned veggies, hand sanitizer and toilet paper. Images from the great toilet paper shortage (there is no real shortage) has been trending on Twitter for weeks #ToiletPaperApocalypse.

Closure of Large Tech Events
Due to the rapid spread of Coronavirus, companies are becoming more and more nervous about running large events where huge numbers of people will congregate. It has already caused the cancellation of popular industry conferences, like Google’s Cloud Next in San Francisco, and Microsoft’s MVP Summit in the Seattle.Organisers have chosen to reduce the risk of infection by turning them into virtual events instead.

Microsoft cancels MVP Summit due to COVID-19 virus fears. The mid-March event will be a virtual-only one now: https://t.co/6ttwVLq4ad
— Mary Jo Foley (@maryjofoley) March 2, 2020

What you can do to protect yourself
You can choose to be as cautious as our SSW China team, (who are in the epicentre of the virus), or do more basic things to prevent infection. According to the World Heath Organisation, Coronaviruses typically cause respiratory symptoms, so they recommend that you adhere to:
normal basic hand hygiene practices, like hand washing with soap and water
respiratory hygiene such as covering your mouth with your elbow when you sneeze
wearing a face mask if unwell.
They break it down for you in this cool informative video:
[embedded content]
Stay safe everyone and remember to wash your hands and don’t hoard toilet paper!

Read More

EF Core Query Tags and Alternatives

When doing a performance review on client applications (and my friend’s apps), I often see issues related to EF Core and most devs don’t seem to notice them until they spiral out of control. When this happens, they don’t know how to find problematic queries and then link them back to the original code.
In this blog post, I’ll show you a couple of tricks on how to track your queries, so when you need to debug performance issues, you won’t have a problem finding the problematic SQL query as well the code that generates it. You can also skip to the end of the recommended approach.
I’ll assume that you have configured logging in your .NET Core application, but if you need instructions for that, go to ASP.NET Core 3.0 + Serilog. I recommend collecting the logs into Seq and/or Application Insights for later analysis.
Tagging Queries
If you use EF Core 2.2+, you can easily track your queries by tagging them with .TagWith().

var list = await _context.Tweets
.TagWith(“GetTweets”)
.ToListAsync(cancellationToken)
.ConfigureAwait(false);

This will add GetTweets into SQL statement, which can be seen in logs and even SQL Profiler.

— GetTweets

SELECT [t].[Id], [t].[CreatedUtc], [t].[Message], [t].[Username]
FROM [Tweets] AS [t]

Figure: We can see the tag as part of the query.

Query Tags are supported to any IQueryable. This includes methods like FromSqlRaw which are now being used to execute store procedures and views as long it inherits from IQueryable.
Sadly adding, updating and removing entities is not supported by Query Tags.
NOTE: For EF6 you can try to use this 3rd party Nuget package: EF6.TagWith
Log Scope
The second approach is to add Log Scope. This approach is great if .TagWith() isn’t available. This could be because you want to log inserts/updates/deletes, you’re running EF Core before version 2.2, legacy EF or even if you don’t have direct access to the queries (like Microsoft Identity).

using (_logger.BeginScope(new Dictionary { { “EFQueries”, “GetTweets” } }))
{
return await _context.Tweets
.ToListAsync(ct)
.ConfigureAwait(false);
}

In this example, I’ll show you how you can indirectly log SQL statements generated by EF Core. To demonstrate that, we’ll need to get an instance of ILogger and then we’ll create a new Log Scope, which propagates to all logs inside that context.

public async Task InsertTweet(string username, string message, CancellationToken ct = default)
{
// This can optionally be in the bellow log scope but is not necessary.
// The tweet is going to be added into SQL DB when `.SaveChanges` is called.
_context.Tweets.Add(new Tweet
{
Username = username,
Message = message
});

using (_logger.BeginScope(new Dictionary { { “EFQueries”, “InsertTweet” } }))
{
// This will make SQL queries to save data into DB.
await _context.SaveChangesAsync(ct).ConfigureAwait(false);
}
}

Figure: Add tweet by adding it to Tweets table.

public async Task InsertTweet(string username, string message, CancellationToken ct = default)
{
using (_logger.BeginScope(new Dictionary { { “EFQueries”, “InsertTweetStoreProc” } }))
{
InsertTweetInternal(username, message);
}
}

private async Task InsertTweetInternal(string username, string message)
{
// This query can also be outside this class and it would still be logged with the “EFQueries” scope.
_ = _context.Tweets
.FromSqlRaw(
“InsertTweet @Username, @Message”,
new SqlParameter(“Username”, username),
new SqlParameter(“Message”, message))
// A hack to make STORE PROC work when they don’t return anything.
.AsNoTracking()
.Select(x = > new { })
.AsEnumerable()
.FirstOrDefault();
}

Figure: Insert Tweets with store procedure.

The above query might get lost if you have a lot of different queries, but by adding a Log Scope, we can search in your preferred rich logger aggregator like Seq or Application Insights for “InsertTweetStoreProc” in property “EFQueries”.
This way, all queries are searchable based on context, find rogue queries and separate your queries from 3rd party queries. Now you can better focus on what queries to optimize or find original code that ran that query.
Recommended approach
Depending on the project, Log Scope might be a better approach since now you can track every SQL query (and other logs) the same way. Use Log Scopes when you know that SQL Server is going to be a problem or visibility is more critical then compact code.

using (_logger.EFQueryScope(“GetTweetsLog”))
{
return await _context.Tweets
.TagWith(“GetTweets + LogContext”)
.ToListAsync(ct)
.ConfigureAwait(false);
}

Small utility for easier logging:

public static class EFCoreLoggingUtils
{
public static IDisposable EFQueryScope(this ILogger logger, string queryScopeName)
{
return logger.BeginScope(new Dictionary { { “EFQueries”, queryScopeName } });
}

public static IDisposable EFQueryScope(this ILogger logger, string queryScopeName)
{
return logger.BeginScope(new Dictionary { { “EFQueries”, queryScopeName } });
}
}

Figure: Logs in Seq with Query Tags and Log Scopes.
In Seq and Application Insights you can find all queries with the following filter SourceContext = “Microsoft.EntityFrameworkCore.Database.Command”. You can then do further filtering based on Log Scope by filtering EFQueries.
You can find source code here: https://github.com/jernejk/EfCoreSamples.Logging

Read More