Exemple #1
0
        public string GetConnectString(string svrName, string account)
        {
            string result;
            DBConnectionStringBuilder dbbuilder = new DBConnectionStringBuilder();
            string pubConn  = string.Empty;
            string userConn = string.Empty;

            if (string.IsNullOrWhiteSpace(svrName))
            {
                pubConn = dbbuilder.GetMainConnStringElement(0, out result, false);//取第一个(默认)服务器
            }
            else
            {
                pubConn = dbbuilder.GetMainConnStringElement(svrName, out result);
            }

            //数据库名不完整,缺少NG
            if (account.Length > 0 && account.ToLower().IndexOf("ng") != 0)
            {
                account = "NG" + account;
            }
            userConn = dbbuilder.GetAccConnstringElement(svrName, account, pubConn, out result);
            NG3.Data.Service.ConnectionInfoService.SetSessionConnectString(userConn);//初始化2.0的dbhelper
            return(userConn);
        }
        /// <summary>
        /// 构造函数
        /// </summary>

        public WorkFlowApiController()
        {
            //获取AppInfo值 头部信息记录
            #region 设置当前线程数据库
            var base64EncodedBytes = Convert.FromBase64String(HttpContext.Current.Request.Headers.GetValues("AppInfo").First());
            var jsonText           = Encoding.UTF8.GetString(base64EncodedBytes);
            var AppInfo            = JsonConvert.DeserializeObject <ApiControllerBase.Models.AppInfoBase>(jsonText);

            if (AppInfo != null)
            {
                DBConnectionStringBuilder dbbuilder = new DBConnectionStringBuilder();
                string result, userConn;
                var    pubConn = dbbuilder.GetMainConnStringElement(0, out result, false);
                string defaultConn = dbbuilder.GetDefaultConnString();

                if (AppInfo.DbName.ToLower() == "ngsoft")
                {
                    userConn = pubConn;
                }
                else
                {
                    userConn = string.IsNullOrWhiteSpace(AppInfo.DbName)
                        ? defaultConn
                        : dbbuilder.GetAccConnstringElement(0, AppInfo.DbName, pubConn,
                                                            out result);
                }

                //设置当前数据库连接信息
                ConnectionInfoService.SetCallContextConnectString(userConn);
                MultiDelegatingDbProvider.CurrentDbProviderName = AppInfo.DbName;
            }
            #endregion

            service = new WorkFlowServiceProxy();
        }
Exemple #3
0
        public string GetAccList(string svrName)
        {
            DBConnectionStringBuilder dbbuilder = new DBConnectionStringBuilder();
            string result;
            string pubConnStr = dbbuilder.GetMainConnStringElement(svrName, out result);

            //string sql = "select ucode,uname from ngusers order by ucode ";

            string sql = "select dbname,uname from ngusers order by ucode ";

            DataTable dt = NG3.Data.Service.DbHelper.GetDataTable(pubConnStr, sql);

            foreach (DataRow dr in dt.Rows)
            {
                //dr["uname"] = dr["ucode"].ToString() + "-" + dr["uname"].ToString();
                dr["uname"] = dr["dbname"].ToString() + "-" + dr["uname"].ToString();
            }

            //Ajax.WriteRaw(dt.ToJSON("ucode", "uname"));

            string str = DataConverterHelper.ToJson(dt, dt.Rows.Count);

            return(str);

            //return this.Json(str, JsonRequestBehavior.AllowGet);
        }
        //初始化数据库
        private void InitDb()
        {
            //数据库连接方式取值方法一:固定链接串
            //string connectionString=@"ConnectType=SqlClient;Server=10.0.16.168\upty;Database=NG0054;User ID=sa;Password=123456";
            //string connectionString = "ConnectType=SqlClient;Server=10.0.18.21;Database=NG0008;User ID=sa;Password="******"ConnectType=SqlClient;Server=10.0.17.118;Database=NG0004;User ID=sa;Password=psoft";

            //二:从web.config取值
            //string connectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();

            //三:从config目录下文件DataBases.xml中取值
            DBConnectionStringBuilder dbbuilder = new DBConnectionStringBuilder();
            //var userConn = dbbuilder.GetDefaultConnString(); //主帐套连接串

            var result   = string.Empty;
            var dbname   = dbbuilder.DefaultDB;
            var pubConn  = dbbuilder.GetMainConnStringElement(0, out result, false);          //获取主数据库连接串 NGSoft
            var userConn = dbbuilder.GetAccConnstringElement(0, dbname, pubConn, out result); //获取默认数据库连接串 NG0001

            ConnectionInfoService.SetSessionConnectString(userConn);

            I6WebAppInfo appInfo = new I6WebAppInfo();

            appInfo.PubConnectString  = pubConn;
            appInfo.UserConnectString = userConn;
            appInfo.LoginID           = "xyp";
            appInfo.UserName          = "******";
            appInfo.OCode             = "001";
            appInfo.UCode             = dbname.Substring(2);
            appInfo.DbName            = dbname;
            //appInfo.UserID = 2;
            //appInfo.OrgID = 1;

            string uid = DbHelper.GetString(userConn, string.Format("select phid from fg3_user where userno='{0}'", appInfo.LoginID));
            string oid = DbHelper.GetString(userConn, string.Format("select phid from fg_orglist where ocode='{0}'", appInfo.OCode));

            if (!string.IsNullOrWhiteSpace(uid))
            {
                appInfo.UserID = Convert.ToInt64(uid);
            }
            else
            {
                appInfo.UserID = 1;
            }

            if (!string.IsNullOrWhiteSpace(oid))
            {
                appInfo.OrgID = Convert.ToInt64(oid);
            }
            else
            {
                appInfo.OrgID = 1;
            }

            System.Web.HttpContext.Current.Session["NGWebAppInfo"] = appInfo;
        }
