cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

initialize FileRepository thing with multiple folders

drieder
16-Pearl

initialize FileRepository thing with multiple folders

Hello everyone,

 

I am writing a service in a thing called "getInitializedFileStructure"

 

There I want to create multiple Folders in a specific order for a fileRepository Thing.

 

The code goes something like this:

 

function addFolder(path){
var params = {
path: path
};
fileRepo.CreateFolder(params);
}

 

for(i = 1; i <= 5; i++){
addFolder("/" + me.name + "/Milestone" + i.toString());
}

 

I want to initialize the repository with the folders "Milestone 1 ... Milestone 5" in this order. It needs to be done via a service. The problem is, that with the current code the folders are created in a random order. I guess it has to do with the asynchronous charactersitic of the "fileRepo.createFolder" function. 

 

Any Ideas how to tackle that problem? Thank you very much in advance

 

Best Regards,

Dominik

 

Edit: An even better approach for me would be, if it was possible to create a new fileRepository Thing with some default folders

3 REPLIES 3

There's a checkbox called Async in Service Info field, enable it and see if that could help.

 

The Description mentioned "a separate thread will be created " for this service.

drieder
16-Pearl
(To:zyuan1)

Hi @zyuan1 , thank you for your reply.

 

unfortunately this did not work for me. When changing the type of the service to "async" the service suddenly returns nothing (or empty table)

So I found out that it probably doesn't have anything to do with the serivce being asynchronous...

When I use the "CreateFolder" Method of the file Repository, it creates the new folder in the first place of the parent folder. But sometimes it creates the folder somewhere in the middle.

 

I could not find out where this inconsistency comes from...

Announcements


Top Tags