Ejemplo n.º 1
0
        /// <summary>
        /// CheckIn del documento corrente MTEXT
        /// </summary>
        private void CheckInMTextDocument(String file)
        {
            // Salvataggio del docNumber del documento in CheckOut
            String docNumber = CheckOutContext.Current.Status.DocumentNumber;

            // Estrai porzione del path di interesse per M/TEXT
            file = file.Substring(8);

            // Accedi a MTEXT per prelevare il PDF
            MTextModelProvider mtext = models.ModelProviderFactory <MTextModelProvider> .GetInstance();

            // Preleva contenuto PDF
            Byte[] content = mtext.ExportDocument(file, "application/pdf");

            // Fai sembrare il file M/TEXT un file FDF
            CheckOutContext.Current.Status.DocumentLocation = "mtext.pdf";

            // Effettua il checkin del documento
            NttDataWA.DocsPaWR.ValidationResultInfo result = CheckInOutServices.CheckInDocument(content);

            // Salva l'FQN del file M/TEXT
            NttDataWA.DocsPaWR.DocsPaWebService ws = new NttDataWA.DocsPaWR.DocsPaWebService();
            ws.SetMTextFullQualifiedName(new NttDataWA.DocsPaWR.MTextDocumentInfo()
            {
                DocumentDocNumber = docNumber,
                FullQualifiedName = file
            });

            if (!result.Value)
            {
                // Scrittura dei messaggi di errore nel checkin
                Response.Write(this.GetErrorMessage(result));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Rendering del documento checkedout
        /// </summary>
        private void RenderCheckedOutDocument()
        {
            byte[] content = null;

            if (CheckOutPage.SessionContent == null)
            {
                // Se il download del file non è stato fatto
                // contestualmente al CheckOut, viene reperito
                // il content del file dal server
                content = CheckInOutServices.GetCheckedOutFileDocument();
            }
            else
            {
                // Se il file è già stato scaricato contestualmente al checkout,
                // viene reperito il content del file dalla sessione
                content = CheckOutPage.SessionContent;

                CheckOutPage.SessionContent = null;
            }

            if (content != null)
            {
                Response.BinaryWrite(content);
                Response.End();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Checkout di un documento e download del contenuto del file
        /// </summary>
        /// <param name="idDocument"></param>
        /// <param name="documentNumber"></param>
        /// <param name="machineName"></param>
        /// <param name="documentLocation">Percorso di estrazione del file</param>
        /// <param name="downloadFile">Se true, viene effettuato il download del file contestualmente al checkout</param>
        private void CheckOutDocument(string idDocument, string documentNumber, string documentLocation, string machineName, bool downloadFile)
        {
            CheckOutStatus checkOutStatus;

            ValidationResultInfo result = null;

            if (downloadFile)
            {
                byte[] content;

                result = CheckInOutServices.CheckOutDocumentWithFile(documentLocation, machineName, out checkOutStatus, out content);

                if (result.Value)
                {
                    SessionContent = content;
                }
            }
            else
            {
                result = CheckInOutServices.CheckOutDocument(documentLocation, machineName, out checkOutStatus);
            }

            if (!result.Value)
            {
                // Scrittura dei messaggi di errore nel checkout
                Response.Write(this.GetErrorMessage(result));
            }
            else
            {
                System.Web.HttpContext.Current.Session["isCheckinOrOut"] = result.Value;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Aggiornamento pannello checkinout
        /// </summary>
        /// <param name="idDocument"></param>
        /// <param name="documentNumber"></param>
        public void Refresh(string idDocument, string documentNumber)
        {
            // Impostazione parametri relativi al documento corrente
            this.IDDocument        = this.documentId.Value = idDocument;
            this.DocumentNumber    = this.documentNumber.Value = documentNumber;
            this.hdnFilePath.Value = CheckOutFilePath;
            lastDocument           = this.LastDocument;
            this.isSigned.Value    = IsSignedFile.ToString();
            // Registrazione eventi javascript
            this.RegisterClientScriptEvents();

            //bool fileExist = false;
            //if (string.IsNullOrEmpty(UIManager.FileManager.getSelectedFile().fileSize))
            //fileExist = true;
            // Verifica se l'utente è abilitato all'utilizzo della funzione

            // Inizializzazione del contesto di checkout per il documento corrente
            CheckInOutServices.InitializeContext();
            this.ViewState["IsUserEnabled"] = true;

            this.ViewState["LastAcquiredDocumentExtension"] = null;
            this.fileExt.Value = LastAcquiredDocumentExtension;
            this.pnlFileExtValue.Update();
            this.CheckInOutController.UpdateCheckOutPath();
        }
Ejemplo n.º 5
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.º 6
0
        /// <summary>
        /// Annullamento del blocco sul documento
        /// </summary>
        private void UndoCheckOutDocument()
        {
            ValidationResultInfo retValue = CheckInOutServices.UndoCheckOutDocument();

            if (!retValue.Value)
            {
                // Scrittura dei messaggi di errore nel checkout
                Response.Write(this.GetErrorMessage(retValue));
            }
            else
            {
                System.Web.HttpContext.Current.Session["isCheckinOrOut"] = retValue.Value;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// CheckIn del documento corrente
        /// </summary>
        private void CheckInDocument()
        {
            byte[] content = Request.BinaryRead(Request.ContentLength);

            NttDataWA.DocsPaWR.ValidationResultInfo result = CheckInOutServices.CheckInDocument(content);

            if (!result.Value)
            {
                // Scrittura dei messaggi di errore nel checkin
                Response.Write(this.GetErrorMessage(result));
            }
            else
            {
                System.Web.HttpContext.Current.Session["isCheckinOrOut"] = result.Value;
                CheckOutContext.Current = null;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Inizializzazione pannello checkinout
        /// </summary>
        /// <param name="idDocument"></param>
        /// <param name="documentNumber"></param>
        public void Initialize(string idDocument, string documentNumber)
        {
            if (!this.IsPostBack)
            {
                // Impostazione parametri relativi al documento corrente
                this.IDDocument     = idDocument;
                this.DocumentNumber = documentNumber;

                // Registrazione eventi javascript
                this.RegisterClientScriptEvents();

                //bool fileExist = false;
                //if (string.IsNullOrEmpty(UIManager.FileManager.getSelectedFile().fileSize))
                //fileExist = true;
                // Verifica se l'utente è abilitato all'utilizzo della funzione
                if (this.UserEnabled) // && fileExist
                {
                    // Inizializzazione del contesto di checkout per il documento corrente
                    CheckInOutServices.InitializeContext();
                }
            }
        }
Ejemplo n.º 9
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);
                    }
                }
            }
        }