private void ExCmdLogin() { if (string.IsNullOrEmpty(UserName)) { Msg = "用户名为空..."; return; } if (string.IsNullOrEmpty(UserPsw)) { Msg = "密码为空..."; return; } if (string.IsNullOrEmpty(IpAddr)) { Msg = "Ip地址为空..."; return; } if (ServerMain) { ServerStyle = 1; if (!Wlst.Sr.PPPandSocketSvr.Server.SocketClient.Connect(IpAddr, IpPort, 3)) { Msg = "连接服务器失败...<未联网或服务器未开启>"; return; } else { Msg = "连接服务器成功,正在验证用户名密码..."; } _bolCanLogin = false; } else if (ServerBak) { ServerStyle = 2; if (!Wlst.Sr.PPPandSocketSvr.Server.SocketClient.Connect(IpAddrBak, IpPortBak, 3)) { Msg = "连接服务器失败...<未联网或服务器未开启>"; return; } else { Msg = "连接服务器成功,正在验证用户名密码..."; } _bolCanLogin = false; } else { ServerStyle = 0; Msg = "请选择一个服务器连接方式..."; return; } // Wlst.Cr.Core.CoreServices.RegionManage.SetLoadInner(); //更新本地数据库的用户名密码地址 if (IpAddr == null) { IpAddr = "0.0.0.0"; } if (IpAddrBak == null) { IpAddrBak = "0.0.0.0"; } UpdateKeyVauleDb("ipAddr", IpAddr.Trim()); UpdateKeyVauleDb("ipPort", IpPort.ToString(CultureInfo.InvariantCulture)); UpdateKeyVauleDb("userName", UserName); UpdateKeyVauleDb("ipAddrBak", IpAddrBak.Trim()); UpdateKeyVauleDb("ipPortBak", IpPortBak.ToString(CultureInfo.InvariantCulture)); UpdateKeyVauleDb("serverStyle", ServerStyle.ToString(CultureInfo.InvariantCulture)); //在程序加载未显示设备列表时 屏蔽来自服务器端的各种显示信息 信息和选测信息 var lst = new List <string>(); lst.Add("wlst.msg .server_msg"); lst.Add("wlst.rtu.2000"); Wlst.Sr.PPPandSocketSvr.Server.ProtocolServices.ShieldCmd(true, lst); Thread.Sleep(900); //请求登录 var xxxinfo = Wlst.Sr.ProtocolPhone.LxLogin.wst_cnt_login; //.ServerPart.wlst_login_clinet_request_login; xxxinfo.WstLoginCntLogin.UserName = UserName; xxxinfo.WstLoginCntLogin.UserPassword = UserPsw; string sttachinfo = ""; if (File.Exists("C:\\Windows\\AdminLogin.txt")) //序列号LvfGay { StreamReader rd = File.OpenText("C:\\Windows\\AdminLogin.txt"); sttachinfo = rd.ReadToEnd(); xxxinfo.WstLoginCntLogin.AttachInfo = sttachinfo; } SndOrderServer.OrderSnd(xxxinfo, 3, 1); //线程检测登录 try { if (thread.IsAlive) { thread.Abort(); } } catch (Exception exx) { } thread = new Thread(ThreadRunForOutTime); thread.Start(); }
private void ExCmdLogin() { MsgDetail = ""; if (string.IsNullOrEmpty(UserName)) { Msg = "用户名为空..."; return; } if (string.IsNullOrEmpty(UserPsw)) { Msg = "密码为空..."; return; } if (string.IsNullOrEmpty(IpAddr)) { Msg = "Ip地址为空..."; return; } _islogin = true; if (ServerMain) { ServerStyle = 1; Wlst.Sr.EquipmentInfoHolding.Services.Others.SeverIpAddr = IpAddr + ""; Wlst.Sr.EquipmentInfoHolding.Services.Others.SeverPort = IpPort + ""; if (!Wlst.Sr.PPPandSocketSvr.Server.SocketClient.Connect(IpAddr, IpPort, 3)) { Msg = "连接服务器失败...<未联网或服务器未开启>"; return; } else { Msg = "连接服务器成功,正在验证用户名密码..."; } _bolCanLogin = false; HttpUrl = IpAddr; } else if (ServerBak) { ServerStyle = 2; Wlst.Sr.EquipmentInfoHolding.Services.Others.SeverIpAddr = IpAddrBak + ""; Wlst.Sr.EquipmentInfoHolding.Services.Others.SeverPort = IpPortBak + ""; if (!Wlst.Sr.PPPandSocketSvr.Server.SocketClient.Connect(IpAddrBak, IpPortBak, 3)) { Msg = "连接服务器失败...<未联网或服务器未开启>"; return; } else { Msg = "连接服务器成功,正在验证用户名密码..."; } _bolCanLogin = false; HttpUrl = IpAddrBak; } else { ServerStyle = 0; Msg = "请选择一个服务器连接方式..."; return; } // Wlst.Cr.Core.CoreServices.RegionManage.SetLoadInner(); //更新本地数据库的用户名密码地址 if (IpAddr == null) { IpAddr = "0.0.0.0"; } if (IpAddrBak == null) { IpAddrBak = "0.0.0.0"; } UpdateKeyVauleDb("ipAddr", IpAddr.Trim()); UpdateKeyVauleDb("ipPort", IpPort.ToString(CultureInfo.InvariantCulture)); UpdateKeyVauleDb("userName", UserName); UpdateKeyVauleDb("ipAddrBak", IpAddrBak.Trim()); UpdateKeyVauleDb("ipPortBak", IpPortBak.ToString(CultureInfo.InvariantCulture)); UpdateKeyVauleDb("serverStyle", ServerStyle.ToString(CultureInfo.InvariantCulture)); //在程序加载未显示设备列表时 屏蔽来自服务器端的各种显示信息 信息和选测信息 var lst = new List <string>(); lst.Add("wlst.msg .server_msg"); lst.Add("wlst.rtu.2000"); Wlst.Sr.PPPandSocketSvr.Server.ProtocolServices.ShieldCmd(true, lst); Thread.Sleep(900); //请求登录 var xxxinfo = Wlst.Sr.ProtocolPhone.LxLogin.wst_cnt_login; //.ServerPart.wlst_login_clinet_request_login; xxxinfo.WstLoginCntLogin.UserName = UserName; xxxinfo.WstLoginCntLogin.UserPassword = UserPsw; //lvf 如果需要自动登录 记录当前用户密码 string dir = Directory.GetCurrentDirectory() + "\\config"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } string path = dir + "\\login.xml"; if (File.Exists(path)) { try { var dicOp = new Dictionary <string, string>(); dicOp.Add("UserName", UserName); dicOp.Add("Password", UserPsw); Wlst.Cr.CoreOne.Services.SystemXmlConfig.Save(dicOp, "login", "\\config"); } catch (Exception) { } } string sttachinfo = ""; if (File.Exists("C:\\Windows\\AdminLogin.txt")) //序列号Lvf { StreamReader rd = File.OpenText("C:\\Windows\\AdminLogin.txt"); sttachinfo = rd.ReadToEnd(); xxxinfo.WstLoginCntLogin.AttachInfo = sttachinfo; } SndOrderServer.OrderSnd(xxxinfo, 3, 1); //线程检测登录 try { if (thread.IsAlive) { thread.Abort(); } } catch (Exception exx) { } thread = new Thread(ThreadRunForOutTime); thread.Start(); }