public ActionResult FsuLog(string fsu) { var ext = _fsuService.GetExtFsu(fsu); if (ext != null) { var ftp = new C_Ftp { IP = ext.IP, Port = 21, User = ext.FtpUid, Password = ext.FtpPwd, Directory = "logs" }; var key = this.GetFtpKey(ftp); _cacheManager.Set(string.Format(GlobalCacheKeys.Ftp_Info_Cfg, key), ftp, TimeSpan.FromHours(1)); ViewBag.FTPKey = key; } return(View("Index")); }
public String OpSignal([FromBody] API_GV_OpSignal signal) { try { if (signal == null) { throw new ArgumentNullException("signal"); } var ids = Common.SplitKeys(signal.ID); if (ids.Length != 2) { throw new iPemException("参数ID无效"); } var device = ids[0]; var point = ids[1]; var value = signal.Value; if (string.IsNullOrWhiteSpace(device)) { throw new ArgumentNullException("device"); } if (string.IsNullOrWhiteSpace(point)) { throw new ArgumentNullException("point"); } var curDevice = _deviceService.GetDevice(device); if (curDevice == null) { throw new iPemException("未找到设备"); } var curFsu = _fsuService.GetFsu(curDevice.FsuId); if (curFsu == null) { throw new iPemException("未找到Fsu"); } var curExtFsu = _fsuService.GetExtFsu(curFsu.Id); if (curExtFsu == null) { throw new iPemException("未找到Fsu"); } if (!curExtFsu.Status) { throw new iPemException("Fsu通信中断"); } var curGroup = _groupService.GetGroup(curExtFsu.GroupId); if (curGroup == null) { throw new iPemException("未找到SC采集组"); } if (!curGroup.Status) { throw new iPemException("SC通信中断"); } var signals = _signalService.GetAllSignals(new Kv <string, string>[] { new Kv <string, string>(device, point) }); if (signals.Count == 0) { throw new iPemException("未找到信号"); } var curPoint = signals.First(); var package = new SetPointPackage() { FsuId = curFsu.Code, DeviceList = new List <SetPointDevice>() { new SetPointDevice() { Id = curDevice.Code, Values = new List <TSemaphore>() { new TSemaphore() { Id = curPoint.Code, SignalNumber = curPoint.Number, Type = (EnmBIPoint)((int)curPoint.PointType), MeasuredVal = "NULL", SetupVal = value.ToString(), Status = EnmBIState.NOALARM, Time = DateTime.Now } } } } }; var result = _packMgr.SetPoint(new UriBuilder("http", curGroup.IP, curGroup.Port, "/").ToString(), package); if (result != null) { if (result.Result == EnmBIResult.FAILURE) { throw new iPemException(result.FailureCause ?? "参数设置失败"); } if (result.DeviceList != null) { var devResult = result.DeviceList.Find(d => d.Id == curDevice.Code); if (devResult != null && devResult.SuccessList.Any(s => s.Id == curPoint.Code && s.SignalNumber == curPoint.Number)) { return(null); } } } throw new iPemException("参数设置失败"); } catch (Exception exc) { return(exc.Message); } }