public void AddDeployTaskTest() { _esSession.Open(); string basepackageName = "test1"; DeployPackageTask deployTask = new DeployPackageTask(); deployTask.BasepackageName = "basepackage1"; deployTask.DeviceDn = "NE=123;NE=1234"; deployTask.FirmwareList = "CAN,SSD"; WebOneESightParam <dynamic> postParam = new WebOneESightParam <dynamic>(); postParam.ESightIP = "127.0.0.1"; postParam.Param = deployTask; LogUtil.HWLogger.API.Info("AddDeployTaskTest postParam:" + JsonUtil.SerializeObject(postParam)); string taskName = _esSession.BasePackageWorker.AddDeployTask(deployTask); JObject taskObject = new JObject(); taskObject.Add("taskName", taskName); WebReturnResult <JObject> taskResult = new WebReturnResult <JObject>(); taskResult.Data = taskObject; taskResult.Description = ""; LogUtil.HWLogger.API.Info("AddDeployTaskTest Result:" + JsonUtil.SerializeObject(taskResult)); }
/// <summary> /// 删除失败的软件源任务 /// </summary> private WebReturnResult <int> DeleteTask(object eventData) { var ret = new WebReturnResult <int>() { Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR), Description = "", Data = 0 }; try { LogUtil.HWLogger.UI.Info("Deleting failed software source task..."); int deleteTaskResult = ESightEngine.Instance.ClearAllFailedSoftwareSourceTask(); ret.Code = 0; ret.Data = deleteTaskResult; ret.Description = "Deleting failed software source task successful!"; LogUtil.HWLogger.UI.InfoFormat("Deleting failed software source task successful! the ret is [{0}]", JsonUtil.SerializeObject(ret)); } catch (BaseException ex) { LogUtil.HWLogger.UI.Error("Deleting failed software source task failed: ", ex); ret.Code = CoreUtil.GetObjTranNull <int>(ex.Code); ret.ErrorModel = ex.ErrorModel; ret.Data = 0; ret.Description = ex.Message; } catch (Exception ex) { LogUtil.HWLogger.UI.Error("Deleting failed software source task failed: ", ex); ret.Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR); ret.Data = 0; ret.Description = ex.InnerException.Message ?? ex.Message; } return(ret); }
public void FindDeployTaskWithSyncTest() { _esSession.Open(); AddDeployTaskTest(); QueryDeployPackageParam queryDeployParam = new QueryDeployPackageParam(); queryDeployParam.PageNo = 1; queryDeployParam.PageSize = 20; queryDeployParam.TaskStatus = "";//ConstMgr.HWESightTask.TASK_STATUS_RUNNING; queryDeployParam.TaskeName = "t"; queryDeployParam.Order = "taskName"; queryDeployParam.OrderDesc = false; WebOneESightParam <QueryDeployPackageParam> queryParam = new WebOneESightParam <QueryDeployPackageParam>(); queryParam.ESightIP = _esSession.HWESightHost.HostIP; queryParam.Param = queryDeployParam; LogUtil.HWLogger.API.Info("FindDeployTaskWithSyncTest queryParam:" + JsonUtil.SerializeObject(queryParam)); QueryPageResult <HWESightTask> taskResult = _esSession.BasePackageWorker.FindDeployTaskWithSync(queryDeployParam); WebReturnResult <QueryPageResult <HWESightTask> > ret = new WebReturnResult <QueryPageResult <HWESightTask> >(); ret.Code = 0; ret.Description = ""; ret.Data = taskResult; LogUtil.HWLogger.API.Info("FindDeployTaskWithSyncTest QueryPageResult:" + JsonUtil.SerializeObject(ret)); }
public void AddDeployTaskTest() { _esSession.Open(); string basepackageName = "test1"; DeployTask deployTask = new DeployTask(); deployTask.DeviceDn = "NE=123;NE=1234;NE=34603357;NE=34603313"; deployTask.Templates = "template1,poweron1"; var newSource = new { deployTaskName = basepackageName, deviceDn = deployTask.DeviceDn, templates = deployTask.Templates }; WebOneESightParam <dynamic> postParam = new WebOneESightParam <dynamic>(); postParam.ESightIP = "127.0.0.1"; postParam.Param = newSource; LogUtil.HWLogger.API.Info("AddDeployTaskTest postParam:" + JsonUtil.SerializeObject(postParam)); string taskName = _esSession.DeployWorker.AddDeployTask(basepackageName, deployTask); JObject taskObject = new JObject(); taskObject.Add("taskName", taskName); WebReturnResult <JObject> taskResult = new WebReturnResult <JObject>(); taskResult.Data = taskObject; taskResult.Description = ""; LogUtil.HWLogger.API.Info("AddDeployTaskTest Result:" + JsonUtil.SerializeObject(taskResult)); }
public void FindAllSoftwareSourceTaskWithSyncTest() { List <HWESightTask> taskList = new List <HWESightTask>(ESightEngine.Instance.FindAllSoftwareSourceTaskWithSync()); WebReturnResult <List <HWESightTask> > ret = new WebReturnResult <List <HWESightTask> >(); ret.Code = 0; ret.Description = ""; ret.Data = taskList; LogUtil.HWLogger.API.InfoFormat("FindAllSoftwareSourceTaskWithSyncTest Result:" + JsonUtil.SerializeObject(taskList)); }
public void ClearFailedTask() { var delTask = new { }; LogUtil.HWLogger.API.Info("ClearFailedTask packageParam:" + JsonUtil.SerializeObject(delTask)); WebReturnResult <int> ret = new WebReturnResult <int>(); ret.Code = 0; ret.Description = ""; ret.Data = ESightEngine.Instance.ClearAllFailedPackageTask(); LogUtil.HWLogger.API.Info("ClearFailedTask QueryPageResult:" + JsonUtil.SerializeObject(ret)); }
public void QueryDeployTaskDNProcessTest() { _esSession.Open(); string taskName = "API@FirmWareTask_1503898934595"; string dn = "NE=34603009"; var firmwareTaskDetail = _esSession.BasePackageWorker.QueryDeployTaskDNProcess(taskName, dn); var ret = new WebReturnResult <BasePackageDNProgress>(); ret.Code = firmwareTaskDetail.Code; ret.Data = firmwareTaskDetail.Data; ret.Description = firmwareTaskDetail.Description; LogUtil.HWLogger.API.InfoFormat("QueryDeployTaskDNProcess QueryPageResult: {0}", JsonUtil.SerializeObject(ret)); Assert.IsNotNull(ret.Data); }
public void DeleteTaskTest() { var delTask = new { taskId = 1 }; WebOneESightParam <dynamic> packageParam = new WebOneESightParam <dynamic>(); packageParam.ESightIP = "127.0.0.1"; packageParam.Param = delTask; LogUtil.HWLogger.API.Info("DeleteTaskTest packageParam:" + JsonUtil.SerializeObject(packageParam)); WebReturnResult <int> ret = new WebReturnResult <int>(); ret.Code = 0; ret.Description = ""; ret.Data = _esSession.BasePackageWorker.DeleteTask(delTask.taskId); LogUtil.HWLogger.API.Info("DeleteTaskTest QueryPageResult:" + JsonUtil.SerializeObject(ret)); }
public void FindUnFinishedUploadPackageTask() { _esSession.Open(); List <HWESightTask> hwTaskList = new List <HWESightTask>(_esSession.BasePackageWorker.FindUnFinishedUploadPackageTask()); Assert.IsNotNull(hwTaskList); UploadBasePackageJsonTest(); hwTaskList = new List <HWESightTask>(_esSession.BasePackageWorker.FindUnFinishedUploadPackageTask()); LogUtil.HWLogger.API.Info("FindUnFinishedTaskToJson:" + JsonUtil.SerializeObject(hwTaskList)); WebReturnResult <List <HWESightTask> > ret = new WebReturnResult <List <HWESightTask> >(); ret.Code = 0; ret.Description = ""; ret.Data = hwTaskList; LogUtil.HWLogger.API.Info("FindUnFinishedTaskToJson:" + JsonUtil.SerializeObject(ret)); Assert.IsTrue(hwTaskList.Count >= 0); }
/// <summary> /// 添加模板任务 /// </summary> private WebReturnResult <JObject> Save(object eventData) { var ret = new WebReturnResult <JObject>() { Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR) }; try { //1. 获取UI传来的参数 var jsData = JsonUtil.SerializeObject(eventData); var webOneESightParam = JsonUtil.DeserializeObject <WebOneESightParam <ParamOfAddDeployTask> >(jsData); LogUtil.HWLogger.UI.InfoFormat("Saving template task..., the param is [{0}]", jsData); //2. 根据HostIP获取IESSession IESSession esSession = ESSessionHelper.GetESSession(webOneESightParam.ESightIP); //3. 保存 DeployTask deployTask = new DeployTask(); deployTask.DeviceDn = webOneESightParam.Param.DeviceDn; deployTask.Templates = webOneESightParam.Param.Templates; string taskName = esSession.DeployWorker.AddDeployTask(webOneESightParam.Param.TaskSourceName, deployTask); //4. 返回数据 JObject taskObject = new JObject(); taskObject.Add("taskName", taskName); ret.Code = 0; ret.Description = ""; ret.Data = taskObject; LogUtil.HWLogger.UI.InfoFormat("Saving template task completed! the ret is [{0}]", JsonUtil.SerializeObject(ret)); } catch (BaseException ex) { LogUtil.HWLogger.UI.Error("Saving template task failed: ", ex); ret.Code = CoreUtil.GetObjTranNull <int>(ex.Code); ret.ErrorModel = ex.ErrorModel; ret.Description = ex.Message; ret.Data = null; } catch (Exception ex) { LogUtil.HWLogger.UI.Error("Saving template task failed: ", ex); ret.Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR); ret.Description = ex.InnerException.Message ?? ex.Message; ret.Data = null; } return(ret); }
public void QueryDeployTaskProcessTest() { _esSession.Open(); var packageTask = new { taskName = "API@Task_1456209500919" }; WebOneESightParam <dynamic> packageParam = new WebOneESightParam <dynamic>(); packageParam.ESightIP = "127.0.0.1"; packageParam.Param = packageTask; LogUtil.HWLogger.API.Info("QueryDeployTaskProcessTest packageParam:" + JsonUtil.SerializeObject(packageParam)); DeployPackageTaskDetail taskDetail = _esSession.BasePackageWorker.QueryDeployTaskProcess(packageTask.taskName); WebReturnResult <DeployPackageTaskDetail> ret = new WebReturnResult <DeployPackageTaskDetail>(); ret.Code = 0; ret.Description = ""; ret.Data = taskDetail; LogUtil.HWLogger.API.Info("QueryDeployTaskProcessTest basePackageProcess:" + JsonUtil.SerializeObject(ret)); }
/// <summary> /// 查询升级任务详情 /// </summary> /// <param name="eventData">JS参数</param> /// <returns></returns> private WebReturnResult <BasePackageDNProgress> GetTaskDetail(object eventData) { var ret = new WebReturnResult <BasePackageDNProgress>() { Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR) }; try { //1. 解析js传过来的参数 var jsData = JsonUtil.SerializeObject(eventData); var webOneESightParam = JsonUtil.DeserializeObject <WebOneESightParam <ParamOfQueryFirmewareDetail> >(jsData); LogUtil.HWLogger.UI.InfoFormat("Querying firmware task detail, the param is [{0}]", jsData); //2. 根据HostIP获取IESSession IESSession esSession = ESSessionHelper.GetESSession(webOneESightParam.ESightIP); //3. 获取升级任务详情 string taskName = webOneESightParam.Param.TaskName; string dn = webOneESightParam.Param.DN; var firmwareTaskDetail = esSession.BasePackageWorker.QueryDeployTaskDNProcess(taskName, dn); //4. 返回数据 ret.Code = firmwareTaskDetail.Code; ret.Data = firmwareTaskDetail.Data; ret.Description = firmwareTaskDetail.Description; LogUtil.HWLogger.UI.InfoFormat("Querying firmware task detail successful, the ret is [{0}]", JsonUtil.SerializeObject(ret)); } catch (BaseException ex) { ret.Code = CoreUtil.GetObjTranNull <int>(ex.Code); ret.ErrorModel = ex.ErrorModel; ret.Description = ex.Message; ret.Data = null; LogUtil.HWLogger.UI.Error("Querying firmware task detail failed: ", ex); } catch (Exception ex) { ret.Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR); ret.Description = ex.InnerException.Message ?? ex.Message; ret.Data = null; LogUtil.HWLogger.UI.Error("Querying firmware task detail failed: ", ex); } return(ret); }
/// <summary> /// 删除已上传的升级包 /// </summary> /// <param name="eventData"></param> /// <returns></returns> private WebReturnResult <int> DeleteBasepackage(object eventData) { var ret = new WebReturnResult <int>() { Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR) }; try { //1. 解析js传过来的参数 var jsData = JsonUtil.SerializeObject(eventData); var webOneESightParam = JsonUtil.DeserializeObject <WebOneESightParam <ParamOfQueryBasePackageDetail> >(jsData); LogUtil.HWLogger.UI.InfoFormat("Deleting basepackage..., the param is [{0}]", jsData); //2. 根据HostIP获取IESSession IESSession esSession = ESSessionHelper.GetESSession(webOneESightParam.ESightIP); //3. 获取升级任务详情 string basepackageName = webOneESightParam.Param.BasepackageName; esSession.BasePackageWorker.DeleteBasePackage(basepackageName); //4. 返回数据 ret.Code = 0; ret.Data = 1; ret.Description = "delete FMBasePackage File success."; LogUtil.HWLogger.UI.InfoFormat("Deleting basepackage successful, the ret is [{0}]", JsonUtil.SerializeObject(ret)); } catch (BaseException ex) { ret.Code = CoreUtil.GetObjTranNull <int>(ex.Code); ret.ErrorModel = ex.ErrorModel; ret.Description = ex.Message; ret.Data = 0; LogUtil.HWLogger.UI.Error("Deleting basepackage failed: ", ex); } catch (Exception ex) { ret.Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR); ret.Description = ex.InnerException.Message ?? ex.Message; ret.Data = 0; LogUtil.HWLogger.UI.Error("Deleting basepackage failed: ", ex); } return(ret); }
private WebReturnResult <DeployTemplate> GetTemplateDetail(object eventData) { var ret = new WebReturnResult <DeployTemplate>() { Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR) }; try { //1. 解析js传过来的参数 var jsData = JsonUtil.SerializeObject(eventData); var webOneESightParam = JsonUtil.DeserializeObject <WebOneESightParam <ParamOfQueryTemplateDetail> >(jsData); LogUtil.HWLogger.UI.InfoFormat("Querying template detail, the param is [{0}]", jsData); //2. 根据HostIP获取IESSession IESSession esSession = ESSessionHelper.GetESSession(webOneESightParam.ESightIP); //3. 获取升级任务详情 string templateName = webOneESightParam.Param.TemplateName; var templateDetail = esSession.DeployWorker.QueryDeployTemplate(templateName); //4. 返回数据 ret.Code = 0; ret.Data = templateDetail; ret.Description = "Operation success."; LogUtil.HWLogger.UI.InfoFormat("Querying template detail successful, the ret is [{0}]", JsonUtil.SerializeObject(ret)); } catch (BaseException ex) { ret.Code = CoreUtil.GetObjTranNull <int>(ex.Code); ret.ErrorModel = ex.ErrorModel; ret.Description = ex.Message; ret.Data = null; LogUtil.HWLogger.UI.Error("Querying template detail failed: ", ex); } catch (Exception ex) { ret.Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR); ret.Description = ex.InnerException.Message ?? ex.Message; ret.Data = null; LogUtil.HWLogger.UI.Error("Querying template detail failed: ", ex); } return(ret); }
/// <summary> /// 查询服务器详细信息 /// </summary> /// <param name="eventData">JS传递的参数</param> /// <returns></returns> public static WebReturnResult <QueryListResult <HWDeviceDetail> > GetDeviceDetail(object eventData) { var ret = new WebReturnResult <QueryListResult <HWDeviceDetail> >() { Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR) }; try { //1. 解析js传过来的参数 var jsData = JsonUtil.SerializeObject(eventData); var webOneESightParam = JsonUtil.DeserializeObject <ParamOfQueryDeviceDetail>(jsData); LogUtil.HWLogger.UI.InfoFormat("Querying server detail, the param is [{0}]", jsData); //2. 根据HostIP获取IESSession IESSession esSession = ESSessionHelper.GetESSession(webOneESightParam.ESightIP); //3. 获取升级任务详情 string dn = webOneESightParam.DN; var hwDeviceDetailList = esSession.DviWorker.QueryForDeviceDetail(dn); //4. 返回数据 ret.Code = 0; ret.Data = hwDeviceDetailList; ret.Description = "Succeeded in querying server details."; LogUtil.HWLogger.UI.InfoFormat("Querying server detail successful, the ret is [{0}]", JsonUtil.SerializeObject(ret)); } catch (BaseException ex) { ret.Code = CoreUtil.GetObjTranNull <int>(ex.Code); ret.ErrorModel = ex.ErrorModel; ret.Description = ex.Message; ret.Data = null; LogUtil.HWLogger.UI.Error("Querying server detail failed: ", ex); } catch (Exception ex) { ret.Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR); ret.Description = ex.InnerException.Message ?? ex.Message; ret.Data = null; LogUtil.HWLogger.UI.Error("Querying server detail failed: ", ex); } return(ret); }
/// <summary> /// 删除软件源 /// </summary> private WebReturnResult <int> Delete(object eventData) { var ret = new WebReturnResult <int>() { Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR), Description = "", Data = 0 }; try { //1. 获取UI传来的参数 var jsData = JsonUtil.SerializeObject(eventData); var webOneESightParam = JsonUtil.DeserializeObject <WebOneESightParam <string> >(jsData); LogUtil.HWLogger.UI.InfoFormat("Deleting software source..., the param is [{0}]", jsData); //2. 根据HostIP获取IESSession IESSession esSession = ESSessionHelper.GetESSession(webOneESightParam.ESightIP); //3. 删除模板 esSession.SoftSourceWorker.DeleteSoftwareSource(webOneESightParam.Param); //4. 返回数据 ret.Code = 0; ret.Data = 1; ret.Description = ""; LogUtil.HWLogger.UI.InfoFormat("Deleting software source successful! the ret is: [{0}]", JsonUtil.SerializeObject(ret)); } catch (BaseException ex) { LogUtil.HWLogger.UI.Error("Deleting software source failed: ", ex); ret.Code = CoreUtil.GetObjTranNull <int>(ex.Code); ret.ErrorModel = ex.ErrorModel; ret.Data = 0; ret.Description = ex.Message; } catch (Exception ex) { LogUtil.HWLogger.UI.Error("Deleting software source failed: ", ex); ret.Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR); ret.Data = 0; ret.Description = ex.InnerException.Message ?? ex.Message; } return(ret); }
/// <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 template task..., the param is [{0}]", jsData); //2. 根据HostIP获取IESSession IESSession esSession = ESSessionHelper.GetESSession(webOneESightParam.ESightIP); //3. 删除模板任务 int deleteResult = esSession.DeployWorker.DeleteTask(webOneESightParam.Param.TaskId); //4. 返回数据 ret.Code = 0; ret.Description = "Deleting template task successful!"; ret.Data = deleteResult; LogUtil.HWLogger.UI.InfoFormat("Deleting template task successful! the ret is [{0}]", JsonUtil.SerializeObject(ret)); } catch (BaseException ex) { LogUtil.HWLogger.UI.Error("Deleting template 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 template 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); }
public void TestJsonResult() { List <WebReturnESightResult> list = new List <WebReturnESightResult>(); WebReturnESightResult webReturnESightResult1 = new WebReturnESightResult(); webReturnESightResult1.ESightIp = "127.0.0.1"; webReturnESightResult1.Code = 0; webReturnESightResult1.Description = "成功"; list.Add(webReturnESightResult1); WebReturnESightResult webReturnESightResult2 = new WebReturnESightResult(); webReturnESightResult2.ESightIp = "127.0.0.3"; webReturnESightResult2.Code = 51001; webReturnESightResult2.Description = "模板名称重复,模板已存在"; list.Add(webReturnESightResult2); WebReturnResult <List <WebReturnESightResult> > taskResult = new WebReturnResult <List <WebReturnESightResult> >(); taskResult.Data = list; taskResult.Code = 51001; taskResult.Description = "模板名称重复,模板已存在"; LogUtil.HWLogger.API.Info("TestJsonResult Result:" + JsonUtil.SerializeObject(taskResult)); }
public void UploadBasePackageJsonTest() { _esSession.Open(); BasePackage basePackage = new BasePackage(); basePackage.BasepackageName = "basepackage1"; basePackage.BasepackageDescription = "This is a basepackage."; basePackage.BasepackageType = ConstMgr.HWBasePackage.PACKAGE_TYPE_FIRMWARE; basePackage.FileList = "iBMC.zip,iBMC.zip.asc"; basePackage.SftpserverIP = "188.10.18.188"; basePackage.SftpUserName = "******"; basePackage.SftpPassword = "******"; WebMutilESightsParam <BasePackage> postESightParam = new WebMutilESightsParam <BasePackage>(); postESightParam.ESights = new List <string>() { "127.0.0.1" }; postESightParam.Data = basePackage; LogUtil.HWLogger.API.Info("UploadBasePackageJsonTest Params:" + JsonUtil.SerializeObject(postESightParam)); string taskName = _esSession.BasePackageWorker.UploadBasePackage(basePackage); JObject taskObject = new JObject(); taskObject.Add("taskName", taskName); WebReturnResult <JObject> taskResult = new WebReturnResult <JObject>(); taskResult.Data = taskObject; taskResult.Description = ""; LogUtil.HWLogger.API.Info("UploadBasePackageJsonTest Result:" + JsonUtil.SerializeObject(taskResult)); Assert.IsTrue(!string.IsNullOrEmpty(taskName)); }
/// <summary> /// 加载软件源任务列表 /// </summary> private WebReturnResult <List <HWESightTask> > GetSoftwareSourceTaskList(object eventData) { var ret = new WebReturnResult <List <HWESightTask> >() { Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR), Description = "" }; try { LogUtil.HWLogger.UI.InfoFormat("Querying software source task list..."); //1. ESightEngine.Instance.InitESSessions(); //2. 获取软件源任务数据 List <HWESightTask> hwESightTaskList = new List <HWESightTask>(ESightEngine.Instance.FindAllSoftwareSourceTaskWithSync()); //3. 组织数据 ret.Code = 0; ret.Data = hwESightTaskList; ret.Description = ""; LogUtil.HWLogger.UI.InfoFormat("Querying software source task list successful, the ret is: [{0}]", JsonUtil.SerializeObject(ret)); } catch (BaseException ex) { ret.Code = CoreUtil.GetObjTranNull <int>(ex.Code); ret.ErrorModel = ex.ErrorModel; ret.Description = ex.Message; ret.Data = null; LogUtil.HWLogger.UI.Error("Querying software source task list failed: ", ex); } catch (Exception ex) { ret.Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR); ret.Description = ex.InnerException.Message ?? ex.Message; ret.Data = null; LogUtil.HWLogger.UI.Error("Querying software source task list failed: ", ex); } return(ret); }
/// <summary> /// 保存软件源 /// </summary> private WebReturnResult <List <WebReturnESightResult> > Save(object eventData) { var ret = new WebReturnResult <List <WebReturnESightResult> >() { Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR), Description = "" }; try { //1. 获取UI传来的参数 var jsData = JsonUtil.SerializeObject(eventData); var newJsData = CommonBLLMethodHelper.HidePassword(jsData); LogUtil.HWLogger.UI.InfoFormat("Saving software source..., the param is [{0}]", newJsData); var webMutilESightsParam = JsonUtil.DeserializeObject <WebMutilESightsParam <SoftwareSource> >(jsData); //2. 根据HostIP获取IESSession List <WebReturnESightResult> webReturnESightResultList = new List <WebReturnESightResult>(); int eSightCount = webMutilESightsParam.ESights.Count; int errorCount = 0; int errorCode = 0; string errorModel = ""; foreach (string hostIP in webMutilESightsParam.ESights) { IESSession esSession = null; //3. 保存软件源 WebReturnESightResult webReturnESightResult = new WebReturnESightResult(); try { esSession = ESSessionHelper.GetESSession(hostIP); esSession.SoftSourceWorker.UploadSoftwareSource(webMutilESightsParam.Data); webReturnESightResult.ESightIp = hostIP; webReturnESightResult.Code = 0; webReturnESightResult.Description = "successful"; LogUtil.HWLogger.UI.InfoFormat("Saving software source 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, ref errorModel); LogUtil.HWLogger.UI.Error(string.Format("Saving software source 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.Message; errorCount++; SetErrorCode(errorCount, ConstMgr.ErrorCode.SYS_UNKNOWN_ERR, "", ref errorCode, ref errorModel); LogUtil.HWLogger.UI.Error(string.Format("Saving software source failed on eSight [{0}]: ", webReturnESightResult.ESightIp), ex); } webReturnESightResultList.Add(webReturnESightResult); } SetSaveResultWhenComplete(errorCount, eSightCount, errorCode, errorModel, ref ret); ret.Description = ""; ret.Data = webReturnESightResultList; LogUtil.HWLogger.UI.InfoFormat("Saving software source completed! the ret is [{0}]", JsonUtil.SerializeObject(ret)); } catch (BaseException ex) { LogUtil.HWLogger.UI.Error("Saving software source failed: ", ex); ret.Code = CoreUtil.GetObjTranNull <int>(ex.Code); ret.ErrorModel = ex.ErrorModel; ret.Description = ex.Message; ret.Data = null; } catch (Exception ex) { LogUtil.HWLogger.UI.Error("Saving software source failed: ", ex); ret.Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR); ret.Description = ex.InnerException.Message ?? ex.Message; ret.Data = null; } return(ret); }
private void SetSaveResultWhenComplete(int errorCount, int eSightCount, int errorCode, string errorModel, ref WebReturnResult <List <WebReturnESightResult> > ret) { if (errorCount == 0) { ret.Code = 0; } else if (errorCount == eSightCount) { ret.Code = errorCode; } else { ret.Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_PART_ERR); } ret.ErrorModel = errorModel; }