Hosting a Workflow in an MVVM application - mvvm

I'm designing a MVVM application that does not use WPF or Silverlight. It will simply present web pages in HTML5, styled with CSS3.
The domain is a perfect case for using WF because it involves a number of activities in a long-running process. Specifically, I am tracking the progress of interactions with a customer over a 30 day period and that involves filling out various forms at points along the way, getting approvals from a supervisor at certain times, and making certain that the designated order of activities is followed and is executed correctly.
Each activity will normally be represented by a form on a view designed to capture the desired information at that step. Stated differently, the view that a user sees will be determined by where she is in the workflow at that moment.
My research so far has turned up examples where the workflow is used to execute business logic in accordance with the flowchart that defines it.
In my situation, I need for a user to login then pick up where she left off in the workflow (for example, some new external event has occurred and she needs to fill out the form for that or move forward in the workflow to that step.)
And I need to support the case where the supervisor logs in and can basically be presented with activities that need approval at that time.
So... it seems to me that a WF solution might be appropriate, but maybe the way I want to use it is inverted - like the cart pulling the horse so to speak.
I'd appreciate any insight that anyone here can offer.
Thanks - Steve

I have designed an app similar to yours, actually based on WPF, but the screens shown by the application are actually driven by workflows.
I use a task-based approach. I have some custom activities that create user tasks on a DB. There are different type of tasks, one for every different form type that the application supports. When the workflow reaches one of these special activities, the task is saved to DB and the WF goes idle (bookmark).
Once the user submits the form, the wf is resumed up to the point where another user task is reached and so on.
Tasks can be assigned to different users along the way (final user, supervisor, ..) and they have a pending tasks list where they can resume previous wf instances, etc.
Then, to generate user views (HTML5 forms in your case) you have to read the pending task and translate that into the corresponding form.
Hope you find it useful

Related

tabbarview with children tab with many tabs becomes slow to load in home page leads to black screen

