private ApiResult Test(object eventData)
        {
            ApiResult ret = new ApiResult(ErrorCode.SYS_UNKNOWN_ERR, "");

            try
            {
                var jsData    = JsonUtil.SerializeObject(eventData);
                var newJsData = CommonBLLMethodHelper.HidePd(jsData);
                LogUtil.HWLogger.UI.InfoFormat("Testing FD connect..., the param is [{0}]", newJsData);
                var fusionDirector = JsonUtil.DeserializeObject <FusionDirectorModel>(jsData);
                var result         = HttpHelper.Instance.TestLinkFD(fusionDirector);
                if (result)
                {
                    LogUtil.HWLogger.UI.Info("Testing FD connect successful!");
                    ret.Code    = "0";
                    ret.Success = true;
                    ret.Msg     = "Testing FD connect successful!";
                }
            }
            catch (BaseException ex)
            {
                LogUtil.HWLogger.UI.Error("Testing FD connect failed: ", ex);
                ret.Code    = ex.Code;
                ret.Success = false;
                ret.Msg     = "Testing FD connect failed!";
            }
            catch (Exception ex)
            {
                LogUtil.HWLogger.UI.Error("Testing FD connect failed: ", ex);
                ret.Code    = ErrorCode.SYS_UNKNOWN_ERR;
                ret.Success = false;
                ret.Msg     = "Testing FD connect failed!";
            }
            return(ret);
        }
Beispiel #2
0
        /// <summary>
        ///请求FD接口
        /// </summary>
        public virtual CommonResponse RequestFusionDirectorAPI(object eventData)
        {
            var ret       = new CommonResponse("0");
            var jsData    = JsonUtil.SerializeObject(eventData);
            var newJsData = CommonBLLMethodHelper.HidePd(jsData);
            var request   = JsonUtil.DeserializeObject <CommonRequest>(jsData);

            try
            {
                LogUtil.HWLogger.API.Info(newJsData);
                return(HttpHelper.Instance.CommonHttpHandle(request));
            }
            catch (BaseException ex)
            {
                LogUtil.HWLogger.UI.Error("ExeFDApi failed: ", ex);
                ret.Code = ex.Code;
                ret.Ips  = request.Ips;
            }
            catch (Exception ex)
            {
                LogUtil.HWLogger.UI.Error("ExeFDApi failed: ", ex);
                ret.Code = ErrorCode.SYS_UNKNOWN_ERR;
                ret.Ips  = request.Ips;
            }
            return(ret);
        }
        private ApiResult Edit(object eventData)
        {
            ApiResult ret = new ApiResult(ErrorCode.SYS_UNKNOWN_ERR, "");

            try
            {
                var jsData    = JsonUtil.SerializeObject(eventData);
                var newJsData = CommonBLLMethodHelper.HidePd(jsData);
                LogUtil.HWLogger.UI.InfoFormat("Saving FD configuration..., the param is [{0}]", newJsData);
                var fusionDirector = JsonUtil.DeserializeObject <FusionDirectorModel>(jsData);
                var result         = HttpHelper.Instance.TestLinkFD(fusionDirector);
                if (result)
                {
                    var model = FusionDirectorWorker.Instance.FindByIP(fusionDirector.HostIP);
                    model.Port         = fusionDirector.Port;
                    model.AliasName    = fusionDirector.AliasName;
                    model.LoginAccount = fusionDirector.LoginAccount;
                    model.LoginPwd     = EncryptUtil.EncryptPwd(fusionDirector.LoginPwd);
                    if (FusionDirectorWorker.Instance.Update(model))
                    {
                        LogUtil.HWLogger.UI.Info("Edit FD configuration successful!");
                        ret.Code    = "0";
                        ret.Success = true;
                        ret.Msg     = "Edit FD configuration successful!";
                    }
                    else
                    {
                        LogUtil.HWLogger.UI.Info("Edit FD configuration failed!");
                        ret.Code    = ErrorCode.SYS_UNKNOWN_ERR;
                        ret.Success = true;
                        ret.Msg     = "Edit FD configuration failed!";
                    }
                }
            }
            catch (BaseException ex)
            {
                LogUtil.HWLogger.UI.Error("Edit FD configuration failed: ", ex);
                ret.Code    = ex.Code;
                ret.Success = false;
                ret.Msg     = "Edit FD configuration failed!";
            }
            catch (Exception ex)
            {
                LogUtil.HWLogger.UI.Error("Edit FD configuration failed: ", ex);
                ret.Code    = ErrorCode.SYS_UNKNOWN_ERR;
                ret.Success = false;
            }
            return(ret);
        }