Ejemplo n.º 1
0
        /// <summary>
        /// Aggiornamento abilitazione / disabilitazione funzioni di checkin - checkout
        /// </summary>
        private void RefreshButtons()
        {
            this.DisableAllButtons();

            DocsPaWR.SchedaDocumento currentScheda = this.CurrentSchedaDocumento;

            if (currentScheda != null)
            {
                FileRequest selectedFile = FileManager.getSelectedFile();

                // 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 == UserManager.getInfoUtente().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 (DocsPAWA.UserManager.isFiltroAooEnabled(this.Page))
                                    {
                                        DocsPaWR.Registro[] userRegistri = DocsPAWA.UserManager.getListaRegistri(this.Page);
                                        this.btnCheckIn.Enabled            = UserManager.verifyRegNoAOO(currentScheda, userRegistri);
                                        this.btnOpenCheckedOutFile.Enabled = UserManager.verifyRegNoAOO(currentScheda, userRegistri);
                                        this.btnUndoCheckOut.Enabled       = UserManager.verifyRegNoAOO(currentScheda, userRegistri);
                                    }
                                }

                                this.btnShowCheckOutStatus.Enabled = true;
                                this.btnShowCheckOutStatus.Visible = true;
                                this.btnShowCheckOutStatus.ToolTip = "Il documento risulta bloccato dall'utente " + 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;
                                }
                            }
                            else
                            {
                                //modifica
                                DocsPAWA.DocsPaWR.DocsPaWebService ws = new DocsPAWA.DocsPaWR.DocsPaWebService();

                                string idAmm = UserManager.getInfoUtente().idAmministrazione;
                                //DocsPAWA.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;
                                        }

                                        if (IsTimeStampedFile)
                                        {
                                            this.btnCheckOut.Enabled = false;
                                        }
                                    }
                                }
                                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
                                    {
                                        this.btnCheckOut.Enabled = this.UserEnabled;

                                        if (IsTimeStampedFile)
                                        {
                                            this.btnCheckOut.Enabled = false;
                                        }

                                        if (DocsPAWA.UserManager.isFiltroAooEnabled(this.Page))
                                        {
                                            if (btnCheckOut.Enabled)
                                            {
                                                DocsPaWR.Registro[] userRegistri = DocsPAWA.UserManager.getListaRegistri(this.Page);
                                                btnCheckOut.Enabled = 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;
                if (selectedFile != null && Int32.TryParse(selectedFile.fileSize, out size))
                {
                    this.btnSave.Enabled = (size > 0);
                }
            }
        }