コード例 #1
0
        public bool ChangePwd(MenuRequest request, out ErrorMessage message)
        {
            //var item = HttpUtil.PostResponse(request.ServiceUrl, request.PostData, "gb2312", "application/x-www-form-urlencoded");
            var item = HttpHelper.PostRequest(request.ServiceUrl, request.PostData, 3000, "gb2312");
            var root = CheckResult(item, out message);//检查数据

            message.Result = (root != null && root["st"] != null && root["st"].InnerText.Equals("1"));
            if (!message.Result)
            {
                message.Message = root == null ? "" : root.InnerText;
            }
            return(message.Result);
        }
コード例 #2
0
        public MenuResponseModel GetMenuAndUserInfo(string loginName, string password)
        {
            ErrorMessage message;
            MenuRequest  request = new MenuRequest
            {
                Service    = "getmenus",
                ProjCode   = Projcode,
                JobNumber  = loginName,
                Pwd        = password,
                ServiceUrl = ServiceUrl
            };

            return(GetMenuAndUserInfo(request, out message));
        }
コード例 #3
0
        public ErrorMessage Login(string loginName, string password)
        {
            ErrorMessage message;
            MenuRequest  request = new MenuRequest
            {
                Service    = "login",
                ProjCode   = Projcode,
                JobNumber  = loginName,
                Pwd        = password,
                ServiceUrl = ServiceUrl
            };

            ChangePwd(request, out message);
            return(message);
        }
コード例 #4
0
        /// <summary> 获取用户信息</summary>
        /// <param name="request">请求字段</param>
        /// <param name="message">错误信息</param>
        /// <returns>响应信息</returns>
        public MenuResponseModel GetUserInfo(MenuRequest request, out ErrorMessage message)
        {
            //var item = HttpUtil.PostResponse(request.ServiceUrl, request.PostUserIdData, "gb2312", "application/x-www-form-urlencoded");
            var         item = HttpHelper.PostRequest(request.ServiceUrl, request.PostData, 3000, "gb2312");
            XmlNodeList userNodes;
            var         root = CheckUserInfo(item, out userNodes, out message);//检查用户数据

            if (null == root)
            {
                return(null);
            }
            var menuResponse = new MenuResponseModel();
            var userInfo     = new MenuUserModel();

            for (var i = 0; i < userNodes.Count; i++)
            {
                var result = (XmlElement)userNodes[i];
                if (result == null)
                {
                    continue;
                }
                // ReSharper disable PossibleNullReferenceException
                userInfo.Name       = result["userId"].InnerText;
                userInfo.Name       = result["name"].InnerText;
                userInfo.JobNumber  = result["jobNumber"].InnerText;
                userInfo.Gender     = result["gender"].InnerText;
                userInfo.IdCard     = result["IdCard"].InnerText;
                userInfo.DepartName = result["departName"].InnerText;
                userInfo.CrtTime    = result["crtTime"].InnerText;
                userInfo.MdfTime    = result["mdfTime"].InnerText;
                userInfo.Enable     = result["enable"].InnerText;
                userInfo.Remark     = result["remark"].InnerText;
                userInfo.DptName    = result["dptName"].InnerText;
                // ReSharper restore PossibleNullReferenceException
            }
            return(menuResponse);
        }
コード例 #5
0
        /// <summary>获取用户和菜单信息</summary>
        /// <param name="request">请求字段</param>
        /// <param name="message">错误信息</param>
        /// <returns>响应信息</returns>
        public MenuResponseModel GetMenuAndUserInfo(MenuRequest request, out ErrorMessage message)
        {
            //var item = HttpUtil.PostResponse(request.ServiceUrl, request.PostData, "gb2312", "application/x-www-form-urlencoded");
            var         item = HttpHelper.PostRequest(request.ServiceUrl, request.PostData, 3000, "gb2312");
            XmlNodeList menuNodes;
            XmlNodeList userNodes;
            var         root = Check(item, out menuNodes, out message, out userNodes);//检查数据

            if (null == root)
            {
                return(null);
            }
            var menuResponse = new MenuResponseModel();
            var userInfo     = new MenuUserModel();

            for (var i = 0; i < userNodes.Count; i++)
            {
                var result = (XmlElement)userNodes[i];
                if (result == null)
                {
                    continue;
                }
                userInfo.UserId     = Convert.ToInt32(result["userId"].InnerText);
                userInfo.Name       = result["name"].InnerText;
                userInfo.JobNumber  = result["jobNumber"].InnerText;
                userInfo.Gender     = result["gender"].InnerText;
                userInfo.IdCard     = result["IdCard"].InnerText;
                userInfo.DepartName = result["departName"].InnerText;
                userInfo.DeptId     = result["dptid"].InnerText;
            }
            var menulist = new List <MenuModel>();

            for (var i = 0; i < menuNodes.Count; i++)
            {
                var result = (XmlElement)menuNodes[i];
                if (result == null)
                {
                    continue;
                }
                XmlNodeList xmlNodeList = result.SelectNodes("menu");
                for (var j = 0; j < xmlNodeList.Count; j++)
                {
                    var menu     = new MenuModel();
                    var menunode = (XmlElement)xmlNodeList[j];
                    if (menunode == null)
                    {
                        continue;
                    }
                    menu.id       = menunode.GetAttribute("id");
                    menu.Name     = menunode.GetAttribute("name");
                    menu.Title    = menunode.GetAttribute("title");
                    menu.Url      = menunode.GetAttribute("url");
                    menu.OrderNo  = Convert.ToInt32(menunode.GetAttribute("orderNo"));
                    menu.children = GetMenu(menunode, menuResponse);
                    menulist.Add(menu);
                    string url = GetMenuUrl(menu.Url);
                    if (!string.IsNullOrWhiteSpace(url) && !menuResponse.MenuUrl.ContainsKey(url))
                    {
                        menuResponse.MenuUrl.Add(url, menu);
                    }
                }
            }
            message = null;
            menuResponse.MenuEntity = menulist;
            menuResponse.UserEntity = userInfo;
            return(menuResponse);
        }