Exemplo n.º 1
0
        private static void AcquireFileFromModel(DocumentRowData rowData, InfoUtente userInfo, Ruolo role, bool isSmistamentoEnabled, SchedaDocumento schedaDocumento, string ftpAddress, String ftpUsername, String ftpPassword)
        {
            // L'oggetto fileRequest
            FileRequest fileRequest;
            // L'oggetto fileDocumento
            FileDocumento   fileDocumento;
            string          tipologia   = rowData.DocumentTipology;
            TemplateManager tempManager = new TemplateManager(userInfo, role, isSmistamentoEnabled, tipologia, TemplateType.RTF);

            byte[] content = tempManager.BuildDocumentFromTemplate(rowData, schedaDocumento);
            // Creazione dell'oggetto fileDocumento
            fileDocumento = new FileDocumento();
            // Impostazione del nome del file
            fileDocumento.name = Path.GetFileName(schedaDocumento.systemId + ".rtf");
            // Impostazione del full name
            fileDocumento.fullName       = schedaDocumento.systemId + ".rtf";
            fileDocumento.estensioneFile = "rtf";
            // Impostazione del path
            //fileDocumento.path = Path.GetPathRoot(rowData.Pathname);
            // Impostazione della grandezza del file
            fileDocumento.length = content.Length;
            // Impostazione del content del documento
            fileDocumento.content = content;
            fileRequest           = (FileRequest)schedaDocumento.documenti[0];
            try
            {
                FileManager.putFile(fileRequest, fileDocumento, userInfo);
            }
            catch (Exception e)
            {
                // Aggiunta del problema alla lista dei problemi
                throw new Exception("Errore durante l'upload del file.");
            }
        }