//Save as is executed instead of save...
 public override string SetNewData(XtraReport report, string defaultUrl)
 {
     try
     {
         var layoutStream = new MemoryStream();
         report.SaveLayoutToXml(layoutStream);
         layoutStream.Position = 0;
         string layout = null;
         using (var sr = new StreamReader(layoutStream))
         {
             layout = sr.ReadToEnd();
         }
         if (defaultUrl == "Customers")
         {
             ReportRepository.SampleMasterReportLayout = layout;
         }
         else
         {
             ReportRepository.SampleDetailReportLayout = layout;
         }
         return(defaultUrl);
     }
     catch (Exception x)
     {
         throw propagateExceptionToDevExpressClient("save report", x);
     }
 }
Beispiel #2
0
 public override void SetData(XtraReport report, string url)
 {
     using (var stream = new MemoryStream()) {
         report.SaveLayoutToXml(stream);
         SaveAndUpateSessionState(url, stream.ToArray());
     }
 }
        public override string SetNewData(XtraReport report, string defaultUrl)
        {
            // Append "1" if a new report name already exists.
            if (GetUrls().ContainsValue(defaultUrl))
            {
                defaultUrl = string.Concat(defaultUrl, "1");
            }

            // Save a report to the storage with a new URL.
            // The defaultUrl parameter is the report name that the user specifies.
            DataRow row = reportsTable.NewRow();

            row["ReportId"]    = 0;
            row["DisplayName"] = defaultUrl;
            using (MemoryStream ms = new MemoryStream())
            {
                report.SaveLayoutToXml(ms);
                row["LayoutData"] = ms.GetBuffer();
            }
            reportsTable.Rows.Add(row);
            reportsTableAdapter.Update(reportsTable);
            // Refill the dataset to obtain the actual value of the new row's autoincrement key field.
            reportsTable.Clear();
            reportsTableAdapter.Fill(reportsTable);
            return(reportsTable.AsEnumerable().
                   FirstOrDefault(x => x["DisplayName"].ToString() == defaultUrl)["ReportId"].ToString());
        }
Beispiel #4
0
 public override void SetData(XtraReport report, string url)
 {
     using (var stream = new MemoryStream()) {
         report.SaveLayoutToXml(stream);
         HttpContextAccessor.HttpContext.Session.Set(url, stream.ToArray());
     }
 }
Beispiel #5
0
 public static ReportItem CreateAdminReport()
 {
     using (MemoryStream ms = new MemoryStream())
     {
         var report = new XtraReport();
         report.Bands.AddRange(new Band[] {
             new TopMarginBand()
             {
                 HeightF = 100f
             },
             new DetailBand()
             {
                 HeightF = 100f
             },
             new BottomMarginBand()
             {
                 HeightF = 100f
             }
         });
         report.Bands[BandKind.Detail].Controls.Add(new XRLabel()
         {
             Text  = "Hello Admin!",
             SizeF = new System.Drawing.SizeF(200, 50)
         });
         report.SaveLayoutToXml(ms);
         return(new ReportItem()
         {
             Id = AdminReportName,
             ReportLayout = ms.ToArray()
         });
     }
 }
 public override void SetData(XtraReport report, string url)
 {
     using (var reportFile = File.Open(Path.Combine(reportDirectory, url + FileExtension), FileMode.OpenOrCreate))
     {
         report.SaveLayoutToXml(reportFile);
     }
 }
Beispiel #7
0
 static byte[] ReportToByteArray(XtraReport report)
 {
     using (var memoryStream = new MemoryStream()) {
         report.SaveLayoutToXml(memoryStream);
         return(memoryStream.ToArray());
     }
 }
 static XtraReport CloneReportLayout(XtraReport report)
 {
     using (var stream = new MemoryStream()) {
         report.SaveLayoutToXml(stream);
         stream.Position = 0;
         return(XtraReport.FromStream(stream, true));
     }
 }
Beispiel #9
0
 byte[] SerializeReport(XtraReport report)
 {
     using (MemoryStream stream = new MemoryStream()) {
         report.SaveLayoutToXml(stream);
         stream.Position = 0;
         return(stream.GetBuffer());
     }
 }
