hide or show an element on client with using signalR - asp.net

I'm trying to hide or show an element on the client by updating a parameter on db. Is that possible with signalR? Or is there any other way to do it?
Note: my application is based on asp.net core mvc (entity framework)

Asp.net core SignalR is used to create real-time web functionality, are you sure you want to achieve this behavior?
"hide or show an element on the client by updating a parameter on db."
For this question, it depends on how you want to hide or show the element, real time or just one time?
If you just want to hide or show the element when page load (one time per page load), you can query the database and get the condition (parameter from the database), and then use an if-else statement to hide or show the element.
If you want to change the element status real-time, you can use SignalR.
Create a scheduled task on the back end and trace the database parameter status, if the parameter changes, call the client method and show or hide the element.
Reference:
Background tasks with hosted services
How can I execute a method every year using BackgroundService in ASP.NET core Application?
Send messages from outside a hub

Related

Dynamic Flex Workflow in Studio

As part of my Twilio Studio flow I am using the HTTP request step to get data from an external database that responds back with the agent skill to be used when routing the call however I am unable to figure out how to use this variable in the send to flex step. Is it possible to dynamically set the workflow in the send to flex step from a variable?
I found the solution passing Json in the send to flex step and using filters at the workflow level.

IBM Worklight 6.1 wlCommonInit() behaviour

I want to know what is exactly the behaviour of wlCommonInit() function.
I have moved my initialization code into this function, but then it seems to be not called in the case of connection to the server failure.
is wlCommonInit() called when the Worklight server is not reachable ?
If I want to use direct update, I want to call WL.Client.updateUserInfo() on my initialization, and I want the app to be working also in offline mode, does this mean I must implement onConnectionFailure in wlInitOptions ?
If I implement onConnectionFailure in wlInitOptions, can I display the default popup that inform about the connection failure, and provide details ?
It really depends on the logic you wrote in your "initialization code" IMO. The question is somewhat cryptic...
The wlCommonInit function is called once the Worklight framework has completed initialization. If you set connectOnStartup to true, only if connection to the server is successful, it will then be called.
Direct Update is not related to any specific API you implement in your application. If you change any web resource in your project (HTML, CSS, JavaScript, images, ...), this will trigger a Direct Update in the application.
A Direct Update is checked in 2 scenarios:
on application launch, and
on return to the foreground (if the app was in the background)
The Direct Update check is performed only if and when the application connects to the Worklight Server. If you did not previously set your application by either using connectOnStartup:true or used WL.Client.connect or invoked an adapter procedure (all three send a request to the server), the Direct Update check will not be done.
If you choose to override the default dialog provided by Worklight by using onConnectionFailure, the Details button (which I assume if what you wanted) - is not available. By overriding, you select to fully customize it.

asp.net page wait others server side / asynchrone page

I created an asp.net page for waiting ajax. I have one page creating something that takes 30 seconds. On every step I change a session value.
I have another page for ajax, returning the session value for showing the percentage of creation. But, I dont know why, my ajax page awaits the end of the creation of my first page. So I only get the 100% at the end.
Maybe it's because I use VS development server and not IIS server. If this is the problem, can I change settings of the development server for asynchrone execution?
Or is it something else?
WebForms are not ideal for asynchronous operations.
Add SignalR to your project and use a Hub to push status data back to your page to update the current state of the process you are running Asynchronously.
An example of a technique to perform this type of asynchronous notification is covered in my blog post titled "A Guide to using ASP.Net SignalR with RadNotifications"
Don't use ASP.Net session state to do that. It has an implicit reader/writer lock around it, meaning your other call is probably blocking until your process finishes. You can try storing your status in a database or the cache, but it would probably be better to redesign the interaction.

post array of values to a http web service via ajax and read on asp.net web server

I am just wondering how to do this:
I have a page which shows some tabular data. On each row there is a checkbox. The user selects two/more checkboxes; my web page must find the corresponding ids of the rows which are checked. I must send this to the http web service. (basically a *.ashx file). I have two questions:
how will I access this on web server
how will my web server know the total no. of items I've passed. Must I manually send this to the server as a http post parameter?
what if the data I am sending is more complex like a person object which has fields like FirstName, LastName, etc. ?
I know I can use a asp.net web service or a wcf service with exposes a datacontract. But what is the best way to handle this without the SOAP overhead; what if you are sending all this data via ajax as a normal http post?
http://jquery.malsup.com/form/#getting-started might be worth investigating as a starting point.
In terms of your questions, the answers will partly depend on whether you are using MVC or WebForms. But in general:
If you use the above plugin, you will access it just like it was a normal form submit (post).
They will be populated into Request.Form.
This shouldn't be a problem. Model binding on MVC should handle this fine, I am not 100% sure of the equivalent on WebForms (you could always do it manually).
My suggestion would be to ignore the AJAX requirement for now. Get it working with a standard form submit (POST). Then come back and integrate the above plugin to enable AJAX.
1. How will I access this on web server
Using either postback (and a checkboxlist control), or handling POST yourself. GET wouldn't be appropriate for the task.
2. How will my web server know the total no. of items I've passed. Must I manually send this to the server as a http post parameter?
It will send back the value of each checkbox you have on the form, which will give you the total.
3. What if the data I am sending is more complex like a person object which has fields like FirstName, LastName, etc. ?
You could use Viewstate for this, or just re-assemble the objects on the server. Typically this means putting an ID in the checkbox value for the person each checkbox represents - you don't need to send back every piece of information about the object.
What is the best way to handle this without the SOAP overhead; what if you are sending all this data via ajax as a normal http post?
jQuery and JSON would be the best solution for this, if you want side step the built in ASP.NET ajax controls. As suggested, jQuery is the simplest Javascript library for the client side part of the task - you'll need to use $.post

How to access log information for ColdFusion server in Flex

I have Flex front end talking with ColdFusion as the back end. I have to debug my application and need to:
Add log support to ColdFusion where I can add my custom messages to log list
Access this log at Flex end.
Is it possible? Has anyone tried it before? Please help me with your suggestions ideas on this.
My recommendation :
Flex-side :
Create custom LogEvent objects that carry an id, a message, any other properties you want to log.
Dispatch those events whenever you want to Log an action or system event that occurs
Create a LogManager that's in charge of catching these events, and using a Delegate to make a ServiceCall to your ColdFusion services
ColdFusion :
Create a Logging service with APIs for listening for any service-calls from the Flex application
Save these log events into your database
Create a service that the Flex app can call to retrieve LogObjects (or whatever DAO you want)
Flex :
Create a LogView (a datagrid / advanced data grid with a column for every log property you want (essentially a mirror of the database log entries)
Create a delegate that your LogManager can use to call that Coldfusion Log Service to retrieve these Log Objects
I'm not sure if you're using a framework (Cairngorms, SWIZ, etc.) so my description of these objects is a little more abstract that you could do it all custom, or put it into your existing framework.
I've done this before, for AnalyticsEvents for GoogleAnalytics (worked with ExternalInterface) and with LogEvents for USER actions and SYSTEM actions.

Resources