Ejemplo n.º 1
0
    protected TreeNode ProcessDirectUploader(TreeProvider tree)
    {
        TreeNode node = null;

        // Create new document
        string fileName = Path.GetFileNameWithoutExtension(ucDirectUploader.AttachmentName);

        int maxFileNameLength = FileNameFieldInfo.Size;

        if (fileName.Length > maxFileNameLength)
        {
            fileName = fileName.Substring(0, maxFileNameLength);
        }

        node = TreeNode.New("CMS.File", tree);
        node.DocumentCulture = CMSContext.PreferredCultureCode;
        node.DocumentName    = fileName;

        // Load default values
        FormHelper.LoadDefaultValues(node);

        if (node.ContainsColumn("FileDescription"))
        {
            node.SetValue("FileDescription", txtFileDescription.Text);
        }
        //node.SetValue("FileName", fileName);
        node.SetValue("FileAttachment", Guid.Empty);

        // Set default template ID
        if (templateId > 0)
        {
            node.DocumentPageTemplateID = templateId;
        }
        else
        {
            node.DocumentPageTemplateID = DataClass.ClassDefaultPageTemplateID;
        }

        // Insert the document
        DocumentHelper.InsertDocument(node, nodeId, tree);

        // Set the attachment GUID later - important when document is under workflow and  using check-in/check-out
        node.SetValue("FileAttachment", ucDirectUploader.Value);

        return(node);
    }
Ejemplo n.º 2
0
    protected TreeNode ProcessFileUploader(TreeProvider tree)
    {
        TreeNode node = null;

        // Create new document
        string fileName = Path.GetFileNameWithoutExtension(FileUpload.FileName);

        int maxFileNameLength = FileNameFieldInfo.Size;

        if (fileName.Length > maxFileNameLength)
        {
            fileName = fileName.Substring(0, maxFileNameLength);
        }

        node = TreeNode.New("CMS.File", tree);
        node.DocumentCulture = CMSContext.PreferredCultureCode;
        node.DocumentName    = fileName;

        // Load default values
        FormHelper.LoadDefaultValues(node);

        if (node.ContainsColumn("FileDescription"))
        {
            node.SetValue("FileDescription", txtFileDescription.Text);
        }
        //node.SetValue("FileName", fileName);
        node.SetValue("FileAttachment", Guid.Empty);

        // Set default template ID
        if (templateId > 0)
        {
            node.DocumentPageTemplateID = templateId;
        }
        else
        {
            node.DocumentPageTemplateID = DataClass.ClassDefaultPageTemplateID;
        }

        // Insert the document
        DocumentHelper.InsertDocument(node, nodeId, tree);

        // Add the file
        DocumentHelper.AddAttachment(node, "FileAttachment", FileUpload.PostedFile, tree, ResizeToWidth, ResizeToHeight, ResizeToMaxSideSize);

        return(node);
    }