Principal Software Engineer at Allscipts in Malvern, Pennsylvania, Microsoft Windows Dev MVP, Husband, Dad and Geek.
77913 stories
·
26 followers

How to Build Multi-Platform Apps with Uno Platform and Blockchain – Part 2

1 Share

 This is Part 2 of a two-part series. You can find Part 1 here.

In our previous article, we introduced the Ethereum blockchain, itemized tools used for building, testing and deploying its networks, and shared some resources to help get a deeper understanding of the technology and its ecosystem.

In this article we are going to delve deeper into a part of the Ethereum blockchain that allows you to make executable functions/methods from decentralized apps.

Blockchain is an important technology for several reasons. It possesses several properties that are beneficial to business sectors that require trust, security and ease of sharing of data:

  1. Transparency: This blockchain property ensures that all connected parties have access to and can track all transactions and work done on the network.
  2. Security: This property ensures the protection of the transactions and work done in the network using cryptography algorithms and methods to encrypt and decrypt transactions.
  3. Immutability: This property safeguards the integrity of transactions and data by preventing the modification or alteration of previously stored data.
  4. Traceability: This property is observed in a blockchain when a completed transaction is linked to a previously completed transaction thus ensuring the verification of the history of all transactions in the network.
  5. Distributed: This property allows for a reduction in both human and financial costs since the transactions and data of the network are not stored in one data center that is typically costly and requires human resources to run and maintain.

Aside from the financial sector, another sector that will benefit greatly from blockchain technology is Healthcare. From healthcare data sharing between stakeholders to drug shipment tracking this sector has several avenues that can utilize and benefit from blockchain technology.

This is why this series, showcasing how to build an Uno platform cross platform application that connects to a blockchain network to track drug shipments between relevant parties could be relevant to Healthcare systems and application developers.

We are going to delve into smart contacts with a simplified real-world example of Drug shipments.

For the sake of simplicity, we will be dealing with only the actual Drug shipment and ignoring other factors involved in the real-life shipment pipeline such as Payment of fees, insurance etc.

In summary, we have Four CD types of users:

  1. Manufacturer: This is the typical large pharmaceutical companies that make drugs and distribute shipments to wholesalers.
  2. Wholesaler: This is your typical large scale brand drug pharmacies and wholesalers that distribute drug shipments to smaller pharmacies or their smaller patient accessible subsidiaries. With this type of user, initial drug shipments received from manufacturers are broken down into smaller drug shipments to be dispatched to various pharmacies in their network.
  3. Pharmacy: This is your typical corner store pharmacy where drug shipments received from wholesalers are further broken down into smaller shipments to be dispatched/dispensed to individual people/patients.
  4. Patient: This is your typical person (You & I) that procures drugs from a pharmacy and consumes it. Since we cannot create and or distribute drugs (Suppress your inner Walter White alter ego 😉) you just need to connect to a pharmacies network receive your drug shipment and consume it.

The diagram illustrated below shows the possible flow of a drug shipment(s) between parties involved:

As previously mentioned, we will be using Ethereum smart contracts which are typically written using the programming language called Solidity.

To represent a Manufacturer, Wholesaler or Pharmacy’s network and functions that can be executed in the given network, we will create three smart contracts:

  1. Drug Shipment: This smart contract inherits from Open-Zeppelin’s implementation of a type of non-fungible token (NFT) called ECR721.
    With the principle of inheritance in object-oriented programming in mind, what you have from this inheritance relationship between
    DrugShipment and ECR721 smart contracts is the ability to access public variables and functions defined in ECR 721 in the DrugShipment smart contract. In addition to inherited variables and functions, the drug shipment defines and implements several variables and functions aimed at storing the details previous and current owners of drug shipments, creating, dispatching and consuming of drug shipments.
  2. Wholesaler: The wholesaler intents from the DrugShipment smart contract and as such has access to the public variables and functions defined and inherited by the DrugShipment.
  3. Pharmacy: In similar fashion, the Pharmacy smart contract inherits from the DrugShipment smart contract. However, the Pharmacy smart contract has an executable Consume function that can only be executed by a Patient connected to their network that owns/is in
    possession of a drug shipment previously owned and dispatched from a pharmacy.

The code snippets below show some of the key functions in the smart
contracts discussed above.

Figure 1: Patient Consume Function
Figure 2: Dispatch Function
Figure 3: Create and Dispense private functions.

To deploy the contracts and view transactions on the Ganache client, follow the steps itemized below:

  1. Open Ganache Desktop client and use a default Workspace
    configuration (QUICKSTART Ethereum) or create yours (NEW WORKSPACE Ethereum). Take note of the RPC Server address and port number.
