Ejemplo n.º 1
0
        /// <summary>
        /// Caricamento dati relativamente allo stato del documento bloccato
        /// </summary>
        private void Fetch()
        {
            CheckOutStatus status = CheckInOutServices.GetCheckOutDocumentStatus();

            if (status != null)
            {
                this.DrawTable(status);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Aggiornamento abilitazione / disabilitazione funzioni di checkin - checkout
        /// </summary>
        public void RefreshButtons()
        {
            this.DisableAllButtons();

            DocsPaWR.SchedaDocumento currentScheda = this.CurrentSchedaDocumento;

            Boolean canContinue = (!string.IsNullOrEmpty(UIManager.DocumentManager.getSelectedAttachId())) || (this.getCaller() != "ATTACHMENTS");

            if (currentScheda != null && canContinue)
            {
                //FileRequest selectedFile =(UIManager.DocumentManager.getSelectedAttachId() != null) ?
                //    UIManager.FileManager.GetFileRequest(UIManager.DocumentManager.getSelectedAttachId()) :
                //        UIManager.FileManager.GetFileRequest();

                FileRequest selectedFile = null;

                if (UIManager.DocumentManager.getSelectedAttachId() != null)
                {
                    selectedFile = FileManager.GetFileRequest(UIManager.DocumentManager.getSelectedAttachId());
                }
                else
                {
                    String selectedVersionId = null;
                    if (DocumentManager.getSelectedNumberVersion() != null && DocumentManager.ListDocVersions != null)
                    {
                        selectedVersionId = (from v in DocumentManager.ListDocVersions where v.version.Equals(DocumentManager.getSelectedNumberVersion()) select v.versionId).FirstOrDefault();
                    }

                    selectedFile = FileManager.GetFileRequest(selectedVersionId);
                }

                // Verifica stato consolidamento del documento (solo se non consolidato, si può fare checkout)
                if (currentScheda.ConsolidationState == null ||
                    (currentScheda.ConsolidationState != null && currentScheda.ConsolidationState.State == DocsPaWR.DocumentConsolidationStateEnum.None))
                {
                    if (!string.IsNullOrEmpty(currentScheda.systemId) && (currentScheda.tipoProto != "R" && currentScheda.tipoProto != "C"))
                    {
                        // NB: Nei casi in cui l'utente non è abilitato per l'utilizzo della funzione di checkin / checkout,
                        // le uniche funzionalità non disponibili saranno quelle relative al checkin e all'undocheckout.
                        // In ogni caso potrà vedere lo stato del documento e chi l'ha posto in checkout.

                        // Verifica se il documento non è né cestinato né annullato
                        if (!this.IsDocumentoInCestino && !this.IsDocumentoAnnullato)
                        {
                            CheckOutStatus status = CheckInOutServices.GetCheckOutDocumentStatus();

                            if (status != null)
                            {
                                // Il documento risulta bloccato, reperimento del proprietario del blocco
                                string ownerUser       = status.UserName.ToUpper();
                                bool   isOwnerCheckOut = (ownerUser == UIManager.UserManager.GetInfoUser().userId.ToUpper());

                                if (this.UserEnabled && isOwnerCheckOut)
                                {
                                    // Documento bloccato dall'utente corrente: funzioni di rilascio abilitate
                                    this.btnCheckIn.Enabled            = true;
                                    this.btnOpenCheckedOutFile.Enabled = true;
                                    this.btnUndoCheckOut.Enabled       = true;

                                    if (UIManager.UserManager.isFiltroAooEnabled())
                                    {
                                        //DocsPaWR.Registro[] userRegistri = UIManager.UserManager.getListaRegistri(this.Page);
                                        DocsPaWR.Registro[] userRegistri = RoleManager.GetRoleInSession().registri;
                                        this.btnCheckIn.Enabled            = UIManager.UserManager.verifyRegNoAOO(currentScheda, userRegistri);
                                        this.btnOpenCheckedOutFile.Enabled = UIManager.UserManager.verifyRegNoAOO(currentScheda, userRegistri);
                                        this.btnUndoCheckOut.Enabled       = UIManager.UserManager.verifyRegNoAOO(currentScheda, userRegistri);
                                    }
                                }
                                string language = UIManager.UserManager.GetUserLanguage();

                                this.btnShowCheckOutStatus.Enabled = true;
                                this.btnShowCheckOutStatus.Visible = true;
                                this.btnShowCheckOutStatus.ToolTip = Utils.Languages.GetLabelFromCode("DocumentImgLockTooltip", language) + ownerUser;

                                //Verifico che il documento è bloccato per una richiesta di conversione pdf lato server
                                //In caso affermativo disabilito l'apertura del file ed il rilascia sen
                                if (status.InConversionePdf)
                                {
                                    this.btnOpenCheckedOutFile.Enabled = false;
                                    this.btnCheckIn.Enabled            = false;

                                    // Se il documento è in stato di conversione pdf,
                                    // il pulsante di annullamento è abilitato solo se l'owner
                                    // del blocco è l'utente stesso
                                    //this.btnUndoCheckOut.Enabled = isOwnerCheckOut;
                                    this.btnUndoCheckOut.Enabled = false;
                                }
                            }
                            else
                            {
                                //modifica
                                NttDataWA.DocsPaWR.DocsPaWebService ws = new NttDataWA.DocsPaWR.DocsPaWebService();

                                //string idAmm = UIManager.UserManager.GetInfoUser().idAmministrazione;
                                ////NttDataWA.DocsPaWR.CacheConfig info = ws.getConfigurazioneCache(idAmm);
                                //if (ws.isActiveCache(idAmm))
                                //{
                                //    bool inCache = ws.inCache(currentScheda.docNumber, currentScheda.documenti[currentScheda.documenti.Length - 1].versionId, idAmm);

                                //    if (inCache)
                                //    {
                                //        string pathComponents = ws.recuperaPathComponents(currentScheda.docNumber, currentScheda.documenti[currentScheda.documenti.Length - 1].versionId);
                                //        if (string.IsNullOrEmpty(pathComponents))
                                //            this.btnCheckOut.Enabled = false;
                                //        else
                                //            this.btnCheckOut.Enabled = true;
                                //    }
                                //}
                                //else
                                //fine mofidica
                                if (Session["docInRisposta"] == null && Session["docInRisposta2"] == null)
                                {
                                    if (!this.IsEnabledProfilazioneAllegati &&
                                        this.IsSelectedTabAllegati && selectedFile.GetType() == typeof(DocsPaWR.Allegato))
                                    {
                                        // La funzione di checkout esplicita da tab allegati è disabilitata se la profilazione allegati è disabilitata
                                        this.btnCheckOut.Enabled = false;
                                    }
                                    else
                                    {
                                        if (DocumentManager.getSelectedRecord() != null && !string.IsNullOrEmpty(DocumentManager.getSelectedRecord().systemId))
                                        {
                                            if (!UIManager.UserManager.disabilitaButtHMDiritti(DocumentManager.getSelectedRecord().accessRights))
                                            {
                                                this.btnCheckOut.Enabled = this.UserEnabled;
                                            }
                                            else
                                            {
                                                this.btnCheckOut.Enabled = false;
                                            }
                                        }
                                        else
                                        {
                                            this.btnCheckOut.Enabled = this.UserEnabled;
                                        }

                                        if (UIManager.UserManager.isFiltroAooEnabled())
                                        {
                                            if (btnCheckOut.Enabled)
                                            {
                                                //DocsPaWR.Registro[] userRegistri = UIManager.UserManager.getListaRegistri(this.Page);
                                                DocsPaWR.Registro[] userRegistri = RoleManager.GetRoleInSession().registri;
                                                btnCheckOut.Enabled = UIManager.UserManager.verifyRegNoAOO(currentScheda, userRegistri);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    this.btnCheckOut.Enabled = false;
                                    if (Session["docInRisposta"] != null)
                                    {
                                        Session.Remove("docInRisposta");
                                    }
                                    else
                                    if (Session["docInRisposta2"] != null)
                                    {
                                        Session.Remove("docInRisposta2");
                                    }
                                }
                            }
                        }
                    }
                }

                // Abilitazione / disabilitazione pulsante salva file,
                // che viene comunque abilitato (se file presente)
                // indipendentemente dalle regole di abilitazione del checkin / checkout
                int size;
                //Prendo la versione del documento attualmente selezionata

                /* Emanuela 07-07-2014: Commentato perchè il filerequest è stato già preso con il selectedFile
                 * FileRequest fileReq;
                 * if (UIManager.DocumentManager.getSelectedAttachId() != null)
                 * {
                 *  fileReq = FileManager.GetFileRequest(UIManager.DocumentManager.getSelectedAttachId());
                 * }
                 * else
                 * {
                 *  String selectedVersionId = null;
                 *  if (DocumentManager.getSelectedNumberVersion() != null && DocumentManager.ListDocVersions != null)
                 *      selectedVersionId = (from v in DocumentManager.ListDocVersions where v.version.Equals(DocumentManager.getSelectedNumberVersion()) select v.versionId).FirstOrDefault();
                 *
                 *  fileReq = FileManager.GetFileRequest(selectedVersionId);
                 * }
                 * */

                /*
                 * if (DocumentManager.getSelectedNumberVersion() != null && DocumentManager.ListDocVersions != null)
                 * {
                 *  fileReq = (from v in DocumentManager.ListDocVersions where v.version.Equals(DocumentManager.getSelectedNumberVersion()) select v).FirstOrDefault();
                 * }
                 */
                if (selectedFile != null && Int32.TryParse(selectedFile.fileSize, out size))
                {
                    this.btnSave.Enabled = (size > 0) && !selectedFile.inLibroFirma;// && (CheckInOutServices.UserEnabledSaveLocal);
                    this.Refresh(currentScheda.systemId, selectedFile.docNumber);
                }

                if (DocumentManager.IsDocumentCheckedOut() || CheckInOut.CheckInOutServices.IsCheckedOutDocument(DocumentManager.getSelectedRecord().docNumber, DocumentManager.getSelectedRecord().docNumber, UserManager.GetInfoUser(), true, DocumentManager.getSelectedRecord()) || DiagrammiManager.IsDocumentInFinalState() || (selectedFile != null && selectedFile.inLibroFirma))
                {
                    this.btnCheckOut.Enabled = false;
                }
            }
            else
            {
                if (canContinue)
                {
                    FileRequest fileReq;
                    int         size;
                    if (UIManager.DocumentManager.getSelectedAttachId() != null)
                    {
                        fileReq = FileManager.GetFileRequest(UIManager.DocumentManager.getSelectedAttachId());
                    }
                    else
                    {
                        String selectedVersionId = null;
                        if (DocumentManager.getSelectedNumberVersion() != null && DocumentManager.ListDocVersions != null)
                        {
                            selectedVersionId = (from v in DocumentManager.ListDocVersions where v.version.Equals(DocumentManager.getSelectedNumberVersion()) select v.versionId).FirstOrDefault();
                        }

                        fileReq = FileManager.GetFileRequest(selectedVersionId);
                    }

                    if (fileReq != null && Int32.TryParse(fileReq.fileSize, out size))
                    {
                        this.btnSave.Enabled = (size > 0) && !fileReq.inLibroFirma; // && (CheckInOutServices.UserEnabled);
                    }
                }
            }
        }