/// <summary>
        /// 填充分页查询获得的任务里设备明细
        /// </summary>
        /// <param name="hwTaskPage">传入分页对象</param>
        /// <returns>填充好设备明细的任务分页</returns>
        private QueryPageResult <HWESightTask> FillDeviceDetails(QueryPageResult <HWESightTask> hwTaskPage)
        {
            //生成任务ID组成的字符串。方便后面sql一次查询
            //因为只是查询分页内的数据,所以数据不会很多。
            StringBuilder sb = new StringBuilder("-9999");

            foreach (HWESightTask hwESightTask in hwTaskPage.Data)
            {
                sb.Append(",").Append(hwESightTask.ID);
            }
            //获得任务列表
            IList <HWTaskResource> resourceList = HWTaskResourceDal.Instance.FindTaskResourceByTaskIds(sb.ToString());

            //填充资源数据
            foreach (HWESightTask hwESightTask in hwTaskPage.Data)
            {
                foreach (HWTaskResource hwTaskResource in resourceList)
                {
                    if (hwTaskResource.HWESightTaskID == hwESightTask.ID)
                    {
                        if (!string.IsNullOrEmpty(hwTaskResource.ErrorCode) && !string.Equals(hwTaskResource.ErrorCode, "0"))
                        {
                            hwTaskResource.ErrorCode = errorPix + hwTaskResource.ErrorCode;
                        }
                        hwESightTask.DeviceDetails.Add(hwTaskResource);
                    }
                }
            }
            return(hwTaskPage);
        }
Пример #2
0
        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));
        }
Пример #3
0
        /// <summary>
        /// 查询 iBMC 服务器分页。
        /// </summary>
        /// <param name="queryDeviceParam">查询参数</param>
        /// <returns>分页对象</returns>
        public QueryPageResult <HWDevice> QueryHWPage(DeviceParam queryDeviceParam)
        {
            StringBuilder sb = new StringBuilder(ConstMgr.HWESightHost.URL_DEVICEPAGE);

            sb.Append("?servertype=").Append(queryDeviceParam.ServerType);
            if (queryDeviceParam.StartPage > 0)
            {
                sb.Append("&start=").Append(queryDeviceParam.StartPage);
            }
            if (queryDeviceParam.PageSize > 0)
            {
                sb.Append("&size=").Append(queryDeviceParam.PageSize);
            }
            if (string.IsNullOrEmpty(queryDeviceParam.PageOrder))
            {
                sb.Append("&orderby=").Append(queryDeviceParam.PageOrder);
            }
            if (string.IsNullOrEmpty(queryDeviceParam.PageOrder))
            {
                sb.Append("&desc=").Append(queryDeviceParam.OrderDesc);
            }
            JObject jResult = HCGet(sb.ToString());

            CheckAndThrowDviException(jResult);
            QueryPageResult <HWDevice> pageResult = jResult.ToObject <QueryPageResult <HWDevice> >();

            if (pageResult.Code != 0)
            {
                LogUtil.HWLogger.API.ErrorFormat("openid:" + this.OpenID);
                throw new ESSessionExpceion(pageResult.Code.ToString(), this, "Query device list error:" + pageResult.Description);
            }
            return(pageResult);
        }
        public QueryPageResult <HWESightTask> FindDeployTaskWithSync(QueryDeployPackageParam queryDeployParam)
        {
            SyncDeployTaskFromESight();
            //Search Again.
            QueryPageResult <HWESightTask> hwTaskPage = HWESightTaskDal.Instance.FindDeployPackageTask(this.ESSession.HWESightHost.ID, queryDeployParam);

            return(hwTaskPage);
        }
Пример #5
0
        /// <summary>
        /// Gets the server list.
        /// </summary>
        /// <param name="queryDeviceParam">The query device parameter.</param>
        /// <returns>QueryPageResult&lt;HWDevice&gt;.</returns>
        public QueryPageResult <HWDevice> GetServerList(DeviceParam queryDeviceParam)
        {
            var    result = new QueryPageResult <HWDevice>();
            string url    = string.Empty;

            try
            {
                StringBuilder sb = new StringBuilder("rest/openapi/server/device");
                sb.Append("?servertype=").Append(queryDeviceParam.ServerType);
                if (queryDeviceParam.StartPage > 0)
                {
                    sb.Append("&start=").Append(queryDeviceParam.StartPage);
                }
                if (queryDeviceParam.PageSize > 0)
                {
                    sb.Append("&size=").Append(queryDeviceParam.PageSize);
                }
                if (string.IsNullOrEmpty(queryDeviceParam.PageOrder))
                {
                    sb.Append("&orderby=").Append(queryDeviceParam.PageOrder);
                }
                if (string.IsNullOrEmpty(queryDeviceParam.PageOrder))
                {
                    sb.Append("&desc=").Append(queryDeviceParam.OrderDesc);
                }
                url = this.GetFullUrl(sb.ToString());

                //logger.Api.Info($"GetServerList start.Url:{url}");

                this.CheckAndReLogin();
                this.TrustCertificate();

                var httpClient = new HttpClient();
                httpClient.DefaultRequestHeaders.Add("openid", this.OpenId);
                var res       = httpClient.GetAsync(url).Result;
                var resultStr = res.Content.ReadAsStringAsync().Result;
                logger.Api.Debug($"GetServerList success.Url:{url} \r\nresult:{resultStr}");
                resultStr = resultStr.Replace("\"data\":\"null\"", "\"data\":[]");
                result    = JsonUtil.DeserializeObject <QueryPageResult <HWDevice> >(resultStr);
                if (result.Code != 0)
                {
                    throw new ESSessionExpceion(result.Code.ToString(), this, resultStr);
                }
            }
            catch (Exception ex)
            {
                result.Code        = -1;
                result.Description = ex.Message;
                logger.Api.Error($"GetServerList Error.Url:{url} : ", ex);
                throw;
            }
            return(result);
        }
