Beispiel #1
0
        /// <summary>
        /// Eliminazione di un utente da gruppo di amministrazione
        /// </summary>
        /// <param name="idPeople"></param>
        /// <param name="idGruppo"></param>
        /// <returns></returns>
        public EsitoOperazione EliminaUtenteDaRuoloAmm(string userId, string idAmministrazione)
        {
            EsitoOperazione ret     = new EsitoOperazione();
            IQueryService   qrySrvc = null;

            try
            {
                qrySrvc = this.GetQueryServiceInstance();

                string codiceAmministrazione = string.Format("sys_{0}", DocsPaServices.DocsPaQueryHelper.getCodiceAmministrazione(idAmministrazione).ToLower());

                string query = string.Format("ALTER GROUP '{0}' DROP '{1}'",
                                             TypeGruppo.NormalizeGroupName(codiceAmministrazione).ToLower(),
                                             TypeUtente.NormalizeUserName(userId).ToLower());

                QueryResult queryResult = DfsHelper.executePassThrough(qrySrvc, query);

                logger.Debug(DEBUG_HEADER + "EliminaUtenteDaRuoloAmm completata con SUCCESSO");
                return(ret);
            }
            catch (Exception ex)
            {
                String st = ex.ToString();
                logger.Debug(DEBUG_HEADER + "EliminaUtenteDaRuoloAmm FALLITA, Exception=" + st);
                ret.Codice      = -1;
                ret.Descrizione = ERR_HEADER + "EliminaUtenteDaRuoloAmm";
                return(ret);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Caricamento dei valori delle properties relative allo stato checkout per il documento
        /// </summary>
        /// <param name="documentNumber"></param>
        /// <param name="isStampaRegistro"></param>
        /// <returns></returns>
        protected virtual PropertySet LoadCheckOutProperties(string documentNumber, bool isStampaRegistro)
        {
            ObjectIdentity identity = null;

            if (isStampaRegistro)
            {
                identity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(documentNumber);
            }
            else
            {
                identity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(documentNumber);
            }

            List <string> filters = new List <string>();

            filters.Add("r_object_id");
            filters.Add("object_name");
            filters.Add("r_lock_owner");
            filters.Add("r_lock_date");
            filters.Add(TypeDocumento.CHECKOUT_LOCAL_FILE_PATH);
            filters.Add(TypeDocumento.CHECKOUT_MACHINE_NAME);

            if (!isStampaRegistro)
            {
                // Caricamento informazioni di checkout specifiche per documenti non di tipo stampa registro
                filters.Add(TypeDocumento.TIPO_PROTOCOLLO);
            }

            IObjectService service    = this.GetServiceInstance <IObjectService>(true);
            DataObject     dataObject = DfsHelper.getAllPropsAndFolders(service, identity, filters, false);

            return(dataObject.Properties);
        }
Beispiel #3
0
        /// <summary>
        /// Inserimento di un utente in un ruolo
        /// </summary>
        /// <param name="idPeople"></param>
        /// <param name="idGruppo"></param>
        /// <returns></returns>
        public EsitoOperazione InserisciUtenteInRuolo(string idPeople, string idGruppo)
        {
            EsitoOperazione ret = new EsitoOperazione();

            IQueryService qrySrvc = null;

            try
            {
                qrySrvc = this.GetQueryServiceInstance();

                string codiceRuolo  = DocsPaServices.DocsPaQueryHelper.getCodiceRuoloFromIdGroups(idGruppo);
                string codiceUtente = DocsPaServices.DocsPaQueryHelper.getCodiceUtente(idPeople);

                string query = string.Format("ALTER GROUP '{0}' ADD '{1}'",
                                             TypeGruppo.NormalizeGroupName(codiceRuolo),
                                             TypeUtente.NormalizeUserName(codiceUtente));

                QueryResult queryResult = DfsHelper.executePassThrough(qrySrvc, query);

                logger.Debug(DEBUG_HEADER + "InserisciUtenteInRuolo completata con SUCCESSO");
                return(ret);
            }
            catch (Exception ex)
            {
                String st = ex.ToString();
                logger.Debug(DEBUG_HEADER + "InserisciUtenteInRuolo FALLITA, Exception=" + st);
                ret.Codice      = -1;
                ret.Descrizione = ERR_HEADER + "InserisciUtenteInRuolo";
                return(ret);
            }
        }
Beispiel #4
0
        private void inserisciUtenteInAmministrazione(OrgUtente utente, DataObject userDataObject)
        {
            string codiceAmm = DocsPaQueryHelper.getCodiceAmministrazione(utente.IDAmministrazione);
            string gruppoAmm = TypeGruppo.GetGroupNameForAmministrazione(codiceAmm);

            try
            {
                //inserimento del nuovo utente nel gruppo associato alla amministrazione
                IQueryService qrySrvc = this.GetQueryServiceInstance();
                DfsHelper.insertUserInGroup(TypeUtente.getUserName(utente), gruppoAmm, qrySrvc);

                // eventuale inserimento nel gruppo dei syadmin
                if (utente.Amministratore != null && utente.Amministratore != "0")
                {
                    gruppoAmm = TypeGruppo.GetGroupNameForSysAdminAmministrazione(codiceAmm);
                    DfsHelper.insertUserInGroup(TypeUtente.getUserName(utente), gruppoAmm, qrySrvc);
                }
            }
            catch (Exception e)
            {
                string msg = string.Format(
                    DEBUG_HEADER + ": errore in inserimento utente {0} nel gruppo {1}: {2}",
                    TypeUtente.getUserName(utente), gruppoAmm, e.ToString());
                logger.Debug(msg);
                undoCreateUser(utente);
                throw new ApplicationException(msg, e);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Aggiornamento delle proprietà dell'oggetto "p3_document"
        /// </summary>
        /// <param name="idCheckOut"></param>
        /// <param name="documentNumber"></param>
        /// <param name="machineName"></param>
        /// <param name="documentLocation"></param>
        /// <returns></returns>
        private bool SaveCheckOutDocumentProperties(string idCheckOut, string documentNumber, string documentLocation, string machineName)
        {
            bool retValue = false;

            try
            {
                // Determina se il documento da bloccare è di tipo stampa registro
                bool isStampaRegistro = (DocsPaQueryHelper.isStampaRegistro(documentNumber));

                ObjectIdentity identity = null;

                if (!string.IsNullOrEmpty(idCheckOut))
                {
                    identity = DfsHelper.createObjectIdentityObjId(idCheckOut);
                }
                else
                {
                    if (DocsPaQueryHelper.isStampaRegistro(documentNumber))
                    {
                        identity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(documentNumber);
                    }
                    else
                    {
                        identity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(documentNumber);
                    }
                }

                DataObject dataObject = new DataObject(identity);
                dataObject.Properties = new PropertySet();

                List <Property> propertyList = new List <Property>();
                propertyList.Add(new StringProperty(TypeDocumento.CHECKOUT_LOCAL_FILE_PATH, documentLocation));
                propertyList.Add(new StringProperty(TypeDocumento.CHECKOUT_MACHINE_NAME, machineName));
                dataObject.Properties.Properties.AddRange(propertyList);

                DataPackage dataPackage = new DataPackage(dataObject);
                dataPackage.RepositoryName = dataObject.Identity.RepositoryName;

                IObjectService service = this.GetServiceInstance <IObjectService>(false);
                dataPackage = service.Update(dataPackage, null);

                retValue = (dataPackage.DataObjects.Count > 0);
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug("Errore in Documentum. SaveCheckOutDocumentProperties: " + ex.ToString());
            }

            return(retValue);
        }
Beispiel #6
0
        public void InserisciUtenteInAmm(OrgUtente utente)
        {
            string codiceAmm = DocsPaQueryHelper.getCodiceAmministrazione(utente.IDAmministrazione);
            string gruppoAmm = TypeGruppo.GetGroupNameForAmministrazione(codiceAmm);

            try
            {
                //inserimento del nuovo utente nel gruppo associato alla amministrazione
                IQueryService qrySrvc = this.GetQueryServiceInstance();
                DfsHelper.insertUserInGroup(TypeUtente.getUserName(utente), gruppoAmm, qrySrvc);
            }
            catch (Exception e)
            {
                string msg = string.Format(
                    DEBUG_HEADER + ": errore in inserimento utente {0} nel gruppo {1}: {2}",
                    TypeUtente.getUserName(utente), gruppoAmm, e.ToString());
                logger.Debug(msg);
                throw new ApplicationException(msg, e);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Attivazione di un titolario
        /// </summary>
        /// <param name="titolario"></param>
        /// <returns></returns>
        public bool AttivaTitolario(OrgTitolario titolario)
        {
            bool retValue = true;

            try
            {
                // Verifica della presenza di un titolario attivo
                string repositoryName = DctmConfigurations.GetRepositoryName();

                IObjectService objSrvc = this.GetObjectServiceInstance();

                // Verifica se in documentum è presente un titolario attivo
                bool existTitolarioAttivo = (Dfs4DocsPa.containsTitolarioAttivo(titolario.CodiceAmministrazione, this.GetQueryServiceInstance()));

                DataObject dataObjectTitolarioAttivo = null;

                if (existTitolarioAttivo)
                {
                    // Reperimento oggetto identity per il titolario attivo
                    ObjectIdentity identity = Dfs4DocsPa.getTitolarioAttivoIdentity(titolario.CodiceAmministrazione);

                    // Reperimento oggetto DataObject relativo al titolario attivo (se presente)
                    List <string> filters = new List <string>();
                    filters.Add(TypeTitolario.ID_DOCSPA);
                    dataObjectTitolarioAttivo = DfsHelper.getAllPropsAndFolders(objSrvc, identity, filters, false);
                    string idDocsPa = dataObjectTitolarioAttivo.Properties.Get(TypeTitolario.ID_DOCSPA).GetValueAsString();

                    // Reperimento del titolario appena chiuso in docspa, cui corrisponde il titolario da chiudere in documentum
                    OrgTitolario titolarioChiuso = DocsPaQueryHelper.getTitolario(idDocsPa);

                    dataObjectTitolarioAttivo            = new DataObject();
                    dataObjectTitolarioAttivo.Identity   = Dfs4DocsPa.getTitolarioIdentity(titolarioChiuso.ID);
                    dataObjectTitolarioAttivo.Type       = ObjectTypes.TITOLARIO;
                    dataObjectTitolarioAttivo.Properties = new PropertySet();
                    dataObjectTitolarioAttivo.Properties.Properties.AddRange(Dfs4DocsPa.getTitolarioProperties(titolarioChiuso));
                }

                // Reperimento identity titolario in definizione
                ObjectIdentity identityTitolarioInDef   = Dfs4DocsPa.getTitolarioIdentity(titolario.ID);
                DataObject     dataObjectTitolarioInDef = new DataObject();
                dataObjectTitolarioInDef.Identity   = identityTitolarioInDef;
                dataObjectTitolarioInDef.Type       = ObjectTypes.TITOLARIO;
                dataObjectTitolarioInDef.Properties = new PropertySet();
                dataObjectTitolarioInDef.Properties.Properties.AddRange(Dfs4DocsPa.getTitolarioProperties(titolario));

                List <DataObject> dataObjectList = new List <DataObject>();

                if (existTitolarioAttivo)
                {
                    dataObjectList.Add(dataObjectTitolarioAttivo);
                }

                dataObjectList.Add(dataObjectTitolarioInDef);

                // Creazione oggetto DataPackage
                DataPackage dataPackage = new DataPackage();
                dataPackage.DataObjects.AddRange(dataObjectList);

                dataPackage = objSrvc.Update(dataPackage, null);

                string objectId = ((ObjectId)dataPackage.DataObjects[0].Identity.Value).Id.ToString();

                retValue = (!string.IsNullOrEmpty(objectId));

                if (retValue)
                {
                    logger.Debug(string.Format("Documentum.AttivaTitolario: attivato titolario con id {0}", titolario.ID));
                }
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug("Errore in Documentum.AttivaTitolario: " + ex.ToString());
            }

            return(retValue);
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="nodoTitolario"></param>
        /// <param name="refreshAclIfUpdate">
        /// Se true, indica di aggiornare le entries dell'ACL associata al nodo titolario
        /// </param>
        /// <returns></returns>
        public bool SaveNodoTitolario(OrgNodoTitolario nodoTitolario, bool refreshAclIfUpdate)
        {
            bool retValue = false;

            bool aclCreated = false;

            try
            {
                //titolario.ID  viene SEMPRE valorizzato da ETDOCS; se così non è --> ERRORE
                if (string.IsNullOrEmpty(nodoTitolario.ID))
                {
                    retValue = false;

                    logger.Debug("Errore passaggio dati da ETDOCS: ID nodo titolario mancante");
                }
                else
                {
                    IQueryService querySrvc = this.GetQueryServiceInstance();

                    DataObject dataObject = new DataObject();
                    dataObject.Type = ObjectTypes.NODO_TITOLARIO;

                    DataObject dataObjectFascicoloGenerale = null;

                    // Reperimento oggetto identity per il titolario corrente
                    ObjectIdentity nodoTitolarioIdentity = Dfs4DocsPa.getNodoTitolarioIdentity(nodoTitolario.ID);

                    // Verifica esistenza nodo titolario
                    bool insertMode = (!Dfs4DocsPa.containsNodoTitolario(nodoTitolario.ID, querySrvc));

                    IObjectService objSrvc = this.GetObjectServiceInstance();

                    if (insertMode)
                    {
                        // Modalità di inserimento
                        // Creazione oggetto identity per nuovo inserimento
                        dataObject.Identity = new ObjectIdentity(DctmConfigurations.GetRepositoryName());

                        // Determinazione dell'oggetto parent del nodo di titolario da inserire
                        ObjectIdentity parentIdentity = null;

                        if (nodoTitolario.Livello == "1")
                        {
                            // Se nodo di primo livello, deve essere legato alla struttura di titolario
                            parentIdentity = Dfs4DocsPa.getTitolarioIdentity(nodoTitolario.ID_Titolario);
                        }
                        else
                        {
                            // Se nodo figlio di un altro nodo, lo lega al padre
                            parentIdentity = Dfs4DocsPa.getNodoTitolarioIdentity(nodoTitolario.IDParentNodoTitolario);
                        }

                        dataObject.Relationships = new List <Relationship>();
                        dataObject.Relationships.Add(DfsHelper.createParentFolderRelationship(parentIdentity));

                        // Creazione fascicolo generale, figlio nodo del titolario da creare
                        dataObjectFascicoloGenerale          = new DataObject();
                        dataObjectFascicoloGenerale.Type     = ObjectTypes.FASCICOLO_GENERALE;
                        dataObjectFascicoloGenerale.Identity = new ObjectIdentity(DctmConfigurations.GetRepositoryName());

                        // Creazione oggetto relationship
                        dataObjectFascicoloGenerale.Relationships = new List <Relationship>();
                        dataObjectFascicoloGenerale.Relationships.Add(DfsHelper.createParentFolderRelationship(nodoTitolarioIdentity));

                        dataObjectFascicoloGenerale.Properties = new PropertySet();
                        dataObjectFascicoloGenerale.Properties.Properties.AddRange(Dfs4DocsPa.getFascicoloGeneraleProperties(nodoTitolario));
                    }
                    else
                    {
                        // Modalità di aggiornamento

                        // Reperimento oggetto identity per nodo titolario da modificare
                        dataObject.Identity = nodoTitolarioIdentity;
                    }

                    // Impostazione proprietà nodo titolario
                    dataObject.Properties = new PropertySet();
                    dataObject.Properties.Properties.AddRange(Dfs4DocsPa.getNodoTitolarioProperties(nodoTitolario));

                    List <DataObject> dataObjectList = new List <DataObject>();
                    dataObjectList.Add(dataObject);
                    if (dataObjectFascicoloGenerale != null)
                    {
                        // Inserimento DataObject relativo al fascicolo generale
                        dataObjectList.Add(dataObjectFascicoloGenerale);
                    }

                    // Creazione oggetto DataPackage
                    DataPackage dataPackage = new DataPackage();
                    dataPackage.DataObjects.AddRange(dataObjectList);
                    dataPackage.RepositoryName = DctmConfigurations.GetRepositoryName();

                    // Save oggetto nodo titolario in documentum
                    if (insertMode)
                    {
                        // Creazione ACL, comune sia per il nodo titolario che per il fascicolo generale in esso contenuto
                        CustomServices.AclDefinition aclDefinition = this.CreateAclNodoTitolario(nodoTitolario);

                        // ACL del titolario creata
                        aclCreated = true;

                        // Impostazione delle properties relative all'acl per il nodo titolario
                        AclHelper.setAclObjectProperties(dataObject.Properties, aclDefinition);

                        // Impostazione delle properties relative all'acl per il fascicolo generale
                        AclHelper.setAclObjectProperties(dataObjectFascicoloGenerale.Properties, aclDefinition);

                        dataPackage = objSrvc.Create(dataPackage, null);
                    }
                    else
                    {
                        dataPackage = objSrvc.Update(dataPackage, null);

                        if (refreshAclIfUpdate)
                        {
                            // Aggiornamento delle entries dell'acl associata al nodo
                            this.RefreshAclNodoTitolario(nodoTitolario);
                        }
                    }

                    retValue = (dataPackage.DataObjects.Count > 0);

                    if (retValue)
                    {
                        logger.Debug(string.Format("Documentum.SaveNodoTitolario: salvato nodo di titolario con id {0}", nodoTitolario.ID));
                    }
                }
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug("Errore in Documentum.SaveNodoTitolario: " + ex.ToString());

                if (aclCreated)
                {
                    // Se l'ACL è stata creata, viene rimossa
                    this.DeleteAclNodoTitolario(nodoTitolario);
                }
            }

            return(retValue);
        }
Beispiel #9
0
        /// <summary>
        /// Inserimento o aggiornamento dei metadati generali relativi
        /// all’intera struttura di classificazione dei documenti
        /// </summary>
        /// <param name="titolario"></param>
        /// <returns></returns>
        public bool SaveTitolario(OrgTitolario titolario)
        {
            bool retValue = false;

            try
            {
                //titolario.ID viene SEMPRE valorizzato da ETDOCS; se così non è --> ERRORE
                if (string.IsNullOrEmpty(titolario.ID))
                {
                    logger.Debug("Errore passaggio dati da ETDOCS: ID Titolario mancante");
                }
                else
                {
                    // Reperimento istanza objectservice
                    IObjectService objSrvc = GetObjectServiceInstance();

                    DataObject dataObject = new DataObject();
                    dataObject.Type = ObjectTypes.TITOLARIO;

                    // Reperimento oggetto identity per il titolario corrente
                    ObjectIdentity titolarioIdentity = Dfs4DocsPa.getTitolarioIdentity(titolario.ID);

                    IQueryService querySrvc = this.GetQueryServiceInstance();

                    // Verifica se il titolario è già esistente
                    bool insertMode = (!Dfs4DocsPa.containsTitolario(titolario.ID, querySrvc));

                    if (insertMode)
                    {
                        // Creazione oggetto identity per nuovo inserimento
                        dataObject.Identity = new ObjectIdentity(DctmConfigurations.GetRepositoryName());

                        // Modalità di in inserimento, creazione oggetto Identity parent e oggetto relationship
                        ObjectIdentity parentIdentity = DfsHelper.createObjectIdentityByPath(DocsPaAdminCabinet.getRootTitolario(titolario.CodiceAmministrazione));

                        dataObject.Relationships = new List <Relationship>();
                        dataObject.Relationships.Add(DfsHelper.createParentFolderRelationship(parentIdentity));
                    }
                    else
                    {
                        // Reperimento oggetto identity per titolario da modificare
                        dataObject.Identity = titolarioIdentity;
                    }

                    // Impostazione proprietà titolario
                    dataObject.Properties = new PropertySet();
                    dataObject.Properties.Properties.AddRange(Dfs4DocsPa.getTitolarioProperties(titolario));

                    DataPackage dataPackage = new DataPackage(dataObject);
                    dataPackage.RepositoryName = DctmConfigurations.GetRepositoryName();

                    // Save oggetto titolario in documentum
                    if (insertMode)
                    {
                        // Reperimento ACL dell'amministrazione da associare al titolario
                        CustomServices.AclDefinition aclDefinition = Dfs4DocsPa.getAclDefinitionAmministrazione(titolario.CodiceAmministrazione);

                        // Impostazione delle properties relative all'acl per il nodo titolario
                        AclHelper.setAclObjectProperties(dataObject.Properties, aclDefinition);

                        dataPackage = objSrvc.Create(dataPackage, null);
                    }
                    else
                    {
                        dataPackage = objSrvc.Update(dataPackage, null);
                    }

                    retValue = (dataPackage.DataObjects.Count > 0);

                    if (retValue)
                    {
                        logger.Debug(string.Format("Documentum.SaveTitolario: salvato titolario con id {0}", titolario.ID));
                    }
                }
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug("Errore in Documentum.SaveTitolario: " + ex.ToString());
            }

            return(retValue);
        }
Beispiel #10
0
        /// <summary>
        /// Checkin di un documento in stato checkout
        /// </summary>
        /// <param name="checkOutStatus"></param>
        /// <param name="library"></param>
        /// <returns></returns>
        public bool CheckIn(DocsPaVO.CheckInOut.CheckOutStatus checkOutStatus, byte[] content, string checkInComments)
        {
            bool retValue = false;

            try
            {
                // Creazione di un nuovo DataObject che rappresenta il documento da sbloccare
                DataObject dataObject = new DataObject();
                dataObject.Type = ObjectTypes.DOCUMENTO;

                // Reperimento identity del documento da sbloccare
                if (DocsPaQueryHelper.isStampaRegistro(checkOutStatus.DocumentNumber))
                {
                    dataObject.Identity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(checkOutStatus.DocumentNumber);
                }
                else
                {
                    dataObject.Identity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(checkOutStatus.DocumentNumber);
                }

                List <Property> propertyList = new List <Property>();

                // Impostazione numero versione
                propertyList.Add(new NumberProperty(TypeDocumento.NUMERO_VERSIONE, DocsPaQueryHelper.getDocumentNextVersionId(checkOutStatus.IDDocument)));

                // Rimozione valore proprietà p3_locked_filepath
                propertyList.Add(new StringProperty(TypeDocumento.CHECKOUT_LOCAL_FILE_PATH, string.Empty));

                // Rimozione valore proprietà p3_locked_file_machinename
                propertyList.Add(new StringProperty(TypeDocumento.CHECKOUT_MACHINE_NAME, string.Empty));

                dataObject.Properties = new PropertySet();
                dataObject.Properties.Properties.AddRange(propertyList);

                // Temporaneo, inserimento contentuto file
                OperationOptions opts = new OperationOptions();

                CheckinProfile checkInProfile = new CheckinProfile();
                checkInProfile.MakeCurrent         = true;
                checkInProfile.DeleteLocalFileHint = true;

                opts.Profiles.Add(checkInProfile);

                // Creazione di un nuovo oggetto BinaryContent
                BinaryContent binaryContent = new BinaryContent();
                binaryContent.Value = content;

                string ext = System.IO.Path.GetExtension(checkOutStatus.DocumentLocation);
                if (ext.StartsWith("."))
                {
                    ext = ext.Substring(1);
                }
                string fileFormat = DfsHelper.getDctmFileFormat(this.GetServiceInstance <IQueryService>(false), ext);

                binaryContent.Format = fileFormat;

                dataObject.Contents.Add(binaryContent);

                DataPackage dataPackage = new DataPackage(dataObject);
                dataPackage.RepositoryName = DctmConfigurations.GetRepositoryName();

                IVersionControlService service = this.GetServiceInstance <IVersionControlService>(false);

                VersionStrategy strategy = VersionStrategy.IMPLIED;
                if (!DocsPaQueryHelper.isDocumentAcquisito(checkOutStatus.IDDocument))
                {
                    strategy = VersionStrategy.SAME_VERSION;
                }

                dataPackage = service.Checkin(dataPackage, strategy, false, null, opts);

                retValue = (dataPackage.DataObjects.Count > 0);

                if (retValue)
                {
                    logger.Debug(string.Format("Documentum.CheckIn: effettuato il checkin del documento con id {0} e docnumber {1}", checkOutStatus.IDDocument, checkOutStatus.DocumentNumber));
                }
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug("Errore in Documentum.CheckIn: " + ex.ToString());
            }

            return(retValue);
        }
Beispiel #11
0
        /// <summary>
        /// Inserimento di un documento in un folder
        /// </summary>
        /// <param name="idProfile"></param>
        /// <param name="idFolder"></param>
        /// <returns></returns>
        public bool AddDocumentInFolder(string idProfile, string idFolder)
        {
            logger.Info("BEGIN");
            bool retValue = false;

            // Reperimento idfolder per il record di tipo "C" in docspa (root folder)
            idFolder = DocsPaQueryHelper.getIdFolderCType(idFolder);

            // Reperimento docNumber da idProfile
            string docNumber = DocsPaQueryHelper.getDocNumber(idProfile);

            //bool stampaRegistro = DocsPaQueryHelper.isStampaRegistro(docNumber);
            bool stampaRegistro = DocsPaQueryHelper.isStampaRegistroRepertorio(docNumber);

            try
            {
                IObjectService objectService = DctmServiceFactory.GetServiceInstance <IObjectService>(UserManager.ImpersonateSuperUser());

                // 1. recuperare il documento con tutti i link a folder attuali

                ObjectIdentity documentIdentity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(docNumber);

                if (stampaRegistro)
                {
                    documentIdentity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(docNumber);
                }

                // 2. Creare il nuovo link al folder di classificazione
                ObjectIdentity folderIdentity = null;

                // Verifica se l'idFolder si riferisce ad un fascicolo o a un sottofascicolo
                if (!DocsPaQueryHelper.isSottofascicolo(idFolder))
                {
                    // Reperimento id del fascicolo dal folder (record tipo "C")
                    string tipoFascicolo;
                    string idFascicolo = DocsPaQueryHelper.getIdFascicoloFromFolder(idFolder, out tipoFascicolo);

                    folderIdentity = Dfs4DocsPa.getFascicoloIdentityBySystemId(idFascicolo);

                    //Effettuo un refresh dei permessi sul fascicolo per allineare le ACL con DOCUMENTUM
                    //Fascicolo fascicolo = DocsPaQueryHelper.getFascicolo(idFascicolo, this.InfoUtente);
                    //if (fascicolo != null)
                    //  RefreshAclFascicolo(fascicolo);
                }
                else
                {
                    folderIdentity = Dfs4DocsPa.getSottofascicoloIdentityById(idFolder);
                }

                ReferenceRelationship addRelationship = DfsHelper.createParentFolderRelationship(folderIdentity);
                //la aggiungeremo alla lista degli update nell'ultimo passo

                // 3. salvare
                DataObject updatedDoc = new DataObject(documentIdentity);
                updatedDoc.Relationships.Add(addRelationship);

                // 4. Allineamento ACL documento:
                //  per coerenza è necessario che, una volta che il documento
                //  viene inserito in un fascicolo, questo diventi visibile anche
                //  a tutti gli utenti che hanno la visibilità solo sul fascicolo e
                //  non sul documento
                this.UpdateAclDocumento(idProfile, docNumber);

                DataPackage dataPackage = new DataPackage(updatedDoc);
                dataPackage = objectService.Update(dataPackage, null);

                retValue = (dataPackage.DataObjects.Count > 0);

                if (retValue)
                {
                    logger.Debug(string.Format("Documentum.AddDocumentInFolder: inserito il documento con docnumber {0} nel folder con id {1}", idProfile, idFolder));
                }
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug(string.Format("Errore in Documentum.AddDocumentInFolder:\n{0}", ex.ToString()));
            }
            logger.Info("END");
            return(retValue);
        }
Beispiel #12
0
        /// <summary>
        /// Rimozione di un documento dal fascicolo (in generale, da tutti i folder presenti nel fascicolo)
        /// </summary>
        /// <param name="idProfile"></param>
        /// <param name="folder"></param>
        /// <returns></returns>
        public bool RemoveDocumentFromProject(string idProfile, DocsPaVO.fascicolazione.Folder folder)
        {
            logger.Debug(string.Format("RemoveDocumentFromProject - IdProfile: {0} - IdFolder: {1} - IdFascicolo: {2}", idProfile, folder.systemID, folder.idFascicolo));

            // 1. recuperare tutti link del documento
            // 2. identificare quelli da rimuovere (tutti quelli sotto il folder in input)
            // 3. aggiungere eventualmente il link a documenti non classificati
            //    (se non c'è neanche più un link residuo)

            bool           retValue = false;
            IObjectService objSrvc  = null;

            // Reperimento docNumber da idProfile
            string docNumber = DocsPaQueryHelper.getDocNumber(idProfile);

            bool isStampaRegistro = DocsPaQueryHelper.isStampaRegistroRepertorio(docNumber);

            try
            {
                string repositoryName = DctmConfigurations.GetRepositoryName();
                //objSrvc = this.GetObjectServiceInstance();
                objSrvc = DctmServiceFactory.GetServiceInstance <IObjectService>(UserManager.ImpersonateSuperUser());
                List <Relationship> removeRelationships = new List <Relationship>();

                // 1. recuperare tutti link del documento:
                ObjectIdentity documentIdentity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(docNumber);
                if (isStampaRegistro)
                {
                    documentIdentity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(docNumber);
                }

                logger.Debug("RemoveDocumentFromProject: 1.recuperare tutti link del documento");

                List <string> filters = new List <string>();
                filters.Add("r_object_id");
                DataObject documentData = DfsHelper.getAllPropsAndFolders(objSrvc, documentIdentity, filters, true);

                // 2. identificare quelli da rimuovere (tutti quelli sotto il folder in input):
                if (documentData.Relationships != null && documentData.Relationships.Count > 0)
                {
                    logger.Debug("RemoveDocumentFromProject:  2. identificare quelli da rimuovere (tutti quelli sotto il folder in input)");

                    // 2a. recuperiamo la root del nodo associato a Folder:
                    ObjectIdentity folderIdentity = Dfs4DocsPa.getFascicoloIdentityBySystemId(folder.idFascicolo);

                    if (folderIdentity.ValueType == ObjectIdentityType.QUALIFICATION)
                    {
                        logger.Debug(((Qualification)folderIdentity.Value).GetValueAsString());
                    }

                    filters = new List <string>();
                    filters.Add("r_folder_path");
                    DataObject folderData = DfsHelper.getAllPropsAndFolders(objSrvc, folderIdentity, filters, false);
                    Property   p          = folderData.Properties.Get("r_folder_path");
                    if (p == null)
                    {
                        throw new Exception("Impossibile leggere r_folder_path");
                    }
                    string rootPath = p.GetValueAsString();

                    logger.Debug(string.Format("RemoveDocumentFromProject: RootPath: {0}", rootPath));

                    foreach (ReferenceRelationship r in documentData.Relationships)
                    {
                        // 2b. recuperiamo il path del folder in esame
                        // qui contiamo sul fatto che gli objectIdentity dei folder a cui è linkato vengano istanziati
                        // come OBJECT_ID
                        string targetDctmId = ((ObjectId)r.Target.Value).Id;

                        logger.Error(string.Format("LOG-DEBUG: RemoveDocumentFromProject: targetDctmId: {0}", targetDctmId));

                        ObjectIdentity targetIdentity = new ObjectIdentity(new ObjectId(targetDctmId), repositoryName);
                        DataObject     targetData     = DfsHelper.getAllPropsAndFolders(objSrvc, targetIdentity, filters, false);

                        Property prop = targetData.Properties.Properties.Find(e => e.Name == "r_folder_path");

                        if (prop != null)
                        {
                            string targetPath = targetData.Properties.Get("r_folder_path").GetValueAsString();

                            logger.Debug(string.Format("RemoveDocumentFromProject: targetPath: {0}", targetPath));

                            //se il target è sotto la root allora è da rimuovere
                            if (targetPath.StartsWith(rootPath))
                            {
                                removeRelationships.Add(DfsHelper.createRemoveParentFolder(targetIdentity));
                            }
                        }
                    }
                }

                // 3. committare il tutto
                DataObject updatedDoc = new DataObject(documentIdentity);
                updatedDoc.Relationships = removeRelationships;

                DataPackage dp    = new DataPackage(updatedDoc);
                DataPackage retDp = objSrvc.Update(dp, null);

                logger.Debug("RemoveDocumentFromProject: 3. committare il tutto");

                if (retDp.DataObjects.Count > 0)
                {
                    retValue = true;

                    logger.Debug(string.Format("Documentum.RemoveDocumentFromProject: rimosso documento con docnumber {0} dal fascicolo con id {0}", idProfile, folder.systemID));
                }
            }
            catch (Exception e)
            {
                retValue = false;

                logger.Debug(string.Format("Errore in Documentum.RemoveDocumentFromProject:\n{0}", e.ToString()));
            }

            return(retValue);
        }
Beispiel #13
0
        /// <summary>
        /// Creazione nuovo sottofascicolo
        /// </summary>
        /// <param name="folder"></param>
        /// <param name="ruolo"></param>
        /// <param name="result"></param>
        /// <param name="ruoliSuperiori">
        /// Ruoli superiori cui è impostata la visibilità del sottofascicolo
        /// </param>
        /// <returns></returns>
        public bool CreateFolder(DocsPaVO.fascicolazione.Folder folder, DocsPaVO.utente.Ruolo ruolo, out DocsPaVO.fascicolazione.ResultCreazioneFolder result, out DocsPaVO.utente.Ruolo[] ruoliSuperiori)
        {
            bool retValue = false;

            result         = ResultCreazioneFolder.GENERIC_ERROR;
            ruoliSuperiori = null;

            try
            {
                // Recuperare l'ID del padre del folder: dato che la modalità è diversa se il padre
                // è Fascicolo o Sottofascicolo, è necessario verificare la casistica

                // Caso in cui il parent del sottofascicolo è un sottofascicolo stesso
                Qualification qualSottoFascicoloParent = Dfs4DocsPa.getSottofascicoloQualificationById(folder.idParent);
                string        parentId = DfsHelper.getDctmObjectId(this.GetServiceInstance <IQueryService>(false), qualSottoFascicoloParent);

                if (string.IsNullOrEmpty(parentId))
                {
                    // Caso in cui il parent del sottofascicolo è un fascicolo stesso
                    qualSottoFascicoloParent = Dfs4DocsPa.getFascicoloQualificationById(folder.idFascicolo);
                    parentId = DfsHelper.getDctmObjectId(this.GetServiceInstance <IQueryService>(false), qualSottoFascicoloParent);
                }

                if (!string.IsNullOrEmpty(parentId))
                {
                    ObjectIdentity parentIdentity = new ObjectIdentity(new ObjectId(parentId), DctmConfigurations.GetRepositoryName());

                    ObjectIdentity identity   = new ObjectIdentity(DctmConfigurations.GetRepositoryName());
                    DataObject     dataObject = new DataObject(identity, ObjectTypes.SOTTOFASCICOLO);
                    dataObject.Properties.Properties.AddRange(Dfs4DocsPa.getSottoFascicoloProperties(folder));
                    dataObject.Relationships.Add(DfsHelper.createParentFolderRelationship(parentIdentity));

                    // Reperimento ACL del fascicolo di appartenenza e associazione al sottofascicolo
                    CustomServices.AclDefinition aclDefinition = this.GetAclDefinitionSottoFascicolo(folder);
                    AclHelper.setAclObjectProperties(dataObject.Properties, aclDefinition);

                    DataPackage dataPackage = new DataPackage(dataObject);
                    dataPackage = this.GetServiceInstance <IObjectService>(false).Create(dataPackage, null);

                    retValue = (dataPackage.DataObjects.Count == 1);

                    if (retValue)
                    {
                        result = ResultCreazioneFolder.OK;

                        logger.Debug(string.Format("Documentum.CreateFolder: creato sottofascicolo con id {0}", folder.systemID));
                    }
                }
                else
                {
                    throw new ApplicationException(string.Format("Non è stato possibile reperire l'oggetto parent per il folder con id '{0}'", folder.systemID));
                }
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug(string.Format("Errore in Documentum.CreateFolder:\n{0}", ex.ToString()));
            }

            return(retValue);
        }
Beispiel #14
0
        /// <summary>
        /// Creazione di un nuovo fascicolo in DCTM
        /// </summary>
        /// <remarks>
        ///
        /// PreCondizioni:
        ///     Il fascicolo è stato inserito correttamente in DocsPa
        ///     ed è stato generato un'identificativo univoco
        ///
        /// PostCondizioni:
        ///     Creato un oggetto in Documentum corrispondente all'oggetto
        ///     fascicolo di DocsPa. L'oggetto avrà i metadati del fascicolo
        ///     per la sola consultazione in documentum.
        ///
        /// </remarks>
        /// <param name="classifica"></param>
        /// <param name="fascicolo"></param>
        /// <param name="ruolo"></param>
        /// <param name="enableUfficioReferente"></param>
        /// <returns></returns>
        public bool CreateProject(Classificazione classifica, Fascicolo fascicolo, Ruolo ruolo, bool enableUfficioReferente, out ResultCreazioneFascicolo result)
        {
            logger.Info("BEGIN");
            bool retValue = false;

            result = ResultCreazioneFascicolo.GENERIC_ERROR;

            CustomServices.AclDefinition aclFascicolo = null;

            try
            {
                //fascicolo.systemID  viene SEMPRE valorizzato da ETDOCS; se così non è --> ERRORE
                if (string.IsNullOrEmpty(fascicolo.systemID))
                {
                    logger.Debug("Errore passaggio dati da ETDOCS.");
                }
                else
                {
                    // Reperimento dell'objectidentity relativo al nodo titolario in cui andrà inserito il fascicolo
                    ObjectIdentity nodoTitolarioIdentity = Dfs4DocsPa.getNodoTitolarioIdentity(fascicolo.idClassificazione);

                    // Reperimento properties del fascicolo procedimentale
                    PropertySet props = new PropertySet();
                    props.Properties.AddRange(Dfs4DocsPa.getFascicoloProcedimentaleProperties(fascicolo));

                    // Creazione delle ACL per il fascicolo
                    aclFascicolo = this.CreateAclFascicolo(fascicolo, ruolo);

                    // Associazione delle ACL al fascicolo da creare
                    AclHelper.setAclObjectProperties(props, aclFascicolo);

                    ObjectIdentity identity   = new ObjectIdentity(DctmConfigurations.GetRepositoryName());
                    DataObject     dataObject = new DataObject(identity, ObjectTypes.FASCICOLO_PROCEDIMENTALE);
                    dataObject.Properties = props;
                    dataObject.Relationships.Add(DfsHelper.createParentFolderRelationship(nodoTitolarioIdentity));

                    DataPackage dataPackage = new DataPackage(dataObject);

                    IObjectService objectService = this.GetServiceInstance <IObjectService>(false);
                    dataPackage = objectService.Create(dataPackage, null);

                    retValue = (dataPackage.DataObjects.Count == 1);

                    if (retValue)
                    {
                        result = ResultCreazioneFascicolo.OK;

                        logger.Debug(string.Format("Documentum.CreateProject: creato fascicolo con id {0}", fascicolo.systemID));
                    }
                }
            }
            catch (Exception ex)
            {
                retValue = false;
                result   = ResultCreazioneFascicolo.GENERIC_ERROR;

                logger.Debug(string.Format("Errore in Documentum.CreateProject:\n{0}", ex.ToString()));

                if (aclFascicolo != null)
                {
                    // Rimozione ACL fascicolo in caso di errore
                    this.DeleteAcl(aclFascicolo);
                }
            }
            logger.Info("END");
            return(retValue);
        }
Beispiel #15
0
        /// <summary>
        /// Modifica dei dati di un utente in amministrazione
        /// </summary>
        /// <param name="utente"></param>
        /// <returns></returns>
        public EsitoOperazione ModificaUtente(OrgUtente utente)
        {
            EsitoOperazione ret            = new EsitoOperazione();
            string          logMsg         = string.Empty;
            IObjectService  objSrvc        = null;
            IQueryService   qrySvc         = null;
            string          repositoryName = DctmConfigurations.GetRepositoryName();
            bool            wasSysAdmin    = false;
            bool            isSysAdmin     = false;
            string          gruppoSysAdm;
            string          codiceAmm;

            // test sui campi obbligatori
            if (string.IsNullOrEmpty(utente.Codice) ||
                string.IsNullOrEmpty(utente.Email) ||
                string.IsNullOrEmpty(utente.IDPeople) ||
                string.IsNullOrEmpty(utente.UserId))
            {
                logMsg          = ERR_HEADER + "ModificaUtente: dati insufficienti";
                ret.Codice      = -1;
                ret.Descrizione = logMsg;
                logger.Debug(logMsg);
                return(ret);
            }

            try
            {
                objSrvc = this.GetObjectServiceInstance();
                qrySvc  = this.GetQueryServiceInstance();

                ObjectIdentity userIdentity = Dfs4DocsPa.getUserIdentityByName(TypeUtente.getUserName(utente));

                // non è possibile cambiare il nome di un utente
                List <string> filters = new List <string>();
                filters.Add("user_name");
                DataObject oldData = DfsHelper.getAllPropsAndFolders(objSrvc, userIdentity, filters, false);
                Property   oldName = oldData.Properties.Get("user_name");
                if (oldName == null)
                {
                    ret.Codice      = -1;
                    logMsg          = ERR_HEADER + "ModificaUtente: impossibile leggere il vecchio nome dell'utente";
                    ret.Descrizione = logMsg;
                    logger.Debug(logMsg);
                    return(ret);
                }
                if (!oldName.GetValueAsString().Equals(utente.UserId, StringComparison.OrdinalIgnoreCase))
                {
                    ret.Codice      = -1;
                    logMsg          = ERR_HEADER + "ModificaUtente: non è possibile modificare il nome dell'utente";
                    ret.Descrizione = logMsg;
                    logger.Debug(logMsg);
                    return(ret);
                }

                // dobbiamo capire se prima dell'update era sysAdmin oppure no
                codiceAmm    = DocsPaQueryHelper.getCodiceAmministrazione(utente.IDAmministrazione);
                gruppoSysAdm = TypeGruppo.GetGroupNameForSysAdminAmministrazione(codiceAmm);
                wasSysAdmin  = DfsHelper.isUserMemberOf(TypeUtente.getUserName(utente), gruppoSysAdm, qrySvc);
                isSysAdmin   = (utente.Amministratore != null && utente.Amministratore != "0");

                // verifico se sia stata modificata la password o meno
                //     if (!string.IsNullOrEmpty(utente.Password))
                //     {

                // eliminato controllo su presenza password, gli altri dati dell'utente devono essere modificati
                // anche senza un cambio password (speriamo almeno..) Necessario per replicare stato attivazione rispetto a docspa.
                // il campo password non viene passato se non è valorizzato

                DataObject userData = new DataObject(userIdentity, ObjectTypes.UTENTE);

                // Reperimento properties utente
                userData.Properties.Properties.AddRange(Dfs4DocsPa.getUserProperties(utente));

                DataPackage pkg = new DataPackage(userData);
                pkg = objSrvc.Update(pkg, null);

                if (pkg.DataObjects.Count > 0)
                {
                    // eventuale inserimento nel gruppo dei syadmin
                    if (isSysAdmin && !wasSysAdmin)
                    {
                        DfsHelper.insertUserInGroup(TypeUtente.getUserName(utente), gruppoSysAdm, qrySvc);
                    }
                    else if (wasSysAdmin && !isSysAdmin)
                    {
                        DfsHelper.removeUserFromGroup(TypeUtente.getUserName(utente), gruppoSysAdm, qrySvc);
                    }

                    ret.Codice      = 0;
                    ret.Descrizione = string.Empty;

                    logger.Debug(DEBUG_HEADER + "ModificaUtente completata con SUCCESSO");
                }
                else
                {
                    throw new ApplicationException();
                }

                /**  }
                 * else
                 * {
                 *    ret.Codice = 0;
                 *    ret.Descrizione = string.Empty;
                 *
                 *    logger.Debug(DEBUG_HEADER + "ModificaUtente completata con SUCCESSO");
                 * } */
                return(ret);
            }
            catch (Exception ex)
            {
                String st = ex.ToString();
                logger.Error(DEBUG_HEADER + "ModificaUtente FALLITA, Exception=" + st);
                ret.Codice      = -1;
                ret.Descrizione = ERR_HEADER + "ModificaUtente";
                return(ret);
            }
        }