Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
Exemple #4
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);
            }
        }