void server_ReceiveCmd(object sender, QcCmdEventArgs e) { lock (obj) { QcCmd cmd = e.Cmd; string from = e.Cmd.tokens(1); string to = e.Cmd.tokens(2); if (lstUser.ContainsKey(from)) { lstUser[from].LastOnline = DateTime.Now; } switch (cmd.CmdType) { case QcProtocol.QcCommand.QcCheckLicense: try { LicenseRetCode ret = LicenseRetCode.未授权; //CONTINUE: // if (cmd == null) goto CONTINUE; string type = cmd.tokens(1); string arg = cmd.tokens(2); switch (type) { case "Feature": int id = 0; int.TryParse(arg, out id); ret = License.CheckFeature(id); break; case "Module": ret = License.CheckModule(arg); break; case "Product": ret = License.CheckProduct(arg); break; case "Regsiter": ret = License.RegsisterUser(arg); break; case "Release": License.ReleaseUser(arg); break; } e.Chanel.Send(QcCmd.MakeCmd(QcProtocol.QcCommand.QcCheckLicense, ret.ToString())); e.Chanel.CloseLink(); } catch (Exception ex) { QcLog.LogString("QcCheckLicense " + cmd.ToString() + ":" + ex.Message); } break; case QcProtocol.QcCommand.QcUserLogin: bool blLogined = false; blLogined = true; if (lstUser.ContainsKey(from) == false) { var user = QcUser.RefreshUser(from); if (user != null) { var qmu = new QcMsgUser(user); lstUser.TryAdd(qmu.Name, qmu); } } if (lstUser.ContainsKey(from)) { //这里判断一下是否可以登录 var msguser = lstUser[from]; var user = msguser.User as QcUser; string sql = "select * from " + QcUser.TableName + " where " + user.CodeField + "='" + user.Code + "' and 状态='启用'"; if (DbHelper.Exists(sql)) { QcChanel chanel = new QcChanel(); chanel.SetChanel(e.Chanel, this); lstUser[from].Chanel = chanel; if (this.Logined != null) { var userfrom = lstUser[from]; var evtarg = new QcMessagerLoginEventArg(userfrom); this.Logined(this, evtarg); } //this.BroadcastMsg(e.Cmd.ToString()); this.BroadcastMsg(QcCmd.MakeCmd(QcProtocol.QcCommand.QcUserLogin, from, "*")); blLogined = true; } else { blLogined = false; } QcClientService qcs = e.Chanel as QcClientService; e.Chanel.Send(QcCmd.MakeCmd(QcProtocol.QcCommand.QcLoginReplay, blLogined)); } break; case QcProtocol.QcCommand.QcListUser: var strusers = ""; foreach (var u in OnlineUsers) { strusers += u.Name + ","; } e.Chanel.Send(QcCmd.MakeCmd(QcProtocol.QcCommand.QcListUser, strusers)); break; case QcProtocol.QcCommand.QcLoginOut: if (lstUser.ContainsKey(from)) { var userfrom = lstUser[from]; if (this.Loginout != null) { var evt = new QcMessagerLoginEventArg(userfrom); this.Loginout(this, evt); } this.BroadcastMsg(QcCmd.MakeCmd(QcProtocol.QcCommand.QcLoginOut, from, "*")); userfrom.Close(); } break; case QcProtocol.QcCommand.QcDataUpdate: this.BroadcastMsg(e.Cmd.ToString()); break; default: if (to == "*") { this.BroadcastMsg(e.Cmd.ToString()); return; } else { if (lstUser.ContainsKey(to)) { var user = lstUser[to]; user.Send(e.Cmd.ToString()); } } break; } } }
public LicenseRetCode CheckProduct(string ProductName) { return(license.CheckProduct(ProductName)); }