|
@@ -834,14 +834,14 @@ namespace IMCS.CCS.Services
|
|
List<Device> devices = _deviceService.GetDeviceList();
|
|
List<Device> devices = _deviceService.GetDeviceList();
|
|
Device deviceFtp = devices.Where(x => x.Ip.Equals(req.url)
|
|
Device deviceFtp = devices.Where(x => x.Ip.Equals(req.url)
|
|
&& x.ProtocolType.Equals(ProtocalTypeEnum.FTP.ToString())).FirstOrDefault();
|
|
&& x.ProtocolType.Equals(ProtocalTypeEnum.FTP.ToString())).FirstOrDefault();
|
|
- Device deviceOpcUA = devices.Where(x => x.Ip.Equals(req.url)
|
|
|
|
|
|
+ Device deviceOpcUa = devices.Where(x => x.Ip.Equals(req.url)
|
|
&& x.ProtocolType.Equals(ProtocalTypeEnum.OPCUA.ToString())).FirstOrDefault();
|
|
&& x.ProtocolType.Equals(ProtocalTypeEnum.OPCUA.ToString())).FirstOrDefault();
|
|
Device deviceFanuc = devices.Where(x => x.Ip.Equals(req.url)
|
|
Device deviceFanuc = devices.Where(x => x.Ip.Equals(req.url)
|
|
&& x.ProtocolType.Equals(ProtocalTypeEnum.FANUC.ToString())).FirstOrDefault();
|
|
&& x.ProtocolType.Equals(ProtocalTypeEnum.FANUC.ToString())).FirstOrDefault();
|
|
Device deviceHeidenhain = devices.Where(x => x.Ip.Equals(req.url)
|
|
Device deviceHeidenhain = devices.Where(x => x.Ip.Equals(req.url)
|
|
&& x.ProtocolType.Equals(ProtocalTypeEnum.HEIDEHAIN.ToString())).FirstOrDefault();
|
|
&& x.ProtocolType.Equals(ProtocalTypeEnum.HEIDEHAIN.ToString())).FirstOrDefault();
|
|
|
|
|
|
- if (deviceFtp == null && deviceFanuc == null && deviceHeidenhain == null)
|
|
|
|
|
|
+ if (deviceOpcUa == null && deviceFanuc == null && deviceHeidenhain == null)
|
|
{
|
|
{
|
|
Log.Instance.WriteLogAdd(ActionTypeEnum.UploadFile + "设备已离线===>>" + JsonConvert.SerializeObject(req),
|
|
Log.Instance.WriteLogAdd(ActionTypeEnum.UploadFile + "设备已离线===>>" + JsonConvert.SerializeObject(req),
|
|
EnumHelper.GetDescription(ActionTypeEnum.UploadFile));
|
|
EnumHelper.GetDescription(ActionTypeEnum.UploadFile));
|
|
@@ -849,38 +849,20 @@ namespace IMCS.CCS.Services
|
|
return responseData;
|
|
return responseData;
|
|
}
|
|
}
|
|
//西门子系统上传
|
|
//西门子系统上传
|
|
- if (deviceOpcUA != null)
|
|
|
|
- {
|
|
|
|
- //FtpClient ftpClient = new DeviceFtp().Connect(ftpUrlContext, ftpUserContext, ftpPwdContext);
|
|
|
|
- //ftpClient.Get(req.data.fileName, LocalPath, req.data.fileName);
|
|
|
|
- //ftpClient.DisConnect();
|
|
|
|
- //try
|
|
|
|
- //{
|
|
|
|
- // DeviceSFTP sftp = new DeviceSFTP(deviceFtp.Ip, deviceFtp.Port, deviceFtp.UserName, deviceFtp.Password);
|
|
|
|
- // bool ifcon = sftp.Connect();
|
|
|
|
- // if (ifcon)
|
|
|
|
- // {
|
|
|
|
- // sftp.Put(LocalPath + "\\" + req.data.fileName, req.data.remotePath + req.data.fileName);
|
|
|
|
- // sftp.Disconnect();
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- //}
|
|
|
|
- //catch (Exception exscp)
|
|
|
|
- //{
|
|
|
|
- // Log.Instance.WriteLogAdd(ActionTypeEnum.UploadFile + "上传异常,scp连接失败," + exscp.Message + "," + JsonConvert.SerializeObject(req),
|
|
|
|
- // EnumHelper.GetDescription(ActionTypeEnum.UploadFile));
|
|
|
|
- // responseData.result = "false";
|
|
|
|
- // return responseData;
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
|
|
+ if (deviceOpcUa != null)
|
|
|
|
+ {
|
|
RequestOpcUaData opcUaReq = new RequestOpcUaData();
|
|
RequestOpcUaData opcUaReq = new RequestOpcUaData();
|
|
- opcUaReq.Type = OpcUaActionTypeEnum.Upload.ToString();
|
|
|
|
|
|
+ opcUaReq.ServerUrl = deviceOpcUa.ServerUrl;
|
|
|
|
+ opcUaReq.UserName = deviceOpcUa.UserName;
|
|
|
|
+ opcUaReq.Password = deviceOpcUa.Password;
|
|
opcUaReq.Path = req.data.fileName;
|
|
opcUaReq.Path = req.data.fileName;
|
|
|
|
+ opcUaReq.Type = OpcUaActionTypeEnum.Upload.ToString();
|
|
var Result = await _apiRequestService.RequestAsync(RequsetModeEnum.Post, opcuacUrlContext, opcUaReq, null);
|
|
var Result = await _apiRequestService.RequestAsync(RequsetModeEnum.Post, opcuacUrlContext, opcUaReq, null);
|
|
- if (!Result.IsSuccess)
|
|
|
|
|
|
+ ResponseOpcUaData responseOpcUaData = JsonConvert.DeserializeObject<ResponseOpcUaData>(Result.Message);
|
|
|
|
+ if (!Result.IsSuccess || !responseOpcUaData.result)
|
|
{
|
|
{
|
|
- Log.Instance.WriteLogAdd(ActionTypeEnum.UploadFile + "上传异常,opcUA上传," + Result.Message + "," + JsonConvert.SerializeObject(req),
|
|
|
|
- EnumHelper.GetDescription(ActionTypeEnum.UploadFile));
|
|
|
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.UploadFile + "上传异常===>>" + JsonConvert.SerializeObject(req),
|
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.UploadFile));
|
|
responseData.result = "false";
|
|
responseData.result = "false";
|
|
return responseData;
|
|
return responseData;
|
|
}
|
|
}
|
|
@@ -979,14 +961,16 @@ namespace IMCS.CCS.Services
|
|
try
|
|
try
|
|
{
|
|
{
|
|
List<Device> devices = _deviceService.GetDeviceList();
|
|
List<Device> devices = _deviceService.GetDeviceList();
|
|
- Device deviceFtp = devices.Where(x => x.Ip.Equals(req.url)
|
|
|
|
- && x.ProtocolType.Equals(ProtocalTypeEnum.FTP.ToString())).FirstOrDefault();
|
|
|
|
|
|
+ //Device deviceFtp = devices.Where(x => x.Ip.Equals(req.url)
|
|
|
|
+ // && x.ProtocolType.Equals(ProtocalTypeEnum.FTP.ToString())).FirstOrDefault();
|
|
|
|
+ Device deviceOpcUa = devices.Where(x => x.Ip.Equals(req.url)
|
|
|
|
+ && x.ProtocolType.Equals(ProtocalTypeEnum.OPCUA.ToString())).FirstOrDefault();
|
|
Device deviceFanuc = devices.Where(x => x.Ip.Equals(req.url)
|
|
Device deviceFanuc = devices.Where(x => x.Ip.Equals(req.url)
|
|
&& x.ProtocolType.Equals(ProtocalTypeEnum.FANUC.ToString())).FirstOrDefault();
|
|
&& x.ProtocolType.Equals(ProtocalTypeEnum.FANUC.ToString())).FirstOrDefault();
|
|
Device deviceHeidenhain = devices.Where(x => x.Ip.Equals(req.url)
|
|
Device deviceHeidenhain = devices.Where(x => x.Ip.Equals(req.url)
|
|
&& x.ProtocolType.Equals(ProtocalTypeEnum.HEIDEHAIN.ToString())).FirstOrDefault();
|
|
&& x.ProtocolType.Equals(ProtocalTypeEnum.HEIDEHAIN.ToString())).FirstOrDefault();
|
|
|
|
|
|
- if (deviceFtp == null && deviceFanuc == null && deviceHeidenhain == null)
|
|
|
|
|
|
+ if (deviceOpcUa == null && deviceFanuc == null && deviceHeidenhain == null)
|
|
{
|
|
{
|
|
Log.Instance.WriteLogAdd(ActionTypeEnum.UploadFile + "设备已离线===>>" + JsonConvert.SerializeObject(req),
|
|
Log.Instance.WriteLogAdd(ActionTypeEnum.UploadFile + "设备已离线===>>" + JsonConvert.SerializeObject(req),
|
|
EnumHelper.GetDescription(ActionTypeEnum.UploadFile));
|
|
EnumHelper.GetDescription(ActionTypeEnum.UploadFile));
|
|
@@ -994,26 +978,20 @@ namespace IMCS.CCS.Services
|
|
return responseData;
|
|
return responseData;
|
|
}
|
|
}
|
|
//西门子系统上传
|
|
//西门子系统上传
|
|
- if (deviceFtp != null)
|
|
|
|
|
|
+ if (deviceOpcUa != null)
|
|
{
|
|
{
|
|
- FtpClient ftpClient = new DeviceFtp().Connect(ftpUrlContext, ftpUserContext, ftpPwdContext);
|
|
|
|
- ftpClient.Get(req.data.fileName, LocalPath, req.data.fileName);
|
|
|
|
- ftpClient.DisConnect();
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- DeviceSFTP sftp = new DeviceSFTP(deviceFtp.Ip, deviceFtp.Port, deviceFtp.UserName, deviceFtp.Password);
|
|
|
|
- bool ifcon = sftp.Connect();
|
|
|
|
- if (ifcon)
|
|
|
|
- {
|
|
|
|
- sftp.Put(LocalPath + "\\" + req.data.fileName, req.data.remotePath + req.data.fileName);
|
|
|
|
- sftp.Disconnect();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- catch (Exception exscp)
|
|
|
|
|
|
+ RequestOpcUaData opcUaReq = new RequestOpcUaData();
|
|
|
|
+ opcUaReq.ServerUrl = deviceOpcUa.ServerUrl;
|
|
|
|
+ opcUaReq.UserName = deviceOpcUa.UserName;
|
|
|
|
+ opcUaReq.Password = deviceOpcUa.Password;
|
|
|
|
+ opcUaReq.Path = req.data.fileName;
|
|
|
|
+ opcUaReq.Type = OpcUaActionTypeEnum.Upload.ToString();
|
|
|
|
+ var Result = await _apiRequestService.RequestAsync(RequsetModeEnum.Post, opcuacUrlContext, opcUaReq, null);
|
|
|
|
+ ResponseOpcUaData responseOpcUaData = JsonConvert.DeserializeObject<ResponseOpcUaData>(Result.Message);
|
|
|
|
+ if (!Result.IsSuccess || !responseOpcUaData.result)
|
|
{
|
|
{
|
|
- Log.Instance.WriteLogAdd(ActionTypeEnum.UploadFile + "上传异常,scp连接失败," + exscp.Message + "," + JsonConvert.SerializeObject(req),
|
|
|
|
- EnumHelper.GetDescription(ActionTypeEnum.UploadFile));
|
|
|
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.UploadFile + "预上传异常===>>" + JsonConvert.SerializeObject(req),
|
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.UploadFile));
|
|
responseData.result = "false";
|
|
responseData.result = "false";
|
|
return responseData;
|
|
return responseData;
|
|
}
|
|
}
|