Example #1
0
    private void _doOnRunEventXls(RmtThreadHandler sender, out IRemoteProcInst instance) {
      var rptCfg = CXLReportConfig.LoadFromFile(
        null,
        this.bioCode,
        Utl.NormalizeDir(this.BioSession.Cfg.IniPath) + "rpts\\",
        Utl.NormalizeDir(this.BioSession.Cfg.WorkspacePath) + "rpts\\",
        this.BioSession.Cfg.dbSession,
        this.BioSession.CurSessionID,
        this.BioSession.Cfg.CurUser.Login,
        this.BioSession.CurSessionRemoteIP,
        this.bioParams,
        !this.BioSession.Cfg.Debug
      );
      instance = new CXLReport(null, rptCfg, this.Context);

      var v_action = String.Format("Запуск отчета \"{1}\". Параметры запуска: {0}", this.bioParams.ToString(), ((CXLReport)instance).RptDefinition.Title);

      SQLCmd.ExecuteScript(
        this.BioSession.Cfg.dbSession,
        "begin givcadmin.utils.reg_usr_activity (" +
        " :p_usr_id," +
        " :p_iobj_cd," +
        " :p_iobj_uid," +
        " :p_action); end;",
        new Params(
          new Param("p_usr_id", this.BioSession.Cfg.CurUser.UID),
          new Param("p_iobj_cd", "XLR-BUILDER"),
          new Param("p_iobj_uid", this.bioCode),
          new Param("p_action", v_action)
        ),
        60
      );

    }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="pOwner"></param>
		/// <param name="cfg"></param>
		public XLRDataSource(CXLReport pOwner, CXLReportDSConfig cfg){
			this._owner = pOwner;
      this._cfg = cfg;

      this._ds = new CXLRDataSet(this);
      this._ds.OnProgress += this._doOnProgressDataSet;
    }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="owner"></param>
		/// <param name="dss"></param>
		public XLRDataSources(CXLReport owner, List<CXLReportDSConfig> dss){
      this._owner = owner;
      this._dss = new List<XLRDataSource>();
			foreach(var dsCfg in dss){
        var v_newDS = new XLRDataSource(this._owner, dsCfg);
        v_newDS.OnProgress += this._owner.DoOnProgressDataSource;
        this._dss.Add(v_newDS);
			}
		}
 public CXLRDefinition(CXLReport owner, CXLReportConfig rptCfg) {
   this._owner = owner;
   this._rptCfg = rptCfg;
   this._rptCfg.detectTemplateFileName();
   if (!this.InParams.ParamExists("SYS_CURUSERUID", true))
     this.InParams.Add("SYS_CURUSERUID", this._rptCfg.extAttrs.userUID);
   if (!this.InParams.ParamExists("SYS_CURUSERIP", true))
     this.InParams.Add("SYS_CURUSERIP", this._rptCfg.extAttrs.remoteIP);
   if (!this.InParams.ParamExists("SYS_CURUSERROLES", true))
     this.InParams.Add("SYS_CURUSERROLES", this._rptCfg.extAttrs.roles);
   if (!this.InParams.ParamExists("SYS_CURODEPUID", true))
     this.InParams.Add("SYS_CURODEPUID", this._rptCfg.extAttrs.userUID);
   if (!this.InParams.ParamExists("SYS_TITLE", true))
     this.InParams.Add("SYS_TITLE", this._rptCfg.title);
 }
