mibuso.com

Microsoft Business Solutions online community
It is currently Tue May 21, 2013 9:36 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 109 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Author Message
 Post subject:
PostPosted: Wed Aug 20, 2008 9:26 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8700
Location: 3rd rock from sun
Country: United States (us)
In that case just just run standard NAV Job queue for each company. And write record in the other company Job queue entry as in the above link and wait till it gets processed by NAS.

If posting errors then grab the error and you need to specify how you want to proceed.

Hope this makes sense.

One NAS for each company A and B (need to purchase One more NAS).

From Company A Write Order to Company B. Write entry into job queue entry of Company B. Wait for NAS to post in Company B. If successful then continue, else take appropriate action.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Thu Oct 02, 2008 11:21 am 
Offline

Joined: Tue May 06, 2008 2:56 pm
Posts: 350
Location: Walton-On-Thames
Country: United Kingdom (uk)
Oh I'd forgotten about this.
Okay, it's not difficult to make a NAS that hops between companies, and you only need one NAS and it works with 3.01B (this is when I tried it).

First you need the DLL that's used by the windows to configure the NAS.

Code: Select all
NasControl   Automation   'nascontrol 1.0 Type Library'.NAS_Control   


Next you need the service name of the NAS.

Code: Select all
NasName   Code      30


Then you just set it:

Code: Select all
CREATE(NasControl);
NasControl.ServiceName := NasName;
NasControl.put_NASProperty('company', "New Company Name");
NasControl.ServiceConfigurationChanged();

The NAS will switch companies when the current trigger exits.

Use an NFTimer as normal to get control back.

Code: Select all
NFTimer   Automation   'Navision Timer 1.0'.Timer

Timer.Interval := 500;
Timer.Enabled  := TRUE;
EXIT(TRUE);


If you want to log error messages use the error event trigger.

Code: Select all
NFTimer::TimerError(ErrorString : Text[1024])


Seems to be reliable, if a little slow.

_________________
Robert de Bath
TVision Technology Ltd


Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Mon Feb 02, 2009 12:38 pm 
Offline

Joined: Tue Feb 22, 2000 8:01 am
Posts: 911
Location: Glasgow
Country: United Kingdom (uk)
Might be useful as well.
Batch/CMD code to create NAS instanse "on-fly".

Code: Select all
@echo off
SET /P NAS_USER=Enter Windows account to start NAS:
SET /P NAS_PASSWORD=Enter user account password:

"C:\Program Files\Microsoft Business Solutions-Navision\Application Server\nassql.exe" appservername=<service name>, servername=<Native/SQL Server Name>, database=<databse name>, company=<company name>, startupparameter=<NAS Parameter>, installasservice
sc config <service name> start= demand obj= %NAS_USER% password= %NAS_PASSWORD%


Note about "sc" syntax. "demand" means "Manual" service start-up.
It weird, but you HAVE TO put "space" before parameter's value. Otherwise it will not work.

Later you just need to use "net start <service name>"/"net stop <service name>".

_________________
"Make everything as simple as possible, but not simpler."
- Albert Einstein

“A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.”
― Douglas Adams, Mostly Harmless


Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Mon Feb 02, 2009 3:46 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8700
Location: 3rd rock from sun
Country: United States (us)
Here is another solution using webservices.


viewtopic.php?f=32&t=31476

You don't need to purchase a second expensive NAS.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Tue Dec 08, 2009 4:57 pm 
Offline

