Example #1
0
        /// <summary>
        /// Sets the column mapping for this commands data table columns to attributes
        /// based on the comma separated list of names (or the catch all *)
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="attributenames"></param>
        /// <param name="context"></param>
        protected virtual void ApplyAttributes(DataSet ds, string attributenames, PDFDataContext context)
        {
            DataTable dt = ds.Tables[this.GetDataTableName(ds)];

            if (attributenames == "*")
            {
                foreach (DataColumn dc in dt.Columns)
                {
                    dc.ColumnMapping = MappingType.Attribute;
                }
            }
            else
            {
                string[] all = attributenames.Split(',');
                foreach (string name in all)
                {
                    DataColumn dc;
                    if (dt.Columns.Contains(name.Trim()))
                    {
                        dc = dt.Columns[name.Trim()];
                        dc.ColumnMapping = MappingType.Attribute;
                    }
                    else
                    {
                        context.TraceLog.Add(TraceLevel.Warning, "Data Table provider command", "The data column '" + name + "could not be found, so cannot be set as a mapping type of Attribute");
                    }
                }
            }
        }
        private void BindActionedComponents(BindingActionList actions, PDFDataContext context)
        {
            if (context.TraceLog.ShouldLog(TraceLevel.Debug))
            {
                context.TraceLog.Begin(TraceLevel.Debug, "PDFWithFieldSet", "Starting to bind " + actions.Count.ToString() + "components with their respective data items");
            }

            var lastIndex = context.CurrentIndex;
            var index     = 0;

            foreach (BindingAction action in actions)
            {
                context.CurrentIndex = index;
                context.DataStack.Push(action.Data, action.Source);
                action.Component.DataBind(context);

                context.DataStack.Pop();
                index++;
            }

            if (context.TraceLog.ShouldLog(TraceLevel.Debug))
            {
                context.TraceLog.End(TraceLevel.Debug, "PDFWithFieldSet", "Completed bound " + actions.Count.ToString() + "components with their respective data items");
            }
        }
        protected override void DoDataBind(PDFDataContext context, bool includechildren)
        {
            base.DoDataBind(context, includechildren);

            var doc = context.Document;

            if (null != doc && null != this.Source && null != this.FontFamily)
            {
                PDFFontDefinition definition;

                if (this.TryGetFont(doc, context, out definition))
                {
                    string name = PDFFont.GetFullName(this.FontFamily.FamilyName, this.FontBold, this.FontItalic);
                    //PDFFontResource resource = PDFFontResource.Load(definition, name);

                    doc.EnsureResource(PDFFontResource.FontDefnResourceType, name, definition);
                }
                else
                {
                    context.TraceLog.Add(TraceLevel.Warning, "CSS", "The font for " + this.Source.ToString() + " with name " + this.FontFamily + " could not be loaded");
                }
            }
            else
            {
                context.TraceLog.Add(TraceLevel.Warning, "CSS", "No font-family or src was specified for the @font-face rule.");
            }
        }
 protected virtual void OnDataBound(PDFDataContext context)
 {
     if (null != this.DataBound)
     {
         this.DataBound(this, new PDFDataBindEventArgs(context));
     }
 }
