Ejemplo n.º 1
0
        public bool BigFilesFTP_InsertIntoTable(DocsPaVO.ExternalServices.FileFtpUpInfo infoFile)
        {
            bool retval = true;

            try
            {
                using (DocsPaDB.DBProvider dbProvider = new DocsPaDB.DBProvider())
                {
                    DocsPaUtils.Query q      = DocsPaUtils.InitQuery.getInstance().getQuery("I_DPABIGFILE");
                    string            values = "";

                    values += infoFile.IdDocument;
                    values += "," + infoFile.IdAmm;
                    values += "," + infoFile.UploaderRoleId;
                    values += "," + infoFile.UploaderId;
                    values += ",'" + infoFile.FileName;
                    values += "','" + infoFile.FileSize;
                    values += "','" + infoFile.HashFile;
                    values += "','" + infoFile.FTPPath + "',";

                    q.setParam("values", values);
                    q.setParam("iddoc", infoFile.IdDocument);
                    string queryString = q.getSQL();
                    logger.Debug(queryString);

                    retval = this.ExecuteNonQuery(queryString);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                retval = false;
            }
            return(retval);
        }
Ejemplo n.º 2
0
        public ArrayList BigFilesFTP_GetFilesToTransfer()
        {
            ArrayList retval = new ArrayList();

            DocsPaUtils.Query q = DocsPaUtils.InitQuery.getInstance().getQuery("S_DPABIGFILE");
            q.setParam("condizione", " UPPER(A.FILEUPSTATUS) = 'PENDING' ");
            string queryString = q.getSQL();

            logger.Debug(queryString);
            // Inserire oggetto Evento CDS
            DocsPaVO.ExternalServices.FileFtpUpInfo infoFile;
            DataSet dataset = new DataSet();

            this.ExecuteQuery(out dataset, "BFFTPINFO", queryString);
            if (dataset.Tables["BFFTPINFO"] != null && dataset.Tables["BFFTPINFO"].Rows.Count > 0)
            {
                foreach (DataRow r in dataset.Tables["BFFTPINFO"].Rows)
                {
                    //Inserire associazione oggetto CDS
                    infoFile                = new DocsPaVO.ExternalServices.FileFtpUpInfo();
                    infoFile.IdQueue        = r["IDQUEUE"].ToString();
                    infoFile.IdDocument     = r["IDDOCUMENT"].ToString();
                    infoFile.Description    = r["DESCRIPTION"].ToString();
                    infoFile.IdAmm          = r["ID_AMM"].ToString();
                    infoFile.CodeAdm        = r["CODEADM"].ToString();
                    infoFile.UploaderId     = r["UPLOADERID"].ToString();
                    infoFile.Uploader       = r["UPLOADER"].ToString();
                    infoFile.UploaderRoleId = r["UPLOADERROLEID"].ToString();
                    infoFile.UploaderRole   = r["UPLOADERROLE"].ToString();
                    infoFile.FileName       = r["FILENAME"].ToString();
                    infoFile.FileSize       = r["FILESIZE"].ToString();
                    infoFile.HashFile       = r["HASHFILE"].ToString();
                    infoFile.FTPPath        = r["FTPPATH"].ToString();
                    infoFile.Status         = r["STATUS"].ToString();
                    infoFile.ErrorMessage   = r["ERRORMESSAGE"].ToString();
                    infoFile.VersionId      = r["VERSIONID"].ToString();
                    infoFile.Version        = r["VERSION"].ToString();
                    infoFile.FSPath         = r["FSPATH"].ToString();
                    // comunico il doc_Root per far copiare i file
                    if (string.IsNullOrEmpty(infoFile.FSPath))
                    {
                        infoFile.FSPath = System.Configuration.ConfigurationManager.AppSettings["UPLOAD_BIGFILE_REPOSITORY"];
                    }


                    if (string.IsNullOrEmpty(infoFile.FSPath))
                    {
                        infoFile.FSPath = System.Configuration.ConfigurationManager.AppSettings["DOC_ROOT"];
                    }

                    retval.Add(infoFile);
                }
            }
            else
            {
                retval = null;
            }
            return(retval);
        }
Ejemplo n.º 3
0
        public static Services.FilesUploader.FileFTPUpload.FileFTPUploadResponse CheckFileFTPUpload(Services.FilesUploader.FileFTPUpload.CheckFileFTPUploadRequest request)
        {
            Services.FilesUploader.FileFTPUpload.FileFTPUploadResponse response = new Services.FilesUploader.FileFTPUpload.FileFTPUploadResponse();
            try
            {
                DocsPaVO.utente.Utente     utente     = null;
                DocsPaVO.utente.InfoUtente infoUtente = null;

                //Inizio controllo autenticazione utente
                infoUtente = Utils.CheckAuthentication(request, "CheckFileFTPUpload");

                utente = BusinessLogic.Utenti.UserManager.getUtenteById(infoUtente.idPeople);
                if (utente == null)
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }
                //Fine controllo autenticazione utente

                DocsPaVO.ExternalServices.FileFtpUpInfo ftpInfoResponse = BusinessLogic.Amministrazione.SistemiEsterni.BigFileFTP_GetInfoFileFTP(request.IdQueue, request.IdDocument);
                Domain.FileFTPUploadInfo retInfo = Utils.getDomFileFTPInfo(ftpInfoResponse);
                response.InfoUpload = retInfo;

                response.Success = true;
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }

            return(response);
        }
