管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2023-07-28 015a83929f2f04455c704546f3d3f80d42c23101
添加文件上传功能
已添加2个文件
已修改7个文件
170 ■■■■■ 文件已修改
DataLoader/DataLoader.csproj 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap.sln 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Controllers/UploadController.cs 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/ExportMap.csproj 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Models/FileDesc.cs 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Web.config 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/cs/NoBufferPolicySelector.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/up.html 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaCode/JavaCode.csproj 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/DataLoader.csproj
@@ -41,6 +41,26 @@
  <PropertyGroup>
    <StartupObject>DataLoader.App</StartupObject>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x64\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>true</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    <OutputPath>bin\x64\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>true</Prefer32Bit>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="CefSharp, Version=108.4.130.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL">
      <HintPath>..\packages\CefSharp.Common.108.4.130\lib\net452\CefSharp.dll</HintPath>
ExportMap.sln
@@ -12,25 +12,43 @@
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Debug|x64 = Debug|x64
        Release|Any CPU = Release|Any CPU
        Release|x64 = Release|x64
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {53C216F2-AAAB-474C-8A33-9DB69E3670AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {53C216F2-AAAB-474C-8A33-9DB69E3670AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {53C216F2-AAAB-474C-8A33-9DB69E3670AF}.Debug|x64.ActiveCfg = Debug|x64
        {53C216F2-AAAB-474C-8A33-9DB69E3670AF}.Debug|x64.Build.0 = Debug|x64
        {53C216F2-AAAB-474C-8A33-9DB69E3670AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {53C216F2-AAAB-474C-8A33-9DB69E3670AF}.Release|Any CPU.Build.0 = Release|Any CPU
        {53C216F2-AAAB-474C-8A33-9DB69E3670AF}.Release|x64.ActiveCfg = Release|x64
        {53C216F2-AAAB-474C-8A33-9DB69E3670AF}.Release|x64.Build.0 = Release|x64
        {49F2AA44-7BF5-46B7-B08F-40AA1455F089}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {49F2AA44-7BF5-46B7-B08F-40AA1455F089}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {49F2AA44-7BF5-46B7-B08F-40AA1455F089}.Debug|x64.ActiveCfg = Debug|x64
        {49F2AA44-7BF5-46B7-B08F-40AA1455F089}.Debug|x64.Build.0 = Debug|x64
        {49F2AA44-7BF5-46B7-B08F-40AA1455F089}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {49F2AA44-7BF5-46B7-B08F-40AA1455F089}.Release|Any CPU.Build.0 = Release|Any CPU
        {49F2AA44-7BF5-46B7-B08F-40AA1455F089}.Release|x64.ActiveCfg = Release|x64
        {49F2AA44-7BF5-46B7-B08F-40AA1455F089}.Release|x64.Build.0 = Release|x64
        {95C212E0-D078-4932-9FAB-7A7BFD6657B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {95C212E0-D078-4932-9FAB-7A7BFD6657B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {95C212E0-D078-4932-9FAB-7A7BFD6657B3}.Debug|x64.ActiveCfg = Debug|x64
        {95C212E0-D078-4932-9FAB-7A7BFD6657B3}.Debug|x64.Build.0 = Debug|x64
        {95C212E0-D078-4932-9FAB-7A7BFD6657B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {95C212E0-D078-4932-9FAB-7A7BFD6657B3}.Release|Any CPU.Build.0 = Release|Any CPU
        {95C212E0-D078-4932-9FAB-7A7BFD6657B3}.Release|x64.ActiveCfg = Release|x64
        {95C212E0-D078-4932-9FAB-7A7BFD6657B3}.Release|x64.Build.0 = Release|x64
        {1670B5DF-E266-473F-AF55-EA2AC1CFC6E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {1670B5DF-E266-473F-AF55-EA2AC1CFC6E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {1670B5DF-E266-473F-AF55-EA2AC1CFC6E7}.Debug|x64.ActiveCfg = Debug|x64
        {1670B5DF-E266-473F-AF55-EA2AC1CFC6E7}.Debug|x64.Build.0 = Debug|x64
        {1670B5DF-E266-473F-AF55-EA2AC1CFC6E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {1670B5DF-E266-473F-AF55-EA2AC1CFC6E7}.Release|Any CPU.Build.0 = Release|Any CPU
        {1670B5DF-E266-473F-AF55-EA2AC1CFC6E7}.Release|x64.ActiveCfg = Release|x64
        {1670B5DF-E266-473F-AF55-EA2AC1CFC6E7}.Release|x64.Build.0 = Release|x64
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
ExportMap/Controllers/UploadController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,50 @@
using ExportMap.cs;
using ExportMap.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
namespace ExportMap.Controllers
{
    public class UploadController : ApiController
    {
        [HttpPost]
        public Task<IEnumerable<FileDesc>> Post([FromUri]string path)
        {
            //string root = HttpContext.Current.Server.MapPath("~/uploads");
            if (string.IsNullOrEmpty(path)) return null;
            string root = Path.Combine(Tools.GetSetting("tempFolder"), path);
            if (!Directory.Exists(root)) Directory.CreateDirectory(root);
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "请求的格式不正确!"));
            }
            var provider = new CustomMultipartFormDataStreamProvider(root);
            var task = Request.Content.ReadAsMultipartAsync(provider).ContinueWith<IEnumerable<FileDesc>>(t =>
            {
                if (t.IsFaulted || t.IsCanceled)
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
                var fileInfos = provider.FileData.Select(i =>
                {
                    FileInfo info = new FileInfo(i.LocalFileName);
                    return new FileDesc(info.Name, info.Length);
                });
                return fileInfos;
            });
            return task;
        }
    }
}
ExportMap/ExportMap.csproj
@@ -143,6 +143,7 @@
    <Compile Include="Controllers\licenseEncryptionController.cs" />
    <Compile Include="Controllers\TBController.cs" />
    <Compile Include="Controllers\TerraController.cs" />
    <Compile Include="Controllers\UploadController.cs" />
    <Compile Include="cs\CacheUtils.cs" />
    <Compile Include="cs\ConvertUtils.cs" />
    <Compile Include="cs\CustomMultipartFormDataStreamProvider.cs" />
@@ -165,6 +166,7 @@
    </Compile>
    <Compile Include="Models\Decrypt.cs" />
    <Compile Include="Models\ExportArgs.cs" />
    <Compile Include="Models\FileDesc.cs" />
    <Compile Include="Models\ResponseMsg.cs" />
    <Compile Include="Models\Secret.cs" />
    <Compile Include="Models\SpatialItem.cs" />
@@ -202,6 +204,24 @@
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
ExportMap/Models/FileDesc.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,24 @@
using ExportMap.cs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace ExportMap.Models
{
    /// <summary>
    /// æ–‡ä»¶æè¿°
    /// </summary>
    public class FileDesc
    {
        public FileDesc(string name, long length)
        {
            this.Name = name;
            this.Length = Tools.FormatBytes(length);
        }
        public string Name { set; get; }
        public string Length { set; get; }
    }
}
ExportMap/Web.config
@@ -3,6 +3,8 @@
  <appSettings>
    <!-- å»ŠåŠæœåŠ¡ -->
    <add key="lfServer" value="http://127.0.0.1:12316/server"/>
    <!-- ä¸´æ—¶ç›®å½• -->
    <add key="tempFolder" value="D:\LF\temp"/>
    <!-- ä¸Šä¼ ç›®å½• -->
    <add key="uploadFolder" value="D:\LF\upload"/>
    <!-- ä¸‹è½½ç›®å½• -->
@@ -32,12 +34,14 @@
  <connectionStrings/>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2"/>
    <httpRuntime maxRequestLength="2147483647"/>
    <!-- maxRequestLength是上传文件时最大size(单位是KB,默认值是4096kb),executionTimeout是请求session(单位是秒,默认值是110s) -->
    <httpRuntime maxRequestLength="2147483647" executionTimeout="14400"/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <!-- 1GB = 1073741824 -->
        <requestLimits maxAllowedContentLength="2147483647"/>
      </requestFiltering>
    </security>
ExportMap/cs/NoBufferPolicySelector.cs
@@ -15,7 +15,7 @@
            if (context != null)
            {
                if (context.Request.HttpMethod == HttpMethod.Post.ToString() && context.Request.ContentLength > 200000)
                if (context.Request.HttpMethod == HttpMethod.Post.ToString() && context.Request.ContentLength > 102400)
                {
                    return false;
                }
ExportMap/up.html
@@ -510,7 +510,8 @@
  </script>
</head>
<body>
  <form id="upForm" name="upForm" method="post" enctype="multipart/form-data" action="http://127.0.0.1:12316/file/upload">
  <!--<form id="upForm" name="upForm" method="post" enctype="multipart/form-data" action="http://127.0.0.1:12316/file/upload">-->
  <form id="upForm" name="upForm" method="post" enctype="multipart/form-data" action="Upload/Post?path=20230728">
    ä¸Šä¼ è·¯å¾„:<span id="pathSpan"></span>,当前令牌:<span id="tokenSpan"></span>
    <hr />
    <br />
@@ -588,6 +589,13 @@
    <input value="下载瓦片" type="button" onclick="downloadTiles();" />
    <hr />
    <br />
    ä¸Šä¼ æµ‹è¯•:
    <div>
      <label for="apifiles">请选择文件:</label>
      <input name="apifiles" type="file" multiple="multiple" />
      <input type="submit" value="Upload" />
    </div>
  </form>
  <br />
  <br />
JavaCode/JavaCode.csproj
@@ -32,6 +32,26 @@
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x64\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>true</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    <OutputPath>bin\x64\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>true</Prefer32Bit>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>