コード例 #1
0
        public void DownloadErrorReport()
        {
            if (Session["bpId"] != null)
            {
                if (Session["bpId"].ToString() != "")
                {
                    Guid bpId = new Guid(Session["bpId"].ToString());
                    Session["bpId"] = null;
                    CurrentInfo  _objCurrentInfo = new CurrentInfo();
                    SPData       _objSPData      = new SPData();
                    string       userCode        = _objCurrentInfo.GetUserCode();
                    string       companyCode     = _objCurrentInfo.GetCompanyCode();
                    DataSet      ds       = _objSPData.GetBatchProcessingErrorLog(companyCode, bpId);
                    HttpResponse response = System.Web.HttpContext.Current.Response;

                    if (ds.Tables[0].Columns.Contains("Row_No"))
                    {
                        ds.Tables[0].Columns["Row_No"].ColumnName         = "Excel Row No";
                        ds.Tables[0].Columns["ERR_REASON"].ColumnName     = "Error Description";
                        ds.Tables[0].Columns["ERR_SUGGESTION"].ColumnName = "Suggestion for error rectification";
                        ds.Tables[0].Columns.Remove("Upload_File_Name");
                        ds.Tables[0].Columns.Remove("Dynamic_Column_Name");
                        ds.Tables[0].Columns.Remove("ERR_CODE");
                        ds.Tables[0].Columns.Remove("Upload_Date");
                        ds.Tables[0].Columns.Remove("Status");
                    }
                    else
                    {
                        ds.Tables[0].Columns["ERR_SUGGESTION"].ColumnName = "Suggestion for error rectification";
                        ds.Tables[0].Columns.Remove("Upload_File_Name");
                        ds.Tables[0].Columns.Remove("Upload_Date");
                        ds.Tables[0].Columns.Remove("Status");
                    }


                    //ds.Tables[0].Columns.Remove("Upload_Date1");
                    DowenloadExcelFile(ds.Tables, "Error_Report_" + DateTime.Now.ToString(), response);
                }
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bpId"></param>
        /// <returns></returns>
        public StringBuilder GetBPErrorLog(Guid bpId)
        {
            string        userCode              = _objCurrentInfo.GetUserCode();
            string        companyCode           = _objCurrentInfo.GetCompanyCode();
            string        msg                   = string.Empty;
            StringBuilder bpErrorLogsHTMLFormat = new StringBuilder();

            DataSet ds = _objSPData.GetBatchProcessingErrorLog(companyCode, bpId);

            if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows != null && ds.Tables[0].Rows.Count > 0)
            {
                DataRowCollection drCollection = ds.Tables[0].Rows;
                // Bind Header Information
                if (drCollection[0]["Status"].ToString() == "ERROR")
                {
                    msg = "Error";
                }
                else if (drCollection[0]["Status"].ToString() == "FAILED")
                {
                    msg = "Failed";
                }
                bpErrorLogsHTMLFormat.Append("<h4 style='margin-top: 7px;margin-left: 6px;'>Header Information</h4>");
                bpErrorLogsHTMLFormat.Append("<div class='Err_header_info' style='border:2px solid;width:93%;'><br /><table style='border-collapse:collapse;'><tr><td><b>File Name</b></td><td>: " + drCollection[0]["Upload_File_Name"] + "</td></tr>");
                bpErrorLogsHTMLFormat.Append("<tr><td><b>Upload Date Time</b></td><td>: " + drCollection[0]["Upload_Date"] + "</td></tr>");
                bpErrorLogsHTMLFormat.Append("<tr><td><b>Status</b></td><td>: " + msg + "</td></tr>");
                bpErrorLogsHTMLFormat.Append("<tr><td><b>Reason</b></td><td>: Kindly refer below.");
                //bpErrorLogsHTMLFormat.Append("<br />Please rectify the errors and re-upload again.");
                bpErrorLogsHTMLFormat.Append("</td></tr></table></div><div style='clear:both'></div>");
                // Bind Error Details.
                bpErrorLogsHTMLFormat.Append("<div><div style='float: left;margin-right: 67%;margin-bottom: 22px;margin-top:14px;'><span style='padding-left:15px;'><b>Error Details:</b></span><br /></div>");
                bpErrorLogsHTMLFormat.Append("<div><span style='float:right;margin-bottom:5px;    margin-top: 11px;margin - right: 5px; '><b><a class='btn small primary'  onclick='fnDownloadErrorReport()' id='excelDownload' value='" + bpId + "'>Download Error Report</a></b></span><br /></div></div>");
                //bpErrorLogsHTMLFormat.Append("<div><span style='float:right;margin-bottom:5px;'><b><a class='btn small primary' href='/BatchProcessing/DownloadErrorReport' onclick='fnDownloadErrorReport()' id='excelDownload' value='" + bpId + "'>Download Error Report</a></b></span><br /></div></div>");
                if (drCollection[0]["Status"].ToString() != "FAILED")
                {
                    bpErrorLogsHTMLFormat.Append("<table  class='bpTable' border='0' cellspacing='0' cellpadding='0'><thead style='position:relative;display:block;width:100%;'><tr><th style='min-width:100px;'>Excel Row No</th><th style='min-width:250px;'>Error Description</th><th style='min-width:327px;'>Suggestion for error rectification</th></tr></thead><tbody style='display:block;position:relative;overflow - y:auto;height:140px;overflow:auto;'>");
                }
                else
                {
                    bpErrorLogsHTMLFormat.Append("<table  class='bpTable' border='0' cellspacing='0' cellpadding='0'><thead><tr><th>Error Description</th></tr></thead><tbody>");
                }
                foreach (DataRow dr in drCollection)
                {
                    if (dr["Status"].ToString() != "FAILED")
                    {
                        string errreson = dr["ERR_REASON"].ToString();
                        bpErrorLogsHTMLFormat.Append("<tr><td style='min-width:100px;'>" + (Convert.ToInt32(dr["ROW_NO"].ToString()) > 0 ? dr["ROW_NO"].ToString() : "") + "</td>");
                        string correctString = errreson.Replace(" <<Dynamic_Column_Name >>", dr["Dynamic_Column_Name"].ToString());
                        bpErrorLogsHTMLFormat.Append("<td style='min-width:250px;'>" + correctString + "</td>");
                        bpErrorLogsHTMLFormat.Append("<td style='min-width:305px;'>" + dr["ERR_SUGGESTION"].ToString() + "</td>");
                        //bpErrorLogsHTMLFormat.Append("<td>");
                        //if (Convert.ToInt32(dr["Can_Auto"].ToString()) == 1)
                        //    bpErrorLogsHTMLFormat.Append("<span style='text-decoration:underline;color:blue;cursor:pointer;' onclick=\"fnDoAction(\'" + dr["ERR_CODE"].ToString() + "\',\'" + dr["Product_Ref_Key"].ToString() + "\',\'" + dr["Product_Type"].ToString() + "\',\'" + dr["Product_Name"].ToString() + "\',\'" + dr["Batch_Number"].ToString() + "\',\'" + dr["Employee_Number"].ToString() + "\');\" > Process </span>");
                        //bpErrorLogsHTMLFormat.Append("</td>");
                        bpErrorLogsHTMLFormat.Append("</tr>");
                    }
                    else
                    {
                        //  string correctString = errreson.Replace(" <<Dynamic_Column_Name >>", dr["Dynamic_Column_Name"].ToString());
                        //   bpErrorLogsHTMLFormat.Append("<td>" + correctString + "</td>");
                        bpErrorLogsHTMLFormat.Append("<td>" + dr["ERR_SUGGESTION"].ToString() + "</td>");
                        //bpErrorLogsHTMLFormat.Append("<td>");
                        //if (Convert.ToInt32(dr["Can_Auto"].ToString()) == 1)
                        //    bpErrorLogsHTMLFormat.Append("<span style='text-decoration:underline;color:blue;cursor:pointer;' onclick=\"fnDoAction(\'" + dr["ERR_CODE"].ToString() + "\',\'" + dr["Product_Ref_Key"].ToString() + "\',\'" + dr["Product_Type"].ToString() + "\',\'" + dr["Product_Name"].ToString() + "\',\'" + dr["Batch_Number"].ToString() + "\',\'" + dr["Employee_Number"].ToString() + "\');\" > Process </span>");
                        //bpErrorLogsHTMLFormat.Append("</td>");
                        bpErrorLogsHTMLFormat.Append("</tr>");
                    }
                }
                bpErrorLogsHTMLFormat.Append("</tbody></table>");
            }
            return(bpErrorLogsHTMLFormat);
        }