Ejemplo n.º 4
0
        public DocsPaVO.ExternalServices.FileFtpUpInfo BigFilesFTP_GetInfoFile(string idQueue, string idDoc)
        {
            DocsPaVO.ExternalServices.FileFtpUpInfo retVal = null;
            try
            {
                DocsPaUtils.Query q = DocsPaUtils.InitQuery.getInstance().getQuery("S_DPABIGFILE");
                if (!string.IsNullOrEmpty(idQueue))
                {
                    q.setParam("condizione", " A.SYSTEM_ID = " + idQueue);
                }
                else
                {
                    q.setParam("condizione", " A.IDPROFILE = " + idDoc + " ORDER BY A.SYSTEM_ID DESC");
                }

                string queryString = q.getSQL();
                logger.Debug(queryString);
                // Inserire oggetto Evento CDS
                DataSet dataset = new DataSet();
                this.ExecuteQuery(out dataset, "BFFTPINFO", queryString);
                if (dataset.Tables["BFFTPINFO"] != null && dataset.Tables["BFFTPINFO"].Rows.Count > 0)
                {
                    retVal                = new DocsPaVO.ExternalServices.FileFtpUpInfo();
                    retVal.IdQueue        = dataset.Tables["BFFTPINFO"].Rows[0]["IDQUEUE"].ToString();
                    retVal.IdDocument     = dataset.Tables["BFFTPINFO"].Rows[0]["IDDOCUMENT"].ToString();
                    retVal.Description    = dataset.Tables["BFFTPINFO"].Rows[0]["DESCRIPTION"].ToString();
                    retVal.IdAmm          = dataset.Tables["BFFTPINFO"].Rows[0]["ID_AMM"].ToString();
                    retVal.CodeAdm        = dataset.Tables["BFFTPINFO"].Rows[0]["CODEADM"].ToString();
                    retVal.UploaderId     = dataset.Tables["BFFTPINFO"].Rows[0]["UPLOADERID"].ToString();
                    retVal.Uploader       = dataset.Tables["BFFTPINFO"].Rows[0]["UPLOADER"].ToString();
                    retVal.UploaderRoleId = dataset.Tables["BFFTPINFO"].Rows[0]["UPLOADERROLEID"].ToString();
                    retVal.UploaderRole   = dataset.Tables["BFFTPINFO"].Rows[0]["UPLOADERROLE"].ToString();
                    retVal.FileName       = dataset.Tables["BFFTPINFO"].Rows[0]["FILENAME"].ToString();
                    retVal.FileSize       = dataset.Tables["BFFTPINFO"].Rows[0]["FILESIZE"].ToString();
                    retVal.HashFile       = dataset.Tables["BFFTPINFO"].Rows[0]["HASHFILE"].ToString();
                    retVal.FTPPath        = dataset.Tables["BFFTPINFO"].Rows[0]["FTPPATH"].ToString();
                    retVal.Status         = dataset.Tables["BFFTPINFO"].Rows[0]["STATUS"].ToString();
                    retVal.ErrorMessage   = dataset.Tables["BFFTPINFO"].Rows[0]["ERRORMESSAGE"].ToString();
                    retVal.VersionId      = dataset.Tables["BFFTPINFO"].Rows[0]["VERSIONID"].ToString();
                    retVal.Version        = dataset.Tables["BFFTPINFO"].Rows[0]["VERSION"].ToString();
                    retVal.FSPath         = dataset.Tables["BFFTPINFO"].Rows[0]["FSPATH"].ToString();
                }
            }
            catch (Exception ex) {
                logger.Error(ex);
                retVal = null;
            }
            return(retVal);
        }
