Example #1
0
    protected override IDictionary<String, JSFieldType> open(IDbConnection conn, CXLReportDSConfig dsCfg, Int32 timeout) {


      IDictionary<String, JSFieldType> rslt = null;

      this.FCmd = new SQLCursor(conn);
      String vSQL = dsCfg.sql;
      this.FCmd.Init(vSQL, dsCfg.owner.inPrms);
      try {
        if (dsCfg.owner.debug)
          Utl.SaveStringToFile(dsCfg.owner.logPath + dsCfg.owner.extAttrs.shortCode + ".prdDS." + dsCfg.rangeName + ".sql", vSQL, null);
        this.FCmd.Open(timeout);
        //if (this.FDataReader.Next()) {
          rslt = new Dictionary<String, JSFieldType>();
          for (int i = 0; i < this.FCmd.FieldsCount; i++) {
            rslt.Add(this.FCmd.Fields[i].FieldName,
                     this.FCmd.Fields[i].DataType);
          }
        //}
          return rslt;
      } catch (ThreadAbortException) {
        throw;
      } catch (Exception ex) {
        throw EBioException.CreateIfNotEBio(ex);
      }
    }
		/// <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;
    }
Example #3
0
 private void bldCSV(CXLReportDSConfig dsCfg, CXLRDataFactory tbl, String fileName, Boolean addHeader, Params colHeaders) {
   String vCSVDelimiter = ";";
   Encoding vEnc = Encoding.GetEncoding(1251);
   if (File.Exists(fileName))
     File.Delete(fileName);
   String vLine = null;
   if (addHeader) {
     if (colHeaders != null) {
       for (int j = 0; j < colHeaders.Count; j++) {
         //String vColHeader = (String)Params.FindParamValue(pColHeaders, pTbl.GetCoulumnName(j));
         String vColHeader = colHeaders[j].ValueAsString();
         if (!String.IsNullOrEmpty(vColHeader))
           Utl.AppendStr(ref vLine, vColHeader, vCSVDelimiter);
       }
       Utl.AppendStringToFile(fileName, vLine, vEnc);
     }
   }
   var conn = tbl.openDbConnection(dsCfg.owner);
   try {
     tbl.Open(conn, dsCfg, 120);
     while (tbl.Next()) {
       vLine = null;
       for (int j = 0; j < colHeaders.Count; j++) {
         if (!String.Equals(colHeaders[j].Name, csEXPDATAROWNUMBER_COL_NAME, StringComparison.CurrentCultureIgnoreCase)) {
           Object vValueObj = tbl.ValueByName(colHeaders[j].Name);
           String vValue = null;
           if (vValueObj is DateTime)
             vValue = ((DateTime)vValueObj).ToString(CultureInfo.GetCultureInfo("ru-RU"));
           else
             vValue = (vValueObj != null) ? vValueObj.ToString() : null;
           if ((vValueObj is String) && !String.IsNullOrEmpty(vValue) && (vValue.IndexOf(vCSVDelimiter) >= 0)) {
             vValue = "\"" + vValue.Replace("\"", "\"\"") + "\"";
           }
           Utl.AppendStr(ref vLine, vValue, vCSVDelimiter);
         }
       }
       Utl.AppendStringToFile(fileName, vLine, vEnc);
     }
   } finally {
     conn.Close();
   }
 }
Example #4
0
 protected override IDictionary<String, JSFieldType> open(IDbConnection conn, CXLReportDSConfig dsCfg, Int32 timeout) {
   this._cmd = new SqlCommand(dsCfg.sql);
   this._cmd.CommandType = dsCfg.commandType;
   this._cmd.Connection = conn as SqlConnection;
   this._cmd.CommandTimeout = timeout;
   try {
     if (dsCfg.owner.debug)
       Utl.SaveStringToFile(dsCfg.owner.logPath + dsCfg.owner.extAttrs.shortCode + ".prdDS." + dsCfg.rangeName + ".sql", dsCfg.sql, null);
     _applayParams(this._cmd, dsCfg.owner.inPrms);
     this._dataReader = this._cmd.ExecuteReader();
     IDictionary<String, JSFieldType> v_rslt = new Dictionary<String, JSFieldType>();
     for (var i = 0; i < this._dataReader.FieldCount; i++) {
       v_rslt.Add(this._dataReader.GetName(i).ToUpper(),
                ftypeHelper.ConvertTypeToFType(this._dataReader.GetFieldType(i)));
     }
     return v_rslt;
   } catch (ThreadAbortException) {
     throw;
   } catch (Exception ex) {
     throw EBioException.CreateIfNotEBio(ex);
   }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="cfg"></param>
 public void Add(CXLReportDSConfig cfg) {
   var v_newDS = new XLRDataSource(this._owner, cfg);
   v_newDS.OnProgress += this._owner.DoOnProgressDataSource;
   _dss.Add(v_newDS);
 }