Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int statusCode = 0;

            NttDataWA.Utils.FileJSON file = null;
            string componentType          = UIManager.UserManager.getComponentType(Request.UserAgent);

            if ((Request.QueryString["Absolutepath"] != null) && (Request.QueryString["Absolutepath"] != ""))
            {
                //1. controllo se arriva la path assoluta
                absolutePath = decodeQueryString(Request.QueryString["Absolutepath"].ToString());
                //1.0.1 Controllo della dimensione del file
                if (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings[NttDataWA.Utils.WebConfigKeys.FILE_ACQ_SIZE_MAX.ToString()]) &&
                    (Int32.Parse(System.Configuration.ConfigurationManager.AppSettings[NttDataWA.Utils.WebConfigKeys.FILE_ACQ_SIZE_MAX.ToString()].ToString()) * 1024) < Request.ContentLength
                    )
                {
                    parseStatusCode(5);
                    if (!String.IsNullOrEmpty(componentType) && componentType.Equals(Constans.TYPE_SOCKET))
                    {
                        ImportDocManager.setSessionMapImportStatus(absolutePath, this.Response.StatusDescription);
                    }
                    else
                    {
                        HttpContext.Current.Session["ImportStatus"] = this.Response.StatusDescription;
                    }
                }
                else
                {
                    fd = new NttDataWA.DocsPaWR.FileDocumento();
                    //1.1 Leggo il content del file
                    if (!IsSocket)
                    {
                        byte[] ba = Request.BinaryRead(Request.ContentLength);
                        fd.content = ba;
                    }
                    else
                    {
                        //Stream stream=Request.InputStream;
                        string contentFile = Request["contentFile"];
                        if (!String.IsNullOrEmpty(contentFile))
                        {
                            contentFile = contentFile.Replace(' ', '+');
                            contentFile = contentFile.Trim();
                            file        = JsonConvert.DeserializeObject <NttDataWA.Utils.FileJSON>(contentFile);
                        }
                        if (file != null && !String.IsNullOrEmpty(file.content))
                        {
                            fd.content = Convert.FromBase64String(file.content);
                        }
                    }

                    //1.2 leggo il codice fascicolo
                    if (Request.QueryString["codFasc"] != null && Request.QueryString["codFasc"] != "")
                    {
                        codFasc = decodeQueryString(Request.QueryString["codFasc"].ToString());
                        //fasc = FascicoliManager.getFascicoloDaCodice(this.Page, codFasc);
                        fasc = NttDataWA.UIManager.ProjectManager.getFascicoloDaCodice(this.Page, codFasc, Request.QueryString["idTitolario"]);
                    }

                    //1.4. tipo passato
                    if (Request.QueryString["type"] != null && Request.QueryString["type"] != "")
                    {
                        type = Request.QueryString["type"].ToString();
                    }

                    if (Request.QueryString["foldName"] != null && Request.QueryString["foldName"] != "")
                    {
                        foldName = decodeQueryString(Request.QueryString["foldName"].ToString());
                    }

                    //1.5. se tutte le condizioni sono ok... procedo
                    if ((codFasc != "") && (absolutePath != ""))
                    {
                        /* prendo la cartella selezionata per l'acquisizione massiva */
                        DocsPaWR.Folder folder = null;
                        if (UIManager.ProjectManager.getProjectInSession().folderSelezionato != null)
                        {
                            folder = UIManager.ProjectManager.getProjectInSession().folderSelezionato;
                        }

                        statusCode = ImportDocManager.checkORCreateDocFolderFasc(this.Page, fasc, absolutePath, fd, foldName, type, folder, componentType);

                        // parsing degli stati
                        parseStatusCode(statusCode);
                        if (!String.IsNullOrEmpty(componentType) && componentType.Equals(Constans.TYPE_SOCKET))
                        {
                            ImportDocManager.setSessionMapImportStatus(absolutePath, this.Response.StatusDescription);
                        }
                        else
                        {
                            HttpContext.Current.Session["ImportStatus"] = this.Response.StatusDescription;
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            bool   retValue      = false;
            bool   isContent     = false;
            bool   issocket      = false;
            string idDocument    = string.Empty;
            string base64content = string.Empty;

            // Put user code to initialize the page here
            try
            {
                this.startUp();
                this.ErrorPage = "";
                if (Request.QueryString["tipofirma"] != null)
                {
                    if (!Request.QueryString["tipofirma"].Equals(""))
                    {
                        tipofirma = Request.QueryString["tipofirma"];
                    }
                }
                if (tipofirma.Equals("cosign"))
                {
                    firmabool = true;
                }
                else
                {
                    firmabool = false;
                }


                if (Request.QueryString["iscontent"] != null)
                {
                    bool.TryParse(Request.QueryString["iscontent"], out isContent);
                }

                if (Request.QueryString["issocket"] != null)
                {
                    bool.TryParse(Request.QueryString["issocket"], out issocket);
                }

                if (Request.QueryString["idDocumento"] != null)
                {
                    idDocument = Request.QueryString["idDocumento"].ToString();
                }

                byte[] ba = null;

                if (!issocket)
                {
                    ba = Request.BinaryRead(Request.ContentLength);
                }
                else
                {
                    string contentFile = Request["contentFile"];
                    //Stream stream=Request.InputStream;
                    if (!String.IsNullOrEmpty(contentFile))
                    {
                        contentFile = contentFile.Replace(' ', '+');
                        contentFile = contentFile.Trim();
                        NttDataWA.Utils.FileJSON file = JsonConvert.DeserializeObject <NttDataWA.Utils.FileJSON>(contentFile);
                        ba = Convert.FromBase64String(file.content);
                    }
                }
                DocsPaWR.DocsPaWebService DocsPaWS = ProxyManager.GetWS();
                DocsPaWR.FileDocumento    fd       = new NttDataWA.DocsPaWR.FileDocumento();
                //fd.content=ba;

                ASCIIEncoding ae = new ASCIIEncoding();
                if (!isContent)
                {
                    base64content = ae.GetString(ba);
                }

                if (UIManager.UserManager.getBoolDocSalva(this) == null)
                {
                    if (!IsPostBack)
                    {
                        //	string prova=base64content.Replace(base64content.Substring(4,2),"Ds");
                        FileRequest fr = null;
                        DocsPaWR.SchedaDocumento schedaDocumento = null;

                        if (string.IsNullOrEmpty(idDocument))
                        {
                            fr = UIManager.FileManager.getSelectedFile();
                        }
                        else
                        {
                            fr = UIManager.FileManager.getSelectedMassSignature(idDocument).fileRequest;
                            FirmaDigitaleMng mmg = new FirmaDigitaleMng();
                            schedaDocumento = mmg.GetSchedaDocumento(idDocument);
                        }

                        if (!string.IsNullOrEmpty(Request.QueryString["signedAsPdf"]))
                        {
                            // Se il file è in formato pdf, viene modificato il nome del file
                            bool signedAsPdf;
                            bool.TryParse(Request.QueryString["signedAsPdf"], out signedAsPdf);
                            if (signedAsPdf)
                            {
                                fr.fileName += ".PdF_convertito"; //SERVE PER IL BACKEND NON MODIFICARLO!!!
                            }
                        }

                        fr.dataInserimento = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");

                        if (fr.GetType().Equals(typeof(DocsPaWR.Allegato)))
                        {
                            // Creazione di un nuovo allegato per il file firmato
                            DocsPaWR.Allegato currentAllegato = (DocsPaWR.Allegato)fr;

                            DocsPaWR.Allegato newAllegato = new DocsPaWR.Allegato();
                            newAllegato.descrizione       = currentAllegato.descrizione;
                            newAllegato.numeroPagine      = currentAllegato.numeroPagine;
                            newAllegato.fileName          = fr.fileName;
                            newAllegato.firmatari         = currentAllegato.firmatari;
                            newAllegato.docNumber         = currentAllegato.docNumber;
                            newAllegato.version           = "0";
                            newAllegato.cartaceo          = false;
                            newAllegato.repositoryContext = UIManager.DocumentManager.GetSelectedAttachment().repositoryContext;

                            fr = newAllegato;
                        }

                        if (isContent)
                        {
                            retValue = DocsPaWS.AppendContentFirmato(ba, firmabool, ref fr, UIManager.UserManager.GetInfoUser());
                        }
                        else
                        {
                            retValue = DocsPaWS.AppendDocumentoFirmato(base64content, firmabool, ref fr, UIManager.UserManager.GetInfoUser());
                        }

                        if (!retValue)
                        {
                            throw new Exception();
                        }

                        UIManager.FileManager.setSelectedFile(fr);
                        if (schedaDocumento == null)
                        {
                            schedaDocumento = UIManager.DocumentManager.getSelectedRecord();
                        }

                        List <DocsPaWR.Allegato> attachments = new List <DocsPaWR.Allegato>(schedaDocumento.allegati);

                        if (UIManager.DocumentManager.getSelectedAttachId() != null)
                        {
                            //attachments.Add((Allegato)fr);
                            //schedaDocumento.allegati = attachments.ToArray();
                            int      index = schedaDocumento.allegati.Select((item, i) => new { obj = item, index = i }).First(item => item.obj.versionId.Equals(UIManager.DocumentManager.GetSelectedAttachment().versionId)).index;
                            Allegato a     = new Allegato();
                            a.applicazione          = fr.applicazione;
                            a.daAggiornareFirmatari = fr.daAggiornareFirmatari;
                            a.dataInserimento       = fr.dataInserimento;
                            a.descrizione           = fr.descrizione;
                            a.docNumber             = fr.docNumber;
                            a.docServerLoc          = fr.docServerLoc;
                            a.fileName          = fr.fileName;
                            a.fileSize          = fr.fileSize;
                            a.firmatari         = fr.firmatari;
                            a.firmato           = fr.firmato;
                            a.idPeople          = fr.idPeople;
                            a.path              = fr.path;
                            a.subVersion        = fr.version;
                            a.version           = fr.version;
                            a.versionId         = fr.versionId;
                            a.versionLabel      = schedaDocumento.allegati[index].versionLabel;
                            a.cartaceo          = fr.cartaceo;
                            a.repositoryContext = fr.repositoryContext;
                            a.TypeAttachment    = 1;
                            //a.numeroPagine = (fr as Allegato).numeroPagine;
                            // modifica necessaria per FILENET (A.B.)
                            if ((fr.fNversionId != null) && (fr.fNversionId != ""))
                            {
                                a.fNversionId = fr.fNversionId;
                            }
                            schedaDocumento.allegati[index] = a;

                            UIManager.DocumentManager.setSelectedAttachId(fr.versionId);
                            UIManager.DocumentManager.setSelectedNumberVersion(a.version);
                            //schedaDocumento.allegati = UIManager.DocumentManager.AddAttachment((Allegato)fr);
                        }
                        else
                        {
                            //fr = UIManager.DocumentManager.AddVersion(fr, false);
                            schedaDocumento.documenti = UIManager.DocumentManager.addVersion(schedaDocumento.documenti, (Documento)fr);
                            UIManager.DocumentManager.setSelectedNumberVersion(fr.version);
                        }

                        UIManager.DocumentManager.setSelectedRecord(schedaDocumento);
                        UIManager.UserManager.setBoolDocSalva(this, "salvato");
                    }
                }
            }
            catch (Exception es)
            {
                ErrorManager.setError(this, es);
            }
        }