Is it possible to create a plug-in in the Dynamics CRM 2011 online that calls a WebService every 30 seconds, and does this all day long?
In a normal application, I would create an infinite loop with a Thread.Sleep(30000) inside, but Dynamics CRM online does not allow this. The CRM online kills my plug-in after 2 minutes.
Is there a way to achieve my goal? Maybe some kind of timers, system jobs or workflows?
From what I found on the internet, a workflow calling itself from time to time only works if there is a pause of about 70 minutes between calls; otherwise, CRM will consider this an infinite loop and kill it after 6-7 calls.
No. Both of the limitations you've found are true. If you need to run something every 30 seconds, you'll have to find somewhere external to run it.
Related
When user registers, an email is sent to user after 20 seconds. Is this possible to code with sleep() in moodle.
sleep(20);
if (!send_confirmation_email($user)) {
print_error('noemail','core_email');
}
The sleep will be fairly poor UX and block the session. An adhoc task is the right way to go as DerKanzler said.
As of https://tracker.moodle.org/browse/MDL-66925 you can run the adhoc tasks in keep alive mode and they will process continuously as a psuedo daemon:
php admin/cli/adhoc_task.php --keep-alive=60 --execute
If you still wanted the email to be sent roughly 20 seconds into the future, when you use the Task API to queue the task you can set the future time that it should run:
https://docs.moodle.org/dev/Task_API#Set_a_task_to_run_at_a_future_time
Either way this sounds like a terrible idea to force a user to either way in their browser for 20 seconds, or to wait reloading their email client for 20 seconds. I'd strongly recommend against it.
If you want to do it the 'hacky' way and patch some core files sleep(seconds) is indeed the easiest way to go.
If you are writing a plugin, you can have a look at the Task API, especially at defining AdHoc Tasks. Though this will not execute until your cron job is fired. So you would have to lower your cron execution time limit. Besides that there is currently no option to do this with the moodle API.
I have an MVC web site, a storage queue and a WebJob. Users can request the generation of a set of reports by clicking a button on the web page. This inserts a message into the storage queue. In the past, the WebJob ran continuously and processed those requests fine. But the demand and size of the reports has grown to the point where the WebJob is slowing down the web app. I would like to still place the request message in the queue, but delay processing of all requests until the evening, when the web app is mostly idle. This would allow me to continue using the WebJob code and QueueTrigger functionality without having to waste resources by moving to a dedicated Worker Role, etc. The reports don't need to be generated immediately, so a delay is acceptable.
I don't see a built-in way to set a time window on processing. The only thing I have found is a powershell cmdlet for starting and stopping WebJobs (Start-AzureWebsiteJob / Stop-AzureWebsiteJob). So I was thinking that I could create a scheduled powershell job that runs at midnight, starts the webjob, lets it run, and then runs again early in the AM and stops it.
Does anyone know of a better option than this? Anything more "official" that perhaps I could not find?
One possible solution would be to hide the messages in the queue for a certain amount of time when they are inserted.
If you're using AddMessage method, you can specify this timespan value in initialVisibilityDelay parameter.
What this will do is ensure that the messages are not immediately visible in the queue to be picked by WebJob and will become visible only when this timespan elapses.
Will such a solution work for you?
Maybe I didn't fully understand your question, but couldn't you use "Triggered" WebJob that is triggered by CRON schedule? You can then limit it to specific hours
0 * 20-22 * * *
This example will run every minute from 8pm to 10pm
Microsoft word allows us to add datetime stamp which will update datetime and sync up with system datetime. I am looking for a similar item. Is there a countdown item available?
Usage: When I send a document to my colleague I mention this event will happen in 5 minutes.
Ex: I will kick the build in 5 minutes.
I am trying to express the same in the following way
Build will happen in 5:00 Minutes
after a second
Build will happen in 4:59 Minutes
after five minute
Build will happen in 0:00 Minutes
or
Build happend
Does MSword capable of doing this?
Thanks,
Esen
There is no count down timer control kind of thing available. You have to write a macro to do that for you. Even if you use macro, unless the receipt user enable its content he wont see it. I would suggest use a javascript and send email with html body
Is there any way to increase the maximum time that a plugin can execute for?
It's 2 minutes by default. I found that here.
The limit is there to help protect the performance of the server, so the correct approach here is to re-engineer your solution (e.g. move your intensive logic out into a workflow or a web service and call it asynchonrously).
I'm not aware of any setting, flag or registry entry that will extend the two-minute timeout, though if you must persevere, you may find it possible to fudge a solution by wrapping your logic in a try/catch block, catching System.TimeoutExceptionand continuing your code. Maybe (untested).
I'd like to add that it seems that the time limit only applies when a plugin is registered in a sandbox / partial trust mode.
We had this kind of an issue and solved it by registering the plugin in fully trusted (non-sandbox) mode. I verified this by using Thread.Sleep function to wait 2 minutes before even starting to executing any plugin logic. In total almost 4 minutes were spent but the plugin still managed to do well when in non-sandbox mode. In a sandbox mode it threw us a 2 minutes exception.
According to E-learning material from Microsoft sandbox plugins in CRM 2013 has only 30 seconds limit instead of 120 seconds. I haven't tested that out yet.
I am new in Powershell but not to programing
I have created a form to monitor web server availablility
I used Primalforms 2011 which is quite good.
The script works fine and the result is as expected.
The next step is to continuously check the webservers at a 10 minute interval.
My question is how can I achieve this from within yhe Powershell form.
I can create a another script to call the script every 10 minutes but that is not a smart way(IMHO).
What I would like is to call the Webcheck function every 10 minutes from withing the form, check the pages and update the status accodingly.
Is there some documentation on how the Poweshell form intenals work or is it trial and error?
It is per se possible.
Look at the asynchronous event handling in PSH2: the help for Register-ObjectEvent includes an example with a timer.
(A web search might be able to find a fuller example of PowerShell + GUI + Timer. Eg. http://www.sapien.com/blog/2011/08/09/primalforms-2011-spotlight-on-the-timer-control/)
Not an answer per se but personally I prefer a monitoring solution to be more than a GUI running on a machine. Of course it depends on the requirements\SLA of what you are monitoring and a GUI only solution has many advantages.
Having some form of scheduling software running a script that updates a datafile or database and then have a GUI read that would be my preferred way.
You could do it on a simple level with windows scheduled tasks. If you don't want to use a database you could use Export\Import-CliXML for very quick and easy data storage. Have the GUI check for a new\updated file every X minute(s) and load it if it's new.
Something I've done when using Sapien is to write all my functional code in PowerShell modules and have the GUI call the modules cmdlets. I like the idea of keeping the display different from the functionality - like MVC in web dev. It's very useful if you want to reuse the function from a script.