Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="serverName"></param>
        /// <param name="infoUtente"></param>
        /// <param name="ruolo"></param>
        /// <param name="registro"></param>
        /// <param name="faxUserLogin"></param>
        /// <param name="faxUserCodRubrica"></param>
        /// <returns></returns>
        public static int processaCasellaFax(string serverName, DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.utente.Ruolo ruolo, DocsPaVO.utente.Registro registro, string faxUserLogin, string faxUserCodRubrica)
        {
            logger.Debug("processaCasellaFax");
            int rtn = 0;

            try
            {
                //si ricava il destinatario della trasmissione
                DocsPaVO.addressbook.QueryCorrispondente qco = new DocsPaVO.addressbook.QueryCorrispondente();
                System.Collections.ArrayList             reg = new System.Collections.ArrayList();
                reg.Add(registro.systemId);
                qco.codiceRubrica     = faxUserCodRubrica;
                qco.idAmministrazione = registro.idAmministrazione;
                qco.idRegistri        = reg;
                qco.getChildren       = false;
                System.Collections.ArrayList   corr         = BusinessLogic.Utenti.addressBookManager.listaCorrispondentiIntMethod(qco);
                DocsPaVO.utente.Corrispondente destinatario = (DocsPaVO.utente.Corrispondente)corr[0];


                //ACCESSO AL FAX
                ZfLib.ZfAPI api = new ZfLib.ZfAPI();
                logger.Debug("Tentativo di login con " + faxUserLogin);
                ZfLib.UserSession session = api.Logon(faxUserLogin, false);
                logger.Debug("Login effettuata al server ZFAX con utenza " + faxUserLogin);
                ZfLib.ServerInfo sinfo = session.Server.GetServerInfo();
                bool             msgS  = session.Inbox.CheckNewMsgStatus();

                logger.Debug("Messaggi trovati bool: " + msgS);
                logger.Debug("Messaggi trovati: " + session.Inbox.GetMsgList().Count);
                string path = session.UserInDir;
                rtn = session.Inbox.GetMsgList().Count;
                for (int i = 0; i < session.Inbox.GetMsgList().Count; i++)
                {
                    logger.Debug("Esame messaggio " + i);
                    logger.Debug("Esame messaggio " + path);
                    logger.Debug("Esame messaggio " + destinatario.descrizione);
                    ZfLib.Message mess = session.Inbox.GetMsgList()[i];
                    processaMessaggio(serverName, path, mess, infoUtente, ruolo, registro, destinatario);
                    //cancellazione messaggio
                    logger.Debug("Esame messaggio inizia cancellazione " + i);
                    mess.DeleteMsg(false);
                    logger.Debug("Esame messaggio finita cancellazione " + i);
                }
                return(rtn);
            }
            catch (Exception e)
            {
                logger.Debug("Errore nella gestione dei fax (processaCasellaFax)", e);
                throw e;
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="serverName"></param>
        /// <param name="path"></param>
        /// <param name="messaggio"></param>
        /// <param name="infoUtente"></param>
        /// <param name="ruolo"></param>
        /// <param name="registro"></param>
        /// <param name="destinatario"></param>
        private static void processaMessaggio(string serverName, string path, ZfLib.Message messaggio, DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.utente.Ruolo ruolo, DocsPaVO.utente.Registro registro, DocsPaVO.utente.Corrispondente destinatario)
        {
            logger.Debug("processaMessaggio");
            System.IO.FileStream fs = null;
            bool daAggiornareUffRef = false;
            bool dbOpen             = false;
            bool fsOpen             = false;

            try
            {
                //informazioni sul fax
                string dataRic = messaggio.GetMsgHistories()[0].Date.ToString();
                logger.Debug(" @ dataric = " + dataRic);

                //accesso al file del fax
                fs = getFileStream(path + messaggio.GetMsgInfo().Body);              //=new System.IO.FileStream(path+messaggio.GetMsgInfo().Body+".G3N",System.IO.FileMode.Open,System.IO.FileAccess.ReadWrite,System.IO.FileShare.ReadWrite);

                logger.Debug(fs.CanRead.ToString() + "@ OK @");
                fsOpen = true;

                //creazione scheda documento
                DocsPaVO.documento.SchedaDocumento sd = new DocsPaVO.documento.SchedaDocumento();
                sd.idPeople = infoUtente.idPeople;

                logger.Debug("sd.idPeople = " + sd.idPeople.ToString());

                sd.userId = infoUtente.userId;
                logger.Debug("sd.userId = " + sd.userId.ToString());
                DocsPaVO.documento.Oggetto ogg = new DocsPaVO.documento.Oggetto();
                ogg.descrizione = "Fax ricevuto in data " + dataRic;              //DA COMPLETARE
                sd.oggetto      = ogg;
                sd.predisponiProtocollazione = true;
                sd.registro  = registro;
                sd.tipoProto = "A";
                sd.typeId    = "MAIL";

                //aggiunta protocollo entrata
                DocsPaVO.documento.ProtocolloEntrata protEntr = new DocsPaVO.documento.ProtocolloEntrata();
                DocsPaVO.utente.Corrispondente       mittente = new DocsPaVO.utente.Corrispondente();
                mittente.descrizione = messaggio.GetMsgInfo().Comment;
                logger.Debug(" @ mittente.descrizione = " + mittente.descrizione);               //"QUI SI METTONO INFORMAZIONI";
                protEntr.mittente = mittente;

                sd.protocollo = protEntr;
                protEntr.dataProtocollazione = System.DateTime.Today.ToString();
                sd.appId = "ACROBAT";
                sd       = BusinessLogic.Documenti.DocSave.addDocGrigia(sd, infoUtente, ruolo);
                logger.Debug("Salvataggio doc...");
                sd = BusinessLogic.Documenti.DocSave.save(infoUtente, sd, false, out daAggiornareUffRef, ruolo);
                logger.Debug("Salvataggio eseguito");
                DocsPaVO.documento.FileDocumento fd = new DocsPaVO.documento.FileDocumento();
                byte[] buffer = new byte[fs.Length];
                fs.Read(buffer, 0, (int)fs.Length);
                fd.content = buffer;
                fd.length  = buffer.Length;
                fd.name    = "fax.tif";

                BusinessLogic.Documenti.FileManager.putFile((DocsPaVO.documento.FileRequest)sd.documenti[0], fd, infoUtente);
                logger.Debug("Documento inserito");
                fs.Close();
                fsOpen = false;

                //TRASMISSIONE
                DocsPaVO.trasmissione.Trasmissione trasm = new DocsPaVO.trasmissione.Trasmissione();
                trasm.ruolo = ruolo;
                //db.openConnection();
                dbOpen       = true;
                trasm.utente = BusinessLogic.Utenti.UserManager.getUtente(infoUtente.idPeople);
                DocsPaVO.documento.InfoDocumento infoDoc = new DocsPaVO.documento.InfoDocumento();
                infoDoc.idProfile   = sd.systemId;
                infoDoc.docNumber   = sd.docNumber;
                infoDoc.oggetto     = sd.oggetto.descrizione;
                infoDoc.tipoProto   = "A";
                trasm.infoDocumento = infoDoc;
                //costruzione singole trasmissioni
                DocsPaVO.trasmissione.RagioneTrasmissione ragione = getRagioneTrasm();
                System.Collections.ArrayList dest = new System.Collections.ArrayList();
                dest.Add(destinatario);
                System.Collections.ArrayList trasmissioniSing = new System.Collections.ArrayList();

                for (int i = 0; i < dest.Count; i++)
                {
                    DocsPaVO.trasmissione.TrasmissioneSingola trSing = new DocsPaVO.trasmissione.TrasmissioneSingola();
                    trSing.ragione = ragione;
                    logger.Debug(dest[i].GetType().ToString());
                    if (dest[i].GetType().Equals(typeof(DocsPaVO.utente.Ruolo)))
                    {
                        logger.Debug("ruolo");
                        trSing.corrispondenteInterno = (DocsPaVO.utente.Ruolo)dest[i];
                    }
                    else
                    {
                        logger.Debug("utente");
                        trSing.corrispondenteInterno = (DocsPaVO.utente.Utente)dest[i];
                    }
                    logger.Debug("ok");
                    trSing.tipoTrasm = "S";
                    if (dest[i].GetType().Equals(typeof(DocsPaVO.utente.Ruolo)))
                    {
                        logger.Debug("caso ruolo");
                        trSing.tipoDest = DocsPaVO.trasmissione.TipoDestinatario.RUOLO;
                        //ricerca degli utenti del ruolo
                        System.Collections.ArrayList             utenti = new System.Collections.ArrayList();
                        DocsPaVO.addressbook.QueryCorrispondente qc     = new DocsPaVO.addressbook.QueryCorrispondente();
                        qc.codiceRubrica = ((DocsPaVO.utente.Ruolo)dest[i]).codiceRubrica;
                        System.Collections.ArrayList registri = new System.Collections.ArrayList();
                        registri.Add(registro.systemId);
                        qc.idRegistri        = registri;
                        qc.idAmministrazione = registro.idAmministrazione;
                        qc.getChildren       = true;
                        utenti = BusinessLogic.Utenti.addressBookManager.listaCorrispondentiIntMethod(qc);
                        System.Collections.ArrayList trasmissioniUt = new System.Collections.ArrayList();
                        for (int k = 0; k < utenti.Count; k++)
                        {
                            DocsPaVO.trasmissione.TrasmissioneUtente trUt = new DocsPaVO.trasmissione.TrasmissioneUtente();
                            trUt.utente = (DocsPaVO.utente.Utente)utenti[k];
                            trasmissioniUt.Add(trUt);
                        }
                        trSing.trasmissioneUtente = trasmissioniUt;
                    }
                    else
                    {
                        logger.Debug("Caso utente");
                        trSing.tipoDest = DocsPaVO.trasmissione.TipoDestinatario.UTENTE;
                        System.Collections.ArrayList             trasmissioniUt = new System.Collections.ArrayList();
                        DocsPaVO.trasmissione.TrasmissioneUtente trUt           = new DocsPaVO.trasmissione.TrasmissioneUtente();
                        trUt.utente = (DocsPaVO.utente.Utente)dest[i];
                        trasmissioniUt.Add(trUt);
                        trSing.trasmissioneUtente = trasmissioniUt;
                    }
                    trasmissioniSing.Add(trSing);
                }

                trasm.trasmissioniSingole = trasmissioniSing;
                if (infoUtente.delegato != null)
                {
                    trasm.delegato = ((DocsPaVO.utente.InfoUtente)(infoUtente.delegato)).idPeople;
                }
                //BusinessLogic.Trasmissioni.TrasmManager.saveTrasmMethod(trasm);
                //BusinessLogic.Trasmissioni.ExecTrasmManager.executeTrasmMethod(serverName,trasm);
                BusinessLogic.Trasmissioni.ExecTrasmManager.saveExecuteTrasmMethod(serverName, trasm);
            }
            catch (Exception e)
            {
                logger.Debug(e.Message);
                if (fsOpen)
                {
                    fs.Close();
                }
                if (dbOpen)
                {
                    //db.closeConnection();
                }

                logger.Debug("Errore nella gestione dei fax (processaMessaggio)", e);
                throw e;
            }
        }