示例#1
0
        /// <summary>
        /// This functions save report to OnBase ftp
        /// </summary>
        /// <param name="executionID">Execution Id of the batch</param>
        /// <param name="headerId">The parameter required to generate the report</param>
        /// <param name="ReportCode">Report Code from PTMS which has to be generated.</param>
        /// <returns></returns>
        protected static bool SaveReportOnBase(int executionID, int headerId, string ReportCode)
        {
            //DataSet documentGroup = null;
            string    documentTypeGroupName = string.Empty;
            string    byDate                    = string.Empty;
            DataTable getReportserver           = null;
            string    reportServer              = string.Empty;
            string    reportLocation            = string.Empty;
            string    sFTPLocation              = string.Empty;
            string    sFTPUserName              = string.Empty;
            string    sFTPPassword              = string.Empty;
            string    Msg                       = string.Empty;
            DataTable getDocumentTypeForReports = null;
            string    onbaseDocumentType        = string.Empty;
            string    onbaseDocumentGroup       = string.Empty;

            string[] installmentSecuredReportParameters = null;
            bool     onBaseSuccess = false;
            string   folder        = ConfigurationSettings.AppSettings["ReportFolder"];

            //Declaring Index File Keys variables

            string indexFileKey = string.Empty;

            string[] indexFileKeyParameters = null;
            try
            {
                getDocumentTypeForReports = BatchUtility.GetDocumentGroupAndTypeValue(ReportCode);
                if (getDocumentTypeForReports != null && getDocumentTypeForReports.Rows.Count > 0 &&
                    getDocumentTypeForReports.Columns.Contains("OnbaseDocumentGroup") &&
                    getDocumentTypeForReports.Columns.Contains("OnbaseDocumentType")
                    //&& (!string.IsNullOrEmpty(getDocumentTypeForReports.Rows[0]["OnbaseDocumentGroup"].ToString()))
                    // && (!string.IsNullOrEmpty(getDocumentTypeForReports.Rows[0]["OnbaseDocumentType"].ToString()))
                    )
                {
                    onbaseDocumentGroup = getDocumentTypeForReports.Rows[0]["OnbaseDocumentGroup"].ToString();
                    onbaseDocumentType  = getDocumentTypeForReports.Rows[0]["OnbaseDocumentType"].ToString();
                }

                ////TO BE ADDED//
                //documentGroup = BatchUtility.GetConfigValue("AC", "PEN", "DocumentGroup");
                //if (documentGroup != null && documentGroup.Tables.Count > 0 && documentGroup.Tables[0] != null && documentGroup.Tables[0].Rows.Count > 0)
                //{
                //    documentTypeGroupName = documentGroup.Tables[0].Rows[0]["Value"].ToString();
                //}
                //TO BE CHANGED//

                getReportserver = BatchUtility.getReportServerDetails(folder);

                if (getReportserver != null && getReportserver.Rows.Count > 0 &&
                    getReportserver.Columns.Contains("ReportServerName") &&
                    getReportserver.Columns.Contains("FolderName") &&
                    (!string.IsNullOrEmpty(getReportserver.Rows[0]["ReportServerName"].ToString())) &&
                    (!string.IsNullOrEmpty(getReportserver.Rows[0]["FolderName"].ToString())))
                {
                    reportServer   = getReportserver.Rows[0]["ReportServerName"].ToString();
                    reportLocation = getReportserver.Rows[0]["FolderName"].ToString();



                    DataSet FTPLocation = BatchUtility.GetConfigValue("PTMS", "OnBase_FTP", "ServerAddress");
                    DataSet FTPUserName = BatchUtility.GetConfigValue("PTMS", "OnBase_FTP", "UserName");
                    DataSet FTPPassword = BatchUtility.GetConfigValue("PTMS", "OnBase_FTP", "Password");
                    if (FTPLocation != null && FTPLocation.Tables.Count > 0 && FTPLocation.Tables[0] != null && FTPLocation.Tables[0].Rows.Count > 0) //Null Check Implemented
                    {
                        sFTPLocation = FTPLocation.Tables[0].Rows[0]["Value"].ToString();
                    }
                    if (FTPUserName != null && FTPUserName.Tables.Count > 0 && FTPUserName.Tables[0] != null && FTPUserName.Tables[0].Rows.Count > 0) //Null Check Implemented
                    {
                        sFTPUserName = FTPUserName.Tables[0].Rows[0]["Value"].ToString();
                    }
                    if (FTPPassword != null && FTPPassword.Tables.Count > 0 && FTPPassword.Tables[0] != null && FTPPassword.Tables[0].Rows.Count > 0) //Null Check Implemented
                    {
                        sFTPPassword = FTPPassword.Tables[0].Rows[0]["Value"].ToString();
                    }
                    string onBaseFTPMessageForSecuredReport = string.Empty;
                    string exportLocation   = Environment.CurrentDirectory + @"\";
                    string reportParameters = headerId.ToString();
                    installmentSecuredReportParameters = reportParameters.Split(',');

                    //Writing Index File Key to String Array

                    if (!string.IsNullOrEmpty(onbaseDocumentType) && !string.IsNullOrEmpty(onbaseDocumentGroup))
                    {
                        indexFileKey = "ExecutionID," + executionID.ToString() + ",RunDate," + DateTime.Now.ToShortDateString();

                        indexFileKeyParameters = indexFileKey.Split(',');
                    }

                    //Confirm
                    string reportName  = ConfigurationSettings.AppSettings[ReportCode];
                    String ReportValue = BatchUtility.GetFileName(reportName, executionID);
                    byte[] OutputbytesForSecuredReport = ExportReportAs(reportServer, reportLocation + reportName, exportLocation, reportName, "pdf", reportName, executionID, installmentSecuredReportParameters);
                    onBaseFTPMessageForSecuredReport = BatchUtility.UploadtoOnBaseFTP(sFTPLocation, sFTPUserName, sFTPPassword
                                                                                      , ReportValue + ".pdf", OutputbytesForSecuredReport, onbaseDocumentType, installmentSecuredReportParameters, 0, indexFileKeyParameters
                                                                                      , onbaseDocumentType, onbaseDocumentGroup, "Roll Corrections");
                    if (onBaseFTPMessageForSecuredReport == "1")
                    {
                        onBaseSuccess = true;
                    }
                }
            }
            catch (Exception Ex)
            {
                Msg = "Error Details : " + Ex.Message.ToString();
                BatchUtility.LogMessage(Ex.Message + "--" + DateTime.Now.ToString(), executionID, "EXCEP");
                throw Ex;
            }
            return(onBaseSuccess);
        }