Ejemplo n.º 5
0
        public static Services.FilesUploader.FileFTPUpload.FileFTPUploadResponse NotifyFileFTPUpload(Services.FilesUploader.FileFTPUpload.NotifyFileFTPUploadRequest request)
        {
            Services.FilesUploader.FileFTPUpload.FileFTPUploadResponse response = new Services.FilesUploader.FileFTPUpload.FileFTPUploadResponse();
            try
            {
                bool retval1 = false;
                DocsPaVO.utente.Utente     utente     = null;
                DocsPaVO.utente.InfoUtente infoUtente = null;

                //Inizio controllo autenticazione utente
                infoUtente = Utils.CheckAuthentication(request, "NotifyFileFTPUpload");

                utente = BusinessLogic.Utenti.UserManager.getUtenteById(infoUtente.idPeople);
                if (utente == null)
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }
                //Fine controllo autenticazione utente

                //TODO
                int sizeInt = 0, maxSize = 104857600;
                if (!string.IsNullOrEmpty(DocsPaUtils.Configuration.InitConfigurationKeys.GetValue("0", "FE_DO_BIG_FILE_MAX")))
                {
                    if (!Int32.TryParse(DocsPaUtils.Configuration.InitConfigurationKeys.GetValue("0", "FE_DO_BIG_FILE_MAX"), out maxSize))
                    {
                        maxSize = 104857600;
                    }
                }

                if (!string.IsNullOrEmpty(request.FileSize))
                {
                    if (Int32.TryParse(request.FileSize, out sizeInt))
                    {
                        if (sizeInt > maxSize)
                        {
                            throw new Exception("Dimensione del file troppo grande");
                        }
                    }
                    else
                    {
                        throw new Exception("Dimensione file non valida");
                    }
                }
                else
                {
                    throw new Exception("Dimensione del file obbligatoria");
                }


                DocsPaVO.ExternalServices.FileFtpUpInfo ftpInfo = new DocsPaVO.ExternalServices.FileFtpUpInfo();
                ftpInfo.CodeAdm        = request.CodeAdm;
                ftpInfo.IdAmm          = infoUtente.idAmministrazione;
                ftpInfo.UploaderId     = infoUtente.idPeople;
                ftpInfo.UploaderRoleId = infoUtente.idGruppo;
                ftpInfo.IdDocument     = request.IdDocument;
                ftpInfo.FileName       = request.FileName;
                ftpInfo.HashFile       = request.FileHash;
                ftpInfo.FileSize       = request.FileSize;
                ftpInfo.FTPPath        = request.FTPPath;

                retval1 = BusinessLogic.Amministrazione.SistemiEsterni.BigFilesFTP_InsertIntoTable(ftpInfo);
                if (retval1)
                {
                    DocsPaVO.ExternalServices.FileFtpUpInfo ftpInfoResponse = BusinessLogic.Amministrazione.SistemiEsterni.BigFileFTP_GetInfoFileFTP("", request.IdDocument);
                    Domain.FileFTPUploadInfo retInfo = Utils.getDomFileFTPInfo(ftpInfoResponse);
                    response.InfoUpload = retInfo;
                }

                response.Success = true;
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }

            return(response);
        }
