| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using MES.Service.DB; |
| | | using MES.Service.Dto.service; |
| | | using MES.Service.Dto.webApi; |
| | | using MES.Service.Modes; |
| | | using MES.Service.util; |
| | | using Microsoft.Data.SqlClient; |
| | | using SqlSugar; |
| | | using System.Data; |
| | | using System.Dynamic; |
| | | |
| | | namespace MES.Service.service |
| | | { |
| | | public class SysUserService : Repository<SysUser> |
| | | { |
| | | |
| | | public List<UserPermission> QueryPurview(string userNo) |
| | | { |
| | | // è·åç¨æ·æéå表 |
| | | List<string> purviewData = this.DoPurview(userNo); |
| | | List<UserPermission> resultList = new List<UserPermission>(); |
| | | |
| | | if (purviewData.Count > 0) |
| | | { |
| | | string purviewString = purviewData[0]; |
| | | string[] splitResult = purviewString.Split(new string[] { "[" }, StringSplitOptions.None); |
| | | |
| | | if (splitResult.Length > 2) |
| | | { |
| | | for (int i = 2; i < splitResult.Length; i++) |
| | | { |
| | | string trimmedStr = splitResult[i].Trim(); // å»æç©ºæ ¼ |
| | | string[] itemArray = trimmedStr.Split(new char[] { '#' }); |
| | | |
| | | UserPermission permission = new UserPermission |
| | | { |
| | | Name = itemArray[0], |
| | | Category = "å
¨é¨åºç¨", |
| | | IconType = itemArray[1], |
| | | Path = "input" , |
| | | Color = itemArray[2] |
| | | }; |
| | | |
| | | resultList.Add(permission); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // æ·»å éåºé项 |
| | | /* resultList.Add(new UserPermission |
| | | { |
| | | Name = "éåº", |
| | | Category = "å
¨é¨åºç¨", |
| | | IconType = "close", |
| | | Path = "/logout", |
| | | Color = "red" |
| | | });*/ |
| | | |
| | | return resultList; |
| | | } |
| | | |
| | | |
| | | private List<string> DoPurview(string userNo) |
| | | { |
| | | List<string> resultList = new List<string>(); |
| | | |
| | | try |
| | | { |
| | | // å®ä¹è¾å
¥åæ° |
| | | var inputParam1 = new SugarParameter("c_User_No", userNo.ToUpper()); |
| | | var inputParam2 = new SugarParameter("c_MachType", "AN"); |
| | | |
| | | // å®ä¹è¾åºåæ° |
| | | var outParam = new SugarParameter("c_Result", null, true); |
| | | |
| | | // 使ç¨SqlSugaræ§è¡åå¨è¿ç¨ |
| | | Db.Ado.ExecuteCommand("BEGIN Prc_rf_j2_user_login(:c_User_No, :c_MachType, :c_Result); END;", |
| | | inputParam1, inputParam2, outParam); |
| | | |
| | | // è·åè¾åºåæ°çå¼ |
| | | string result = outParam.Value == DBNull.Value ? string.Empty : (string)outParam.Value; |
| | | |
| | | // æ·»å å°ç»æå表 |
| | | if (!string.IsNullOrEmpty(result)) |
| | | { |
| | | resultList.Add(result); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // è®°å½å¼å¸¸ |
| | | Console.WriteLine($"è·åç¨æ·æé失败: {ex.Message}"); |
| | | // å¯ä»¥éæ©æåºå¼å¸¸æè¿å空å表 |
| | | } |
| | | |
| | | return resultList; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·ååè½çé¢è®¾ç½® |
| | | /// </summary> |
| | | /// <param name="functionName">åè½åç§°</param> |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·ååè½çé¢è®¾ç½® |
| | | /// </summary> |
| | | /// <param name="functionName">åè½åç§°</param> |
| | | /// <returns>åè½çé¢è®¾ç½®ä¿¡æ¯</returns> |
| | | public ResponseResult GetRfSetup(string functionName) |
| | | { |
| | | try |
| | | { |
| | | List<string> setupData = DoRfSetup(functionName); |
| | | |
| | | if (setupData.Count > 0 && !string.IsNullOrEmpty(setupData[0])) |
| | | { |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.setupData = setupData[0]; |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "æ¥è¯¢åè½ç颿åï¼", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "æªæ¾å°åè½çé¢è®¾ç½®ï¼" |
| | | }; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(ex.ToString()); |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "æ¥è¯¢åè½çé¢å¤±è´¥ï¼" |
| | | }; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·ååè½çé¢è®¾ç½®æ°æ® |
| | | /// </summary> |
| | | /// <param name="functionName">åè½åç§°</param> |
| | | /// <returns>åè½çé¢è®¾ç½®æ°æ®å表</returns> |
| | | private List<string> DoRfSetup(string functionName) |
| | | { |
| | | List<string> resultList = new List<string>(); |
| | | |
| | | try |
| | | { |
| | | // å®ä¹è¾å
¥åæ° |
| | | var inputParam1 = new SugarParameter("functionName", functionName); |
| | | var inputParam2 = new SugarParameter("deviceType", "AN"); |
| | | |
| | | // å®ä¹è¾åºåæ° |
| | | var outParam = new SugarParameter("result", null, true); |
| | | |
| | | // 使ç¨SqlSugaræ§è¡åå¨è¿ç¨ |
| | | Db.Ado.ExecuteCommand("BEGIN Prc_rf_setup(:functionName, :deviceType, :result); END;", |
| | | inputParam1, inputParam2, outParam); |
| | | |
| | | // è·åè¾åºåæ°çå¼ |
| | | string result = outParam.Value == DBNull.Value ? string.Empty : (string)outParam.Value; |
| | | |
| | | // æ·»å å°ç»æå表 |
| | | if (!string.IsNullOrEmpty(result)) |
| | | { |
| | | resultList.Add(result); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // è®°å½å¼å¸¸ |
| | | Console.WriteLine($"è·ååè½çé¢è®¾ç½®å¤±è´¥: {ex.Message}"); |
| | | // å¯ä»¥éæ©æåºå¼å¸¸æè¿å空å表 |
| | | } |
| | | |
| | | return resultList; |
| | | } |
| | | |
| | | |
| | | |
| | | public ResponseResult GetExcProc(string functionName, string fileName, string pmachtype, string fileValue, string outFiles) |
| | | { |
| | | try |
| | | { |
| | | List<string> resultList = DoExcProc(functionName, fileName, pmachtype, fileValue); |
| | | Console.WriteLine(string.Join(", ", resultList)); |
| | | |
| | | if (resultList.Count > 0) |
| | | { |
| | | string s = resultList[0]; |
| | | string[] strs = s.Split('['); |
| | | |
| | | if (strs.Length < 1) |
| | | { |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "è¿åå¼çæ ¼å¼ä¸æ£ç¡®!" + string.Join(", ", resultList) |
| | | }; |
| | | } |
| | | |
| | | // 夿å弿¯å¦æå |
| | | string str = strs[0]; |
| | | if (str.Equals("002")) |
| | | { |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = strs[1] |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | if (string.IsNullOrEmpty(outFiles)) |
| | | { |
| | | if (strs.Length < 2) |
| | | { |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | data = "" |
| | | }; |
| | | } |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | data = strs[1] |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | List<string[]> at = new List<string[]>(); |
| | | // [001[4500108372,80000123,100,ç©æ80000123仿¥å·²æ¶è´§ 100] |
| | | string[] files = outFiles.Split(','); |
| | | string[] res = strs[1].Split(new char[] { ',' }, StringSplitOptions.None); |
| | | |
| | | for (int i = 0; i < files.Length; i++) |
| | | { |
| | | string[] temp = new string[2]; |
| | | temp[0] = files[i]; |
| | | temp[1] = res[i]; |
| | | at.Add(temp); |
| | | } |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | data = at |
| | | }; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | data = resultList |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(ex.ToString()); |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "æ§è¡åå¨è¿ç¨å¤±è´¥ï¼" + ex.Message |
| | | }; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ§è¡åå¨è¿ç¨ |
| | | /// </summary> |
| | | /// <param name="functionName">åè½åç§°</param> |
| | | /// <param name="fileName">åæ®µå</param> |
| | | /// <param name="pmachtype">设å¤ç±»å</param> |
| | | /// <param name="fileValue">åæ°å¼</param> |
| | | /// <returns>åå¨è¿ç¨æ§è¡ç»æ</returns> |
| | | private List<string> DoExcProc(string functionName, string fileName, string pmachtype, string fileValue) |
| | | { |
| | | List<string> resultList = new List<string>(); |
| | | |
| | | try |
| | | { |
| | | // å®ä¹è¾å
¥åæ° |
| | | var inputParam1 = new SugarParameter("functionName", functionName); |
| | | var inputParam2 = new SugarParameter("fileName", fileName?.Trim()); |
| | | var inputParam3 = new SugarParameter("pmachtype", "AN"); // 设å¤ç±»å wince5,wmb5,wmb6 |
| | | var inputParam4 = new SugarParameter("fileValue", fileValue); // åæ°å¼[第ä¸ä½æ¯ç¨æ·] |
| | | |
| | | // å®ä¹è¾åºåæ° |
| | | var outParam = new SugarParameter("result", null, true); |
| | | |
| | | // 使ç¨SqlSugaræ§è¡åå¨è¿ç¨ |
| | | Db.Ado.ExecuteCommand("BEGIN Prc_rf_setup_ExcProc(:functionName, :fileName, :pmachtype, :fileValue, :result); END;", |
| | | inputParam1, inputParam2, inputParam3, inputParam4, outParam); |
| | | |
| | | // è·åè¾åºåæ°çå¼ |
| | | string result = outParam.Value == DBNull.Value ? string.Empty : (string)outParam.Value; |
| | | |
| | | // æ·»å å°ç»æå表 |
| | | if (!string.IsNullOrEmpty(result)) |
| | | { |
| | | resultList.Add(result); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // è®°å½å¼å¸¸ |
| | | Console.WriteLine($"æ§è¡åå¨è¿ç¨å¤±è´¥: {ex.Message}"); |
| | | // å¯ä»¥éæ©æåºå¼å¸¸æè¿å空å表 |
| | | } |
| | | |
| | | return resultList; |
| | | } |
| | | |
| | | } |
| | | } |