Esempio n. 1
0
        public static DynamicModels.RootReport PopulateReport(IConnectToDB _Connect1, DynamicModels.RootReport thisModel, string ReportName, DataTable thisDT)
        {
            ConnectToDB _Connect = _Connect1.Copy();

            _Connect.Schema = "DYNAMIC";

            thisModel.ReportName = ReportName;

            if (thisDT.Rows.Count > 0)
            {
                thisModel.ReportFilters = new List <DynamicModels.RootReportFilter>();

                // thisModel.ProcedureName = thisDT.Rows[0].Field<string>("PROCEDURE_NAME");
                thisModel.Template_ID = thisDT.Rows[0].Field <long>("TEMPLATE_ID");
                thisModel.Template    = thisDT.Rows[0].Field <string>("TEMPLATE");
                thisModel.ReportName  = thisDT.Rows[0].Field <string>("REPORT_NAME");

                thisModel.ReportFilters = new List <DynamicModels.RootReportFilter>();

                for (int i = 0; i < thisDT.Rows.Count; i++)
                {
                    DynamicModels.RootReportFilter thisReport = new DynamicModels.RootReportFilter();

                    thisReport.FilterName          = thisDT.Rows[i].Field <string>("FILTER_NAME");
                    thisReport.PrettyName          = thisDT.Rows[i].Field <string>("PRETTY_NAME");
                    thisReport.ParamSize           = Convert.ToInt32(thisDT.Rows[i].Field <long>("PARAM_SIZE"));
                    thisReport.SearchParamSize     = Convert.ToInt32(thisDT.Rows[i].Field <long>("SEARCH_DB_SIZE"));
                    thisReport.DBType              = GetSqlDbType(thisDT.Rows[i].Field <string>("DB_TYPE"));
                    thisReport.SearchDBType        = GetSqlDbType(thisDT.Rows[i].Field <string>("SEARCH_DB_TYPE"));
                    thisReport.FilterSelect        = thisDT.Rows[i].Field <string>("FILTER_SELECT");
                    thisReport.FilterType          = GetFilterType(thisDT.Rows[i].Field <string>("FILTER_TYPE"));
                    thisReport.inPickList          = thisDT.Rows[i].Field <string>("IN_PICK_LIST") == "T" ? true : false;
                    thisReport.ParamValue          = thisDT.Rows[i].Field <string>("ParamValue");
                    thisReport.Required            = thisDT.Rows[i].Field <string>("REQUIRED") == "T" ? true : false;
                    thisReport.AlternateTemplate   = thisDT.Rows[i].Field <string>("ALTERNATE_TEMPLATE");
                    thisReport.AlternateReportName = thisDT.Rows[i].Field <string>("ALTERNATE_REPORT_NAME");
                    thisReport.AlternateSchema     = thisDT.Rows[i].Field <string>("ALTERNATE_SCHEMA");
                    thisReport.AlternateSource     = thisDT.Rows[i].Field <string>("ALTERNATE_SOURCE");

                    thisModel.ReportFilters.Add(thisReport);
                }
            }
            else
            {
                thisModel.ReportFilters = new List <DynamicModels.RootReportFilter>();
            }

            return(thisModel);
        }
        public virtual void CustomReportLogic(DynamicModels.ReportLogicModel logicModel, HttpRequest Request)
        {
            foreach (DynamicModels.RootReportFilter _thisReport in logicModel.CurrentReportSelected.ReportFilters)
            {
                #region Basic List Search
                DynamicModels.RootReportFilter thisCurrentFilter = Tools.Box.Clone <DynamicModels.RootReportFilter>(_thisReport);
                var P_THIS_FILTERNAME = logicModel.useQsCol ? logicModel.qscol.Get("P_" + thisCurrentFilter.FilterName) : Request.Query["P_" + thisCurrentFilter.FilterName].ToString();

                if (P_THIS_FILTERNAME != null && logicModel.UsedFilters.Exists(S => S.FilterName.ToUpper() == thisCurrentFilter.FilterName.ToUpper()) == false)
                {
                    thisCurrentFilter.DBType     = thisCurrentFilter.SearchDBType;
                    thisCurrentFilter.ParamSize  = thisCurrentFilter.SearchParamSize;
                    thisCurrentFilter.ParamValue = P_THIS_FILTERNAME.ToString();
                    logicModel.UsedFilters.Add(thisCurrentFilter);
                }
                #endregion

                #region Equals Search
                DynamicModels.RootReportFilter thisCurrentFilter_ = Tools.Box.Clone <DynamicModels.RootReportFilter>(_thisReport);
                var P_THIS_FILTERNAME_ = logicModel.useQsCol ? logicModel.qscol.Get("P_" + thisCurrentFilter_.FilterName + "_") : Request.Query["P_" + thisCurrentFilter_.FilterName + "_"].ToString();

                if (P_THIS_FILTERNAME_ != null && logicModel.UsedFilters.Exists(S => S.FilterName.ToUpper() == thisCurrentFilter_.FilterName.ToUpper() + "_") == false)
                {
                    thisCurrentFilter_.DBType     = thisCurrentFilter_.SearchDBType;
                    thisCurrentFilter_.FilterName = thisCurrentFilter_.FilterName.ToUpper() + "_";
                    thisCurrentFilter_.ParamSize  = thisCurrentFilter_.SearchParamSize;
                    thisCurrentFilter_.ParamValue = P_THIS_FILTERNAME_.ToString();
                    logicModel.UsedFilters.Add(thisCurrentFilter_);
                }
                #endregion

                #region Basic Not in List Search
                DynamicModels.RootReportFilter thisCurrentFilterExclude = Tools.Box.Clone <DynamicModels.RootReportFilter>(_thisReport);
                var P_THIS_EXCLUDE_FILTERNAME = logicModel.useQsCol ? logicModel.qscol.Get("P_EXCLUDE_" + thisCurrentFilterExclude.FilterName) : Request.Query["P_EXCLUDE_" + thisCurrentFilterExclude.FilterName].ToString();

                if (P_THIS_EXCLUDE_FILTERNAME != null && logicModel.UsedFilters.Exists(S => S.FilterName.ToUpper() == "EXCLUDE_" + thisCurrentFilterExclude.FilterName.ToUpper()) == false)
                {
                    thisCurrentFilterExclude.DBType     = thisCurrentFilterExclude.SearchDBType;
                    thisCurrentFilterExclude.ParamSize  = thisCurrentFilterExclude.SearchParamSize;
                    thisCurrentFilterExclude.ParamValue = P_THIS_EXCLUDE_FILTERNAME.ToString();
                    thisCurrentFilterExclude.FilterName = "EXCLUDE_" + thisCurrentFilterExclude.FilterName;
                    logicModel.UsedFilters.Add(thisCurrentFilterExclude);
                }
                #endregion
            }
        }