/// <summary> /// 删除升级任务 /// </summary> private WebReturnResult <int> Delete(object eventData) { var ret = new WebReturnResult <int>() { Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR) }; try { //1. 获取UI传来的参数 var jsData = JsonUtil.SerializeObject(eventData); var webOneESightParam = JsonUtil.DeserializeObject <WebOneESightParam <ParamOfDeleteTask> >(jsData); LogUtil.HWLogger.UI.InfoFormat("Deleting firmware task..., the param is [{0}]", jsData); //2. 根据HostIP获取IESSession IESSession esSession = ESSessionHelper.GetESSession(webOneESightParam.ESightIP); //3. 删除升级任务 int deleteResult = esSession.BasePackageWorker.DeleteTask(webOneESightParam.Param.TaskId); //4. 返回数据 ret.Code = 0; ret.Description = "Deleting firmware task successful!"; ret.Data = deleteResult; LogUtil.HWLogger.UI.InfoFormat("Deleting firmware task successful! the ret is [{0}]", JsonUtil.SerializeObject(ret)); } catch (BaseException ex) { LogUtil.HWLogger.UI.Error("Deleting firmware task failed: ", ex); ret.Code = CoreUtil.GetObjTranNull <int>(ex.Code); ret.ErrorModel = ex.ErrorModel; ret.Description = ex.Message; ret.Data = 0; } catch (Exception ex) { LogUtil.HWLogger.UI.Error("Deleting firmware task failed: ", ex); ret.Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR); ret.Description = ex.InnerException.Message ?? ex.Message; ret.Data = 0; } return(ret); }
/// <summary> /// 加载固件升级包明细列表 /// </summary> private ApiResult <BasePackageDetail> GetFirmwareDetails(object eventData) { var ret = new ApiResult <BasePackageDetail>(false, ConstMgr.ErrorCode.SYS_UNKNOWN_ERR, "", "", null); try { //1. 解析js传过来的参数 var jsData = JsonUtil.SerializeObject(eventData); var webOneESightParam = JsonUtil.DeserializeObject <WebOneESightParam <ParamOfQueryBasePackageDetail> >(jsData); LogUtil.HWLogger.UI.InfoFormat("Querying basepackage detail, the param is: [{0}] [{1}]", webOneESightParam.ESightIP, webOneESightParam.Param.BasepackageName); //2. 根据HostIP获取IESSession IESSession esSession = ESSessionHelper.GetESSession(webOneESightParam.ESightIP); //3. 获取固件升级包明细数据 QueryObjectResult <BasePackageDetail> basePackageDetail = esSession.BasePackageWorker.QueryBasePackageDetail(webOneESightParam.Param.BasepackageName); //4. 组织数据 ret.Code = basePackageDetail.Code.ToString(); ret.Success = basePackageDetail.Code == 0 ? true : false; ret.Data = basePackageDetail.Data; LogUtil.HWLogger.UI.InfoFormat("Querying basepackage detail successful, the ret is: [{0}]", JsonUtil.SerializeObject(ret)); } catch (BaseException ex) { ret.Code = string.Format("{0}{1}", ex.ErrorModel, ex.Code); ret.Success = false; ret.ExceptionMsg = ex.Message; ret.Data = null; LogUtil.HWLogger.UI.Error("Querying basepackage detail failed: ", ex); } catch (Exception ex) { ret.Code = ConstMgr.ErrorCode.SYS_UNKNOWN_ERR; ret.Success = false; ret.ExceptionMsg = ex.InnerException.Message ?? ex.Message; ret.Data = null; LogUtil.HWLogger.UI.Error("Querying basepackage detail failed: ", ex); } return(ret); }
/// <summary> /// 删除模板 /// </summary> private ApiResult Delete(object eventData) { ApiResult ret = new ApiResult(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR, ""); try { LogUtil.HWLogger.UI.InfoFormat("Deleting template..., the param is [{0}]", JsonUtil.SerializeObject(eventData)); //1. 获取UI传来的参数 var jsData = eventData as Dictionary <string, object>; string hostIP = DictHelper.GetDicValue(jsData, "hostIP"); string templateName = DictHelper.GetDicValue(jsData, "templateName"); //2. 根据HostIP获取IESSession IESSession esSession = ESSessionHelper.GetESSession(hostIP); //3. 删除模板 esSession.DeployWorker.DelDeployTemplate(templateName); LogUtil.HWLogger.UI.Info("Deleting template successful!"); ret.Code = "0"; ret.Success = true; ret.Msg = "Deleting template successful!"; } catch (BaseException ex) { LogUtil.HWLogger.UI.Error("Deleting template failed: ", ex); ret.Code = string.Format("{0}{1}", ex.ErrorModel, ex.Code); ret.Success = false; ret.ExceptionMsg = ex.Message; } catch (Exception ex) { LogUtil.HWLogger.UI.Error("Deleting template failed: ", ex); ret.Code = ConstMgr.ErrorCode.SYS_UNKNOWN_ERR; ret.Success = false; ret.ExceptionMsg = ex.InnerException.Message ?? ex.Message; } return(ret); }
/// <summary> /// 添加升级包 /// </summary> private ApiListResult <WebReturnESightResult> Save(object eventData) { var ret = new ApiListResult <WebReturnESightResult>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR, ""); try { //1. 获取UI传来的参数 var jsData = JsonUtil.SerializeObject(eventData); var newJsData = CommonBLLMethodHelper.HidePassword(jsData); LogUtil.HWLogger.UI.InfoFormat("Saving basepackage..., the param is [{0}]", newJsData); WebMutilESightsParam <BasePackage> webMutilESightsParam = JsonUtil.DeserializeObject <WebMutilESightsParam <BasePackage> >(jsData); //2. 根据HostIP获取IESSession IList <WebReturnESightResult> webReturnESightResultList = new List <WebReturnESightResult>(); int eSightCount = webMutilESightsParam.ESights.Count; int errorCount = 0; string errorCode = ""; foreach (string hostIP in webMutilESightsParam.ESights) { IESSession esSession = null; //3. 保存 WebReturnESightResult webReturnESightResult = new WebReturnESightResult(); try { esSession = ESSessionHelper.GetESSession(hostIP); esSession.BasePackageWorker.UploadBasePackage(webMutilESightsParam.Data); webReturnESightResult.ESightIp = hostIP; webReturnESightResult.Code = 0; webReturnESightResult.Description = "successful"; LogUtil.HWLogger.UI.InfoFormat("Saving basepackage successful on eSight [{0}]", webReturnESightResult.ESightIp); } catch (BaseException ex) { webReturnESightResult.ESightIp = hostIP; webReturnESightResult.Code = CommonUtil.CoreUtil.GetObjTranNull <int>(ex.Code); webReturnESightResult.ErrorModel = ex.ErrorModel; webReturnESightResult.Description = ex.Message; errorCount++; SetErrorCode(errorCount, ex.Code, ex.ErrorModel, ref errorCode); LogUtil.HWLogger.UI.Error(string.Format("Saving basepackage failed on eSight [{0}]: ", webReturnESightResult.ESightIp), ex); } catch (Exception ex) { webReturnESightResult.ESightIp = hostIP; webReturnESightResult.Code = CommonUtil.CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR); webReturnESightResult.Description = ex.InnerException.Message ?? ex.Message; errorCount++; SetErrorCode(errorCount, ConstMgr.ErrorCode.SYS_UNKNOWN_ERR, "", ref errorCode); LogUtil.HWLogger.UI.Error(string.Format("Saving basepackage failed on eSight [{0}]: ", webReturnESightResult.ESightIp), ex); } webReturnESightResultList.Add(webReturnESightResult); } SetSaveResultWhenComplete(errorCount, eSightCount, errorCode, ref ret); ret.Data = webReturnESightResultList; LogUtil.HWLogger.UI.InfoFormat("Saving basepackage completed! the ret is [{0}]", JsonUtil.SerializeObject(ret)); } catch (BaseException ex) { LogUtil.HWLogger.UI.Error("Saving basepackage failed: ", ex); ret.Code = string.Format("{0}{1}", ex.ErrorModel, ex.Code); ret.Success = false; ret.ExceptionMsg = ex.Message; ret.Data = null; } catch (Exception ex) { LogUtil.HWLogger.UI.Error("Saving basepackage failed: ", ex); ret.Code = ConstMgr.ErrorCode.SYS_UNKNOWN_ERR; ret.Success = false; ret.ExceptionMsg = ex.InnerException.Message ?? ex.Message; ret.Data = null; } return(ret); }