From ab9d9126ced7d6dac0e14c3ede5a49fdb7fc94df Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周三, 17 9月 2025 13:25:06 +0800 Subject: [PATCH] 代码初次提交 --- DEmon/WebWIPAPI/WebWIPAPI.csproj | 15 ++++- /dev/null | 38 ------------ DEmon/iWareCommon/iWareCommon.csproj | 1 DEmon/WebWIPAPI/Web.config | 10 +++ DEmon/WebWIPAPI/packages.config | 4 + DEmon/WebWIPAPI/Global.asax.cs | 5 + DEmon/WebWIPAPI/Controllers/MesIntegrController.cs | 11 ++- DEmon/WebWIPAPI/Utils/ClassHelper.cs | 39 +++++++++++++ 8 files changed, 77 insertions(+), 46 deletions(-) diff --git a/DEmon/WebWIPAPI/Controllers/MesIntegrController.cs b/DEmon/WebWIPAPI/Controllers/MesIntegrController.cs index 7a70f5b..0852c30 100644 --- a/DEmon/WebWIPAPI/Controllers/MesIntegrController.cs +++ b/DEmon/WebWIPAPI/Controllers/MesIntegrController.cs @@ -1,4 +1,5 @@ -锘縰sing iWareCommon.Common.Entity; +锘縰sing AutoMapper; +using iWareCommon.Common.Entity; using iWareCommon.Utils; using iWareDataCore.BASE.Entity; using iWareDataCore.BASE.Service; @@ -10,6 +11,7 @@ using System.Web.Mvc; using WebWIPAPI.Models; using WebWIPAPI.Properties; +using WebWIPAPI.Utils; using LogTextHelper = WebWIPAPI.Utils.LogTextHelper; namespace WebWIPAPI.Controllers @@ -86,7 +88,10 @@ //绗竴姝ワ細鍏堟柊澧炲埌鐗╂枡鍩虹琛� List<MaterialViewEntity> materials = new List<MaterialViewEntity>(); - materials = ClassHelper.RotationMapping<List<MaterialViewEntity>, List<MaterialViewForMesEntity>>(importMaterials); + + materials = ClassHelper.RotationMapping_Json<List<MaterialViewEntity>, List<MaterialViewForMesEntity>>(importMaterials); + + MaterialViewService.GetInstance().ImportExcelFromMes(materials, out msg); if (!string.IsNullOrEmpty(msg)) { @@ -104,7 +109,7 @@ string typeName = "鍏ュ簱"; List<InputMaterialEntity> inputmaterials = new List<InputMaterialEntity>(); - inputmaterials = ClassHelper.RotationMapping<List<InputMaterialEntity>, List<MaterialViewForMesEntity>>(importMaterials); + inputmaterials = ClassHelper.RotationMapping_Json<List<InputMaterialEntity>, List<MaterialViewForMesEntity>>(importMaterials); handler_importOutOrder(typeName, inputmaterials, out msg); #endregion diff --git a/DEmon/WebWIPAPI/Global.asax.cs b/DEmon/WebWIPAPI/Global.asax.cs index 89bcf80..eb6b8df 100644 --- a/DEmon/WebWIPAPI/Global.asax.cs +++ b/DEmon/WebWIPAPI/Global.asax.cs @@ -1,4 +1,5 @@ -锘縰sing System; +锘縰sing AutoMapper; +using System; using System.Collections.Generic; using System.Linq; using System.Web; @@ -19,6 +20,8 @@ WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); + + } } } \ No newline at end of file diff --git a/DEmon/WebWIPAPI/Utils/ClassHelper.cs b/DEmon/WebWIPAPI/Utils/ClassHelper.cs new file mode 100644 index 0000000..092c003 --- /dev/null +++ b/DEmon/WebWIPAPI/Utils/ClassHelper.cs @@ -0,0 +1,39 @@ +锘縰sing Newtonsoft.Json; + +namespace WebWIPAPI.Utils +{ + public class ClassHelper + { + ///// <summary> + ///// 瀹炰綋浜掕浆 + ///// </summary> + ///// <typeparam name="T">鏂拌浆鎹㈢殑瀹炰綋</typeparam> + ///// <typeparam name="S">瑕佽浆鎹㈢殑瀹炰綋</typeparam> + ///// <param name="s"></param> + ///// <returns></returns> + //public static T RotationMapping<T, S>(S s) + //{ + // T target = Activator.CreateInstance<T>(); + // var originalObj = s.GetType(); + // var targetObj = typeof(T); + // foreach (PropertyInfo original in originalObj.GetProperties()) + // { + // foreach (PropertyInfo t in targetObj.GetProperties()) + // { + // if (t.Name == original.Name) + // { + // t.SetValue(target, original.GetValue(s, null), null); + // } + // } + // } + // return target; + //} + public static T RotationMapping_Json<T, S>(S s) + { + var oldStr = JsonConvert.SerializeObject(s); + return JsonConvert.DeserializeObject<T>(oldStr); + } + + + } +} diff --git a/DEmon/WebWIPAPI/Web.config b/DEmon/WebWIPAPI/Web.config index 0c4d843..ec93dd0 100644 --- a/DEmon/WebWIPAPI/Web.config +++ b/DEmon/WebWIPAPI/Web.config @@ -40,4 +40,14 @@ <add name="DbModelLog" connectionString="data source=.;initial catalog=WGQ_WB19011_LOG;user id=sa;password=123abc.com;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" /> <add name="DbModelCore" connectionString="data source=.;initial catalog=WGQ_WB19011_CORE;user id=sa;password=123abc.com;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" /> </connectionStrings> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.8.1.0" newVersion="4.8.1.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> + + </configuration> diff --git a/DEmon/WebWIPAPI/WebWIPAPI.csproj b/DEmon/WebWIPAPI/WebWIPAPI.csproj index caab7a7..890fcab 100644 --- a/DEmon/WebWIPAPI/WebWIPAPI.csproj +++ b/DEmon/WebWIPAPI/WebWIPAPI.csproj @@ -41,6 +41,9 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="AutoMapper, Version=6.2.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL"> + <HintPath>..\packages\AutoMapper.6.2.0\lib\net45\AutoMapper.dll</HintPath> + </Reference> <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\dll\EntityFramework.dll</HintPath> @@ -49,9 +52,14 @@ <HintPath>..\dll\EntityFramework.SqlServer.dll</HintPath> </Reference> <Reference Include="Microsoft.CSharp" /> + <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> + <Reference Include="System.Runtime.Serialization" /> <Reference Include="System.Web.DynamicData" /> <Reference Include="System.Web.Entity" /> <Reference Include="System.Web.ApplicationServices" /> @@ -70,9 +78,6 @@ <Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Private>True</Private> <HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath> - </Reference> - <Reference Include="Newtonsoft.Json"> - <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath> </Reference> <Reference Include="System.Net.Http"> </Reference> @@ -127,6 +132,7 @@ <DesignTime>True</DesignTime> <DependentUpon>Resources.resx</DependentUpon> </Compile> + <Compile Include="Utils\ClassHelper.cs" /> <Compile Include="Utils\LogTextHelper.cs" /> </ItemGroup> <ItemGroup> @@ -165,6 +171,9 @@ <Name>iWareDataCore</Name> </ProjectReference> </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> <PropertyGroup> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> diff --git a/DEmon/WebWIPAPI/packages.config b/DEmon/WebWIPAPI/packages.config new file mode 100644 index 0000000..82ea0d4 --- /dev/null +++ b/DEmon/WebWIPAPI/packages.config @@ -0,0 +1,4 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="AutoMapper" version="6.2.0" targetFramework="net45" /> +</packages> \ No newline at end of file diff --git a/DEmon/iWareCommon/Utils/ClassHelper.cs b/DEmon/iWareCommon/Utils/ClassHelper.cs deleted file mode 100644 index 85fba25..0000000 --- a/DEmon/iWareCommon/Utils/ClassHelper.cs +++ /dev/null @@ -1,38 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Reflection; - -namespace iWareCommon.Utils -{ - public class ClassHelper - { - /// <summary> - /// 瀹炰綋浜掕浆 - /// </summary> - /// <typeparam name="T">鏂拌浆鎹㈢殑瀹炰綋</typeparam> - /// <typeparam name="S">瑕佽浆鎹㈢殑瀹炰綋</typeparam> - /// <param name="s"></param> - /// <returns></returns> - public static T RotationMapping<T, S>(S s) - { - T target = Activator.CreateInstance<T>(); - var originalObj = s.GetType(); - var targetObj = typeof(T); - foreach (PropertyInfo original in originalObj.GetProperties()) - { - foreach (PropertyInfo t in targetObj.GetProperties()) - { - if (t.Name == original.Name) - { - t.SetValue(target, original.GetValue(s, null), null); - } - } - } - return target; - } - - - - } -} diff --git a/DEmon/iWareCommon/iWareCommon.csproj b/DEmon/iWareCommon/iWareCommon.csproj index 88acdbf..ac80c0d 100644 --- a/DEmon/iWareCommon/iWareCommon.csproj +++ b/DEmon/iWareCommon/iWareCommon.csproj @@ -106,7 +106,6 @@ <DependentUpon>Resources.resx</DependentUpon> </Compile> <Compile Include="Utils\Base64Helper.cs" /> - <Compile Include="Utils\ClassHelper.cs" /> <Compile Include="Utils\DESHelper.cs" /> <Compile Include="Utils\EntityPropHelper.cs" /> <Compile Include="Utils\FileHelper.cs" /> -- Gitblit v1.9.3