Beispiel #1
0
 public AlboTokenVO DecryptToken(string token)
 {
     if (token.StartsWith("TOK="))
     {
         token = token.Replace("TOK=", string.Empty);
         DocsPaUtils.Security.CryptoString c = new DocsPaUtils.Security.CryptoString("ALBO_TELEMATICO");
         token = c.Decrypt(token).Replace("\0", string.Empty);
         string[]    tokField = token.Split('|');
         AlboTokenVO reval    = new AlboTokenVO {
             userID = tokField[0], CodRuolo = tokField[1], DocNumber = tokField[2]
         };
         return(reval);
     }
     return(null);
 }
Beispiel #2
0
        public string InviaRelata(byte[] fileReleata, String Stato, string token)
        {
            AlboToken   at        = new AlboToken();
            AlboTokenVO tvo       = at.DecryptToken(token);
            String      docNumber = tvo.DocNumber;
            String      nomeFile  = "Relata.pdf";

            string IdAmministrazione = BusinessLogic.Utenti.UserManager.getIdAmmUtente(tvo.userID);

            DocsPaVO.utente.Utente utente = BusinessLogic.Utenti.UserManager.getUtente(tvo.userID, IdAmministrazione);
            utente.dst = BusinessLogic.Utenti.UserManager.getSuperUserAuthenticationToken();
            if (utente == null)
            {
                throw new ApplicationException(string.Format("Utente {0} non trovato", tvo.userID));
            }

            DocsPaVO.utente.Ruolo[] ruoli = (DocsPaVO.utente.Ruolo[])BusinessLogic.Utenti.UserManager.getRuoliUtente(utente.idPeople).ToArray(typeof(DocsPaVO.utente.Ruolo));

            if (ruoli != null && ruoli.Length > 0)
            {
                throw new ApplicationException("L'utente non non risulta associato ad alcun ruolo");
            }

            DocsPaVO.utente.InfoUtente infoUtente = new DocsPaVO.utente.InfoUtente(utente, ruoli[0]);

            DocsPaVO.documento.Allegato all = new DocsPaVO.documento.Allegato();
            all.descrizione = "Relata di Pubblicazione";

            all.docNumber    = docNumber;
            all.fileName     = nomeFile;
            all.version      = "0";
            all.numeroPagine = 1;
            DocsPaVO.documento.Allegato allIns = null;
            String err = String.Empty;

            try
            {
                allIns = BusinessLogic.Documenti.AllegatiManager.aggiungiAllegato(infoUtente, all);
            }
            catch (Exception ex)
            {
                logger.DebugFormat("Problemi nell'inserire l'allegato per la relata di pubblicazione {0} \r\n {1}", ex.Message, ex.StackTrace);
            }

            try
            {
                DocsPaVO.documento.SchedaDocumento sd    = BusinessLogic.Documenti.DocManager.getDettaglioNoSecurity(infoUtente, docNumber);
                DocsPaVO.documento.FileDocumento   fdAll = new DocsPaVO.documento.FileDocumento();
                fdAll.content = fileReleata;
                fdAll.length  = fileReleata.Length;

                fdAll.name = nomeFile;
                fdAll.bypassFileContentValidation = true;
                DocsPaVO.documento.FileRequest fRAll = (DocsPaVO.documento.FileRequest)sd.documenti[0];
                fRAll = (DocsPaVO.documento.FileRequest)all;
                if (fdAll.content.Length > 0)
                {
                    logger.Debug("controllo se esiste l'ext");
                    if (!BusinessLogic.Documenti.DocManager.esistiExt(nomeFile))
                    {
                        BusinessLogic.Documenti.DocManager.insertExtNonGenerico(nomeFile, "application/octet-stream");
                    }

                    if (!BusinessLogic.Documenti.FileManager.putFile(ref fRAll, fdAll, infoUtente, out err))
                    {
                        logger.Debug("errore durante la putfile");
                    }
                }
            }
            catch (Exception ex)
            {
                if (err == "")
                {
                    err = string.Format("Errore nel reperimento del file allegato: {0}.  {1}", nomeFile, ex.Message);
                }
                BusinessLogic.Documenti.AllegatiManager.rimuoviAllegato(all, infoUtente);
                logger.Debug(err);
            }


            //Mettere il cambio di stato.

            return("OK");
        }