1970 lines
67 KiB
C#
1970 lines
67 KiB
C#
using DeviceRepair.DataAccess;
|
||
using DeviceRepair.DataAccess.CheckForm;
|
||
using DeviceRepair.DataAccess.Device;
|
||
using DeviceRepair.DataAccess.Maintenance;
|
||
using DeviceRepair.DataAccess.PLAN;
|
||
using DeviceRepair.DataAccess.Preserve;
|
||
using DeviceRepair.DataAccess.SFC;
|
||
using DeviceRepair.DataAccess.SysCommon;
|
||
using DeviceRepair.DataAccess.Tag;
|
||
using DeviceRepair.Models;
|
||
using DeviceRepair.Models.Enum;
|
||
using DeviceRepair.Models.Preserve;
|
||
using DeviceRepair.Utils;
|
||
using Newtonsoft.Json;
|
||
using NLog;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Web;
|
||
using System.Web.Services;
|
||
using System.Web.Services.Protocols;
|
||
using TsSFCDeviceSvc.App_Code;
|
||
|
||
namespace TsSFCDeviceSvc
|
||
{
|
||
/// <summary>
|
||
/// MainService 的摘要说明
|
||
/// </summary>
|
||
[WebService(Namespace = "http://www.TechScan.cn/")]
|
||
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||
[System.ComponentModel.ToolboxItem(false)]
|
||
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
|
||
// [System.Web.Script.Services.ScriptService]
|
||
public class MainService : WebService
|
||
{
|
||
public App_Code.SFCAuthorize auth;
|
||
private static readonly Logger log = LogManager.GetCurrentClassLogger();
|
||
|
||
#region 是否开启版本校验
|
||
private static bool? _ckAppVer;
|
||
private static bool ckAppVer
|
||
{
|
||
get
|
||
{
|
||
if (!_ckAppVer.HasValue)
|
||
{
|
||
var bCheckAppVer = System.Configuration.ConfigurationManager.AppSettings?.Get("bckAppVer") ?? "true";
|
||
var b = true;
|
||
bool.TryParse(bCheckAppVer, out b);
|
||
_ckAppVer = b;
|
||
}
|
||
|
||
return _ckAppVer.Value;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
public MainService()
|
||
{
|
||
}
|
||
|
||
[WebMethod]
|
||
[SoapHeader("auth")]
|
||
public string HelloWorld()
|
||
{
|
||
HttpAuthtication();
|
||
return "Hello World";
|
||
}
|
||
|
||
[WebMethod]
|
||
[SoapHeader("auth")]
|
||
public DateTime ServiceTime()
|
||
{
|
||
HttpAuthtication();
|
||
return DateTime.Now;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取数据
|
||
/// </summary>
|
||
/// <param name="module"></param>
|
||
/// <param name="inParams"></param>
|
||
/// <param name="btResults"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "通用数据获取接口")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData GetDatas(SysModelType module, string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
switch (module)
|
||
{
|
||
case SysModelType.SYS_SET:
|
||
SysConfigDa rdSys = new SysConfigDa(Parameters);
|
||
dsResults = rdSys.GetDatas();
|
||
break;
|
||
case SysModelType.DEVICE:
|
||
// 设备信息
|
||
DeviceDa rdDev = new DeviceDa(Parameters);
|
||
dsResults = rdDev.Get_DEVICE_Datas();
|
||
break;
|
||
case SysModelType.PM_PLAN:
|
||
// 设备PM计划
|
||
PlanDa rdPlan = new PlanDa(Parameters);
|
||
dsResults = rdPlan.Get_PM_PLAN_Datas();
|
||
break;
|
||
case SysModelType.AM_PLAN:
|
||
PlanDa pdCmd = new PlanDa(Parameters);
|
||
dsResults = pdCmd.Get_AM_PLAN_Datas();
|
||
break;
|
||
case SysModelType.PLAN_Pregress:
|
||
PlanDa pdCmd2 = new PlanDa(Parameters);
|
||
dsResults = pdCmd2.Get_PlanRecordProgress();
|
||
break;
|
||
case SysModelType.PM_PLAN_CurrentMonth:
|
||
PlanDa rdPlan2 = new PlanDa(Parameters);
|
||
dsResults = rdPlan2.Get_PM_PLAN_CurrentMonth();
|
||
break;
|
||
case SysModelType.USER_INFO:
|
||
// 用户信息
|
||
UserDa rdUser = new UserDa(Parameters);
|
||
dsResults = rdUser.Get_User_Datas();
|
||
break;
|
||
case SysModelType.CheckForm:
|
||
// 点检表信息
|
||
CheckFormDa cfDa = new CheckFormDa(Parameters);
|
||
dsResults = cfDa.Get_PM_CheckForm_Datas();
|
||
break;
|
||
case SysModelType.Attachment:
|
||
// 附件信息
|
||
CommonDa rdCmd = new CommonDa(Parameters);
|
||
dsResults = rdCmd.GetAttachment();
|
||
break;
|
||
case SysModelType.CustomField:
|
||
// 自定义字段
|
||
CustomFieldDa cfCmd = new CustomFieldDa(Parameters);
|
||
dsResults = cfCmd.GetDatas();
|
||
break;
|
||
case SysModelType.Maintenance:
|
||
// 设备维修
|
||
MaintenanceDa mdCmd = new MaintenanceDa(Parameters);
|
||
dsResults = mdCmd.GetDatas();
|
||
break;
|
||
case SysModelType.MaintenanceAccessories:
|
||
// 设备维修的配件
|
||
MaintenanceDa mdCmd2 = new MaintenanceDa(Parameters);
|
||
dsResults = mdCmd2.GetFormAccessories();
|
||
break;
|
||
case SysModelType.Tag:
|
||
TagDa tagCmd = new TagDa(Parameters);
|
||
dsResults = tagCmd.GetDatas();
|
||
break;
|
||
case SysModelType.Email:
|
||
EmailConfigDa emailCmd = new EmailConfigDa(Parameters);
|
||
dsResults = emailCmd.GetDatas();
|
||
break;
|
||
case SysModelType.Get_EquiAnnualPlans:
|
||
PlanDa pdCmd3 = new PlanDa(Parameters);
|
||
dsResults = pdCmd3.GetDeviceInformationPlans();
|
||
break;
|
||
case SysModelType.AM_PLAN_Scheduler:
|
||
PlanDa pdCmd4 = new PlanDa(Parameters);
|
||
dsResults = pdCmd4.AM_PLAN_Scheduler();
|
||
break;
|
||
case SysModelType.SFC_Batch_PE_QE_Email:
|
||
MaintenanceDa mdCmd1 = new MaintenanceDa(Parameters);
|
||
dsResults = mdCmd1.CurrentBatchManagerEmail();
|
||
break;
|
||
case SysModelType.Get_SFC_Auths:
|
||
UserDa udCmd = new UserDa(Parameters);
|
||
dsResults = udCmd.GetAuths();
|
||
break;
|
||
case SysModelType.Get_JumpCheck:
|
||
var jpCmd = new EquipmentJumpPlanCheckDa(Parameters);
|
||
dsResults = jpCmd.GetDatas();
|
||
break;
|
||
case SysModelType.Get_WarrantyPrintVer:
|
||
var wpvCmd = new MaintenanceDa(Parameters);
|
||
dsResults = wpvCmd.GetFormVerPrintTemplate();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
return new APIResponseData() { Code = 1, Message = "数据获取成功!" };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex.Message);
|
||
return new APIResponseData() { Code = -1, Message = ex.Message };
|
||
}
|
||
finally
|
||
{
|
||
GC.Collect();
|
||
GC.WaitForPendingFinalizers();
|
||
}
|
||
}
|
||
|
||
|
||
[WebMethod(Description = "用户登陆接口")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData UserLogin(string userCode, string pwd, string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
UserDa rdUser = new UserDa(Parameters);
|
||
var vRtn = rdUser.UserLogin(userCode, pwd, out dsResults);
|
||
if (vRtn.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return vRtn;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
#region 设备信息
|
||
|
||
[WebMethod(Description = "获取树形结构")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_DEVICE_TreeDatas(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
DeviceDa devDa = new DeviceDa(Parameters);
|
||
APIResponseData apiResponseData = devDa.Get_DEVICE_TreeDatas(out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取设备分组数据
|
||
/// </summary>
|
||
/// <param name="inParams"></param>
|
||
/// <param name="btResults"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "获取设备分组数据")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_DEVICE_Route(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
DeviceDa devDa = new DeviceDa(Parameters);
|
||
APIResponseData apiResponseData = devDa.Get_DEVICE_Route(out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "设备编号是否存在")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_DEVICE_EXISTS(string inParams, string Equipment, out bool EXISTS)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
EXISTS = true;
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
DeviceDa devDa = new DeviceDa(Parameters);
|
||
EXISTS = devDa.Get_DEVICE_EXISTS(Equipment) > 0;
|
||
|
||
return new APIResponseData { Code = 1 };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "设备新增")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Insert_DEVICE_Data(string inParams, DataTable Datas, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
IList<DeviceInformationInfo> lst = DTOHelper<DeviceInformationInfo>.DataTableToList(Datas);
|
||
|
||
DeviceDa devDa = new DeviceDa(Parameters);
|
||
APIResponseData apiResponseData = devDa.Insert_DEVICE_Data(lst.FirstOrDefault(), out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "设备信息修改")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Updata_DEVICE_Update(string inParams, DataTable Datas, out DateTime Operation)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
Operation = DateTime.Now;
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
IList<DeviceInformationInfo> lst = DTOHelper<DeviceInformationInfo>.DataTableToList(Datas);
|
||
|
||
DeviceDa devDa = new DeviceDa(Parameters);
|
||
APIResponseData apiResponseData = devDa.Updata_DEVICE_Data(lst.FirstOrDefault(), out Operation);
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "设备状态修改")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Update_DEVICE_Status(string inParams, int AutoID, out DateTime Operation)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
Operation = DateTime.Now;
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
DeviceDa devDa = new DeviceDa(Parameters);
|
||
APIResponseData apiResponseData = devDa.Update_DEVICE_Status(AutoID, out Operation);
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 设备保养
|
||
|
||
#region 计划
|
||
|
||
#region PM
|
||
|
||
/// <summary>
|
||
/// 获取单条PM计划任务进度
|
||
/// </summary>
|
||
/// <param name="inParams"></param>
|
||
/// <param name="btResults"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "获取单条PM计划任务进度")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData PM_PLAN_Single(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
PlanDa rdPlan = new PlanDa(Parameters);
|
||
APIResponseData apiResponseData = rdPlan.PM_PLAN_Single(out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 新增或修改PM计划
|
||
/// </summary>
|
||
/// <param name="inParams"></param>
|
||
/// <param name="Datas"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "新增或修改PM计划")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Insert_OR_Edit_PM_PLAN(string inParams, DataTable Datas)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
IList<DriveMaintencePlanInfo> lst = DTOHelper<DriveMaintencePlanInfo>.DataTableToList(Datas);
|
||
|
||
PlanDa rdPlan = new PlanDa(Parameters);
|
||
return rdPlan.Insert_OR_Edit_PM_PLAN(lst.ToList());
|
||
}
|
||
catch (Exception)
|
||
{
|
||
throw;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除PM计划
|
||
/// </summary>
|
||
/// <param name="inParams"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "删除PM计划")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Del_PM_PLAN(string inParams)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
PlanDa rdPlan = new PlanDa(Parameters);
|
||
return rdPlan.Delete_PM_PLAN();
|
||
}
|
||
catch (Exception)
|
||
{
|
||
throw;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取PM计划导出数据
|
||
/// </summary>
|
||
/// <param name="Year"></param>
|
||
/// <param name="inParams"></param>
|
||
/// <param name="btResults"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "获取PM计划导出数据")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_PM_PLAN_Xlsx(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
PlanDa rdPlan = new PlanDa(Parameters);
|
||
APIResponseData apiResponseData = rdPlan.Get_PM_PLAN_Xlsx(out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取PM计划任务进度
|
||
/// </summary>
|
||
/// <param name="inParams"></param>
|
||
/// <param name="btResults"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "获取PM计划任务进度")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_PM_PLAN_ProgressInfo(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
PlanDa rdPlan = new PlanDa(Parameters);
|
||
APIResponseData apiResponseData = rdPlan.Get_PM_PLAN_ProgressInfo(out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取AM计划任务进度
|
||
/// </summary>
|
||
/// <param name="inParams"></param>
|
||
/// <param name="btResults"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "获取AM计划任务进度")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_AM_PLAN_ProgressInfo(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
PlanDa rdPlan = new PlanDa(Parameters);
|
||
APIResponseData apiResponseData = rdPlan.Get_AM_PLAN_ProgressInfo(out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "获取单计划数据")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_PLAN_Single(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
PlanDa rdPlan = new PlanDa(Parameters);
|
||
APIResponseData apiResponseData = rdPlan.Get_PLAN_Single(out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// App 版本验证
|
||
/// </summary>
|
||
/// <param name="Parameters"></param>
|
||
private static void AppVersionValid(Dictionary<string, string> Parameters)
|
||
{
|
||
if (!ckAppVer) return;
|
||
|
||
if (Parameters.ContainsKey("APPVERSION"))
|
||
{
|
||
var vServerVersion = System.Configuration.ConfigurationManager.AppSettings.Get("Version").ToString();
|
||
if (string.Compare(Parameters["APPVERSION"], vServerVersion) != 0)
|
||
{
|
||
throw new Exception(
|
||
$"当前客户端版本为:{Parameters["APPVERSION"]},服务端版本为:{vServerVersion},<br/>请更新当前客户端到最新版本!");
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region AM
|
||
|
||
/// <summary>
|
||
/// 获取PM计划导出数据
|
||
/// </summary>
|
||
/// <param name="Year"></param>
|
||
/// <param name="inParams"></param>
|
||
/// <param name="btResults"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "获取AM计划导出数据")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_AM_PLAN_Xlsx(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
PlanDa rdPlan = new PlanDa(Parameters);
|
||
APIResponseData apiResponseData = rdPlan.Get_AM_PLAN_Xlsx(out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#endregion
|
||
|
||
#region 记录
|
||
|
||
[WebMethod(Description = "PM 设备保养")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Insert_PM_Preserve_Data(string inParams, DataSet Datas)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
IList<MaintenanceRecordInfo> Record =
|
||
DTOHelper<MaintenanceRecordInfo>.DataTableToList(Datas.Tables["Record"]);
|
||
IList<AttachmentSubmitModel> Files =
|
||
DTOHelper<AttachmentSubmitModel>.DataTableToList(Datas.Tables["Files"]);
|
||
IList<AttachmentSubmitModel> Imgs =
|
||
DTOHelper<AttachmentSubmitModel>.DataTableToList(Datas.Tables["Imgs"]);
|
||
|
||
MaintenanceRecordSubmit submit = new MaintenanceRecordSubmit
|
||
{
|
||
Banci = 0,
|
||
ContentData = null,
|
||
Daily_Date = DateTime.Now,
|
||
Files = Files.ToList(),
|
||
Imgs = Imgs.ToList(),
|
||
Record = Record.First()
|
||
};
|
||
|
||
PreserveDa rdPd = new PreserveDa(Parameters);
|
||
APIResponseData apiResponseData = rdPd.Insert_PM_Preserve_Data(submit);
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "获取单条保养记录")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_Preserve_Single(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
PreserveDa rdPre = new PreserveDa(Parameters);
|
||
APIResponseData apiResponseData = rdPre.Get_Preserve_Single(out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "获取单条保养记录")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_Preserve_SingleByParams(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
int PlanAutoID = 0;
|
||
if (!Parameters.ContainsKey("PlanAutoID") || !int.TryParse(Parameters["PlanAutoID"], out PlanAutoID))
|
||
{
|
||
throw new ArgumentException("传入的计划编号参数不正确!");
|
||
}
|
||
|
||
int EquipmentPrimaryID = 0;
|
||
if (!Parameters.ContainsKey("EquipmentPrimaryID") ||
|
||
!int.TryParse(Parameters["EquipmentPrimaryID"], out EquipmentPrimaryID))
|
||
{
|
||
throw new ArgumentException("传入的设备编号参数不正确!");
|
||
}
|
||
|
||
int FormPrimaryID = 0;
|
||
if (!Parameters.ContainsKey("FormPrimaryID") ||
|
||
!int.TryParse(Parameters["FormPrimaryID"], out FormPrimaryID))
|
||
{
|
||
throw new ArgumentException("传入的点检表编号参数不正确!");
|
||
}
|
||
|
||
PreserveDa rdPre = new PreserveDa(Parameters);
|
||
APIResponseData apiResponseData =
|
||
rdPre.Get_Preserve_Single(PlanAutoID, EquipmentPrimaryID, FormPrimaryID, out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "通过设备主键编号及点检表主键编号获取单条保养信息记录")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_PreserveDetail_All(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
PreserveDa rdPre = new PreserveDa(Parameters);
|
||
APIResponseData apiResponseData = rdPre.Get_PreserveDetail_All(out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "获取设备保养记录信息")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_PreserveDetail_HisView(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
PreserveDa rdPre = new PreserveDa(Parameters);
|
||
APIResponseData apiResponseData = rdPre.GetRecordHisView(out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#endregion
|
||
|
||
#region 设备点检表
|
||
|
||
[WebMethod(Description = "获取单条保养相关计划与点检表数据")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_CheckFormAndPlan_Single(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
int PlanAutoID = 0;
|
||
if (!Parameters.ContainsKey("PlanAutoID") || !int.TryParse(Parameters["PlanAutoID"], out PlanAutoID))
|
||
{
|
||
throw new ArgumentException("传入的计划编号参数不正确!");
|
||
}
|
||
|
||
CheckFormDa cfDa = new CheckFormDa(Parameters);
|
||
APIResponseData apiResponseData = cfDa.Get_CheckForm_Single(PlanAutoID, out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "修改点检表状态")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData ChangeFormStatus(string inParams)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
CheckFormDa cfPlan = new CheckFormDa(Parameters);
|
||
return cfPlan.Change_PM_CheckForm_Status();
|
||
}
|
||
catch (Exception)
|
||
{
|
||
throw;
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "分配点检表到指定设备")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData AssigFormToDevice(string inParams, DataTable Datas)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
IList<SubmitAssignFormsToDevices> lst = DTOHelper<SubmitAssignFormsToDevices>.DataTableToList(Datas);
|
||
CheckFormDa cfPlan = new CheckFormDa(Parameters);
|
||
return cfPlan.AssigFormToDevice(lst.ToList());
|
||
}
|
||
catch (Exception)
|
||
{
|
||
throw;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 判断点检表数据是否存在
|
||
/// </summary>
|
||
/// <param name="inParams"></param>
|
||
/// <param name="Count"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "判断点检表数据是否存在")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_CheckForm_Exists(string inParams, out int Count)
|
||
{
|
||
HttpAuthtication();
|
||
Count = 0;
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
CheckFormDa cfPlan = new CheckFormDa(Parameters);
|
||
APIResponseData apiResponseData = cfPlan.Get_CheckForm_Exists(out Count);
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "新增点检表")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Insert_CheckForm_Data(string inParams, DataTable Datas)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
IList<MaintenanceFormVersionInfo> lst = DTOHelper<MaintenanceFormVersionInfo>.DataTableToList(Datas);
|
||
|
||
CheckFormDa cfPlan = new CheckFormDa(Parameters);
|
||
return cfPlan.Insert_CheckForm_Data(lst.FirstOrDefault());
|
||
}
|
||
catch (Exception)
|
||
{
|
||
throw;
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "修改点检表备注")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Change_CheckForm_Remark(string inParams, DataTable Datas)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
IList<MaintenanceFormVersionInfo> lst = DTOHelper<MaintenanceFormVersionInfo>.DataTableToList(Datas);
|
||
|
||
CheckFormDa cfPlan = new CheckFormDa(Parameters);
|
||
return cfPlan.Change_CheckForm_Remark(lst.FirstOrDefault());
|
||
}
|
||
catch (Exception)
|
||
{
|
||
throw;
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "获取单点检表数据")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_CheckForm_Single(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
int AutoID = 0;
|
||
if (!Parameters.ContainsKey("AutoID") || !int.TryParse(Parameters["AutoID"].Trim(), out AutoID))
|
||
{
|
||
throw new ArgumentException("传入的点检表编号参数不正确!");
|
||
}
|
||
|
||
CheckFormDa cmd = new CheckFormDa(Parameters);
|
||
MaintenanceFormVersionInfo Item = cmd.GetSingle(AutoID);
|
||
|
||
DataTable table = new List<MaintenanceFormVersionInfo> { Item }.ToDataTable();
|
||
dsResults.Tables.Add(table);
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
return new APIResponseData { Code = 1 };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 设备维修
|
||
|
||
[WebMethod(Description = "设备维修单-维修数据新增")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Insert_Maintenance_Data(string inParams, DataSet DataContent)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
MaintenanceDa cmd = new MaintenanceDa(Parameters);
|
||
return cmd.Insert(DataContent);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "设备维修单设备状态修改")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Update_Maintenance_Status(string inParams)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
MaintenanceDa cmd = new MaintenanceDa(Parameters);
|
||
return cmd.ChangeFormStatus();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "设备维修单设备恢复确认")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData ADD_Maintenance_DoubleValidate(string inParams)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
MaintenanceDa cmd = new MaintenanceDa(Parameters);
|
||
return cmd.ValidateMaintenance();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "停机单新增")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData ADD_DeviceDownForm_DATA(string inParams, DataTable DataContent, out int AutoID)
|
||
{
|
||
AutoID = 0;
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
MaintenanceDa cmd = new MaintenanceDa(Parameters);
|
||
return cmd.ADD_DeviceDownForm_DATA(DataContent, out AutoID);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "设备维修单列表导出")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_Maintenance_Xlsx_Datas(string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
|
||
MaintenanceDa cmd = new MaintenanceDa(Parameters);
|
||
APIResponseData apiResponseData = cmd.Get_Xlsx_Data(out dsResults);
|
||
if (apiResponseData.IsSuccess)
|
||
{
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
}
|
||
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "设备维修单是否已提交")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_Maintenance_BeSubmit(string inParams, out bool BeSubmit)
|
||
{
|
||
HttpAuthtication();
|
||
BeSubmit = true;
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
|
||
try
|
||
{
|
||
MaintenanceDa cmd = new MaintenanceDa(Parameters);
|
||
return cmd.DataBeSubmit(out BeSubmit);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "判断当前账户是否PE QE")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_CurrentIsManager(string inParams, out int PostType)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
PostType = -1;
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
MaintenanceDa cmd = new MaintenanceDa(Parameters);
|
||
PostType = cmd.CurrentIsManager();
|
||
return new APIResponseData() { Code = 1 };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "停机单 - 评估")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData ADD_DownFormAssessment(string inParams, DataTable DataContent)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
MaintenanceDa cmd = new MaintenanceDa(Parameters);
|
||
return cmd.DownFormAssessment(DataContent);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "生产部门 - 设备恢复确认")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData DeviceResumptionComfirm(string inParams)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
MaintenanceDa cmd = new MaintenanceDa(Parameters);
|
||
return cmd.DeviceResumptionComfirm();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Tag
|
||
|
||
[WebMethod(Description = "TAG数据新增")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData ADD_Tag_Data(string inParams, DataTable DataContent, out DataTable dtData)
|
||
{
|
||
HttpAuthtication();
|
||
dtData = null;
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
TagDa cmd = new TagDa(Parameters);
|
||
return cmd.Creat(DataContent, out dtData);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "TAG数据接受/维修")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Receipt_Tag_Data(string inParams, DataTable DataContent, out DataTable dtData)
|
||
{
|
||
HttpAuthtication();
|
||
dtData = null;
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
TagDa cmd = new TagDa(Parameters);
|
||
return cmd.Receipt(DataContent, out dtData);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 自定义字段
|
||
|
||
/// <summary>
|
||
/// 自定义字段新增或修改
|
||
/// </summary>
|
||
/// <param name="inParams"></param>
|
||
/// <param name="DataContent"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "自定义字段新增或修改")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData InsertOrEdit_Field_Data(string inParams, DataSet DataContent)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
if (DataContent == null || DataContent.Tables.Count == 0)
|
||
{
|
||
throw new Exception($"当前传入的操作对象为空,操作失败!");
|
||
}
|
||
|
||
CustomFieldDa cmd = new CustomFieldDa(Parameters);
|
||
return cmd.InsertOrEdit_Field_Data(DataContent.Tables[0]);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 判断自定义字段是否存在
|
||
/// </summary>
|
||
/// <param name="inParams"></param>
|
||
/// <param name="BeExists"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "判断自定义字段是否存在")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_Field_Exists(string inParams, out bool BeExists)
|
||
{
|
||
HttpAuthtication();
|
||
BeExists = true;
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
CustomFieldDa cmd = new CustomFieldDa(Parameters);
|
||
APIResponseData apiResponseData = cmd.Get_Field_Exists(out BeExists);
|
||
return apiResponseData;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改自定义字段状态
|
||
/// </summary>
|
||
/// <param name="inParams"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "修改自定义字段状态")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Change_Field_Status(string inParams)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
CustomFieldDa cmd = new CustomFieldDa(Parameters);
|
||
return cmd.Change_Field_Status();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 文件上传/下载
|
||
|
||
[WebMethod(Description = "图片附件下载")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData ImgAttrGet(string inParams, out byte[] btDatas)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
btDatas = new byte[] { };
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
int AutoID = 0;
|
||
if (!Parameters.ContainsKey("AutoID") || !int.TryParse(Parameters["AutoID"].Trim(), out AutoID))
|
||
{
|
||
throw new ArgumentException("传入的附件编号参数不正确!");
|
||
}
|
||
|
||
CommonDa cmd = new CommonDa(Parameters);
|
||
AttachmentInfo attachmentInfo = cmd.Get_Attach_Single(AutoID);
|
||
|
||
if (File.Exists(attachmentInfo.FilePath))
|
||
{
|
||
using (FileStream stream = new FileStream(attachmentInfo.FilePath, FileMode.Open, FileAccess.Read,
|
||
FileShare.ReadWrite))
|
||
{
|
||
stream.Seek(0, SeekOrigin.Begin);
|
||
byte[] bytes = new byte[stream.Length];
|
||
stream.Read(bytes, 0, bytes.Length);
|
||
stream.Close();
|
||
btDatas = bytes;
|
||
}
|
||
|
||
return new APIResponseData { Code = 1 };
|
||
}
|
||
else
|
||
{
|
||
throw new ArgumentException("文件不存在或被移动,请联系管理员!");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 点检表文件下载
|
||
/// </summary>
|
||
/// <param name="inParams"></param>
|
||
/// <param name="btDatas"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "点检表文件下载")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Form_File_Down(string inParams, out byte[] btDatas)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
btDatas = new byte[] { };
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
int AutoID = 0;
|
||
if (!Parameters.ContainsKey("AutoID") || !int.TryParse(Parameters["AutoID"].Trim(), out AutoID))
|
||
{
|
||
throw new ArgumentException("传入的点检表编号参数不正确!");
|
||
}
|
||
|
||
CheckFormDa cmd = new CheckFormDa(Parameters);
|
||
MaintenanceFormVersionInfo Item = cmd.GetSingle(AutoID);
|
||
|
||
if (File.Exists(Item.FormPath))
|
||
{
|
||
using (FileStream stream = new FileStream(Item.FormPath, FileMode.Open, FileAccess.Read,
|
||
FileShare.ReadWrite))
|
||
{
|
||
stream.Seek(0, SeekOrigin.Begin);
|
||
byte[] bytes = new byte[stream.Length];
|
||
stream.Read(bytes, 0, bytes.Length);
|
||
stream.Close();
|
||
btDatas = bytes;
|
||
}
|
||
|
||
return new APIResponseData { Code = 1 };
|
||
}
|
||
else
|
||
{
|
||
throw new ArgumentException("文件不存在或被移动,请联系管理员!");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "文件上传")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData FileUpdate(string inParams, byte[] btDatas)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
string root = Path.Combine(DeviceRepair.Utils.Config.Configurations.Properties.AttachmentDirectory,
|
||
"FormVer");
|
||
if (!Directory.Exists(root))
|
||
Directory.CreateDirectory(root);
|
||
|
||
string vFileName = $"{Guid.NewGuid().ToString("N")}_{DateTime.Now.ToString("yyMMddHHmmssfff")}";
|
||
vFileName = Path.Combine(root, $"{vFileName}.{Parameters["FileExtension"]}");
|
||
if (File.Exists(vFileName))
|
||
{
|
||
File.Delete(vFileName);
|
||
}
|
||
|
||
using (FileStream stream = new FileStream(vFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||
{
|
||
stream.Write(btDatas, 0, btDatas.Length);
|
||
stream.Close();
|
||
}
|
||
|
||
return new APIResponseData { Code = 1, Data = vFileName };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取附件
|
||
/// </summary>
|
||
/// <param name="AttaID"></param>
|
||
/// <param name="inParams"></param>
|
||
/// <param name="btDatas"></param>
|
||
/// <returns></returns>
|
||
[WebMethod(Description = "获取附件")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Attachment(int AttaID, string inParams, out byte[] btDatas)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
btDatas = null;
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
CommonDa cmd = new CommonDa(Parameters);
|
||
return cmd.GetAttachment(AttaID, out btDatas);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 系统设置
|
||
|
||
#region SFC 数据处理
|
||
|
||
[WebMethod(Description = "设备编号是否存在")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_BatchInfoToStaff_Exists(string inParams, out bool EXISTS)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
EXISTS = true;
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
BatchDa cmd = new BatchDa(Parameters);
|
||
return cmd.GetBatchInfoToStaff(out EXISTS);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
[WebMethod(Description = "批量编辑配置")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData EditConfigs(string inParams, DataTable DataContent)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
SysConfigDa cmd = new SysConfigDa(Parameters);
|
||
return cmd.EditConfigs(DataContent);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 设备计划完成校验
|
||
|
||
[WebMethod(Description = "判断当前开工设备是否存在未完成的保养计划")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Get_EquipmentPlanIsComplete(string inParams)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
if (!Parameters.ContainsKey("EquipmentID"))
|
||
{
|
||
throw new ArgumentException("缺少传入参数设备编号(EquipmentID)");
|
||
}
|
||
|
||
if (!Parameters.ContainsKey("Banci"))
|
||
{
|
||
throw new ArgumentException("缺少传入参数班次(Banci)");
|
||
}
|
||
|
||
int Banci = -1;
|
||
if (!int.TryParse(Parameters["Banci"], out Banci))
|
||
{
|
||
throw new ArgumentException("传入参数班次(Banci)类型不正确!");
|
||
}
|
||
|
||
PlanDa cmd = new PlanDa(Parameters);
|
||
return cmd.Get_EquipmentPlanIsComplete(Parameters["EquipmentID"], Banci);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
|
||
[WebMethod(Description = "跳过指定设备指定日期的设备计划完成校验")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData News_JumpCheckData(string inParams)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
EquipmentJumpPlanCheckDa cmd = new EquipmentJumpPlanCheckDa(Parameters);
|
||
return cmd.DataNews();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
[WebMethod(Description = "删除跳过指定设备指定日期的设备计划完成校验")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData Remove_JumpCheckData(string inParams)
|
||
{
|
||
HttpAuthtication();
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
EquipmentJumpPlanCheckDa cmd = new EquipmentJumpPlanCheckDa(Parameters);
|
||
return cmd.DataDel();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 历史信息查询
|
||
[WebMethod(Description = "数据历史获取通用接口")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData HistoryGet(HistoryType vType, string inParams, out byte[] btResults)
|
||
{
|
||
HttpAuthtication();
|
||
btResults = new byte[] { };
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
DataSet dsResults = new DataSet("DataResults");
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
var his = new HistoryDa(Parameters);
|
||
dsResults = his.HistoryGet(vType);
|
||
|
||
btResults = DataCompressHelper.AddDataSet(dsResults);
|
||
return new APIResponseData() { Code = 1, Message = "数据获取成功!" };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex.Message);
|
||
return new APIResponseData() { Code = -1, Message = ex.Message };
|
||
}
|
||
finally
|
||
{
|
||
GC.Collect();
|
||
GC.WaitForPendingFinalizers();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
[WebMethod(Description = "电子签")]
|
||
[SoapHeader("auth")]
|
||
public APIResponseData UserConfirm(string inParams, DataTable DataContent, out DataTable dtData)
|
||
{
|
||
HttpAuthtication();
|
||
dtData = null;
|
||
Dictionary<string, string> Parameters = GetParameters(inParams);
|
||
try
|
||
{
|
||
#region 检查APP版本是否是最新版本,否则返回错误
|
||
|
||
AppVersionValid(Parameters);
|
||
|
||
#endregion
|
||
|
||
UserDa cmd = new UserDa(Parameters);
|
||
return cmd.UserConfirm(DataContent, out dtData);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log.Error(ex);
|
||
return new APIResponseData { Code = -1, Message = ex.Message };
|
||
}
|
||
}
|
||
|
||
private void HttpAuthtication()
|
||
{
|
||
#region 校验
|
||
|
||
if (auth == null || !auth.ValidUser(auth.Username, auth.Password))
|
||
{
|
||
HttpException soapEx = new HttpException(403, "服务不允许访问此页面,也不允许匿名访问。");
|
||
|
||
log.Warn(
|
||
string.Format("客户端[{0}]我们试图执行远程匿名访问Func[{1}]!这是被禁止的!", HttpContext.Current.Request.UserHostAddress,
|
||
"GetDatas"), soapEx);
|
||
throw soapEx;
|
||
}
|
||
|
||
#endregion 校验
|
||
}
|
||
|
||
private Dictionary<string, string> GetParameters(string inParameter)
|
||
{
|
||
return JsonConvert.DeserializeObject<Dictionary<string, string>>(inParameter);
|
||
}
|
||
|
||
}
|
||
} |