Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically Passing and Pulling JSON data between .NET Framework and .NET Core

I am new in computer science (so hopefully I am using the right words and give the right information to answer this question), hopefully you guys can help me. I want to automatically transfer (JSON) data between two .NET Solutions.

I have two Solutions in .NET:

  1. The Bot Framework SDK - Build in .NET Core 2.2 (https://docs.microsoft.com/en-us/azure/bot-service/dotnet/bot-builder-dotnet-sdk-quickstart?view=azure-bot-service-4.0)

    • From what I understand: build in ASP.NET Core
  2. The Qlik Sense .Net SDK. - build in .NET Framework 4.5.2 (https://github.com/kolsrud/qlik-dot-net-sdk-hypercube-usage)

I want to let these two solutions communicate with each other.

  • On the one hand: in the QlikSense.NET SDK we store all the data into a variable (let's say variable 'Sales', holding JSON data), if this variable is updated, I want to transfer it to the Bot framework (and store the data here).

  • On the other hand: we have a variable in the Bot Framework (let's say variable 'Query', holding JSON data), if that variable is updated, I want to pass it to the Qliksense SDK.

Summarized: I want to automatically transfer (JSON) data between the Qliksense SDK and the Bot framework SDK. How can I do that?

Again, sorry if something is unclear. Thanks in advance for you help! Appreciated!

Edit 1: What have I tried? As asked by Selvin:
The only thing that I could come up with, was writing the JSON variable into a text file, and read that Text file from the other script. But, I don't think that this is a proper 'solution'.

like image 379
R overflow Avatar asked Mar 18 '19 12:03

R overflow


3 Answers

There are a few solutions, which you can apply depending on details in your projects.

As I understand you are using Bot framework SDK without anything more. The base Nuget is written in .NET Standard 2.0, which can be used both in dotNet Core and dotNet Framework. So the easiest way is to upgrade/change your project to compile on dotNet Framework instead of dotNet Core. Then you can reference the second project without any problems.

If there are more compilations which I don't know you can do one of the following solutions:

  1. Create to processes on the same machine a send "messages" between them (one is a file as you mentioned, second is HTTP requests, third are queues, and more ...) - I can provide more details if I know how you want to host your solution
  2. Try to migrate QlikSense project to dotNet Core. You can check if migration is easy using the official guide: https://docs.microsoft.com/en-us/dotnet/core/porting/third-party-deps and this post: https://www.stevejgordon.co.uk/migrating-full-net-framework-net-core
  3. Search another library for QlikSense if you want to stay with dotnet Core
like image 95
Piotr Stapp Avatar answered Oct 30 '22 10:10

Piotr Stapp


Disclaimer

This answer assumes ( as I can not discern any such details from the question ) that you already have your applications communicating, and are able to serialize and deserialize JSON and what you desire assistance with is the automatic sending of data on object update.

Use encapsulation to handle updates

By using c#'s class mechanisms, you can - make sure your "Sales" variable is only updated via your publicly displayed update method - the publicly displayed update method also sends the new data to your other application

class SalesContainer
{
    private string _sales;

    public string getSales()
    {
        return _sales;
    }

    public string updateSales (string sales)
    {
        _sales = sales;
        sendData(sales);
    }

    private sendData(string json)
    {
        // your sending logic here
    }
}

Alternatively, you can look a bit into operator overload to allow you to makes less changes on your existing codebase.

like image 34
Mister Amen Avatar answered Oct 30 '22 09:10

Mister Amen


I understand you have two applications. They cann't communicate with each other directly. You need a third-party mediation. A file, database, network stream, or MemoryMappedFile. QlikSense.NET application push update to mediation, and Bot Framework application read the update from mediation.

I think this is cross-process communication problemn, so each cross-process communication solution is feasible.

like image 45
YonF Avatar answered Oct 30 '22 10:10

YonF