| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:SmartDeviceService.cs
- * 2.功能描述:接收智能设备请求
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 陈晓野 2018/10/25 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.ServiceModel;
- using System.ServiceModel.Activation;
- using Dongke.IBOSS.PRD.Basics.Library;
- using Dongke.IBOSS.PRD.Service.DataModels;
- using Dongke.IBOSS.PRD.Service.PMModuleLogic;
- using Dongke.IBOSS.PRD.Service.SmartDeviceService;
- using Dongke.IBOSS.PRD.WCF.Contracts;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- namespace Dongke.IBOSS.PRD.WCF.Services
- {
- /// <summary>
- /// 智能设备对接服务
- /// </summary>
- [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
- [ServiceBehavior(ConfigurationName = "SmartDeviceService",
- InstanceContextMode = InstanceContextMode.PerCall,
- ConcurrencyMode = ConcurrencyMode.Multiple,
- UseSynchronizationContext = false)]
- public class SmartDeviceService : ISmartDevice
- {
- /// <summary>
- /// 连接测试
- /// </summary>
- /// <param name="message"></param>
- /// <returns></returns>
- public string Test(string message)
- {
- return message + " is ok";
- }
- /// <summary>
- /// 自动扫描计件
- /// </summary>
- /// <returns></returns>
- public void AddWorkPiece(string accountCode, string userCode, string userPassword,
- int procedureID, string barcode)
- {
- try
- {
- DataTable userInfo = SmartDeviceLogic.CheckUserCode(accountCode, userCode);
- if (userInfo == null)
- {
- OutputLog.TraceLog(LogPriority.Warning,
- this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name,
- " userInfo is null " + userPassword + System.Environment.NewLine +
- " accountCode:" + accountCode + " userCode:" + userCode + " procedureID:" + procedureID + " barcode:" + barcode,
- LocalPath.LogExePath + "SmartDevice\\");
- return;
- }
- SUserInfo sUserInfo = new SUserInfo();
- sUserInfo.AccountID = Convert.ToInt32(userInfo.Rows[0]["AccountID"]);
- sUserInfo.AccountCode = accountCode;
- sUserInfo.UserID = Convert.ToInt32(userInfo.Rows[0]["userid"]);
- sUserInfo.UserCode = userCode;
- //DataTable barcodeTable = new DataTable();
- //barcodeTable.TableName = "barcodeTable";
- //barcodeTable.Columns.Add("BarCode");
- //barcodeTable.Columns.Add("UserID");
- //barcodeTable.Columns.Add("UserCode");
- //barcodeTable.Columns.Add("UserName");
- //barcodeTable.Columns.Add("LogoID");
- //DataRow drCollectType = barcodeTable.NewRow();
- //drCollectType["BarCode"] = barcode;
- //drCollectType["UserID"] = sUserInfo.UserID;
- //drCollectType["UserCode"] = sUserInfo.UserCode;
- //drCollectType["UserName"] = userInfo.Rows[0]["UserName"].ToString();
- //barcodeTable.Rows.Add(drCollectType);
- DataTable barcodeTable = userInfo;
- barcodeTable.Columns.Add("LogoID");
- barcodeTable.Columns.Add("BarCode");
- barcodeTable.Rows[0]["BarCode"] = barcode;
- ProcedureEntity procedureInfo = null;
- DataTable dt = PMModuleLogicDAL.AddWorkPiece(procedureID, barcodeTable, sUserInfo, out procedureInfo);
- if (dt != null && dt.Rows.Count > 0 && !string.IsNullOrWhiteSpace(dt.Rows[0]["out_errMsg"].ToString()))
- {
- OutputLog.TraceLog(LogPriority.Warning,
- this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name + System.Environment.NewLine +
- userPassword + System.Environment.NewLine +
- " accountCode:" + accountCode + " userCode:" + userCode + " procedureID:" + procedureID + " barcode:" + barcode,
- JsonHelper.ToJson(dt),
- LocalPath.LogExePath+ "SmartDevice\\");
- }
- }
- catch (Exception ex)
- {
- OutputLog.TraceLog(LogPriority.Error,
- this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name + System.Environment.NewLine +
- userPassword + System.Environment.NewLine +
- " accountCode:" + accountCode + " userCode:" + userCode + " procedureID:" + procedureID + " barcode:" + barcode,
- ex.ToString(),
- LocalPath.LogExePath);
- }
- }
- /// <summary>
- /// 自动扫描计件
- /// </summary>
- /// <returns></returns>
- public string AddWorkPieceByStatus(string accountCode, string userCode, string userPassword,
- int procedureID, string barcode, string remarks)
- {
- try
- {
- DataTable userInfo = SmartDeviceLogic.CheckUserCode(accountCode, userCode);
- if (userInfo == null)
- {
- OutputLog.TraceLog(LogPriority.Warning,
- this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name,
- " userInfo is null " + userPassword + System.Environment.NewLine +
- " accountCode:" + accountCode + " userCode:" + userCode + " procedureID:" + procedureID + " barcode:" + barcode,
- LocalPath.LogExePath + "SmartDevice\\");
- return "EU-01";
- }
- SUserInfo sUserInfo = new SUserInfo();
- sUserInfo.AccountID = Convert.ToInt32(userInfo.Rows[0]["AccountID"]);
- sUserInfo.AccountCode = accountCode;
- sUserInfo.UserID = Convert.ToInt32(userInfo.Rows[0]["userid"]);
- sUserInfo.UserCode = userCode;
- //DataTable barcodeTable = new DataTable();
- //barcodeTable.TableName = "barcodeTable";
- //barcodeTable.Columns.Add("BarCode");
- //barcodeTable.Columns.Add("UserID");
- //barcodeTable.Columns.Add("UserCode");
- //barcodeTable.Columns.Add("UserName");
- //barcodeTable.Columns.Add("LogoID");
- //DataRow drCollectType = barcodeTable.NewRow();
- //drCollectType["BarCode"] = barcode;
- //drCollectType["UserID"] = sUserInfo.UserID;
- //drCollectType["UserCode"] = sUserInfo.UserCode;
- //drCollectType["UserName"] = userInfo.Rows[0]["UserName"].ToString();
- //barcodeTable.Rows.Add(drCollectType);
- DataTable barcodeTable = userInfo;
- barcodeTable.Columns.Add("LogoID");
- barcodeTable.Columns.Add("BarCode");
- barcodeTable.Columns.Add("Remarks");
- barcodeTable.Rows[0]["BarCode"] = barcode;
- barcodeTable.Rows[0]["Remarks"] = remarks;
- ProcedureEntity procedureInfo = null;
- DataTable dt = PMModuleLogicDAL.AddWorkPiece(procedureID, barcodeTable, sUserInfo, out procedureInfo);
- string out_msg = dt.Rows[0]["out_errMsg"].ToString();
- if (dt != null && dt.Rows.Count > 0 && !string.IsNullOrWhiteSpace(out_msg))
- {
- OutputLog.TraceLog(LogPriority.Warning,
- this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name + System.Environment.NewLine +
- userPassword + System.Environment.NewLine +
- " accountCode:" + accountCode + " userCode:" + userCode + " procedureID:" + procedureID + " barcode:" + barcode,
- JsonHelper.ToJson(dt),
- LocalPath.LogExePath + "SmartDevice\\");
- if (out_msg.StartsWith("无效条码"))
- {
- return "EP-01";
- }
- if (out_msg.Contains("不能到达该工序"))
- {
- return "EP-02";
- }
- return "EP-00";
- }
- return "OK";
- }
- catch (Exception ex)
- {
- OutputLog.TraceLog(LogPriority.Error,
- this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name + System.Environment.NewLine +
- userPassword + System.Environment.NewLine +
- " accountCode:" + accountCode + " userCode:" + userCode + " procedureID:" + procedureID + " barcode:" + barcode,
- ex.ToString(),
- LocalPath.LogExePath);
- return "EE";
- }
- }
- }
- }
|