コード例 #1
0
        protected void PDF(int rpid, ReportCriteria[] rpParam = null, CUSTOMRP.BLL.AppHelper.QueryParamsObject[] qpParam = null)
        {
            //string sql = AppHelper.getSql(rpid, me, rpParam);
            //DataTable dt = WebHelper.bllCommon.query(sql);

            CUSTOMRP.Model.REPORT myReport = WebHelper.bllReport.GetModel(me.ID, rpid);

            string rpName   = myReport.REPORTNAME;
            string rpTitle  = myReport.RPTITLE;
            string showType = myReport.EXTENDFIELD.Split(',')[0];

            List <string> comments = new List <string>();
            List <string> avgs     = new List <string>();
            List <string> sums     = new List <string>();
            List <string> groups   = new List <string>();
            List <string> subtotal = new List <string>();
            List <string> subavg   = new List <string>();
            List <string> subcount = new List <string>();
            List <string> count    = new List <string>();

            //v1.2.0 - Cheong - 2016/07/04 - Add option to hide duplicate items
            //DataTable dt = CUSTOMRP.BLL.AppHelper.getDataForReport(ref comments, ref avgs, ref sums, ref groups, ref subtotal, ref subavg, ref subcount, ref count, me, rpid, true, rpParam);
            DataTable dt = CUSTOMRP.BLL.AppHelper.getDataForReport(me.ID, ref comments, ref avgs, ref sums, ref groups, ref subtotal, ref subavg, ref subcount, ref count, me,
                                                                   rpid, myReport.fHideDuplicate, rpParam, QueryParamsToSqlParams(qpParam));

            this.p_fSuppressRender = true;

            string[]      rptHeader     = !String.IsNullOrEmpty(myReport.REPORT_HEADER) ? myReport.REPORT_HEADER.Split('\n') : null;
            string[]      rptFooter     = !String.IsNullOrEmpty(myReport.REPORT_FOOTER) ? myReport.REPORT_FOOTER.Split('\n') : null;
            var           tmp           = myReport.ReportColumns.Where(x => x.ColumnFunc == CUSTOMRP.Model.REPORTCOLUMN.ColumnFuncs.SortOn);
            List <string> sortonCols    = tmp.Select(x => x.ColumnType == CUSTOMRP.Model.REPORTCOLUMN.ColumnTypes.Normal ? x.COLUMNNAME : x.DisplayName).ToList();
            List <bool>   isAscending   = tmp.Select(x => x.IS_ASCENDING).ToList();
            List <int>    seq           = tmp.Select(x => x.SEQ).ToList();
            string        subcountLabel = !String.IsNullOrEmpty(myReport.SUBCOUNT_LABEL) ? myReport.SUBCOUNT_LABEL : null;
            bool          pdfGridLines  = myReport.PDF_GRID_LINES;

            List <string> hideRows = myReport.ReportColumns
                                     .Where(x => x.ColumnFunc == CUSTOMRP.Model.REPORTCOLUMN.ColumnFuncs.Content &&
                                            x.ColumnType == CUSTOMRP.Model.REPORTCOLUMN.ColumnTypes.Normal &&
                                            x.EXCEL_COLWIDTH == 0m)
                                     .Select(x => x.COLUMNNAME).ToList();

            ////v1.0.0 - Cheong - 2016/03/17 - Add formatting to criteria
            //comments = comments.Select(x => x.Remove(0, 6).TrimEnd(')')).ToList();

            string fontPath = PathHelper.getFontFolderName() + "simsun.ttc,1";

            bool showChangeOnly = myReport.EXTENDFIELD.Split(',')[CUSTOMRP.Model.REPORT.EXTENDFIELDs.ReportType] == CUSTOMRP.Model.REPORT.ExtReportType.ChangeOnly;
            bool hideHeaders    = myReport.EXTENDFIELD.Split(',')[CUSTOMRP.Model.REPORT.EXTENDFIELDs.ReportType] == CUSTOMRP.Model.REPORT.ExtReportType.DataExport;
            bool hideCriteria   = myReport.EXTENDFIELD.Split(',')[CUSTOMRP.Model.REPORT.EXTENDFIELDs.HideCriteria] == "1";

            Common.MyPdf.exp_Pdf(showChangeOnly, hideHeaders, hideCriteria,
                                 myReport.ReportColumns.Where(x => x.ColumnFunc == CUSTOMRP.Model.REPORTCOLUMN.ColumnFuncs.Content).ToDictionary(x => x.ColumnType == CUSTOMRP.Model.REPORTCOLUMN.ColumnTypes.Normal ? x.COLUMNNAME : x.DisplayName, y => y.DisplayName),
                                 subtotal, subavg, subcount, count, groups, avgs, sums, AppNum.companyName, rptHeader ?? comments.ToArray(), dt, rpTitle,
                                 fontPath, 14, 1, iTextSharp.text.BaseColor.BLACK,
                                 fontPath, 11, 1, iTextSharp.text.BaseColor.BLACK, //列头字体、大小、样式、颜色
                                 PathHelper.getTempFolderName(), rpName,
                                 fontPath, 11, 1, iTextSharp.text.BaseColor.BLACK, //正文字体、大小、样式、颜色
                                 rptFooter, subcountLabel, sortonCols, isAscending, seq, hideRows, pdfGridLines);
        }
