Example #1
0
        private string SaveDocument(InfoUtente userInfo, Ruolo role, SchedaDocumento document, FileDocumento fileDoc, out Ruolo[] superiori)
        {

            //Salvataggio del documento
            DocsPaDocumentale.Documentale.DocumentManager docManager = new DocsPaDocumentale.Documentale.DocumentManager(userInfo);

            //Salvataggio dell'oggetto
            document = ProtoManager.addOggettoLocked(userInfo.idAmministrazione, document);

            Ruolo[] ruoliSuperiori;
            //if (docManager.CreateDocumentoStampaRegistro(document, role, out ruoliSuperiori))
            if (docManager.CreateDocumentoGrigio(document, role, out ruoliSuperiori))
            //if(docManager.CreateDocumentoGrigio(document, role))
            {
                //Notifica evento documento creato
                //DocsPaDocumentale.Interfaces.IAclEventListener eventsNotification = new DocsPaDocumentale.Documentale.AclEventListener(userInfo);
                //eventsNotification.DocumentoCreatoEventHandler(document, role, ruoliSuperiori);
                
                //Salvataggio del file associato al documento
                DocsPaVO.documento.FileRequest fileRequest = (DocsPaVO.documento.FileRequest)document.documenti[0];

                fileRequest = BusinessLogic.Documenti.FileManager.putFile(fileRequest, fileDoc, userInfo);
                if(fileRequest == null)
                    throw new ApplicationException("Si è verificato un errore nell'upload del documento per la stampa del registro di conservazione");

            }

            superiori = ruoliSuperiori;
            if (superiori == null)
                superiori = new Ruolo[] { };

            //Restituzione del numero documento            
            return document.docNumber;
        }
Example #2
0
 private void OnRestartProtocols()
 {
     foreach (NetProtocols num in Enum.GetValues(typeof(NetProtocols)))
     {
         ProtoManager.AddRequestDelegate((int)num, Response);
     }
 }
Example #3
0
        private string SaveDocument(InfoUtente infoUtente, Ruolo role, SchedaDocumento schedaDoc, FileDocumento fileDoc)
        {
            //Salvataggio del documento
            DocsPaDocumentale.Documentale.DocumentManager docManager = new DocsPaDocumentale.Documentale.DocumentManager(infoUtente);

            //Salvataggio dell'oggetto
            schedaDoc = ProtoManager.addOggettoLocked(infoUtente.idAmministrazione, schedaDoc);

            Ruolo[] ruoliSuperiori;

            if (docManager.CreateDocumentoGrigio(schedaDoc, role, out ruoliSuperiori))
            {
                //Salvataggio del file associato al documento
                DocsPaVO.documento.FileRequest fileRequest = (DocsPaVO.documento.FileRequest)schedaDoc.documenti[0];

                fileRequest = BusinessLogic.Documenti.FileManager.putFile(fileRequest, fileDoc, infoUtente);
                if (fileRequest == null)
                {
                    throw new ApplicationException("Si è verificato un errore nell'upload del documento di certificazione");
                }
            }

            /*
             * superiori = ruoliSuperiori;
             * if (superiori == null)
             *  superiori = new Ruolo[] { };
             * */

            //restituzione numero documento
            return(schedaDoc.docNumber);
        }
Example #4
0
    public static void Export(ProtoManager pm)
    {
        ProtoModuleData server = pm.apiReader.modules.GetValueByKey("test");
        ProtoModuleData client = pm.apiReader.modules.GetValueByKey("ClientGM");

        ExportModule(server, true, Setting.Options.jsonServerGM);
        ExportModule(client, false, Setting.Options.jsonClientGM);
    }
    public static void Export(ProtoManager pm)
    {
        List <ProtoStructData> oobValues = pm.structReader.structs.Values;

        foreach (var oob in oobValues)
        {
            ExportStruct(oob);
        }
    }
