From 9e351e41907f9cdc43bf98fae03b2f52cb381cd0 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Fri, 10 Nov 2023 12:46:30 +0300 Subject: [PATCH] csharp-mvc: replace the previous implementation of formats --- .../csharp-mvc/Helpers/DocManagerHelper.cs | 8 ++--- .../csharp-mvc/Models/FileUtility.cs | 35 +++---------------- .../csharp-mvc/OnlineEditorsExampleMVC.csproj | 5 +++ .../csharp-mvc/web.appsettings.config | 4 --- 4 files changed, 13 insertions(+), 39 deletions(-) diff --git a/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs b/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs index 7721001c..41493888 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs @@ -51,24 +51,24 @@ namespace OnlineEditorsExampleMVC.Helpers // get file extensions that can be viewed public static List ViewedExts { - get { return (WebConfigurationManager.AppSettings["files.docservice.viewed-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } + get { return FormatManager.ViewableExtensions(); } } public static List FillFormExts { - get { return (WebConfigurationManager.AppSettings["files.docservice.fillform-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } + get { return FormatManager.FillableExtensions(); } } // get file extensions that can be edited public static List EditedExts { - get { return (WebConfigurationManager.AppSettings["files.docservice.edited-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } + get { return FormatManager.EditableExtensions(); } } // get file extensions that can be converted public static List ConvertExts { - get { return (WebConfigurationManager.AppSettings["files.docservice.convert-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } + get { return FormatManager.ConvertibleExtensions(); } } // get current user host address diff --git a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs index f7eb6d8e..b2de3aba 100644 --- a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs @@ -40,39 +40,12 @@ namespace OnlineEditorsExampleMVC.Models { var ext = Path.GetExtension(fileName).ToLower(); - if (ExtsDocument.Contains(ext)) return FileType.Word; // word type for document extensions - if (ExtsSpreadsheet.Contains(ext)) return FileType.Cell; // cell type for spreadsheet extensions - if (ExtsPresentation.Contains(ext)) return FileType.Slide; // slide type for presentation extensions + if (FormatManager.DocumentExtensions().Contains(ext)) return FileType.Word; // word type for document extensions + if (FormatManager.SpreadsheetExtensions().Contains(ext)) return FileType.Cell; // cell type for spreadsheet extensions + if (FormatManager.PresentationExtensions().Contains(ext)) return FileType.Slide; // slide type for presentation extensions return FileType.Word; // the default type is word } - - // document extensions - public static readonly List ExtsDocument = new List - { - ".doc", ".docx", ".docm", - ".dot", ".dotx", ".dotm", - ".odt", ".fodt", ".ott", ".rtf", ".txt", - ".html", ".htm", ".mht", ".xml", - ".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps", ".oform" - }; - - // spreadsheet extensions - public static readonly List ExtsSpreadsheet = new List - { - ".xls", ".xlsx", ".xlsm", ".xlsb", - ".xlt", ".xltx", ".xltm", - ".ods", ".fods", ".ots", ".csv" - }; - - // presentation extensions - public static readonly List ExtsPresentation = new List - { - ".pps", ".ppsx", ".ppsm", - ".ppt", ".pptx", ".pptm", - ".pot", ".potx", ".potm", - ".odp", ".fodp", ".otp" - }; } public class Format @@ -98,7 +71,7 @@ namespace OnlineEditorsExampleMVC.Models } } - public class FormatManager + public static class FormatManager { public static List FillableExtensions() { diff --git a/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj b/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj index 3691fc7d..e9e88433 100644 --- a/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj +++ b/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj @@ -193,6 +193,11 @@ + + + + + diff --git a/web/documentserver-example/csharp-mvc/web.appsettings.config b/web/documentserver-example/csharp-mvc/web.appsettings.config index fb6b5f44..51630ee6 100644 --- a/web/documentserver-example/csharp-mvc/web.appsettings.config +++ b/web/documentserver-example/csharp-mvc/web.appsettings.config @@ -7,10 +7,6 @@ - - - -