Example #5
0
 private void DoOnPrepareTemplate(Object opener, ref Excel.Workbook wb, CXLReport report) {
     Excel.Range vRng = ExcelSrv.GetRangeByName(ref wb, "mRng");
     if (vRng != null) {
       Excel.Worksheet vWS = vRng.Worksheet;
       vRng = ExcelSrv.getRange(vWS, vWS.Cells[vRng.Row - 1, 2], vWS.Cells[vRng.Row + vRng.Rows.Count, 2]);
       var dsCfg = report.RptDefinition.dsCfgByRangeName("mRng");
       var colHeadersFromCli = Params.FindParamValue<Dictionary<String, String>>(report.RptDefinition.InParams, "dataGridOnClientHeaders");
       if (colHeadersFromCli != null) {
         foreach (var fd in dsCfg.fieldDefs) {
           String colHeader;
           if (colHeadersFromCli.TryGetValue(fd.name.ToUpper(), out colHeader))
             fd.header = colHeader;
         }
       }
       this.insertCols(ref vRng, dsCfg.fieldDefs);
     }
 }
 private void _applyParamsToWs(CXLReport rpt, Excel.Worksheet ws) {
   var rDef = this.Owner.RptDefinition;
   if (rDef.RptParams != null) {
     for (var i = 0; i < rDef.RptParams.Count; i++) {
       var prmName = rDef.RptParams[i].Name;
       var prmValue = rDef.RptParams.GetReportParameter(rpt, prmName);
       _setParam(ws, "#" + prmName + "#", prmValue);
     }
   }
   _setParam(ws, CXLRDefinition.getParamMappingOfProp("ThrowCode"), rDef.ThrowCode);
   _setParam(ws, CXLRDefinition.getParamMappingOfProp("FullCode"), rDef.FullCode);
   _setParam(ws, CXLRDefinition.getParamMappingOfProp("ShortCode"), rDef.ShortCode);
   _setParam(ws, CXLRDefinition.getParamMappingOfProp("Roles"), rDef.Roles);
   _setParam(ws, CXLRDefinition.getParamMappingOfProp("Title"), rDef.Title);
   _setParam(ws, CXLRDefinition.getParamMappingOfProp("Subject"), rDef.Subject);
   _setParam(ws, CXLRDefinition.getParamMappingOfProp("Autor"), rDef.Autor);
   //this.setParam(ws, CXLRDefinition.getParamMappingOfProp("DBConnStr"), vRDef.DBConnStr);
   _setParam(ws, CXLRDefinition.getParamMappingOfProp("SessionID"), rDef.SessionID);
   _setParam(ws, CXLRDefinition.getParamMappingOfProp("UserName"), rDef.UserName);
   _setParam(ws, CXLRDefinition.getParamMappingOfProp("RemoteIP"), rDef.RemoteIP);
   _setParam(ws, CXLRDefinition.getParamMappingOfProp("RptLocalPath"), rDef.RptLocalPath);
   _setParam(ws, CXLRDefinition.getParamMappingOfProp("TmpPath"), rDef.TmpPath);
   _setParam(ws, CXLRDefinition.getParamMappingOfProp("LogPath"), rDef.LogPath);
 }
//public
		//constructor
		public CXLRSQLScript(CXLReport pOwner){
			this.FOwner = pOwner;
		}