Beispiel #10
0
 public override string SetNewData(XtraReport report, string defaultUrl)
 {
     using (var stream = new MemoryStream()) {
         report.SaveLayoutToXml(stream);
         SaveAndUpateSessionState(defaultUrl, stream.ToArray());
     }
     return(defaultUrl);
 }
Beispiel #11
0
 public override string SetNewData(XtraReport report, string defaultUrl)
 {
     using (var stream = new MemoryStream()) {
         report.SaveLayoutToXml(stream);
         HttpContextAccessor.HttpContext.Session.Set(defaultUrl, stream.ToArray());
     }
     return(defaultUrl);
 }
 public static XtraReport Clone(this XtraReport report)
 {
     using (var ms = new MemoryStream()) {
         report.SaveLayoutToXml(ms);
         ms.Position = 0;
         return(XtraReport.FromStream(ms, true));
     }
 }
 public override void SetData(XtraReport report, string url)
 {
     // Stores the specified report to a Report Storage using the specified URL.
     // This method is called only after the IsValidUrl and CanSetData methods are called.
     using (var reportFile = File.Open(Path.Combine(reportDirectory, url + FileExtension), FileMode.OpenOrCreate)) {
         report.SaveLayoutToXml(reportFile);
     }
 }
Beispiel #14
0
 public override void SetData(XtraReport report, string url)
 {
     if (!IsWithinReportsFolder(url, reportDirectory))
     {
         throw new FaultException(new FaultReason("Invalid report name."), new FaultCode("Server"), "GetData");
     }
     report.SaveLayoutToXml(Path.Combine(reportDirectory, url + FileExtension));
 }
Beispiel #15
0
        public static string Save(this XtraReport report)
        {
            var stream = new MemoryStream();

            report.SaveLayoutToXml(stream);

            stream.Position = 0;
            return(new StreamReader(stream).ReadToEnd());
        }
Beispiel #16
0
        private void LoadReportAndSaveToXml()
        {
            XtraReport report = new XtraReport();

            InitDataSource(report);
            InitControls(report);
            InitExtensions(report);
            report.SaveLayoutToXml(fileName);
        }
Beispiel #17
0
 public override void SetData(XtraReport report, string url)
 {
     // Stores the specified report to a Report Storage using the specified URL.
     // This method is called only after the IsValidUrl and CanSetData methods are called.
     if (!IsWithinReportsFolder(url, reportDirectory))
     {
         throw new FaultException(new FaultReason("Invalid report name."), new FaultCode("Server"), "GetData");
     }
     report.SaveLayoutToXml(Path.Combine(reportDirectory, url + FileExtension));
 }
 public override void SetData(XtraReport report, string url)
 {
     // Stores the specified report to a Report Storage using the specified URL.
     // This method is called only after the IsValidUrl and CanSetData methods are called.
     if (!IsWithinReportsFolder(url, ReportDirectory))
     {
         throw new DevExpress.XtraReports.Web.ClientControls.FaultException("Invalid report name.");
     }
     report.SaveLayoutToXml(Path.Combine(ReportDirectory, url + FileExtension));
 }
Beispiel #19
0
 string GetData(XtraReport report)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         report.SaveLayoutToXml(ms);
         using (StreamReader sr = new StreamReader(ms))
         {
             sr.BaseStream.Seek(0, SeekOrigin.Begin);
             return(sr.ReadToEnd());
         }
     }
 }
Beispiel #20
0
 public override void SetData(XtraReport report, string url)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         report.SaveLayoutToXml(ms);
         cosmosApiStorage.UpdateReportItem(new ReportItem()
         {
             Id           = url,
             ReportLayout = ms.ToArray()
         }).Wait();
     }
 }
 public override void SetData(XtraReport report, string url)
 {
     try {
         string filePath = GetPath(url);
         throw new NotSupportedException("Saving is not allowed."); //Comment this line to enable saving
         report.SaveLayoutToXml(filePath);
     }
     catch (Exception ex) {
         //Pass readable exception message to the Web Report Designer
         throw new FaultException(ex.Message);
     }
 }
