#if DESIGNER using Microsoft.AspNetCore.Html; using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Text; using System.Threading.Tasks; using System.ComponentModel; using FastReport.Web.Services; namespace FastReport.Web { partial class WebReport { #region Designer Properties /// /// Designer settings /// public DesignerSettings Designer { get; set; } = DesignerSettings.Default; /// /// Enable code editor in the Report Designer /// [Obsolete("DesignerScriptCode is obsolete, please use Designer.ScriptCode")] [EditorBrowsable(EditorBrowsableState.Never)] public bool DesignScriptCode { get => Designer.ScriptCode; set => Designer.ScriptCode = value; } /// /// Gets or sets path to the Report Designer /// [Obsolete("DesignerPath is obsolete, please use Designer.Path")] [EditorBrowsable(EditorBrowsableState.Never)] public string DesignerPath { get => Designer.Path; set => Designer.Path = value; } /// /// Gets or sets path to a folder for save designed reports /// If value is empty then designer posts saved report in variable ReportFile on call the DesignerSaveCallBack // TODO /// [Obsolete("DesignerPath is obsolete, please use Designer.SavePath")] [EditorBrowsable(EditorBrowsableState.Never)] public string DesignerSavePath { get => Designer.SavePath; set => Designer.SavePath = value; } /// /// Gets or sets path to callback page after Save from Designer /// [Obsolete("DesignerSaveCallBack is obsolete, please use Designer.SaveCallBack instead.")] [EditorBrowsable(EditorBrowsableState.Never)] public string DesignerSaveCallBack { get => Designer.SaveCallBack; set => Designer.SaveCallBack = value; } /// /// Callback method for saving an edited report by Online Designer /// Params: reportID, report file name, report, out - message /// /// /// webReport.DesignerSaveMethod = (string reportID, string filename, string report) => /// { /// string webRootPath = _hostingEnvironment.WebRootPath; /// string pathToSave = Path.Combine(webRootPath, filename); /// System.IO.File.WriteAllTextAsync(pathToSave, report); /// /// return "OK"; /// }; /// [Obsolete("DesignerSaveMethod is obsolete, please use Designer.SaveMethod instead.")] [EditorBrowsable(EditorBrowsableState.Never)] public Func DesignerSaveMethod { get => Designer.SaveMethod; set => Designer.SaveMethod = value; } /// /// Report name without extension /// public string ReportName { get { return (!string.IsNullOrEmpty(Report.ReportInfo.Name) ? Report.ReportInfo.Name : Path.GetFileNameWithoutExtension(Report.FileName)); } } /// /// Report file name with extension (*.frx) /// public string ReportFileName => $"{ReportName}.frx"; /// /// Gets or sets the locale of Designer /// [Obsolete("DesignerLocale is obsolete, please use Designer.Locale")] [EditorBrowsable(EditorBrowsableState.Never)] public string DesignerLocale { get => Designer.Locale; set => Designer.Locale = value; } /// /// Gets or sets the text of configuration of Online Designer /// [Obsolete("DesignerConfig is obsolete, please use Designer.Config")] [EditorBrowsable(EditorBrowsableState.Never)] public string DesignerConfig { get => Designer.Config; set => Designer.Config = value; } /// /// Gets or sets the request headers /// public WebHeaderCollection RequestHeaders { get; set; } /// /// Occurs when designed report save is started. /// public event EventHandler SaveDesignedReport; #endregion #region Public Methods /// /// Runs on designed report save /// internal void OnSaveDesignedReport() { if (SaveDesignedReport != null) { SaveDesignedReportEventArgs e = new SaveDesignedReportEventArgs(); e.Stream = new MemoryStream(); Report.Save(e.Stream); e.Stream.Position = 0; SaveDesignedReport.Invoke(this, e); } } #endregion #region Private Methods HtmlString RenderDesigner() { //string designerPath = WebUtils.GetAppRoot(DesignerPath); string designerLocale = Designer.Locale.IsNullOrWhiteSpace() ? "" : $"&lang={Designer.Locale}"; return new HtmlString($@" "); // TODO: add fit script } //void SendPreviewObjectResponse(HttpContext context) //{ // string uuid = context.Request.Params["previewobject"]; // SetUpWebReport(uuid, context); // WebUtils.SetupResponse(webReport, context); // if (!NeedExport(context) && !NeedPrint(context)) // SendReport(context); // cache.PutObject(uuid, webReport); // Finalize(context); //} // On-line Designer //void SendDesigner(HttpContext context, string uuid) //{ // WebUtils.SetupResponse(webReport, context); // StringBuilder sb = new StringBuilder(); // context.Response.AddHeader("Content-Type", "html/text"); // try // { // string designerPath = WebUtils.GetAppRoot(context, webReport.DesignerPath); // string designerLocale = String.IsNullOrEmpty(webReport.Designer.Locale) ? "" : "&lang=" + webReport.Designer.Locale; // sb.AppendFormat(""); // // add resize here // if (webReport.Height == System.Web.UI.WebControls.Unit.Percentage(100)) // sb.Append(GetFitScript(uuid)); // } // catch (Exception e) // { // log.AddError(e); // } // if (log.Text.Length > 0) // { // context.Response.Write(log.Text); // log.Clear(); // } // SetContainer(context, Properties.ControlID); // context.Response.Write(sb.ToString()); //} string GetFitScript(string ID) { StringBuilder sb = new StringBuilder(); sb.AppendLine(""); return sb.ToString(); } #endregion } } #endif