WPF Powershell App Hangs on Invoke-PowerBIRestMethod - wpf

I have created a Powershell WPF app using XAML and within my app I allow the user to create a Power BI Streaming Dataset within a particular workspace that they authenticate to beforehand using Connect-PowerBIServiceAccount. The user clicks a button that is connected to an event and immediately Connect-PowerBIServiceAccount is fired, which triggers a Microsoft OAuth login and assuming the user is authenticated everything runs perfectly fine. However, the step immediately after involves making a Post request with Invoke-PowerBIRestMethod using the parameters passed in from my WPF inputs the user filled out. At this point, my WPF app freezes and it appears that nothing has happened, but when I check powerbi.com I can clearly see the dataset has been created.
It seems to me that for whatever reason a response code of 201 is not being returned to my WPF app. I have my powershell window open and can clearly see no response once the post has been made. Is this a synchronous issue that specifically related to firing a post request inside a WPF app on button click?
Edit: I just realized that when I close my WPF app, I can see the response code in my Powershell console so it is definitely something on the WPF side blocking the response.

I was able to figure this out by reviewing other posts on SO of individuals who had similar issues making API requests with their C# WPF Apps. I am not 100% sure why a response is not returned to the WPF app so it can continue on, but from what I read it has to do with a button event handler being a synchronous call and since a 201 response is never received, it just holds the application frozen until a user closes it down. I was able to do the powershell equivalent of C# multithreading by invoking a command as a powershell job making the call async. It is still odd to me because the call itself to post the dataset to powerbi is very fast.. I could understand this issue if the response was slow, but it seems like the response never came, which is what I found so odd.
Code:
Start-Job -ScriptBlock { param($body)
Login-PowerBIServiceAccount #even though this is an async call, start-job fires off a thread locally so we can don't need to store credentials and pass them to the following command as that is done automatically.
Invoke-PowerBIRestMethod -Url 'myEndpoint' -Method Post -Body $body -Verbose #-Headers $PBIToken
} -ArgumentList $body

Related

Not able to create events using Microsoft Graph SDK

I am trying to create an Event using Microsoft Graph SDK, as following the document #
https://learn.microsoft.com/en-us/graph/api/user-post-events?view=graph-rest-beta&tabs=csharp
1.Created "authProvider"
2.Created GraphClient with above AuthProvider
3.Creating Event using
The event is not creating also no exception/error is throwing, Could any one help me here?
This is happening because this call is being made with same transactionId frequently. It avoids unnecessary retries on the server.
It is an optional parameter , just comment out this property and try again. It should work.
Note : This identifier specified by a client app for the server , to avoid redundant POST operations in case of client retries to create the same event and also useful when low network connectivity causes the client to time out before receiving a response from the server for the client's prior create-event request.
More info is required here, as the reply from Allen Wu stated. without any details I would focus my efforts on the authprovider piece and azure app registration piece. as the rest of the example is just sending a post request to graph api.
but what is recommended really depends on what type of application you are trying to build. eg. is it a service daemon, a web app, mobile app, desktop app, single page app, etc.

Logic apps logs in application insights

Can I send traces(input/ output) of all actions/steps executed in my logic app to any application insight?
Is there an out of box provision for the same?
So far it still seems its not possible to post events or traces to events log directly from Logic App actions.
However, have a look this article here:
https://jlattimer.blogspot.com/2018/03/log-to-application-insights-from.html
It's easy enough to post trace or event to a API endpoint from a Logic App.

How to verify events fired when a button is clicked using selenium?

I have a selenium suite that runs on our user interactive website. Our company also tracks the event that are fired when a user interact with an input field (such a numeric input or slider) on third party such as google analytics. I am trying to verify the events fired when a user clicks on a button on a page. Is there a way, selenium can track that event in console and verify it?
There are 2 approaches that you could take in order to achieve what you're looking for:
Parse WebDriver's logs and get required info from there, here is an example on how to get them from chromedriver: https://sites.google.com/a/chromium.org/chromedriver/logging/performance-log - please note that for, for example, firefox - capabilities would be different, also you won't be able to get response codes and response time, only basic info.
Create proxy, configure wd to use it and capture traffic using proxy, one of the solutions is called BrowserMob proxy. Once traffic goes through you may get Har file from proxy and get all the data from there. Har captures all the data you may need: request, params, response code, response timings.

DevExpress - Show Alert Window for all users in app

We've got a program that runs on our network (it's published to our app-server and run from there as well) and I'd like to show an Alert window (by DevExpress) to all users who are running the app, whenever a new item is entered. Obviously the code would go in the Save event but when I put it in there, it only works for me, meaning I'm the only user who sees the alert, no one else. The same can be said for other users...they only see the alert when they enter it, not when someone else enters it.
Any ideas as to how this can be accomplished?
You can use straight MSMQ to put on a message and have clients listen on that queue. You can also use NServiceBus (which does use MSMQ) that has a publish subscribe framework built in. This way your clients can subscribe to all clients or certain clients.
Since WinXP, Vista and Win7 have MSMQ it just maybe a matter of installation and configuration (which NServiceBus will do 'automatically' for you)
You could try with Comet if you want true push mechanism. Otherwise you could use periodical pull using setInterval and ajax calls. However, both techniques have some performance repercussions.

Loading thread for Windows Form Application?

I am currently developing a windows form application as the subscriber for my WCF service and a asp.net application as the publisher for the service.
Whenever I launch the service or the client, and attempt to "Connect" (AKA subscribe) to the service, it would take awhile to load before it displays a successful message or exception handling. And while the thing "loads", the windows form sort of "hangs" temporary until the thing loads finish.
Is it possible to create a loading effect while they are "loading" to feedback to the user? Anyone can guide me on how to actually start developing this effect.
Thanks!
You can use asynchronous service calls. Before calling the asynchronous call you can show graphical representation of this and in the completion of the asynchronous call you can stop displaying the progress of the call.
Refer to this link to know how you can call the wcf service asynchronously.

Resources