From fff9a5065058cc5aedfcb2381733c1d17a22c8f3 Mon Sep 17 00:00:00 2001 From: clovejunti Date: Thu, 30 May 2024 23:52:57 +0800 Subject: [PATCH] 4 --- DeviceRepair.Api/App_Start/Startup.Auth.cs | 2 + .../Controllers/CommonController.cs | 20 ++ .../Controllers/MaintenanceController.cs | 255 ++--------------- .../CustomAttribute/HttpAuthorizeAttribute.cs | 85 +----- DeviceRepair.Api/DeviceRepair.Api.csproj | 15 +- .../PublishProfiles/FolderProfile.pubxml | 3 +- .../PublishProfiles/FolderProfile.pubxml.user | 42 ++- DeviceRepair.Api/Runtime.cs | 9 + DeviceRepair.Api/Web.config | 5 +- DeviceRepair.Api/packages.config | 17 +- DeviceRepair.DataAccess/DbContext.cs | 41 ++- .../DeviceRepair.DataAccess.csproj | 1 + DeviceRepair.DataAccess/SystemUtil.cs | 35 +++ DeviceRepair.DataAccess/TsSFCAccess.cs | 133 +++++++++ DeviceRepair.DataAccess/app.config | 2 +- .../Common/SysEmailConfigInfo.cs | 77 ++++++ .../DeviceRepair.Models.csproj | 9 +- .../SFC/Addon/ResourceAllocationsInfo.cs | 49 ++++ DeviceRepair.Models/SFC/Addon/StaffsInfo.cs | 85 ++++++ .../SFC/Addon/UserPostsInfo.cs | 49 ++++ DeviceRepair.Models/SFC/Data/InspBatchInfo.cs | 261 ++++++++++++++++++ DeviceRepair.Models/app.config | 2 +- DeviceRepair.Models/packages.config | 2 +- DeviceRepair.Utils/Config/ConfigProperties.cs | 4 + DeviceRepair.Utils/app.config | 2 +- DeviceRepairAndOptimization.sln | 4 +- DeviceRepairAndOptimization/App.config | 2 +- .../DeviceRepairAndOptimization.csproj | 5 +- DeviceRepairAndOptimization/packages.config | 2 +- Intend/App.config | 2 +- Intend/Intend.csproj | 4 +- Intend/packages.config | 2 +- SqlSugarTest/App.config | 10 +- Test/App.config | 10 +- Test/Test.csproj | 4 +- Test/packages.config | 2 +- TsSFCDeivceClient/Biz/HttpHelper.cs | 4 +- TsSFCDeivceClient/DeviceApiUrlConstValue.cs | 12 +- TsSFCDeivceClient/DowntimeFormAdd.cs | 112 ++++---- TsSFCDeivceClient/DowntimeFormAdd.designer.cs | 1 + TsSFCDeivceClient/Model/UserInfo.cs | 2 - .../Properties/Resources.Designer.cs | 65 ++--- TsSFCDeivceClient/Properties/Resources.resx | 17 +- TsSFCDeivceClient/Resources/Maintenance.png | 3 + TsSFCDeivceClient/TsSFCDeivceClient.csproj | 69 +++-- TsSFCDeivceClient/pageDeivceView.cs | 9 +- TsSFCDeivceClient/pageDeivceView.designer.cs | 21 +- .../pageDeviceMaintenanceFormView.cs | 177 ++++++++---- .../pageDeviceMaintenanceFormView.designer.cs | 3 +- 49 files changed, 1188 insertions(+), 559 deletions(-) create mode 100644 DeviceRepair.Api/Runtime.cs create mode 100644 DeviceRepair.DataAccess/TsSFCAccess.cs create mode 100644 DeviceRepair.Models/Common/SysEmailConfigInfo.cs create mode 100644 DeviceRepair.Models/SFC/Addon/ResourceAllocationsInfo.cs create mode 100644 DeviceRepair.Models/SFC/Addon/StaffsInfo.cs create mode 100644 DeviceRepair.Models/SFC/Addon/UserPostsInfo.cs create mode 100644 DeviceRepair.Models/SFC/Data/InspBatchInfo.cs create mode 100644 TsSFCDeivceClient/Resources/Maintenance.png diff --git a/DeviceRepair.Api/App_Start/Startup.Auth.cs b/DeviceRepair.Api/App_Start/Startup.Auth.cs index 44d46b1..8518f77 100644 --- a/DeviceRepair.Api/App_Start/Startup.Auth.cs +++ b/DeviceRepair.Api/App_Start/Startup.Auth.cs @@ -46,6 +46,8 @@ namespace DeviceRepair.Api // 使应用程序可以使用不记名令牌来验证用户身份 app.UseOAuthBearerTokens(OAuthOptions); + + // 取消注释以下行可允许使用第三方登录提供程序登录 //app.UseMicrosoftAccountAuthentication( // clientId: "", diff --git a/DeviceRepair.Api/Controllers/CommonController.cs b/DeviceRepair.Api/Controllers/CommonController.cs index 26d35c3..edd9da1 100644 --- a/DeviceRepair.Api/Controllers/CommonController.cs +++ b/DeviceRepair.Api/Controllers/CommonController.cs @@ -123,5 +123,25 @@ namespace DeviceRepair.Api.Controllers return response; } + /// + /// 获取邮箱配置 + /// + /// + /// + [HttpGet, Route("sysEmailConfigByModuleCode"), HttpAuthorize] + public APIResponseData sysEmailConfigByModuleCode(string ModuleCode) + { + APIResponseData apiResponseData = new APIResponseData { Code = -1, Message = "未能获取到数据" }; + try + { + apiResponseData = SystemUtil.Instance.sysEmailConfigByModuleCode(ModuleCode); + } + catch (Exception ex) + { + apiResponseData.Code = -1; + apiResponseData.Message = ex.Message; + } + return apiResponseData; + } } } diff --git a/DeviceRepair.Api/Controllers/MaintenanceController.cs b/DeviceRepair.Api/Controllers/MaintenanceController.cs index 644f8c8..4a0cc0b 100644 --- a/DeviceRepair.Api/Controllers/MaintenanceController.cs +++ b/DeviceRepair.Api/Controllers/MaintenanceController.cs @@ -2,17 +2,8 @@ using DeviceRepair.Api.CustomAttribute; using DeviceRepair.DataAccess; using DeviceRepair.Models; -using DeviceRepair.Models.Common; -using DeviceRepair.Utils; -using Newtonsoft.Json.Linq; using System; -using System.Data; -using System.Net.Http; -using System.Text; using System.Web.Http; -using System.Xml; -using System.Linq; -using System.Collections.Generic; namespace DeviceRepair.Api.Controllers { @@ -183,245 +174,38 @@ namespace DeviceRepair.Api.Controllers /// /// /// - [HttpPost, HttpAuthorize, Route("GetBatchInfoToStaff")] - public APIResponseData GetBatchInfoToStaff(SfcParams Params) + [HttpGet, HttpAuthorize, Route("GetBatchInfoToStaff")] + public APIResponseData GetBatchInfoToStaff(string Batch) { APIResponseData apiResponseData = new APIResponseData { Code = -1, Message = "获取失败!" }; try { - string SFCWebServiceUrl = Utils.Config.Configurations.Properties.SFCWebServiceUrl; - bool isSuccess = false; - byte[] password = Encoding.Unicode.GetBytes(Params.LoginCode); - Array.Reverse(password); - string pass64 = Convert.ToBase64String(password); - if (pass64.Length < 10) - pass64 += "YeT+=fue"; - - StringBuilder builder = new StringBuilder(); - builder.AppendLine($""); - builder.AppendLine($""); - builder.AppendLine($" "); - builder.AppendLine($" "); - builder.AppendLine($" {pass64}"); - builder.AppendLine($" {Params.LoginCode}"); - builder.AppendLine($" "); - builder.AppendLine($" "); - builder.AppendLine($" "); - builder.AppendLine($" "); - builder.AppendLine($" {Params.inParams}"); - builder.AppendLine($" "); - builder.AppendLine($" "); - builder.AppendLine($""); - - using (var client = new HttpClient()) - { - var content = new StringContent(builder.ToString(), Encoding.UTF8, "text/xml"); - var request = new HttpRequestMessage(HttpMethod.Post, $"{SFCWebServiceUrl}/SfcService.asmx"); - request.Content = content; - - var response = client.SendAsync(request).Result; - if (response.IsSuccessStatusCode) - { - string stringRtn = response.Content.ReadAsStringAsync().Result; - - XmlDocument doc = new XmlDocument(); - doc.LoadXml(stringRtn); - XmlNode Node = doc.DocumentElement["soap:Body"]["GetBatchInfoToStaffResponse"]["GetBatchInfoToStaffResult"]["Code"].LastChild; - - if (Node.Value == "0") - { - Node = doc.DocumentElement["soap:Body"]["GetBatchInfoToStaffResponse"]["btResults"].LastChild; - byte[] bytes = Convert.FromBase64String(Node.Value); - DataSet ds = bytes.ExactDataSet(); - isSuccess = ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0; - - if (isSuccess) - return new APIResponseData { Code = 1, Data = ds.Tables[0] }; - } - else - { - Node = doc.DocumentElement["soap:Body"]["GetBatchInfoToStaffResponse"]["GetBatchInfoToStaffResult"]["Msg"].LastChild; - return new APIResponseData { Code = -1, Message = Node.Value }; - } - - } - } + return TsSFCAccess.Instance.GetBatchInfoToStaff(Batch); } catch (Exception ex) { + apiResponseData.Code = -1; apiResponseData.Message = ex.Message; } return apiResponseData; } - ///// - ///// 获取PE QE 信息 - ///// - ///// - ///// - //[HttpPost, HttpAuthorize, Route("ProductResourceAllocationsGet")] - //public APIResponseData ProductResourceAllocationsGet(SfcParams Params) - //{ - // APIResponseData apiResponseData = new APIResponseData { Code = -1, Message = "获取失败!" }; - // try - // { - // string SFCWebServiceUrl = Utils.Config.Configurations.Properties.SFCWebServiceUrl; - // bool isSuccess = false; - // byte[] password = Encoding.Unicode.GetBytes(Params.LoginCode); - // Array.Reverse(password); - // string pass64 = Convert.ToBase64String(password); - // if (pass64.Length < 10) - // pass64 += "YeT+=fue"; - - // StringBuilder builder = new StringBuilder(); - // builder.AppendLine($""); - // builder.AppendLine($""); - // builder.AppendLine($" "); - // builder.AppendLine($" "); - // builder.AppendLine($" {pass64}"); - // builder.AppendLine($" {Params.LoginCode}"); - // builder.AppendLine($" "); - // builder.AppendLine($" "); - // builder.AppendLine($" "); - // builder.AppendLine($" "); - // builder.AppendLine($" {Params.inParams}"); - // builder.AppendLine($" "); - // builder.AppendLine($" "); - // builder.AppendLine($""); - - // using (var client = new HttpClient()) - // { - // var content = new StringContent(builder.ToString(), Encoding.UTF8, "text/xml"); - // var request = new HttpRequestMessage(HttpMethod.Post, $"{SFCWebServiceUrl}/SfcAddon.asmx"); - // request.Content = content; - - // var response = client.SendAsync(request).Result; - // if (response.IsSuccessStatusCode) - // { - // string stringRtn = response.Content.ReadAsStringAsync().Result; - - // XmlDocument doc = new XmlDocument(); - // doc.LoadXml(stringRtn); - // XmlNode Node = doc.DocumentElement["soap:Body"]["ProductResourceAllocationsGetResponse"]["ProductResourceAllocationsGetResult"]["Code"].LastChild; - - // if (Node.Value == "0") - // { - // Node = doc.DocumentElement["soap:Body"]["ProductResourceAllocationsGetResponse"]["btResults"].LastChild; - // byte[] bytes = Convert.FromBase64String(Node.Value); - // DataSet ds = bytes.ExactDataSet(); - // isSuccess = ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0; - - // if (isSuccess) - // { - // APIResponseData s = StaffsDatasGet(Params); - // if (s.IsSuccess) - // { - // DataTable t2 = s.Data as DataTable; - // Guid[] staffs = ds.Tables[0].AsEnumerable().Select(x => x.Field("Staff")).ToArray(); - // var query = from row in t2.AsEnumerable() - // where staffs.Contains(row.Field("GUID")) - // select row.Field("EMail"); - - // //t2.AsEnumerable().Where(x=>x.Field<"">) - - // return new APIResponseData { Code = 1, Data = ds }; - // } - // else - // { - // return new APIResponseData { Code = -1, Message = s.Message }; - // } - // } - // } - // else - // { - // Node = doc.DocumentElement["soap:Body"]["ProductResourceAllocationsGetResponse"]["ProductResourceAllocationsGetResult"]["Msg"].LastChild; - // return new APIResponseData { Code = -1, Message = Node.Value }; - // } - // } - // } - // } - // catch (Exception ex) - // { - // apiResponseData.Message = ex.Message; - // } - // return apiResponseData; - //} - /// - /// 获取PE QE 信息 + /// 获取当前批次的QE PE邮箱 /// /// /// - [HttpPost, HttpAuthorize, Route("ProductResourceAllocationsGet")] - public APIResponseData ProductResourceAllocationsGet(SfcParams Params) + [HttpGet, HttpAuthorize, Route("CurrentBatchManagerEmail")] + public APIResponseData CurrentBatchManagerEmail(string Batch) { APIResponseData apiResponseData = new APIResponseData { Code = -1, Message = "获取失败!" }; try { - JObject js = JObject.Parse(Params.inParams); - js.Add("UserCode", ""); - js.Add("UserName", ""); - js.Add("Post", ""); - - string SFCWebServiceUrl = Utils.Config.Configurations.Properties.SFCWebServiceUrl; - bool isSuccess = false; - byte[] password = Encoding.Unicode.GetBytes(Params.LoginCode); - Array.Reverse(password); - string pass64 = Convert.ToBase64String(password); - if (pass64.Length < 10) - pass64 += "YeT+=fue"; - - StringBuilder builder = new StringBuilder(); - builder.AppendLine($""); - builder.AppendLine($""); - builder.AppendLine($" "); - builder.AppendLine($" "); - builder.AppendLine($" {pass64}"); - builder.AppendLine($" {Params.LoginCode}"); - builder.AppendLine($" "); - builder.AppendLine($" "); - builder.AppendLine($" "); - builder.AppendLine($" "); - builder.AppendLine($" {js.ToString()}"); - builder.AppendLine($" "); - builder.AppendLine($" "); - builder.AppendLine($""); - - using (var client = new HttpClient()) - { - var content = new StringContent(builder.ToString(), Encoding.UTF8, "text/xml"); - var request = new HttpRequestMessage(HttpMethod.Post, $"{SFCWebServiceUrl}/SfcAddon.asmx"); - request.Content = content; - - var response = client.SendAsync(request).Result; - if (response.IsSuccessStatusCode) - { - string stringRtn = response.Content.ReadAsStringAsync().Result; - - XmlDocument doc = new XmlDocument(); - doc.LoadXml(stringRtn); - XmlNode Node = doc.DocumentElement["soap:Body"]["StaffsDatasGetResponse"]["StaffsDatasGetResult"]["Code"].LastChild; - - if (Node.Value == "0") - { - Node = doc.DocumentElement["soap:Body"]["StaffsDatasGetResponse"]["btResults"].LastChild; - byte[] bytes = Convert.FromBase64String(Node.Value); - DataSet ds = bytes.ExactDataSet(); - isSuccess = ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0; - - if (isSuccess) - return new APIResponseData { Code = 1, Data = ds.Tables[0] }; - } - else - { - Node = doc.DocumentElement["soap:Body"]["StaffsDatasGetResponse"]["StaffsDatasGetResult"]["Msg"].LastChild; - return new APIResponseData { Code = -1, Message = Node.Value }; - } - } - } + return TsSFCAccess.Instance.CurrentBatchManagerEmail(Batch); } catch (Exception ex) { + apiResponseData.Code = -1; apiResponseData.Message = ex.Message; } return apiResponseData; @@ -447,5 +231,26 @@ namespace DeviceRepair.Api.Controllers } return apiResponseData; } + + /// + /// 判断当前账户是否PE QE + /// + /// + /// + [HttpGet, HttpAuthorize, Route("CurrentIsManager")] + public APIResponseData CurrentIsManager(string UserCode) + { + APIResponseData apiResponseData = new APIResponseData { Code = -1, Message = "查询失败!" }; + try + { + return TsSFCAccess.Instance.CurrentIsManager(UserCode); + } + catch (Exception ex) + { + apiResponseData.Code = -1; + apiResponseData.Message = ex.Message; + } + return apiResponseData; + } } } diff --git a/DeviceRepair.Api/CustomAttribute/HttpAuthorizeAttribute.cs b/DeviceRepair.Api/CustomAttribute/HttpAuthorizeAttribute.cs index bb89a88..5b5d566 100644 --- a/DeviceRepair.Api/CustomAttribute/HttpAuthorizeAttribute.cs +++ b/DeviceRepair.Api/CustomAttribute/HttpAuthorizeAttribute.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Net; using System.Net.Http; using System.Text; +using System.Web.Caching; using System.Web.Http; using System.Xml; @@ -53,8 +54,10 @@ namespace DeviceRepair.Api.CustomAttribute !string.IsNullOrWhiteSpace(model.LoginCode) && !string.IsNullOrWhiteSpace(model.Password) ) { - if (SfcUserValidate(model.LoginCode, model.Password, model.inParams)) + string @Value = Runtime.Cachce[model.LoginCode]?.ToString(); + if (desToken.Equals(Value) || SfcUserValidate(model.LoginCode, model.Password, model.inParams)) { + Runtime.Cachce.Add(model.LoginCode, desToken, null, DateTime.Now.AddMinutes(15), TimeSpan.Zero, CacheItemPriority.Normal, null); return; } } @@ -66,85 +69,6 @@ namespace DeviceRepair.Api.CustomAttribute } } - //IEnumerable token; - //if (actionContext.Request.Headers.TryGetValues("auth", out token)) - //{ - // if (token != null && token.Count() > 0) - // { - // try - // { - // TokenModel userInfo = null; - // foreach (string item in token) - // { - // userInfo = DecodeToObject(item); - // if (userInfo != null) - // break; - // } - - // if (userInfo != null) - // return; - // } - // catch (Exception ex) - // { - // throw ex; - // } - // } - // return; - //} - //else if (actionContext.Request.Headers.TryGetValues("inParams", out token)) - //{ - // if (token != null && token.Count() > 0) - // { - // try - // { - // IEnumerable LoginCode; - // IEnumerable Password; - // if (actionContext.Request.Headers.TryGetValues("LoginCode", out LoginCode) && - // actionContext.Request.Headers.TryGetValues("Password", out Password) && - // LoginCode != null && LoginCode.Count() > 0 - // && Password != null && Password.Count() > 0) - // { - // string inParams = string.Empty; - // string lc = string.Empty; - // string pwd = string.Empty; - - // foreach (string item in token) - // { - // if (!string.IsNullOrWhiteSpace(item)) - // { - // inParams = item; - // } - // } - - // foreach (string item in LoginCode) - // { - // if (!string.IsNullOrWhiteSpace(item)) - // { - // lc = item; - // } - // } - - // foreach (string item in Password) - // { - // if (!string.IsNullOrWhiteSpace(item)) - // { - // pwd = item; - // } - // } - - // bool isSuccess = SfcUserValidate(lc, pwd, inParams); - // if (isSuccess) - // return; - // } - // } - // catch (Exception ex) - // { - // throw ex; - // } - // } - // return; - //} - actionContext.Response = new HttpResponseMessage(HttpStatusCode.Unauthorized) { Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(Rtn), Encoding.UTF8, "application/json") }; return; } @@ -226,7 +150,6 @@ namespace DeviceRepair.Api.CustomAttribute } } - /// /// 通过token反序列化到对象 /// diff --git a/DeviceRepair.Api/DeviceRepair.Api.csproj b/DeviceRepair.Api/DeviceRepair.Api.csproj index f00aaae..46cda23 100644 --- a/DeviceRepair.Api/DeviceRepair.Api.csproj +++ b/DeviceRepair.Api/DeviceRepair.Api.csproj @@ -54,13 +54,23 @@ True - - ..\packages\Newtonsoft.Json.10.0.1\lib\net45\Newtonsoft.Json.dll + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.1.0.0\lib\netstandard1.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Options.1.0.0\lib\netstandard1.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.1.0.0\lib\netstandard1.0\Microsoft.Extensions.Primitives.dll + + + ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll ..\packages\sqlSugar.5.0.0\lib\SqlSugar.dll + @@ -235,6 +245,7 @@ + diff --git a/DeviceRepair.Api/Properties/PublishProfiles/FolderProfile.pubxml b/DeviceRepair.Api/Properties/PublishProfiles/FolderProfile.pubxml index afb8a6f..dc6d493 100644 --- a/DeviceRepair.Api/Properties/PublishProfiles/FolderProfile.pubxml +++ b/DeviceRepair.Api/Properties/PublishProfiles/FolderProfile.pubxml @@ -7,10 +7,11 @@ https://go.microsoft.com/fwlink/?LinkID=208121. False False True - Release + Debug Any CPU FileSystem C:\Users\Clove\Desktop\WebSite FileSystem + \ No newline at end of file diff --git a/DeviceRepair.Api/Properties/PublishProfiles/FolderProfile.pubxml.user b/DeviceRepair.Api/Properties/PublishProfiles/FolderProfile.pubxml.user index 9316c66..af0bc49 100644 --- a/DeviceRepair.Api/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/DeviceRepair.Api/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. <_PublishTargetUrl>C:\Users\Clove\Desktop\WebSite - True|2024-05-29T05:43:17.4797209Z; + True|2024-05-30T09:42:28.4008960Z;True|2024-05-30T17:35:13.0117556+08:00;True|2024-05-30T17:28:00.7834102+08:00;True|2024-05-30T17:10:05.9943745+08:00;True|2024-05-29T13:43:17.4797209+08:00; @@ -78,37 +78,37 @@ https://go.microsoft.com/fwlink/?LinkID=208121. 05/28/2024 22:39:54 - 05/30/2024 09:50:08 + 05/30/2024 17:35:12 - 05/30/2024 09:50:08 + 05/30/2024 17:35:12 - 05/30/2024 09:50:07 + 05/30/2024 17:06:52 - 05/21/2024 00:58:04 + 05/30/2024 11:42:20 - 05/30/2024 09:50:07 + 05/30/2024 17:06:52 - 05/30/2024 09:50:07 + 05/30/2024 17:06:52 - 04/16/2024 11:52:33 + 05/30/2024 11:42:20 - 05/30/2024 09:50:07 + 05/30/2024 17:06:52 - 05/30/2024 09:50:07 + 05/30/2024 17:06:52 - 05/21/2024 00:58:03 + 05/30/2024 11:42:20 - 05/30/2024 09:50:07 + 05/30/2024 17:06:52 05/28/2024 22:39:54 @@ -137,6 +137,15 @@ https://go.microsoft.com/fwlink/?LinkID=208121. 05/28/2024 22:39:56 + + 06/22/2016 17:14:56 + + + 06/22/2016 17:14:56 + + + 06/22/2016 17:14:56 + 05/28/2024 22:39:56 @@ -168,7 +177,10 @@ https://go.microsoft.com/fwlink/?LinkID=208121. 05/28/2024 22:39:57 - 05/28/2024 22:39:54 + 11/28/2018 02:07:34 + + + 11/28/2018 01:59:08 05/28/2024 22:39:58 @@ -345,7 +357,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. 04/16/2024 09:58:38 - 04/16/2024 10:35:55 + 05/30/2024 11:41:56 04/16/2024 09:58:39 @@ -402,7 +414,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. 04/16/2024 09:58:38 - 05/29/2024 13:43:16 + 05/30/2024 17:35:12 \ No newline at end of file diff --git a/DeviceRepair.Api/Runtime.cs b/DeviceRepair.Api/Runtime.cs new file mode 100644 index 0000000..0ae3b63 --- /dev/null +++ b/DeviceRepair.Api/Runtime.cs @@ -0,0 +1,9 @@ +using System.Web.Caching; + +namespace DeviceRepair.Api +{ + public static class Runtime + { + public static Cache @Cachce = new Cache(); + } +} \ No newline at end of file diff --git a/DeviceRepair.Api/Web.config b/DeviceRepair.Api/Web.config index 852e3b2..489791c 100644 --- a/DeviceRepair.Api/Web.config +++ b/DeviceRepair.Api/Web.config @@ -16,9 +16,10 @@ + - + @@ -56,7 +57,7 @@ - + diff --git a/DeviceRepair.Api/packages.config b/DeviceRepair.Api/packages.config index 18eceb2..e3855fd 100644 --- a/DeviceRepair.Api/packages.config +++ b/DeviceRepair.Api/packages.config @@ -32,6 +32,9 @@ + + + @@ -52,8 +55,20 @@ - + + + + + + + + + + + + + \ No newline at end of file diff --git a/DeviceRepair.DataAccess/DbContext.cs b/DeviceRepair.DataAccess/DbContext.cs index 8cad34f..b2e6e63 100644 --- a/DeviceRepair.DataAccess/DbContext.cs +++ b/DeviceRepair.DataAccess/DbContext.cs @@ -1,6 +1,7 @@ using SqlSugar; using System; using System.Collections.Generic; +using System.Data.SqlClient; using System.Diagnostics; using System.Linq; @@ -12,6 +13,8 @@ namespace DeviceRepair.DataAccess private static readonly string logConn = Utils.Config.Configurations.Properties.logConn; + private static readonly string sfc = Utils.Config.Configurations.Properties.SfcConn; + public SqlSugarClient db; //{ // get @@ -21,16 +24,16 @@ namespace DeviceRepair.DataAccess // { // ConnectionString = connectionString, // DbType = DbType.SqlServer, - // InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息 - // IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样我就不多解释了 + // InitKeyType = InitKeyType.Attribute, + // IsAutoCloseConnection = true, // ConfigId = "main" // }, // new ConnectionConfig() // { // ConnectionString = logConn, // DbType = DbType.SqlServer, - // InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息 - // IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样我就不多解释了 + // InitKeyType = InitKeyType.Attribute, + // IsAutoCloseConnection = true, // ConfigId = "log" // } // }); @@ -49,22 +52,44 @@ namespace DeviceRepair.DataAccess public DbContext() { + SqlConnectionStringBuilder TsSFCdb = new SqlConnectionStringBuilder(sfc); + TsSFCdb.InitialCatalog = "SFCData"; + string SFCData = TsSFCdb.ConnectionString; + TsSFCdb.InitialCatalog = "SFCAddOn"; + string SFCAddOn = TsSFCdb.ConnectionString; + db = new SqlSugarClient(new List { new ConnectionConfig() { ConnectionString = connectionString, DbType = DbType.SqlServer, - InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息 - IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样我就不多解释了 + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true, ConfigId = "main" }, new ConnectionConfig() { ConnectionString = logConn, DbType = DbType.SqlServer, - InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息 - IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样我就不多解释了 + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true, ConfigId = "log" + }, + new ConnectionConfig() + { + ConnectionString = SFCData, + DbType = DbType.SqlServer, + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true, + ConfigId = "data" + }, + new ConnectionConfig() + { + ConnectionString = SFCAddOn, + DbType = DbType.SqlServer, + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true, + ConfigId = "addon" } }); diff --git a/DeviceRepair.DataAccess/DeviceRepair.DataAccess.csproj b/DeviceRepair.DataAccess/DeviceRepair.DataAccess.csproj index 9a6bdf2..c49ee65 100644 --- a/DeviceRepair.DataAccess/DeviceRepair.DataAccess.csproj +++ b/DeviceRepair.DataAccess/DeviceRepair.DataAccess.csproj @@ -54,6 +54,7 @@ + diff --git a/DeviceRepair.DataAccess/SystemUtil.cs b/DeviceRepair.DataAccess/SystemUtil.cs index 0cf6df1..051f5dd 100644 --- a/DeviceRepair.DataAccess/SystemUtil.cs +++ b/DeviceRepair.DataAccess/SystemUtil.cs @@ -1,4 +1,5 @@ using DeviceRepair.Models; +using DeviceRepair.Models.Common; using SqlSugar; using System; using System.Collections.Generic; @@ -152,6 +153,40 @@ namespace DeviceRepair.DataAccess } return apiResponseData; } + + /// + /// 获取邮箱配置 + /// + /// + /// + public APIResponseData sysEmailConfigByModuleCode(string ModuleCode) + { + APIResponseData apiResponseData = new APIResponseData { Code = -1, Message = $"获取数据失败!" }; + try + { + if (string.IsNullOrWhiteSpace(ModuleCode)) + { + throw new Exception($"邮件模块编码不能为空!"); + } + + base.db.ChangeDatabase("main"); + SysEmailConfigInfo config = db.Queryable().First(x => x.MuduleCode == ModuleCode); + apiResponseData.Code = 1; + apiResponseData.Message = ""; + apiResponseData.Data = config; + } + catch (SqlSugarException ex) + { + apiResponseData.Code = -1; + apiResponseData.Message = ex.Message; + } + catch (Exception ex) + { + apiResponseData.Code = -1; + apiResponseData.Message = ex.Message; + } + return apiResponseData; + } } } diff --git a/DeviceRepair.DataAccess/TsSFCAccess.cs b/DeviceRepair.DataAccess/TsSFCAccess.cs new file mode 100644 index 0000000..a36d323 --- /dev/null +++ b/DeviceRepair.DataAccess/TsSFCAccess.cs @@ -0,0 +1,133 @@ +using DeviceRepair.Models; +using DeviceRepair.Models.SFC; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace DeviceRepair.DataAccess +{ + public class TsSFCAccess : DbContext + { + private static TsSFCAccess manager; + public static TsSFCAccess Instance + { + get + { + if (manager == null) + manager = new TsSFCAccess(); + return manager; + } + } + + /// + /// 判断批次是否存在 + /// + /// + /// + public APIResponseData GetBatchInfoToStaff(string Batch) + { + APIResponseData apiResponseData = new APIResponseData { Code = -1, Message = $"获取数据失败!" }; + try + { + db.ChangeDatabase("data"); + int Count = db.Queryable().Count(x => x.Batch.ToUpper().Equals(Batch.ToUpper())); + + apiResponseData.Code = 1; + apiResponseData.Message = ""; + apiResponseData.Data = Count; + } + catch (SqlSugarException ex) + { + apiResponseData.Code = -1; + apiResponseData.Message = ex.Message; + } + catch (Exception ex) + { + apiResponseData.Code = -1; + apiResponseData.Message = ex.Message; + } + return apiResponseData; + } + + /// + /// 判断当前账户是否PE QE + /// + /// + /// + /// + /// + public APIResponseData CurrentIsManager(string UserCode) + { + APIResponseData apiResponseData = new APIResponseData { Code = -1, Message = $"获取数据失败!" }; + try + { + db.ChangeDatabase("addon"); + int Count = db.Queryable().Count(x => x.UserCode == UserCode); + + apiResponseData.Code = 1; + apiResponseData.Message = ""; + apiResponseData.Data = Count; + } + catch (SqlSugarException ex) + { + apiResponseData.Code = -1; + apiResponseData.Message = ex.Message; + } + catch (Exception ex) + { + apiResponseData.Code = -1; + apiResponseData.Message = ex.Message; + } + return apiResponseData; + } + + /// + /// 获取当前批次的QE PE邮箱 + /// + /// + /// + public APIResponseData CurrentBatchManagerEmail(string Batch) + { + APIResponseData apiResponseData = new APIResponseData { Code = -1, Message = $"获取数据失败!" }; + List emailLst = new List(); + try + { + db.ChangeDatabase("data"); + InspBatchInfo BatchInfo = db.Queryable().First(x => x.Batch.ToUpper().Equals(Batch.ToUpper())); + if (BatchInfo != null) + { + db.ChangeDatabase("addon"); + List allocationsInfos = db.Queryable().Where(x => x.Product.Trim().Equals(BatchInfo.Product.ToUpper()) && + x.Technology.Trim().ToUpper() == BatchInfo.Technology.Trim().ToUpper()).ToList(); + + if (allocationsInfos != null) + { + Guid[] guids = allocationsInfos.Select(x => x.Staff).ToArray(); + List staffs = db.Queryable().Where(x => SqlFunc.ContainsArray(guids, x.Guid) && (x.Post == "0" || x.Post == "1")).ToList(); + if (staffs != null && staffs.Count > 0) + { + emailLst.AddRange(staffs.Select(x => x.EMail).ToArray()); + } + } + } + + apiResponseData.Code = 1; + apiResponseData.Message = ""; + apiResponseData.Data = emailLst; + } + catch (SqlSugarException ex) + { + apiResponseData.Code = -1; + apiResponseData.Message = ex.Message; + } + catch (Exception ex) + { + apiResponseData.Code = -1; + apiResponseData.Message = ex.Message; + } + return apiResponseData; + } + + } +} diff --git a/DeviceRepair.DataAccess/app.config b/DeviceRepair.DataAccess/app.config index dde2c3c..e936cc1 100644 --- a/DeviceRepair.DataAccess/app.config +++ b/DeviceRepair.DataAccess/app.config @@ -4,7 +4,7 @@ - + diff --git a/DeviceRepair.Models/Common/SysEmailConfigInfo.cs b/DeviceRepair.Models/Common/SysEmailConfigInfo.cs new file mode 100644 index 0000000..6b221ff --- /dev/null +++ b/DeviceRepair.Models/Common/SysEmailConfigInfo.cs @@ -0,0 +1,77 @@ +using SqlSugar; +using System; + +namespace DeviceRepair.Models.Common +{ + /// + /// 邮件配置表 + /// + [SugarTable("sysEmailConfig")] + public class SysEmailConfigInfo + { + /// + /// 主键编号 + /// + [SugarColumn(ColumnName = "AutoID", IsPrimaryKey = true, IsIdentity = true)] + public int AutoID { get; set; } + + /// + /// 唯一编号 + /// 默认值: (newid()) + /// + [SugarColumn(ColumnName = "GUID")] + public Guid Guid { get; set; } + + /// + /// 模块编码 + /// + [SugarColumn(ColumnName = "MuduleCode")] + public string MuduleCode { get; set; } + + /// + /// 邮箱账户 + /// + [SugarColumn(ColumnName = "EmailAddress")] + public string EmailAddress { get; set; } + + /// + /// 邮箱密码(Des加密) + /// + [SugarColumn(ColumnName = "EmailPassWord")] + public string EmailPassWord { get; set; } + + /// + /// 邮箱是否为无密码模式 + /// + [SugarColumn(ColumnName = "EmailNoPass")] + public bool EmailNoPass { get; set; } + + /// + /// 邮箱发件url + /// + [SugarColumn(ColumnName = "SmtpServer")] + public string SmtpServer { get; set; } + + /// + /// 邮箱发件端口 + /// + [SugarColumn(ColumnName = "SmtpPort")] + public int SmtpPort { get; set; } + + /// + /// 是否SSL加密 + /// + [SugarColumn(ColumnName = "SmtpSSL")] + public bool SmtpSSL { get; set; } + + /// + /// 状态 + /// C 创建 + /// A 激活 + /// L 锁定 + /// D 删除 + /// + [SugarColumn(ColumnName = "Status")] + public string Status { get; set; } + } +} diff --git a/DeviceRepair.Models/DeviceRepair.Models.csproj b/DeviceRepair.Models/DeviceRepair.Models.csproj index 6372177..61451bd 100644 --- a/DeviceRepair.Models/DeviceRepair.Models.csproj +++ b/DeviceRepair.Models/DeviceRepair.Models.csproj @@ -30,8 +30,8 @@ 4 - - ..\packages\Newtonsoft.Json.10.0.1\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll ..\packages\sqlSugar.5.0.0\lib\SqlSugar.dll @@ -59,6 +59,7 @@ + @@ -120,6 +121,10 @@ + + + + diff --git a/DeviceRepair.Models/SFC/Addon/ResourceAllocationsInfo.cs b/DeviceRepair.Models/SFC/Addon/ResourceAllocationsInfo.cs new file mode 100644 index 0000000..64cdc49 --- /dev/null +++ b/DeviceRepair.Models/SFC/Addon/ResourceAllocationsInfo.cs @@ -0,0 +1,49 @@ +using SqlSugar; +using System; + +namespace DeviceRepair.Models.SFC +{ + /// + /// + /// + [SugarTable("ResourceAllocations")] + public class ResourceAllocationsInfo + { + /// + /// + /// + [SugarColumn(ColumnName = "GUID", IsPrimaryKey = true)] + public Guid Guid { get; set; } + + /// + /// 产品号 + /// + [SugarColumn(ColumnName = "Product")] + public string Product { get; set; } + + /// + /// 工艺版本 + /// + [SugarColumn(ColumnName = "Technology")] + public string Technology { get; set; } + + /// + /// 岗位 + /// + [SugarColumn(ColumnName = "Staff")] + public Guid Staff { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CreateBy")] + public string CreateBy { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CreateOn")] + public DateTime? CreateOn { get; set; } + + } +} diff --git a/DeviceRepair.Models/SFC/Addon/StaffsInfo.cs b/DeviceRepair.Models/SFC/Addon/StaffsInfo.cs new file mode 100644 index 0000000..13aec76 --- /dev/null +++ b/DeviceRepair.Models/SFC/Addon/StaffsInfo.cs @@ -0,0 +1,85 @@ +using SqlSugar; +using System; + +namespace DeviceRepair.Models.SFC +{ + /// + /// + /// + [SugarTable("Staffs")] + public class StaffsInfo + { + /// + /// 0:QE 1:PE 2:ME + /// + [SugarColumn(ColumnName = "GUID", IsPrimaryKey = true)] + public Guid Guid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Post")] + public string Post { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Image")] + public string Image { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Code")] + public string Code { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Name")] + public string Name { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Telephone")] + public string Telephone { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "EMail")] + public string EMail { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Status")] + public string Status { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CreateBy")] + public string CreateBy { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CreateOn")] + public DateTime CreateOn { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ModifyBy")] + public string ModifyBy { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ModifyOn")] + public DateTime? ModifyOn { get; set; } + + } +} diff --git a/DeviceRepair.Models/SFC/Addon/UserPostsInfo.cs b/DeviceRepair.Models/SFC/Addon/UserPostsInfo.cs new file mode 100644 index 0000000..386d76f --- /dev/null +++ b/DeviceRepair.Models/SFC/Addon/UserPostsInfo.cs @@ -0,0 +1,49 @@ +using SqlSugar; +using System; + +namespace DeviceRepair.Models.SFC +{ + /// + /// + /// + [SugarTable("UserPosts")] + public class UserPostsInfo + { + /// + /// + /// + [SugarColumn(ColumnName = "GUID", IsPrimaryKey = true)] + public Guid Guid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "UserCode")] + public string UserCode { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Post")] + public Guid Post { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CreateBy")] + public string CreateBy { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CreateOn")] + public DateTime CreateOn { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CreateClient")] + public string CreateClient { get; set; } + + } +} diff --git a/DeviceRepair.Models/SFC/Data/InspBatchInfo.cs b/DeviceRepair.Models/SFC/Data/InspBatchInfo.cs new file mode 100644 index 0000000..d6e96ef --- /dev/null +++ b/DeviceRepair.Models/SFC/Data/InspBatchInfo.cs @@ -0,0 +1,261 @@ +using SqlSugar; +using System; + +namespace DeviceRepair.Models.SFC +{ + /// + /// + /// + [SugarTable("InspBatch")] + public class InspBatchInfo + { + /// + /// + /// + [SugarColumn(ColumnName = "Id", IsIdentity = true)] + public int Id { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "GUID", IsPrimaryKey = true)] + public Guid Guid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Batch", IsPrimaryKey = true)] + public string Batch { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Product")] + public string Product { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "MoCode")] + public string MoCode { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "MoQty")] + public decimal? MoQty { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ufts")] + public byte[] Ufts { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CreateBy")] + public string CreateBy { get; set; } + + /// + /// + /// 默认值: (getdate()) + /// + [SugarColumn(ColumnName = "CreateOn")] + public DateTime CreateOn { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ModifyBy")] + public string ModifyBy { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ModifyOn")] + public DateTime? ModifyOn { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "bComplete")] + public bool? BComplete { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CompleteQty")] + public decimal? CompleteQty { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ScrapQty")] + public decimal? ScrapQty { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CompleteBy")] + public string CompleteBy { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CompleteOn")] + public DateTime? CompleteOn { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "bClosed")] + public bool? BClosed { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ClosedBy")] + public string ClosedBy { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ClosedOn")] + public DateTime? ClosedOn { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ClosedDesc")] + public string ClosedDesc { get; set; } + + /// + /// + /// 默认值: ('A') + /// + [SugarColumn(ColumnName = "Status")] + public string Status { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "bLocked")] + public bool? BLocked { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "LockedBy")] + public string LockedBy { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "LockedOn")] + public DateTime? LockedOn { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "LockedType")] + public string LockedType { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "LockedDesc")] + public string LockedDesc { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "LockedIP")] + public string LockedIP { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "LockedMAC")] + public string LockedMAC { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "LockedName")] + public string LockedName { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Note")] + public string Note { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CompleteBanCi")] + public string CompleteBanCi { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CreateBanCi")] + public string CreateBanCi { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ModifyBanCi")] + public string ModifyBanCi { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CreateClient")] + public string CreateClient { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ModifyClient")] + public string ModifyClient { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CompleteClient")] + public string CompleteClient { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CloseClient")] + public string CloseClient { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ProductName")] + public string ProductName { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "SapNo")] + public string SapNo { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "IsFA")] + public bool? IsFA { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Technology")] + public string Technology { get; set; } + + } +} diff --git a/DeviceRepair.Models/app.config b/DeviceRepair.Models/app.config index dde2c3c..e936cc1 100644 --- a/DeviceRepair.Models/app.config +++ b/DeviceRepair.Models/app.config @@ -4,7 +4,7 @@ - + diff --git a/DeviceRepair.Models/packages.config b/DeviceRepair.Models/packages.config index 45b178b..4467677 100644 --- a/DeviceRepair.Models/packages.config +++ b/DeviceRepair.Models/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/DeviceRepair.Utils/Config/ConfigProperties.cs b/DeviceRepair.Utils/Config/ConfigProperties.cs index b5fab6e..f0beeff 100644 --- a/DeviceRepair.Utils/Config/ConfigProperties.cs +++ b/DeviceRepair.Utils/Config/ConfigProperties.cs @@ -13,6 +13,10 @@ [Config("LogConnection")] public string logConn { get; set; } + [DESEncrypted(true)] + [Config("SfcConnection")] + public string SfcConn { get; set; } + /// /// 加密Key /// diff --git a/DeviceRepair.Utils/app.config b/DeviceRepair.Utils/app.config index dde2c3c..e936cc1 100644 --- a/DeviceRepair.Utils/app.config +++ b/DeviceRepair.Utils/app.config @@ -4,7 +4,7 @@ - + diff --git a/DeviceRepairAndOptimization.sln b/DeviceRepairAndOptimization.sln index 06daf13..c71a957 100644 --- a/DeviceRepairAndOptimization.sln +++ b/DeviceRepairAndOptimization.sln @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:99e147d7a3262455accf060a1a62ea37f176e8ad8e315f687e352f725800fb2b -size 6598 +oid sha256:9dc261904ae28870e36532ed49a4a8557af83797d887ddc4428a20717f2dd892 +size 6607 diff --git a/DeviceRepairAndOptimization/App.config b/DeviceRepairAndOptimization/App.config index 3c41296..c1f79ef 100644 --- a/DeviceRepairAndOptimization/App.config +++ b/DeviceRepairAndOptimization/App.config @@ -64,7 +64,7 @@ - + diff --git a/DeviceRepairAndOptimization/DeviceRepairAndOptimization.csproj b/DeviceRepairAndOptimization/DeviceRepairAndOptimization.csproj index 77c8f28..dafa710 100644 --- a/DeviceRepairAndOptimization/DeviceRepairAndOptimization.csproj +++ b/DeviceRepairAndOptimization/DeviceRepairAndOptimization.csproj @@ -221,9 +221,8 @@ ..\packages\Microsoft.IdentityModel.Tokens.6.32.3\lib\net45\Microsoft.IdentityModel.Tokens.dll True - - ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll - True + + ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll ..\packages\NPOI.2.5.6\lib\net45\NPOI.dll diff --git a/DeviceRepairAndOptimization/packages.config b/DeviceRepairAndOptimization/packages.config index e9f4446..88f41f5 100644 --- a/DeviceRepairAndOptimization/packages.config +++ b/DeviceRepairAndOptimization/packages.config @@ -18,7 +18,7 @@ - + diff --git a/Intend/App.config b/Intend/App.config index 2294673..776d315 100644 --- a/Intend/App.config +++ b/Intend/App.config @@ -7,7 +7,7 @@ - + diff --git a/Intend/Intend.csproj b/Intend/Intend.csproj index a7868b3..843b135 100644 --- a/Intend/Intend.csproj +++ b/Intend/Intend.csproj @@ -41,8 +41,8 @@ - - ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll ..\packages\sqlSugar.5.0.0\lib\SqlSugar.dll diff --git a/Intend/packages.config b/Intend/packages.config index b30ed2e..4467677 100644 --- a/Intend/packages.config +++ b/Intend/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/SqlSugarTest/App.config b/SqlSugarTest/App.config index 88fa402..776d315 100644 --- a/SqlSugarTest/App.config +++ b/SqlSugarTest/App.config @@ -1,6 +1,14 @@ - + + + + + + + + + \ No newline at end of file diff --git a/Test/App.config b/Test/App.config index ed63964..48a0314 100644 --- a/Test/App.config +++ b/Test/App.config @@ -1,4 +1,4 @@ - + @@ -13,4 +13,12 @@ + + + + + + + + \ No newline at end of file diff --git a/Test/Test.csproj b/Test/Test.csproj index 1352ce5..abef1b4 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -64,8 +64,8 @@ ..\DeviceRepairAndOptimization\DLLs\HttpHelper.dll - - ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll ..\packages\sqlSugar.5.0.0\lib\SqlSugar.dll diff --git a/Test/packages.config b/Test/packages.config index 2e591d6..4467677 100644 --- a/Test/packages.config +++ b/Test/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/TsSFCDeivceClient/Biz/HttpHelper.cs b/TsSFCDeivceClient/Biz/HttpHelper.cs index b84cc89..2d661dc 100644 --- a/TsSFCDeivceClient/Biz/HttpHelper.cs +++ b/TsSFCDeivceClient/Biz/HttpHelper.cs @@ -1,9 +1,9 @@ -using Newtonsoft.Json; +using DeviceRepair.Models; +using Newtonsoft.Json; using System; using System.Net.Http; using System.Text; using TsSFCDeivceClient.Common; -using TsSFCDeivceClient.Model; namespace TsSFCDeivceClient.Biz { diff --git a/TsSFCDeivceClient/DeviceApiUrlConstValue.cs b/TsSFCDeivceClient/DeviceApiUrlConstValue.cs index 1245e5e..9f8ddf3 100644 --- a/TsSFCDeivceClient/DeviceApiUrlConstValue.cs +++ b/TsSFCDeivceClient/DeviceApiUrlConstValue.cs @@ -40,6 +40,16 @@ /// /// 获取PE QE 信息 /// - public const string ProductResourceAllocationsGet = "/Api/Maintenance/ProductResourceAllocationsGet"; + public const string CurrentBatchManagerEmail = "/Api/Maintenance/CurrentBatchManagerEmail"; + + /// + /// 判断当前账户是否PE QE + /// + public const string CurrentIsManager = "/Api/Maintenance/CurrentIsManager"; + + /// + /// 邮箱发送配置 + /// + public const string SysEmailConfig = "/Api/Common/sysEmailConfigByModuleCode"; } } diff --git a/TsSFCDeivceClient/DowntimeFormAdd.cs b/TsSFCDeivceClient/DowntimeFormAdd.cs index 9e070b8..248fabc 100644 --- a/TsSFCDeivceClient/DowntimeFormAdd.cs +++ b/TsSFCDeivceClient/DowntimeFormAdd.cs @@ -1,6 +1,8 @@ using DevExpress.XtraBars.ToolbarForm; using DevExpress.XtraEditors; using DevExpress.XtraEditors.DXErrorProvider; +using DeviceRepair.Models; +using DeviceRepair.Models.Common; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; @@ -10,9 +12,6 @@ using System.Text.RegularExpressions; using System.Windows.Forms; using TsSFCDeivceClient.Common; using TsSFCDeivceClient.Email; -using TsSFCDeivceClient.Model; -using TsSFCDeivceClient.Model.Common; -using TsSFCDeivceClient.Model.DeviceWarrantyRequest; namespace TsSFCDeivceClient { @@ -20,7 +19,7 @@ namespace TsSFCDeivceClient { MailKitHelp mail = new MailKitHelp(); string emailPattern = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"; - public DeviceInfo CurrentDeviceInfo = null; + public DeviceInformationInfo CurrentDeviceInfo = null; System.Configuration.Configuration m_Config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); string ServiceUrl { @@ -86,25 +85,44 @@ namespace TsSFCDeivceClient mail = new MailKitHelp(); } //发件服务器设置 + APIResponseData apiRtn = Biz.HttpHelper.Instance.Get($"{ServiceUrl}{DeviceApiUrlConstValue.SysEmailConfig}?ModuleCode=DeviceWarranty"); + if (!apiRtn.IsSuccess) + throw new Exception(apiRtn.Message); - // mail.medtronic.com - mail.SmtpAddress = m_Config.AppSettings.Settings["SmtpServer"].Value.Trim(); + SysEmailConfigInfo config = apiRtn.ToDeserializeObject(); - // false - mail.IsSSL = bool.Parse(m_Config.AppSettings.Settings["SmtpSSL"].Value.Trim()); - - // 25 - mail.SmtpPort = int.Parse(m_Config.AppSettings.Settings["SmtpPort"].Value.Trim()); - - //是否启用无密码模式 - if (bool.Parse(m_Config.AppSettings.Settings["EmailNoPass"].Value.Trim())) + mail.FromMailAddress = config.EmailAddress; + mail.SmtpAddress = config.SmtpServer; + mail.IsSSL = config.SmtpSSL; + mail.SmtpPort = config.SmtpPort; + if (!config.EmailNoPass) + { + mail.PassWord = DESEncrypt.Decrypt(config.EmailPassWord); + } + else { mail.IsUseDefaultCredentials = true; } - else - mail.PassWord = m_Config.AppSettings.Settings["EmailPassWord"].Value.Trim(); - mail.FromMailAddress = m_Config.AppSettings.Settings["EmailAddress"].Value.Trim(); + + //// mail.medtronic.com + //mail.SmtpAddress = m_Config.AppSettings.Settings["SmtpServer"].Value.Trim(); + + //// false + //mail.IsSSL = bool.Parse(m_Config.AppSettings.Settings["SmtpSSL"].Value.Trim()); + + //// 25 + //mail.SmtpPort = int.Parse(m_Config.AppSettings.Settings["SmtpPort"].Value.Trim()); + + ////是否启用无密码模式 + //if (bool.Parse(m_Config.AppSettings.Settings["EmailNoPass"].Value.Trim())) + //{ + // mail.IsUseDefaultCredentials = true; + //} + //else + // mail.PassWord = m_Config.AppSettings.Settings["EmailPassWord"].Value.Trim(); + + //mail.FromMailAddress = m_Config.AppSettings.Settings["EmailAddress"].Value.Trim(); return true; } @@ -210,22 +228,24 @@ namespace TsSFCDeivceClient if (dxValidationProvider1.Validate()) { string cBatch = txtBatch.EditValue + ""; + List emailLst = new List(); - // 有在生产的批次 - DataTable dtRtn = null; if (InProduction) { - JObject js = JObject.Parse(Runtime.inParams); - js.Add("Batch", cBatch); + APIResponseData apiRtn = Biz.HttpHelper.Instance.Get($"{ServiceUrl}{DeviceApiUrlConstValue.GetBatchInfoToStaff}?Batch={cBatch}"); + if (!apiRtn.IsSuccess) + throw new Exception(apiRtn.Message); - APIResponseData apiResponseData2 = Biz.HttpHelper.Instance.Post($"{ServiceUrl}{DeviceApiUrlConstValue.GetBatchInfoToStaff}", JsonConvert.SerializeObject(new { LoginCode = Runtime.CurrentUser.UserCode, Password = Runtime.CurrentUser.Password, inParams = js.ToString() })); - if (!apiResponseData2.IsSuccess) - throw new Exception(apiResponseData2.Message); + if (apiRtn.ToInt() == 0) + throw new Exception("当前批次不存在!"); - dtRtn = apiResponseData2.ToDeserializeObject(); + apiRtn = Biz.HttpHelper.Instance.Get($"{ServiceUrl}{DeviceApiUrlConstValue.CurrentBatchManagerEmail}?Batch={cBatch}"); + if (!apiRtn.IsSuccess) + throw new Exception(apiRtn.Message); + emailLst.AddRange(apiRtn.ToDeserializeObject>()); } - DeviceWarrantyRequestForm deviceWarrantyRequestForm = new DeviceWarrantyRequestForm + DeviceWarrantyRequestFormView deviceWarrantyRequestForm = new DeviceWarrantyRequestFormView { EquipmentPK = CurrentDeviceInfo.AutoID, EquipmentID = CurrentDeviceInfo.EquipmentID, @@ -239,46 +259,14 @@ namespace TsSFCDeivceClient ReceivingDep = "设备设施部" }; - APIResponseData apiResponseData = Biz.HttpHelper.Instance.Post($"{ServiceUrl}{DeviceApiUrlConstValue.DeviceDownFormAdd}", deviceWarrantyRequestForm.toJson()); + APIResponseData apiResponseData = Biz.HttpHelper.Instance.Post($"{ServiceUrl}{DeviceApiUrlConstValue.DeviceDownFormAdd}", JsonConvert.SerializeObject(deviceWarrantyRequestForm)); if (!apiResponseData.IsSuccess) throw new Exception(apiResponseData.Message); int MaintenanceAutoID = Convert.ToInt32(apiResponseData.Data); try { - List EmailList = new List(); - if (dtRtn != null && dtRtn.Rows.Count > 0 && dtRtn.Columns.Contains("Product") && dtRtn.Columns.Contains("Technology")) - { - string Product = dtRtn.Rows[0]["Product"] + ""; - string Technology = dtRtn.Rows[0]["Technology"] + ""; - - JObject js = JObject.Parse(Runtime.inParams); - js.Add("Product", Product); - js.Add("Technology", Technology); - - apiResponseData = Biz.HttpHelper.Instance.Post($"{ServiceUrl}{DeviceApiUrlConstValue.ProductResourceAllocationsGet}", JsonConvert.SerializeObject(new { LoginCode = Runtime.CurrentUser.UserCode, Password = Runtime.CurrentUser.Password, inParams = js.ToString() })); - if (!apiResponseData.IsSuccess) - throw new Exception(apiResponseData.Message); - - DataTable staffResourceAllocations = apiResponseData.ToDeserializeObject(); - //IList staffResourceAllocations = p_InspRespos.ProductResourceAllocationsGet(Product, Technology); - if (staffResourceAllocations != null && (staffResourceAllocations.Rows?.Count ?? 0) > 0) - { - foreach (DataRow item in staffResourceAllocations.Rows) - { - if ((item["Post"]?.ToString() ?? "-1") == "0" || (item["Post"]?.ToString() ?? "-1") == "1") - { - string eml = item["EMail"]?.ToString() ?? ""; - if (!string.IsNullOrWhiteSpace(eml) && Regex.IsMatch(eml, emailPattern)) - { - EmailList.Add(eml); - } - } - } - } - } - - if (EmailList.Count > 0 && InitializeMail()) + if (emailLst.Count > 0 && InitializeMail()) { mail.Title = $"有在生产的设备出现故障,请您尽快评估故障状态!"; mail.IsBodyHtml = true; @@ -288,7 +276,7 @@ namespace TsSFCDeivceClient mail.Body = builder.ToString(); string msgResult = ""; //收件人 - mail.ToMailAddress = EmailList.ToArray(); + mail.ToMailAddress = emailLst.ToArray(); MailKitHelp.SendStatus ss = mail.Send(out msgResult); } } @@ -297,8 +285,6 @@ namespace TsSFCDeivceClient XtraMessageBoxHelper.Warn($"新增数据成功,邮件发送失败,失败原因:{ex.Message}"); } - - DialogResult = DialogResult.OK; } } diff --git a/TsSFCDeivceClient/DowntimeFormAdd.designer.cs b/TsSFCDeivceClient/DowntimeFormAdd.designer.cs index 0a42291..d9595db 100644 --- a/TsSFCDeivceClient/DowntimeFormAdd.designer.cs +++ b/TsSFCDeivceClient/DowntimeFormAdd.designer.cs @@ -547,6 +547,7 @@ namespace TsSFCDeivceClient this.DoubleBuffered = true; this.Font = new System.Drawing.Font("Microsoft YaHei UI", 11.25F); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.IconOptions.Image = global::TsSFCDeivceClient.Properties.Resources.Maintenance; this.IconOptions.LargeImage = ((System.Drawing.Image)(resources.GetObject("DowntimeFormAdd.IconOptions.LargeImage"))); this.Margin = new System.Windows.Forms.Padding(4); this.Name = "DowntimeFormAdd"; diff --git a/TsSFCDeivceClient/Model/UserInfo.cs b/TsSFCDeivceClient/Model/UserInfo.cs index f1690f0..c6af928 100644 --- a/TsSFCDeivceClient/Model/UserInfo.cs +++ b/TsSFCDeivceClient/Model/UserInfo.cs @@ -13,7 +13,5 @@ namespace TsSFCDeivceClient.Model public string UserName { get; set; } public string Password { get; set; } - - public bool HasPost { get; set; } } } diff --git a/TsSFCDeivceClient/Properties/Resources.Designer.cs b/TsSFCDeivceClient/Properties/Resources.Designer.cs index 7d653ea..dbce3c6 100644 --- a/TsSFCDeivceClient/Properties/Resources.Designer.cs +++ b/TsSFCDeivceClient/Properties/Resources.Designer.cs @@ -1,70 +1,73 @@ //------------------------------------------------------------------------------ // // 此代码由工具生成。 -// 运行时版本: 4.0.30319.42000 +// 运行时版本:4.0.30319.42000 // -// 对此文件的更改可能导致不正确的行为,如果 -// 重新生成代码,则所做更改将丢失。 +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 // //------------------------------------------------------------------------------ - -namespace TsSFCDeivceClient.Properties -{ +namespace TsSFCDeivceClient.Properties { + using System; + + /// - /// 强类型资源类,用于查找本地化字符串等。 + /// 一个强类型的资源类,用于查找本地化的字符串等。 /// // 此类是由 StronglyTypedResourceBuilder // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// - /// 返回此类使用的缓存 ResourceManager 实例。 + /// 返回此类使用的缓存的 ResourceManager 实例。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TsSFCDeivceClient.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// 重写当前线程的 CurrentUICulture 属性,对 /// 使用此强类型资源类的所有资源查找执行重写。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap Maintenance { + get { + object obj = ResourceManager.GetObject("Maintenance", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/TsSFCDeivceClient/Properties/Resources.resx b/TsSFCDeivceClient/Properties/Resources.resx index af7dbeb..bfce48f 100644 --- a/TsSFCDeivceClient/Properties/Resources.resx +++ b/TsSFCDeivceClient/Properties/Resources.resx @@ -46,7 +46,7 @@ mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with - : System.Serialization.Formatters.Binary.BinaryFormatter + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 @@ -60,6 +60,7 @@ : and then encoded with base64 encoding. --> + @@ -68,9 +69,10 @@ - + + @@ -85,9 +87,10 @@ - + + @@ -109,9 +112,13 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Maintenance.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/TsSFCDeivceClient/Resources/Maintenance.png b/TsSFCDeivceClient/Resources/Maintenance.png new file mode 100644 index 0000000..4d420f7 --- /dev/null +++ b/TsSFCDeivceClient/Resources/Maintenance.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:73f361ec0e2e748bd42a57592e6810da0f202e241a9e7610356b48802e7baac1 +size 1263 diff --git a/TsSFCDeivceClient/TsSFCDeivceClient.csproj b/TsSFCDeivceClient/TsSFCDeivceClient.csproj index 1db7bc5..037665f 100644 --- a/TsSFCDeivceClient/TsSFCDeivceClient.csproj +++ b/TsSFCDeivceClient/TsSFCDeivceClient.csproj @@ -38,16 +38,35 @@ ..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False - - - - - - - - - ..\DeviceRepairAndOptimization\DLLs\HttpHelper.dll @@ -56,16 +75,20 @@ ..\packages\MailKit.3.0.0\lib\net452\MailKit.dll + False ..\packages\MimeKit.3.0.0\lib\net452\MimeKit.dll + False ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + False ..\packages\System.Buffers.4.5.1\lib\netstandard1.1\System.Buffers.dll + False @@ -103,18 +126,7 @@ frmWaiting.cs - - - - - - - - - - - Form @@ -152,6 +164,7 @@ True Resources.resx + True @@ -167,10 +180,24 @@ - + + + {4e787bc1-b925-4829-a81f-b0075d8d6790} + DeviceRepair.DataAccess + + + {2a1ffb12-b20f-4f9b-905e-1f928f17b4ee} + DeviceRepair.Models + + + {2ae8089a-c70a-47be-921b-de6a502f8d04} + DeviceRepair.Utils + + + \ No newline at end of file diff --git a/TsSFCDeivceClient/pageDeivceView.cs b/TsSFCDeivceClient/pageDeivceView.cs index 7cd257f..6e88bdc 100644 --- a/TsSFCDeivceClient/pageDeivceView.cs +++ b/TsSFCDeivceClient/pageDeivceView.cs @@ -1,10 +1,9 @@ using DevExpress.XtraBars.ToolbarForm; +using DeviceRepair.Models; using System; using System.Collections.Generic; using System.Windows.Forms; using TsSFCDeivceClient.Common; -using TsSFCDeivceClient.Model; -using TsSFCDeivceClient.Model.DeviceWarrantyRequest; namespace TsSFCDeivceClient { @@ -12,7 +11,7 @@ namespace TsSFCDeivceClient { int m_SelectedCurrentRowIndex = 0; - public DeviceInfo CurrentDeviceInfo = null; + public DeviceInformationInfo CurrentDeviceInfo = null; System.Configuration.Configuration m_Config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); string ServiceUrl { @@ -55,7 +54,7 @@ namespace TsSFCDeivceClient if (!apiResponseData.IsSuccess) throw new Exception(apiResponseData.Message); - List lst = apiResponseData.ToDeserializeObject>(); + List lst = apiResponseData.ToDeserializeObject>(); CloseWaitForm(); gridControl1.DataSource = lst; @@ -117,7 +116,7 @@ namespace TsSFCDeivceClient if (e.FocusedRowHandle >= 0) { m_SelectedCurrentRowIndex = e.FocusedRowHandle; - CurrentDeviceInfo = gridView1.GetRow(e.FocusedRowHandle) as DeviceInfo; + CurrentDeviceInfo = gridView1.GetRow(e.FocusedRowHandle) as DeviceInformationInfo; #region 修改选定状态 if (gridView1.SelectedRowsCount > 0) diff --git a/TsSFCDeivceClient/pageDeivceView.designer.cs b/TsSFCDeivceClient/pageDeivceView.designer.cs index bd521db..12e674b 100644 --- a/TsSFCDeivceClient/pageDeivceView.designer.cs +++ b/TsSFCDeivceClient/pageDeivceView.designer.cs @@ -39,8 +39,8 @@ namespace TsSFCDeivceClient this.gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView(); this.gcEquipmentID = new DevExpress.XtraGrid.Columns.GridColumn(); this.gcEquipmentName = new DevExpress.XtraGrid.Columns.GridColumn(); - this.gcRemarks = new DevExpress.XtraGrid.Columns.GridColumn(); this.gcSpecification = new DevExpress.XtraGrid.Columns.GridColumn(); + this.gcRemarks = new DevExpress.XtraGrid.Columns.GridColumn(); this.stackPanel1 = new DevExpress.Utils.Layout.StackPanel(); this.labelControl1 = new DevExpress.XtraEditors.LabelControl(); this.txt_Filter = new DevExpress.XtraEditors.TextEdit(); @@ -102,7 +102,7 @@ namespace TsSFCDeivceClient // // gridControl1 // - this.gridControl1.EmbeddedNavigator.Margin = new System.Windows.Forms.Padding(2); + this.gridControl1.EmbeddedNavigator.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); this.gridControl1.Location = new System.Drawing.Point(12, 60); this.gridControl1.MainView = this.gridView1; this.gridControl1.Name = "gridControl1"; @@ -138,6 +138,14 @@ namespace TsSFCDeivceClient this.gcEquipmentName.Visible = true; this.gcEquipmentName.VisibleIndex = 1; // + // gcSpecification + // + this.gcSpecification.Caption = "规格型号"; + this.gcSpecification.FieldName = "Specification"; + this.gcSpecification.Name = "gcSpecification"; + this.gcSpecification.Visible = true; + this.gcSpecification.VisibleIndex = 3; + // // gcRemarks // this.gcRemarks.Caption = "说明"; @@ -147,14 +155,6 @@ namespace TsSFCDeivceClient this.gcRemarks.Visible = true; this.gcRemarks.VisibleIndex = 2; // - // gcSpecification - // - this.gcSpecification.Caption = "规格型号"; - this.gcSpecification.FieldName = "Specification"; - this.gcSpecification.Name = "gcSpecification"; - this.gcSpecification.Visible = true; - this.gcSpecification.VisibleIndex = 3; - // // stackPanel1 // this.stackPanel1.Controls.Add(this.labelControl1); @@ -420,6 +420,7 @@ namespace TsSFCDeivceClient this.DoubleBuffered = true; this.Font = new System.Drawing.Font("Microsoft YaHei UI", 11.25F); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.IconOptions.Image = global::TsSFCDeivceClient.Properties.Resources.Maintenance; this.IconOptions.LargeImage = ((System.Drawing.Image)(resources.GetObject("pageDeivceView.IconOptions.LargeImage"))); this.Margin = new System.Windows.Forms.Padding(4); this.Name = "pageDeivceView"; diff --git a/TsSFCDeivceClient/pageDeviceMaintenanceFormView.cs b/TsSFCDeivceClient/pageDeviceMaintenanceFormView.cs index 56f0fd0..750a967 100644 --- a/TsSFCDeivceClient/pageDeviceMaintenanceFormView.cs +++ b/TsSFCDeivceClient/pageDeviceMaintenanceFormView.cs @@ -1,5 +1,7 @@ using DevExpress.XtraBars.ToolbarForm; using DevExpress.XtraEditors; +using DeviceRepair.Models; +using DeviceRepair.Models.Common; using Newtonsoft.Json; using System; using System.Collections; @@ -9,11 +11,8 @@ using System.Drawing; using System.Linq; using System.Reflection; using System.Windows.Forms; -using TsSFC.Base.Model.Device; using TsSFCDeivceClient.Common; using TsSFCDeivceClient.Model; -using TsSFCDeivceClient.Model.Common; -using TsSFCDeivceClient.Model.DeviceWarrantyRequest; namespace TsSFCDeivceClient { @@ -32,6 +31,9 @@ namespace TsSFCDeivceClient } List lookupMaintenanceStatus; + + #region 表单数据 + DeviceWarrantyRequestFormFilter _filter; DeviceWarrantyRequestFormFilter FilterInfo { @@ -86,68 +88,95 @@ namespace TsSFCDeivceClient { get { return Convert.ToDateTime(de_EndDate.EditValue); } } + #endregion bool HasAuth = false; - public pageDeviceMaintenanceFormView(UserInfo user, string APPVERSION) + public pageDeviceMaintenanceFormView(UserInfo user, string APPVERSION = "5.0.0.0") { InitializeComponent(); Runtime.CurrentUser = user; - Runtime.inParams = JsonConvert.SerializeObject(new { OPERATORGUID = user.GUID, OPERATOR = user.UserCode, CLIENTIP = ComputerHelper.Instance().IpAddress, CLIENTMAC = ComputerHelper.Instance().MacAddress, CLIENTNAME = ComputerHelper.Instance().ComputerName , APPVERSION = APPVERSION }); - HasAuth = user.HasPost; + Runtime.inParams = JsonConvert.SerializeObject(new { OPERATORGUID = user.GUID, OPERATOR = user.UserCode, CLIENTIP = ComputerHelper.Instance().IpAddress, CLIENTMAC = ComputerHelper.Instance().MacAddress, CLIENTNAME = ComputerHelper.Instance().ComputerName, APPVERSION = APPVERSION }); + + //HasAuth = user.HasPost; this.Load += PageDeviceMaintenanceFormView_Load; } private void PageDeviceMaintenanceFormView_Load(object sender, EventArgs e) { - if (Runtime.CurrentUser == null) + try { - XtraMessageBoxHelper.Error($"非法的调用,请重试。"); - this.Close(); - } + splashScreenManager1.ShowWaitForm(); - if (string.IsNullOrWhiteSpace(ServiceUrl)) - { - XtraMessageBoxHelper.Error($"缺少配置字段(设备管理软件接口地址)【ServiceApiUrl】。"); - this.Close(); - } - - if (lookupMaintenanceStatus == null) - lookupMaintenanceStatus = new List(); - - foreach (DeviceWarrantyRequestFormStatus item in Enum.GetValues(typeof(DeviceWarrantyRequestFormStatus))) - { - lookupMaintenanceStatus.Add(new LookUpItemModel + if (Runtime.CurrentUser == null) { - ValueMember = (int)item, - DisplayMember = item.ToDescription() - }); + XtraMessageBoxHelper.Error($"非法的调用,请重试。"); + this.Close(); + } + + if (string.IsNullOrWhiteSpace(ServiceUrl)) + { + XtraMessageBoxHelper.Error($"缺少配置字段(设备管理软件接口地址)【ServiceApiUrl】。"); + this.Close(); + } + + + APIResponseData apiResponseData = Biz.HttpHelper.Instance.Get($"{ServiceUrl}{DeviceApiUrlConstValue.CurrentIsManager}?UserCode={Runtime.CurrentUser.UserCode}"); + if (!apiResponseData.IsSuccess) + { + XtraMessageBoxHelper.Error(apiResponseData.Message); + this.Close(); + } + + HasAuth = apiResponseData.ToInt() > 0; + + if (lookupMaintenanceStatus == null) + lookupMaintenanceStatus = new List(); + + foreach (DeviceWarrantyRequestFormStatus item in Enum.GetValues(typeof(DeviceWarrantyRequestFormStatus))) + { + lookupMaintenanceStatus.Add(new LookUpItemModel + { + ValueMember = (int)item, + DisplayMember = item.ToDescription() + }); + } + + cb_Status.Properties.DataSource = lookupMaintenanceStatus; + cb_Status.Properties.DisplayMember = "DisplayMember"; + cb_Status.Properties.ValueMember = "ValueMember"; + cb_Status.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; + cb_Status.EditValue = (int)DeviceWarrantyRequestFormStatus.All; + + + cbbIsDown.Properties.Items.BeginUpdate(); + foreach (DeviceRunningStatus item in Enum.GetValues(typeof(DeviceRunningStatus))) + { + cbbIsDown.Properties.Items.Add(item.ToDescription()); + } + cbbIsDown.Properties.Items.EndUpdate(); + cbbIsDown.SelectedIndex = 0; + + + de_StartDate.EditValue = DateTime.Today.AddMonths(-1); + de_EndDate.EditValue = DateTime.Today; + + InitializeGridViewStyle(); + splashScreenManager1.CloseWaitForm(); } - - cb_Status.Properties.DataSource = lookupMaintenanceStatus; - cb_Status.Properties.DisplayMember = "DisplayMember"; - cb_Status.Properties.ValueMember = "ValueMember"; - cb_Status.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; - cb_Status.EditValue = (int)DeviceWarrantyRequestFormStatus.All; - - - cbbIsDown.Properties.Items.BeginUpdate(); - foreach (DeviceRunningStatus item in Enum.GetValues(typeof(DeviceRunningStatus))) + catch (Exception ex) { - cbbIsDown.Properties.Items.Add(item.ToDescription()); + XtraMessageBoxHelper.Error(ex.Message); + splashScreenManager1.CloseWaitForm(); + this.Close(); } - cbbIsDown.Properties.Items.EndUpdate(); - cbbIsDown.SelectedIndex = 0; - - - de_StartDate.EditValue = DateTime.Today.AddMonths(-1); - de_EndDate.EditValue = DateTime.Today; - - InitializeGridViewStyle(); } - List GridDatas = null; + Dictionary CurrentGridDatas; + + + //List GridDatas = null; DataTable ToDataTable(IList list) { @@ -184,15 +213,43 @@ namespace TsSFCDeivceClient try { splashScreenManager1.ShowWaitForm(); - APIResponseData apiResponseData = Biz.HttpHelper.Instance.Post($"{ServiceUrl}{DeviceApiUrlConstValue.GetMaintenance}", FilterInfo.ToJson()); + APIResponseData apiResponseData = Biz.HttpHelper.Instance.Post($"{ServiceUrl}{DeviceApiUrlConstValue.GetMaintenance}", JsonConvert.SerializeObject(FilterInfo)); if (!apiResponseData.IsSuccess) throw new Exception(apiResponseData.Message); - GridDatas = apiResponseData.ToDeserializeObject>(); + List GridDatas = apiResponseData.ToDeserializeObject>(); + + if (GridDatas != null && GridDatas.Count > 0) + CurrentGridDatas = GridDatas.ToDictionary(x => x.AutoID, x => x); + DataTable table = ToDataTable(GridDatas); + table.Columns.Add("InProductionText"); + table.Columns.Add("EvaluatorPE"); + table.Columns.Add("EvaluatorTimePE"); + table.Columns.Add("EvaluatorQE"); + table.Columns.Add("EvaluatorTimeQE"); + + string[] ManagerCodes = new string[] { "QE", "PE" }; + foreach (DataRow item in table.Rows) + { + int AutoID = Convert.ToInt32(item["AutoID"]); + if (CurrentGridDatas.ContainsKey(AutoID) && CurrentGridDatas[AutoID] != null) + { + item["InProductionText"] = CurrentGridDatas[AutoID].InProduction ? "是" : "否"; + foreach (string Code in ManagerCodes) + { + DeviceWarrantyEvaluatorInfo deviceWarrantyEvaluatorInfo = CurrentGridDatas[AutoID].EvaluatorItems.FirstOrDefault(x => x.EvaluatorCode == Code); + if (deviceWarrantyEvaluatorInfo == null) + continue; + item[$"Evaluator{Code}"] = deviceWarrantyEvaluatorInfo.CreatorName; + item[$"EvaluatorTime{Code}"] = deviceWarrantyEvaluatorInfo.CreatOn; + } + } + } + gridControl1.DataSource = null; gridControl1.DataSource = table; gridView1.BestFitColumns(); @@ -293,7 +350,7 @@ namespace TsSFCDeivceClient bool RestorationConfirmation = false; int AutoID = Convert.ToInt32(CurrentRequestForm["AutoID"]); - DeviceWarrantyRequestForm Item = GridDatas.FirstOrDefault(x => x.AutoID == AutoID); + DeviceWarrantyRequestFormView Item = CurrentGridDatas[AutoID];// GridDatas.FirstOrDefault(x => x.AutoID == AutoID); if (Item != null && HasAuth && Item.FormStatus != DeviceWarrantyRequestFormStatus.BeComplate && Item.InProduction) { @@ -378,11 +435,6 @@ namespace TsSFCDeivceClient } } - private void btn_Filter_Click(object sender, EventArgs e) - { - - } - /// /// 新增设备维修单 /// @@ -397,8 +449,8 @@ namespace TsSFCDeivceClient if (view.ShowDialog() == DialogResult.OK) { XtraMessageBoxHelper.Info("操作成功!"); + InitializeGridDatas(); } - InitializeGridDatas(); } } catch (Exception ex) @@ -423,7 +475,7 @@ namespace TsSFCDeivceClient int AutoID = 0; if (int.TryParse(CurrentRequestForm["AutoID"] + "", out AutoID) && AutoID > 0) { - DeviceWarrantyRequestForm Item = GridDatas.FirstOrDefault(x => x.AutoID == AutoID); + DeviceWarrantyRequestFormView Item = CurrentGridDatas[AutoID];//GridDatas.FirstOrDefault(x => x.AutoID == AutoID); if (Item == null) throw new Exception($"获取维修单数据出错,请重试!"); @@ -455,17 +507,18 @@ namespace TsSFCDeivceClient FormID = Item.AutoID, }; - APIResponseData apiResponseData = Biz.HttpHelper.Instance.Post($"{ServiceUrl}{DeviceApiUrlConstValue.MaintenanceFormAssessment}", info.ToJson()); + APIResponseData apiResponseData = Biz.HttpHelper.Instance.Post($"{ServiceUrl}{DeviceApiUrlConstValue.MaintenanceFormAssessment}", JsonConvert.SerializeObject(info)); if (!apiResponseData.IsSuccess) throw new Exception(apiResponseData.Message); + CloseWaitForm(); + XtraMessageBoxHelper.Info("操作成功!"); + InitializeGridDatas(); } } else { throw new Exception($"获取维修单数据出错,请重试!"); } - CloseWaitForm(); - XtraMessageBoxHelper.Info("操作成功!"); } catch (Exception ex) { @@ -484,7 +537,7 @@ namespace TsSFCDeivceClient int AutoID = 0; if (int.TryParse(CurrentRequestForm["AutoID"] + "", out AutoID) && AutoID > 0) { - DeviceWarrantyRequestForm Item = GridDatas.FirstOrDefault(x => x.AutoID == AutoID); + DeviceWarrantyRequestFormView Item = CurrentGridDatas[AutoID];// GridDatas.FirstOrDefault(x => x.AutoID == AutoID); if (Item == null) throw new Exception($"获取维修单数据出错,请重试!"); @@ -516,7 +569,7 @@ namespace TsSFCDeivceClient FormID = Item.AutoID, }; - APIResponseData apiResponseData = Biz.HttpHelper.Instance.Post($"{ServiceUrl}{DeviceApiUrlConstValue.MaintenanceFormAssessment}", info.ToJson()); + APIResponseData apiResponseData = Biz.HttpHelper.Instance.Post($"{ServiceUrl}{DeviceApiUrlConstValue.MaintenanceFormAssessment}", JsonConvert.SerializeObject(info)); if (!apiResponseData.IsSuccess) throw new Exception(apiResponseData.Message); } @@ -527,6 +580,7 @@ namespace TsSFCDeivceClient } CloseWaitForm(); XtraMessageBoxHelper.Info("操作成功!"); + InitializeGridDatas(); } catch (Exception ex) { @@ -555,7 +609,7 @@ namespace TsSFCDeivceClient int AutoID = 0; if (int.TryParse(CurrentRequestForm["AutoID"] + "", out AutoID) && AutoID > 0) { - DeviceWarrantyRequestForm Item = GridDatas.FirstOrDefault(x => x.AutoID == AutoID); + DeviceWarrantyRequestFormView Item = CurrentGridDatas[AutoID];// GridDatas.FirstOrDefault(x => x.AutoID == AutoID); if (Item == null) throw new Exception($"获取维修单数据出错,请重试!"); @@ -577,6 +631,7 @@ namespace TsSFCDeivceClient CloseWaitForm(); XtraMessageBoxHelper.Info("操作成功!"); + InitializeGridDatas(); } } else diff --git a/TsSFCDeivceClient/pageDeviceMaintenanceFormView.designer.cs b/TsSFCDeivceClient/pageDeviceMaintenanceFormView.designer.cs index fe2fb45..9116de2 100644 --- a/TsSFCDeivceClient/pageDeviceMaintenanceFormView.designer.cs +++ b/TsSFCDeivceClient/pageDeviceMaintenanceFormView.designer.cs @@ -268,7 +268,7 @@ namespace TsSFCDeivceClient // gridControl1 // this.gridControl1.Dock = System.Windows.Forms.DockStyle.Fill; - this.gridControl1.EmbeddedNavigator.Margin = new System.Windows.Forms.Padding(2); + this.gridControl1.EmbeddedNavigator.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); this.gridControl1.Location = new System.Drawing.Point(4, 72); this.gridControl1.MainView = this.gridView1; this.gridControl1.Margin = new System.Windows.Forms.Padding(4); @@ -671,6 +671,7 @@ namespace TsSFCDeivceClient this.Controls.Add(this.toolbarFormControl1); this.DoubleBuffered = true; this.Font = new System.Drawing.Font("Microsoft YaHei UI", 11.25F); + this.IconOptions.Image = global::TsSFCDeivceClient.Properties.Resources.Maintenance; this.IconOptions.LargeImage = ((System.Drawing.Image)(resources.GetObject("pageDeviceMaintenanceFormView.IconOptions.LargeImage"))); this.Margin = new System.Windows.Forms.Padding(4); this.Name = "pageDeviceMaintenanceFormView";