Example #8
0
    private void _doOnRunEventXls(RmtThreadHandler sender, out IRemoteProcInst instance) {
      var title = this.BioRequest<RmtClientRequest>().title;
      title = title != null ? title.Replace("<br>", "\n") : "";
      var io = this.BioSession.IObj_get(this.bioCode);
      if (io == null)
        throw new Exception(String.Format("Bio {0} не найден!", this.bioCode));
      var defaultTmpl = this.BioSession.Cfg.IniPath + "iod\\bio2xl_default.xlsm";
      var customTmpl = io.ioTemplate2XL;
      if ((!File.Exists(defaultTmpl)) && (String.IsNullOrEmpty(customTmpl)))
        throw this.creBioEx("Шаблон для экспорта не найден в системе.", null);

      var isDefaultTempl = true;
      var seldTempl = defaultTmpl;
      if (!String.IsNullOrEmpty(customTmpl)) {
        seldTempl = customTmpl;
        isDefaultTempl = false;
      }

      var rptCfg = new CXLReportConfig();
      rptCfg.fullCode = io.bioCode;
      rptCfg.extAttrs.roles = "all";
      rptCfg.debug = false;
      rptCfg.extAttrs.liveScripts = false;
      rptCfg.templateAdv = seldTempl;
      rptCfg.title = title;
      rptCfg.filenameFmt = "{$code}_{$now}";
      rptCfg.dbSession = this.BioSession.Cfg.dbSession;
      rptCfg.extAttrs.sessionID = this.BioSession.CurSessionID;
      rptCfg.extAttrs.userUID = this.BioSession.Cfg.CurUser.UID;
      rptCfg.extAttrs.remoteIP = this.BioSession.CurSessionRemoteIP;
      rptCfg.extAttrs.workPath = this.BioSession.Cfg.WorkspacePath;
      foreach (var prm in this.bioParams)
        rptCfg.inPrms.Add((Param) prm.Clone());
      foreach (var prm in this.bioParams)
        rptCfg.rptPrms.Add(prm.Name, prm.Value, "str");
      rptCfg.debug = Xml.getAttribute<Boolean>(io.IniDocument.XmlDoc.DocumentElement, "debug", false);
      rptCfg.dss.Add(CXLReportDSConfig.DecodeFromBio(
        io.IniDocument.XmlDoc.DocumentElement,
        io.LocalPath, "cdsRpt", "mRng", rptCfg.title, null));
      instance = new CXLReport(io, rptCfg, this.Context);
      if (isDefaultTempl)
        (instance as CXLReport).OnPrepareTemplate += this.DoOnPrepareTemplate;

    }
 private void runScript(CXLReport rpt, String pName, Params pParams) {
   if(pName != null) {
     Object vArg1 = Type.Missing;
     if(pParams.Count > 0)
       vArg1 = pParams.GetReportParameter(rpt, pParams[0].Name);
     Object vArg2 = Type.Missing;
     if(pParams.Count > 1)
       vArg2 = pParams.GetReportParameter(rpt, pParams[1].Name);
     Object vArg3 = Type.Missing;
     if(pParams.Count > 2)
       vArg3 = pParams.GetReportParameter(rpt, pParams[2].Name);
     Object vArg4 = Type.Missing;
     if(pParams.Count > 3)
       vArg3 = pParams.GetReportParameter(rpt, pParams[3].Name);
     Object vArg5 = Type.Missing;
     if(pParams.Count > 4)
       vArg5 = pParams.GetReportParameter(rpt, pParams[4].Name);
     Object vArg6 = Type.Missing;
     if(pParams.Count > 5)
       vArg6 = pParams.GetReportParameter(rpt, pParams[5].Name);
     Object vArg7 = Type.Missing;
     if(pParams.Count > 6)
       vArg7 = pParams.GetReportParameter(rpt, pParams[6].Name);
     Object vArg8 = Type.Missing;
     if(pParams.Count > 7)
       vArg8 = pParams.GetReportParameter(rpt, pParams[7].Name);
     Object vArg9 = Type.Missing;
     if(pParams.Count > 8)
       vArg9 = pParams.GetReportParameter(rpt, pParams[8].Name);
     Object vArg10 = Type.Missing;
     if(pParams.Count > 9)
       vArg10 = pParams.GetReportParameter(rpt, pParams[9].Name);
     Object vArg11 = Type.Missing;
     if(pParams.Count > 10)
       vArg11 = pParams.GetReportParameter(rpt, pParams[10].Name);
     Object vArg12 = Type.Missing;
     if(pParams.Count > 11)
       vArg12 = pParams.GetReportParameter(rpt, pParams[11].Name);
     Object vArg13 = Type.Missing;
     if(pParams.Count > 12)
       vArg13 = pParams.GetReportParameter(rpt, pParams[12].Name);
     Object vArg14 = Type.Missing;
     if(pParams.Count > 13)
       vArg14 = pParams.GetReportParameter(rpt, pParams[13].Name);
     Object vArg15 = Type.Missing;
     if(pParams.Count > 14)
       vArg15 = pParams.GetReportParameter(rpt, pParams[14].Name);
     Object vArg16 = Type.Missing;
     if(pParams.Count > 15)
       vArg16 = pParams.GetReportParameter(rpt, pParams[15].Name);
     Object vArg17 = Type.Missing;
     if(pParams.Count > 16)
       vArg17 = pParams.GetReportParameter(rpt, pParams[16].Name);
     Object vArg18 = Type.Missing;
     if(pParams.Count > 17)
       vArg18 = pParams.GetReportParameter(rpt, pParams[17].Name);
     Object vArg19 = Type.Missing;
     if(pParams.Count > 18)
       vArg19 = pParams.GetReportParameter(rpt, pParams[18].Name);
     Object vArg20 = Type.Missing;
     if(pParams.Count > 19)
       vArg20 = pParams.GetReportParameter(rpt, pParams[19].Name);
     Object vArg21 = Type.Missing;
     if(pParams.Count > 20)
       vArg21 = pParams.GetReportParameter(rpt, pParams[20].Name);
     Object vArg22 = Type.Missing;
     if(pParams.Count > 21)
       vArg22 = pParams.GetReportParameter(rpt, pParams[21].Name);
     Object vArg23 = Type.Missing;
     if(pParams.Count > 22)
       vArg23 = pParams.GetReportParameter(rpt, pParams[22].Name);
     Object vArg24 = Type.Missing;
     if(pParams.Count > 23)
       vArg24 = pParams.GetReportParameter(rpt, pParams[23].Name);
     Object vArg25 = Type.Missing;
     if(pParams.Count > 24)
       vArg25 = pParams.GetReportParameter(rpt, pParams[24].Name);
     Object vArg26 = Type.Missing;
     if(pParams.Count > 25)
       vArg26 = pParams.GetReportParameter(rpt, pParams[25].Name);
     Object vArg27 = Type.Missing;
     if(pParams.Count > 26)
       vArg27 = pParams.GetReportParameter(rpt, pParams[26].Name);
     Object vArg28 = Type.Missing;
     if(pParams.Count > 27)
       vArg28 = pParams.GetReportParameter(rpt, pParams[27].Name);
     Object vArg29 = Type.Missing;
     if(pParams.Count > 28)
       vArg29 = pParams.GetReportParameter(rpt, pParams[28].Name);
     Object vArg30 = Type.Missing;
     if(pParams.Count > 29)
       vArg30 = pParams.GetReportParameter(rpt, pParams[29].Name);
     if(pParams.Count > 30)
       throw new EBioException("Количество входных параметров макроса не может быть больше 30");
     this.FWorkbook.Application.Run(pName,
       vArg1, vArg2, vArg3, vArg4, vArg5, vArg6, vArg7, vArg8, vArg9, vArg10,
       vArg11, vArg12, vArg13, vArg14, vArg15, vArg16, vArg17, vArg18, vArg19, vArg20,
       vArg21, vArg22, vArg23, vArg24, vArg25, vArg26, vArg27, vArg28, vArg29, vArg30);
   }
 }
 protected override void doOnDispose() {
   this._owner = null;
   this._rptCfg = null;
 }
