|
@@ -389,388 +389,5 @@ namespace InABox.Wpf.Reports
|
|
|
{
|
|
|
PrintMenu(element, sectionName, model, allowdesign, populate);
|
|
|
}
|
|
|
-
|
|
|
- #region Old RDL Stuff (Deprecated)
|
|
|
-
|
|
|
- // private static ReportDefinition SetupReportDefinition(String rdl, Dictionary<System.Type, CoreTable> dataenvironment = null)
|
|
|
- // {
|
|
|
- // ReportDefinition report = null;
|
|
|
- // if (String.IsNullOrWhiteSpace(rdl))
|
|
|
- // report = CreateReport();
|
|
|
- // else
|
|
|
- // report = DeserialiseReport(rdl);
|
|
|
- //
|
|
|
- // if (dataenvironment != null)
|
|
|
- // SetupReportData(report, dataenvironment);
|
|
|
- // return report;
|
|
|
- // }
|
|
|
-
|
|
|
- // public static String SetupReport(String rdl, Dictionary<System.Type, CoreTable> dataenvironment = null)
|
|
|
- // {
|
|
|
- // var defn = SetupReportDefinition(rdl, dataenvironment);
|
|
|
- // return SerialiseReport(defn);
|
|
|
- // }
|
|
|
- //
|
|
|
- // public static MemoryStream SetupReportToStream(String rdl, Dictionary<System.Type, CoreTable> dataenvironment = null)
|
|
|
- // {
|
|
|
- // var defn = SetupReportDefinition(rdl, dataenvironment);
|
|
|
- // return SerialiseReportToStream(defn);
|
|
|
- // }
|
|
|
-
|
|
|
- // public static String CleanupReport(String rdl)
|
|
|
- // {
|
|
|
- // ReportDefinition report = null;
|
|
|
- // if (String.IsNullOrWhiteSpace(rdl))
|
|
|
- // report = CreateReport();
|
|
|
- // else
|
|
|
- // report = DeserialiseReport(rdl);
|
|
|
- //
|
|
|
- // CleanupReportData(report);
|
|
|
- //
|
|
|
- // return SerialiseReport(report);
|
|
|
- //
|
|
|
- // }
|
|
|
-
|
|
|
-// private static ReportDefinition CreateReport()
|
|
|
-// {
|
|
|
-// ReportDefinition rd = new ReportDefinition();
|
|
|
-// rd.DataSources = new DataSources();
|
|
|
-// rd.DataSets = new DataSets();
|
|
|
-//
|
|
|
-// rd.ReportSections = new ReportSections();
|
|
|
-// rd.ReportSections.Add(
|
|
|
-// new ReportSection()
|
|
|
-// {
|
|
|
-// Width = new Syncfusion.RDL.DOM.Size("7.5in"),
|
|
|
-// Body = new Body()
|
|
|
-// {
|
|
|
-// Style = new Syncfusion.RDL.DOM.Style() { BackgroundColor = "White", Border = new Syncfusion.RDL.DOM.Border() },
|
|
|
-// Height = new Syncfusion.RDL.DOM.Size("10in"),
|
|
|
-//
|
|
|
-// },
|
|
|
-// Page = new Syncfusion.RDL.DOM.Page()
|
|
|
-// {
|
|
|
-// PageHeight = new Syncfusion.RDL.DOM.Size("11in"),
|
|
|
-// PageWidth = new Syncfusion.RDL.DOM.Size("8.5in"),
|
|
|
-// Style = new Syncfusion.RDL.DOM.Style() { BackgroundColor = "White", Border = new Syncfusion.RDL.DOM.Border() },
|
|
|
-// }
|
|
|
-// }
|
|
|
-// );
|
|
|
-// rd.EmbeddedImages = new EmbeddedImages();
|
|
|
-//
|
|
|
-// rd.RDLType = RDLType.RDL2010;
|
|
|
-// rd.CodeModules = new CodeModules();
|
|
|
-// rd.CodeModules.Add(new CodeModule() { Value = "System.Drawing, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a" });
|
|
|
-// rd.CodeModules.Add(new CodeModule() { Value = "Syncfusion.Pdf.Base, Version = 13.3350.0.7, Culture = neutral, PublicKeyToken = 3d67ed1f87d44c89" });
|
|
|
-// rd.CodeModules.Add(new CodeModule() { Value = "Syncfusion.Linq.Base, Version = 13.3350.0.7, Culture = neutral, PublicKeyToken = 3d67ed1f87d44c89" });
|
|
|
-//
|
|
|
-// rd.Classes = new Classes();
|
|
|
-// rd.Classes.Add(new Class() { ClassName = "Syncfusion.Pdf.Barcode.PDFCode39Barcode", InstanceName = "Code39" });
|
|
|
-// rd.Classes.Add(new Class() { ClassName = "Syncfusion.Pdf.Barcode.PdfQRBarcode", InstanceName = "QRCode" });
|
|
|
-//
|
|
|
-// rd.Code = @"
|
|
|
-// Public Function Code39BarCode(Text As String) As String
|
|
|
-// Dim _msg as String
|
|
|
-// try
|
|
|
-// Code39.BarHeight = 100
|
|
|
-// Code39.Text = Text
|
|
|
-// Code39.EnableCheckDigit = True
|
|
|
-// Code39.EncodeStartStopSymbols = True
|
|
|
-// Code39.ShowCheckDigit = False
|
|
|
-// Code39.TextDisplayLocation = 0
|
|
|
-// Dim _img As System.Drawing.Image = Code39.ToImage()
|
|
|
-// Dim ms As New System.IO.MemoryStream()
|
|
|
-// _img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp)
|
|
|
-// Dim _bytes = ms.ToArray()
|
|
|
-// Return System.Convert.ToBase64String(_bytes, 0, _bytes.Length)
|
|
|
-// Catch ex As Exception
|
|
|
-// _msg = ex.toString()
|
|
|
-// End Try
|
|
|
-// return Nothing
|
|
|
-// End Function
|
|
|
-//
|
|
|
-// Public Function QRBarCode(Text As String) As String
|
|
|
-// Dim _msg as String
|
|
|
-// try
|
|
|
-// QRCode.Text = Text
|
|
|
-// QRCode.XDimension = 4
|
|
|
-// Dim _img As System.Drawing.Image = QRCode.ToImage()
|
|
|
-// Dim ms As New System.IO.MemoryStream()
|
|
|
-// _img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp)
|
|
|
-// Dim _bytes = ms.ToArray()
|
|
|
-// Return System.Convert.ToBase64String(_bytes, 0, _bytes.Length)
|
|
|
-// Catch ex As Exception
|
|
|
-// _msg = ex.toString()
|
|
|
-// End Try
|
|
|
-// return Nothing
|
|
|
-// End Function
|
|
|
-//
|
|
|
-// ";
|
|
|
-// return rd;
|
|
|
-//
|
|
|
-// //MemoryStream memoryStream = new MemoryStream();
|
|
|
-// //TextWriter ws2 = new StreamWriter(memoryStream);
|
|
|
-// //xs2.Serialize(ws2, rd, serialize);
|
|
|
-// //memoryStream.Position = 0;
|
|
|
-// ////To save to a file.
|
|
|
-// //StringWriter ws3 = new StringWriter
|
|
|
-// //TextWriter ws3 = new StreamWriter(_tempfile);
|
|
|
-// //xs2.Serialize(ws3, rd, serialize);
|
|
|
-// //ws2.Close();
|
|
|
-// //ws3.Close();
|
|
|
-// //memoryStream.Close();
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
- private static string DataTableToXML(Type type, CoreTable table)
|
|
|
- {
|
|
|
- var doc = new XmlDocument();
|
|
|
-
|
|
|
- var root = doc.CreateElement("", type.Name.ToLower() + "s", "");
|
|
|
- doc.AppendChild(root);
|
|
|
-
|
|
|
- //var properties = CoreUtils.PropertyList(type, x => true, true);
|
|
|
- if (table != null)
|
|
|
- {
|
|
|
- if (table.Rows.Any())
|
|
|
- {
|
|
|
- foreach (var datarow in table.Rows)
|
|
|
- {
|
|
|
- var row = doc.CreateElement("", type.Name.ToLower(), "");
|
|
|
- foreach (var column in table.Columns)
|
|
|
- {
|
|
|
- var field = doc.CreateElement("", column.ColumnName.Replace('.', '_'), "");
|
|
|
- var oVal = datarow[column.ColumnName];
|
|
|
- var value = doc.CreateTextNode(oVal != null ? oVal.ToString() : "");
|
|
|
- field.AppendChild(value);
|
|
|
- row.AppendChild(field);
|
|
|
- }
|
|
|
-
|
|
|
- root.AppendChild(row);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- var row = doc.CreateElement("", type.Name.ToLower(), "");
|
|
|
- foreach (var column in table.Columns)
|
|
|
- {
|
|
|
- var field = doc.CreateElement("", column.ColumnName.Replace('.', '_'), "");
|
|
|
- var value = doc.CreateTextNode("");
|
|
|
- field.AppendChild(value);
|
|
|
- row.AppendChild(field);
|
|
|
- }
|
|
|
-
|
|
|
- root.AppendChild(row);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- var xmlString = "";
|
|
|
- using (var wr = new StringWriter())
|
|
|
- {
|
|
|
- doc.Save(wr);
|
|
|
- xmlString = wr.ToString();
|
|
|
- }
|
|
|
-
|
|
|
- return xmlString.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n", "");
|
|
|
- }
|
|
|
-
|
|
|
- public static DataSet CreateReportDataSource(Dictionary<Type, CoreTable> dataenvironment)
|
|
|
- {
|
|
|
- var ds = new DataSet();
|
|
|
- foreach (var key in dataenvironment.Keys)
|
|
|
- {
|
|
|
- var table = dataenvironment[key];
|
|
|
- var dt = new DataTable(key.EntityName().Split('.').Last());
|
|
|
- foreach (var column in table.Columns)
|
|
|
- dt.Columns.Add(column.ColumnName);
|
|
|
- foreach (var row in table.Rows)
|
|
|
- dt.Rows.Add(row.Values.ToArray());
|
|
|
- ds.Tables.Add(dt);
|
|
|
- }
|
|
|
-
|
|
|
- return ds;
|
|
|
- }
|
|
|
-
|
|
|
- // private static void SetupReportData(ReportDefinition report, Dictionary<System.Type,CoreTable> dataenvironment)
|
|
|
- // {
|
|
|
- //
|
|
|
- // report.DataSets.Clear();
|
|
|
- // report.DataSources.Clear();
|
|
|
- // foreach (System.Type type in dataenvironment.Keys)
|
|
|
- // {
|
|
|
- // String _tempfile = Path.GetTempFileName();
|
|
|
- // String xml = DataTableToXML(type, dataenvironment[type]);
|
|
|
- // File.WriteAllText(_tempfile, xml);
|
|
|
- // // Create DataSource(s)
|
|
|
- // DataSource datasource = new DataSource()
|
|
|
- // {
|
|
|
- // Name = type.Name,
|
|
|
- // ConnectionProperties = new ConnectionProperties()
|
|
|
- // {
|
|
|
- // DataProvider = "XML",
|
|
|
- // IntegratedSecurity = true,
|
|
|
- // ConnectString = _tempfile
|
|
|
- // },
|
|
|
- // SecurityType = SecurityType.None,
|
|
|
- // };
|
|
|
- // report.DataSources.Add(datasource);
|
|
|
- //
|
|
|
- // Syncfusion.RDL.DOM.DataSet dataset = new Syncfusion.RDL.DOM.DataSet() { Name = type.Name };
|
|
|
- // dataset.Fields = new Fields();
|
|
|
- //
|
|
|
- // CoreTable table = dataenvironment[type];
|
|
|
- // foreach (var column in table.Columns)
|
|
|
- // {
|
|
|
- // dataset.Fields.Add(
|
|
|
- // new Field()
|
|
|
- // {
|
|
|
- // Name = column.ColumnName.Replace('.', '_'),
|
|
|
- // DataField = column.ColumnName.Replace('.', '_'),
|
|
|
- // TypeName = column.DataType.Name
|
|
|
- // }
|
|
|
- // );
|
|
|
- // }
|
|
|
- //
|
|
|
- // //var properties = CoreUtils.PropertyList(type, x => true, true);
|
|
|
- //
|
|
|
- // //// Create DataSet(s)
|
|
|
- // //foreach (String key in properties.Keys)
|
|
|
- // //{
|
|
|
- // // dataset.Fields.Add(
|
|
|
- // // new Field()
|
|
|
- // // {
|
|
|
- // // Name = key.Replace('.', '_'),
|
|
|
- // // DataField = key.Replace('.', '_'),
|
|
|
- // // TypeName = properties[key].Name
|
|
|
- // // }
|
|
|
- // // );
|
|
|
- // //}
|
|
|
- // dataset.Query = new Query()
|
|
|
- // {
|
|
|
- // DataSourceName = type.Name,
|
|
|
- // CommandType = Syncfusion.RDL.DOM.CommandType.Text,
|
|
|
- // CommandText = String.Format("{0}s/{0}", type.Name.ToLower())
|
|
|
- // };
|
|
|
- // report.DataSets.Add(dataset);
|
|
|
- // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // private static void CleanupReportData(ReportDefinition report)
|
|
|
- // {
|
|
|
- // foreach (var ds in report.DataSources)
|
|
|
- // {
|
|
|
- // String _tempfile = ds.ConnectionProperties.ConnectString;
|
|
|
- // if (File.Exists(_tempfile))
|
|
|
- // File.Delete(_tempfile);
|
|
|
- // ds.ConnectionProperties.ConnectString = "";
|
|
|
- // }
|
|
|
- // report.DataSources[0].ConnectionProperties.ConnectString = "";
|
|
|
- // }
|
|
|
- //
|
|
|
- // private static ReportDefinition DeserialiseReport(String rdl)
|
|
|
- // {
|
|
|
- // String data = rdl;
|
|
|
- // try
|
|
|
- // {
|
|
|
- // byte[] debase64 = Convert.FromBase64String(rdl);
|
|
|
- // data = Encoding.UTF8.GetString(debase64);
|
|
|
- // }
|
|
|
- // catch (Exception e)
|
|
|
- // {
|
|
|
- // Logger.Send(LogType.Error, "", String.Format("*** Unknown Error: {0}\n{1}", e.Message, e.StackTrace));
|
|
|
- // }
|
|
|
- // ReportDefinition report = null;
|
|
|
- // XmlSerializer xs = new XmlSerializer(typeof(ReportDefinition), "http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition");
|
|
|
- // using (StringReader stringreader = new StringReader(data)) // root.ToString()))
|
|
|
- // {
|
|
|
- // report = (ReportDefinition)xs.Deserialize(stringreader);
|
|
|
- // }
|
|
|
- // return report;
|
|
|
- // }
|
|
|
- //
|
|
|
- // [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times")]
|
|
|
- // private static String SerialiseReport(ReportDefinition report)
|
|
|
- // {
|
|
|
- // var stream = SerialiseReportToStream(report);
|
|
|
- // return Encoding.UTF8.GetString(stream.ToArray());
|
|
|
- //
|
|
|
- // }
|
|
|
- //
|
|
|
- // [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times")]
|
|
|
- // private static MemoryStream SerialiseReportToStream(ReportDefinition report)
|
|
|
- // {
|
|
|
- //
|
|
|
- // string nameSpace = "http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition";
|
|
|
- //
|
|
|
- // if (report.RDLType == RDLType.RDL2010)
|
|
|
- // nameSpace = "http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition";
|
|
|
- //
|
|
|
- // XmlSerializerNamespaces serialize = new XmlSerializerNamespaces();
|
|
|
- // serialize.Add("rd", "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner");
|
|
|
- // XmlSerializer xs2 = new XmlSerializer(typeof(Syncfusion.RDL.DOM.ReportDefinition), nameSpace);
|
|
|
- // MemoryStream memoryStream = new MemoryStream();
|
|
|
- // TextWriter ws2 = new StreamWriter(memoryStream);
|
|
|
- // xs2.Serialize(ws2, report, serialize);
|
|
|
- // memoryStream.Position = 0;
|
|
|
- // return memoryStream;
|
|
|
- // //return Encoding.UTF8.GetString(memoryStream.ToArray());
|
|
|
- //
|
|
|
- // }
|
|
|
-
|
|
|
- // private static byte[] GhostScriptIt(byte[] pdf)
|
|
|
- // {
|
|
|
- // String input = Path.GetTempFileName();
|
|
|
- // File.WriteAllBytes(input, pdf);
|
|
|
-
|
|
|
- // byte[] result = new byte[] { };
|
|
|
-
|
|
|
- // GhostscriptVersionInfo gv = new GhostscriptVersionInfo(
|
|
|
- // new Version(0, 0, 0),
|
|
|
- // "gsdll32.dll",
|
|
|
- // "",
|
|
|
- // GhostscriptLicense.GPL
|
|
|
- // );
|
|
|
-
|
|
|
- // GhostscriptPipedOutput gsPipedOutput = new GhostscriptPipedOutput();
|
|
|
-
|
|
|
- // // pipe handle format: %handle%hexvalue
|
|
|
- // string outputPipeHandle = "%handle%" + int.Parse(gsPipedOutput.ClientHandle).ToString("X2");
|
|
|
- // using (GhostscriptProcessor processor = new GhostscriptProcessor(gv, true))
|
|
|
- // {
|
|
|
- // List<string> switches = new List<string>();
|
|
|
- // switches.Add("-empty");
|
|
|
- // switches.Add("-dQUIET");
|
|
|
- // switches.Add("-dSAFER");
|
|
|
- // switches.Add("-dBATCH");
|
|
|
- // switches.Add("-dNOPAUSE");
|
|
|
- // switches.Add("-dNOPROMPT");
|
|
|
- // switches.Add("-dCompatibilityLevel=1.4");
|
|
|
- // switches.Add("-sDEVICE=pdfwrite");
|
|
|
- // switches.Add("-o" + outputPipeHandle);
|
|
|
- // switches.Add("-q");
|
|
|
- // switches.Add("-f");
|
|
|
- // switches.Add(input);
|
|
|
-
|
|
|
- // try
|
|
|
- // {
|
|
|
- // processor.StartProcessing(switches.ToArray(), null);
|
|
|
- // result = gsPipedOutput.Data;
|
|
|
-
|
|
|
- // }
|
|
|
- // catch (Exception ex)
|
|
|
- // {
|
|
|
- // Console.WriteLine(ex.Message);
|
|
|
- // }
|
|
|
- // finally
|
|
|
- // {
|
|
|
- // gsPipedOutput.Dispose();
|
|
|
- // gsPipedOutput = null;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // File.Delete(input);
|
|
|
- // return result;
|
|
|
- // }
|
|
|
-
|
|
|
- #endregion
|
|
|
}
|
|
|
}
|