internal static string createVersionFNET(string nomeFile, ref DocsPaVO.documento.FileRequest fileRequest, string idamministrazione, string dst) { IDMError.ErrorManager idmErrorManager = new IDMError.ErrorManager(); try { string path = ConfigurationManager.AppSettings["FNET_pathServer"]; DocsPaDocumentale_FILENET.Documentale.UserManager userManager = new DocsPaDocumentale_FILENET.Documentale.UserManager(); IDMObjects.Library oLibrary = userManager.getFileNETLib(idamministrazione); oLibrary.LogonId = dst; IDMObjects.IFnFolderDual folder = DocumentManagement.getRootFolder(oLibrary); IDMObjects.IFnDocumentDual docFNET = (IDMObjects.IFnDocumentDual)oLibrary.GetObject(IDMObjects.idmObjectType.idmObjTypeDocument, fileRequest.docNumber, oLibrary, null, null); bool canCheckout = docFNET.GetState(IDMObjects.idmDocState.idmDocCanCheckout); if (canCheckout) { docFNET.Version.CheckoutNoCopy(); } else { throw new Exception("Il file è utilizzato da un altro processo"); } bool canCheckin = docFNET.GetState(IDMObjects.idmDocState.idmDocCanCheckin); docFNET.Version.Checkin(path, nomeFile, IDMObjects.idmCheckin.idmCheckinKeep); IDMObjects.Version vers = docFNET.Version; bool canIndex = docFNET.GetState(IDMObjects.idmDocState.idmDocCanIndex); if (canIndex) { vers.IndexContent(IDMObjects.idmIndex.idmIndexContent); } string numVers = getFNETnumVers(docFNET.Version.Number); //OLD: fileRequest.versionId = numVers + getFNETename(fileRequest.docNumber); fileRequest.fNversionId = numVers + getFNETename(fileRequest.docNumber); return(numVers); } catch (Exception e) { string msg = e.Message; for (int i = 0; i < idmErrorManager.Errors.Count; i++) { msg += " " + idmErrorManager.Errors[i].Description; } throw new Exception(msg); } }
internal void unlock(DocsPaVO.documento.FileRequest fileReq, string idamministrazione) { int numVersione = getNumVers(fileReq.versionId); DocsPaDocumentale_FILENET.Documentale.UserManager userManager = new DocsPaDocumentale_FILENET.Documentale.UserManager(); IDMObjects.Library oLibrary = userManager.getFileNETLib(idamministrazione); IDMObjects.IFnDocumentDual docFNET = (IDMObjects.IFnDocumentDual)oLibrary.GetObject(IDMObjects.idmObjectType.idmObjTypeDocument, fileReq.docNumber, oLibrary, null, null); bool canCheckin = docFNET.GetState(IDMObjects.idmDocState.idmDocCanCheckin); if (canCheckin) { docFNET.Version.CancelCheckout(IDMObjects.idmCancelCheckout.idmCancelCheckoutNoKeep); } }
internal static DocsPaVO.documento.SchedaDocumento addFirstVersione(DocsPaVO.documento.SchedaDocumento schedaDocumento, IDMObjects.IFnDocumentDual IDMdoc) { DocsPaVO.documento.Documento versione = null; logger.Debug("sono in add first versione"); if (schedaDocumento.documenti == null) { schedaDocumento.documenti = new ArrayList(); } if (schedaDocumento.documenti.Count == 0) { versione = new DocsPaVO.documento.Documento(); } else { versione = (DocsPaVO.documento.Documento)schedaDocumento.documenti[0]; } versione.docNumber = schedaDocumento.docNumber; // gestione dei firmatari setFirmatari(versione); versione.fileSize = "0"; if (versione.daInviare != null && versione.daInviare.Length > 0) { versione.daInviare = "1"; } //string nomeFile = ConfigurationManager.AppSettings["FNET_pathServer"] + ConfigurationManager.AppSettings["FNET_nomeFileTemp"]; logger.Debug("prima di SaveNew "); // logger.Debug("chiamata saveNew con file in path: " + nomeFile); //file tmp dinamico costruito on line su percorso standard string nomeFile = ConfigurationManager.AppSettings["FNET_pathServer"] + schedaDocumento.idPeople + "_void.tmp"; try { // verifico preesistenza if (System.IO.File.Exists(nomeFile)) { System.IO.File.Delete(nomeFile); } using (System.IO.StreamWriter writer = new System.IO.StreamWriter(nomeFile)) { writer.WriteLine(" "); writer.Flush(); writer.Close(); } IDMdoc.SaveNew(nomeFile, IDMObjects.idmSaveNewOptions.idmDocSaveNewKeep | IDMObjects.idmSaveNewOptions.idmDocSaveNewIndexContent); logger.Debug("chiamata saveNew con file in path: " + nomeFile + " esisto OK"); bool canCheckout = IDMdoc.GetState(IDMObjects.idmDocState.idmDocCanCheckout); logger.Debug("dopo di GetState canCheckout su doc di saveNew id:" + IDMdoc.ID); bool canCheckin = IDMdoc.GetState(IDMObjects.idmDocState.idmDocCanCheckin); logger.Debug("dopo di GetState canCheckin su doc di saveNew id:" + IDMdoc.ID); versione.versionId = getFNETnumVers("1") + schedaDocumento.docNumber; logger.Debug("dopo di versionID creata: " + versione.versionId); if (schedaDocumento.documenti.Count == 0) { schedaDocumento.documenti.Add(versione); } else { schedaDocumento.documenti[0] = versione; } updateVers(versione); return(schedaDocumento); } catch (Exception ex) { IDMError.ErrorManager idmErrorManager = new IDMError.ErrorManager(); logger.Debug(ex.Message); string msg = ex.Message; for (int i = 0; i < idmErrorManager.Errors.Count; i++) { msg += " " + idmErrorManager.Errors[i].Description; } logger.Debug(msg); return(null); } finally { // verifico preesistenza if (System.IO.File.Exists(nomeFile)) { System.IO.File.Delete(nomeFile); } } }