Ejemplo n.º 1
0
        /// <summary>
        /// web登录验证
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public Stream WebLogin(Stream data)
        {
            #region 查找数据
            ResWebLogin response = new ResWebLogin();
            bool        success  = false;
            try
            {
                DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqWebLogin));
                //读取器
                StreamReader sr         = new StreamReader(data);
                string       dataString = String.Empty;
                while (!sr.EndOfStream)
                {
                    dataString = sr.ReadToEnd();
                    Console.WriteLine(dataString);

                    #region 日志输出
                    CommonInfo.Log(dataString);
                    #endregion

                    //反序列化json为对象注意顺序很重要
                    ReqWebLogin  request = new ReqWebLogin();
                    MemoryStream temp    = new MemoryStream(Encoding.UTF8.GetBytes(dataString));
                    request = json.ReadObject(temp) as ReqWebLogin;

                    //关闭临时流
                    temp.Close();

                    //调用用户更新密码接口
                    if (request != null)
                    {
                        //**********(此处加入代码) 根据查询条件 加入业务逻辑代码*************

                        string token = PatrolUserInfoRule.LoginCheck(request.user_id, request.password);

                        if (token != String.Empty)
                        {
                            success = true;
                        }
                        //验证成功后 获取用户数据
                        if (success)
                        {
                            if (request.user_id != null && request.user_id != String.Empty)
                            {
                                DataTable user = UserEntity.getUserInfo(request.user_id);
                                response.user = ResWebLogin.getUserInfo(user);

                                //设置成功状态
                                success = true;
                            }
                        }
                    }
                }
                sr.Close();
                Console.WriteLine(data);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                #region 日志输出
                CommonInfo.Error("Web登录发生错误" + ex.Message);
                #endregion
            }

            //返回消息体
            if (success)
            {
                response.SetSuccess();
            }
            else
            {
                ////默认是失败
                //response.SetFailed();
            }
            //将消息序列化为Json格式数据
            DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResWebLogin));
            MemoryStream ms = new MemoryStream();
            obj2Json.WriteObject(ms, response);

            //注意一定要设置流的位置到开始位置,否则没有消息输出
            ms.Position = 0;
            return(ms);

            #endregion
        }
