private void LoadReportFromSession(decimal Id) { try { _report = (FI.BusinessObjects.OlapReport)Session["Report"]; } catch (InvalidCastException exc) { if (Id == -1) { throw new Exception("Cannot load report from session"); } LoadReportFromId(Id); } if (_report.ID != Id || _report.State == Report.StateEnum.Closed) { if (_report.State == Report.StateEnum.Executing) { _report.CancelExecute(); // if report was executing , and not current, cancel it } LoadReportFromId(Id); } }
public void ExecuteAllOlapReports(string CompanyNameShort, int millisecondsTimeout, string logPath) { if (!System.IO.Path.IsPathRooted(logPath)) { logPath = FI.Common.AppConfig.TempDir + "\\" + logPath; } FI.Common.DataAccess.IUsersDA dacObj = DataAccessFactory.Instance.GetUsersDA(); FI.Common.Data.FIDataTable table = dacObj.ReadUsers(); if (table.Rows.Count == 0) { return; } table.DefaultView.Sort = "Id asc"; int errorCount = 0; int rptCount = 1; foreach (System.Data.DataRowView userRow in table.DefaultView) { if (((string)userRow["CompanyNameShort"]).ToUpper() == CompanyNameShort.ToUpper()) { User user = new User((decimal)userRow["Id"], false); FI.Common.Data.FIDataTable t = user.ReportSystem.GetReportHeaders(typeof(OlapReport)); t.DefaultView.Sort = "id asc"; string userLog = string.Format("***************** User id={0}, login='******', password='******'", user.ID, user.Logon, user.Password); System.IO.StreamWriter sw = System.IO.File.AppendText(logPath); sw.WriteLine(userLog); sw.Close(); foreach (DataRowView rptRow in t.DefaultView) { if ((byte)rptRow["sharing_status"] == (byte)Report.SharingEnum.InheriteSubscriber || (byte)rptRow["sharing_status"] == (byte)Report.SharingEnum.SnapshotSubscriber) { continue; } string log = string.Format("{0}\t#{1}\t", DateTime.Now.ToShortTimeString(), rptCount); try { OlapReport rpt = (OlapReport)user.ReportSystem.GetReport((decimal)rptRow["id"], typeof(OlapReport), true); log += string.Format("OlapReport id={0}, name='{1}', description='{2}'", rpt.ID, rpt.Name, rpt.Description); rpt.BeginExecute(); int milisecondCount = 0; while (milisecondCount < millisecondsTimeout && rpt.State == Report.StateEnum.Executing) { System.Threading.Thread.Sleep(500); milisecondCount += 500; } if (rpt.State == Report.StateEnum.Executing) { rpt.CancelExecute(); log += "\r\n\tcanceled on timeout"; } else { rpt.EndExecute(); log += "\r\n\tcompleted, cells=" + rpt.Cellset.Axis0PosCount * rpt.Cellset.Axis1PosCount; } } catch (Exception exc) { log += string.Format("exception \r\n\t\t{0}", exc.Message); errorCount++; } rptCount++; sw = System.IO.File.AppendText(logPath); sw.WriteLine(log); sw.Close(); } } } }
public void CancelExecute() { _report.CancelExecute(); }
private void LoadReportFromSession(decimal Id) { try { _report=(FI.BusinessObjects.OlapReport)Session["Report"]; } catch(InvalidCastException exc) { if(Id==-1) throw new Exception("Cannot load report from session"); LoadReportFromId(Id); } if(_report.ID!=Id || _report.State==Report.StateEnum.Closed) { if(_report.State==Report.StateEnum.Executing) _report.CancelExecute(); // if report was executing , and not current, cancel it LoadReportFromId(Id); } }