AXForum  
Вернуться   AXForum > Microsoft Dynamics NAV > NAV: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 09.12.2016, 03:31   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
waldo: Automate downloads of Microsoft Dynamics NAV Cumulative Updates
Источник: https://dynamicsuser.net/nav/b/waldo...lative-updates
==============

Yesterday, I blogged about the availability of the first Cumulative Update of NAV 2017. In that post, I talked about the fact that Microsoft recently changed the place where to download them.

This also means the way of automating the download had to be changed. In fact, the PowerShell function that was part of my repository (and built by Kamil originally), didn’t work anymore. I didn’t really know how to get around this – but luckily, I have a really clever colleague (well, I do have more than one ;-)) that did find a way in .Net. And we managed to transfer the logic to PowerShell .. (literally “transfer”, not rewrite … you’ll see what I mean ;-)).

I’m not going to tell you “how” it works – you can find out in the code. I’ll just show you what we created, and how it works.

Load-NAVCumulativeUpdateHelper

The main functionality is in C# .. and you can make it available by loading and compiling it by simply calling “Load-NAVCumulativeUpdateHelper”. In C#, you’re just that more flexible – and since we’re working in HTML, and figuring stuff out in HTML, it’s just much nicer to do so in C#. And .. the fact that this is the preferred environment of my colleague might have a reason in that as well ;-).

The PowerShell function is loading (compiling) two functions in memory and make them available to me:

static System.Collections.Generic.IEnumerable[MicrosoftDownload.NAVDownload] GetDownloadLocales(int productID) static System.Collections.Generic.IEnumerable[MicrosoftDownload.NAVDownload] GetDownloadDetail(int productID, string language)Let me show you some examples on how to use them.

This example, is going to show you a gridview of all download URLs in a gridview, and when you select one and press ok, it starts the download. It uses the “GetDownloadLocales” to get all the languages one-by-one:



Load-NAVCumulativeUpdateHelper $Locales = [MicrosoftDownload.MicrosoftDownloadParser]::GetDownloadLocales(54317) $MyDownload = $Locales | out-gridview -PassThru | foreach { $_.DownloadUrl Start-BitsTransfer -Source $_.DownloadUrl -Destination C:\_Download\Filename.zip }The other function “GetDownloadDetail”, you need to specify the Locale (like “en-US”), which can be used to speed up the process (no need to generate and navigate to all the URLs of all the “Locales”), like:



Load-NAVCumulativeUpdateHelper $MyDownload = [MicrosoftDownload.MicrosoftDownloadParser]::GetDownloadDetail(54317, 'en-US') | Select-Object * $MyDownloadYou also see that the functions need a ProductID. Well, that’s how Download Center works .. If you have the ID, you know what to download .. and to get to that ProductID, let’s look into the next function.

Get-NAVCumulativeUpdateFile

This function is based on the good old function that Kamil Sacek once wrote – based on the ideas of my colleague. It is going to look at the Microsoft Dynamics NAV Team Blog to figure out the link to the Download Center – and yes – to figure out the ProductID. And obviously, going to use the Helper above to be able to start the download(s). It’s still limited to only search for the latest Cumulative Update. I’m working on a solution (probably a new function) to start the download from a specific blog article, or KB article.

The function above can simply be used in this way (and here are some more examples) which will simply start the download to the specified folder:

Get-NAVCumulativeUpdateFile -versions 2017 -CountryCode W1 -DownloadFolder C:\_DownloadThe function also creates a JSON with specifics about the download. Not because it’s necessary .. just because we can ;-).

Do I need the complete module to be able to do this?

No. You basically only need these two functions. So go ahead and automate! :-). The result is a much more stable way to automate these downloads, simply because Download Center doesn’t require you to run through a complicated login process ..




Источник: https://dynamicsuser.net/nav/b/waldo...lative-updates
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
waldo: Microsoft Dynamics NAV 2017 – what’s really new? Blog bot NAV: Blogs 0 13.10.2016 05:22
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 8 Blog bot Dynamics CRM: Blogs 1 30.04.2016 10:26
NAV Team: Cumulative Update 10 for Microsoft Dynamics NAV 2013 R2 has been released Blog bot Dynamics CRM: Blogs 0 20.08.2014 17:40
axinthefield: Dynamics AX Event IDs Blog bot DAX Blogs 0 01.03.2011 22:11
Nav developer: Overview of NAV blogs in 2008 Blog bot Dynamics CRM: Blogs 0 07.12.2008 02:18
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 11:54.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.