Пример #6
0
        public void QueryHWPageTest()
        {
            _esSession.Open();
            DeviceParam queryDeviceParam = new DeviceParam();

            queryDeviceParam.ServerType = ConstMgr.HWDevice.SERVER_TYPE_BLADE;
            queryDeviceParam.StartPage  = 1;
            queryDeviceParam.PageSize   = 100;
            queryDeviceParam.PageOrder  = "ipAddress";
            queryDeviceParam.OrderDesc  = true;
            QueryPageResult <HWDevice> hwDevicePageResult = _esSession.QueryHWPage(queryDeviceParam);

            LogUtil.HWLogger.DEFAULT.Info(hwDevicePageResult);
            Assert.IsNotNull(hwDevicePageResult);
        }
Пример #7
0
        public void TestOpenId()
        {
            ESightEngine.Instance.SaveNewESSession(_hwESightHost.HostIP, _hwESightHost.HostPort, _hwESightHost.LoginAccount, _hwESightHost.LoginPwd);
            IESSession  iSession         = ESightEngine.Instance.FindAndOpenESSession(_hwESightHost.HostIP);
            DeviceParam queryDeviceParam = new DeviceParam();

            queryDeviceParam.ServerType = ConstMgr.HWDevice.SERVER_TYPE_BLADE;
            queryDeviceParam.StartPage  = 1;
            queryDeviceParam.PageSize   = 100;
            queryDeviceParam.PageOrder  = "ipAddress";
            queryDeviceParam.OrderDesc  = true;
            QueryPageResult <HWDevice> hwDevicePageResult = iSession.QueryHWPage(queryDeviceParam);

            LogUtil.HWLogger.DEFAULT.Info(hwDevicePageResult);
            Assert.IsTrue(!string.IsNullOrEmpty(iSession.OpenID));
        }
        /// <summary>
        /// 加载服务器列表, 用于服务器列表UI、添加升级任务UI、添加模板任务UI
        /// </summary>
        public static QueryPageResult <HWDevice> GetServerList(object eventData)
        {
            var ret = new QueryPageResult <HWDevice>()
            {
                Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR)
            };

            try
            {
                //1. 解析js传过来的参数
                var jsData            = JsonUtil.SerializeObject(eventData);
                var webOneESightParam = JsonUtil.DeserializeObject <WebOneESightParam <DeviceParam> >(jsData);
                LogUtil.HWLogger.UI.InfoFormat("Querying server list, the param is [{0}]", jsData);
                //2. 根据HostIP获取IESSession
                IESSession esSession = ESSessionHelper.GetESSession(webOneESightParam.ESightIP);
                //3. 获取服务器列表数据
                var hwDevicePageResult = esSession.QueryHWPage(webOneESightParam.Param);
                //4. 返回数据
                ret = hwDevicePageResult;
                LogUtil.HWLogger.UI.InfoFormat("Querying server 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;
                ret.TotalSize   = 0;
                ret.TotalPage   = 0;
                LogUtil.HWLogger.UI.Error("Querying server 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;
                ret.TotalSize   = 0;
                ret.TotalPage   = 0;
                LogUtil.HWLogger.UI.Error("Querying server list failed: ", ex);
            }
            return(ret);
        }
        /// <summary>
        /// 加载模板任务列表
        /// </summary>
        private QueryPageResult <HWESightTask> GetTaskList(object eventData)
        {
            var ret = new QueryPageResult <HWESightTask>()
            {
                Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR)
            };

            try
            {
                //1. 解析js传过来的参数
                var jsData            = JsonUtil.SerializeObject(eventData);
                var webOneESightParam = JsonUtil.DeserializeObject <WebOneESightParam <QueryDeployParam> >(jsData);
                LogUtil.HWLogger.UI.InfoFormat("Querying template task list, the param is [{0}]", jsData);
                //2. 根据HostIP获取IESSession
                IESSession esSession = ESSessionHelper.GetESSession(webOneESightParam.ESightIP);
                //3. 获取模板列表数据
                QueryPageResult <HWESightTask> templateTaskList = esSession.DeployWorker.FindDeployTaskWithSync(webOneESightParam.Param);
                //4. 返回数据
                ret = templateTaskList;
                LogUtil.HWLogger.UI.InfoFormat("Querying template 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;
                ret.TotalPage   = 0;
                ret.TotalSize   = 0;
                LogUtil.HWLogger.UI.Error("Querying template 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;
                ret.TotalPage   = 0;
                ret.TotalSize   = 0;
                LogUtil.HWLogger.UI.Error("Querying template task list failed: ", ex);
            }
            return(ret);
        }
Пример #10
0
        public void QueryHWPageJsonTest()
        {
            _esSession.Open();
            DeviceParam queryDeviceParam = new DeviceParam();

            queryDeviceParam.ServerType = ConstMgr.HWDevice.SERVER_TYPE_BLADE;
            queryDeviceParam.StartPage  = 1;
            queryDeviceParam.PageSize   = 100;
            queryDeviceParam.PageOrder  = "ipAddress";
            queryDeviceParam.OrderDesc  = true;
            WebOneESightParam <DeviceParam> webQueryParam = new WebOneESightParam <DeviceParam>();

            webQueryParam.ESightIP = "127.0.0.1";
            webQueryParam.Param    = queryDeviceParam;
            LogUtil.HWLogger.API.Info("queryDeviceParam:" + JsonUtil.SerializeObject(webQueryParam));

            QueryPageResult <HWDevice> hwDevicePageResult = _esSession.QueryHWPage(queryDeviceParam);

            LogUtil.HWLogger.API.Info("hwDevicePageResult:" + JsonUtil.SerializeObject(hwDevicePageResult));
            Assert.IsNotNull(hwDevicePageResult);
        }
        public void FindDeployTaskWithSyncTest()
        {
            _esSession.Open();
            AddDeployTaskTest();
            QueryDeployParam queryDeployParam = new QueryDeployParam();

            queryDeployParam.PageNo         = 1;
            queryDeployParam.PageSize       = 20;
            queryDeployParam.TaskStatus     = "";//ConstMgr.HWESightTask.TASK_STATUS_RUNNING;
            queryDeployParam.TaskSourceName = "t";
            queryDeployParam.Order          = "taskName";
            queryDeployParam.OrderDesc      = true;
            WebOneESightParam <QueryDeployParam> queryParam = new WebOneESightParam <QueryDeployParam>();

            queryParam.ESightIP = _esSession.HWESightHost.HostIP;
            queryParam.Param    = queryDeployParam;
            LogUtil.HWLogger.API.Info("FindDeployTaskWithSyncTest queryParam:" + JsonUtil.SerializeObject(queryParam));

            QueryPageResult <HWESightTask> taskResult = _esSession.DeployWorker.FindDeployTaskWithSync(queryDeployParam);

            LogUtil.HWLogger.API.Info("FindDeployTaskWithSyncTest QueryPageResult:" + JsonUtil.SerializeObject(taskResult));
        }
        /// <summary>
        ///  查询模板部署任务分页
        /// </summary>
        /// <param name="eSightID"></param>
        /// <param name="queryDeployParam">查询参数</param>
        /// <returns>分页对象</returns>
        public QueryPageResult <HWESightTask> FindDeployPackageTask(int eSightID, QueryDeployPackageParam queryDeployParam)
        {
            QueryPageResult <HWESightTask> queryPageResult = new QueryPageResult <HWESightTask>();
            int    totalCount = 0;
            string sql        = " HW_ESIGHT_HOST_ID=" + eSightID;

            if (!string.IsNullOrWhiteSpace(queryDeployParam.TaskeName))
            {
                sql += " and TASK_NAME like '%" + this.ReplaceQuote(queryDeployParam.TaskeName.Trim()) + "%'";
            }

            if (!string.IsNullOrWhiteSpace(queryDeployParam.TaskStatus))
            {
                sql += " and SYNC_STATUS ='" + this.ReplaceQuote(queryDeployParam.TaskStatus.Trim()) + "'";
            }

            queryPageResult.Data = GetList(out totalCount, sql
                                           + " and TASK_TYPE='" + ConstMgr.HWESightTask.TASK_TYPE_DEPLOYFIRMWARE + "'",
                                           queryDeployParam.PageSize, queryDeployParam.PageNo, queryDeployParam.Order, queryDeployParam.OrderDesc);
            queryPageResult.TotalSize = totalCount;
            queryPageResult.TotalPage = GetPageCount(queryDeployParam.PageSize, totalCount);
            return(queryPageResult);
        }