Ejemplo n.º 1
0
 private Image LoadImage()
 {
     try {
         Image  im;
         string absFileName = this.AbsoluteFileName;
         System.Diagnostics.Trace.WriteLine(String.Format("<CORE.LoadImage > {0}", absFileName));
         if (!String.IsNullOrEmpty(absFileName) && File.Exists(absFileName))
         {
             im = Image.FromFile(this.AbsoluteFileName);
         }
         else
         {
             im = BaseImageItem.ErrorBitmap(base.Size);
         }
         if (im == null)
         {
             string str = String.Format(CultureInfo.InvariantCulture,
                                        "Unable to Load {0}", imageFileName);
             throw new ReportException(str);
         }
         return(im);
     } catch (System.OutOfMemoryException) {
         throw;
     } catch (System.IO.FileNotFoundException) {
         throw;
     }
 }
Ejemplo n.º 2
0
        public static void Absolut2RelativePath(ReportModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            foreach (BaseSection section in model.SectionCollection)
            {
                foreach (BaseReportItem item in section.Items)
                {
                    BaseImageItem baseImageItem = item as BaseImageItem;
                    if (baseImageItem != null)
                    {
                        baseImageItem.ReportFileName = model.ReportSettings.FileName;

                        if (Path.IsPathRooted(baseImageItem.ImageFileName))
                        {
                            string d = FileUtility.GetRelativePath(
                                Path.GetDirectoryName(model.ReportSettings.FileName),
                                Path.GetDirectoryName(baseImageItem.ImageFileName));

                            baseImageItem.RelativeFileName = d + Path.DirectorySeparatorChar + Path.GetFileName(baseImageItem.ImageFileName);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public override void Fill(IDataItem item)
        {
            if (current != null)
            {
                BaseDataItem baseDataItem = item as BaseDataItem;
                if (baseDataItem != null)
                {
                    PropertyDescriptor p = this.listProperties.Find(baseDataItem.ColumnName, true);
                    if (p != null)
                    {
                        baseDataItem.DBValue = p.GetValue(this.Current).ToString();
                    }
                    else
                    {
                        baseDataItem.DBValue = string.Format(CultureInfo.InvariantCulture, "<{0}> missing!", baseDataItem.ColumnName);
                    }
                    return;
                }

                //image processing from IList
                BaseImageItem baseImageItem = item as BaseImageItem;

                if (baseImageItem != null)
                {
                    PropertyDescriptor p = this.listProperties.Find(baseImageItem.ColumnName, true);
                    if (p != null)
                    {
                        baseImageItem.Image = p.GetValue(this.Current) as System.Drawing.Image;
                    }
                    return;
                }
            }
        }
Ejemplo n.º 4
0
 public static void AdjustReportName(ReportModel model)
 {
     if (model == null)
     {
         throw new ArgumentNullException("model");
     }
     foreach (BaseSection section in model.SectionCollection)
     {
         foreach (BaseReportItem item in section.Items)
         {
             BaseImageItem baseImageItem = item as BaseImageItem;
             if (baseImageItem != null)
             {
                 baseImageItem.ReportFileName = model.ReportSettings.FileName;
             }
         }
     }
 }
Ejemplo n.º 5
0
        internal static ReportItemCollection DataItemsFromDataSet(DataSet dataSet)
        {
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }

            if (dataSet.Tables.Count > 1)
            {
                string s = String.Format(System.Globalization.CultureInfo.InvariantCulture,
                                         "AutoBuildFromDataSet : at this time no more than one table is allowed <{0}>", dataSet.Tables.Count);
                ICSharpCode.Core.MessageService.ShowError(s);
            }

            ReportItemCollection itemCol = new ReportItemCollection();

            foreach (DataTable tbl in dataSet.Tables)
            {
                foreach (DataColumn col  in tbl.Columns)
                {
                    if (col.DataType == typeof(System.Byte[]))
                    {
                        ICSharpCode.Reports.Core.BaseImageItem rItem = new ICSharpCode.Reports.Core.BaseImageItem();
                        rItem.ColumnName       = col.ColumnName;
                        rItem.BaseTableName    = tbl.TableName;
                        rItem.Name             = col.ColumnName;
                        rItem.ScaleImageToSize = false;
                        itemCol.Add(rItem);
                    }
                    else
                    {
                        ICSharpCode.Reports.Core.BaseDataItem rItem = new ICSharpCode.Reports.Core.BaseDataItem();
                        rItem.ColumnName    = col.ColumnName;
                        rItem.DBValue       = col.ColumnName;
                        rItem.BaseTableName = tbl.TableName;
                        rItem.DataType      = col.DataType.ToString();
                        rItem.Name          = col.ColumnName;
                        rItem.Text          = "=[" + col.ColumnName + "]";
                        itemCol.Add(rItem);
                    }
                }
            }
            return(itemCol);
        }
Ejemplo n.º 6
0
 public static void AdjustReportName(ReportModel model)
 {
     if (model == null)
     {
         throw new ArgumentNullException("model");
     }
     System.Diagnostics.Trace.WriteLine("");
     System.Diagnostics.Trace.WriteLine(String.Format("FilePathConverter:AdjustReportName {0}", model.ReportSettings.FileName));
     foreach (BaseSection section in model.SectionCollection)
     {
         foreach (BaseReportItem item in section.Items)
         {
             BaseImageItem baseImageItem = item as BaseImageItem;
             if (baseImageItem != null)
             {
                 baseImageItem.ReportFileName = model.ReportSettings.FileName;
             }
         }
     }
 }
Ejemplo n.º 7
0
		internal static ReportItemCollection ReportItemCollection (DataSet dataSet)
		{
			if (dataSet == null) {
				throw new ArgumentNullException("dataSet");
			}
		
			if (dataSet.Tables.Count > 1) {
				string s = String.Format(System.Globalization.CultureInfo.InvariantCulture,
				                         "AutoBuildFromDataSet : at this time no more than one table is allowed <{0}>",dataSet.Tables.Count);
				ICSharpCode.Core.MessageService.ShowError(s);
			}
			
			ReportItemCollection itemCol = new ReportItemCollection();
			
			foreach (DataTable tbl in dataSet.Tables) {
				foreach (DataColumn col  in tbl.Columns) {
					if (col.DataType == typeof(System.Byte[])) {
						ICSharpCode.Reports.Core.BaseImageItem rItem = new ICSharpCode.Reports.Core.BaseImageItem();
						rItem.ColumnName = col.ColumnName;
						rItem.BaseTableName = tbl.TableName;
						rItem.Name = col.ColumnName;
						rItem.ScaleImageToSize = false;
						itemCol.Add (rItem);
					} else {
						ICSharpCode.Reports.Core.BaseDataItem rItem = new ICSharpCode.Reports.Core.BaseDataItem();
						rItem.ColumnName = col.ColumnName;
						rItem.DBValue = col.ColumnName;
						rItem.BaseTableName = tbl.TableName;
						rItem.DataType = col.DataType.ToString();
						rItem.Name = col.ColumnName;
						rItem.Text = "=[" + col.ColumnName + "]";
						itemCol.Add (rItem);
					}
				}
			}
			return itemCol;
		}
Ejemplo n.º 8
0
        public override void Fill(IReportItem item)
        {
            base.Fill(item);

            DataRow row = this.Current as DataRow;

            if (row != null)
            {
                BaseDataItem baseDataItem = item as BaseDataItem;
                if (baseDataItem != null)
                {
                    baseDataItem.DBValue = row[baseDataItem.ColumnName].ToString();
                    return;
                }
                BaseImageItem bi = item as BaseImageItem;
                if (bi != null)
                {
                    using (System.IO.MemoryStream memStream = new System.IO.MemoryStream()){
                        Byte[] val = row[bi.ColumnName] as Byte[];
                        if (val != null)
                        {
                            if ((val[78] == 66) && (val[79] == 77))
                            {
                                memStream.Write(val, 78, val.Length - 78);
                            }
                            else
                            {
                                memStream.Write(val, 0, val.Length);
                            }
                            System.Drawing.Image image = System.Drawing.Image.FromStream(memStream);
                            bi.Image = image;
                        }
                    }
                }
            }
        }