body: TabBarView(
children: [
Home_G_HX(),
Physical(),
Text("1"),
],
),
Home_G_HX and Physical have many widgets so home screen loading becomes slow
The most effective method to Create a Chatbot Using DialogFlow ?
What is DialogFlow ?
DialogFlow is an improvement stage made by Google that can assist us with making Chatbots. It depends on NLP (Natural Language Processing) which offers our chatbots the likelihood to be extremely strong.
What is the ChatBot ?
A chatBot is a keen program that can cooperate with individuals like a human and serves them in the particular space where it has been made. The chatbot examines the expectation of the client and investigates the reaction that will be more adjusted.
Presently you understand what DialogFlow and chatbot are, we should perceive how we can make a chatbot utilizing Dialogflow.
Note: You ought to have a google account and login in to the Dialogflow stage prior to following these means.
In this article, we will make a chatbot that can serve clients who will believe should do a booking for a room in a Hotel.
Stage 1. Make an Agent
An Agent is a smart program inside the chatbot, that program interfaces with the clients or clients.
To make an Agent, go to the left segment of your screen and snap on the main button underneath the Dialogflow logo and go down to the make new specialist button.
From that point onward, the new screen will be stacked, and you will be request to indicate the name of the Agent, the language that it ought to be talk and the time region. As far as I might be concerned, I type reservation-bot for the name and the rest, I leave the default values. From that point onward, you should tap on the CREATE button and DialogFlow will make a specialist for your chatbot.
Stage 2. Make plans
Purposes is use by the chatbot to comprehend what the clients or clients need. It's inside the goals that we ought to give to the chatbot the instances of expressions that the clients might ask and a few reactions that the chatbot ought to use to pay all due respects to the clients. We should demonstrate the way that we can make it happen.
Note: When we make another specialist, it accompanies two defaults aims named Default Fallback Intent and Default Welcome Intent
For make another Intent, click on the Create Intent button
From that point onward, you should give the name of your goal. Then, at that point, go to the Training Phrases segment and snap on add preparing phrases. This part concerns the way where you ought to give the case of the expression which addresses the various inquiries that clients might pose to the chatbot. we prescribe giving numerous guides to make your chatbot extremely strong.
For this model, you could accept similar expressions as me.
We have added a few expressions that clients might ask to our chatbot, for your own chatbot, go ahead and add one more expression to work on the force of your chatbot
In this picture, we can see that two articulations are overlined. DialogFlow has recognized these articulations as a substance, truth be told. DialogFlow perceives three kinds of elements like frameworks substances, engineer elements, and meeting substances. this evening and today are perceived as frameworks elements, it alludes to the date or timeframe, this kind of substance is now set in Dialogflow. Later we will make our own elements which will perceive by DialogFlow as Developer substances. For more data, look at this documentation
Presently, we should characterize a Responses that the specialist might use to pay all due respects to clients. Go down to the Response segment and snap on the Add reaction button, and add a few reactions explanations.
Moving Bot Articles:
How Conversational AI can Automate Customer Service
Robotized versus Live Chats: What will the Future of Customer Service Look Like?
Chatbots As Medical Assistants In COVID-19 Pandemic
Chatbot Vs. Clever Virtual Assistant — What's the distinction and Why Care?
You can see that inside these reactions models there are a few articulations that beginning with the $ image, these articulations are considered as factors that will contain the qualities that clients will make reference to in their inquiries, and that DialogFlow will have perceived as a specific substance. On the picture above, we have three factors, for example, $time-period, $date-time, and $reservation-type. $time-period and $date-time are frameworks substances factors and $reservation-type is a Developer element variable, and that implies $reservation-type ought to be made by the engineer, before that DialogFLow might remember it. After added a few reactions that the specialist ought to utilize, click on the Save button, we will return from this point forward.
Stage 3. Making of substances
In all actuality, substances are catchphrases that assist the Agent with perceiving what the client needs. To make it, simply follow me.
Click on the Entities button
production of substances
After click on the Create Entity button
formation of element
Later, determine the name of the element (you ought to give reservation-type as name of your substance, since you have use it as factor when you gave a few reactions to the specialist). Then, add a substance bed-room and a few equivalents like beneath.
try to check the case Define equivalent words previously, and afterward click on Save button.
The job of equivalent words is that, when clients ought to discuss bed-room, bed or room, all of this ought to allude to the bed-room.
Do likewise with the element reservation-activity and save it.
formation of reservation-activity substance
Presently, we have two elements fit to be utilized.
Stage 4. add our substances inside preparing phrases articulations
back to the booking aim interface and go to the preparation phrases segment.
At the point when you are there, select an articulation, and inside this articulation select the word bed-room like this
Then, at that point, research for #reservation-type
What's more, click on this, and the shade of bed-room will change.
Do exactly the same thing to all the bed-room inside all articulations.
For the words booking, reservation, and save, do exactly the same things however rather than research #reservation-type you will explore #reservation-activity.
adding developper elements inside our preparation expression articulations
Stage 5. Meaning of boundaries and activities
It's not needed, yet now and again, it will be vital to commit the client to provide for the chatbot, some data.
Go down to the Actions and boundaries segment, consistently inside the booking expectation interface. you ought to have this picture underneath.
activity and boundaries
For our chatbot, we need that clients give the booking type and the date of the reservation. Make a point to really look at it.
activities and boundaries
From that point forward, we ought to indicate the brief text that the Agent ought to show to the client when they haven't determined the necessary boundaries. You want to tap on the Define prompts… space on the ideal locations of this segment, in the wake of characterizing brief text, close the container discourse.
for the date-time boundary
characterize brief text for date time boundary
for the booking type boundary
After this, save the plan.
Presently you can test your chatbot.
test segment
You can test your chatbot here.
Stage 6. Coordination on the web stage
reconciliation
Click on the reconciliations button
You can incorporate your chatbot within numerous stages, as Facebook courier, WhatsApp, wire, etc.
For this article, we will pick the Web Demo
coordination demo
click on the connection, and test it once more.
You can use DialogFlow from Google, Luis/Bot-service from Azure etc for cloud based solutions or Rasa-Ai for simpler on-prem solutions. So to get started, build a simple Flutter app that has a text box where you can type something. Once you type, let the content flow to server via an explicit submit button for instance and let the NodeJos server ( or any server ) return you a random message. This is your first phase. You then need to replace the request-response scheme with a chatbot.
An example of a bot using Azure system can be found here: https://github.com/pawanit17/EventBright
Another example that uses socket.io based communication to the clients can be found here:
https://github.com/pawanit17/LetsChat-A-Simple-WebSockets-Chatting-App
Experiment with them.

Occasionally connected CQRS systems - Client and Server Commands - Task based screens

