duan
2024-08-21 22bd5bc1ce2b49284cc2f042c7f4f48619fcf85b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using DIXWeb.Business.Common;
using DIXWeb.Entity.GlobalM;
using DIXWeb.Util;
using System.Linq;
using System;
using DIXWeb.Entity.Power;
using DIXWeb.DataRepository;
using DIXWeb.DAL;
using DIXWeb.Entity.EasyUI;
 
namespace DIXWeb.Business.GlobalM
{
    public class HomeBusiness:BaseBusiness<UserInfo>
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="UserNo"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public ResultMessage SubmitLogin(string UserNo, string password)
        {
            try {
                if (UserNo.IsNullOrEmpty() || password.IsNullOrEmpty())
                    return Error("账号或密码不能为空!");
                password = password.ToMD5String();
                var theUser = GetIQueryable().Where(x => x.UserNo == UserNo && x.Password == password).FirstOrDefault();
                if (theUser != null)
                {
                    Operator.Login(theUser.UserNo);
                    return Success();
                }
                else
                    return Error("账号或密码不正确!");
            }
            catch (Exception er) {
                return Error("错误,"+er.Message);
            }
            
        }
 
 
        public RSP SonyUserUpload(string UserNo, string password)
        {
            RSP r = null;
            using (DBContext db = new DBContext())
            {
                string psdTemp = MD5Security.MD5Encrypt32(password);
                System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[2];
                paramList[0] = new System.Data.SqlClient.SqlParameter("@UserCode", UserNo);
                paramList[1] = new System.Data.SqlClient.SqlParameter("@Password", psdTemp);
                paramList[1] = new System.Data.SqlClient.SqlParameter("@PasswordStr", password);
                r = db.Database.SqlQuery<RSP>("EXEC dbo.p_SonyUserUpload @UserCode,@Password,@PasswordStr ", paramList).FirstOrDefault();
            }
            return r;
        }
 
 
 
    }
}
 
/*
 
ALTER procedure[dbo].[p_SonyUserUpload]
(
   @UserCode varchar(32),
    @Password varchar(64)
)as begin
    declare
 
        @rCode int = 200,
        @rMessage varchar(512)
 
 
    declare @Id int=-4
    select @Id = Id from UserInfo with(nolock) where UserNo = @UserCode
 
 
    begin try
        if @Id = -4 begin
            insert into UserInfo(UserNo, UserName, Tel, Email, [Address], IdCard, MobilePhone, BirthDay, Sex, IsEnable, CreateTime, [Password])
 
            values(@UserCode,'游客','','','中国','','','1900-01-01',1,1, GETDATE(), @Password)
 
        end else begin
            update UserInfo set[Password] = @Password where Id = @Id
 
        end
    end try
    begin catch
        set @rCode = 500
 
        set @rMessage = ERROR_MESSAGE()
 
    end catch
    select
 
        @rCode as 'Code',
        @rMessage as 'Message'
end
 
/*
use Organize
go
 
declare 
    @UserCode varchar(32)='5105244240',
    @Password varchar(64)='d277df6403346075b550f4b37742917a'
exec p_SonyUserUpload @UserCode,@Password
 
    
 
*/