Beispiel #22
0
 public override string SetNewData(XtraReport report, string defaultUrl)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         report.SaveLayoutToXml(ms);
         cosmosApiStorage.CreateReportItem(new ReportItem()
         {
             Id           = defaultUrl,
             ReportLayout = ms.ToArray()
         }).Wait();
         return(defaultUrl);
     }
 }
 void SetDataInternal(XtraReport report, string url, bool isNewOne)
 {
     if (!isNewOne && !Reports.ContainsKey(url))
     {
         throw new FaultException(new FaultReason(string.Format("Could not find report '{0}'.", url)), new FaultCode("Server"), "SetData");
     }
     using (var stream = new MemoryStream())
     {
         report.SaveLayoutToXml(stream);
         var reportLayout = stream.ToArray();
         var newReportDetails = new ReportDetails { DisplayName = url, Layout = reportLayout };
         Reports.AddOrUpdate(url, newReportDetails, (currentUrl, existingReport) => { existingReport.Layout = reportLayout; return existingReport; });
     }
 }
Beispiel #24
0
 public override void SetData(XtraReport report, string url)
 {
     // Stores the specified report to a Report Storage using the specified URL.
     // This method is called only after the IsValidUrl and CanSetData methods are called.
     try
     {
         //string urlsave = "\\" + "\\SRV-DB\\DocsGenerados\\" + url + FileExtension;
         //report.SaveLayoutToXml(urlsave);
         report.SaveLayoutToXml(Path.Combine(reportDirectory, url + FileExtension));
     }
     catch (Exception Ex)
     {
         string Exe = Ex.Message;
     }
 }
        public override void SetData(XtraReport report, string url)
        {
            // Write a report to the storage under the specified URL.
            DataRow row = reportsTable.Rows.Find(int.Parse(url));

            if (row != null)
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    report.SaveLayoutToXml(ms);
                    row["LayoutData"] = ms.GetBuffer();
                }
                reportsTableAdapter.Update(reportsTable);
            }
        }
        protected static byte[] SerializeControls(XRControl[] controls)
        {
            XtraReport tempReport = new XtraReport();
            DetailBand tempBand   = new DetailBand();

            tempReport.Bands.Add(tempBand);

            using (XtraReport cloneReport = new XtraReport()) {
                using (MemoryStream stream = new MemoryStream()) {
                    controls[0].RootReport.SaveLayoutToXml(stream);
                    stream.Position = 0;

                    cloneReport.LoadLayoutFromXml(stream);
                }
                foreach (XRControl control in controls)
                {
                    XRControl clone = cloneReport.FindControl(control.Name, true);
                    if (clone != null)
                    {
                        tempBand.Controls.Add(clone);
                    }
                }
            }

            float topMost  = float.MaxValue;
            float leftMost = float.MaxValue;

            foreach (XRControl control in tempBand.Controls)
            {
                topMost  = Math.Min(topMost, control.TopF);
                leftMost = Math.Min(leftMost, control.LeftF);
            }

            foreach (XRControl control in tempBand.Controls)
            {
                control.LocationF = new PointF(control.LeftF - leftMost, control.TopF - topMost);
            }

            byte[] layoutBytes = null;

            using (MemoryStream stream = new MemoryStream()) {
                tempReport.SaveLayoutToXml(stream);
                layoutBytes = stream.ToArray();
            }

            tempReport.Dispose();
            return(layoutBytes);
        }