Premise:
It is recommended that in CQRS+DDD+ES style applications use task based screens, these screens guide the user and capture intent.
These task screens can also be referred to as Inductive User Interface. Some examples of UI design guidelines that can help you create mondern, user-friendly apps:
Microsoft Inductive User Interface Guidelines and,
Index of UX guidelines
The way I understand it, the tasks, generally speaking, should line up with Commands or Functions waiting on the Server.
For example, if the User makes a change to the Customer's [first name], generally speaking this should be an isolated task where a pop-up window or the like provides a mechanism for this event, and this event only.
Questions:
Part-1:
In the situation where the User is not just making a change to a Customer's [first name], but actually creating a new Customer. Surely the User will not go from [first name] => to [last name] => to [address] => to [email], etc. -- in a wizard like style, where each wizard screen maps to a Command.
a) How are the screens laid out when it's just not practical to isolate a single task? For example when creating a new Customer or Inventory Item.
b) What does the code and/or logic flow related to the Commands look like on the Client and Server in this situation, keeping in mind the obvious pull to stay consistent with the "normal" task based flow of the rest of the system? After all, these all just translate to Activities or Events in the Event Source.
Part-2:
What if the User is not just making a change to a Customer's [first name], but their [last name], [address], and [phone number] -- all the while they User is off-line.
I think ultimately, the User should still be able to do real work on multiple tasks in different areas of the application, while off-line, and perform robust conflict resolution when coming back online.
a) What is the code and/or logic flow and/or artifacts related to the Commands on the Client side while the User is off-line while handling these events locally (IndexDb, queues, etc.)? and
b) What does the connection look like and how does it act when off-line (retries)?
c) What is the code and/or logic flow and/or artifacts related to the Commands on the Client and Server side, when the User comes back on-line?
d) What does the connection look like and how does it act when coming back on-line (reestablish of connection, if it is determined that the Client side ViewModel is stale, WebSockets, etc.)?
Reference diagram:
The way I understand it, the tasks, generally speaking, should line up with Commands or Functions waiting on the Server.
Or sometimes events, but the basic idea is right.
Surely the User will not go from [first name] => to [last name] => to [address] => to [email], etc. -- in a wizard like style, where each wizard screen maps to a Command.
No, we usually want a coarser grain than that. Some tasks do only require a single property, but several properties is a common case.
How are the screens laid out when it's just not practical to isolate a single task?
By grouping together cohesive units; consider the Amazon order workflow -- there are actually several different sets of data collected (the order itself, the selection of payment, specifying new methods of payment, specifying the delivery address, specifying the shipping priority....).
all the while they User is off-line.
See CQRS, not just for server systems; but in broad strokes - treat the data collected from the user as events (FormSubmitted) rather than commands. The offline device is the authority for tracking what the user did while off line; but the unavailable server is still the authority for the consequences of those events. So the server is responsible for the merge when the client reconnects.
The precise details might vary from one domain to another -- for instance, in a warehousing system, where the offline device has been collecting information about inventory, you might handle the inconsistencies that the server observes during the merge by raising exception reports (the device registered this package leaving the warehouse, but we have no record of it entering the warehouse).

Where to put my application logic when using Entity Framework and MVVM

In the last days I spent a lot of time creating the architecture for my program, but still have a problem with it. At the moment it looks like this:
DataLayer: Here my context class which derived from DbContext and the mapper classes which derived from EntityTypeConfiguration like JobMap for the Domain objects reside
DomainLayer: Here my domain/business objects like Job or Schedule reside.
Presentation Layer: Here I have the *ViewModel and *View classes (I use WPF for the views)
Now to my question: I want to build a scheduling application with some optimization abilities (it is a single user and single pc application so no further decoupling like web application is needed). But I have the problem that I don't know where this application fits into this architecture?
Considering the following use case: The user clicks a button "Start" on the View which calls the ViewModel which redirects to my scheduling/optimization application. This app then gets all the new jobs from the database and creates/updates the current schedule. The ViewModel should then update the old schedule with the new created one. Finally the View shows the generated schedule to the user.
In this case my ViewModel knows about my application (because it calls it) and about my domain/business objects (because my app will deliver e.g. a Schedule domain object, which the ViewModel encapsulates).
Is this a correct usage of the EF, MVVM and my application?
Regards
To start, you'll want to identify which pieces of your application go where, and that's fairly easy to do. Essentially, you have to ask yourself: Does this method or class help define my domain. If the answer is yes, you put it in the domain layer, and if not, you'll put it in presentation.
Here's how you'd look at it in your example:
Your Presentation layer (PL) receives a message via the start
button.
The PL calls the Domain and tells it to generate a schedule. This call is probably to a domain service.
Your domain service is then in charge of populating the Job domain objects, creating a new Schedule domain object (or modifying an existing one), and returning the Schedule domain object.
Your PL then simply displays the returned Schedule.
This might be different if you just wanted to obtain an existing Schedule object. Instead of calling a domain service, you would ask a domain repository to get the existing schedule. The repository would be the way of encapsulating or otherwise obscuring the data layer from your PL and from your Domain.
Now, what you DON'T want to do:
Do not get the list of jobs in your PL, and then use that list of jobs to create the schedule in the controller of your MVVM. This would be business logic that defines your domain.
If Schedules are commonly generated from Jobs, regardless of whether it's called from MVVM or a PHP site, then don't add complexity in your PL and Domain Layer by forcing the PL to first get the jobs and pass them back into the Domain for a Schedule to be generated. The fact that those two concepts are tied to each other means that the relationship helps define your domain, and thus belongs in your domain layer. An exception might be when both the jobs and the schedule to be modified both rely on context from the front end (user input), but even this isn't always an exception.
Do not pass in VMs to your domain. Let your controller filter out the data and determine what needs to be sent to which domain part.
It's really hard to give a precise detail of what you should place where because only you would have a clear view of what defines your domain, but here's essentially how I break it down:
Could I change/replace this without affecting how my business/domain works?
If the answer is yes, it does not belong in your domain. Example: You could replace your entire MVVM front-end to flat PHP or ASPX, and even though it'd be a lot of work and a huge pain, you could to do it without affecting how the rest of the business operates.

