Esempio n. 1
0
        /// <summary>
        /// 重新登录
        /// </summary>
        /// <param name="ci"></param>
        /// <param name="Uid"></param>
        public void CheckUid(ClientInfo ci, string Uid)
        {
            ci.CnStr        = System.Configuration.ConfigurationManager.ConnectionStrings["WSERPSysConnString"].ToString();
            ci.DataBaseName = System.Configuration.ConfigurationManager.AppSettings["WSERPSysDatabaseName"].ToString();

            using (AdoEx ado = new AdoEx("System.Data.SqlClient", ci.CnStr))
            {
                ci.UserName = Uid;
                //删除当前用户、客户端登录记录
                UtilityTools.WriteTxt("//Log//删除当前用户、客户端登录记录", "删除当前用户、客户端登录记录:" + ci.UserName + ", ci.MachineName:" + ci.MachineName + "  \r\n ci.CnStr:" + ci.CnStr);

                int i = ado.ExecuteNonQuery(CommandType.Text,
                                            "DELETE FROM MPSHELP WHERE A=@A AND C=@C",
                                            new SqlParameter[] {
                    new SqlParameter("@A", Wellshsoft.Net.DataProtector.Encode(ci.UserName)),
                    new SqlParameter("@C", Wellshsoft.Net.DataProtector.Encode(ci.MachineName))
                });
                UtilityTools.WriteTxt("//Log//删除当前用户返回的i", "删除当前用户返回的i" + i);
            }
            try
            {
                ci.CnStr        = System.Configuration.ConfigurationManager.ConnectionStrings["ConnString"].ToString();
                ci.DataBaseName = System.Configuration.ConfigurationManager.AppSettings["DatabaseName"].ToString();
                UtilityTools.WriteTxt("//Log//重新登录", "重新登录 前  \r\n              ci.UserName:"******" \r\n  ci.MachineName:" + ci.MachineName
                                      + " \r\n  ci.Tag:" + ci.Tag
                                      + " \r\n  ci.CnStr:" + ci.CnStr);
                //重新登录
                Security security = new WSERP.DataAccess.Security();
                //网站根目录需要配置连接数据库文件LocalNetDb.xml
                UsersData uid = security.Login(ci, ci.UserName, ci.MachineName);
                if (uid == null)
                {
                    UtilityTools.WriteTxt("//Log//重新登录", "重新登录 后 uid == null ");
                }
                else
                {
                    UtilityTools.WriteTxt("//Log//重新登录", "重新登录 后  \r\n Ename:" + uid.Ename + "EID:" + uid.EID);
                }
                string[] tags = (string[])uid.Tag;

                ci.AccessDateTime = DataConvert.ToDateTime <string>(DataProtector.Decode(tags[1]));
            }
            catch (Exception ex)
            {
                UtilityTools.WriteTxt("//Log//重新登录异常", "重新登录异常,网站根目录LocalNetDb.xml是否配置正确? ex.Message:" + ex.Message);
            }
        }