Example #1
0
        /// <summary>
        /// fills in reportFillParamsArgs with the folders under the current folder
        /// </summary>
        /// <param name="defaultId">folder id to use if cannot find a match</param>
        /// <param name="reportFillParamsArgs">args to fill in</param>
        private void GetBlotterFolderChildren(Guid defaultId, ReportFillParameterEventArgs reportFillParamsArgs)
        {
            BlotterRow blotterRow = null;

            //get the current row out of the parentValue
            if (reportFillParamsArgs.ParentValues != null &&
                reportFillParamsArgs.ParentValues.Count != 0)
            {
                blotterRow = reportFillParamsArgs.ParentValues[0].UserObject as BlotterRow;
            }

            //if there is not row in parent use the default
            if (blotterRow == null)
            {
                blotterRow = DataModel.Blotter.Rows.Find(defaultId) as BlotterRow;
            }

            //no parent row return
            if (blotterRow == null)
            {
                return;
            }

            //get all the child blotter rows
            foreach (EntityTreeRow entityTreeRow in blotterRow.EntityRow.GetEntityTreeRowsByFK_Entity_EntityTree_ParentId())
            {
                foreach (BlotterRow childRow in entityTreeRow.EntityRowByFK_Entity_EntityTree_ChildId.GetBlotterRows())
                {
                    reportFillParamsArgs.AddValue(new ReportParameterValue(childRow.BlotterId, childRow));
                }
            }
        }
Example #2
0
        /// <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);
        }
Example #3
0
        /// <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);
            }
        }
Example #4
0
        /// <summary>
        /// Handler that calls the GetConfigData for the GenerationItem. This should alway be
        /// on the Caller's thread
        /// </summary>
        /// <param name="args"></param>
        private void ProcessSendGetConfigData(Object args)
        {
            ProcessSendGetConfigDataEventArgs sendArgs = (ProcessSendGetConfigDataEventArgs)args;

            sendArgs.curItem.GetDataHandler(this, sendArgs.getDataSourceArgs);

            if (sendArgs.fillParameterArgsList.Count != 0)
            {
                //List<ReportFillParameterEventArgs>
                //sendArgs.fillParameterArgsList
                //fist postion the "data pointer" to the correct item/folder


                foreach (ReportFillParameterEventArgs curFillArgs in sendArgs.fillParameterArgsList)
                {
                    //not a path so easy..
                    //subscriber probably not doing anything with it
                    if (curFillArgs.PathType == PathType.None)
                    {
                        sendArgs.curItem.FillParameterHandler(this, curFillArgs);
                        continue;
                    }

                    //so this is a path.. need to call for all the items.
                    ReportFillParameterEventArgs curPathFillArgs = curFillArgs.FirstChild;

                    bool atDataPosition = false;

                    ReportFillParameterEventArgs lastPathFillArgs = null;
                    //First get to the correct data position
                    while (curPathFillArgs != null && atDataPosition == false)
                    {
                        switch (curPathFillArgs.PathType)
                        {
                        case PathType.SelectedItem:
                        case PathType.SelectedFolder:
                        case PathType.FolderParent:
                        case PathType.FolderRoot:
                        {
                            lastPathFillArgs = curPathFillArgs;
                            sendArgs.curItem.FillParameterHandler(this, curPathFillArgs);
                            curPathFillArgs = curPathFillArgs.FirstChild;
                            break;
                        }

                        default:
                            atDataPosition = true;
                            break;
                        }
                    }

                    //the data to get is not defined so the dataPosition defines the data
                    if (atDataPosition == false)
                    {
                        if (lastPathFillArgs.Values != null)
                        {
                            curFillArgs.Values.AddRange(lastPathFillArgs.Values);
                        }

                        continue;
                    }

                    //now try to get the data
                    foreach (ReportFillParameterEventArgs dataPathFillArgs in lastPathFillArgs.Children)
                    {
                        switch (dataPathFillArgs.PathType)
                        {
                        case PathType.CursorFolder:
                        case PathType.CursorChildFolders:
                        case PathType.CursorItems:
                        {
                            sendArgs.curItem.FillParameterHandler(this, dataPathFillArgs);
                            if (dataPathFillArgs.Values != null)
                            {
                                curFillArgs.Values.AddRange(dataPathFillArgs.Values);
                            }

                            break;
                        }

                        case PathType.CursorDescendantFolders:
                        case PathType.CursorDescendantItems:
                        {
                            //RM could do both DescendantFolders and DescendantItems at the same
                            //time, but guessing that only one will be used in any path

                            break;
                        }
                        }
                    }
                }//end foreach(fillParameterArgsList)
            }


            sendArgs.Validated = sendArgs.report.ValidateParameters(sendArgs.parameterNamesToValueMap);
        }
Example #5
0
        /// <summary>
        /// fill in the Report Parameters. Will fill in the path information.
        /// At this point the path information is mostly blotter based. Assuming that
        /// the tree are blotters. This can be changed to be entity based, but some
        /// keys/relations are missing to make the entity lookup efficient
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="defaultId">defualt Id to be used if cannot find match</param>
        /// <param name="dataRow">dataRow that is the current item row</param>
        /// <param name="reportFillParamsArgs">args to be filled in</param>
        public void ReportFillParams(object sender, Guid defaultId, System.Data.DataRow dataRow, ReportFillParameterEventArgs reportFillParamsArgs)
        {
            //trying to keep this generic, but for now folders are == blotters

            switch (reportFillParamsArgs.PathType)
            {
            case PathType.FolderRoot:    //Position cursor to the root folder
            {
                //walk up parents until the parent is null
                BlotterRow blotterRow = null;
                if (reportFillParamsArgs.ParentValues != null &&
                    reportFillParamsArgs.ParentValues.Count > 0)
                {
                    blotterRow = reportFillParamsArgs.ParentValues[0].UserObject as BlotterRow;
                }

                if (blotterRow == null)
                {
                    blotterRow = DataModel.Blotter.Rows.Find(defaultId) as BlotterRow;
                }
                ;

                BlotterRow nextBlotterRow = blotterRow;
                while (nextBlotterRow != null)
                {
                    nextBlotterRow = GetBlotterFolderParent(reportFillParamsArgs.ParentValues, defaultId);

                    if (nextBlotterRow == null || nextBlotterRow == blotterRow)
                    {
                        break;
                    }

                    blotterRow = nextBlotterRow;
                }

                //found the root
                if (blotterRow != null)
                {
                    reportFillParamsArgs.AddValue(new ReportParameterValue(blotterRow.BlotterId, blotterRow));
                }

                break;
            }

            case PathType.FolderParent:
            {
                //position cursor to the parent folder of the current location
                BlotterRow blotterRow = GetBlotterFolderParent(reportFillParamsArgs.ParentValues, defaultId);

                if (blotterRow != null)
                {
                    reportFillParamsArgs.AddValue(new ReportParameterValue(blotterRow.BlotterId, blotterRow));
                }

                break;
            }

            case PathType.SelectedItem:
            {
                //position cursor to selectedItem. will use the
                //PK of that dataRow to define the value of the selected item
                if (dataRow != null &&
                    dataRow.Table.PrimaryKey != null &&
                    dataRow.Table.PrimaryKey.Length == 1)
                {
                    reportFillParamsArgs.AddValue(new ReportParameterValue(dataRow[dataRow.Table.PrimaryKey[0]], null));
                }
                else
                {
                    System.Data.DataRow blotterRow = DataModel.Blotter.Rows.Find(defaultId);
                    reportFillParamsArgs.AddValue(new ReportParameterValue(defaultId, blotterRow));
                }
                break;
            }

            case PathType.SelectedFolder:
            {
                //position cursor to the Folder of the selected item
                System.Data.DataRow blotterRow = DataModel.Blotter.Rows.Find(defaultId);
                reportFillParamsArgs.AddValue(new ReportParameterValue(defaultId, blotterRow));

                break;
            }

            case PathType.CursorFolder:
            {
                //return the Folder that the cursor is at
                if (reportFillParamsArgs.ParentValues != null &&
                    reportFillParamsArgs.ParentValues.Count != 0)
                {
                    reportFillParamsArgs.AddValue(reportFillParamsArgs.ParentValues[0]);
                }

                break;
            }

            case PathType.CursorChildFolders:
            {
                //return the child folders under the cursor position
                GetBlotterFolderChildren(defaultId, reportFillParamsArgs);
                break;
            }
            }
        }