In RESTful world, how does next allowed action returned back to UI in a workflow based application

We have a workflow based application where a given process move from one state to another state based on User action.Currently our requirement is to have UI displayed its current state and allow user to take next action steps.So my question is does generally server tells UI the next actions that can be taken or the UI should decide based on current action? This application is designed using RESTful webservices.
The server should provide the client the next allowed actions, also known as state transfers, using links. Those links should, at least, contain two pieces of information: URL and relationship. The relationship tells the client the meaning of the state transition, allowing to recognize what it will do. The URL only says where to locate the service.
Typically, a REST web service should be ignorant of client state. It should only provide the ability to retrieve and update data based on a specific url (you may want to read up on REST). If you are following these guidelines, then the UI should drive any logic regarding the state of a workflow or record.
The hypertext returned provides the next "possible" transitions in the form of 'links' to the "resources". The client/user selects the next transition.
REST APIs must be hypertext-driven may be a good read!

How to programmatically create a new version of a CQ5 page?

Is it possible to programmatically create a new version of a CQ5 page that has a start time some time in the future?
As an example, let's say we have a page that displays tax rates. We have a component that allows the author to upload a new rates table (in the form of a css file) and it creates the rates page content. We would like to allow the author to upload rates that will be effective the first of next month.
I know the jcr supports multiple versions of nodes, but its unclear how (or whether) this relates to cq5 page versioning. And, further, whether a new version can be activated in the future.
Given the requirements as you've described them, I would probably accomplish the task in a slightly different way...
Instead of storing my rates table information directly within the page's jcr:content node (or a sub node their of) I'd probably abstract it out to somewhere else in the repository. You could then, if you so desired, create some sort of an admin interface to allow content authors to upload their csv file of new rates, and ingest that into the repository as needed. Alternatively, assuming that data comes from some sort of a database, you could probably just write a job to automatically injest it on some sort of a scheduled basis by using a JDBC connection from CQ. Once the data is in the repository, you could then write the display component to read the data from the repository, instead of it being directly inside the page.
This approach has the advantage of making that data re-useable within CQ to be shown on multiple pages, multiple sites, even many different display formats if need be. In addition, you can design your jcr structure to support whatever requirement you have around updates to the data, including daily, monthly, weekly, yearly etc., obviously this will depend on the specific requirements.
The one downside to this is that since there is a separation b/w the data and the page(s) where it is displayed, you may need to find a way to ensure the cache is properly cleared whenever the data does change.
Update (based on your comment):
The problem I foresee with versioning the page, and granted I've not tried this so maybe it will work, is that there can only ever be one active version at a time. Therefore, once the next months data is uploaded, you need to maintain the old data (active) and the new data (not yet active) at the same time. What happens if you require a separate content change during that window...from a business process perspective that just seems messy to me.
Back to cache clear issues, If you know the affected pages, especially if they are all in one subtree, you could write a custom workflow process that uses the replicator service to clear the cache for the affected pages, then set up a launcher to run the wf on node change for the data.
The other option, and this one is less defined in my head, so some experimentation required, would be to use CQs built in activate later and de-activate later functionality.
Maybe create a specific template for the rates data, with the implicit requirement that only one page using that template is ever active at one time. Your display components could use a query to find the currently active rates data.
I have not personally tried this, but...
I assume that you can use the PageManager service's createRevision method, and then if that returns without throwing an exception, you may call page.getContentResource.adaptTo(Node.class), and from there take the node that is returned and edit the JCR properties for your tax rates component.
See PageManager
You could write a workflow that includes a publish step that is triggered by the arrival of a calendar date. The version of the page with the new tax rates remains in the workflow pipeline in draft form and is only published/activated when the date arrives. (So you'd need some sort of process that wakes up once a day to check the calendar.)
Each time a page is modified cq creates a version of the page.
This modified page's modification time is set in jcr:lastModified property of the page.
Manipulation of this property can be done to save future date and activate page on that date though its not preferred way.
You can store the future date as a property in the page.
Later as suggested by #David you can create a workflow or a scheduled job which activates pages with a future date.