Example #5
0
        protected override void DoDataBind(PDFDataContext context, bool includeChildren)
        {
            base.DoDataBind(context, includeChildren);


            if (null != _literal)
            {
                this.Contents.Remove(_literal);
            }

            object data = GetRequiredData(context);

            if (null == data)
            {
                return;
            }

            _literal = new Components.TextLiteral();

            var format = Newtonsoft.Json.Formatting.Indented;

            _literal.Text = Newtonsoft.Json.JsonConvert.SerializeObject(data, format);



            this.Contents.Add(_literal);
        }
 protected override object DoGetMyValue(object parent, PDFDataContext context)
 {
     System.Reflection.PropertyInfo pi = parent.GetType().GetProperty("Item", new Type[] { typeof(string) });
     if (null != pi)
     {
         return(pi.GetValue(parent, new object[] { KeyValue }));
     }
     else if (parent is IDictionary <string, object> )
     {
         object found;
         IDictionary <string, object> dict = parent as IDictionary <string, object>;
         if (dict.TryGetValue(KeyValue, out found))
         {
             return(found);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         throw new ArgumentOutOfRangeException("Item[string]", "Object does not support indexing with a string value or the the dictionary<string,object> interface");
     }
 }
Example #7
0
        /// <summary>
        /// Override method that performs the actual property setting from a boolean result.
        /// </summary>
        /// <param name="component"></param>
        /// <param name="data"></param>
        /// <param name="context"></param>
        protected override void DoBindComponent(object component, object data, PDFDataContext context)
        {
            System.Xml.XPath.XPathExpression   expr = this.GetExpression(data, context);
            System.Xml.XPath.XPathNavigator    nav;
            System.Xml.XPath.XPathNodeIterator itter;

            if (data is System.Xml.XPath.XPathNodeIterator)
            {
                itter = ((System.Xml.XPath.XPathNodeIterator)data);
                nav   = itter.Current;
            }
            else
            {
                nav   = (System.Xml.XPath.XPathNavigator)data;
                itter = context.DataStack.HasData ? context.DataStack.Current as System.Xml.XPath.XPathNodeIterator : null;
            }

            bool value = (bool)nav.Evaluate(expr, itter);

            if (context.ShouldLogVerbose)
            {
                context.TraceLog.Add(TraceLevel.Verbose, "Item Binding", "Setting property '" + this.Property.Name + "' with the XPath binding expression '" + expr.Expression + "' to value '" + value + "'");
            }

            this.Property.SetValue(component, value, null);
        }
Example #8
0
        /// <summary>
        /// Takes all the binding actions (data and component pairs)
        /// and then calls DataBind on each of them in turn using the current data context stack
        /// and the data in the binding action.
        /// </summary>
        /// <param name="actions"></param>
        private void BindActionedComponents(List <BindingActionList> actions, PDFDataContext context)
        {
            if (context.TraceLog.ShouldLog(TraceLevel.Debug))
            {
                context.TraceLog.Begin(TraceLevel.Debug, "DataGrid", "Starting to bind " + actions.Count.ToString() + "components with their respective data items");
            }
            int lastindex = context.CurrentIndex;
            int currIndex = 0;

            foreach (BindingActionList list in actions)
            {
                context.CurrentIndex = currIndex;

                foreach (BindingAction action in list)
                {
                    context.DataStack.Push(action.Data, action.Source);
                    action.Component.DataBind(context);

                    this.OnItemDataBound(context, (IPDFComponent)action.Component);

                    context.DataStack.Pop();
                }

                currIndex++;
            }

            if (context.TraceLog.ShouldLog(TraceLevel.Debug))
            {
                context.TraceLog.End(TraceLevel.Debug, "DataGrid", "Completed bound " + actions.Count.ToString() + "components with their respective data items");
            }

            context.CurrentIndex = lastindex;
        }
 /// <summary>
 /// Inheritors should override this method to provide their own data binding implementations
 /// </summary>
 /// <param name="includeChildren"></param>
 protected virtual void DoDataBind(PDFDataContext context, bool includeChildren)
 {
     if (this._outline != null)
     {
         this.Outline.DataBind(context);
     }
 }
        public virtual object GetParameterValue(IPDFDataSetProviderCommand command, PDFDataContext context)
        {
            string value = this.Value;

            if (string.IsNullOrEmpty(value))
            {
                value = this.DefaultValue;
            }

            if (String.IsNullOrEmpty(value))
            {
                //Special case where the data type is textual, and we are not null.
                if (this.IsStringDataType && null != value)
                {
                    return(String.Empty);
                }
                else
                {
                    return(command.GetNullValue(this.DataType));
                }
            }
            else
            {
                object parsed = TypeConverter.GetNativeValue(this.DataType, value);
                return(parsed);
            }
        }
Example #11
0
 protected override void DoDataBindToContainer(PDFDataContext context, IPDFContainerComponent container)
 {
     if (this.Test && this.Visible)
     {
         base.DoDataBindToContainer(context, container);
     }
 }
        public void DataBind(PDFDataContext context)
        {
            PDFDataBindEventArgs args = new PDFDataBindEventArgs(context);

            this.OnDataBinding(args);
            this.OnDataBound(args);
        }
        protected override object DoEvaluateExpression(string expr, object withData, PDFDataContext context)
        {
            System.Xml.XPath.XPathNavigator nav;
            if (withData is System.Xml.XPath.XPathNavigator)
            {
                nav = withData as System.Xml.XPath.XPathNavigator;
            }
            else
            {
                throw new NotSupportedException("The XmlDataSource can only perfrom select operations on XPathNavigator data.");
            }

            object value = nav.Evaluate(expr, context.NamespaceResolver);

            if (value is XPathNodeIterator)
            {
                XPathNodeIterator itter = value as XPathNodeIterator;
                if (itter.MoveNext())
                {
                    value = itter.Current.Value;
                }
                else
                {
                    value = null;
                }
            }
            return(value);
        }
 /// <summary>
 /// Databinds all the children in the container
 /// </summary>
 protected virtual void DoDataBindChildren(PDFDataContext context)
 {
     if (this.HasContent)
     {
         this.InnerContent.DataBind(context);
     }
 }
 protected virtual void OnDataBinding(PDFDataContext context)
 {
     if (this.DataBinding != null)
     {
         this.DataBinding(this, new PDFDataBindEventArgs(context));
     }
 }
Example #16
0
        private void RemoveHeadersAndFooters(TableGrid grid, PDFDataContext context)
        {
            bool hasHeaders = false;
            bool hasFooters = false;

            for (int i = 0; i < this.Columns.Count; i++)
            {
                if (this.Columns[i].HasHeader)
                {
                    hasHeaders = true;
                }
                if (this.Columns[i].HasFooter)
                {
                    hasFooters = true;
                }

                if (hasHeaders && hasFooters)
                {
                    break;
                }
            }

            if (hasHeaders == false && grid.Rows.Count > 0)
            {
                grid.Rows.RemoveAt(0);
            }
        }
Example #17
0
        protected override IPDFTemplate GetTemplateForBinding(PDFDataContext context, int index, int count)
        {
            //If we are not visible then don't do anything and return null

            if (this.Visible == false)
            {
                return(null);
            }

            IPDFTemplate tempate = null;
            bool         found   = false;

            foreach (ChooseWhen where in this.Whens)
            {
                if (where.EvaluateTest(context))
                {
                    if (where.Template != null)
                    {
                        tempate = where.Template;
                    }
                    found = true;
                    break;
                }
            }
            //If we have a template and should be binding on it
            if (!found && this.Otherwise != null && this.Otherwise.Template != null)
            {
                tempate = Otherwise.Template;
            }

            return(tempate);
        }
Example #18
0
        /// <summary>
        /// Sets up the context with any required data
        /// </summary>
        /// <param name="context">The context to set up</param>
        /// <returns>True if new data was added to the context</returns>
        protected virtual bool DoSetupWithData(PDFDataContext context)
        {
            bool hasdata = false;

            lastResolver = context.NamespaceResolver;
            IPDFDataSource datasource;
            object         data = null;

            //Get the datasource
            if (null != this.Value)
            {
                data       = this.Value;
                datasource = context.DataStack.HasData ? context.DataStack.Source : null;
                hasdata    = true;
            }
            else if (this.HasAssignedDataSourceComponent(context, out datasource))
            {
                data = datasource.Select(this.SelectPath, context);
                if (null == data)
                {
                    context.TraceLog.Add(TraceLevel.Warning, "Data With", string.Format("NULL data was returned for the path '{0}' on the PDFWith component {1} with datasource {2}", this.SelectPath, this.ID, datasource.ID));
                }
                hasdata = true;
            }
            else if (string.IsNullOrEmpty(this.SelectPath) == false)
            {
                datasource = context.DataStack.Source;
                data       = datasource.Select(this.SelectPath, context.DataStack.Current, context);
                if (null == data)
                {
                    context.TraceLog.Add(TraceLevel.Warning, "Data For Each", string.Format("NULL data was returned for the path '{0}' on the PDFForEach component {1} with data source {2}", this.SelectPath, this.ID, datasource.ID));
                }
                hasdata = true;
            }
            else if (!context.DataStack.HasData)
            {
                context.TraceLog.Add(TraceLevel.Warning, "Data With", string.Format("There is no current data for the PDFWith component {0}", this.ID));
            }
            else
            {
                data       = context.DataStack.Current;
                datasource = context.DataStack.Source;
            }

            if (hasdata)
            {
                data = GetCurrentOrFirstItem(data);
                if (null == data)
                {
                    hasdata = false;
                }
                else
                {
                    context.DataStack.Push(data, datasource);
                }
            }

            return(hasdata);
        }
 private PDFLoadContext GetLoadContext(PDFDataContext dataContext)
 {
     if (null == _loadContext)
     {
         _loadContext = new PDFLoadContext(dataContext.Items, dataContext.TraceLog, dataContext.PerformanceMonitor, this.Document);
     }
     return(_loadContext);
 }
Example #20
0
 protected override void DoDataBind(PDFDataContext context, bool includechildren)
 {
     base.DoDataBind(context, includechildren);
     if (includechildren)
     {
         this.Styles.DataBind(context);
     }
 }
Example #21
0
        /// <summary>
        /// Overrides the base implementation to restore the items collection to it's original value
        /// </summary>
        /// <param name="e"></param>
        protected override void OnDataBound(PDFDataContext context)
        {
            base.OnDataBound(context);

            if (null != this.OriginalItems)
            {
                context.Items = this.OriginalItems;
            }
        }
        protected override void OnDataBound(PDFDataContext context)
        {
            base.OnDataBound(context);

            if (null != _orgitems)
            {
                context.Items = _orgitems;
            }
        }
Example #23
0
        protected override void DoDataBindChildren(PDFDataContext context)
        {
            bool setup = this.DoSetupWithData(context);

            base.DoDataBindChildren(context);
            this.DoBindDataIntoContainer(this, this.Contents.Count, context);

            this.DoTearDownWithData(setup, context);
        }
Example #24
0
        //
        // override methods
        //

        #region protected override void DoDataBind(PDFDataContext context)

        /// <summary>
        /// Extends the base implementation to ensure the parameters are also databound
        /// </summary>
        /// <param name="context"></param>
        protected override void DoDataBind(PDFDataContext context, bool includeChildren)
        {
            base.DoDataBind(context, includeChildren);

            if (this.HasParameters)
            {
                this.Parameters.DataBind(context);
            }
        }
Example #25
0
 protected override IPDFTemplate GetTemplateForBinding(PDFDataContext context, int index, int count)
 {
     if (this.Template is IPDFDataTemplateGenerator)
     {
         ((IPDFDataTemplateGenerator)this.Template).DataStyleStem          = this.DataStyleIdentifier;
         ((IPDFDataTemplateGenerator)this.Template).UseDataStyleIdentifier = this.CacheStyles;
     }
     return(this.Template);
 }
Example #26
0
 public virtual bool RemoveIfColumnHidden(PDFDataContext context)
 {
     if (this.AllInvisible)
     {
         this.HideEntireColumnAsAllInivisible();
         return(true);
     }
     return(false);
 }
Example #27
0
        /// <summary>
        /// Removes any data that was set up in the context.
        /// </summary>
        /// <param name="hasData"></param>
        /// <param name="context"></param>
        protected virtual void DoTearDownWithData(bool hasData, PDFDataContext context)
        {
            if (hasData)
            {
                context.DataStack.Pop();
            }

            context.NamespaceResolver = lastResolver;
        }
 public void DataBind(PDFDataContext context)
 {
     if (this.Count > 0)
     {
         foreach (DataRelation rel in this)
         {
             rel.DataBind(context);
         }
     }
 }
 public void DataBind(PDFDataContext context)
 {
     if (this.Count > 0)
     {
         foreach (ObjectParameter param in this)
         {
             param.DataBind(context);
         }
     }
 }
        //
        // methods
        //

        #region public void DataBind(PDFDataContext context)

        /// <summary>
        /// Supports the databinding capabilites of the parameter by raising the events
        /// </summary>
        /// <param name="context"></param>
        public virtual void DataBind(PDFDataContext context)
        {
            if (null != this.DataBinding || null != this.DataBound)
            {
                PDFDataBindEventArgs args = new PDFDataBindEventArgs(context);
                this.OnDataBinding(args);

                this.OnDataBound(args);
            }
        }