コード例 #2
0
ファイル: REPORT.cs プロジェクト: lsfv/queryreport
        public bool Replace(CUSTOMRP.Model.REPORT model)
        {
            bool result = false;

            using (var ts = DAL.TransactionUtils.CreateTransactionScope())
            {
                try
                {
                    if (dal.Replace(model))
                    {
                        ts.Complete();
                        result = true;
                    }
                    //v1.2.0 Kim 2016.10.26 move upward
                    //result = true;
                }
                catch (Exception)
                {
                    // Log error here
                    throw;
                }
            }
            return(result);
        }
コード例 #3
0
        protected void Word(int rpid, ReportCriteria[] rpParam = null, CUSTOMRP.BLL.AppHelper.QueryParamsObject[] qpParam = null)
        {
            CUSTOMRP.Model.REPORT myReport = WebHelper.bllReport.GetModel(me.ID, rpid);
            string WordFilePath            = null;

            if ((myReport.WordFile != null) && (File.Exists(g_Config["WordTemplatePath"] + myReport.WordFile.WordFileName)))
            {
                WordFilePath = myReport.WordFile.WordFileName;
            }
            else
            {
                CUSTOMRP.Model.WORDTEMPLATE template = WebHelper.bllWORDTEMPLATE.GetModelByReportID(me.ID, myReport.ID, me.ID);
                if (File.Exists(g_Config["WordTemplatePath"] + template.TemplateFileName))
                {
                    WordFilePath = template.TemplateFileName;
                }
                else
                {
                    Context.Response.Write(String.Format("<script type=\"text/javascript\">alert(\"{0}\");</script>",
                                                         AppNum.ErrorMsg.filenotfounderror));
                    Context.Response.End();
                    return;
                }
            }

            CUSTOMRP.Model.SOURCEVIEW mySV = WebHelper.bllSOURCEVIEW.GetModel(me.ID, myReport.SVID);
            string[] colnames;

            switch (mySV.SourceType)
            {
            case CUSTOMRP.Model.SOURCEVIEW.SourceViewType.StoredProc:
            {
                colnames = CUSTOMRP.BLL.AppHelper.GetColumnNamesForStoredProc(me.ID, me.DatabaseNAME, mySV.TBLVIEWNAME);
            }
            break;

            default:
            {
                colnames = CUSTOMRP.BLL.AppHelper.GetColumnNamesForTblView(me.ID, me.DatabaseNAME, mySV.TBLVIEWNAME);
            }
            break;
            }

            //just print .no need save to database.
            List <string> rpcr     = new List <string>();
            List <string> comments = new List <string>();
            List <string> avgs     = new List <string>();
            List <string> sums     = new List <string>();
            List <string> groups   = new List <string>();
            List <string> subtotal = new List <string>();
            List <string> subavg   = new List <string>();
            List <string> subcount = new List <string>();
            List <string> count    = new List <string>();

            //v1.2.0 - Cheong - 2016/07/04 - Add option to hide duplicate items
            //DataTable dt = CUSTOMRP.BLL.AppHelper.getDataForReport(ref comments, ref avgs, ref sums, ref groups, ref subtotal, ref subavg, ref subcount, ref count, me, rpid, true, rpParam);
            DataTable dt = CUSTOMRP.BLL.AppHelper.getDataForReport(me.ID, ref comments, ref avgs, ref sums, ref groups, ref subtotal, ref subavg, ref subcount, ref count, me,
                                                                   rpid, myReport.fHideDuplicate, rpParam, QueryParamsToSqlParams(qpParam));

            this.p_fSuppressRender = true;

            string path             = g_Config["WordTemplatePath"] + WordFilePath;
            string downloadFilename = myReport.REPORTNAME.Replace(' ', '_') + ".docx";

            // Not calling downloadfile because this function need not write on disk
            using (MemoryStream filestream = MailMerge.PerformMailMergeFromTemplate(path, dt, colnames))
            {
                Context.Response.ContentType = "application/octet-stream";
                //Context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + downloadFilename + "\"");
                Context.Response.AddHeader("Content-Disposition", String.Format("attachment; filename=\"{0}\"; filename*=utf-8''{1}", downloadFilename, HttpUtility.UrlPathEncode(downloadFilename)));
                Context.Response.AddHeader("Content-Length", filestream.Length.ToString());
                byte[] fileBuffer = new byte[filestream.Length];
                filestream.Read(fileBuffer, 0, (int)filestream.Length);
                //CA2202
                //filestream.Close();
                Context.Response.BinaryWrite(fileBuffer);
                Context.Response.End();
            }
        }