Exemple #5
0
        private static void TestOracle()
        {
            string result;
            DBConnectionStringBuilder dbbuilder = new DBConnectionStringBuilder();
            string pubConn  = string.Empty;
            string userConn = string.Empty;

            pubConn  = dbbuilder.GetMainConnStringElement(0, out result, false); //取第一个(默认)服务器
            userConn = dbbuilder.GetDefaultConnString();                         //取默认连接串

            userConn = dbbuilder.GetAccConnstringElement("10.0.16.168:1521/orclup.rd.ngsoft.com", "NG0001", pubConn, out result);

            userConn = dbbuilder.GetAccConnstringElement(0, "NG0001", pubConn, out result);

            DataTable tb = dbbuilder.GetDBserverList();
            DataTable dt = dbbuilder.GetAccountList("10.0.0.233:1521/orcl.rd.ngsoft.com");
        }
Exemple #6
0
        public string GetServerList()
        {
            DataSet ds = new DBConnectionStringBuilder().DBConfig;

            try
            {
                //Ajax.WriteRaw(ds.Tables["Connect"].ToJSON("byname", "servername"));

                string str = DataConverterHelper.ToJson(ds.Tables["Connect"], ds.Tables["Connect"].Rows.Count);
                return(str);

                //return this.Json(str, JsonRequestBehavior.AllowGet);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #7
0
        public string GetUserConnectString(string ucode)
        {
            DBConnectionStringBuilder dBConnectionStringBuilder = new DBConnectionStringBuilder();

            string    theResult = string.Empty;
            DataTable dtacc     = DbHelper.GetDataTable(NG3.AppInfoBase.PubConnectString, "select ucode,uname,dbname,product from ngusers order by ucode ");

            if (dtacc != null && dtacc.Rows.Count > 0)
            {
                foreach (DataRow dr in dtacc.Rows)
                {
                    if (dr["ucode"].ToString() == ucode)
                    {
                        return(dBConnectionStringBuilder.GetAccConnstringElement(0, dr["dbname"].ToString(), NG3.AppInfoBase.PubConnectString, out theResult));
                    }
                }
            }
            return(string.Empty);
        }
Exemple #8
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            //获取AppInfo值 头部信息记录
            var base64EncodedBytes = Convert.FromBase64String(HttpContext.Current.Request.Headers.GetValues("AppInfo").First());
            var jsonText           = Encoding.UTF8.GetString(base64EncodedBytes);
            var AppInfo            = JsonConvert.DeserializeObject <AppInfoBase>(jsonText);

            if (AppInfo != null)
            {
                string curConnect = DbHelper.ConnectString;
                if (curConnect.IndexOf(AppInfo.DbName, StringComparison.CurrentCultureIgnoreCase) > 0)
                {
                    //连接串包含了当前数据库
                }
                else
                {
                    DBConnectionStringBuilder dbbuilder = new DBConnectionStringBuilder();
                    string result, userConn;
                    var    pubConn = dbbuilder.GetMainConnStringElement(0, out result, false);
                    string defaultConn = dbbuilder.GetDefaultConnString();

                    if (AppInfo.DbName.ToLower() == "ngsoft")
                    {
                        userConn = pubConn;
                    }
                    else
                    {
                        userConn = string.IsNullOrWhiteSpace(AppInfo.DbName)
                            ? defaultConn
                            : dbbuilder.GetAccConnstringElement(0, AppInfo.DbName, pubConn,
                                                                out result);
                    }

                    //设置当前数据库连接信息
                    ConnectionInfoService.SetCallContextConnectString(userConn);
                    MultiDelegatingDbProvider.CurrentDbProviderName = AppInfo.DbName;
                }
            }

            base.OnActionExecuting(actionContext);
        }
Exemple #9
0
        public string GetConnectType(string svrName, string account)
        {
            try
            {
                string connectType = "0";
                var    dbbuilder   = new DBConnectionStringBuilder();
                string pubConn     = string.Empty;
                string result;
                if (string.IsNullOrWhiteSpace(svrName))
                {
                    pubConn = dbbuilder.GetMainConnStringElement(0, out result, false);//取第一个(默认)服务器
                }
                else
                {
                    pubConn = dbbuilder.GetMainConnStringElement(svrName, out result);
                }
                DataTable dt  = new DataTable();
                byte[]    obj = null;

                DbHelper.Open(pubConn);
                string sql = "select file_value from fg_systemconfigfile where file_key='NG_NetWorkIPMapping_Data'";
                obj = (byte[])DbHelper.ExecuteScalar(pubConn, sql);
                if (obj != null)
                {
                    dt = NG3.Runtime.Serialization.SerializerBase.DeSerialize(obj) as DataTable;
                    if (dt != null && dt.Rows.Count > 0 && dt.Columns.IndexOf("connectType") != -1)
                    {
                        connectType = dt.Rows[0]["connectType"].ToString();
                    }
                }

                return(connectType);
            }
            catch (Exception ex)
            {
                return("0");

                throw new Exception(ex.Message);
            }
        }
Exemple #10
0
        public static DBConnectionStringBuilder GetAcountDBConnectString(string svrName, string database, out string pubConn, out string userConn)
        {
            var    dbbuilder = new DBConnectionStringBuilder();
            string result;

            if (string.IsNullOrWhiteSpace(svrName))
            {
                pubConn = dbbuilder.GetMainConnStringElement(0, out result, false);//取第一个(默认)服务器
            }
            else
            {
                pubConn = dbbuilder.GetMainConnStringElement(svrName, out result);
            }
            if (string.IsNullOrWhiteSpace(database))
            {
                userConn = dbbuilder.GetDefaultConnString();//取默认连接串
            }
            else
            {
                userConn = dbbuilder.GetAccConnstringElement(svrName, "NG" + database.Replace("NG", ""), pubConn, out result);
            }
            return(dbbuilder);
        }
Exemple #11
0
        public string getUserInfo()
        {
            //string mobileno = System.Web.HttpContext.Current.Request.Params["mobileno"];  //人员手机号码

            string mobileno = CasAuthentication.CurrentPrincipal.Identity.Name;

            //根据手机号码获取人员信息

            DBConnectionStringBuilder dbbuilder = new DBConnectionStringBuilder();
            string    theResult;
            string    pubConn  = dbbuilder.GetMainConnStringElement(0, out theResult, false); //取第一个(默认)服务器
            string    userConn = dbbuilder.GetDefaultConnString();                            //取默认连接串
            DataTable dt       = null;
            object    userData = null;

            if (string.IsNullOrEmpty(mobileno))
            {
                return(DataConverterHelper.SerializeObject(new
                {
                    Status = ResponseStatus.Error,
                    Msg = "没有获取到云平台的cas的手机号码."
                }));
            }

            try
            {
                string sqlType       = "";
                string connectString = "";

                //ConnectType=ORACLEClient;Data Source=10.0.14.34:1521/DQW;User ID=NG0001;Password=NG0001;Self Tuning=false;Statement Cache Size=0;Metadata Pooling=false
                //ConnectType=SqlClient;Server=10.0.13.168;Database=NG0012;User ID=sa;Password=123456;
                if (userConn.IndexOf("ConnectType=SqlClient", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    sqlType = "sqlclient";
                    string server   = NG.NGKeyValueUtility.GetValue(userConn, "Server");
                    string dataBase = NG.NGKeyValueUtility.GetValue(userConn, "Database", "Initial Catalog");
                    string userid   = NG.NGKeyValueUtility.GetValue(userConn, "User ID");
                    string password = NG.NGKeyValueUtility.GetValue(userConn, "Password");

                    connectString = string.Format("Server={0};Database={1};User ID={2};Password={3}", server, dataBase, userid, password);
                }

                if (userConn.IndexOf("ConnectType=OracleClient", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    sqlType = "oracle";

                    string   source      = NG.NGKeyValueUtility.GetValue(userConn, "Data Source");
                    string[] arrySource  = source.Split(new char[] { ':', '/' }, StringSplitOptions.RemoveEmptyEntries);
                    string   host        = arrySource[0];
                    string   port        = arrySource[1];
                    string   Server_name = arrySource[2];
                    string   userid      = NG.NGKeyValueUtility.GetValue(userConn, "User ID");
                    string   password    = NG.NGKeyValueUtility.GetValue(userConn, "Password");

                    connectString = string.Format("Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST={0})(PORT={1}))(CONNECT_DATA=(SERVICE_NAME={2})));Persist Security Info=True;User ID={3};Password={4};", host, port, Server_name, userid, password);
                }

                //"oracle":"Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.6.139)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl)));Persist Security Info=True;User ID=PUBDATA;Password=pubdata;";
                //"sqlclient":"Server=218.108.53.111,1433;Database=DMPBase;User ID=sa;Password=newgrand@123";



                string SQLString = string.Format("select userno,pwd from fg3_user where mobileno='{0}'", mobileno);

                if (sqlType == "sqlclient")
                {
                    using (SqlConnection connection = new SqlConnection(connectString))
                    {
                        DataSet ds = new DataSet();
                        try
                        {
                            connection.Open();
                            SqlDataAdapter command = new SqlDataAdapter(SQLString, connection);

                            command.Fill(ds, "ds");
                        }
                        catch (SqlException ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            connection.Close();
                        }
                    }
                }
                else if (sqlType == "oracle")
                {
                    using (OracleConnection connection = new OracleConnection(connectString))
                    {
                        DataSet ds = new DataSet();
                        try
                        {
                            connection.Open();
                            OracleDataAdapter command = new OracleDataAdapter(SQLString, connection);
                            command.Fill(ds, "ds");
                        }
                        catch (OracleException ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            connection.Close();
                        }

                        dt = ds.Tables[0];
                    }
                }
            }
            catch (Exception e)
            {
                //throw e;
                return(DataConverterHelper.SerializeObject(new
                {
                    Status = ResponseStatus.Error,
                    Msg = e.ToString()
                }));
            }

            if (dt != null && dt.Rows.Count > 0)
            {
                if (dt.Rows.Count > 1)
                {
                    return(DataConverterHelper.SerializeObject(new
                    {
                        Status = ResponseStatus.Error,
                        Msg = "当前的人员的手机号:" + mobileno + ",含有多个数据"
                    }));
                }
                string dbpwd = "";
                if (!string.IsNullOrEmpty(dt.Rows[0]["pwd"].ToString()))
                {
                    dbpwd = NG3.NGEncode.DecodePassword(dt.Rows[0]["pwd"].ToString(), 128);
                }


                userData = new
                {
                    logid = dt.Rows[0]["userno"].ToString(),
                    pwd   = string.IsNullOrEmpty(dt.Rows[0]["pwd"].ToString()) ? "" : dt.Rows[0]["pwd"].ToString()
                };
            }
            else
            {
                return(DataConverterHelper.SerializeObject(new
                {
                    Status = ResponseStatus.Error,
                    Msg = "当前的人员的手机号:" + mobileno + ",没有对应的账号"
                }));
            }

            var data = new
            {
                Status = ResponseStatus.Success,
                Msg    = "",
                Data   = userData
            };


            return(DataConverterHelper.SerializeObject(data));
        }
Exemple #12
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="requestContext">请求上下文</param>
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            var isSso = System.Web.HttpContext.Current.Request.Params["issso"] == null ? "" : System.Web.HttpContext.Current.Request.Params["issso"].ToString();

            if (isSso == "1")
            {
                var logId   = System.Web.HttpContext.Current.Request.Params["logno"] == null ? "" : System.Web.HttpContext.Current.Request.Params["logno"].ToString();
                var logName = System.Web.HttpContext.Current.Request.Params["logname"] == null ? "" : System.Web.HttpContext.Current.Request.Params["logname"].ToString();
                var oCode   = System.Web.HttpContext.Current.Request.Params["ocode"] == null ? "" : System.Web.HttpContext.Current.Request.Params["ocode"].ToString();
                var uCode   = System.Web.HttpContext.Current.Request.Params["ucode"] == null ? "" : System.Web.HttpContext.Current.Request.Params["ucode"].ToString();

                //comment by ljy 2018.01.17 特变要求预览能跟正式发布单据一样操作
                //ViewBag.IsSso = "true";
                ViewBag.IsSso = "false";

                try
                {
                    //设置NG3的i6WebInfoBase对象
                    var dbbuilder = new DBConnectionStringBuilder();
                    var dbName    = string.Empty;

                    //没有传帐套号过来
                    if (string.IsNullOrWhiteSpace(uCode))
                    {
                        dbName = dbbuilder.DefaultDB;  //如NG0001
                        uCode  = dbName.Substring(2);  //如0001
                    }
                    else
                    {
                        dbName = "NG" + uCode;
                    }

                    var result   = string.Empty;
                    var pubConn  = dbbuilder.GetMainConnStringElement(0, out result, false);          //获取主数据库连接串 NGSoft
                    var userConn = dbbuilder.GetAccConnstringElement(0, dbName, pubConn, out result); //获取默认数据库连接串 NG0001

                    var i6AppInfo = new I6WebAppInfo()
                    {
                        UserType          = UserType.OrgUser,
                        PubConnectString  = pubConn,
                        UserConnectString = userConn,
                        LoginID           = logId,
                        UserName          = logName,
                        OCode             = oCode,
                        UCode             = uCode,
                        DbName            = dbName,
                        UserID            = Convert.ToInt64(DbHelper.GetString(userConn, string.Format("select phid from fg3_user where userno='{0}'", logId))),
                        OrgID             = Convert.ToInt64(DbHelper.GetString(userConn, string.Format("select phid from fg_orglist where ocode='{0}'", oCode)))
                    };

                    System.Web.HttpContext.Current.Session["NGWebAppInfo"] = i6AppInfo;
                    ConnectionInfoService.SetSessionConnectString(i6AppInfo.UserConnectString);
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message); //应该加入日志,设置i6WebAppInfo异常。
                }
            }

            base.Initialize(requestContext);

            //调老丰AFCommonController的InitialAF(),里面含WorkFlowHandling()
            string dbnameStr = NG3.AppInfoBase.DbName;

            if (string.IsNullOrWhiteSpace(dbnameStr))
            {
                dbnameStr = base.NGPreCompileHandling();
            }
            base.InitialAF(dbnameStr);
        }
Exemple #13
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="svrName">数据库服务器名</param>
        /// <param name="account">帐套</param>
        /// <param name="logid">登录id</param>
        /// <param name="pwd">密码</param>
        /// <param name="msg">消息</param>
        /// <returns></returns>
        public bool Login(string svrName, string account, string logid, string pwd, ref string msg)
        {
            string result;
            DBConnectionStringBuilder dbbuilder = new DBConnectionStringBuilder();
            string pubConn  = string.Empty;
            string userConn = string.Empty;

            if (string.IsNullOrWhiteSpace(svrName))
            {
                pubConn = dbbuilder.GetMainConnStringElement(0, out result, false);//取第一个(默认)服务器
            }
            else
            {
                pubConn = dbbuilder.GetMainConnStringElement(svrName, out result);
            }

            if (string.IsNullOrWhiteSpace(account))
            {
                userConn = dbbuilder.GetDefaultConnString();//取默认连接串
            }
            else
            {
                userConn = dbbuilder.GetAccConnstringElement(svrName, account, pubConn, out result);
            }

            I6WebAppInfo appInfo = new I6WebAppInfo();

            appInfo.UserType = UserType.OrgUser;

            #region 校验用户是否存在

            object obj = DbHelper.ExecuteScalar(userConn, string.Format("select count(logid) from secuser where logid='{0}'", logid));
            if (obj == null || obj == DBNull.Value || obj.ToString() == "0")
            {
                //检测系统管理员
                obj = DbHelper.ExecuteScalar(pubConn, string.Format("select count(cname) from ngrights where cname='{0}'", logid));
                if (obj == null || obj == DBNull.Value || obj.ToString() == "0")
                {
                    //this.SetErrMsg(ps, "不存在该用户!");
                    //return false;

                    msg = "不存在该用户!";
                    return(false);
                }
                else
                {
                    appInfo.UserType = SUP.Common.Base.UserType.System;
                }
            }
            #endregion

            #region 用户状态
            string sql = "select status from secuser where logid='" + logid + "'";
            string ret = DbHelper.GetString(userConn, sql);

            if (ret == "1")
            {
                msg = "用户已锁定,请联系系统管理员!";
                return(false);
            }
            #endregion

            #region 校验密码


            if (UserType.OrgUser == appInfo.UserType)
            {
                obj = DbHelper.ExecuteScalar(userConn, string.Format("select pwd from secuser where logid='{0}'", logid));
            }
            else
            {
                obj = DbHelper.ExecuteScalar(pubConn, string.Format("select cpwd from ngrights where cname='{0}'", logid));
            }

            if (string.IsNullOrEmpty(pwd))
            {
                if (obj != null && obj != DBNull.Value)
                {
                    if (obj.ToString().Length > 0)
                    {
                        msg = "密码不正确";
                        return(false);
                    }
                }
            }
            else
            {
                if (obj == null || obj == DBNull.Value)
                {
                    msg = "密码不正确";
                    return(false);
                }
                else
                {
                    string dbpwd = NG3.NGEncode.DecodePassword(obj.ToString(), 128);
                    if (dbpwd.Equals(pwd) == false)
                    {
                        msg = "密码不正确";
                        return(false);
                    }
                }
            }

            #endregion

            return(true);
        }
Exemple #14
0
        public void Check(ref string msg, ref bool loginflag, string svrName, string account, string logid, string pwd)
        {
            string result;
            DBConnectionStringBuilder dbbuilder = new DBConnectionStringBuilder();
            string pubConn  = string.Empty;
            string userConn = string.Empty;


            if (string.IsNullOrWhiteSpace(svrName))
            {
                pubConn = dbbuilder.GetMainConnStringElement(0, out result, false);//取第一个(默认)服务器
            }
            else
            {
                pubConn = dbbuilder.GetMainConnStringElement(svrName, out result);
            }

            if (string.IsNullOrWhiteSpace(account))
            {
                userConn = dbbuilder.GetDefaultConnString();//取默认连接串
            }
            else
            {
                userConn = dbbuilder.GetAccConnstringElement(svrName, account, pubConn, out result);
            }

            I6WebAppInfo appInfo = new I6WebAppInfo();

            appInfo.UserType = UserType.OrgUser;


            #region 用户状态

            string sql = "select status from secuser where logid='" + logid + "'";
            string ret = DbHelper.GetString(userConn, sql);

            if (ret == "1")
            {
                msg       = "用户[" + logid + "]已锁定,请联系系统管理员!";
                loginflag = false;
                return;
            }

            int sysErrortimes     = this.dac.GetSysErrTimes(userConn);//系统定义出错次数
            int currentErrorTimes = this.dac.GetErrTimes(logid, userConn);

            if (currentErrorTimes == sysErrortimes)
            {
                this.dac.SetUserStateOff(logid, userConn);//锁定用户
                msg       = "用户[" + logid + "]已锁定,请联系系统管理员!";
                loginflag = false;
                return;
            }

            #endregion

            string username = string.Empty;
            //校验用户
            object obj = DbHelper.ExecuteScalar(userConn, string.Format("select count(logid) from secuser where logid='{0}'", logid));
            if (obj == null || obj == DBNull.Value || obj.ToString() == "0")
            {
                //检测系统管理员
                obj = DbHelper.ExecuteScalar(pubConn, string.Format("select count(cname) from ngrights where cname='{0}'", logid));
                if (obj == null || obj == DBNull.Value || obj.ToString() == "0")
                {
                    //this.SetErrMsg(ps, "不存在该用户!");
                    //return false;

                    msg       = "用户名或密码错误!";//"不存在该用户!";
                    loginflag = false;
                    this.dac.AddErrTimes(logid, userConn);
                    return;
                }
                else
                {
                    appInfo.UserType = SUP.Common.Base.UserType.System;
                }
                username = logid;
            }
            else
            {
                string usernameSql = string.Format("select u_name from secuser where logid='{0}'", logid);
                username = DbHelper.GetString(userConn, usernameSql);
            }


            #region 校验密码


            if (UserType.OrgUser == appInfo.UserType)
            {
                obj = DbHelper.ExecuteScalar(userConn, string.Format("select pwd from secuser where logid='{0}'", logid));
            }
            else
            {
                obj = DbHelper.ExecuteScalar(pubConn, string.Format("select cpwd from ngrights where cname='{0}'", logid));
            }

            if (string.IsNullOrEmpty(pwd))
            {
                if (obj != null && obj != DBNull.Value)
                {
                    if (obj.ToString().Length > 0)
                    {
                        msg       = "用户名或密码错误!";//"密码不正确";
                        loginflag = false;
                        this.dac.AddErrTimes(logid, userConn);
                        return;
                    }
                }
            }
            else
            {
                if (obj == null || obj == DBNull.Value)
                {
                    msg       = "用户名或密码错误!"; //"密码不正确";
                    loginflag = false;
                    this.dac.AddErrTimes(logid, userConn);
                    return;
                }
                else
                {
                    string dbpwd = NG3.NGEncode.DecodePassword(obj.ToString(), 128);
                    if (dbpwd.Equals(pwd) == false)
                    {
                        msg       = "用户名或密码错误!";//"密码不正确";
                        loginflag = false;
                        this.dac.AddErrTimes(logid, userConn);
                        return;
                    }
                }
            }

            #endregion

            //错误次数清零
            this.dac.ClearErr(logid, userConn);

            //普通用户,获取组织
            string ocode = string.Empty;
            if (UserType.System != appInfo.UserType)
            {
                ocode = DbHelper.ExecuteScalar(userConn, string.Format("select lastloginorg from secuser where logid='{0}'", logid)).ToString();

                if (string.IsNullOrWhiteSpace(ocode))
                {
                    sql = "select ocode from fg_orglist";
                    DataTable dt = DbHelper.GetDataTable(userConn, sql);

                    if (dt.Rows.Count > 0)
                    {
                        ocode = dt.Rows[0]["ocode"].ToString();//取第一个组织作为默认组织
                    }
                }
            }

            #region 在线用户

            //string message = this.CheckUserOnline(logid, account, string.Empty);
            string message = this.CheckTheSameSessionUser(logid);
            if (!string.IsNullOrEmpty(message))
            {
                msg       = message;
                loginflag = false;
                return;
            }

            #endregion

            appInfo.PubConnectString  = pubConn;
            appInfo.UserConnectString = userConn;
            appInfo.LoginID           = logid;
            appInfo.UserName          = username;
            appInfo.OCode             = ocode;
            appInfo.UCode             = account;
            appInfo.UserID            = Convert.ToInt64(DbHelper.GetString(userConn, string.Format("select phid from fg3_user where userno='{0}'", logid)));
            appInfo.OrgID             = Convert.ToInt64(DbHelper.GetString(userConn, string.Format("select phid from fg_orglist where ocode='{0}'", ocode)));

            System.Web.HttpContext.Current.Session[UPAppInfoNameInSession] = appInfo;
            NG3.Data.Service.ConnectionInfoService.SetSessionConnectString(appInfo.UserConnectString);//初始化2.0的dbhelper
        }