public override string SetNewData(DevExpress.XtraReports.UI.XtraReport report, string defaultUrl)
        {
            // Save a report to the storage under a new URL.
            // The defaultUrl parameter contains the report display name specified by a user.
            if (CanSetData(defaultUrl))
            {
                SetData(report, defaultUrl);
            }
            else
            {
                using (var session = SessionFactory.Create())
                {
                    MemoryStream ms = new MemoryStream();
                    report.SaveLayout(ms);

                    var reportEntity = new TSOUTERREPORT(session)
                    {
                        Url = defaultUrl
                    };
                    this.SaveToFile(reportEntity.Url, ms);
                    session.CommitChanges();
                }
            }
            return(defaultUrl);
        }
Exemplo n.º 2
0
        public ActionResult GridViewPartial()
        {
            List <ReportModel> reportModels = new List <ReportModel>();

            using (var session = SessionFactory.Create())
            {
                string currentPath  = HostingEnvironment.ApplicationPhysicalPath;
                string messageError = string.Empty;
                currentPath = Path.Combine(currentPath, ApplicationConstant.LOCATION_REPORT_SAVE_NAME);
                FileManagement fileManagement = new FileManagement();
                List <ClassesHelper.FliesName> reportsFile = fileManagement.GetFilesWithoutExtensionFromDirectory(currentPath, ref messageError);

                if (reportsFile != null)
                {
                    var reports = session.Query <TSOUTERREPORT>()
                                  .Select(x => new ReportModel
                    {
                        Url = x.Url,
                        Id  = x.Id
                    })
                                  .ToArray();
                    if (reportsFile.Count != reports.Count())
                    {
                        foreach (var item in reports)
                        {
                            DeletReport(item.Id);
                        }

                        foreach (var elem in reportsFile)
                        {
                            var reportEntity = new TSOUTERREPORT(session)
                            {
                                Url = elem.Url
                            };
                            session.CommitChanges();
                        }
                        reports = session.Query <TSOUTERREPORT>()
                                  .Select(x => new ReportModel
                        {
                            Url = x.Url,
                            Id  = x.Id
                        })
                                  .ToArray();
                    }

                    reportModels = reports.ToList();
                }

                return(PartialView("GridViewPartial", reportModels));
            }
        }
Exemplo n.º 3
0
        public void Delete(long id)
        {
            TSOUTERREPORT obj = DeletReport(id);

            if (obj != null)
            {
                string currentPath  = HostingEnvironment.ApplicationPhysicalPath;
                string messageError = string.Empty;
                string url          = obj.Url;
                currentPath = Path.Combine(currentPath, ApplicationConstant.LOCATION_REPORT_SAVE_NAME);
                url         = url + ApplicationConstant.EXETENSTION_REPORT_SAVE_NAME;
                currentPath = Path.Combine(currentPath, url);
                FileManagement fileManagement = new FileManagement();
                fileManagement.DeleteFileByPath(currentPath, ref messageError);
            }
        }
Exemplo n.º 4
0
        public ActionResult Index(string token)
        {
            List <ReportModel> reportModels = new List <ReportModel>();
            var config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");

            if (config.AppSettings.Settings["TarasolLink"] != null)
            {
                if (bool.Parse(config.AppSettings.Settings["TarasolLink"].Value) && (token != ApplicationConstant.TOKEN_AUTH))
                {
                    return(View("ErrorPage"));
                }
            }

            var connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"];

            if (connectionString == null)
            {
                return(RedirectToAction("Index", "Setting"));
            }
            if (string.IsNullOrWhiteSpace(connectionString.ConnectionString))
            {
                return(RedirectToAction("Index", "Setting"));
            }

            using (var session = SessionFactory.Create())
            {
                string currentPath  = HostingEnvironment.ApplicationPhysicalPath;
                string messageError = string.Empty;
                currentPath = Path.Combine(currentPath, ApplicationConstant.LOCATION_REPORT_SAVE_NAME);
                FileManagement fileManagement = new FileManagement();
                List <ClassesHelper.FliesName> reportsFile = fileManagement.GetFilesWithoutExtensionFromDirectory(currentPath, ref messageError);

                if (reportsFile != null)
                {
                    var reports = session.Query <TSOUTERREPORT>()
                                  .Select(x => new ReportModel
                    {
                        Url = x.Url,
                        Id  = x.Id
                    })
                                  .ToArray();
                    if (reportsFile.Count != reports.Count())
                    {
                        foreach (var item in reports)
                        {
                            DeletReport(item.Id);
                        }

                        foreach (var elem in reportsFile)
                        {
                            var reportEntity = new TSOUTERREPORT(session)
                            {
                                Url = elem.Url
                            };
                            session.CommitChanges();
                        }
                        reports = session.Query <TSOUTERREPORT>()
                                  .Select(x => new ReportModel
                        {
                            Url = x.Url,
                            Id  = x.Id
                        })
                                  .ToArray();
                    }

                    reportModels = reports.ToList();
                }

                return(View("Index", reportModels));
            }
        }