コード例 #4
0
        protected void Excel(int rpid, ReportCriteria[] rpParam = null, CUSTOMRP.BLL.AppHelper.QueryParamsObject[] qpParam = null)
        {
            //string sql = AppHelper.getSql(rpid, me, rpParam);
            //DataTable dt = WebHelper.bllCommon.query(sql);

            CUSTOMRP.Model.REPORT myReport = WebHelper.bllReport.GetModel(me.ID, rpid);

            string rpName  = myReport.REPORTNAME;
            string rpTitle = myReport.RPTITLE;

            List <string> comments = new List <string>();
            List <string> avgs     = new List <string>();
            List <string> sums     = new List <string>();
            List <string> groups   = new List <string>();
            List <string> subtotal = new List <string>();
            List <string> subavg   = new List <string>();
            List <string> subcount = new List <string>();
            List <string> count    = new List <string>();

            //v1.2.0 - Cheong - 2016/07/04 - Add option to hide duplicate items
            //DataTable dt = CUSTOMRP.BLL.AppHelper.getDataForReport(ref comments, ref avgs, ref sums, ref groups, ref subtotal, ref subavg, ref subcount, ref count, me, rpid, true, rpParam);
            DataTable dt = CUSTOMRP.BLL.AppHelper.getDataForReport(me.ID, ref comments, ref avgs, ref sums, ref groups, ref subtotal, ref subavg, ref subcount, ref count, me,
                                                                   rpid, myReport.fHideDuplicate, rpParam, QueryParamsToSqlParams(qpParam));

            Dictionary <string, decimal> colwidths = myReport.ReportColumns.Where(x => x.ColumnFunc == CUSTOMRP.Model.REPORTCOLUMN.ColumnFuncs.Content)
                                                     .ToDictionary(x => x.ColumnType == CUSTOMRP.Model.REPORTCOLUMN.ColumnTypes.Normal ? x.COLUMNNAME : x.DisplayName,
                                                                   y => y.EXCEL_COLWIDTH);

            Dictionary <string, QueryReport.Code.NPOIHelper.ColumnSetting> colSettings = myReport.ReportColumns.Where(x => x.ColumnFunc == CUSTOMRP.Model.REPORTCOLUMN.ColumnFuncs.Content)
                                                                                         .ToDictionary(x => x.ColumnType == CUSTOMRP.Model.REPORTCOLUMN.ColumnTypes.Normal ? x.COLUMNNAME : x.DisplayName,
                                                                                                       y => new QueryReport.Code.NPOIHelper.ColumnSetting(y.FONT_SIZE, y.FONT_BOLD, y.FONT_ITALIC, y.HORIZONTAL_TEXT_ALIGN, y.CELL_FORMAT, y.BACKGROUND_COLOR, y.FONT_COLOR));

            List <string> rptHeader     = !String.IsNullOrEmpty(myReport.REPORT_HEADER) ? new List <string>(myReport.REPORT_HEADER.Split('\n')) : null;
            List <string> rptFooter     = !String.IsNullOrEmpty(myReport.REPORT_FOOTER) ? new List <string>(myReport.REPORT_FOOTER.Split('\n')) : null;
            string        subcountLabel = !String.IsNullOrEmpty(myReport.SUBCOUNT_LABEL) ? myReport.SUBCOUNT_LABEL : null;
            bool          pdfGridLines  = myReport.PDF_GRID_LINES;
            string        fontFamily    = !String.IsNullOrEmpty(myReport.FONT_FAMILY) ? myReport.FONT_FAMILY : null;

            ////v1.0.0 - Cheong - 2016/03/17 - Add formatting to criteria
            //comments = comments.Select(x => x.Remove(0, 6).TrimEnd(')')).ToList();

            //v1.8.8 Alex 2018.10.22 Add Group Indent Width
            List <decimal> indentWidths = myReport.ReportColumns.Where(x => x.ColumnFunc == CUSTOMRP.Model.REPORTCOLUMN.ColumnFuncs.Group).Select(x => x.EXCEL_COLWIDTH).ToList();

            //v1.8.8 Alex 2018.11.01 Move sort orders to rpexcel. Retrieve data here - Begin
            var           tmp         = myReport.ReportColumns.Where(x => x.ColumnFunc == CUSTOMRP.Model.REPORTCOLUMN.ColumnFuncs.SortOn);
            List <string> sortonCols  = tmp.Select(x => x.ColumnType == CUSTOMRP.Model.REPORTCOLUMN.ColumnTypes.Normal ? x.COLUMNNAME : x.DisplayName).ToList();
            List <bool>   isAscending = tmp.Select(x => x.IS_ASCENDING).ToList();
            List <int>    seq         = tmp.Select(x => x.SEQ).ToList();
            //v1.8.8 Alex 2018.11.01 Move sort orders to rpexcel. Retrieve data here - End

            XSSFWorkbook XSSFworkbook = NPOIHelper.GetWorkbookFromDt(dt, rpTitle, myReport.EXTENDFIELD.Split(','), rptHeader, comments,
                                                                     myReport.ReportColumns.Where(x => x.ColumnFunc == CUSTOMRP.Model.REPORTCOLUMN.ColumnFuncs.Content).ToDictionary(x => x.ColumnType == CUSTOMRP.Model.REPORTCOLUMN.ColumnTypes.Normal ? x.COLUMNNAME : x.DISPLAYNAME, y => y.DisplayName),
                                                                     avgs, sums, groups, subtotal, subavg, subcount, count, colwidths, myReport.PrintOrientation, myReport.PRINT_FITTOPAGE,
                                                                     rptFooter, colSettings, fontFamily, indentWidths, subcountLabel, sortonCols, isAscending, seq);

            string fileName = rpName + ".xlsx";
            string folder   = PathHelper.getTempFolderName();

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            string filePath = folder + PathHelper.getSafePath(fileName);

            using (FileStream outFs = new FileStream(filePath, FileMode.Create))
            {
                XSSFworkbook.Write(outFs);
                //CA2202
                //outFs.Close();
            }
            DownloadFile(filePath, fileName);
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int rpid = 0;

            this.lblContent.Text = String.Empty;

            #region Login Check

            if (Request.Params["hash"] != null)
            {
                string username = Request.Params["uid"];
                string hash     = Request.Params["hash"];
                int    databaseId;
                if (!Int32.TryParse(Request.Params["dbid"], out databaseId))
                {
                    databaseId = -1;
                }

                this.login(username, hash, databaseId);
            }

            if (!QueryReport.Code.LoginUser.isLogin())
            {
                //return; // print blank page
                Response.StatusCode = 412;
                return;
            }

            #endregion

            switch (Request.QueryString["action"])
            {
            case "getParam":
            {
                #region Get Report Parameters
                if (!String.IsNullOrEmpty(Request.Params["rpid"]) && (Int32.TryParse(Request.Params["rpid"], out rpid)))
                {
                    //this.GetReportCriteria(rpid);
                    this.GetReportCriteriaNew(rpid);
                }
                #endregion
            }
            break;

            //case "getQueryParam":
            //    // v1.8.8 Alex 2018.10.25 Get saved values - Begin
            //    if (!String.IsNullOrEmpty(Request.Params["rpid"]) && (Int32.TryParse(Request.Params["rpid"], out rpid)))
            //    {
            //        this.GetQueryParams(rpid);
            //    }
            //    // v1.8.8 Alex 2018.10.25 Get saved values - End
            //break;
            case "getOperands":
            {
                #region Get supported operand list

                this.GetReportOperands();

                #endregion
            }
            break;

            case "getRptTypes":
            {
                #region Get supported export types

                this.GetReportExportTypes();

                #endregion
            }
            break;

            case "getRptGrps":
            {
                #region Get report group list

                this.GetReportGroups();

                #endregion
            }
            break;

            default:
            {
                if (!String.IsNullOrEmpty(Request.Params["rpid"]) && (Int32.TryParse(Request.Params["rpid"], out rpid)))
                {
                    #region Check report access and export

                    myReport = WebHelper.bllReport.GetModel(me.ID, rpid);
                    string strContent = Request.Params["params"];
                    string rptType    = Request.Params["rptType"];
                    DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(EmbeddedParam[]));
                    EmbeddedParam[]            rpParam    = null;
                    ReportCriteria[]           rcParam    = null;
                    CUSTOMRP.BLL.AppHelper.QueryParamsObject[] qpParam = null;
                    try
                    {
                        rpParam = (EmbeddedParam[])serializer.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(strContent)));
                        rcParam = (from x in rpParam
                                   where string.IsNullOrEmpty(x.ParamName)
                                   select new ReportCriteria()
                            {
                                SVID = x.SVID,
                                RCID = x.RCID,
                                RPID = x.RPID,
                                COLUMNNAME = x.COLUMNNAME,
                                CRITERIA1 = x.CRITERIA1,
                                CRITERIA2 = x.CRITERIA2,
                                CRITERIA3 = x.CRITERIA3,
                                CRITERIA4 = x.CRITERIA4,
                                REPORTNAME = x.REPORTNAME,
                                SOURCEVIEWNAME = x.SOURCEVIEWNAME,
                                CATEGORY = x.CATEGORY,
                                DATATYPE = x.DATATYPE
                            }).ToArray();
                        qpParam = (from x in rpParam
                                   where !string.IsNullOrEmpty(x.Value)
                                   select new CUSTOMRP.BLL.AppHelper.QueryParamsObject()
                            {
                                ParamName = x.ParamName,
                                SqlType = x.SqlType,
                                Value = x.Value
                            }).ToArray();
                        CUSTOMRP.BLL.AppHelper.ParseParam(me.ID, ref rcParam);
                    }
                    catch
                    {
                        // ignore errors
                    }



                    //DataContractJsonSerializer qpserializer = new DataContractJsonSerializer(typeof(CUSTOMRP.BLL.AppHelper.QueryParamsEmbedded[]));
                    //CUSTOMRP.BLL.AppHelper.QueryParamsEmbedded[] qrParam = null;
                    //try
                    //{
                    //    qrParam = (CUSTOMRP.BLL.AppHelper.QueryParamsEmbedded[])serializer.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(strContent)));

                    //    //CUSTOMRP.BLL.AppHelper.ParseQueryParam(me.ID, ref qrParam);
                    //}
                    //catch
                    //{
                    //    // ignore errors
                    //}



                    if (myReport != null)
                    {
                        //this.ltr.Text = myReport.REPORTNAME;
                        switch (rptType)
                        {
                        case "0":               // Excel / Word
                        {
                            if (myReport.TYPE == 1)
                            {
                                if (rcParam != null)
                                {
                                    Excel(myReport.ID, rcParam, qpParam);
                                }
                                else
                                {
                                    Excel(myReport.ID, qpParam: qpParam);
                                }
                            }
                            else
                            {
                                if (rcParam != null)
                                {
                                    Word(myReport.ID, rcParam, qpParam);
                                }
                                else
                                {
                                    Word(myReport.ID, qpParam: qpParam);
                                }
                            }
                        }
                        break;

                        case "2":               // PDF
                        {
                            if (rpParam != null)
                            {
                                PDF(myReport.ID, rcParam, qpParam);
                            }
                            else
                            {
                                PDF(myReport.ID, qpParam: qpParam);
                            }
                        }
                        break;

                        default:                // defaulted to on screen
                        {
                            if (rpParam != null)
                            {
                                HtmlExport1(myReport.ID, rcParam, qpParam);
                            }
                            else
                            {
                                HtmlExport1(myReport.ID, qpParam: qpParam);
                            }
                        }
                        break;
                        }
                    }
                    else
                    {
                        Common.JScript.AlertAndRedirect(AppNum.ErrorMsg.parameter_error, "rplist.aspx");
                        Response.End();
                    }
                    #endregion
                }
                else
                {
                    #region Get Report listing

                    //v1.2.0 - Cheong - 2016/07/14 - Add support for report category filtering
                    //this.GetReportCatalog();
                    this.GetReportCatalog(Request.Params["rpgrp"]);

                    #endregion
                }
            }
            break;
            }
        }