Example #11
0
    /*
    static void test_detectRptAttrsByCode() {
      String descFilePath = null;
      String shrtCode = null;
      String throwCode = null;
      CXLReportConfig.detectRptAttrsByCode(
        @"D:\data\prjs\bioSys-8\Bio.Helpers\Bio.XLFRpt2\Bio.XLFRpt2.Srvc\bin\test\root\", "connLog.report",
        ref descFilePath, ref shrtCode, ref throwCode);
    }

    static void testCQueueRemote() {
      //// Create the channel.
      //IpcChannel channel = new IpcChannel();
      //// Register the channel.
      //ChannelServices.RegisterChannel(channel);
      //// Register as client for remote object.
      //WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(
      //        typeof(RemoteObject),
      //        "ipc://*****:*****@"D:\data\prjs\bioSys-8\Bio.Helpers\Bio.XLFRpt2\Bio.XLFRpt2.Srvc\bin\test\root\",
        "connLog.Cat.CatS.back_door", "admin");
      String r = dc.InnerXml;

      Console.WriteLine(r);
    }
    */
    static void testReport() {
      CXLReportConfig rptCfg = CXLReportConfig.LoadFromFile(
        null,
        "report",
        null,
        "logs",
        null,
        null,
        null,
        null,
        new Params(new Param { Name = "rpt_bgn", Value = "20100714" }, new Param { Name = "rpt_end", Value = "20100716" }),
        false
      );
      CXLReport rptBuilder = new CXLReport(rptCfg);
      //rptBuilder.DataSources.
      String vrsltFileName = rptBuilder.BuildReportSync();
    }
Example #12
0
    /// <summary>
    /// Синхронный вызов построителя отчета
    /// </summary>
    /// <param name="cfg"></param>
    /// <returns></returns>
    public static String BuildReportSync(CXLReportConfig cfg) {

      String vResult = null;
      //String vRptDefDoc = BuildReportConfigXml(rpt_title, rpt_desc, rpt_template, null, dataFactoryTypeName, reportResultFileName, dss, connStr, debug);
      //CXLReport xlReportDocument = new CXLReport(null, vRptDefDoc, null, null);
      CXLReport xlReportDocument = new CXLReport(cfg);
      try {
        //xlReportDocument.DataSources.Add("cdsRpt", "mRng", null, dataFactoryTypeName);
        //xlReportDocument.RptDefinition.RptParams.AddRange(rpt_params);
        //xlReportDocument.RptDefinition.InParams.AddRange(rpt_params);
        xlReportDocument.BuildReportSync();
        vResult = xlReportDocument.LastResultFile;

      } finally {
        xlReportDocument.Dispose();
      }
      return vResult;
    }