Example #6
0
 private void ReceiveMessage()
 {
     if (ReceiveDataQueue.Count > 0)
     {
         ReceiveSocketData rsd    = ReceiveDataQueue.Dequeue();
         DataStream        stream = new DataStream(rsd.Data, true);
         ProtoManager.TryDeserialize(stream, rsd.Socket);
     }
 }
    public static void Export(ProtoManager pm)
    {
        List <ProtoModuleData> apiValues = pm.apiReader.modules.Values;

        foreach (var module in apiValues)
        {
            ExportModule(module);
        }
    }
Example #8
0
    public override void Deserialize(DataStream reader)
    {
        base.Deserialize(reader);
        int attachedRequestsCount = reader.ReadSInt32();

        for (int i = 0; i < attachedRequestsCount; i++)
        {
            ServerRequestBase request = (ServerRequestBase)ProtoManager.TryDeserialize(reader, null);
            AttachedRequests.Add(request);
        }
    }
Example #9
0
 private void LoadProtoManager()
 {
     while (worldmap == null || worldmap.FODLGParser == null || !worldmap.FODLGParser.IsParsed)
     {
         Thread.Sleep(1);
     }
     ProtoManager.Init(Config.BaseProtoFiles.Split(" \t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
                       Config.ProtoFiles.Split(" \t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
                       worldmap.FODLGParser);
     ProtoManager.Load();
 }
Example #10
0
        /// <summary>
        /// Metodo per il recupero delle informazioni sul protocollo miittente
        /// </summary>
        /// <param name="schedaDocumento">Documento da cui estrarre le informazioni</param>
        /// <returns>Informazioni sul protocollo mittente</returns>
        private RecordInfo CreateRecordInfo(SchedaDocumento schedaDocumento)
        {
            RecordInfo recordInfo = new RecordInfo()
            {
                AdministrationCode = schedaDocumento.registro.codAmministrazione,
                AOOCode            = schedaDocumento.registro.codRegistro,
                RecordDate         = DateTime.Parse(ProtoManager.getDataOraProtocollo(schedaDocumento.systemId)),
                RecordNumber       = schedaDocumento.protocollo.numero,
                Subject            = schedaDocumento.oggetto.descrizione
            };

            return(recordInfo);
        }
Example #11
0
 // Use this for initialization
 void Start()
 {
     try
     {
         protoManager = (ProtoManager)GameObject.Find("ProtoManagerObj").GetComponent <ProtoManager>();
         mono         = (GameObject)GameObject.Find("Mono");
         cycle        = (GameObject)GameObject.Find("Cycle");
         floor        = (GameObject)GameObject.Find("floor");
     }
     catch
     {
         print("my little error");
     }
 }
Example #12
0
    private IShootable GetShootable(BatteryAmmoProviderComponent component, EntityCoordinates coordinates)
    {
        switch (component)
        {
        case ProjectileBatteryAmmoProviderComponent proj:
            var ent = Spawn(proj.Prototype, coordinates);
            return(EnsureComp <AmmoComponent>(ent));

        case HitscanBatteryAmmoProviderComponent hitscan:
            return(ProtoManager.Index <HitscanPrototype>(hitscan.Prototype));

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
Example #13
0
 internal static void annullaProtocollo(DocsPaVO.documento.SchedaDocumento schedaDocumento, DocsPaVO.documento.ProtocolloEmergenza protoEme, ref DocsPaVO.documento.resultProtoEmergenza res, DocsPaVO.utente.InfoUtente infoUtente)
 {
     try
     {
         DocsPaVO.documento.ProtocolloAnnullato protocolloAnnullato = new DocsPaVO.documento.ProtocolloAnnullato();
         //DocsPaVO.documento.InfoDocumento infoDocumento = Documenti.Protocollo.getInfoDocumento(schedaDocumento);
         protocolloAnnullato.dataAnnullamento = protoEme.dataAnnullamento;
         protocolloAnnullato.autorizzazione   = protoEme.noteAnnullamento;
         res.isAnnullato = ProtoManager.annullaProtocollo(infoUtente, ref schedaDocumento, protocolloAnnullato);
     }
     catch (Exception e)
     {
         res.messaggio = res.messaggio + " - " + e.Message;
         logger.Debug(e.ToString());
     }
 }
Example #14
0
        //questo metodo crea un documento protocollato su docsPa a partire da un protocollo di emergenza
        public static DocsPaVO.documento.resultProtoEmergenza importaProtoEmergenza(DocsPaVO.documento.ProtocolloEmergenza protoEmergenza, DocsPaVO.utente.InfoUtente infoUtente)
        {
            DocsPaVO.documento.resultProtoEmergenza res = new DocsPaVO.documento.resultProtoEmergenza();

            try
            {
                DocsPaVO.utente.Ruolo ruolo = Utenti.UserManager.getRuolo(infoUtente.idCorrGlobali);
                DocsPaVO.documento.SchedaDocumento schedaDocumento;
                logger.Debug("add protocollo Emergenza");
                //si costruisce l'oggetto schedaDocumento
                schedaDocumento = creaSchedaDocumento(protoEmergenza, infoUtente, ruolo);
                //si protocolla
                DocsPaVO.documento.ResultProtocollazione risultatoProtocollazione;
                schedaDocumento = ProtoManager.protocolla(schedaDocumento, ruolo, infoUtente, out risultatoProtocollazione);
                if (schedaDocumento != null)
                {
                    res.isProtocollato = true;
                }

                //si classifica il documento
                classificaDocumento(schedaDocumento, protoEmergenza.codiceClassifica, ref res, infoUtente, ruolo);

                //eventualmente si annulla il documento
                if (protoEmergenza.dataAnnullamento != null && !protoEmergenza.dataAnnullamento.Equals(""))
                {
                    annullaProtocollo(schedaDocumento, protoEmergenza, ref res, infoUtente);
                }
                else
                {
                    //si trasmette il documento
                    trasmettiDocumento(schedaDocumento, protoEmergenza.templateTrasmissione, ref res, infoUtente, ruolo, protoEmergenza.idRegistro);
                }
            }
            catch (Exception e)
            {
                res.messaggio = res.messaggio + " - " + e.Message;
                logger.Debug(e.ToString());
                return(res);
            }
            return(res);
        }
    public static void Export(ProtoManager pm)
    {
        List <object[]> enumlist = new List <object[]>();

        List <ProtoEnumData> enumValues = pm.enumReader.enums.Values;

        foreach (var item in enumValues)
        {
            enumlist.Add(new object[] { item.name, item.fullClassName });
        }


        TemplateSystem template = new TemplateSystem(File.ReadAllText(TsPathTemplate.ProtoInclude));

        template.AddVariable("enumlist", enumlist.ToArray());
        string content = template.Parse();
        string path    = string.Format(TsPathOut.ProtoInclude);

        PathHelper.CheckPath(path);
        File.WriteAllText(path, content);
    }
    public static void Export(ProtoManager pm)
    {
        List <object[]> ooblist = new List <object[]>();

        List <ProtoStructData> oobValues = pm.structReader.structs.Values;

        foreach (var oob in oobValues)
        {
            ooblist.Add(new object[] { oob.funName });
        }


        TemplateSystem template = new TemplateSystem(File.ReadAllText(TsPathTemplate.ProtoOobHandler));

        template.AddVariable("ooblist", ooblist.ToArray());
        string content = template.Parse();
        string path    = string.Format(TsPathOut.ProtoOobHandler);

        PathHelper.CheckPath(path);
        File.WriteAllText(path, content);
    }
    public static void Export(ProtoManager pm)
    {
        List <object[]> apilist = new List <object[]>();

        List <ProtoModuleData> apiValues = pm.apiReader.modules.Values;

        foreach (var module in apiValues)
        {
            apilist.Add(new object[] { module.name, module.moduleSenderClassName });
        }


        TemplateSystem template = new TemplateSystem(File.ReadAllText(TsPathTemplate.ProtoSenderList));

        template.AddVariable("apilist", apilist.ToArray());
        string content = template.Parse();
        string path    = string.Format(TsPathOut.ProtoSenderList);

        PathHelper.CheckPath(path);
        File.WriteAllText(path, content);
    }
Example #18
0
    //接收到数据放入数据队列,按顺序取出
    void Update()
    {
        if (Client.Instance.IsStandalone)
        {
            return;
        }
        if (!SocketErrorFlag)
        {
            if (receiveDataQueue.Count > 0)
            {
                ReceiveSocketData rsd    = receiveDataQueue.Dequeue();
                DataStream        stream = new DataStream(rsd.Data, true);
                ProtoManager.TryDeserialize(stream, rsd.Socket);
            }

            Client.Instance.Proxy.Send();
        }
        else
        {
            Client.Instance.Proxy.ClientState = ProxyBase.ClientStates.Offline;
            RoundManager.Instance.StopGame();
            SocketErrorFlag = false;
        }
    }
Example #19
0
    static void Main(string[] args)
    {
        //注册EncodeProvider
        //Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);



        Setting.Init(args);

        ProtoManager pm = new ProtoManager();

        pm.ReadProto();
        pm.ReadProtoNote();
        pm.ExportCode();
        pm.ExportGMJson();


        Console.WriteLine("完成!");

        if (!Setting.Options.autoEnd)
        {
            Console.Read();
        }
    }
    public static void Export(ProtoManager pm)
    {
        List <object[]> apilist = new List <object[]>();
        List <object[]> ooblist = new List <object[]>();

        List <ProtoModuleData> apiValues = pm.apiReader.modules.Values;

        foreach (var module in apiValues)
        {
            List <ProtoMessageData> msgValues = module.msgs.Values;
            foreach (var msg in msgValues)
            {
                apilist.Add(new object[] { module.name, msg.name });
            }
        }


        List <ProtoStructData> oobValues = pm.structReader.structs.Values;

        foreach (var oob in oobValues)
        {
            ooblist.Add(new object[] { oob.name });
        }



        TemplateSystem template = new TemplateSystem(File.ReadAllText(TsPathTemplate.ProtoEventKey));

        template.AddVariable("apilist", apilist.ToArray());
        template.AddVariable("ooblist", ooblist.ToArray());
        string content = template.Parse();
        string path    = string.Format(TsPathOut.ProtoEventKey);

        PathHelper.CheckPath(path);
        File.WriteAllText(path, content);
    }
Example #21
0
        /// <summary>
        /// </summary>
        /// <param name="schedaDoc"></param>
        /// <param name="objSicurezza"></param>
        /// <param name="objRuolo"></param>
        /// <param name="debug"></param>
        /// <returns></returns>
        public static DocsPaVO.documento.SchedaDocumento addDocGrigia(DocsPaVO.documento.SchedaDocumento schedaDoc, DocsPaVO.utente.InfoUtente objSicurezza, DocsPaVO.utente.Ruolo objRuolo)
        {
            logger.Info("BEGIN");
            try
            {
                semProtNuovo.WaitOne();

                // Avvio del contesto transazionale
                using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
                {
                    //SOSTITUISCO IL CARATTERE SPECIALE
                    if (schedaDoc.oggetto.descrizione.Contains("–"))
                    {
                        schedaDoc.oggetto.descrizione = schedaDoc.oggetto.descrizione.Replace("–", "-");
                    }

                    // verifico i dati di ingresso
                    ProtoManager.checkInputData(objSicurezza.idAmministrazione, schedaDoc);
                    logger.Debug("nomeUtente=" + schedaDoc.userId);

                    //add massimo digregorio carica dati protocollatore in schedaProtocollo
                    schedaDoc = getDatiProtocollatore(schedaDoc, objRuolo, objSicurezza);
                    schedaDoc = getDatiCreatore(schedaDoc, objRuolo, objSicurezza);

                    // creo il nuovo documento
                    DocsPaDocumentale.Documentale.DocumentManager documentManager = new DocsPaDocumentale.Documentale.DocumentManager(objSicurezza);

                    DocsPaVO.utente.Ruolo[] ruoliSuperiori;

                    List <DocsPaVO.documento.FileRequest> versions = new List <DocsPaVO.documento.FileRequest>();

                    if (schedaDoc.documenti != null && schedaDoc.documenti.Count > 0)
                    {
                        versions = new List <DocsPaVO.documento.FileRequest>((DocsPaVO.documento.FileRequest[])schedaDoc.documenti.ToArray(typeof(DocsPaVO.documento.FileRequest)));

                        // Ordinamento versioni
                        versions.Sort(
                            delegate(DocsPaVO.documento.FileRequest x, DocsPaVO.documento.FileRequest y)
                        {
                            int versionX, versionY;
                            Int32.TryParse(x.version, out versionX);
                            Int32.TryParse(y.version, out versionY);

                            return(versionX.CompareTo(versionY));
                        }
                            );
                    }

                    if (!documentManager.CreateDocumentoGrigio(schedaDoc, objRuolo, out ruoliSuperiori))
                    {
                        throw new ApplicationException("Errore nella creazione del documento grigio");
                    }
                    else
                    {
                        // Notifica evento documento creato
                        DocsPaDocumentale.Interfaces.IAclEventListener eventsNotification = new DocsPaDocumentale.Documentale.AclEventListener(objSicurezza);

                        eventsNotification.DocumentoCreatoEventHandler(schedaDoc, objRuolo, ruoliSuperiori);

                        // Sincronizzazione repository
                        if (schedaDoc.repositoryContext != null)
                        {
                            SessionRepositoryFileManager fileManager = SessionRepositoryFileManager.GetFileManager(schedaDoc.repositoryContext);

                            // In fase di inserimento di un repository temporaneo,
                            // possono essere creati:
                            // - la prima versione del documento e, qualora sia stato acquisito un file
                            //   e firmato, anche la seconda versione firmata del documento
                            // - la prima versione di n allegati
                            // La prima versione del documento è creata automaticamente con la creazione del documento stesso.
                            // In caso di seconda versione firmata del documento, è necessario procedre alla creazione.
                            foreach (DocsPaVO.documento.FileRequest v in versions)
                            {
                                int version;
                                Int32.TryParse(v.version, out version);

                                DocsPaVO.documento.FileRequest savedVersion = null;

                                if (version > 1)
                                {
                                    // Seconda versione firmata del documento,
                                    // impostazione dell'id del documento di appartenenza
                                    v.docNumber = schedaDoc.docNumber;

                                    // Inserimento delle versioni del documento,
                                    // acquisite oltre alla versione principale
                                    if (!documentManager.AddVersion(v, false))
                                    {
                                        throw new ApplicationException(string.Format("Errore nella creazione della versione {0} del documento con id {1}", version, schedaDoc.systemId));
                                    }

                                    savedVersion = SessionRepositorySyncronizer.CopyToRepository(fileManager, v);

                                    // Inserimento della nuova versione come primo elemento della lista documenti
                                    schedaDoc.documenti.Insert(0, savedVersion);
                                }
                                else
                                {
                                    // La versione principale del documento è già stata creata al momento dell'inserimento,
                                    // pertanto è necessario copiare solamente il file acquisito nel repository
                                    savedVersion = SessionRepositorySyncronizer.CopyToRepository(fileManager, (DocsPaVO.documento.FileRequest)schedaDoc.documenti[0]);

                                    // Aggiornamento istanza documento principale
                                    schedaDoc.documenti[0] = savedVersion;
                                }
                            }

                            if (schedaDoc.allegati != null && schedaDoc.allegati.Count > 0)
                            {
                                // Gli allegati e le rispettive versioni andranno create manualmente
                                foreach (DocsPaVO.documento.Allegato allegato in schedaDoc.allegati)
                                {
                                    string oldVersionLabel = allegato.versionLabel;

                                    // Impostazione del docnumber del documento principale
                                    // cui sarà associato l'allegato
                                    allegato.docNumber = schedaDoc.docNumber;

                                    if (!documentManager.AddAttachment(allegato, "N"))
                                    {
                                        throw new ApplicationException(string.Format("Errore nella creazione dell'allegato {0} del documento con id {1}", allegato.position, schedaDoc.systemId));
                                    }

                                    allegato.versionLabel = oldVersionLabel;
                                }

                                DocsPaVO.documento.FileRequest[] allegati = (DocsPaVO.documento.FileRequest[])schedaDoc.allegati.ToArray(typeof(DocsPaVO.documento.Allegato));

                                if (allegati.Length > 0)
                                {
                                    schedaDoc.allegati = new ArrayList(SessionRepositorySyncronizer.CopyToRepository(fileManager, allegati));
                                }
                            }

                            // Se è presente un repository temporaneo, viene effettuato l'inserimento del file nel repository del documentale
                            // Imposta il repository come scaduto
                            fileManager.Delete();

                            schedaDoc.repositoryContext = null;
                        }
                    }

                    //Richiamo il metodo per il calcolo della atipicità del documento
                    DocsPaDB.Query_DocsPAWS.Documentale documentale = new DocsPaDB.Query_DocsPAWS.Documentale();
                    schedaDoc.InfoAtipicita = documentale.CalcolaAtipicita(objSicurezza, schedaDoc.docNumber, DocsPaVO.Security.InfoAtipicita.TipoOggettoAtipico.DOCUMENTO);

                    if (schedaDoc != null)
                    {
                        // Impostazione della transazione come completata,
                        // solamente se il documento è stato creato correttamente
                        transactionContext.Complete();
                    }
                }
                logger.Info("END");
                return(schedaDoc);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                semProtNuovo.ReleaseMutex();
            }
        }
Example #22
0
        /// <summary>
        /// Metodo per la creazione del predisposto e per la sua trasmissione agli utenti impostati nel sistema
        /// </summary>
        /// <param name="settings">Impostazioni relative al particolare registro su cui creare il predisposto</param>
        /// <param name="senderInfo">Informazioni sul mittente del messaggio</param>
        /// <param name="interoperabilityMessage">Informazioni sulla richiesta di interoperabilità</param>
        ///
        private static InfoDocumentDelivered GenerateInteroperabilityDocument(InteroperabilitySettings settings, Corrispondente senderInfo, InteroperabilityMessage interoperabilityMessage, List <ReceiverInfo> receivers, String messageId, Utente user, Ruolo userRole)
        {
            // Se per il registro è disabilitata l'interoperabilità, non si può procedere.
            if (!settings.IsEnabledInteroperability)
            {
                throw new RegistryNotInteroperableException(String.Format("Registro {0} non interoperante", RegistriManager.getRegistro(settings.RegistryId).codice));
            }

            // Creazione della scheda documento
            SchedaDocumento document = CreateDocument(settings, senderInfo, interoperabilityMessage, userRole, user, messageId);

            // Trasmissione dei documenti ai ruoli
            List <ReceiverInfo> uneachableReceivers = TransmitDocument(settings, document, userRole, user, interoperabilityMessage.IsPrivate, receivers);

            // Se il documento è stato marcato privato a causa delle impostazioni sulla gestione
            // viene eliminato il flag privato
            if (!interoperabilityMessage.IsPrivate && document.privato == "1")
            {
                DocManager.SetNotPrivate(document.systemId);
            }

            InfoDocumentDelivered infoDocDelivered = BuildInfoDocumentDelivered(document);

            // Se per il registro è impostata la modalità automatica, si procede con la protocollazione del documento
            if (settings.ManagementMode == ManagementType.A)
            {
                try
                {
                    InfoUtente userInfo = UserManager.GetInfoUtente(user, userRole);

                    // Impostazione della data e ora di protocollazione
                    document.protocollo.dataProtocollazione = DateTime.Now.ToString("dd/MM/yyyy");
                    document.protocollo.anno = DateTime.Now.Year.ToString();

                    ResultProtocollazione protoResult = ResultProtocollazione.OK;
                    ProtoManager.protocolla(document, userRole, userInfo, out protoResult);

                    // Invio della ricevuta di conferma di ricezione al mittente per tutti i destinatari
                    SimplifiedInteroperabilityProtoManager.SendDocumentReceivedProofToSender(
                        interoperabilityMessage,
                        new DocsPaVO.Interoperabilita.Semplificata.RecordInfo()
                    {
                        AdministrationCode = document.registro.codAmministrazione,
                        AOOCode            = document.registro.codRegistro,
                        RecordDate         = DateTime.Parse(document.protocollo.dataProtocollazione),
                        RecordNumber       = document.protocollo.numero
                    },
                        document.systemId,
                        userInfo);
                }
                catch (Exception e)
                {
                    SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(
                        document.systemId,
                        true,
                        "Errore durante la creazione del protocollo");
                    throw new CreatingDocumentException("Errore durante la protocollazione del documento predisposto");
                }
            }

            // Se qualche corrispondente non è stato trovato, viene sollevata un'eccezione
            // di tipo RetrivingSomeTransmissionReceiverException
            if (uneachableReceivers != null && uneachableReceivers.Count > 0)
            {
                throw new RetrivingSomeTransmissionReceiverException(
                          "Nessun destinatario trovato per la trasmissione del documento",
                          uneachableReceivers);
            }

            return(infoDocDelivered);
        }
Example #23
0
        /// <summary>
        /// Creazione del documento nel sistema
        /// </summary>
        /// <param name="settings">Impostazioni relative al registro su cui creare il documento</param>
        /// <param name="senderInfo">Informazioni sul mittente della richiesta</param>
        /// <param name="interoperabilityMessage">Messaggio con le informazioni sulla richiesta di interoperabilità</param>
        /// <param name="userRole">Ruolo dell'utente da utilizzare per la creazione del documento</param>
        /// <param name="user">Utente da utilizzare per la creazione del documento</param>
        /// <returns>Scheda del documento creato</returns>
        private static SchedaDocumento CreateDocument(InteroperabilitySettings settings, Corrispondente senderInfo, InteroperabilityMessage interoperabilityMessage, Ruolo userRole, Utente user, String messageId)
        {
            // Recupero delle informazioni sull'utente da utilizzare come creatore del documento
            InfoUtente userInfo = UserManager.GetInfoUtente(user, userRole);

            // Creazione della scheda documento da restituire
            SchedaDocumento document = DocManager.NewSchedaDocumento(userInfo);

            // Recupero del registro su cui creare il predisposto
            Registro registry = RegistriManager.getRegistro(settings.RegistryId);

            // Recupero del mezzo di spedizione
            MezzoSpedizione channel = InfoDocManager.GetMezzoSpedizioneDaCodice("SIMPLIFIEDINTEROPERABILITY");

            // Impostazione delle proprietà del documento
            try
            {
                if (!String.IsNullOrEmpty(interoperabilityMessage.MainDocument.FileName))
                {
                    document.appId = InteroperabilitaSegnatura.getApp(interoperabilityMessage.MainDocument.FileName).application;
                }
            }
            catch (Exception e) {}

            document.idPeople = user.idPeople;
            document.userId   = user.userId;
            document.oggetto  = new Oggetto()
            {
                descrizione = interoperabilityMessage.Record.Subject
            };
            document.predisponiProtocollazione = true;
            document.registro            = registry;
            document.tipoProto           = "A";
            document.typeId              = "SIMPLIFIEDINTEROPERABILITY";
            document.mezzoSpedizione     = channel.IDSystem;
            document.descMezzoSpedizione = channel.Descrizione;
            document.interop             = "S";
            document.protocollatore      = new Protocollatore(userInfo, userRole);
            document.privato             = interoperabilityMessage.IsPrivate ? "1" : "0";

            // Se la gestione dell'interoperabilità è manuale con mantenimento
            // del documento pendente, il documento viene creato privato e subito dopo
            // la creazione viene rimarcato come non privato
            if (settings.ManagementMode == ManagementType.M && settings.KeepPrivate)
            {
                document.privato = "1";
            }

            // Preparazione dell'oggetto protocollo entrata
            ProtocolloEntrata proto = new ProtocolloEntrata();

            proto.mittente = senderInfo;
            proto.dataProtocolloMittente        = interoperabilityMessage.Record.RecordDate.ToString("dd/MM/yyyy HH:mm:ss");
            proto.descrizioneProtocolloMittente = String.Format("{0}{1}{2}",
                                                                interoperabilityMessage.Record.AOOCode,
                                                                DocsPaDB.Utils.Personalization.getInstance(registry.idAmministrazione).getSepSegnatura(),
                                                                interoperabilityMessage.Record.RecordNumber);
            document.protocollo = proto;

            // Se per l'amministrazione è configurata l'aggiunta di una nota visibile a tutti,
            // ne viene aggiunta una
            String value = DocsPaUtils.Configuration.InitConfigurationKeys.GetValue("0", "BE_NOTE_IN_SEGNATURA");

            if (!String.IsNullOrEmpty(value) && value == "1" && !String.IsNullOrEmpty(interoperabilityMessage.Note))
            {
                document.noteDocumento = new List <DocsPaVO.Note.InfoNota>()
                {
                    new DocsPaVO.Note.InfoNota(interoperabilityMessage.Note, userInfo.idPeople, userInfo.idGruppo, DocsPaVO.Note.TipiVisibilitaNotaEnum.Tutti, String.Empty)
                    {
                        DaInserire = true
                    }
                }
            }
            ;

            // Salvataggio del documento
            try
            {
                document = DocSave.addDocGrigia(document, userInfo, userRole);

                // Associazione del canale di spedizione al documento
                ProtoManager.collegaMezzoSpedizioneDocumento(userInfo, channel.IDSystem, document.systemId);
            }
            catch (Exception e)
            {
                SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(String.Empty, true, e.Message + " Id messaggio: " + messageId);
                throw new CreatingDocumentException("Errore durante la creazione del documento");
            }
            // Se tutto è andato bene, la scheda documento ha ora il campo system id popolato, quindi viene aggiunta
            // una voce al log e viene aggiornato l'id profile per la voce nel registro dei messaggi ricevuti
            SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(document.systemId, false,
                                                                            String.Format("Documento relativo alla richiesta con id {0}, creato correttamente.", messageId));
            SimplifiedInteroperabilityLogAndRegistryManager.SetIdProfileForMessage(messageId, document.systemId);

            // Impostazione delle informazioni aggiuntive e salvataggio del documento
            ((Documento)document.documenti[0]).dataArrivo = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
            bool toUpdate;

            document = DocSave.save(userInfo, document, false, out toUpdate, userRole);
            string errPutFile = "";

            try
            {
                // Associazione dell'immagine al documento
                String      err     = String.Empty;
                FileRequest request = document.documenti[0] as FileRequest;
                logger.DebugFormat("IS - Associa documento. Versionid {0}, Versionlabel {1}, version {2}",
                                   request.versionId, request.versionLabel, request.version);

                if (!String.IsNullOrEmpty(interoperabilityMessage.MainDocument.FileName))
                {
                    SimplifiedInteroperabilityFileManager.DownloadFile(
                        interoperabilityMessage.MainDocument,
                        interoperabilityMessage.Sender.AdministrationId,
                        request,
                        userInfo,
                        interoperabilityMessage.Sender.FileManagerUrl,
                        out errPutFile);
                }
                if (!string.IsNullOrEmpty(errPutFile))
                {
                    throw new Exception("Errore durante l'associazione dell'immagine al documento principale");
                }
            }
            catch (Exception e)
            {
                SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(
                    document.systemId,
                    true,
                    String.Format("Errore durante l'associazione dell'immagine per il documento principale. Messaggio eccezione: {0}",
                                  e.Message));
                if (!string.IsNullOrEmpty(errPutFile) && errPutFile.Contains("formato file"))
                {
                    throw new DownloadDocumentException("Errore durante l'associazione dell'immagine al documento principale." + errPutFile + " destinataria.");
                }
                else
                {
                    throw new DownloadDocumentException("Errore durante l'associazione dell'immagine al documento principale");
                }
            }
            AddAttachments(document.docNumber, interoperabilityMessage.Attachments, userInfo, interoperabilityMessage.Sender.AdministrationId, interoperabilityMessage.Sender.FileManagerUrl);
            // Restituzione del documento salvato
            return(document);
        }