Beispiel #27
0
        public override byte[] GetData(string url)
        {
            // Returns report layout data stored in a Report Storage using the specified URL.
            // This method is called only for valid URLs after the IsValidUrl method is called.
            try
            {
                // In case of the reportviewer, we need to handle the parameters correctly
                var    parts      = url.Split('?');
                string reportName = parts[0];
                bool   isDesigner = parts.Length == 1;
                int[]  ids        = null;
                if (!isDesigner && reportName == "Invoice")
                {
                    var pars = QueryHelpers.ParseQuery(parts[1]);
                    ids = pars["ids"].SelectMany(i => i.Split(',').Select(j => Convert.ToInt32(j))).ToArray();
                }

                XtraReport report = null;
                if (Directory.EnumerateFiles(ReportDirectory).Select(Path.GetFileNameWithoutExtension).Contains(reportName))
                {
                    report = XtraReport.FromFile(Path.Combine(ReportDirectory, $"{reportName}{FileExtension}"));
                }
                else if (ReportsFactory.Reports.ContainsKey(reportName))
                {
                    report = ReportsFactory.Reports[reportName]();
                }
                if (report != null)
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        if (!isDesigner && reportName == "Invoice")
                        {
                            report.Parameters["invoiceIds"].Value   = ids;
                            report.Parameters["invoiceIds"].Visible = false;
                        }
                        report.SaveLayoutToXml(ms);
                        return(ms.ToArray());
                    }
                }
            }
            catch (Exception ex)
            {
                throw new FaultException("Could not get report data.", ex);
            }
            throw new FaultException($"Could not find report '{url}'.");
        }
        public override byte[] GetData(string url)
        {
            var reportNames = GetViewableReportDisplayNamesForCurrentUser();

            if (!reportNames.Contains(url))
            {
                throw new UnauthorizedAccessException();
            }

            // TODO: Put your logic to get bytes from DB
            XtraReport publicReport = CreateReportByDisplayName(url);

            using (MemoryStream ms = new MemoryStream()) {
                publicReport.SaveLayoutToXml(ms);
                return(ms.GetBuffer());
            }
        }
        public override byte[] GetData(string url)
        {
            // Returns report layout data stored in a Report Storage using the specified URL.
            // This method is called only for valid URLs after the IsValidUrl method is called.           
            string[] urlParts = url.Split('?');
            string reportName = urlParts[0];

            var data = EmbeddedResourceReportStorage.GetData(reportName);
            if (data == null)
            {
                ReportDetails details = null;
                if (Reports.TryGetValue(reportName, out details))
                    data = details.Layout;
            }



            if (data != null)
            {
                if (urlParts.Length == 2)
                {
                    XtraReport report = new XtraReport();
                    report.LoadLayoutFromXml(new MemoryStream(data));

                    string[] parameterDefinitions = urlParts[1].Split('&');
                    foreach (string parameterDefinition in parameterDefinitions)
                    {
                        string[] keyValue = parameterDefinition.Split('=');
                        DevExpress.XtraReports.Parameters.Parameter parameter = report.Parameters[keyValue[0]];
                        parameter.Value = Convert.ChangeType(keyValue[1], parameter.Type);
                    }

                    using (MemoryStream ms = new MemoryStream())
                    {
                        report.SaveLayoutToXml(ms);
                        return ms.ToArray();
                    }
                }
                else
                    return data;
            }


            throw new FaultException(new FaultReason(string.Format("Could not find report '{0}'.", url)), new FaultCode("Server"), "GetData");
        }
Beispiel #30
0
        public override byte[] GetData(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(new byte[0]);
            }

            var m_Serializer = new JavaScriptSerializer();
            var m_Filtros    = m_Serializer.Deserialize <ParametrosReport>(url);

            // build report model
            var m_IReport = FactoryReport.CM_GetReport(m_Filtros, services);

            // build layout
            var m_Layout = m_IReport.CM_GetLayout();

            // build XtraReport
            XtraReport newReport = new XtraReport();
            // load layout in XtraReport
            MemoryStream streamLayout = new MemoryStream(StringParaByteArray(m_Layout));

            newReport.LoadLayout(streamLayout);

            // loadDataSource
            var m_Data = m_IReport.CM_CarregaDataSource();
            // serialize dataSource
            var jsonSerializado = m_Serializer.Serialize(m_Data);

            // build CustomJsonSource
            var json = new JsonDataSource();

            json.JsonSource = new CustomJsonSource(jsonSerializado);
            json.Name       = m_Filtros.ds_data_source;
            json.Fill();

            // attach CustomJsonSource to XtraReport
            newReport.DataSource = json;

            // Return XtraReport in bytes to FrontEnd
            MemoryStream streamReport = new MemoryStream();

            newReport.SaveLayoutToXml(streamReport);
            return(streamReport.ToArray());
        }
Beispiel #31
0
 public override void SetData(XtraReport report, Stream stream)
 {
     report.SaveLayoutToXml(stream);
 }