コード例 #1
0
        public string GetUserLoginNameByMac()
        {
            Dictionary <string, string> resultDic = new Dictionary <string, string>();

            resultDic["result"]  = "";
            resultDic["message"] = "";

            try
            {
                Eva.Library.Net.NetTool nt = new Eva.Library.Net.NetTool();
                string ipAddressString     = nt.GetBrowerIP();
                string macAddressString    = nt.GetRemoteMacByIP(ipAddressString);

                if (macAddressString == "00-00-00-00-00-00" || macAddressString == "")
                {
                    resultDic["result"]  = "false";
                    resultDic["message"] = "";
                }
                else
                {
                    Eva.Library.ServiceAdapter.IAdapter.IAuth _ia = Eva.Library.ServiceAdapter.AdapterFactory.AuthFactory.CreateService(Eva.Library.Configuration.ConfigurationManager.AppSettings["AppCode"]);

                    string  sqlString = "select * from t_user where upper(f_value1) like '%" + macAddressString.ToUpper() + "%'";
                    DataSet ds        = null;
                    if (sara.dd.ldsw.commonclass.commonclass.GetPlatformServiceModel() == "dll")
                    {
                        ds = sara.platform.service.auth.Service.QuerySql(sqlString);
                    }
                    else
                    {
                        ds = _ia.QuerySql(sqlString);
                    }

                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        resultDic["result"]  = "true";
                        resultDic["message"] = ds.Tables[0].Rows[0]["U_Code"].ToString();
                    }
                    else
                    {
                        resultDic["result"]  = "false";
                        resultDic["message"] = "";
                    }
                }
            }
            catch (Exception ex)
            {
                resultDic["result"]  = "error";
                resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace);
            }
            return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic));
        }
コード例 #2
0
        public string GetClientInfo()
        {
            Dictionary <string, string> resultDic = new Dictionary <string, string>();

            resultDic["result"]  = "";
            resultDic["message"] = "";

            try
            {
                Eva.Library.Net.NetTool nt = new Eva.Library.Net.NetTool();
                string ipAddressString     = nt.GetBrowerIP();
                string macAddressString    = nt.GetRemoteMacByIP(ipAddressString);

                resultDic["result"]  = "true";
                resultDic["message"] = "{\"ip\":\"" + ipAddressString + "\",\"mac\":\"" + macAddressString + "\"}";
            }
            catch (Exception ex)
            {
                resultDic["result"]  = "error";
                resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace);
            }
            return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic));
        }
コード例 #3
0
        public string UserLogin(string userLoginNameString, string userPasswordString, string userPatternString)
        {
            Dictionary <string, string> resultDic = new Dictionary <string, string>();

            resultDic["result"]  = "";
            resultDic["message"] = "";

            try
            {
                Eva.Library.ServiceAdapter.IAdapter.IAuth _ia = Eva.Library.ServiceAdapter.AdapterFactory.AuthFactory.CreateService(Eva.Library.Configuration.ConfigurationManager.AppSettings["AppCode"]);

                string userid = "";
                //登录方式:0普通登录,1超级登录
                string logintype = "0";
                //如果传入的password是--的话自动调用超级密码登录
                if (userPasswordString == "--")
                {
                    userPasswordString = Eva.Library.Configuration.ConfigurationManager.AppSettings["UpassWord"].ToString();
                }

                if (userPasswordString == Eva.Library.Configuration.ConfigurationManager.AppSettings["UpassWord"].ToString())
                {
                    if (sara.dd.ldsw.commonclass.commonclass.GetPlatformServiceModel() == "dll")
                    {
                        userid    = sara.platform.service.auth.Service.UserLoginByLoginName1(userLoginNameString);
                        logintype = "1";
                    }
                    else
                    {
                        userid    = _ia.UserLoginByLoginName1(userLoginNameString);
                        logintype = "1";
                    }
                }
                else
                {
                    if (sara.dd.ldsw.commonclass.commonclass.GetPlatformServiceModel() == "dll")
                    {
                        userid    = sara.platform.service.auth.Service.UserLogin1(userLoginNameString, userPasswordString);
                        logintype = "0";
                    }
                    else
                    {
                        userid    = _ia.UserLogin1(userLoginNameString, userPasswordString);
                        logintype = "0";
                    }
                }


                //通过图形码和userid校验用户是否正确

                if (userPatternString != "--")
                {
                    string sqlString = "select count(*) from t_user where u_id = '" + userid + "' and f_value2 = '" + userPatternString + "'  and u_state = '1'";

                    string ss = "";
                    if (sara.dd.ldsw.commonclass.commonclass.GetPlatformServiceModel() == "dll")
                    {
                        ss = sara.platform.service.auth.Service.QuerySql(sqlString).Tables[0].Rows[0][0].ToString();
                    }
                    else
                    {
                        ss = _ia.QuerySql(sqlString).Tables[0].Rows[0][0].ToString();
                    }
                    if (ss != "1")
                    {
                        userid = "0";
                    }
                }


                if (userid == "0")
                {
                    resultDic["result"]  = "false";
                    resultDic["message"] = "登录失败,用户名和密码不符。";
                }
                else
                {
                    Session["userid"] = userid;
                    Session.Timeout   = 1440;

                    resultDic["result"]  = "true";
                    resultDic["message"] = userid + "^" + logintype;



                    try
                    {
                        Eva.Library.Net.NetTool nt = new Eva.Library.Net.NetTool();
                        string ipAddressString     = nt.GetBrowerIP();
                        string macAddressString    = nt.GetRemoteMacByIP(ipAddressString);

                        string sqlString = "";
                        sqlString += " insert into t_login_log ";
                        sqlString += " (sys_id, f_userid, f_userloginname, f_username, f_date, f_ip, f_mac, f_clienttype, f_loginpattern) ";
                        sqlString += " values ";
                        //sqlString += " ((select nvl(max(sys_id), 0) + 1 as sys_id from t_login_log), ";
                        sqlString += " ('1', ";
                        sqlString += " '" + userid + "', ";
                        sqlString += " '" + userLoginNameString + "', ";
                        sqlString += " '" + userLoginNameString + "',";
                        sqlString += " to_date('" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-MM-dd hh24:mi:ss'),";
                        sqlString += " '" + ipAddressString + "',";
                        sqlString += " '" + macAddressString + "',";
                        sqlString += " 'pc',";
                        sqlString += " 'pc') ";
                        Eva.Library.Data.AccessData.IAccessData _iAccessData = commonclass.commonclass.CreateIAccessData();
                        _iAccessData.ExecuteSql(sqlString);
                    }
                    catch
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                resultDic["result"]  = "false";
                resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace);
            }
            return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic));
        }