/// <summary> /// Handler that does the show of the report window. This should alway be /// on the Caller's thread /// </summary> /// <param name="args"></param> private void ShowReport(Object args) { IStaticReport report = (IStaticReport)args; FluidTrade.Reporting.Windows.WindowReportContainer window = new FluidTrade.Reporting.Windows.WindowReportContainer(report); window.Show(); }
/// <summary> /// ctor /// </summary> /// <param name="reportGetDataSourceEventArgs"></param> public ReportGetDataSourceEventArgs(ReportGetDataSourceEventArgs reportGetDataSourceEventArgs) { this.report = reportGetDataSourceEventArgs.report; this.requiredColumnNames = reportGetDataSourceEventArgs.requiredColumnNames; this.dataSource = reportGetDataSourceEventArgs.dataSource; this.dataSourceSyncObject = reportGetDataSourceEventArgs.dataSourceSyncObject; }
/// <summary> /// Creates and fills a list of ReportFillParameterEventArgs with all the parameters defined. /// /// </summary> /// <param name="parameterNamesToValueMap"></param> /// <returns></returns> private List <ReportFillParameterEventArgs> CreateParameterArgsList(IStaticReport report, Dictionary <string, List <ReportParameterValue> > parameterNamesToValueMap) { List <ReportFillParameterEventArgs> fillParamArgsList = new List <ReportFillParameterEventArgs>(); foreach (KeyValuePair <string, List <ReportParameterValue> > pair in parameterNamesToValueMap) { string paramName = pair.Key; string upperParamName = paramName.ToUpperInvariant(); //if not a path just make a non path ReportFillParameterEventArgs if (!upperParamName.StartsWith(PATH_TAG)) { fillParamArgsList.Add(new ReportFillParameterEventArgs(report, paramName, pair.Value, PathType.None, null)); continue; } ReportFillParameterEventArgs parentPathArgs = new ReportFillParameterEventArgs(report, paramName, pair.Value, PathType.Path, null); fillParamArgsList.Add(parentPathArgs); //split the path and create the args for the calls back to the provider string[] pathArgsAr = paramName.Substring(PATH_TAG.Length).Split('_'); for (int i = 0; i < pathArgsAr.Length; i++) { PathType pathType = (PathType)Enum.Parse(typeof(PathType), pathArgsAr[i], true); ReportFillParameterEventArgs newPathArgs = new ReportFillParameterEventArgs(report, pathArgsAr[i], null, pathType, parentPathArgs); switch (pathType) { case PathType.SelectedItem: case PathType.SelectedFolder: case PathType.FolderParent: case PathType.FolderRoot: { //positioning args parentPathArgs = newPathArgs; break; } } } } return(fillParamArgsList); }
/// <summary> /// ctor /// </summary> /// <param name="report">IStaticReport that is used to create the control to be put into the ReportWindow</param> public WindowReportContainer(IStaticReport report) { InitializeComponent(); if (report != null) { FluidTrade.Reporting.Controls.ClientReportUserControl reportCtrl = report.CreateReportControl(); reportCtrl.Initialize(report); if(string.IsNullOrEmpty(report.GenerationItem.TemplateName) == true) this.Title = report.GenerationItem.TemplatePath; else this.Title = report.GenerationItem.TemplateName; this.ReportControl = reportCtrl; } }
/// <summary> /// ctor /// </summary> /// <param name="report">IStaticReport that this parameter is for</param> /// <param name="name">name of the parameter</param> /// <param name="values">List of values that is to be populated, or possibly changed if the /// IStaticReport has provided default values</param> /// <param name="pathType">is this parameter a path and if so what type of path node</param> /// <param name="parent">parent parameter</param> public ReportFillParameterEventArgs(IStaticReport report, string name, List <ReportParameterValue> values, PathType pathType, ReportFillParameterEventArgs parent) { this.name = name; this.report = report; this.pathType = pathType; this.values = values; //if this has a parent set up the relationship if (parent != null) { this.parent = parent; if (this.parent.childList == null) { this.parent.childList = new List <ReportFillParameterEventArgs>(); } this.parent.childList.Add(this); } }
/// <summary> /// ctor /// </summary> /// <param name="report"></param> /// <param name="requiredColumnNames">columns that are used in the report</param> public ReportGetDataSourceEventArgs(IStaticReport report, HashSet <string> requiredColumnNames) { this.report = report; this.requiredColumnNames = requiredColumnNames; }
/// <summary> /// ctor /// </summary> /// <param name="report">Report for the eventArg</param> /// <param name="task">task for the event arg</param> /// <param name="status">status of the task</param> /// <param name="userDescriptionText">text that can be displayed to user about task status</param> /// <param name="errorList">list of errors</param> /// <param name="cancelled">has the task been canceled</param> public ReportTaskStatusEventArgs(IStaticReport report, Task task, TaskStatus status, string userDescriptionText, List <Exception> errorList, Boolean cancelled) : base(task, status, userDescriptionText, errorList, cancelled) { this.report = report; }
/// <summary> /// Initialize the report. Must be called before operations or report is viewed. Mostlikely called /// right after ctor /// </summary> /// <param name="report"></param> public void Initialize(IStaticReport report) { this.report = report; //call the abstract method so derived class can do their initialization this.InitializeInternal(report); }
/// <summary> /// method for derived class to override. split apart from /// initialize so derived class does not have to worry about base class logic /// such as setting report /// </summary> /// <param name="report"></param> protected abstract void InitializeInternal(IStaticReport report);
/// <summary> /// Worker thread metod that does the work of generating the report(s) /// </summary> private void WorkerProc() { try { //loop thru all the reports to generate foreach (ReportGenerationItem curItem in this.generationParameter.GenerationItems) { ////NOTE: at somepoint could have a factory to create ////the correct IStaticReport Object but for now since it is ////all crystal Just create a crystal report Object IStaticReport report = new Crystal.CrystalReport(); lock (currentReportSync) this.currentReport = report; HashSet <string> requiredFieldNames = new HashSet <string>(); Dictionary <string, List <ReportParameterValue> > parameterNamesToValueMap = new Dictionary <string, List <ReportParameterValue> >(); //get the pre-configuration data from the IStaticReport Object //the pre-configuration data is infomation about the report that //is needed to configure the report. //in most cases this would load the report template get a list of needed parameters //and a list of needed fieldNames report.PopulateReportConfiguration(this.generationParameter, curItem, requiredFieldNames, parameterNamesToValueMap); ReportGetDataSourceEventArgs getDataArgs = new ReportGetDataSourceEventArgs(report, requiredFieldNames); ReportGetDataSourceEventArgs originalGetDataArgs = getDataArgs; //build fillParamsArgs tree List <ReportFillParameterEventArgs> fillParamArgsList = this.CreateParameterArgsList(report, parameterNamesToValueMap); ProcessSendGetConfigDataEventArgs sendArgs = new ProcessSendGetConfigDataEventArgs(); sendArgs.curItem = curItem; sendArgs.report = report; sendArgs.getDataSourceArgs = getDataArgs; sendArgs.fillParameterArgsList = fillParamArgsList; sendArgs.parameterNamesToValueMap = parameterNamesToValueMap; //sendArgs.parameterNamesToValueMap = parameterNamesToValueMap; //is there is a syncContext then can send request back to caller thread if (this.SyncContext != null) { //want to get this back to the caller thread to get the Config Data //especially the parameterValues. Might want to split the call up //make blocking send call back to caller thread to get the configuration data this.PostOrSend(false, new SendOrPostCallback(this.ProcessSendGetConfigData), new Object[] { sendArgs }); } else { //no syncContext so call on this thread this.ProcessSendGetConfigData(sendArgs); } if (sendArgs.Validated == false) { //TODO: !!!RM LOCALIZE //notify any subscribers of progress this.Notify(new ReportTaskStatusEventArgs(report, this, TaskStatus.Info, string.Format("completed generation: {0}", curItem.TemplatePath), null, false)); continue; } if (curItem.ReportTranslation != null) { getDataArgs = curItem.ReportTranslation.GetTranslatedObject(sendArgs); if (getDataArgs == null) { continue; } } Object curItemDatsSyncObject = getDataArgs.DataSourceSyncObject; // get the sync Object as soon as the GetConfig() returns. //Call IReportObject to configure the report. This will probably not build the report, but it could //it would all depend on the impl of IStaticReport // if it did then the BuildDocumentForView or export calls below would be faster report.ConfigureReport(curItem, getDataArgs, parameterNamesToValueMap); //TODO: !!!RM LOCALIZE //notify any subscribers of progress this.Notify(new ReportTaskStatusEventArgs(report, this, TaskStatus.Started, string.Format("starting generation: {0}", curItem.TemplatePath), null, false)); //if lock Object not null lock it if (curItemDatsSyncObject != null) { lock (curItemDatsSyncObject) { if (curItem.GenerationType == ReportGenerationType.ShowReportInDlg) { report.BuildDocumentForView(); } else { report.Export(); } } } else { if (curItem.GenerationType == ReportGenerationType.ShowReportInDlg) { report.BuildDocumentForView(); } else { report.Export(); } } //TODO: !!!RM LOCALIZE //notify any subscribers of progress this.Notify(new ReportTaskStatusEventArgs(report, this, TaskStatus.Info, string.Format("completed generation: {0}", curItem.TemplatePath), null, false)); //if gen type is show then need to post a message back to //the caller thread to show the window. doning this after //sending completed message if (curItem.GenerationType == ReportGenerationType.ShowReportInDlg) { this.PostOrSend(false, new SendOrPostCallback(this.ShowReport), new Object[] { report }); } } } catch (ThreadAbortException) { //catch the abort, and cancel the task Thread.ResetAbort(); this.isCanceled = true; } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); //catch any other ex and set the property. //the task should never throw will be up to caller to determine what to do with //the exception this.error = ex; } finally { //all done this.SetTaskCompleted(); } }