private SQLGarbageMonitorItem findItem(SQLCmd sqlCmd) { SQLGarbageMonitorItem[] v_list; lock (this._list) { v_list = this._list.ToArray<SQLGarbageMonitorItem>(); } foreach (var v_item in v_list) { if (v_item.sqlCmd.Equals(sqlCmd)) return v_item; } return null; }
private Queue<CXLRptItem> _getReportsList(String viewName) { var v_rslt = new Queue<CXLRptItem>(); var v_cur = new SQLCmd(this.cfg.dbSession); var v_sql = String.Format("SELECT a.rpt_uid, a.rpt_code, a.usr_uid, a.parent_obj_uid, a.cre_date FROM {0} a", viewName); v_cur.Init(v_sql, null); v_cur.Open(120); try { while (v_cur.Next()) { var uid = v_cur.DataReader.GetValue(0) as String; var code = v_cur.DataReader.GetValue(1) as String; var usr = v_cur.DataReader.GetValue(2) as String; var parentUID = v_cur.DataReader.GetValue(3) as String; var created = (DateTime)v_cur.DataReader.GetValue(4); v_rslt.Enqueue(new CXLRptItem { uid = uid, code = code, usr = usr, prms = this._getRptParams(uid), parentObjUID = parentUID, creDate = created }); } } finally { v_cur.Close(); } return v_rslt; }
private Params _getRptParams(String uid) { var v_rslt = new Params(); var v_cur = new SQLCmd(this.cfg.dbSession); var v_prms = new Params(new Param("rpt_uid", uid)); v_cur.Init("select prm_name, prm_type, prm_val from rpt$rparams where rpt_uid = :rpt_uid", v_prms); v_cur.Open(120); try { while (v_cur.Next()) { var v_prmName = v_cur.DataReader.GetValue(0) as String; var v_prmType = v_cur.DataReader.GetValue(1) as String; var v_prmVal = v_cur.DataReader.GetValue(2) as String; var v_prm = new Param(); v_prm.Name = v_prmName; v_prm.Value = _paramDecode(v_prmType, v_prmVal); v_rslt.Add(v_prm); } } finally { v_cur.Close(); } return v_rslt; }
/// <summary> /// Формируем список отчетов в очереди /// </summary> /// <param name="userUID"></param> /// <param name="remoteIP"></param> /// <returns></returns> protected override XmlDocument doOnGetQueue(String userUID, String remoteIP) { var v_rslt = dom4cs.NewDocument("queue").XmlDoc; if (v_rslt.DocumentElement != null) { v_rslt.DocumentElement.SetAttribute("usr", userUID); v_rslt.DocumentElement.SetAttribute("remote_ip", remoteIP); v_rslt.DocumentElement.SetAttribute("count", "0"); } const string sql = "select * from table(xlr.rqueue_xml(null,:p_usr_uid))"; var v_prms = new Params(); v_prms.Add("p_usr_uid", userUID); var v_cur = new SQLCmd(this.cfg.dbSession); v_cur.Init(sql, v_prms); v_cur.Open(120); var v_sb = new StringBuilder(); try{ var v_cnt = 0; while (v_cur.Next()) { v_sb.AppendLine(v_cur.DataReader.GetString(0)); v_cnt++; } if (v_sb.Length > 0) { if (v_rslt.DocumentElement != null) { v_rslt.DocumentElement.InnerXml = v_sb.ToString(); v_rslt.DocumentElement.SetAttribute("count", "" + v_cnt); } } } finally { v_cur.Close(); } return v_rslt; }
/// <summary> /// Тут вытаскиваем из очереди файл готового отчета /// </summary> /// <param name="rptUID"></param> /// <param name="userUID"></param> /// <param name="remoteIP"></param> /// <param name="fileName"></param> /// <param name="buff"></param> protected override void doOnGetReportResult(String rptUID, String userUID, String remoteIP, ref String fileName, ref Byte[] buff) { const string sql = "SELECT a.rpt_result_fn, a.rpt_result_len, a.rpt_result" + " FROM rpt$queue_rslts a"+ " WHERE a.rpt_uid = :rpt_uid"; var v_prms = new Params(); v_prms.Add("rpt_uid", rptUID); var v_cur = new SQLCmd(this.cfg.dbSession); v_cur.Init(sql, v_prms); v_cur.Open(120); try { if (v_cur.Next()) { fileName = (String)v_cur.DataReader.GetValue(0); var v_szAct = v_cur.DataReader.GetDecimal(1); var v_szActInt = (int)v_szAct; buff = new byte[v_szActInt]; v_cur.DataReader.GetBytes(2, 0, buff, 0, v_szActInt); } } finally { v_cur.Close(); } }
private Boolean isSQLCmdRegistred(SQLCmd sqlCmd) { SQLGarbageMonitorItem[] v_list; lock (this._list) { v_list = this._list.ToArray<SQLGarbageMonitorItem>(); } foreach (var v_item in v_list) { if (v_item.sqlCmd.Equals(sqlCmd)) return true; } return false; }
/// <summary> /// Удалить запрос из списка отслеживаемых /// </summary> /// <param name="sqlCmd"></param> public void RemoveItem(SQLCmd sqlCmd) { var v_item = this.findItem(sqlCmd); this.RemoveItem(v_item); }
/// <summary> /// Регистрируе SQL запрос в мониторе для отслеживания времени выполнения /// </summary> /// <param name="sqlCmd"></param> /// <param name="checkItemProc"></param> /// <param name="ajaxRequestTimeout"></param> public void RegisterSQLCmd(SQLCmd sqlCmd, DlgSQLGarbageMonitorCheckItem checkItemProc, int ajaxRequestTimeout) { if(!this.isSQLCmdRegistred(sqlCmd)) { lock(this._list) { this._list.Add(new SQLGarbageMonitorItem { sqlCmd = sqlCmd, checkItemProc = checkItemProc, ajaxRequestTimeout = ajaxRequestTimeout }); sqlCmd.garbageMonitor = this; } } }