Could I add C/AL code to restart NAS service automatically when user modify field in NAV?
How to get NAS status (start/stop) with C/AL Code?
Please help..
Thank you..
Hi Johanna
Try to solve this by organisation. This means changing objecs should not take place in production db, deploy by fob and restart nas after that. Person in charge of deploying should work with checklist. This is not exactly the answer to your question, but works in a lot of projects.
This is a great question!
I have 3 NAS's on three different servers. I would love to be able to stop/restart them from one place- one click.
Now I have to go to the 3 different servers and do each seperately.
How can we do this from within Nav?
Thanks
Good answer, but my question is still why somebody want to do this :?
because a developer has connected to nav trough his local client with a testdb running on a testserver somewhere.
Instead of loggin into the server and doing net stop/start because he changed the singleinstance codeunit.
|Pressing F1 is so much faster than opening your browser| |To-Increase|
The situation:
I am on my Dev machine
I am in NAV connected to the live DB
I import a fob to the Live DB
I want to restart my NAS's (which are on 3 seperate physical servers)
I have to individually connect to the first server
Open the application services
stop and start the NAS
disconnect from that server
connect the next server and repeat
I would like to press a button in Nav or on my desktop and have the process find each server
and stop and start the NAS
Mohana
Thank you for the commands (I presume they are run when on the specific server)
Can I run some variation remotely
How could I tell your commands what server each NAS is on.
I think this is what you actually are looking for:
sc \\computername stop NAS-SQL-ServiceName
Mix this with the C/AL SHELL function, and you control your services from Navision.
For me, I use a batch file from my desktop.
My NAV client is on a random citrix server, SQL and NAS both on their own dedicated machine (all VM'd). Your AD account requires the necessary permissions to stop and start services, tough.
When I want to test, I double-click the batch file om my desktop, resulting in:
And yeah, I've thought about ways to ensure the production NAS auto-restarts after it gets disconnected from the database after importing fobs, but this will require some kind of second 'guardian' service or scheduled task. Haven't got a reliable system worked out.
Thanks for the code.
I will try to put this in a Nav function with a call to SHELL or something and report back
I've not used it but there's an Automation component that shows up called "nascontrol 1.0 Type Library" with some interesting properties and functions. Maybe you could build something from that?
I have found the solution of this issue.
I add new variable Automation 'AutoWindowsScript': 'Windows Script Host Object Model'.WshShell
then add code in OnModify Table :
//STOP SERVICE NAS - START
CREATE(AutoWindowsScript);
AutoWindowsScript.Exec('NET STOP "Navision Application Server NAS"');
CLEAR(AutoWindowsScript);
//STOP SERVICE NAS - FINISH
//DELAY PROCESS - START
COMMIT; // Commit the changes to the database.
SLEEP(5000); // Release locks for a specified duration.
SELECTLATESTVERSION; // Retrieve the most current database version before the process is run.
//DELAY PROCESS - FINISH
//START SERVICE NAS - START
CREATE(AutoWindowsScript);
AutoWindowsScript.Exec('NET START "Navision Application Server NAS"');
CLEAR(AutoWindowsScript);
//START SERVICE NAS - FINISH
It's also possible to connect to another server via Application Server Manager SnapIn. That means you don't have to switch / logon to every single server. So, I see no issues.
"Money is likewise the greatest chance and the greatest scourge of mankind."
Answers
Try to solve this by organisation. This means changing objecs should not take place in production db, deploy by fob and restart nas after that. Person in charge of deploying should work with checklist. This is not exactly the answer to your question, but works in a lot of projects.
Hope this helps
Thomas
I have 3 NAS's on three different servers. I would love to be able to stop/restart them from one place- one click.
Now I have to go to the 3 different servers and do each seperately.
How can we do this from within Nav?
Thanks
So you can try by opening the command.exe using shell commands and execute above commands..
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
Instead of loggin into the server and doing net stop/start because he changed the singleinstance codeunit.
|To-Increase|
I am on my Dev machine
I am in NAV connected to the live DB
I import a fob to the Live DB
I want to restart my NAS's (which are on 3 seperate physical servers)
I have to individually connect to the first server
Open the application services
stop and start the NAS
disconnect from that server
connect the next server and repeat
I would like to press a button in Nav or on my desktop and have the process find each server
and stop and start the NAS
Mohana
Thank you for the commands (I presume they are run when on the specific server)
Can I run some variation remotely
How could I tell your commands what server each NAS is on.
Thanks
sc \\computername stop NAS-SQL-ServiceName
Mix this with the C/AL SHELL function, and you control your services from Navision.
For me, I use a batch file from my desktop.
My NAV client is on a random citrix server, SQL and NAS both on their own dedicated machine (all VM'd). Your AD account requires the necessary permissions to stop and start services, tough.
When I want to test, I double-click the batch file om my desktop, resulting in:
sc \\NAS-SERVER stop NAS-SQL_DevDatabase
sc \\NAS-SERVER start NAS-SQL_DevDatabase
And yeah, I've thought about ways to ensure the production NAS auto-restarts after it gets disconnected from the database after importing fobs, but this will require some kind of second 'guardian' service or scheduled task. Haven't got a reliable system worked out.
I will try to put this in a Nav function with a call to SHELL or something and report back
I've not used it but there's an Automation component that shows up called "nascontrol 1.0 Type Library" with some interesting properties and functions. Maybe you could build something from that?
I have found the solution of this issue.
I add new variable Automation 'AutoWindowsScript': 'Windows Script Host Object Model'.WshShell
then add code in OnModify Table :
//STOP SERVICE NAS - START
CREATE(AutoWindowsScript);
AutoWindowsScript.Exec('NET STOP "Navision Application Server NAS"');
CLEAR(AutoWindowsScript);
//STOP SERVICE NAS - FINISH
//DELAY PROCESS - START
COMMIT; // Commit the changes to the database.
SLEEP(5000); // Release locks for a specified duration.
SELECTLATESTVERSION; // Retrieve the most current database version before the process is run.
//DELAY PROCESS - FINISH
//START SERVICE NAS - START
CREATE(AutoWindowsScript);
AutoWindowsScript.Exec('NET START "Navision Application Server NAS"');
CLEAR(AutoWindowsScript);
//START SERVICE NAS - FINISH
Thanks all
Johanna