public void QuerySoftwarePageToJsonTest()
        {
            _esSession.Open();
            QueryLGListResult <SourceItem> queryLgListResult = _esSession.SoftSourceWorker.QuerySoftwarePage(1, 20);
            WebReturnLGResult <SourceItem> retResult         = new WebReturnLGResult <SourceItem>(queryLgListResult);

            LogUtil.HWLogger.API.Info("QuerySoftwarePageToJsonTest:" + JsonUtil.SerializeObject(retResult));
            Assert.IsNotNull(queryLgListResult);
        }
        /// <summary>
        /// 加载模板列表, 用于模板列表UI、添加模板任务UI
        /// </summary>
        public static WebReturnLGResult <DeployTemplate> GetTemplateList(object eventData)
        {
            var ret = new WebReturnLGResult <DeployTemplate>()
            {
                Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR)
            };

            try
            {
                //1. 解析js传过来的参数
                var jsData            = JsonUtil.SerializeObject(eventData);
                var webOneESightParam = JsonUtil.DeserializeObject <WebOneESightParam <ParamPagingOfQueryTemplate> >(jsData);
                LogUtil.HWLogger.UI.InfoFormat("Querying template list, the param is [{0}]", jsData);
                int    pageNo       = -1;
                int    pageSize     = int.MaxValue;
                string templateType = "";
                if (webOneESightParam.Param != null)
                {
                    pageSize     = webOneESightParam.Param.PageSize;
                    pageNo       = webOneESightParam.Param.PageNo;
                    templateType = webOneESightParam.Param.TemplateType;
                }

                //2. 根据HostIP获取IESSession
                IESSession esSession = ESSessionHelper.GetESSession(webOneESightParam.ESightIP);
                //3. 获取模板列表数据
                var deployTemplate = esSession.DeployWorker.QueryTemplatePage(pageNo, pageSize, templateType);
                //4. 返回数据
                ret.Code        = 0;
                ret.Data        = deployTemplate.Data;
                ret.TotalNum    = deployTemplate.TotalNum;
                ret.Description = "";
                LogUtil.HWLogger.UI.InfoFormat("Querying template 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.TotalNum    = 0;
                LogUtil.HWLogger.UI.Error("Querying template 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.TotalNum    = 0;
                LogUtil.HWLogger.UI.Error("Querying template list failed: ", ex);
            }
            return(ret);
        }
Exemple #3
0
        /// <summary>
        /// 获取eSight列表数据
        /// </summary>
        /// <param name="queryParam">
        /// The query Param.
        /// </param>
        /// <returns>
        /// The <see>
        ///         <cref>WebReturnLGResult</cref>
        ///     </see>
        ///     .
        /// </returns>
        public static WebReturnLGResult <HWESightHost> GetList(ParamPagingOfQueryESight queryParam)
        {
            var ret = new WebReturnLGResult <HWESightHost>
            {
                Code = CoreUtil.GetObjTranNull <int>(
                    ConstMgr.ErrorCode.SYS_UNKNOWN_ERR),
                Description = string.Empty
            };

            try
            {
                // 1. 处理参数
                var jsData = JsonUtil.SerializeObject(queryParam);
                HWLogger.UI.InfoFormat("Querying eSight list, the param is [{0}]", jsData);
                var pageSize = queryParam.PageSize;
                var pageNo   = queryParam.PageNo;
                var hostIp   = queryParam.HostIp;

                // 2. 获取数据
                var hwESightHostList = ESightDal.Instance.GetList();
                var filterList       = hwESightHostList.Where(x => x.HostIP.Contains(hostIp)).Skip((pageNo - 1) * pageSize)
                                       .Take(pageSize).ToList();

                // 3. 返回数据
                ret.Code        = 0;
                ret.Data        = filterList;
                ret.TotalNum    = hwESightHostList.Count();
                ret.Description = string.Empty;

                HWLogger.UI.InfoFormat("Querying eSight 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.TotalNum    = 0;
                HWLogger.UI.Error("Querying eSight list failed: ", ex);
            }
            catch (Exception ex)
            {
                HWLogger.UI.Error(ex);
                ret.Code        = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR);
                ret.Description = ex.InnerException?.Message ?? ex.Message;
                ret.Data        = null;
                ret.TotalNum    = 0;
                HWLogger.UI.Error("Querying eSight list failed: ", ex);
            }

            return(ret);
        }
Exemple #4
0
        public void QueryBasePackagePageTest()
        {
            _esSession.Open();
            var queryParam = new { };
            WebOneESightParam <dynamic> packageParam = new WebOneESightParam <dynamic>();

            packageParam.ESightIP = "127.0.0.1";
            packageParam.Param    = queryParam;
            LogUtil.HWLogger.API.Info("QueryBasePackagePageTest packageParam:" + JsonUtil.SerializeObject(packageParam));

            QueryLGListResult <BasePackageItem> queryLGListResult = _esSession.BasePackageWorker.QueryBasePackagePage(1, 20);
            WebReturnLGResult <BasePackageItem> ret = new WebReturnLGResult <BasePackageItem>(queryLGListResult);

            LogUtil.HWLogger.API.Info("QueryBasePackagePageTest queryLGListResult:" + JsonUtil.SerializeObject(ret));
        }
Exemple #5
0
        /// <summary>
        /// 获取eSight列表数据
        /// </summary>
        /// <param name="eventData"></param>
        /// <returns></returns>
        private WebReturnLGResult <HWESightHost> GetList(object eventData)
        {
            var ret = new WebReturnLGResult <HWESightHost>()
            {
                Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR), Description = ""
            };

            try
            {
                //1. 处理参数
                var jsData            = JsonUtil.SerializeObject(eventData);
                var webOneESightParam = JsonUtil.DeserializeObject <WebOneESightParam <ParamPagingOfQueryESight> >(jsData);
                LogUtil.HWLogger.UI.InfoFormat("Querying eSight list, the param is [{0}]", jsData);
                int    pageSize = webOneESightParam.Param.PageSize;
                int    pageNo   = webOneESightParam.Param.PageNo;
                string hostIp   = webOneESightParam.Param.HostIp;
                //2. 获取数据
                ESightEngine.Instance.InitESSessions();
                List <HWESightHost> hwESightHostList = ESSessionHelper.GethwESightHostList();
                var filterList = hwESightHostList.Where(x => x.HostIP.Contains(hostIp)).Skip((pageNo - 1) * pageSize).Take(pageSize).ToList();
                //3. 返回数据
                ret.Code        = 0;
                ret.Data        = filterList;
                ret.TotalNum    = hwESightHostList.Count();
                ret.Description = "";

                LogUtil.HWLogger.UI.InfoFormat("Querying eSight 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.TotalNum    = 0;
                LogUtil.HWLogger.UI.Error("Querying eSight list failed: ", ex);
            }
            catch (Exception ex)
            {
                LogUtil.HWLogger.UI.Error(ex);
                ret.Code        = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR);
                ret.Description = ex.InnerException.Message ?? ex.Message;
                ret.Data        = null;
                ret.TotalNum    = 0;
                LogUtil.HWLogger.UI.Error("Querying eSight list failed: ", ex);
            }
            return(ret);
        }
        /// <summary>
        /// 获取已上传软件源列表,用于软件源管理UI,添加OS模板中的查询软件源UI
        /// </summary>
        /// <param name="eventData"></param>
        /// <returns></returns>
        public static WebReturnLGResult <SourceItem> GetSoftwareList(object eventData)
        {
            var ret = new WebReturnLGResult <SourceItem>()
            {
                Code = CoreUtil.GetObjTranNull <int>(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR), Description = ""
            };

            try
            {
                //1. 解析js传过来的参数
                var jsData            = JsonUtil.SerializeObject(eventData);
                var webOneESightParam = JsonUtil.DeserializeObject <WebOneESightParam <ParamOnlyPagingInfo> >(jsData);
                LogUtil.HWLogger.UI.InfoFormat("Querying software list, the param is [{0}]", jsData);
                int pageSize = webOneESightParam.Param.PageSize;
                int pageNo   = webOneESightParam.Param.PageNo;
                //2. 根据HostIP获取IESSession
                IESSession esSession = ESSessionHelper.GetESSession(webOneESightParam.ESightIP);
                //3. 获取软件源列表数据
                var softwareSourceList = esSession.SoftSourceWorker.QuerySoftwarePage(pageNo, pageSize);
                //4. 返回数据
                ret.Code        = 0;
                ret.Data        = softwareSourceList.Data;
                ret.TotalNum    = softwareSourceList.TotalNum;
                ret.Description = "";

                LogUtil.HWLogger.UI.InfoFormat("Querying software 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.TotalNum    = 0;
                LogUtil.HWLogger.UI.Error("Querying software 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.TotalNum    = 0;
                LogUtil.HWLogger.UI.Error("Querying software list failed: ", ex);
            }
            return(ret);
        }
        /// <summary>
        /// The process request.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            var action = context.Request.QueryString["action"];

            switch (action)
            {
            case "list":
                var query = new ParamPagingOfQueryESight();
                query.PageNo   = 1;
                query.PageSize = 100000;

                query.HostIp = context.Request.Form["hostIP"] ?? string.Empty;
                var list = ESightHelper.GetList(query);
                Task.Run(() =>
                {
                    ESightEngine.Instance.CheckAllESightConnection();
                });
                context.Response.Write(JsonUtil.SerializeObject(list).Replace("null", "\"\""));
                break;

            case "test":
                var testModel = new HWESightHost();
                testModel.HostIP       = context.Request.Form["hostIP"];
                testModel.HostPort     = Convert.ToInt32(context.Request.Form["hostPort"]);
                testModel.LoginAccount = context.Request.Form["loginAccount"];
                testModel.LoginPd      = context.Request.Form["LoginPd"];
                context.Response.Write(JsonUtil.SerializeObject(ESightHelper.Test(testModel)));
                break;

            case "add":
                var addModel = new HWESightHost();
                addModel.AliasName              = context.Request.Form["aliasName"];
                addModel.HostIP                 = context.Request.Form["hostIP"];
                addModel.HostPort               = Convert.ToInt32(context.Request.Form["hostPort"]);
                addModel.LoginAccount           = context.Request.Form["loginAccount"];
                addModel.SystemID               = context.Request.Form["systemId"];
                addModel.LoginPd                = context.Request.Form["LoginPd"];
                addModel.SubscripeNeDeviceError = string.Empty;
                addModel.SubscripeAlarmError    = string.Empty;
                context.Response.Write(JsonUtil.SerializeObject(ESightHelper.Add(addModel)));
                break;

            case "update":
                var updateModel = new HWESightHost();
                updateModel.AliasName    = context.Request.Form["aliasName"];
                updateModel.HostIP       = context.Request.Form["hostIP"];
                updateModel.HostPort     = Convert.ToInt32(context.Request.Form["hostPort"]);
                updateModel.LoginAccount = context.Request.Form["loginAccount"];
                updateModel.SystemID     = context.Request.Form["systemId"];
                updateModel.LoginPd      = context.Request.Form["LoginPd"];
                if (!string.IsNullOrWhiteSpace(updateModel.LoginAccount))
                {
                    context.Response.Write(JsonUtil.SerializeObject(ESightHelper.Update(updateModel)));
                }
                else
                {
                    context.Response.Write(JsonUtil.SerializeObject(ESightHelper.UpdateWithOutPass(updateModel)));
                }
                break;

            case "delete":
                var ids    = context.Request.Form["ids"];
                var result = ESightHelper.Delete(ids);
                context.Response.Write(JsonUtil.SerializeObject(result));
                break;

            default:
                var ret = new WebReturnLGResult <HWESightHost>
                {
                    Code = CoreUtil.GetObjTranNull <int>(
                        ConstMgr.ErrorCode.SYS_UNKNOWN_ERR),
                    Description = string.Empty
                };
                ret.Code = -999999;
                context.Response.Write(JsonUtil.SerializeObject(ret));
                break;
            }
        }