Показать сообщение отдельно
Старый 19.10.2022, 10:15   #6  
EVGL is offline
EVGL
Banned
Соотечественники
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
 
4,445 / 3001 (0) ++++++++++
Регистрация: 09.07.2002
Адрес: Parndorf, AT
Цитата:
Сообщение от Pandasama Посмотреть сообщение
Не обязательно, кстати - есть возможность настроить на хранение в БД.
Подозреваю, что в D365, с учетом её инфраструктуры, переход на хранение в БД полный.
Все с точностью до наоборот. Файлы не могут храниться в базе данных.
The database is not a supported storage location for files. Use a different location.

К слову, при миграции с Ax2012 надо сначала засосать файлы в базу данных, потом мигрировать ее, потом нажать на кнопку Migrate files и выгрузить их опять, на этот раз в Blob Storage.

https://learn.microsoft.com/en-us/dy...hments-ax-2012

Работает примерно так:
X++:
class DocuFileMigrateDBtoAzure
{
    public static void main(Args _args)
    {
        DocuValue           docuValue;
        DocuRef             docuRef;
        DocuType            docType;
        System.IO.Stream    fileStream;
        Microsoft.Dynamics.AX.Framework.FileManagement.DocumentLocation         location;
        Microsoft.Dynamics.AX.Framework.FileManagement.IDocumentStorageProvider storageProvider;
        DataArea            dataArea;
        ;
        while select dataArea
        {
            changecompany(dataArea.id)
            {
                docType = null;
                docType.skipTTSCheck(true);
                while select forupdate docType
                    where docType.TypeGroup == DocuTypeGroup::File
                {
                    if (docType.FilePlace == DocuFilePlace::Database)
                    {
                        docType.FilePlace = DocuFilePlace::Archive;
                        docType.update();
                    }
                    storageProvider = Docu::GetStorageProvider(docType, false, curUserId());
                    if (storageProvider == null)
                        continue;
                    while select forupdate docuValue
                        where docuValue.StorageProviderId == 0
                           && docuValue.Type == DocuValueType::Others
                    join docuRef
                        where docuRef.ValueRecId      == docuValue.RecId
                           && docuRef.ActualCompanyId == docType.DataAreaId
                           && docuRef.TypeId          == docType.TypeId
                    {
                        fileStream = Binary::constructFromContainer(docuValue.File).getMemoryStream();
                        if (fileStream.Length == 0)
                            continue;
                        docuValue.FileId = newGuid();
                        location = storageProvider.SaveFile(
                                docuValue.FileId,
                                storageProvider.GenerateUniqueName(docuValue.OriginalFileName),
                                System.Web.MimeMapping::GetMimeMapping(docuValue.OriginalFileName),
                                fileStream);
                        fileStream.Close();
                        if (location == null)
                            continue;
                        if (location.NavigationUri)
                        {
                            docuValue.Path = location.get_NavigationUri().ToString();
                        }
                        if (location.AccessUri)
                        {
                            docuValue.AccessInformation = location.get_AccessUri().ToString();
                        }
                        docuValue.StorageProviderId = storageProvider.ProviderId;
                        docuValue.update();
                    }
                }
            }
        }
    }
}
Как можно видеть, никаких сетевых папок как понятия нет. Операции проводятся с in-memory потоками.

Последний раз редактировалось EVGL; 19.10.2022 в 10:20.
За это сообщение автора поблагодарили: Pandasama (2).