public bool DoLogin() { string userName = ""; string password = ""; if (m_incomingDataParser.GetValue(ProtocolKey.UserName, ref userName) & m_incomingDataParser.GetValue(ProtocolKey.Password, ref password)) { if (password.Equals(BasicFunc.MD5String("admin"), StringComparison.CurrentCultureIgnoreCase)) { m_outgoingDataAssembler.AddSuccess(); m_userName = userName; m_logined = true; Program.Logger.InfoFormat("{0} login success", userName); } else { m_outgoingDataAssembler.AddFailure(ProtocolCode.UserOrPasswordError, ""); Program.Logger.ErrorFormat("{0} login failure,password error", userName); } } else { m_outgoingDataAssembler.AddFailure(ProtocolCode.ParameterError, ""); } return(DoSendResult()); }
//检测文件是否正在使用中,如果正在使用中则检测是否被上传协议占用,如果占用则关闭,真表示正在使用中,并没有关闭 public bool CheckFileInUse(string fileName) { if (BasicFunc.IsFileInUse(fileName)) { bool result = true; lock (m_asyncSocketServer.UploadSocketProtocolMgr) { UploadSocketProtocol uploadSocketProtocol = null; for (int i = 0; i < m_asyncSocketServer.UploadSocketProtocolMgr.Count(); i++) { uploadSocketProtocol = m_asyncSocketServer.UploadSocketProtocolMgr.ElementAt(i); if (fileName.Equals(uploadSocketProtocol.FileName, StringComparison.CurrentCultureIgnoreCase)) { lock (uploadSocketProtocol.AsyncSocketUserToken) //AsyncSocketUserToken有多个 { m_asyncSocketServer.ServerLogic.CloseClientSocket(uploadSocketProtocol.AsyncSocketUserToken); } result = false; } } } return(result); } else { return(false); } }
public bool DoLogin() { string userName = ""; string password = ""; if (m_incomingDataParser.GetValue(ProtocolKey.UserName, ref userName) & m_incomingDataParser.GetValue(ProtocolKey.Password, ref password)) { if (password.Equals(BasicFunc.MD5String("admin"), StringComparison.CurrentCultureIgnoreCase)) { m_outgoingDataAssembler.AddSuccess(); m_userName = userName; m_logined = true; Debug.WriteLog.Log(eLogLevel.ell_Info, userName + " login success"); } else { m_outgoingDataAssembler.AddFailure(ProtocolCode.UserOrPasswordError, ""); } } else { m_outgoingDataAssembler.AddFailure(ProtocolCode.ParameterError, ""); } return(DoSendResult()); }