コード例 #6
0
        private void ParseDataToContainer()
        {
            // 2018.09.21 Alex - QueryParams - Begin
            var modelList = (List <CUSTOMRP.BLL.AppHelper.QueryParamsObject>)Session[strSessionKeyQueryParams];
            var newList   = new List <CUSTOMRP.BLL.AppHelper.QueryParamsObject>();

            foreach (var x in modelList)
            {
                //throw new Exception(x.paramName);
                //string checkboxVal = Request.Form[String.Format("{0}_select", x.ParamName)];
                //if (!String.IsNullOrEmpty(checkboxVal))
                //{
                string fieldVal;
                switch (x.Type)
                // 2018.09.21 Alex - Get by POST values (<name> tag) - Begin
                {
                case "bool":
                    fieldVal = Request.Form[String.Format("{0}_optradio", x.ParamName)];
                    break;

                case "enum":
                    fieldVal = Request.Form[String.Format("{0}_autocomplete", x.ParamName.Split('$')[0])];
                    break;

                default:
                    fieldVal = Request.Form[String.Format("{0}_field", x.ParamName)];
                    break;
                    // 2018.09.21 Alex - Get by POST values (<name> tag) - End
                }
                if (!String.IsNullOrEmpty(fieldVal))
                {
                    x.Value = fieldVal;
                    newList.Add(x);
                }
                //}
            }
            container.queryParams = newList;

            // 2018.09.21 Alex - QueryParams - End

            for (int i = 0; i < container.criteriaColumn.Count(); i++)
            {
                Fields     cn = container.criteriaColumn[i];
                ColumnInfo ci = columninfos.Where(x => x.ColName == cn.ColumnName).FirstOrDefault();

                if (myReport == null)
                {
                    myReport = container.GetReportModel(me, columninfos);
                }

                CUSTOMRP.Model.REPORTCOLUMN rc = myReport.ReportColumns.Where(x => x.COLUMNNAME == cn.ColumnName && x.ColumnFunc == REPORTCOLUMN.ColumnFuncs.Criteria).FirstOrDefault();
                if (rc == null)
                {
                    rc = new REPORTCOLUMN()
                    {
                        COLUMNNAME  = cn.ColumnName,
                        DISPLAYNAME = ci.DisplayName,
                        COLUMNTYPE  = 1,
                        COLUMNFUNC  = 2,
                        HIDDEN      = false,
                    };
                    myReport.ReportColumns.Add(rc);
                }
                rc.DATATYPE = (ci != null) ? ci.DataType : "String";
                string postData = Request.Form[String.Format("ContentPlaceHolder1_ctl{0:00}_Label1rd1", i)]; // (modelList == null || modelList.Count == 0) ? i : i + 1)
                if (!String.IsNullOrEmpty(postData))                                                         // has value
                {
                    rc.CRITERIA2 = postData;
                    switch (postData)
                    {
                    case "r1":
                    {
                        rc.CRITERIA3 = Request.Form[String.Format("ContentPlaceHolder1_ctl{0:00}_Label1ddl1", i)];
                        rc.CRITERIA4 = Request.Form[String.Format("ContentPlaceHolder1_ctl{0:00}_Label1tb1", i)];

                        cn.Operator = rc.CRITERIA3;
                        cn.Value1   = rc.CRITERIA4;
                    }
                    break;

                    case "r2":
                    {
                        rc.CRITERIA3 = Request.Form[String.Format("ContentPlaceHolder1_ctl{0:00}_Label1tb2", i)];
                        rc.CRITERIA4 = Request.Form[String.Format("ContentPlaceHolder1_ctl{0:00}_Label1tb3", i)];

                        cn.Operator = "BETWEEN";
                        cn.Value1   = rc.CRITERIA3;
                        cn.Value2   = rc.CRITERIA4;
                    }
                    break;

                    case "r3":
                    {
                        rc.CRITERIA3 = "";
                        rc.CRITERIA4 = "";

                        cn.Operator = "EMPTY";
                        cn.Value1   = rc.CRITERIA3;
                        cn.Value2   = rc.CRITERIA4;
                    }
                    break;
                    }
                }
                ReportCriteria temp = rc;
                CUSTOMRP.BLL.AppHelper.ParseParam(me.ID, ref temp);
            }

            Session[rpexcel.strSessionKeyMyReport] = myReport;
            Session[rpexcel.strSessionKeyReportParameterContainer] = container;
        }
