Пример #1
0
    void SaveDocument(IDocumentInfo documentInfo, bool checkModificationTime)
    {
        long itemId  = ParseDocumentIdFromEditor(documentInfo.DocumentId);
        Item docItem = DataService.FindItemById(itemId);

        if (docItem == null || checkModificationTime && documentInfo.LastModifyTime < docItem.LastWriteTime)
        {
            return;
        }

        byte[] content = null;
        if (IsRichEditDocument(docItem))
        {
            RichEditDocumentInfo richEditDocument = (RichEditDocumentInfo)documentInfo;
            content = richEditDocument.SaveCopy(RichEditDocumentManager.GetFormat(docItem));
        }
        else if (IsSpreadsheetDocument(docItem))
        {
            SpreadsheetDocumentInfo spreadsheetDocument = (SpreadsheetDocumentInfo)documentInfo;
            content = spreadsheetDocument.SaveCopy(SpreadsheetDocumentManager.GetFormat(docItem));
        }
        else
        {
            throw new Exception("Incorrect document format.");
        }

        docItem.UpdateContent(content);
        DataService.SaveChanges();
    }
Пример #2
0
 public DevExpress.Spreadsheet.DocumentFormat GetSpreadsheetDocumentFormat(Item document)
 {
     return(SpreadsheetDocumentManager.GetFormat(document));
 }