Figure 4: Setting up Workspace.
Figure 5: Setup Workspace
  1. Using Visual studio code and ensuring you have installed the Blockchain Development kit for Ethereum by Microsoft, right click on the sol contract and then click on deploy contracts. it will ask you to select a network, select the network matching the network address and port of your Ganache Desktop client. This will build compile and then deploy your contracts to the Ganache test Network. you can confirm this in the Contracts and Transactions tabs.
Figure 6: Blockchain Development Kit for Ethereum
Figure 7: Deploy Contracts.
Figure 8: Select Network.
Figure 9: Compiling and Deployment Output.
Figure 10: Deployment Complete.
Figure 11: Transactions Logs.
  1. In the tests folder you will see sol file, this is a test file that allows you to run some of the functions in the smart contract and test them. To do this use the command below to run the tests.

truffletest./test/drug_shipment.js

Figure 12: Sample Output of Test execution.
  1. If you check your Ganache Desktop client, you will notice changes to balance of Ethers in the test accounts that were used. Also, you will see new transactions and events in transactions tab. The images below illustrate this:
Figure 13: Altered balances.
Figure 14: New Transactions.
Figure 15: Transaction’s Events.

At this point, we can start looking into the porting of the smart contracts into Uno platform cross-targeted library. Specifically, our libraries will be targeting the following platforms:

  1. Android
  2. iOS
  3. MacOS
  4. Windows
  5. WebAssembly

In order to achieve this, we will break down the series of steps required to create the libraries into 2 Stages:

  1. C# code generation using Visual Studio Code and its 3rd party Solidity Extension.
  2. Uno platform cross-targeted library creation using the above generated code.

STAGE 1:C# code generation using Visual Studio Code and its 3rd party Solidity Extension.

a. Starting from your opened solidity project on visual studio code, press the F1 key and type “solidity” to narrow down the list of executable operations to only show the available solidity extension operations. Scroll through the list and select the item titled “Solidity: Create nethereum-gen-settings with default as root.”

Figure 16: Generate nethereum gen settings

b. This will create a file named nethereum-gen-settings with its content similar to the image shown below:

Figure 17: Nethereum-gen.settings snippet code.

lang denotes programming language which has the possible values 0,1 and 2 which map to C#, vb.NET and F# respectively.

c. Next, right-click on one of your smart contracts in my case sol file. Left click on Build contracts. This will take a while and the progress can be monitored on the Output Tab on visual studio code to ensure successful compilation.

Figure 18: Build successful.

d. Again, press F1, type “solidity” and search for and select “Solidity:
Code generate CSharp project from all compiled files”
.

e. Once completed, head over to the project path and you will see the generated code arranged in several folders with a similar nested structure as illustrated below:

Figure 19: Nested folder sample structure

STAGE 2: Uno platform cross-targeted library creation using the above generated code.

This stage requires you to have installed the Uno Platform Solution Templates for Visual Studio.

a. Running a new instance of Visual Studio, create a new project making sure to search and select the Multi-platform Library (Uno Platform). Name your project with the name set in the nethereum-gen-settings projectName field and click on the Create button.

Figure 20: Create an Uno Platform Multi-Platform Library.
Figure 21: Create Project.

b. Once the project is created, copy the generated folders and C# codes obtained from stage 1 into your project and build it.

c. Some errors will occur and for the Drug shipment example, the table below itemizes the description of the common errors and now to fix them.

