示例#1
0
    void DocumentManager_OnSaveData(object sender, DocumentManagerEventArgs e)
    {
        e.UpdateDocument = false;

        TreeNode node = DocumentManager.Node;

        if (UseFileUploader)
        {
            // Process file using file upload
            ProcessFileUploader();
        }
        else
        {
            // Process file using direct uploader
            ProcessDirectUploader();

            // Save temporary attachments
            DocumentHelper.SaveTemporaryAttachments(node, Guid, SiteContext.CurrentSiteName, DocumentManager.Tree);
        }

        // Create default SKU if configured
        if (ModuleManager.CheckModuleLicense(ModuleName.ECOMMERCE, RequestContext.CurrentDomain, FeatureEnum.Ecommerce, ObjectActionEnum.Insert))
        {
            bool?skuCreated = node.CreateDefaultSKU();
            if (skuCreated.HasValue && !skuCreated.Value)
            {
                ShowError(GetString("com.CreateDefaultSKU.Error"));
            }
        }

        // Set additional values
        if (!string.IsNullOrEmpty(fileExtension))
        {
            // Update document extensions if no custom are used
            if (!node.DocumentUseCustomExtensions)
            {
                node.DocumentExtensions = "." + fileExtension;
            }
            node.SetValue("DocumentType", "." + fileExtension);
        }

        // Update the document
        DocumentHelper.UpdateDocument(node, DocumentManager.Tree);
    }