Ejemplo n.º 6
0
        public bool BigFilesFTP_updateTable(DocsPaVO.ExternalServices.FileFtpUpInfo infoFile)
        {
            bool retval = true;

            try
            {
                using (DocsPaDB.DBProvider dbProvider = new DocsPaDB.DBProvider())
                {
                    DocsPaUtils.Query q = DocsPaUtils.InitQuery.getInstance().getQuery("U_DPABIGFILE");

                    q.setParam("stato", infoFile.Status);
                    q.setParam("messErrore", infoFile.ErrorMessage);
                    q.setParam("pathFS", infoFile.FSPath);
                    q.setParam("idQueue", infoFile.IdQueue);
                    string queryString = q.getSQL();
                    logger.Debug(queryString);

                    retval = this.ExecuteNonQuery(queryString);
                    if (infoFile.Status == "OK")
                    {
                        DocsPaUtils.Query q2 = DocsPaUtils.InitQuery.getInstance().getQuery("U_Versions");
                        q2.setParam("param1", "SUBVERSION = 'A'");
                        q2.setParam("param2", "VERSION_ID = " + infoFile.VersionId);
                        queryString = q2.getSQL();
                        logger.Debug(queryString);
                        retval = this.ExecuteNonQuery(queryString);

                        DocsPaUtils.Query q3 = DocsPaUtils.InitQuery.getInstance().getQuery("U_PROFILE_EXT");
                        // controllare le operazioni sul nome del file.
                        string filenameX = infoFile.FileName.ToLower();
                        string cha_firmato = "0", cha_tipo_firma = "N";
                        if (filenameX.ToUpper().Contains(".P7M"))
                        {
                            cha_firmato    = "1";
                            cha_tipo_firma = "C";
                        }

                        while (filenameX.EndsWith(".p7m") || filenameX.EndsWith(".tsd"))
                        {
                            filenameX = filenameX.Substring(0, filenameX.Length - 4);
                        }

                        q3.setParam("ext", "'" + filenameX.Substring(filenameX.LastIndexOf('.') + 1) + "'");
                        q3.setParam("docnumber", infoFile.IdDocument);
                        queryString = q3.getSQL();
                        logger.Debug(queryString);
                        retval = this.ExecuteNonQuery(queryString);

                        DocsPaUtils.Query q4 = DocsPaUtils.InitQuery.getInstance().getQuery("U_Components");
                        q4.setParam("param1", string.Format(
                                        "PATH = '{0}', FILE_SIZE = {1}, VAR_IMPRONTA = '{2}', VAR_NOMEORIGINALE='{3}', ID_PEOPLE_PUTFILE={4}, DTA_FILE_ACQUIRED = SYSDATE, CHA_TIPO_FIRMA = '{5}', CHA_FIRMATO = '{6}'",
                                        infoFile.FSPath, infoFile.FileSize, infoFile.HashFile.ToUpper(), infoFile.FileName, infoFile.UploaderId, cha_tipo_firma, cha_firmato));
                        q4.setParam("param2", "VERSION_ID = " + infoFile.VersionId);
                        queryString = q4.getSQL();
                        logger.Debug(queryString);
                        retval = this.ExecuteNonQuery(queryString);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                retval = false;
            }
            return(retval);
        }
Ejemplo n.º 7
0
 public virtual bool BigFilesFtp_updateTable(DocsPaVO.ExternalServices.FileFtpUpInfo infoFile)
 {
     return(BusinessLogic.Amministrazione.SistemiEsterni.BigFilesFTP_updateTable(infoFile));
 }