Esempio n. 1
0
        public void RunReport()
        {
            string reportCode = context.Bag[MessageDataExtensionKeys.REPORT_CODE].ToString();

            MaestroReportDefinition reportDef = ReportDefinitionCache.Instance.GetByReportCode(reportCode);

            context.Bag.Add("REPORT_DEF", reportDef);

            Type type = Type.GetType(reportDef.CodeBase);

            if (type == null)
            {
                throw new Exception(string.Format("Codebase `{0}` of report definition `{1}` could not be found", reportDef.CodeBase, reportCode));
            }

            ReportBase report = (ReportBase)Activator.CreateInstance(type, new object[] { context });

            report.Render();
        }
        public override void LoadData()
        {
            MaestroReportDefinition reportDef = (MaestroReportDefinition)context.Bag["REPORT_DEF"];

            DateTime beginDate = (DateTime)context.Bag[MessageDataExtensionKeys.BEGIN_DATE];
            DateTime endDate   = (DateTime)context.Bag[MessageDataExtensionKeys.END_DATE];

            SpCall call = new SpCall(reportDef.ProcedureName);

            call.SetDateTime("@BEGIN_DATE", beginDate);
            call.SetDateTime("@END_DATE", endDate);
            reportData = context.Database.ExecuteDataSet(call);

            if (reportData.Tables[0].Rows.Count == 0)
            {
                throw new Exception(string.Format("No data can be found between {0} and {1}", beginDate, endDate));
            }

            baseData = reportData.Tables[0].AsEnumerable().ToList();
        }
        public override void Deserialize(JToken token)
        {
            MaestroReportDefinition resultObj = new MaestroReportDefinition();

            JObject entityObj = JObject.Parse(token.ToString());

            resultObj.Id          = entityObj["Id"].ToObject <long>();
            resultObj.Description = entityObj["Name"].ToString();

            resultObj.ReportCode     = entityObj["ReportCode"].ToString();
            resultObj.ProcedureName  = entityObj["ProcedureName"].ToString();
            resultObj.MetaDefinition = entityObj["MetaDefinition"].ToString();

            resultObj.FileName = entityObj["FileName"].ToString();

            resultObj.ReportType = entityObj["ReportType"].ToString();

            resultObj.CodeBase = entityObj["CodeBase"].ToString();

            resultObj.TransactionCode = entityObj["TransactionCode"].ToString();

            Context.TransactionObject = resultObj;
        }
        protected override void New()
        {
            MaestroReportDefinition rdef = (MaestroReportDefinition)request.TransactionEntityList[0];

            SpCall call = new SpCall("RPT.REPORT_DEFINITION_INSERT");

            call.SetVarchar("@REPORT_CODE", rdef.ReportCode);
            call.SetVarchar("@REPORT_DESCRIPTION", rdef.Description);
            call.SetBinary("@TEMPLATE", rdef.Template);
            call.SetVarchar("@META_DEFINITION", rdef.MetaDefinition);
            call.SetVarchar("@REPORT_FILE_NAME", rdef.FileName);
            call.SetVarchar("@REPORT_PROCEDURE_NAME", rdef.ProcedureName);
            call.SetVarchar("@REPORT_TYPE", rdef.ReportType);
            call.SetVarchar("@CODE_BASE", rdef.CodeBase);

            call.SetDateTime("@CREATE_DATE", DateTime.Now);
            call.SetVarchar("@CREATE_USER", Context.UserName);

            call.SetVarchar("@TRAN_CODE", rdef.TransactionCode);

            rdef.Id = db.ExecuteScalar <long>(call);

            response.TransactionResult = rdef;
        }
        protected override void Update()
        {
            MaestroReportDefinition rdef = (MaestroReportDefinition)request.TransactionEntityList[0];

            SpCall call = new SpCall("RPT.REPORT_DEFINITION_UPDATE");

            call.SetBigInt("@ID", rdef.Id);
            call.SetVarchar("@REPORT_CODE", rdef.ReportCode);
            call.SetVarchar("@REPORT_DESCRIPTION", rdef.Description);
            call.SetBinary("@TEMPLATE", rdef.Template);
            call.SetVarchar("@META_DEFINITION", rdef.MetaDefinition);
            call.SetVarchar("@REPORT_FILE_NAME", rdef.FileName);
            call.SetVarchar("@REPORT_PROCEDURE_NAME", rdef.ProcedureName);
            call.SetVarchar("@REPORT_TYPE", rdef.ReportType);
            call.SetVarchar("@CODE_BASE", rdef.CodeBase);

            call.SetDateTime("@UPDATE_DATE", DateTime.Now);
            call.SetVarchar("@UPDATE_USER", Context.UserName);
            call.SetVarchar("@TRAN_CODE", rdef.TransactionCode);

            db.ExecuteNonQuery(call);
            Context.TransactionObject = rdef;
            ReportDefinitionCache.Instance.Reload(true);
        }
 protected ReportBase(TransactionContext context)
 {
     this.context     = context;
     reportDefinition = (MaestroReportDefinition)context.Bag["REPORT_DEF"];
 }