Ejemplo n.º 2
0
        public Stream GetUserList(Stream data)
        {
            #region 查找数据
            ResGetUserList response = new ResGetUserList();
            bool           success  = true;
            try
            {
                DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqGetUserList));
                //读取器
                StreamReader sr         = new StreamReader(data);
                string       dataString = String.Empty;
                while (!sr.EndOfStream)
                {
                    dataString = sr.ReadToEnd();
                    Console.WriteLine(dataString);

                    #region 日志输出
                    CommonInfo.Log(dataString);
                    #endregion

                    //反序列化json为对象注意顺序很重要
                    ReqGetUserList request = new ReqGetUserList();
                    MemoryStream   temp    = new MemoryStream(Encoding.UTF8.GetBytes(dataString));
                    request = json.ReadObject(temp) as ReqGetUserList;

                    //关闭临时流
                    temp.Close();

                    //调用用户更新密码接口
                    if (request != null)
                    {
                        //**********(此处加入代码) 根据查询条件 加入业务逻辑代码*************
                        // 身份验证
                        if (request.account != null && request.account != String.Empty && request.token != null && request.token != String.Empty)
                        {
                            //管理员权限验证
                            bool isAdmin = PatrolUserInfoRule.AdminCheck(request.account, request.token);
                            if (isAdmin)
                            {
                                // sql查询字符串组织
                                string queryString = String.Empty;
                                string rangeString = String.Empty;
                                // 按条件查询
                                if (request.search_info != null)
                                {
                                    #region 属性查询对应
                                    if (request.search_info.agency_shop != null && request.search_info.agency_shop != String.Empty)
                                    {
                                        queryString += " and t.CompanyCD = '" + request.search_info.agency_shop + "' ";
                                    }
                                    if (request.search_info.filiale != null && request.search_info.filiale != String.Empty)
                                    {
                                        queryString += " and t.SubCompanyCD = '" + request.search_info.filiale + "' ";
                                    }
                                    if (request.search_info.user_id != null && request.search_info.user_id != String.Empty)
                                    {
                                        //用户编号或者名称
                                        queryString += " and (t.StaffCD = '" + request.search_info.user_id + "' or  t.StaffNM = '" + request.search_info.user_id + "' ) ";
                                    }

                                    //分页控制对象范围
                                    int pageIndex = 1;
                                    int pageSize  = 10;
                                    if (request.search_info.Paginator != null)
                                    {
                                        pageIndex = request.search_info.Paginator.PageIndex;
                                        pageIndex = pageIndex > 0 ? pageIndex : 1;
                                        pageSize  = request.search_info.Paginator.PageSize;
                                        pageSize  = pageSize > 0 ? pageSize : 10;

                                        int rangeStart = (pageIndex - 1) * pageSize + 1;
                                        int rangeEnd   = pageIndex * pageSize;

                                        rangeString += " and orderno between " + rangeStart + " and " + rangeEnd + " ";
                                    }
                                    else
                                    {
                                        rangeString += " and orderno between " + pageIndex + " and " + pageSize + " ";
                                    }

                                    //获取数据调用数据库接口
                                    DataTable dt = UserEntity.getUserList(queryString, rangeString);
                                    //转换数据
                                    response.user_list = ResGetUserList.Transfer(dt);
                                    response.count     = UserEntity.getUserCount(queryString);

                                    success = true;
                                    #endregion
                                }
                            }
                        }
                    }
                }
                sr.Close();
                Console.WriteLine(data);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                #region 日志输出
                CommonInfo.Error("获取特巡列表数据错误" + ex.Message);
                #endregion
            }

            //返回消息体
            if (success)
            {
                response.SetSuccess();
            }
            else
            {
                ////默认是失败
                //response.SetFailed();
            }
            //将消息序列化为Json格式数据
            DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResGetUserList));
            MemoryStream ms = new MemoryStream();
            obj2Json.WriteObject(ms, response);

            //注意一定要设置流的位置到开始位置,否则没有消息输出
            ms.Position = 0;
            return(ms);

            #endregion
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 重置用户密码
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public Stream ResetPassword(Stream data)
        {
            bool             success  = false;
            ResResetPassword response = new ResResetPassword();

            try
            {
                DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqResetPassword));
                //读取器
                StreamReader sr         = new StreamReader(data);
                string       dataString = String.Empty;
                while (!sr.EndOfStream)
                {
                    dataString = sr.ReadToEnd();
                    Console.WriteLine(dataString);

                    #region 日志输出
                    CommonInfo.Log(dataString);
                    #endregion

                    //反序列化json为对象注意顺序很重要
                    ReqResetPassword request = new ReqResetPassword();
                    MemoryStream     temp    = new MemoryStream(Encoding.UTF8.GetBytes(dataString));
                    request = json.ReadObject(temp) as ReqResetPassword;

                    //关闭临时流
                    temp.Close();

                    //调用用户更新密码接口
                    if (request != null)
                    {
                        //*.数据合法性检查

                        //*.更新
                        if (request.account != null && request.user_id != null)
                        {
                            success = PatrolUserInfoRule.ResetPassword(request.user_id, request.account);
                        }
                    }
                }
                sr.Close();
                Console.WriteLine(data);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                #region 日志输出
                CommonInfo.Error("重置密码错误" + ex.Message);
                #endregion
            }

            //返回消息体
            if (success)
            {
                response.SetSuccess();
            }
            else
            {
                ////默认是失败
                //response.SetFailed();
            }
            //将消息序列化为Json格式数据
            DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResResetPassword));
            MemoryStream ms = new MemoryStream();
            obj2Json.WriteObject(ms, response);

            //注意一定要设置流的位置到开始位置,否则没有消息输出
            ms.Position = 0;
            return(ms);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 登录验证接口 接口编号 = 1006
        /// </summary>
        /// <param name="data">Post数据</param>
        /// <returns></returns>
        public Stream LoginCheck(Stream data)
        {
            System.ServiceModel.Channels.Message o = OperationContext.Current.RequestContext.RequestMessage;
            bool          success  = false;
            ResLoginCheck response = new ResLoginCheck();

            try
            {
                DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqLoginCheck));
                //读取器
                StreamReader sr         = new StreamReader(data);
                string       dataString = String.Empty;
                while (!sr.EndOfStream)
                {
                    dataString = sr.ReadToEnd();
                    Console.WriteLine(dataString);

                    #region 日志输出
                    CommonInfo.Log(dataString);
                    #endregion

                    //反序列化json为对象注意顺序很重要
                    ReqLoginCheck request = new ReqLoginCheck();
                    MemoryStream  temp    = new MemoryStream(Encoding.UTF8.GetBytes(dataString));
                    request = json.ReadObject(temp) as ReqLoginCheck;

                    //关闭临时流
                    temp.Close();

                    //调用用户更新密码接口
                    if (request != null)
                    {
                        //*.数据合法性检查

                        //*.更新
                        response.token = PatrolUserInfoRule.LoginCheck(request.user_id, request.password);

                        if (response.token != String.Empty)
                        {
                            success = true;
                        }
                    }
                }
                sr.Close();
                Console.WriteLine(data);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                #region 日志输出
                CommonInfo.Error("获取特巡列表数据错误" + ex.Message);
                #endregion
            }

            //返回消息体
            if (success)
            {
                response.SetSuccess();
            }
            else
            {
                ////默认是失败
                //response.SetFailed();
            }
            //将消息序列化为Json格式数据
            DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResLoginCheck));
            MemoryStream ms = new MemoryStream();
            obj2Json.WriteObject(ms, response);

            //注意一定要设置流的位置到开始位置,否则没有消息输出
            ms.Position = 0;
            return(ms);
        }