S/No Error Solution
1. Type or namespace not found (missing using directive or assembly reference Restore NuGet packages. If this does not work check for and install the specific packages missing i.e., Netherereum.Web3
2. Keywords used as variable names (Invalid expression terms) Rename the variable(s) in question.
3. Function overloading errors (Type already defines a member with similar parameters) Rename member variable or function.

 

d. Upon a successful build, in your Debug and/or Release folder,
you will find folders mapping to each targeted platform and inside these folders you will see the dll for the specific platform.

Figure 22: Library Folders.
Figure 23: DLL Library.

Okay! Now, we’re going to use the previously created libraries in an Uno Platform multi-targeted application.

Uno Platform Solution Templates is an extension for the Visual Studio 2019 IDE that allows you to build cross platform applications that target several major platforms like Android, iOS, MacOS, Windows and Web Assembly.

Our custom-made Uno Platform cross-targeted library relies on the Nethereum NuGet package. Nethereum is an open-source .NET integration library for blockchain technology. Nethereum allows .NET developers write smart contracts, cryptographic wallets and decentralized applications for the Ethereum blockchain network.

Before you deploy or test your application, you need to make sure your Ganache client is running. You will need test accounts to interact with in your application.

To create an Uno Platform cross platform application, you need to make sure you have the Uno Platform Solution Templates installed in Visual studio. Start Visual studio and select create a new project. Type “Uno” to narrow down the list of templates available. Then select “Multi-Platform App (Uno Platform)”. Click next and name your app accordingly.

Figure 24: Creating an Uno platform multi-targeted app

This article comes with an accompanying demo application which you can run and test the several functions exposed by your Uno platform cross-targeted library.

When you build and run the app, you will be presented with a page that allows you to input test credentials similar to the images illustrated below (Windows and Android):

Figure 25: Windows- Credentials main page
Figure 26: Android Credentials Main Page.

Behind the scenes, Test account objects and services are created and passed on the Tabbed page which will come next.

Figure 27: Tabbed Pages Manufacturer Tab

Code snippet for the Credentials MainViewModel.

 

public class MainViewModel<br /><br /><br /><br />
{<br /><br /><br /><br />
#region Properties</p><br /><br /><br />
<p>public string DrugShipment { get; set; }<br /><br /><br /><br />
public string Migrations { get; set; }<br /><br /><br /><br />
public string Url { get; set; }<br /><br /><br /><br />
public string NetworkId { get; set; }</p><br /><br /><br />
<p>public AccountAddresses AccountAddress { get; set; }<br /><br /><br /><br />
public AccountKeys AccountKeys { get; set; }</p><br /><br /><br />
<p>public Accounts Accounts { get; set; }</p><br /><br /><br />
<p>public Web3s Web3s { get; set; }</p><br /><br /><br />
<p>#endregion</p><br /><br /><br />
<p>public MainViewModel()<br /><br /><br /><br />
{<br /><br /><br /><br />
Url = "HTTP://127.0.0.1:7545";<br /><br /><br /><br />
NetworkId = "5777";<br /><br /><br /><br />
DrugShipment = "N/A";<br /><br /><br /><br />
Migrations = "N/A";<br /><br /><br /><br />
AccountAddress = new AccountAddresses();<br /><br /><br /><br />
AccountKeys = new AccountKeys();<br /><br /><br /><br />
Accounts = new Accounts();<br /><br /><br /><br />
Web3s = new Web3s();<br /><br /><br /><br />
}</p><br /><br /><br />
<p>public SetUp Setup()<br /><br /><br /><br />
{<br /><br /><br /><br />
Accounts.one = new Account(AccountKeys.one);<br /><br /><br /><br />
Accounts.two = new Account(AccountKeys.two);<br /><br /><br /><br />
Accounts.three = new Account(AccountKeys.three);<br /><br /><br /><br />
Accounts.four = new Account(AccountKeys.four);</p><br /><br /><br />
<p>Web3s.one = new Web3(Accounts.one, Url);<br /><br /><br /><br />
Web3s.two = new Web3(Accounts.two, Url);<br /><br /><br /><br />
Web3s.three = new Web3(Accounts.three, Url);<br /><br /><br /><br />
Web3s.four = new Web3(Accounts.four, Url);</p><br /><br /><br />
<p>return new SetUp { Accounts = Accounts, DrugShipment = DrugShipment, Migrations = Migrations, Web3s = Web3s };<br /><br /><br /><br />
We can now test several public functions written in our smart contracts.

  1. Deploy DrugShipment Contract as a Manufacturer:
    To deploy a drug shipment as a manufacturer, use the DrugShipmentService static class with the method DeployContractAndGetServiceAsync which takes 2 parameters:

    1. Web3
    2. DrugShipmentDeployment

The DeployCommand above is bound to the Deploy button in the Manufacturer’s tab illustrated below.

public async Task DeployCommand(DrugShipmentDeployment deployment)<br /><br /><br />
{</p><br /><br />
<p>DrugShipmentService = await DrugShipmentService.DeployContractAndGetServiceAsync(SetUp.Web3s.one, deployment);</p><br /><br />
<p>}<br /><br /><br />
Figure 28: Deployed contract on demo app.
  1. Deploy Wholesaler Contract as a Wholesaler:

To deploy a Wholesaler drug shipment as a Wholesaler, use the WholesalerService static class with the method DeployContractAndGetServiceAsync which takes 2 parameters:

  1. Web3
  2. WholesalerDeployment object

public async Task DeployCommand(WholesalerDeployment deployment)<br /><br /><br />
{<br /><br /><br />
DrugShipmentService = await WholesalerService.DeployContractAndGetServiceAsync(SetUp.Web3s.three, deployment);<br /><br /><br />
}<br /><br /><br />
The DeployCommand above is bound to the Deploy button in the Wholesaler’s tab illustrated below.

Figure 29: Deployed wholesaler contract on demo app
  1. Deploy Pharmacy Contract as a Pharmacy:
    To deploy a Pharmacy drug shipment as a Pharmacy, you just need to use the PharmacyService static class with the method DeployContractAndGetServiceAsync which takes 2 parameters:
    i. Web3
    ii.
    PharmacyDeployment object.

public async Task DeployCommand(PharmacyDeployment deployment)<br /><br /><br />
{<br /><br /><br />
DrugShipmentService = await PharmacyService.DeployContractAndGetServiceAsync(SetUp.Web3s.three, deployment);<br /><br /><br />
SetUp.Service = DrugShipmentService;<br /><br /><br />
}<br /><br /><br />
The DeployCommand above is bound to the Deploy button in the Pharmacy’s tab illustrated below.

Figure 30: Deployed pharmacy contract on demo app.
  1. Dispatch Drug shipment from Manufacturer to Wholesaler:
    When you dispatch a drug shipment from a Manufacturer to a Wholesaler, you do this with the DispatchRequestAndWaitForReceiptAsync() method which takes a DispatchFunction object as a parameter. This method tells the DrugShipment Service to create a shipment with a unique token id and dispatch it to a given Wholesaler. If successful, 3 events are emitted: Approval, Transfer and LogShipment events and if not successful, a LogError event is emitted.

public async Task DispatchCommand(DispatchFunction fxn)<br /><br /><br />
{<br /><br /><br />
DispatchReceipt = await DrugShipmentService.DispatchRequestAndWaitForReceiptAsync(fxn);<br /><br /><br />
GetDispatchEvents();<br /><br /><br />
}<br /><br /><br />
The DispatchCommand above is bound to the Dispatch button in the Manufacturer’s tab illustrated below.

Figure 31: Completed Manufacturer Dispatch transaction.
  1. Dispatch Drug shipment from a Wholesaler to a Pharmacy:
    In a similar fashion, when you dispatch a drug shipment from a Wholesaler to a Pharmacy, you do this with the DispatchRequestAndWaitForReceiptAsync() method which takes a DispatchFunction object as a parameter. This method tells the Wholesaler Service to create a shipment with a unique token id and dispatch it to a given Pharmacy. If successful, 3 events are emitted: Approval, Transfer and LogShipment events and if not successful, a LogError event is emitted.

public async Task DispatchCommand(DispatchFunction fxn)<br /><br /><br />
{<br /><br /><br />
DispatchReceipt = await DrugShipmentService.DispatchRequestAndWaitForReceiptAsync(fxn);<br /><br /><br />
GetDispatchEvents();<br /><br /><br />
}<br /><br /><br />
The DispatchCommand above is bound to the Dispatch button in the Wholesaler’s tab illustrated below.

Figure 32: Completed Wholesaler Dispatch transaction.
  1. Dispatch Drug shipment from Pharmacy to Patient:
    When you dispatch a drug shipment from a Pharmacy to a Patient, you do this with the DispatchRequestAndWaitForReceiptAsync() method which takes a DispatchFunction object as a parameter. This method tells the Pharmacy Service to create a shipment with a unique token id and dispatch it to a given Patient. If successful, 3 events are emitted: Approval, Transfer and LogShipment events and if not successful, a LogError event is emitted.

public async Task DispatchCommand(DispatchFunction fxn)<br /><br /><br />
{<br /><br /><br />
DispatchReceipt = await DrugShipmentService.DispatchRequestAndWaitForReceiptAsync(fxn);<br /><br /><br />
GetDispatchEvents();<br /><br /><br />
}<br /><br /><br />
The DispatchCommand above is bound to the Dispatch button in the Pharmacy’s tab illustrated below.

Figure 33: Completed Pharmacy Dispatch transaction.
  1. Consume Drug as a Patient:
    The Patient whom owns a specific drug shipment can consume the drug by calling the ConsumeRequestAndWaitForRecieptAsync() method attached to the PharmacyService from which the dispatch function was executed.

public async Task ConsumptionCommand(ConsumeFunction fxn)<br /><br /><br />
{<br /><br /><br />
try<br /><br /><br />
{<br /><br /><br />
ConsumptionReceipt = await DrugShipmentService.ConsumeRequestAndWaitForReceiptAsync(fxn);<br /><br /><br />
GetDispatchEvents();<br /><br /><br />
}<br /><br /><br />
catch (Exception exception)<br /><br /><br />
{<br /><br /><br />
Console.WriteLine(exception.Message);<br /><br /><br />
}<br /><br /><br />
}<br /><br /><br />
The ConsumptionCommand above is bound to the Consume button in the Patient’s tab illustrated below:

Figure 34: Completed Patient Consume transaction

And we’re done! In the exercise above, we have seen and explained how we consumed our Uno platform library in a demo application. You can get all of the code for this exercise here.

In a real-world scenario, Several apps might need to be built or at least a form of User and Role management will need to be implemented in an app to distinguish between patient features and views versus manufacturer, wholesaler and pharmacy features and views. Happy coding!

 

The post How to Build Multi-Platform Apps with Uno Platform and Blockchain – Part 2 appeared first on Uno Platform.

Read the whole story
alvinashcraft
50 minutes ago
reply
West Grove, PA
Share this story
Delete

What is in Code With Me 2021.2?

1 Share

Code With Me, the JetBrains tool for pair programming and collaborative coding, has reached its second big release. 

The new version has received an array of beautiful new features and updates that software teams of all kinds will enjoy. Many of these changes are the result of suggestions from our users. Thank you! This reflects the essence of the product, keeping it true to itself, everything can be made better together. 

As well as receiving some incredible feedback about what new features you want us to add, we have also got lots of nice positive feedback about the product, which makes us very happy ❤🔥

Let’s take a look at the major improvements we’ve made in the Code With Me 2021.2:

🆕 Undo your actions quickly and accurately

Code With Me 2021.2 features a re-worked undo functionality that significantly improves the collaborative programming experience. The revamped undo logic enables both guests and the host to reverse their individual changes in the code. This means that upgrading to the 2021.2 version will allow you to avoid unpleasant situations where one developer accidentally deletes changes made by their peers. This improvement is particularly useful in pair and mob programming scenarios 💻↔💻

🆕 Share any screen during a collaborative session

One of the most eagerly-awaited features, screen sharing, is finally here. Code With Me 2021.2 now lets participants share an application window from their computer screen, not just your JetBrains IDE, to help participants collaborate better. 

🆕 Forward ports to your pair programming peers 

You spoke and we listened! The ability to share specific open ports with participants via an integrated proxy, is now available in Code With Me 2021.2! So, if a host runs applications on a specific port, their guests can access it via a local host on their machine.

🆕 Code With Me is now bundled with AppCode

Starting with version 2021.2 of AppCode, Code With Me will come bundled and ready for use 🙌 This makes pair programming more accessible to even more software developers!

🆕 Try Code With Me on Android Studio Bumblebee

As promised, Code With Me has made decent progress with Android Studio. We are beyond excited to announce that the super-early bird version of the Code With Me plugin compatible with Android Studio Bumblebee 2021.1.1 is out 🎬

Add the following channel https://plugins.jetbrains.com/plugins/eap/14896  to your custom plugin repositories and then install the plugin from the JetBrains Marketplace as you normally would. That way you’ll be getting timely updates and fixes. Please share your feedback about the plugin here.

📍Miscellaneous improvements and fixes 

  1. There is some good news for PyCharm users – Code With Me now supports the Python Packages tool window!
  1. Code With Me sessions can be now disabled by system administrators if pair programming is limited by their security policy. That being said, if security is a major concern, but you still want to do pair programming, you might want to check out Code With Me Enterprise which allows you to host collaborative sessions on your private network.
  1. Terminal sharing has been revamped with new updates, which make the interactions between host and guest more transparent. Now hosts can track whether a terminal is shared or not, and also see the level of access their guests have. 
  1. We have introduced proxy authentication for Code With Me on-premises.
  1. Code With Me now supports the Python console for IntelliJ IDEA users. 

🔑 Availability and subscriptions

Code With Me 2021.2 is available with the latest builds of IntelliJ IDEA, WebStorm, PyCharm, PhpStorm, CLion, GoLand, AppCode, and RubyMine. There are different feature sets for Code With Me which depend on the type of license you have:

  1. IntelliJ IDEA Community or PyCharm Community users have access to Code With Me Community functionality by default. It is free of charge and allows you to create an unlimited number of 30-minute pair programming sessions and invite up to 3 guests to your IDE.
  1. Users of IntelliJ IDEA Ultimate, PhpStorm, GoLand, AppCode, PyCharm Professional, CLion, RubyMine, or WebStorm can use the Code With Me Premium subscription. This is also true for holders of All Products Pack, Educational, Open Source, and Developer Recognition licenses. With a Code With Me Premium subscription, you can create an unlimited number of shared sessions, and there is no time limit per session. You can invite up to 50 guests to a session with this subscription. 
  1. Code With Me on-premises is available with the Code With Me Enterprise license only. You can try it for free for 30 days. 
Only hosts require a license to initiate a collaborative session, guests do not need to have a JetBrains IDE at all. To learn more about the licensing, please visit our pricing page.    

🙋🏾 How did we do? 

Code With Me 2021.2 includes many exciting new features, and we have added in lots of nice bells and whistles to help you stay connected and do great things together. Let us know how we did in the comments ⬇

Read the whole story
alvinashcraft
51 minutes ago
reply
West Grove, PA
Share this story
Delete

In-Person Conferences are Back: See you Soon!

1 Share

As in-person conferences have been cancelled due to COVID-19, we helped to create an experience on par with offline conferences. But conferences are back! Read where we are going to exhibit in the second half of 2021.

Read more



Read the whole story
alvinashcraft
6 hours ago
reply
West Grove, PA
Share this story
Delete

GraphQL Observability

1 Share

Whenever we have a web application we’ll typically want to be able to observe it in production. Typically common questions will be:

  • Which endpoints are being exercised the most?
  • Which endpoints are running slower than normal?
  • Which endpoints are returning errors to our users?

Eagle eyed readers will notice all of these quetsions are about endpoints or routes. Most Application Performance Monotiring (APM) products will have a built in knowledge of HTTP and easily be able to show this to you. New Relic which I’ll use for the rest of my examples even has an understanding of MVC built in and will classify transactions (requests) using their controller and action names rather than just the url.

What about GraphQL?

The way a GraphQL server works is that all queries and mutations are POST’s to the same url (typically something like /graphql) which means you get something like the following in New Relic.

New Relic without operations

Now this data won’t let you answer any of those three questions, and in fact GraphQL comes with even more nuance if you’re running a public GraphQL API which we can discuss another time.

Adding Observability

The Hot Chocolate has the concept of a DiagnosticEventListener, what we’ll do is create our own NewRelicDiagnosticEventListener to append some extra information to the current transaction to make it more useful.

The DiagnosticEventListener class has a number of methods you can override depending on what you care about in terms of your diagnostics. For this exacmple we care about ExecuteRequest.

public class NewRelicDiagnosticEventListener : DiagnosticEventListener
{
    public override IActivityScope ExecuteRequest(IRequestContext context)
    {
        // implementation goes here
    }
}

Now the API pattern for the DiagnosticEventListener is an intersting one that I’d never come across before and it’s worth a bit of explanation. Typeically for these diagnostic API’s we’ll need a hook for the start of a request as well one at the end as sometimes you’ll want to set up things at the start of the requuest and then collect / use them at the end. This can make a hefty API surface if for every “event” there would need to be two hooks. The Hot Chocolate developers resolved this by introducing IActivityScope which is simply a rename of IDisposable.

public interface IActivityScope : IDisposable
{

}

The idea is the framework will call ExecuteRequest at the start of the request. We’ll then request an IActivityScope that will be disposed by the framework at the end of the request.

For our example we’ll want to do changes to the New Relic transaction at the end of the request because we’ll want to use information parsed from the request body.

Here’s our final version, it returns a custom RequestActvityScope that on disposale will set the name of the current transaction in New Relic to be the incoming operation name.

public class NewRelicDiagnosticEventListener : DiagnosticEventListener
{
    public override IActivityScope ExecuteRequest(IRequestContext context)
    {
        return new RequestActvityScope(context);
    }

    private class RequestActvityScope : IActivityScope
    {
        private readonly IRequestContext context;
        private bool _isDisposed;

        public RequestActvityScope(IRequestContext context)
        {
            this.context = context;
        }

        public void Dispose()
        {
            if (_isDisposed)
                return;

            NewRelic.Api.Agent.NewRelic.SetTransactionName("GraphQL", context.Operation?.Name?.Value ?? "unknown");

            _isDisposed = true;
        }
    }
}

We can then use it with our setup code

services.AddGraphQLServer()
    .AddDiagnosticEventListener<NewRelicDiagnosticEventListener>()
    .AddQueryType<Query>();

Now we’ll see something more useful in New Relic, all our traffic previously grouped up in /graphql has been broken apart into the different operations our front end code is making which makes it a lot easier to answer the questions from the start of the post.

New Relic with operations

Conclusion

Out of the box most APM tools will do a poor job of observability into GraphQL operations due to how HTTP is used. We need to do more work on our server to assist the APM to enable us as developers to support our GraphQL API’s in production.

Read the whole story
alvinashcraft
6 hours ago
reply
West Grove, PA
Share this story
Delete

SQL SERVER – Parallelism in Express Edition

1 Share

I enjoy writing blogs as I learn always something new at Comprehensive Database Performance Health Check. Recently a client reached out to me with a very interesting question, why is he not able to see the parallelism in Express Edition. Let us discuss today.

SQL SERVER - Parallelism in Express Edition ParallelisminExpress-800x411

Real-World Scenario on Parallelism in Express Edition

One of my large eCommerce clients has many different versions and editions of SQL Server installed in his environment. They had one query that was running efficiently with Parallel threads, but it always gave a poor performance when it runs on a single thread. Recently they experienced a situation where they have to run the same query on the massive 64 logical CPU machine. They had 1 standard edition and many express editions installed on the machine.

When they ran the query on the standard edition machine, it was able to utilize the maxdop (which was set to 4) efficiently but when they were running the query on the express edition, it was giving a serial plan. They wanted me to help them to have the same parallel plan on the express edition.

Well, the answer is Not possible to have Parallelism in Express Edition. If you are using express edition, your plans will always be serial and will not get any parallel plans.

Well, that’s it for today. I hope you find this information helpful when you are working with different editions of SQL Server.

If you liked this blog, please do not forget to subscribe to my YouTube Channel – SQL in Sixty Seconds.

Here are my few recent videos and I would like to know what is your feedback about them.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – Parallelism in Express Edition

Read the whole story
alvinashcraft
6 hours ago
reply
West Grove, PA
Share this story
Delete

The rise of parallel chat in online meetings: how can we make the most of it?

1 Share
Woman at a desk using a Surface laptop to make a Microsoft Teams video call with one man smiling and wearing a headset. Business Voice conference call/meeting device is in the background.

“I’ll put a link to that doc in the chat”

“Sorry, my internet is terrible, I’ll put my question in the chat”

“That GIF from Amy in the chat is hilarious”

If these phrases sound familiar to you, you’re not alone – people the world over use the chat function in Microsoft Teams and other video-calling services every day. But we could ask: why post messages in parallel to the main conversation? Does it improve or worsen the meeting experience? And crucially, what can we do to make it more effective?

Why do people chat – and is it a good thing for meetings?

To answer these questions, we conducted a study drawing on two sources of data: (1) the diaries of 849 Microsoft employees who journaled their experiences during the summer of 2020, when COVID-19 triggered widespread remote work and online meetings, and (2) a survey of 149 Microsoft employees that specifically asked how they used chat. The paper was accepted at the 2021 ACM CHI Virtual Conference on Human Factors in Computing Systems.

In the survey, the overwhelming majority (85.7%) of participants agreed that parallel chat is a net positive. Only 4.5% responded negatively, and 9.8% were neutral. 

Chat messages themselves can contain a lot of different things: questions; links and documents; agreement and praise that add to what is being conveyed during the call; discussion of related and unrelated topics; and humour and casual conversation. 

Many people did report being distracted by chat – it is difficult to focus on the audio/video (AV) of a meeting while also participating in the chat. People clash over different expectations around how to chat and how formal chat needs to be. For participants that fail to notice important chat entries, confusion can ensue. Moreover, chat poses challenges for people with reading difficulties or people who find it hard to understand sentiment in text. Images posted in chat may not come with alt text to help blind and low vision people understand them. 

As one participant says, “[…] sometimes it’s very distracting as multiple threads are happening that get tangential from the main presenter/speaker. […] it’s really hard to keep track of multiple conversations AND pay attention to the speaker.

And yet our research showed compelling benefits of chat within meetings, which argues for encouraging it, even as we continue to look for ways to minimize the negative consequences.

The many benefits of chat

Chat has become essential in virtual meetings – many online meetings would be much less efficient, and some would be impossible, without chat. Chat enables people to organize their collaboration and action around documents and follow-up meetings. It enables people to work around problems such as poor connectivity and technical issues, language barriers, and inscrutable jargon. It helps manage turn taking and questions/answers, especially in large meetings.

A survey participant explains, “there have been meetings where important links were able to be provided in the text chat, important and relevant topics were brought up and then incorporated into the meeting, etc – these are times when I feel like I really could not live without [it]”

Beyond these functional roles, chat also enables humor and casual conversation, which give meetings a much-needed sense of social support and connection.

As one participant puts it, “we use text chat to send ‘cheers’ and fun gifs to celebrate moments […] this tends to generate a lot of enthusiasm and makes these types of meetings more fun. like people’s personalities coming out.

Perhaps most importantly, chat can be a means of inclusion. Chat enables people to participate without interrupting the speaker, preserving the flow of the meeting. It enables contributions from those who are shy or unable to speak. And by keeping a record of reactions to posts, it can help participants support good ideas that arise from the sidelines. One participant observed “people contributing through chat that might not have a voice otherwise – either limited by technology (no microphone), environment (loud, distracting) or personal preference (shy, new, still finding the way in the team’s culture.)”

Our poll data provided a specific example of chat’s power for inclusivity: women aged 25-34 were much more likely than any other group to report an increase in chat use after shifting to remote work. And women of every age reported more chat usage than men.

A picture of a table showing respondents who reported increased chat usage, sorted by age and gender. Age 25 to 34 shows 20 percent for men and 59 percent for women. Age 35-44 shows 8 percent for men and 29 percent for women. Age 45-64 shows 24 percent for men and 26 percent for women.
Figure 1: Increased chat use was most reported by women aged 25-34. The figure shows the proportion responding ‘strongly agree’ that their own chat use has increased.

This is an important finding, because gender is associated with different meeting experiences and participation rates. Young women sometimes find it difficult to be heard during meetings, and our study suggests that chat gives them another way to participate. However, we should not equate participation in chat with speaking in the ‘main’ audio/video of the call, which is generally more significant.

More broadly, members of minority groups or people with disabilities may have positive or negative experiences with chat. This could include neurodivergent professionals and those who are blind or low vision. On the other hand, chat may enable greater participation for people who lack the ability to speak. Further study is needed to understand whether chat improves the inclusion of those who suffer from systemic disadvantage, or whether it is entrenching that disadvantage, perhaps even exacerbating it, by relegating their participation to a side channel.

How to make the most of chat in online meetings

Chat has both benefits and disadvantages. Used well, it can be a powerful and effective tool in online meetings. Used poorly, it can cause distraction and confusion. Based on our study, here are some guidelines for using chat effectively:

  1. Establish expectations about chat usage before the meeting starts. Clear guidelines will support chat that is inclusive, as well as productive.
  2. Consider accessibility challenges (e.g., some attendees may have difficulty reading text or understanding sentiment in text).
  3. Encourage chat that engages with the meeting topic or makes the meeting more inclusive. Discourage overly off-topic, exclusionary, inaccessible chat.
  4. Monitor chat for questions and comments and address them in the main conversation.
  5. Include a chat summary in meeting archives to preserve and share ideas and feedback.

We’ve also written a meeting chat guide with more explanation of these guidelines.

Chat to the future

Improving chat can lead to more effective conversations as well as enhanced meeting tools. Based on our study, we identified several opportunities for enhancing chat through design. For example, we could use machine learning, or a tagging feature, to identify and differentiate between types of chat messages, so participants could visually recognize questions, clarifications, comments, kudos, on and off-topic talk. We could better integrate chat with the main audio-video conversation by showing indicators of whether chat is quiet or busy, highlighting messages containing terms that match what is being discussed, and integrating images and websites in the chat into the main video stream. For a longer list of opportunities, see section 4.2 of our paper.

The age of online meetings has just begun. We’re still learning how to build tools for effective online collaboration. Even in things as unassuming and prosaic as chat, there are challenges but also tremendous opportunities.

In the spirit of using poetry to help communicate science, we leave readers with a poem written by the first author (Advait Sarkar) that takes inspiration from our study, which was conducted during a pandemic that kept us all apart far longer than expected:

Summer came, but winter’s game
Would see no end
The micro-reign, devil stain
Cleft foe from foe, and friend from friend


Learnt we swift, our this day’s gift
To meet apart
Let sound, sight, and what we write
Join head to head, and heart to heart

Want to learn more? Read our paper.  

Acknowledgments

This research was authored by Advait Sarkar, Sean Rintel, Damian Borowiec, Rachel Bergmann, Sharon Gillett, Danielle Bragg, Nancy Baym, and Abigail Sellen and part of a larger project about meetings during the COVID-19 pandemic.

The post The rise of parallel chat in online meetings: how can we make the most of it? appeared first on Microsoft Research.

Read the whole story
alvinashcraft
16 hours ago
reply
West Grove, PA
Share this story
Delete
Next Page of Stories