コード例 #7
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (Session[rpexcel.strSessionKeyMyReport] != null)
            {
                myReport = (CUSTOMRP.Model.REPORT)Session[rpexcel.strSessionKeyMyReport];
            }

            if (myReport == null)
            {
                if (!String.IsNullOrEmpty(Request.QueryString["id"]))
                {
                    int id = Int32.Parse(Request.QueryString["id"]);
                    myReport = WebHelper.bllReport.GetModel(me.ID, id);

                    if (myReport == null)
                    {
                        Common.JScript.AlertAndRedirect(Code.AppNum.ErrorMsg.parameter_error, "rplist.aspx");
                        Response.End();
                    }
                }
            }

            if (Session[rpexcel.strSessionKeyColumnInfo] != null)
            {
                columninfos = (List <CUSTOMRP.Model.ColumnInfo>)Session[rpexcel.strSessionKeyColumnInfo];
            }

            if (Session[rpexcel.strSessionKeyReportParameterContainer] != null)
            {
                container = (ReportParameterContainer)Session[rpexcel.strSessionKeyReportParameterContainer];
                //v1.0.0 - Cheong - 2015/07/13 - Patch SEQ
                if (myReport != null)
                {
                    foreach (CUSTOMRP.Model.REPORTCOLUMN rc in myReport.ReportColumns)
                    {
                        rc.SEQ = -1;
                    }
                    CUSTOMRP.Model.REPORTCOLUMN l_ReportColumn = null;
                    int contentSEQ = 1;
                    foreach (Fields f in container.contentColumn)
                    {
                        l_ReportColumn = myReport.ReportColumns.Where(x => x.COLUMNFUNC == 1 && x.DisplayName == f.DisplayName).FirstOrDefault();
                        if (l_ReportColumn != null)
                        {
                            l_ReportColumn.SEQ = contentSEQ;
                            contentSEQ++;
                        }
                    }
                    //v1.0.0 - Cheong - 2016/03/23 - Preserve order on criteria and group columns
                    int criteriaSEQ = 1;
                    foreach (Fields f in container.criteriaColumn)
                    {
                        l_ReportColumn = myReport.ReportColumns.Where(x => x.COLUMNFUNC == 2 && x.DisplayName == f.DisplayName).FirstOrDefault();
                        if (l_ReportColumn != null)
                        {
                            l_ReportColumn.SEQ = criteriaSEQ;
                            criteriaSEQ++;
                        }
                    }
                    int sortonSEQ = 1;
                    foreach (Fields f in container.sortonColumn)
                    {
                        l_ReportColumn = myReport.ReportColumns.Where(x => x.COLUMNFUNC == 3 && x.DisplayName == f.DisplayName).FirstOrDefault();
                        if (l_ReportColumn != null)
                        {
                            l_ReportColumn.SEQ = sortonSEQ;
                            sortonSEQ++;
                        }
                    }
                    //v1.0.0 - Cheong - 2016/03/23 - Preserve order on criteria and group columns
                    int groupSEQ = 1;
                    foreach (Fields f in container.groupColumn)
                    {
                        l_ReportColumn = myReport.ReportColumns.Where(x => x.COLUMNFUNC == 6 && x.DisplayName == f.DisplayName).FirstOrDefault();
                        if (l_ReportColumn != null)
                        {
                            l_ReportColumn.SEQ = groupSEQ;
                            groupSEQ++;
                        }
                    }
                    myReport.ReportColumns.OrderBy(x => x.COLUMNFUNC).ThenBy(x => x.SEQ);
                }
            }
            else if (!ReportParameterContainer.LoadReport(myReport.ID, me, out container, out columninfos)) // try load default from table
            {
                Response.Redirect("rplist.aspx");
            }
        }