Joined: Fri Jun 13, 2003 8:57 pm
Posts: 32
Location: Riga, Latvia
Country: Latvia (lv)
Hello, ara3n!
Thank you for your job. It really helped!
I have a problem, though. In case there are any quotation marks (") in company name, job fails. In fact, 2nd application server fails to start and Job Queue log contains an error with company name without quotation marks (see attached image). If company name is renamed (quotation marks are removed), everything works fine.
Of course, we can rename the company, if there is not the other solution. What would you suggest?


Attachments:
File comment: Lets say, company name is 'My "Test" Company'.
Then Job Queue Log Entry contains an error as follows:

NASErrorMsg.jpg
NASErrorMsg.jpg [ 36.46 KiB | Viewed 1350 times ]
Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Tue Dec 08, 2009 5:29 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8700
Location: 3rd rock from sun
Country: United States (us)
I would try and change the CU and add Double quotes to the Company parameter.

Change the code

Code: Select all
'company='                      + JobQueueEntry."Company Name" + ','+



to

'company="' + JobQueueEntry."Company Name" + '",'+

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Wed Dec 09, 2009 1:16 pm 
Offline

Joined: Fri Jun 13, 2003 8:57 pm
Posts: 32
Location: Riga, Latvia
Country: Latvia (lv)
ara3n wrote:
I would try and change the CU and add Double quotes to the Company parameter.

Change the code

Code: Select all
'company='                      + JobQueueEntry."Company Name" + ','+



to

'company="' + JobQueueEntry."Company Name" + '",'+


Hello. Adding additional quotes did not help. Anyway, we have already renamed companies, so the problem is not an issue anymore.

Yet we have another problem: everything works fine on Windows 2003 server, but on Windows 2008 server the 2nd application server hangs up - it never starts. I tried to test the functionality by starting codeunit 448 directly. In this case black command line window appears (which is run to start application server) and no further actions are performed. Job queue entries are not processed. What could be the reason?


Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Wed Dec 09, 2009 3:26 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8700
Location: 3rd rock from sun
Country: United States (us)
I haven't tested in windows 2008.
if you run the CU manually.


Make sure that this is where you installed NAS, If not change the string in the red section to the correct directory.

WindowShell.CurrentDirectory('C:\Program Files\Microsoft Dynamics NAV\Application Server\')
ELSE
WindowShell.CurrentDirectory(APPLICATIONPATH);
txtCommand := 'NASSQL servername=' + Server."Server Name" + ','+
'database=' + Session."Database Name" + ','+
'company=' + JobQueueEntry."Company Name" + ','+
'nettype=TCP,startupparameter=' + 'JOBQUEUE2|'+COMPANYNAME+'|'+FORMAT(JobQueueEntry.ID);
WSHExec := WindowShell.Exec(txtCommand);

Also manually from from command prompt try to start the NAS. AND make sure txtCommand is well formatted based based on your results.
Also see what APPLICATIONPATH returns in NAV on 2008. It should return the same directory where NAS is installed.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Wed Dec 09, 2009 4:14 pm 
Offline

Joined: Fri Jun 13, 2003 8:57 pm
Posts: 32
Location: Riga, Latvia
Country: Latvia (lv)
Thank you, ara3n, for your reply.

I have further testing results.
But first more information about environments:
Windows 2003 server - is our testing environment. As I've said before - everything works fine here.
Windows 2008 server - client's production system. The problem is on this environment.

So, I've decided to do the following on the client's environment:
1. I've installed application server on another computer, running win.xp and tried to run the functionality -> same problem.
2. Next, I've installed 2 separate application servers (2 services) - one server for each company - and have set up jobs in each company -> everything works fine.

Something wrong is in whole environment, the server is not the one rising issue, I guess. 2nd application server cannot be started by the 1st NAS.

ara3n wrote:
Make sure that this is where you installed NAS, If not change the string in the red section to the correct directory. WindowShell.CurrentDirectory('C:\Program Files\Microsoft Dynamics NAV\Application Server\')

Yes, I have already changed it. We have different directory: 'C:\Program Files (x86)\Microsoft Dynamics NAV\Application Server\'
ara3n wrote:
Also see what APPLICATIONPATH returns in NAV on 2008. It should return the same directory where NAS is installed.

Yes, that's correct. C:\Program Files (x86)\Microsoft Dynamics NAV\Application Server\

ara3n wrote:
Also manually from from command prompt try to start the NAS. AND make sure txtCommand is well formatted based based on your results.

I have copied txtCommand variable value from debugger and tried to start NAS manually. It started, although I had to add few quotation marks (") to startup parameter:
NASSQL servername=MYSERVERNAME,database=My Database Name,company=My Test Company,nettype=TCP,startupparameter="JOBQUEUE2|Master Database Name|{E0013D2F-B34B-48B6-8614-C761EB7F3041}"
The quotation marks I've added to code:
Code: Select all
'nettype=TCP,startupparameter=' + '"JOBQUEUE2|' + COMPANYNAME + '|' + FORMAT(JobQueueEntry.ID) + '"';


Any ideas?


Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Wed Dec 09, 2009 5:03 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8700
Location: 3rd rock from sun
Country: United States (us)
Check your PM.
I would need to look at 2008 server.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Thu Dec 10, 2009 10:57 am 
Offline

Joined: Fri Jun 13, 2003 8:57 pm
Posts: 32
Location: Riga, Latvia
Country: Latvia (lv)
I found where the problem was! \:D/
SQL server, DB settings: client had CS (case sensitive) database ](*,)
The main company, Job Queue jobs were run from, had lower and upper case characters in its name. When the company name was passed through NAS it has been converted to upper case. Then in codeunit (Run NAS Accross Company) the company was supposed to be fetched from "Company" table and the action could not be completed. Here is the code:
Code: Select all
IF NOT Company.GET(txtFromCompany) THEN BEGIN
  MESSAGE(txtFromCompany);
  EXIT;
END;

This type of error was not handled in portion of code analyzing NAS command promt output.

I changed the code in Codeunit "Run NAS Accross Company" as follows:
Function OnRun()
Code: Select all
IF NOT Company.GET(txtFromCompany) THEN BEGIN
  MESSAGE('Company was not found ' + txtFromCompany);  //Added constant text string
  EXIT;
END;

Function RunNasForOtherCompany()
Code: Select all
  IF STRPOS(Responseline,Text0003) <> 0 THEN BEGIN
    EXITNAS := TRUE;
    StandardError := TRUE;
  END;
  //Added >>
  IF STRPOS(Responseline,'Company was not found') <> 0 THEN BEGIN
    EXITNAS := TRUE;
    StandardError := TRUE;
  END;
  //Added <<


Of course, the company name has to be renamed in this case (or additional code has to be added to handle name conversion back to its original state).

Thank you very much, ara3n, for your help and the piece of functionality :thumbsup:


Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Mon Jan 04, 2010 5:32 pm 
Offline

Joined: Thu Sep 07, 2006 11:58 am
Posts: 471
Location: Mendrisio
Country: Switzerland (ch)
Hello,

I read the first posts. I am in this situation:
- I only have 2 companies A and B
- I actually have only 1 standard NAS granule
- I need to run a report that import data in company A reading from a text file (and this should go right with the NASSQL installation a 1 standard granule)
- I also need to run another report on company B alway for import data reading from a text file.

I ask you:
- this solution is not for me because I only have 2 companies and need to buy however the second NAS granule. Is that correct? I don't need unlimited company but only two.
- is it possible to use only first NASSQL connected to company A to run also the second report loading data on company B using something like CHANGECOMPANY or this is not recommented if I use for example validate functions? The report insert and modify data on table Customer.

Thank you


Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Mon Jan 04, 2010 6:08 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8700
Location: 3rd rock from sun
Country: United States (us)
On what version are you on?

If you are on 2009, I could offer a better solution.

Thanks.

you can also contact rdebath and look at his solution I haven't tried that one.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Mon Jan 04, 2010 6:17 pm 
Offline

Joined: Thu Sep 07, 2006 11:58 am
Posts: 471
Location: Mendrisio
Country: Switzerland (ch)
For this customer we have NAV 5.0 SP1

Thanks


Top
 Profile  
 
 Post subject: Re: Job Queue for Unlimited Company
PostPosted: Tue Jan 05, 2010 2:11 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8700
Location: 3rd rock from sun
Country: United States (us)
You will need a second NAS.
As you mentioned you can use changecompany but validation does not run in the other company.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 109 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: