Inheritance: Seal.Model.ReportComponent, ITreeSort
Ejemplo n.º 1
0
        /// <summary>
        /// Retrun the list of navigation links in the View context
        /// </summary>
        public List <NavigationLink> GetNavigationLinks(ReportView view)
        {
            var result = new List <NavigationLink>();

            foreach (var link in Links)
            {
                if (link.Type == NavigationType.Drill && !view.IsDrillEnabled)
                {
                    continue;
                }
                if (link.Type == NavigationType.SubReport && !view.IsSubReportsEnabled)
                {
                    continue;
                }

                var newLink = new NavigationLink()
                {
                    Cell = link.Cell, Href = link.Href, Parameters = link.Parameters, Report = link.Report, Tag = link.Tag, Text = link.Text, Type = link.Type
                };
                Helper.CopyProperties(link, newLink);
                if (newLink.Type == NavigationType.Drill)
                {
                    //Add the navigation if exists
                    var modelView      = view.ModelView;
                    var navigationView = modelView.GetValue(Parameter.NavigationView);
                    if (!string.IsNullOrEmpty(navigationView))
                    {
                        newLink.Href += string.Format("&view={0}", modelView.GetValue(Parameter.NavigationView));
                    }
                }
                result.Add(newLink);
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static ReportView Create(ReportViewTemplate template)
        {
            ReportView result = new ReportView()
            {
                GUID = Guid.NewGuid().ToString(), TemplateName = template.Name
            };

            return(result);
        }
Ejemplo n.º 3
0
        void changeElementGUID(ReportElement element, string newGUID, ReportView view)
        {
            string initialLabel = element.DisplayNameEl;

            element.ChangeColumnGUID(newGUID);
            view.ReplaceInParameterValues("nvd3_chart_title", "%" + initialLabel + "%", "%" + element.DisplayNameEl + "%");
            view.ReplaceInParameterValues("chartjs_title", "%" + initialLabel + "%", "%" + element.DisplayNameEl + "%");
            view.ReplaceInParameterValues("plotly_title", "%" + initialLabel + "%", "%" + element.DisplayNameEl + "%");
        }
Ejemplo n.º 4
0
 public void InitTemplates(ReportView view, ref string errors)
 {
     view.InitParameters(false);
     if (!string.IsNullOrEmpty(view.Error))
     {
         errors += string.Format("Error in view template '{0}': {1}\r\n", view.Name, view.Error);
     }
     foreach (var child in view.Views)
     {
         InitTemplates(child, ref errors);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// True if the column has cells with navigation links
 /// </summary>
 public bool HasNavigation(ReportView view, int sourceRow, int col)
 {
     if (sourceRow == BodyStartRow - 1)
     {
         for (int row = BodyStartRow; row < BodyEndRow && col < ColumnCount; row++)
         {
             if (this[row, col].GetNavigationLinks(view).Count > 0)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 6
0
 void setContext(ITypeDescriptorContext context)
 {
     _metaConnection = context.Instance as MetaConnection;
     _metaEnum = context.Instance as MetaEnum;
     _metaTable = context.Instance as MetaTable;
     _metaColumn = context.Instance as MetaColumn;
     _metaJoin = context.Instance as MetaJoin;
     _reportView = context.Instance as ReportView;
     _reportOutput = context.Instance as ReportOutput;
     _reportSchedule = context.Instance as ReportSchedule;
     _parameter = context.Instance as Parameter;
     _security = context.Instance as SealSecurity;
     _emailDevice = context.Instance as OutputEmailDevice;
 }
Ejemplo n.º 7
0
        public bool IsAncestorOf(ReportView view)
        {
            bool result = false;

            foreach (ReportView child in Views)
            {
                if (child == view)
                {
                    return(true);
                }
                result = child.IsAncestorOf(view);
                if (result)
                {
                    break;
                }
            }
            return(result);
        }
Ejemplo n.º 8
0
        public ReportView GetView(string viewId)
        {
            if (ViewId == viewId)
            {
                return(this);
            }

            ReportView result = null;

            foreach (var view in Views)
            {
                if (view.ViewId == viewId)
                {
                    return(view);
                }
                result = view.GetView(viewId);
                if (result != null)
                {
                    break;
                }
            }
            return(result);
        }
Ejemplo n.º 9
0
        public static void PreLoadTemplates()
        {
            lock (_viewLock)
            {
                var templates = ViewTemplates;
                foreach (var template in templates)
                {
                    if (!template.IsParsed)
                    {
                        template.ParseConfiguration();
                    }
                    RazorHelper.Compile(template.Text, typeof(Report), template.CompilationKey);

                    //Create a view to compile partial templates
                    ReportView view = ReportView.Create(template);
                    view.InitPartialTemplates();
                    foreach (var partialTemplate in view.PartialTemplates)
                    {
                        view.GetPartialTemplateKey(partialTemplate.Name, view);
                    }
                }
            }
        }
Ejemplo n.º 10
0
 void initTreeNodeViews(TreeNode node, ReportView view)
 {
     foreach (var childView in view.Views)
     {
         TreeNode childNode = new TreeNode(childView.Name);
         childNode.Tag = childView;
         node.Nodes.Add(childNode);
         initTreeNodeViews(childNode, childView);
     }
 }
Ejemplo n.º 11
0
 public virtual void SetConfigurations(List <string> configurations, ReportView view)
 {
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Function to return partial table data to the report result
        /// </summary>
        public string GetLoadTableData(ReportView view, string parameter)
        {
            var model      = view.ModelView.Model;
            var parameters = parameter.Replace("&lt;", "<").Replace("&gt;", ">").Split('§');

            int    echo = 1, len = 50, start = 0;
            string sort = "", search = "";

            try
            {
                if (parameters.Length != 5)
                {
                    throw new Exception("Invalid parameter size");
                }
                echo   = int.Parse(parameters[0]);
                sort   = parameters[1];
                search = parameters[2];
                len    = int.Parse(parameters[3]);
                start  = int.Parse(parameters[4]);
            }
            catch (Exception ex)
            {
                Helper.WriteLogEntry("Seal Get Table Data", EventLogEntryType.Error, string.Format("GetLoadTableData-> Error in parameter:{0}\r\n{1}", parameter, ex.Message));
                echo = 1; len = 50; start = 0;
                sort = ""; search = "";
            }
            var sb = new StringBuilder();

            sb.Append("\"aaData\": [");

            //Check filter first
            if (search != _lastSearch || _filteredLines == null)
            {
                start          = 0;
                _filteredLines = new List <ResultCell[]>();
                var search2 = search.ToLower();
                for (int row = BodyStartRow; row < BodyEndRow; row++)
                {
                    ResultCell[] line     = Lines[row];
                    bool         filtered = false;
                    if (string.IsNullOrEmpty(search))
                    {
                        filtered = true;
                    }
                    else
                    {
                        for (int col = 0; col < line.Length && !filtered; col++)
                        {
                            ResultCell cell      = line[col];
                            var        cellValue = cell.HTMLValue;
                            if (!string.IsNullOrEmpty(search) && HttpUtility.HtmlDecode(cellValue).ToLower().Contains(search2))
                            {
                                filtered = true;
                                break;
                            }
                        }
                    }
                    if (filtered)
                    {
                        _filteredLines.Add(line);
                    }
                }
            }
            _lastSearch = search;

            //handle sort
            if (!string.IsNullOrEmpty(sort) && sort.Contains(",") && _filteredLines.Count > 0)
            {
                var sortIndex = int.Parse(sort.Split(',')[0]);
                var refLine   = Lines[BodyStartRow];

                //Handle hidden columns
                for (int col = 0; col < refLine.Length; col++)
                {
                    if (col <= sortIndex && (view.IsColumnHidden(col) || IsColumnHidden(col)))
                    {
                        sortIndex++;
                    }
                }


                if (sortIndex < refLine.Length)
                {
                    //clear other sort
                    foreach (var element in model.Elements)
                    {
                        element.FinalSortOrder = "";
                    }
                    //set sort to the column, find the related element...
                    foreach (var line in _filteredLines)
                    {
                        ResultCell cell = line[sortIndex];
                        if (cell.Element != null)
                        {
                            var ascdesc = (sort.ToLower().Contains("asc") ? ReportElement.kAscendantSortKeyword : ReportElement.kDescendantSortKeyword);
                            cell.Element.FinalSortOrder = sortIndex + " " + ascdesc;
                            break;
                        }
                    }
                }
                if (ResultCell.ShouldSort(_filteredLines))
                {
                    _filteredLines.Sort(ResultCell.CompareCellsForTableLoad);
                }
            }

            //build the json result
            if (len == -1)
            {
                start = 0;
                len   = _filteredLines.Count;
            }

            var rowBodyClass = view.GetValue("data_table_body_class");
            var rowBodyStyle = view.GetValue("data_table_body_css");
            var rowSubClass  = view.GetValue("data_table_subtotal_class");
            var rowSubStyle  = view.GetValue("data_table_subtotal_css");

            for (int row = start; row < _filteredLines.Count && row < start + len; row++)
            {
                ResultCell[] line = _filteredLines[row];
                if (row != start)
                {
                    sb.Append(",");
                }
                sb.Append("[");
                for (int col = 0; col < line.Length; col++)
                {
                    if (view.IsColumnHidden(col) || IsColumnHidden(col))
                    {
                        continue;
                    }
                    ResultCell cell      = line[col];
                    var        cellValue = cell.HTMLValue;
                    var        fullValue = HttpUtility.JavaScriptStringEncode(string.Format("{0}§{1}§{2}§{3}§{4}§{5}", cell.IsSubTotal ? rowSubStyle : rowBodyStyle, cell.IsSubTotal ? rowSubClass : rowBodyClass, model.GetNavigation(cell, true), cell.CellCssStyle, cell.CellCssClass, cellValue));
                    sb.AppendFormat("\"{0}\",", fullValue);
                }
                sb.Length = sb.Length - 1;
                sb.Append("]");
            }
            sb.Append("]}");

            var sbFinal = new StringBuilder();

            sbFinal.Append(@"{" + "\"sEcho\": " + echo.ToString() + ",");
            sbFinal.Append("\"recordsTotal\": " + _filteredLines.Count.ToString() + ",");
            sbFinal.Append("\"recordsFiltered\": " + _filteredLines.Count.ToString() + ",");
            sbFinal.Append("\"iTotalRecords\": " + (BodyEndRow - BodyStartRow).ToString() + ",");
            sbFinal.Append("\"iTotalDisplayRecords\": " + _filteredLines.Count.ToString() + ",");
            sbFinal.Append(sb);

            return(sbFinal.ToString());
        }
Ejemplo n.º 13
0
        public ReportView AddChildView(ReportView parent, ReportViewTemplate template)
        {
            if (Models.Count == 0) throw new Exception("Unable to create a view: No model available.\r\nPlease create a model first.");

            ReportView result = ReportView.Create(template);
            result.Name = Helper.GetUniqueName(template.Name + " View", (from i in parent.Views select i.Name).ToList());
            result.Report = this;
            result.InitReferences();
            result.SortOrder = parent.Views.Count > 0 ? parent.Views.Max(i => i.SortOrder) + 1 : 1;
            if (template.ForModel) result.ModelGUID = Models[0].GUID;
            parent.Views.Add(result);
            return result;
        }
Ejemplo n.º 14
0
 public virtual void InitFromReferenceView(ReportView referenceView)
 {
 }
Ejemplo n.º 15
0
 void checkRemoveModel(ReportView view, ReportModel model)
 {
     foreach (var childView in view.Views)
     {
         if (view.Views.Exists(i => i.ModelGUID == model.GUID)) throw new Exception(string.Format("The model '{0}' is already used by a view.", model.Name));
         checkRemoveModel(childView, model);
     }
 }
Ejemplo n.º 16
0
 void GetModelsToExecute(ReportView view, List<ReportModel> result)
 {
     if (view.Model != null && !result.Contains(view.Model)) result.Add(view.Model);
     foreach (var child in view.Views) GetModelsToExecute(child, result);
 }
Ejemplo n.º 17
0
 public virtual void SetConfigurations(List<string> configurations, ReportView view)
 {
 }
Ejemplo n.º 18
0
        public void RemoveView(ReportView parent, ReportView view)
        {
            if (parent == null)
            {
                foreach (ReportOutput output in Outputs)
                {
                    if (output.ViewGUID == view.GUID) throw new Exception(string.Format("Unable to remove the view '{0}': This view is used by the output '{1}'.", view.Name, output.Name));
                }

                if (Views.Count == 1) throw new Exception("Unable to remove the view: The report must contain at least one View.");
                Views.Remove(view);
                //Change the default view if necessary
                if (view.GUID == ViewGUID) ViewGUID = Views[0].GUID;
            }
            else parent.Views.Remove(view);
        }
Ejemplo n.º 19
0
 void initTreeNodeViews(TreeNode node, ReportView view)
 {
     if (view != null)
     {
         foreach (var childView in view.Views)
         {
             TreeNode childNode = new TreeNode(childView.Name) { ImageIndex = 8, SelectedImageIndex = 8 };
             childNode.Tag = childView;
             node.Nodes.Add(childNode);
             initTreeNodeViews(childNode, childView);
         }
     }
 }
Ejemplo n.º 20
0
        static void getWidgets(List <DashboardWidget> widgets, Dictionary <string, DateTime> reports, ReportView view, Repository repository)
        {
            _widgets.RemoveAll(i => i.GUID == view.WidgetDefinition.GUID);

            if (!string.IsNullOrEmpty(view.WidgetDefinition.Name))
            {
                view.WidgetDefinition.ReportPath       = view.Report.FilePath.Replace(repository.ReportsFolder, "");
                view.WidgetDefinition.ReportName       = view.Report.DisplayNameEx;
                view.WidgetDefinition.LastModification = view.Report.LastModification;
                if (string.IsNullOrEmpty(view.WidgetDefinition.Description))
                {
                    view.WidgetDefinition.Description = "";
                }
                widgets.Add(view.WidgetDefinition);
            }

            foreach (ReportView child in view.Views)
            {
                getWidgets(widgets, reports, child, repository);
            }
        }
Ejemplo n.º 21
0
 void addViewsToDestinations(ReportView parentView, string prefix)
 {
     string name = string.Format("{0}/{1}", prefix, parentView.Name);
     if (_destinationItems.FirstOrDefault(i => i.Object == parentView) == null)
     {
         if (parentView != _source)
         {
             if (!addRadioButton.Checked || ((ReportView)_source).Template.ParentNames.Contains(parentView.Template.Name))
             {
                 _destinationItems.Add(new PropertyItem() { Name = name, Object = parentView });
             }
         }
         foreach (var view in parentView.Views) addViewsToDestinations(view, name);
     }
 }
Ejemplo n.º 22
0
 public void InitTemplates(ReportView view, ref string errors)
 {
     view.InitParameters(false);
     if (!string.IsNullOrEmpty(view.Error)) errors += string.Format("Error in view template '{0}': {1}\r\n", view.Name, view.Error);
     foreach (var child in view.Views) InitTemplates(child, ref errors);
 }
Ejemplo n.º 23
0
 void exportViewsTranslations(ExecutionLogInterface log, ReportView view, Repository repository, StringBuilder translations, string reportPath, string separator, string extraSeparators, int len)
 {
     translations.AppendFormat("ReportViewName{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(reportPath.Substring(len)), Helper.QuoteDouble(view.Name), extraSeparators);
     foreach (var child in view.Views)
     {
         exportViewsTranslations(log, child, repository, translations, reportPath, separator, extraSeparators, len);
     }
 }
Ejemplo n.º 24
0
 public static ReportView Create(ReportViewTemplate template)
 {
     ReportView result = new ReportView() { GUID = Guid.NewGuid().ToString(), TemplateName = template.Name };
     return result;
 }
Ejemplo n.º 25
0
 public bool IsAncestorOf(ReportView view)
 {
     bool result = false;
     foreach (ReportView child in Views)
     {
         if (child == view) return true;
         result = child.IsAncestorOf(view);
         if (result) break;
     }
     return result;
 }