Developer forum

Forum » Development » Deployment question in regards to Items - dev to live

Deployment question in regards to Items - dev to live

Jan Sangill
Reply

Hi,

I have a site where we use Azure pipelines to deploy with.

In regards to items we have it at the moment to sync with "Files".

When a new file is deployed to live in items - for it to be updated in databse and created there - I need to manually at the moment go in and press "Save" on the item itself.

Any ideas how to handle this dynamically - so when a Itemtype is deployed or altered - then the database syncs itself with the new iteminfo?

All thoughts and ideas are welcome. Perhaps I am even missing something simple. Please let me know then:)

//Jan

 


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Jan,

We're exploring ways to improve the experience with deployment, but I don't have anything to share at the moment and it's most likely going to be DW10 specific.

Specifically for your case, I don't think there are any easy fixes, but a solution could be to create a notification subscriber that listens for AfterStart and creates a FileSystemWatcher for the Items folder. When it sees a change, it could perform the Save action programmatically. This will only work if you deploy your Files while the solution is running though, and it opens up a whole lot of potential timing issues.

There aren't really a lot of strings to pull here, unfortunately.

- Jeppe

Votes for this answer: 1
 
Jan Sangill
Reply

Hi Jeppe, TY for your reply.

I think i'll have to give this one up then. 

 
Jan Sangill
Reply

Hi Jeppe,

Do you know if there is something in API that can get a list of all items - and I can then save each item - via API?

Need this for when a lot of items have been updated - but the database is not current.

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Jan,

While it would be possible to get all item types using the API, it's not possible to save them. The activation method is internal, so you won't be able to proceed that way. There is, however, a method that does it for you: Dynamicweb.Content.Items.ItemManager.UpdateMetadata(). It finds all Model-First item types and saves them. This should happen on start-up, so if you're experiencing that it isn't working, it still might not work calling it manually. Let me know how it works out.

Extra bits:
If you wanted to get all the item types in your system, you would get the Metadata for the item types like this: Metadata is fetched with Dynamicweb.Content.Items.ItemManager.Metadata.GetMetadata(), which will give you a MetadataContainer. The MetadataContainer has a property called Items which is a ItemMetadataCollection that contains ItemType objects. It will contain all your Model-First item types.

- Jeppe

 
Jan Sangill
Reply

Hi Jeppe,

Dynamicweb.Content.Items.ItemManager.UpdateMetadata() is not working as we all hoped:) 

It does not save the new items to database atleast.

Any other smart workarounds that might get this to working? This is one of the things that is most annoying atm when using CI/CD.

//jan

 

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Unfortunately not - at least not without a code change to the Items API.

I've created a bug report for UpdateMetadata not working as expected, and hopefully get it fixed so the solution performs the update correctly on start-up. The number is #83283. I don't know when it'll be fixed but we'll keep you updated here.

- Jeppe

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

Hi Jan,
I could you please add details how you made a call Dynamicweb.Content.Items.ItemManager.UpdateMetadata()
I tested it - item synchronization works as expected.
When something going wrong it should be logged in the folder: \Files\System\Log\items\ActivationWorkflow

Best regards,
Vladimir

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

PS: Note, you can synchronize all items from the page Settings -> Item types  - there is the buttom "Refresh" here

btw it just execcute Dynamicweb.Content.Items.ItemManager.UpdateMetadata()

 
Jan Sangill
Reply

Hi Vladimir,

I will test it start next week. A colleague of mine etsted and mentioned this. I will make a test myself next week and report back.

 
Jan Sangill
Reply

Hi Jeppe and Vladimir,

It seems we were to fast. I have tested it now and it works as it should!

No need for any bug reports here.

TY for your assistance!

 

 

You must be logged in to post in the forum