Merge branch 'master' of http://47.104.102.122:3000/gaofei/HJGL_DS
This commit is contained in:
commit
4c1852dad8
|
|
@ -21,6 +21,8 @@
|
|||
<SccProvider>
|
||||
</SccProvider>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
@ -74,6 +76,39 @@
|
|||
<Reference Include="ICSharpCode.SharpZipLib, Version=1.3.2.10, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SharpZipLib.1.3.2\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\netstandard2.0\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Configuration.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Configuration.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Configuration.Binder, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Configuration.Binder.6.0.0\lib\net461\Microsoft.Extensions.Configuration.Binder.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.6.0.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Http, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Http.6.0.0\lib\net461\Microsoft.Extensions.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Logging.6.0.0\lib\net461\Microsoft.Extensions.Logging.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Options, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Options.6.0.0\lib\net461\Microsoft.Extensions.Options.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Options.ConfigurationExtensions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Options.ConfigurationExtensions.6.0.0\lib\net461\Microsoft.Extensions.Options.ConfigurationExtensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Primitives.6.0.0\lib\net461\Microsoft.Extensions.Primitives.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.SQLServer.ManagedDTS, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Lib\Microsoft.SQLServer.ManagedDTS.dll</HintPath>
|
||||
|
|
@ -94,17 +129,47 @@
|
|||
<HintPath>..\packages\NPOI.2.5.5\lib\net45\NPOI.OpenXmlFormats.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.Linq" />
|
||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.6.0.0\lib\net461\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.DirectoryServices" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Net.Http">
|
||||
<HintPath>E:\工作\集团子公司\CNCEC_SUBQHSE\SUBQHSE\BLL\bin\Debug\System.Net.Http.dll</HintPath>
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
<Reference Include="System.Net.Http.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Net.Http.Json.8.0.0\lib\netstandard2.0\System.Net.Http.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Caching" />
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encodings.Web.8.0.0\lib\netstandard2.0\System.Text.Encodings.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Json.8.0.0\lib\netstandard2.0\System.Text.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.DataVisualization" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
|
|
@ -344,6 +409,13 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets" Condition="Exists('..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
|
||||
|
|
@ -65,8 +65,18 @@ namespace FineUIPro.Web.HJGL.DataIn
|
|||
ViewState["dtOther"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DataTable dtIsoInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return (DataTable)ViewState["dtIsoInfo"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["dtIsoInfo"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
|
|
@ -132,7 +142,7 @@ namespace FineUIPro.Web.HJGL.DataIn
|
|||
fileName = row["text"].ToString();
|
||||
}
|
||||
}
|
||||
outputPath = $"{outputPath}/" + fileName + dic[key].IndexOf(i) + ".pdf";
|
||||
outputPath = $"{outputPath}/" + fileName + DateTime.Now.ToString("yyyyMMddHHmm") + ".pdf";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -212,12 +222,27 @@ namespace FineUIPro.Web.HJGL.DataIn
|
|||
}
|
||||
|
||||
isoInfo.PipeLineLength = length;
|
||||
Funs.DB.SubmitChanges();
|
||||
|
||||
}
|
||||
DataRow[] rowsPipe = dtIsoInfo.Select(" pipeline_id='" + isono + "' ");
|
||||
if (rows != null && rows.Length > 0)
|
||||
{
|
||||
string isNeedHead = rows[0]["post_weld_heat_treatment"].ToString();
|
||||
if (isNeedHead == "N")
|
||||
{
|
||||
isoInfo.IsHot = "0";
|
||||
isoInfo.IsHotType = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
isoInfo.IsHot = "1";
|
||||
}
|
||||
|
||||
//保存文件到附件
|
||||
|
||||
UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(outputPath.Replace(rootPath, ""), 10, null), outputPath.Replace(rootPath, ""), Const.HJGL_PipelineManageMenuId, isoInfo.ISO_ID);
|
||||
} Funs.DB.SubmitChanges();
|
||||
//保存文件到附件
|
||||
|
||||
UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(outputPath.Replace(rootPath, ""), 10, null), outputPath.Replace(rootPath, ""), Const.HJGL_PipelineManageMenuId, isoInfo.ISO_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -295,6 +320,7 @@ namespace FineUIPro.Web.HJGL.DataIn
|
|||
JObject jobject = JObject.Parse(resultdata.Value);
|
||||
JArray jArray = jobject.Value<JArray>("material_rows");
|
||||
JArray jArrayOther = jobject.Value<JArray>("other_regions");
|
||||
JArray jArrayIsoInfo = jobject.Value<JArray>("drawing_info");
|
||||
dt = new DataTable();
|
||||
dt.Columns.Add("id");
|
||||
dt.Columns.Add("pipe_no");
|
||||
|
|
@ -314,6 +340,25 @@ namespace FineUIPro.Web.HJGL.DataIn
|
|||
dtOther.Columns.Add("page");
|
||||
dtOther.Columns.Add("text");
|
||||
|
||||
|
||||
dtIsoInfo = new DataTable();
|
||||
dtIsoInfo.Columns.Add("id");
|
||||
dtIsoInfo.Columns.Add("page_no");
|
||||
dtIsoInfo.Columns.Add("drawing_number");
|
||||
dtIsoInfo.Columns.Add("pipeline_id");
|
||||
dtIsoInfo.Columns.Add("operation_pressure_mpa");
|
||||
dtIsoInfo.Columns.Add("operation_temp_c");
|
||||
dtIsoInfo.Columns.Add("design_pressure_mpa");
|
||||
dtIsoInfo.Columns.Add("design_temp_c");
|
||||
dtIsoInfo.Columns.Add("test_pressure_mpa");
|
||||
dtIsoInfo.Columns.Add("hydraulic_test_pressure");
|
||||
dtIsoInfo.Columns.Add("pipe_diameter_dn");
|
||||
dtIsoInfo.Columns.Add("pipe_spec_grade");
|
||||
dtIsoInfo.Columns.Add("heat_insulation");
|
||||
dtIsoInfo.Columns.Add("insulation_thickness_mm");
|
||||
dtIsoInfo.Columns.Add("post_weld_heat_treatment");
|
||||
dtIsoInfo.Columns.Add("radiographic_examination");
|
||||
|
||||
// 遍历并提取数据
|
||||
foreach (JObject item in jArray)
|
||||
{
|
||||
|
|
@ -341,6 +386,29 @@ namespace FineUIPro.Web.HJGL.DataIn
|
|||
row["text"] = item.Value<string>("text");
|
||||
dtOther.Rows.Add(row);
|
||||
}
|
||||
|
||||
foreach (JObject item in jArrayIsoInfo)
|
||||
{
|
||||
|
||||
|
||||
var row = dtIsoInfo.NewRow();
|
||||
row["id"] = item.Value<string>("id");
|
||||
row["page_no"] = item.Value<string>("page_no");
|
||||
row["drawing_number"] = item.Value<string>("drawing_number");
|
||||
row["pipeline_id"] = item.Value<string>("pipeline_id");
|
||||
row["operation_temp_c"] = item.Value<string>("operation_temp_c");
|
||||
row["design_pressure_mpa"] = item.Value<string>("design_pressure_mpa");
|
||||
row["design_temp_c"] = item.Value<string>("design_temp_c");
|
||||
row["test_pressure_mpa"] = item.Value<string>("test_pressure_mpa");
|
||||
row["hydraulic_test_pressure"] = item.Value<string>("hydraulic_test_pressure");
|
||||
row["pipe_diameter_dn"] = item.Value<string>("pipe_diameter_dn");
|
||||
row["pipe_spec_grade"] = item.Value<string>("pipe_spec_grade");
|
||||
row["heat_insulation"] = item.Value<string>("heat_insulation");
|
||||
row["insulation_thickness_mm"] = item.Value<string>("insulation_thickness_mm");
|
||||
row["post_weld_heat_treatment"] = item.Value<string>("post_weld_heat_treatment");
|
||||
row["radiographic_examination"] = item.Value<string>("radiographic_examination");
|
||||
dtIsoInfo.Rows.Add(row);
|
||||
}
|
||||
BindGrid();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,14 +228,25 @@ namespace FineUIPro.Web.HJGL.DataIn
|
|||
|
||||
foreach (JToken rowData in dynamicObj["rows"])
|
||||
{
|
||||
int index = 0;
|
||||
// int index = 0;
|
||||
var row = dtAfterProcess.NewRow();
|
||||
var datas = rowData.ToList();
|
||||
row["Id"] = Guid.NewGuid().ToString();
|
||||
foreach (var d in datas)
|
||||
|
||||
foreach(DataRow row1 in dtTemp.Rows)
|
||||
{
|
||||
row[index] = d.ToString(); index++;
|
||||
if (datas[0].ToString() == row1[0].ToString())
|
||||
{
|
||||
for(int index = 0; index < dtTemp.Columns.Count; index++)
|
||||
{
|
||||
row[index] = row1[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
//foreach (var d in datas)
|
||||
//{
|
||||
// row[index] = d.ToString(); index++;
|
||||
//}
|
||||
dtAfterProcess.Rows.Add(row);
|
||||
}
|
||||
grid1.DataSource = dtAfterProcess;
|
||||
|
|
@ -518,63 +529,126 @@ namespace FineUIPro.Web.HJGL.DataIn
|
|||
/// <returns>服务器返回的响应内容</returns>
|
||||
public static string UploadCsvFile(string csvContent, string uploadUrl, string fileName, int timeout = 300000)
|
||||
{
|
||||
|
||||
|
||||
// 定义分隔符(随机生成避免冲突)
|
||||
string boundary = "----WebKitFormBoundary" + Guid.NewGuid().ToString("N");
|
||||
byte[] boundaryBytes = Encoding.UTF8.GetBytes("\r\n--" + boundary + "\r\n");
|
||||
|
||||
// 创建内存流存储请求内容
|
||||
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
void WriteString(string text)
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(text);
|
||||
ms.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
// 构建请求体
|
||||
WriteString($"--{boundary}\r\n");
|
||||
WriteString($"Content-Disposition: form-data; name=\"file\"; filename=\"{fileName}\"\r\n");
|
||||
WriteString("Content-Type: text/csv\r\n");
|
||||
WriteString("\r\n");
|
||||
WriteString(csvContent);
|
||||
WriteString("\r\n");
|
||||
|
||||
string header = $"--{boundary}\r\nContent-Disposition: form-data; name=\"extra instructions\"\r\n\r\n注意数据不要少列,不要串列\r\n";
|
||||
byte[] headerBytes = Encoding.UTF8.GetBytes (header);
|
||||
ms.Write(headerBytes, 0, headerBytes.Length);
|
||||
// 1. 写入表单字段头
|
||||
ms.Write(boundaryBytes, 0, boundaryBytes.Length);
|
||||
WriteString($"--{boundary}\r\n");
|
||||
WriteString("Content-Disposition: form-data; name=\"extra_instructions\"\r\n");
|
||||
WriteString("\r\n");
|
||||
WriteString($"注意数据不要少列\r\n");
|
||||
|
||||
// 2. 写入文件内容头
|
||||
string fileHeader =
|
||||
$"Content-Disposition: form-data; name=\"file\"; filename=\"{fileName}\"\r\n" +
|
||||
"Content-Type: text/csv; charset=utf-8\r\n\r\n";
|
||||
byte[] fileHeaderBytes = Encoding.UTF8.GetBytes(fileHeader);
|
||||
ms.Write(fileHeaderBytes, 0, fileHeaderBytes.Length);
|
||||
WriteString($"--{boundary}--\r\n");
|
||||
|
||||
// 3. 写入CSV内容
|
||||
byte[] csvBytes = Encoding.UTF8.GetBytes(csvContent);
|
||||
ms.Write(csvBytes, 0, csvBytes.Length);
|
||||
|
||||
// 4. 写入结束边界
|
||||
byte[] endBoundaryBytes = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n");
|
||||
ms.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
|
||||
|
||||
|
||||
|
||||
// 5. 创建HTTP请求
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uploadUrl);
|
||||
request.Method = "POST";
|
||||
request.ContentType = "multipart/form-data; boundary=" + boundary;
|
||||
request.ContentType = $"multipart/form-data; boundary={boundary}";
|
||||
request.ContentLength = ms.Length;
|
||||
request.Accept = "application/json";
|
||||
request.Timeout = timeout;
|
||||
request.KeepAlive = true;
|
||||
|
||||
// 6. 写入请求数据
|
||||
using (Stream requestStream = request.GetRequestStream())
|
||||
try
|
||||
{
|
||||
ms.Position = 0;
|
||||
ms.CopyTo(requestStream);
|
||||
// 发送数据
|
||||
using (Stream requestStream = request.GetRequestStream())
|
||||
{
|
||||
ms.Position = 0;
|
||||
ms.CopyTo(requestStream);
|
||||
}
|
||||
|
||||
// 获取响应
|
||||
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||
using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
|
||||
{
|
||||
string responseText = reader.ReadToEnd();
|
||||
return responseText;
|
||||
}
|
||||
}
|
||||
|
||||
// 7. 获取响应
|
||||
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||
using (Stream responseStream = response.GetResponseStream())
|
||||
using (StreamReader reader = new StreamReader(responseStream, Encoding.UTF8))
|
||||
catch (WebException ex)
|
||||
{
|
||||
return reader.ReadToEnd();
|
||||
// 处理HTTP错误
|
||||
if (ex.Response != null)
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(ex.Response.GetResponseStream(), Encoding.UTF8))
|
||||
{
|
||||
string errorText = reader.ReadToEnd();
|
||||
throw new Exception($"HTTP错误: {errorText}", ex);
|
||||
}
|
||||
}
|
||||
throw new Exception($"网络错误: {ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// 定义分隔符(随机生成避免冲突)
|
||||
//string boundary = "----WebKitFormBoundary" + Guid.NewGuid().ToString("N");
|
||||
//byte[] boundaryBytes = Encoding.UTF8.GetBytes("\r\n--" + boundary + "\r\n");
|
||||
|
||||
//// 创建内存流存储请求内容
|
||||
//using (MemoryStream ms = new MemoryStream())
|
||||
//{
|
||||
|
||||
|
||||
// string header = $"--{boundary}\r\nContent-Disposition: form-data; name=\"extra_instructions\"\r\n\r\n注意数据不要少列,不要串列\r\n";
|
||||
// byte[] headerBytes = Encoding.UTF8.GetBytes (header);
|
||||
// ms.Write(headerBytes, 0, headerBytes.Length);
|
||||
// // 1. 写入表单字段头
|
||||
// ms.Write(boundaryBytes, 0, boundaryBytes.Length);
|
||||
|
||||
// // 2. 写入文件内容头
|
||||
// string fileHeader =
|
||||
// $"Content-Disposition: form-data; name=\"file\"; filename=\"{fileName}\"\r\n" +
|
||||
// "Content-Type: text/csv; charset=utf-8\r\n\r\n";
|
||||
// byte[] fileHeaderBytes = Encoding.UTF8.GetBytes(fileHeader);
|
||||
// ms.Write(fileHeaderBytes, 0, fileHeaderBytes.Length);
|
||||
|
||||
// // 3. 写入CSV内容
|
||||
// byte[] csvBytes = Encoding.UTF8.GetBytes(csvContent);
|
||||
// ms.Write(csvBytes, 0, csvBytes.Length);
|
||||
|
||||
// // 4. 写入结束边界
|
||||
// byte[] endBoundaryBytes = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n");
|
||||
// ms.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
|
||||
|
||||
|
||||
|
||||
// // 5. 创建HTTP请求
|
||||
// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uploadUrl);
|
||||
// request.Method = "POST";
|
||||
// request.ContentType = "multipart/form-data; boundary=" + boundary;
|
||||
// request.ContentLength = ms.Length;
|
||||
// request.Timeout = timeout;
|
||||
// request.KeepAlive = true;
|
||||
|
||||
// // 6. 写入请求数据
|
||||
// using (Stream requestStream = request.GetRequestStream())
|
||||
// {
|
||||
// ms.Position = 0;
|
||||
// ms.CopyTo(requestStream);
|
||||
// }
|
||||
|
||||
// // 7. 获取响应
|
||||
// using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||
// using (Stream responseStream = response.GetResponseStream())
|
||||
// using (StreamReader reader = new StreamReader(responseStream, Encoding.UTF8))
|
||||
// {
|
||||
// return reader.ReadToEnd();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -268,6 +268,10 @@
|
|||
<Project>{fd1e1931-1688-4b4a-bcd6-335a81465343}</Project>
|
||||
<Name>Model</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\SgManager.AI\SgManager.AI.csproj">
|
||||
<Project>{55f4e1e2-5fb3-4ab4-b692-432ce41b3e61}</Project>
|
||||
<Name>SgManager.AI</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@
|
|||
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net461" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net461" />
|
||||
<package id="Modernizr" version="2.8.3" targetFramework="net461" />
|
||||
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net461" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" />
|
||||
<package id="WebGrease" version="1.6.0" targetFramework="net461" />
|
||||
</packages>
|
||||
Loading…
Reference in New Issue