示例#1
0
        public ActionResult OpenReport()
        {
            StiRequestParams requestParams = StiMvcDesigner.GetRequestParams();

            System.Web.HttpContext.Current.Session["CurrentStimulsoftFileNameToDesign"] = requestParams.Designer.FileName;
            return(StiMvcDesigner.GetReportResult());
        }
示例#2
0
        public ActionResult SaveReport()
        {
            try
            {
                StiReport report = StiMvcDesigner.GetReportObject();

                string fileName = System.Web.HttpContext.Current.Session["CurrentStimulsoftFileNameToDesign"] != null ? System.Web.HttpContext.Current.Session["CurrentStimulsoftFileNameToDesign"].ToString() : null;

                if (fileName != null)
                {
                    if (!System.IO.File.Exists(fileName))
                    {
                        throw new Exception(string.Format("Unable to save file \"{0}\"! The path to the file is not available. Please use Sava As.", fileName));
                    }

                    report.Save(fileName);
                }
                else
                {
                    StiRequestParams requestParams    = StiMvcDesigner.GetRequestParams();
                    string           fileNameFullPath = requestParams.Designer.FileName;

                    try
                    {
                        FileStream f = new FileStream(fileNameFullPath, FileMode.Create, FileAccess.Write);
                        f.Close();
                        report.Save(fileNameFullPath);
                        System.Web.HttpContext.Current.Session["CurrentStimulsoftFileNameToDesign"] = fileNameFullPath;
                    }
                    catch
                    {
                        throw new Exception(string.Format("Unable to save file \"{0}\"! Please enter a valid file name with FULL path.", fileNameFullPath));
                    }
                }
            }
            catch (Exception e)
            {
                System.Web.HttpContext.Current.Session.Remove("CurrentStimulsoftFileNameToDesign");
                return(StiMvcDesigner.SaveReportResult(string.Format("An error happened: {0}", e.Message)));
            }

            return(StiMvcDesigner.SaveReportResult());
        }
示例#3
0
        public ActionResult SaveReportAs()
        {
            string fileNameFullPath = "";

            try
            {
                StiReport report = StiMvcDesigner.GetReportObject();

                StiRequestParams requestParams = StiMvcDesigner.GetRequestParams();
                fileNameFullPath = requestParams.Designer.FileName;

                FileStream f = new FileStream(fileNameFullPath, FileMode.Create, FileAccess.Write);
                f.Close();
                report.Save(fileNameFullPath);
                System.Web.HttpContext.Current.Session["CurrentStimulsoftFileNameToDesign"] = fileNameFullPath;
                return(StiMvcDesigner.SaveReportResult(report));
            }
            catch
            {
                return(StiMvcDesigner.SaveReportResult(string.Format("Unable to save file \"{0}\"! Please enter a valid file name with FULL path.", fileNameFullPath)));
            }
        }
        public ActionResult Get()
        {
            var requestParams = StiMvcDesigner.GetRequestParams();

            if (requestParams.Action == StiAction.Undefined)
            {
                var options = new StiMvcDesignerOptions();
                return(StiMvcDesigner.GetAngularScriptsResult(requestParams, options));
            }

            if (requestParams.Component == StiComponentType.Designer)
            {
                switch (requestParams.Action)
                {
                case StiAction.GetReport:
                    return(GetReport());

                case StiAction.SaveReport:
                    return(SaveReport());
                }
            }

            return(StiMvcDesigner.ProcessRequestResult());
        }