Ejemplo n.º 1
0
    protected void ProcessDirectUploader()
    {
        TreeNode node = DocumentManager.Node;

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

        int maxFileNameLength = FileNameFieldInfo.Size;

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

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

        // Set default template ID
        node.SetDefaultPageTemplateID(DataClass.ClassDefaultPageTemplateID);

        // Ensures documents consistency (blog post hierarchy etc.)
        DocumentManager.EnsureDocumentsConsistency();

        // Insert the document
        DocumentHelper.InsertDocument(node, DocumentManager.ParentNode, DocumentManager.Tree);

        // Set the attachment GUID later - important when document is under workflow and  using check-in/check-out
        node.SetValue("FileAttachment", ucDirectUploader.Value);
    }
Ejemplo n.º 2
0
    protected void ProcessFileUploader()
    {
        TreeNode node = DocumentManager.Node;

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

        int maxFileNameLength = FileNameFieldInfo.Size;

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

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

        // Set default template ID
        node.SetDefaultPageTemplateID(DataClass.ClassDefaultPageTemplateID);

        // Ensures documents consistency (blog post hierarchy etc.)
        DocumentManager.EnsureDocumentsConsistency();

        // Insert the document
        DocumentHelper.InsertDocument(node, DocumentManager.ParentNode, DocumentManager.Tree);

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