/// <summary> /// Inserisco un dizionario di documenti Biblos NON firmati sul tavolo. /// </summary> /// <param name="docCollection"></param> /// <param name="currentDesk"></param> /// <param name="currentDeskLocation"></param> /// <returns></returns> public Desk InsertDocumentNotSignedFromCollaboration(IDictionary <Guid, BiblosDocumentInfo> docCollection, Desk currentDesk, Location currentDeskLocation = null) { foreach (KeyValuePair <Guid, BiblosDocumentInfo> document in docCollection) { if (!document.Value.IsSigned) { DeskDocument deskDocument = new DeskDocument(_userName); Guid chain = Guid.Empty; chain = DocumentInfoFactory.ArchiveDocumentsInBiblos(new List <DocumentInfo>() { document.Value }, currentDeskLocation.ProtBiblosDSDB, chain); deskDocument.DocumentType = DeskDocumentType.MainDocument; deskDocument.IdDocument = chain; deskDocument.Desk = currentDesk; DeskDocumentVersion version = new DeskDocumentVersion(_userName); version.DeskDocument = deskDocument; version.Version = 1; deskDocument.DeskDocumentVersions.Add(version); currentDesk.DeskDocuments.Add(deskDocument); } } return(currentDesk); }
/// <summary> /// Crea un DeskDocumentResult da un DeskDocument /// </summary> public DeskDocumentResult CreateDeskDocumentDto(DeskDocument document, BiblosDocumentInfo biblosDocument, Location deskLocation, bool fromDb) { DeskDocumentVersion deskVersioning = null; DeskStoryBoard lastStoryBoard = null; DeskDocumentResult dto = MapperDeskDocumentResult.MappingDTO(document); // Mappo gli oggetti di Biblos dto.Name = biblosDocument.Name; dto.Size = biblosDocument.Size; dto.IsSavedToBiblos = true; dto.IsSigned = biblosDocument.IsSigned; dto.BiblosSerializeKey = biblosDocument.Serialized; //Mappo commenti e versioning if (fromDb) { deskVersioning = DeskDocumentVersionFacade.GetLastVersionByIdDeskDocument(document.Id); lastStoryBoard = CurrentDeskStoryBoardFacade.GetLastStoryBoard(deskVersioning); } dto.LastVersion = fromDb ? deskVersioning.Version : new decimal(1.0); dto.IdChainBiblos = biblosDocument.ChainId; dto.IdDocumentBiblos = biblosDocument.DocumentId; dto.IsJustInCollaboration = CurrentDeskCollaborationFacade.IsDocumentJustInCollaboration(document.Desk, dto.Name); dto.LastComment = fromDb && lastStoryBoard != null ? lastStoryBoard.Comment : string.Empty; return(dto); }
public DeskDocument AddNewDeskDocument(Desk desk, DocumentInfo document, Location biblosLocation) { DeskDocument deskDocument = new DeskDocument(_userName); Guid chain = Guid.Empty; chain = DocumentInfoFactory.ArchiveDocumentsInBiblos(new List <DocumentInfo> { document }, biblosLocation.ProtBiblosDSDB, chain); deskDocument.DocumentType = DeskDocumentType.MainDocument; deskDocument.IdDocument = chain; deskDocument.Desk = desk; //Aggiungo il versioning DeskDocumentVersion version = new DeskDocumentVersion(_userName) { DeskDocument = deskDocument, Version = 1 }; deskDocument.DeskDocumentVersions.Add(version); this.Save(ref deskDocument); //Inserisco il log CurrentDeskLogFacade.InsertLog(DeskLogType.Modify, string.Format(ADD_DOCUMENT_LOG_FORMAT, document.Name), desk, SeverityLog.Info); return(deskDocument); }
protected override IQueryOver <Desk, Desk> DecorateCriteria(IQueryOver <Desk, Desk> queryOver) { DeskDocumentEndorsement deskDocumentEndorsement = null; DeskRoleUser deskRoleUser = null; DeskDocumentVersion deskDocumentVersion = null; DeskDocument deskDocument = null; queryOver.JoinAlias(o => o.DeskDocuments, () => deskDocument) .JoinAlias(() => deskDocument.DeskDocumentVersions, () => deskDocumentVersion) .JoinAlias(o => o.DeskRoleUsers, () => deskRoleUser) .Left.JoinAlias(() => deskRoleUser.DeskDocumentEndorsements, () => deskDocumentEndorsement, () => deskDocumentEndorsement.DeskDocumentVersion.Id == deskDocumentVersion.Id); if (DeskId.HasValue) { queryOver.Where(desk => desk.Id == DeskId.Value); } FilterByUserPermission(queryOver); queryOver.SelectList(select => select.SelectGroup(() => deskDocument.Id).SelectMax(() => deskDocumentVersion.Version)); if (!VersionFilters.Any()) { return(queryOver); } foreach (KeyValuePair <Guid, decimal> versionFilter in VersionFilters) { queryOver.Where(() => deskDocument.Id == versionFilter.Key) .And(() => deskDocumentVersion.Version == versionFilter.Value); } return(queryOver); }
/// <summary> /// 1) Annulla estrazione del file da parte dell'utente. /// 2) Aggiorna l'ultimo utente che ha eseguito le operazioni sul file e la data. /// 3) Aggiunge un commento nello storyboard. /// </summary> /// <param name="desk"></param> /// <param name="roleUser"></param> /// <param name="docVersion"></param> /// <param name="idDeskDocument"></param> /// <param name="idDocument"></param> /// <param name="userId"></param> public void UndoCheckOut(Desk desk, DeskRoleUser roleUser, DeskDocumentVersion docVersion, Guid?idDeskDocument, Guid idDocument, string userId) { BiblosDocumentInfo.UndoCheckOutDocument(idDocument, userId); BiblosDocumentInfo undoDoc = BiblosDocumentInfo.GetDocumentByVersion(idDocument, null, null); UpdateDocumentLastChages(idDeskDocument); AddCommentStoryBoard(undoDoc, desk, roleUser, docVersion, DeskStoryBoardType.UndoCheckout); }
/// <summary> /// Esegue l'estrazione del documento con lock esclusivo /// </summary> /// <param name="idDocument"></param> /// <param name="userId"></param> /// <param name="contentFormat"></param> /// <param name="returnContent"></param> /// <returns></returns> public BiblosDocumentInfo CheckOut(Desk desk, DeskRoleUser roleUser, DeskDocumentVersion docVersion, Guid?idDeskDocument, Guid idDocument, string userId, ContentFormat contentFormat, bool?returnContent) { BiblosDocumentInfo checkOutDoc = BiblosDocumentInfo.CheckOutDocument(idDocument, userId, contentFormat, returnContent); UpdateDocumentLastChages(idDeskDocument); AddCommentStoryBoard(checkOutDoc, desk, roleUser, docVersion, DeskStoryBoardType.CheckOutComment); return(checkOutDoc); }
/// <summary> /// Aggiorna il documento firmato in BiblosDs2010 /// </summary> public BiblosDocumentInfo UpdateSignedDocument(Desk desk, DeskRoleUser roleUser, Guid idDeskDocument, BiblosDocumentInfo documentToUpdate, string userId) { DeskDocument deskDocument = this.GetById(idDeskDocument); BiblosDocumentInfo documentUpdated = documentToUpdate.Update(userId); DeskDocumentVersion docVersion = DeskDocumentVersionFacade.InsertDocumentVersion(documentUpdated.DocumentId, documentUpdated.Version, deskDocument); AddCommentStoryBoard(documentUpdated, desk, roleUser, docVersion, DeskStoryBoardType.SignedDocument); return(documentUpdated); }
public DeskStoryBoard GetLastStoryBoard(Guid idDeskDocumentVersion) { DeskDocumentVersion deskDocumentVersion = null; return(NHibernateSession.QueryOver <DeskStoryBoard>() .JoinAlias(x => x.DeskDocumentVersion, () => deskDocumentVersion) .Where(() => deskDocumentVersion.Id == idDeskDocumentVersion) .OrderBy(o => o.RegistrationDate).Desc .Take(1) .SingleOrDefault <DeskStoryBoard>()); }
public bool IsAlreadyApproved(Guid idDeskDocument, decimal version, string accountName) { DeskDocumentVersion docVersion = CurrentDeskDocumentVersionFacade.GetByIdAndVersion(idDeskDocument, version); if (docVersion == null) { return(false); } return(!_dao.GetByIdVersionAndAccount(docVersion.Id, accountName).Any()); }
/// <summary> /// CheckIn di una specifica versione del documento. /// </summary> /// <param name="idDocument"></param> /// <param name="docName"></param> /// <param name="content"></param> /// <param name="userId"></param> /// <param name="contentFormat"></param> /// <param name="version">Ritorna la versione corrente del documento appena inserito</param> /// <returns></returns> public BiblosDocumentInfo CheckIn(Desk desk, DeskRoleUser roleUser, Guid?idDeskDocument, Guid idDocument, string docName, byte[] content, string userId, ContentFormat contentFormat, decimal?version) { DeskDocument deskDocument = GetById(idDeskDocument.Value, false); BiblosDocumentInfo newDoc = BiblosDocumentInfo.CheckInDocument(idDocument, docName, content, userId, contentFormat, version); UpdateDocumentCheckIn(idDeskDocument, newDoc.DocumentId); decimal newversion = version ?? newDoc.Version; DeskDocumentVersion docVersion = DeskDocumentVersionFacade.InsertDocumentVersion(newDoc.DocumentId, newversion, deskDocument); AddCommentStoryBoard(newDoc, desk, roleUser, docVersion, DeskStoryBoardType.CheckInComment); return(newDoc); }
protected override IQueryOver <DeskDocumentEndorsement, DeskDocumentEndorsement> MappingProjection(IQueryOver <DeskDocumentEndorsement, DeskDocumentEndorsement> queryOver) { DeskEndorsement deskEndorsment = null; DeskRoleUser deskRoleUser = null; DeskDocumentVersion deskDocumentVersion = null; DeskDocument deskDocument = null; queryOver.JoinAlias(o => o.DeskRoleUser, () => deskRoleUser) .SelectList(list => list // Mappatura degli oggetti DeskDocumentEndorsment .Select(x => x.Endorsement).WithAlias(() => deskEndorsment.IsApprove) // Mappatura degli oggetti DeskDocumentVersion .Select(() => deskDocumentVersion.Version).WithAlias(() => deskEndorsment.Version) // Mappatura degli oggetti DeskDocument .Select(() => deskDocument.Id).WithAlias(() => deskEndorsment.DeskDocumentId) .Select(() => deskRoleUser.AccountName).WithAlias(() => deskEndorsment.AccountName)); return(queryOver); }
/// <summary> /// Mappo gli oggetti di DeskDocumentEndorsement su DeskEndorsement. /// <see cref="IsApprove">IsApprove viene settato intero poichè in una PivotGrid ho la necessità di aggregare questa informazione</see> /// </summary> /// <param name="queryOver"></param> /// <returns></returns> protected override IQueryOver <Desk, Desk> MappingProjection(IQueryOver <Desk, Desk> queryOver) { DeskEndorsement deskEndorsment = null; DeskDocumentEndorsement deskDocumentEndorsement = null; DeskRoleUser deskRoleUser = null; DeskDocumentVersion deskDocumentVersion = null; DeskDocument deskDocument = null; queryOver .SelectList(list => list // Mappatura degli oggetti DeskDocumentEndorsmen //.Select(Projections.Cast(NHibernateUtil.Int32, Projections.Property(() => deskDocumentEndorsement.Endorsement))).WithAlias(() => deskEndorsment.IsApprove) .Select(() => deskDocumentEndorsement.Endorsement).WithAlias(() => deskEndorsment.IsApprove) // Mappatura degli oggetti DeskDocumentVersion .Select(() => deskDocumentVersion.Version).WithAlias(() => deskEndorsment.Version) // Mappatura degli oggetti DeskDocument .Select(() => deskDocument.Id).WithAlias(() => deskEndorsment.DeskDocumentId) .Select(() => deskDocument.IdDocument).WithAlias(() => deskEndorsment.IdChainBiblos) .Select(() => deskRoleUser.AccountName).WithAlias(() => deskEndorsment.AccountName)); return(queryOver); }
/// <summary> /// Inserisce una nuova approvazione o un nuovo rifiuto per il documento specificato /// </summary> /// <param name="idDeskDocument"></param> /// <param name="version"></param> /// <param name="user"></param> /// <param name="approve">Se true approva il documento, se false lo rifiuta</param> public void AddApproveOrRefuse(Guid idDeskDocument, decimal version, DeskRoleUser user, bool approve) { DeskDocument doc = CurrentDeskDocumentFacade.GetById(idDeskDocument); DeskDocumentEndorsement endorsment = new DeskDocumentEndorsement(); if (!doc.DeskDocumentVersions.Any(x => x.Version.Equals(version))) { throw new Exception("Nessuna versione presente per quanto specificato"); } DeskDocumentVersion docVersion = doc.DeskDocumentVersions.Single(x => x.Version.Equals(version)); endorsment.DeskDocumentVersion = docVersion; endorsment.DeskRoleUser = user; endorsment.Endorsement = approve; //Aggiungo il commento relativo all'approvazione string authorName = CommonUtil.GetInstance().UserDescription; DateTime approveDate = DateTime.Now; string comment = string.Empty; if (approve) { comment = string.Format(APPROVE_COMMENT_FORMAT, authorName, approveDate); } else { comment = string.Format(REFUSE_COMMENT_FORMAT, authorName, approveDate); } Save(ref endorsment); CurrentDeskStoryBoardFacade.AddCommentToStoryBoard(comment, authorName, approveDate, doc.Desk, user, docVersion); //Inserisco il log di approvazione CurrentDeskLogFacade.InsertLog(DeskLogType.Approve, comment, doc.Desk, SeverityLog.Info); }
public void AddCommentToStoryBoard(string comment, Desk desk, DeskRoleUser user, DeskDocumentVersion docVersion, DeskStoryBoardType commentType = DeskStoryBoardType.TextComment) { AddCommentToStoryBoard(comment, CommonUtil.GetInstance().UserDescription, desk, user, docVersion, commentType); }
/// <summary> /// Aggiunge un nuovo commento allo storyboard indicando l'azione eseguita e l'utente /// </summary> /// <param name="documentName"></param> /// <param name="desk"></param> /// <param name="roleUser"></param> /// <param name="docVersion"></param> /// <param name="boardType"></param> private void AddCommentStoryBoard(BiblosDocumentInfo biblosDoc, Desk desk, DeskRoleUser roleUser, DeskDocumentVersion docVersion, DeskStoryBoardType boardType) { string commentStringType = string.Empty; switch (boardType) { case DeskStoryBoardType.CheckInComment: commentStringType = checkInComment; break; case DeskStoryBoardType.CheckOutComment: commentStringType = checkOutComment; break; case DeskStoryBoardType.UndoCheckout: commentStringType = undoCheckOutComment; break; case DeskStoryBoardType.SignedDocument: commentStringType = SIGNED_DOCUMENT_LOG_FORMAT; break; case DeskStoryBoardType.RenameDocument: commentStringType = renameComment; break; } string comment = string.Format(commentStringType, _userName, biblosDoc.Name, biblosDoc.Version); CurrentDeskStoryBoardFacade.AddCommentToStoryBoard(comment, desk, roleUser, docVersion, boardType); }
/// <summary> /// Esegue l'estrazione del documento con lock esclusivo /// </summary> /// <param name="document"></param> /// <param name="userId"></param> /// <param name="contentFormat"></param> /// <param name="returnContent"></param> /// <returns></returns> public BiblosDocumentInfo CheckOut(Desk desk, DeskRoleUser roleUser, DeskDocumentVersion docVersion, DeskDocumentResult document, string userId, ContentFormat contentFormat, bool?returnContent) { return(CheckOut(desk, roleUser, docVersion, document.IdDeskDocument, document.IdDocumentBiblos.Value, userId, contentFormat, returnContent)); }
public void AddCommentToStoryBoard(string comment, string authorName, Desk desk, DeskRoleUser user, DeskDocumentVersion docVersion, DeskStoryBoardType commentType = DeskStoryBoardType.TextComment) { AddCommentToStoryBoard(comment, authorName, DateTime.Now, desk, user, docVersion, commentType); }
public void RenameDoc(Desk desk, DeskRoleUser roleUser, DeskDocumentVersion docVersion, BiblosDocumentInfo document, string userId) { Service.UpdateDocument(document, DocSuiteContext.Current.User.FullUserName); AddCommentStoryBoard(document, desk, roleUser, docVersion, DeskStoryBoardType.RenameDocument); }
/// <summary> /// 1) Annulla estrazione del file da parte dell'utente. /// 2) Aggiorna l'ultimo utente che ha eseguito le operazioni sul file e la data. /// 3) Aggiunge un commento nello storyboard. /// </summary> /// <param name="desk"></param> /// <param name="roleUser"></param> /// <param name="docVersion"></param> /// <param name="document"></param> /// <param name="userId"></param> public void UndoCheckOut(Desk desk, DeskRoleUser roleUser, DeskDocumentVersion docVersion, DeskDocumentResult document, string userId) { UndoCheckOut(desk, roleUser, docVersion, document.IdDeskDocument, document.IdDocumentBiblos.Value, userId); }
public void AddCommentToStoryBoard(string comment, string authorName, DateTime commentDate, Desk desk, DeskRoleUser user, DeskDocumentVersion docVersion, DeskStoryBoardType commentType = DeskStoryBoardType.TextComment) { DeskStoryBoard storyBoardComment = new DeskStoryBoard(_userName) { Author = authorName, BoardType = commentType, DateBoard = commentDate.ToLocalTime(), Comment = comment, Desk = desk, DeskDocumentVersion = docVersion }; if (user != null) { storyBoardComment.DeskRoleUser = user; } Save(ref storyBoardComment); }
public DeskStoryBoard GetLastStoryBoard(DeskDocumentVersion deskDocumentVersion) { return(_dao.GetLastStoryBoard(deskDocumentVersion.Id)); }