private void btnCmd_Click(object sender, EventArgs e) { Button btn = sender as Button; CmdInfo info = new CmdInfo(); info.AttrList = new List <ClassAttributeInfo>(); List <string> columnList = new List <string>(); foreach (ListViewItem item in this.lstSelectedFields.Items) { var tagInfo = item.Tag as SixStringInfo; columnList.Add(item.Text); ClassAttributeInfo attrInfo = new ClassAttributeInfo(); attrInfo.AttrName = tagInfo.AttrName; attrInfo.ColName = tagInfo.ColName; attrInfo.TitleName = tagInfo.Remark; attrInfo.AttrType = tagInfo.AttrType; attrInfo.DbType = tagInfo.DbType; attrInfo.Style = tagInfo.Style; info.AttrList.Add(attrInfo); } ListViewItem cmdItem = new ListViewItem(btn.Text); cmdItem.SubItems.AddRange(new string[] { string.Join(",", columnList.ToArray()) }); cmdItem.Tag = Guid.NewGuid().ToString("N"); this.lstCmdList.Items.Add(cmdItem); info.CmdName = cmdItem.Text; info.Guid = cmdItem.Tag as string; PageCache.AddCmd(info); }
protected void cmdAddNew_Click(object sender, EventArgs e) { if ((txtCmd.Text != string.Empty) && (CmdDB.GetIDByCmd(txtCmd.Text) != 0)) { lblUpdateStatus.Text = "<font color='red'> Đã tồn tại chức năng này! </font>"; return; } CmdInfo info = new CmdInfo(); info.Cmd_Name = txtName.Text.Trim(); info.Cmd_Value = txtCmd.Text.Trim(); info.Cmd_Params = txtParams.Text.Trim(); info.Cmd_Url = txtUrl.Text.Trim(); info.Cmd_Path = txtPath.Text.Trim(); info.Cmd_Enable = chkEnable.Checked; info.Cmd_Visible = chkVisble.Checked; info.Cmd_ParentID = ConvertUtility.ToInt32(dropParent.SelectedValue); try { txtID.Text = CmdDB.Insert(info).ToString(); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch (Exception ex) { string s = ex.Message; lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } }
private void SendMsg(IServer server, ISession session, CmdInfo info) { MsgInfo input = info.As <MsgInfo>(); if (input != null) { User fromUser = GetUserInfo(server, input.From); if (fromUser == null) { logger.LogInformation($"您还没有登录系统 the session name is: {session.Name}"); SendError(session, "您还没有登录系统"); return; } if (input.MsgOfBytes != null) { logger.LogInformation($"the first byte is: {input.MsgOfBytes[0]}"); logger.LogInformation($"the last byte is: {input.MsgOfBytes[input.MsgOfBytes.Length - 1]}"); } switch (input.ToType) { case MsgToType.User: ISession toSession = GetSession(server, input.To); SendInfo(toSession, info, new ReceiveMsgInfo(fromUser, input)); break; case MsgToType.Group: break; case MsgToType.System: break; } } }
private void LoginById(ISession session, CmdInfo info) { if (info.Data == null) { return; } string str = info.Data.ToString(); int userId = Convert.ToInt32(str); var user = userRepository.GetById(userId); if (user == null) { SendError(session, "登录失败-请检查用户ID"); return; } user.Password = string.Empty; session[currentUserKey] = user; var queue = msgMgr.GetQueue(userId); if (queue != null && queue.Count > 0) { while (!queue.IsEmpty) { if (queue.TryDequeue(out CmdInfo cloneInfo)) { logger.LogInformation("发送离线消息"); SendInfo(session, cloneInfo); } } } }
private void Check(IServer server, ISession session, CmdInfo info) { object obj = info.Data; int userId = 0; if (obj != null) { int.TryParse(obj.ToString(), out userId); } if (userId > 0) { logger.LogInformation($"the session name is: {session.Name}"); User user = GetUserInfo(server, userId); if (user == null) { logger.LogInformation("没有找到session"); user = GetUserInfo(userId); session[currentUserKey] = user; } else { logger.LogInformation("找到session"); } SendOffLineMsg(session, userId); } }
public CmdBase GetCmd(string instruction, CmdInfo info, string label) { var split = instruction.Split(' '); CmdJ cmd = new CmdJ(info, split[1], label); return(cmd); }
private void SearchUser(IServer server, ISession session, CmdInfo info) { string key = info.Data.ToString(); var list = userRepository.GetListByKey(key); SendInfo(session, info.Clone(list)); }
private void GetPath() { path = "|"; ArrayList titleArr = new ArrayList(); if (cmd != string.Empty) { CmdInfo curCmd = CmdDB.GetInfoByCmd(cmd); while (curCmd != null) { path += curCmd.Cmd_ID + "|"; titleArr.Add(curCmd.Cmd_Name); curCmd = CmdDB.GetInfo(curCmd.Cmd_ParentID); } } string pageTitle = AppEnv.WebTitle + " - "; titleArr.Reverse(); foreach (string item in titleArr) { pageTitle += item + " - "; } if (pageTitle.IndexOf(" - ") > 0) { pageTitle = pageTitle.Substring(0, pageTitle.Length - 2); } AdminPage page = (AdminPage)Page; page.Title = UnicodeUtility.UnicodeToKoDau(pageTitle); }
/// <summary> /// 双击添加动作指令 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gvCmd_DoubleClick(object sender, EventArgs e) { try { gvCmdSet.CloseEditor(); gvActionLandMark.CloseEditor(); CmdInfo cmd = bsCmd.Current as CmdInfo; LandmarkToActionsInfo frag = bsAction.Current as LandmarkToActionsInfo; foreach (var item in frag.ActionList) { if (cmd.CmdCode == item.CmdCode) { return; } } frag.ActionList.Add(new RouteFragmentConfigInfo() { CmdCode = cmd.CmdCode, CmdName = cmd.CmdName, }); this.bsFragment.DataSource = frag.ActionList; this.bsFragment.ResetBindings(false); } catch (Exception ex) { MsgBox.ShowError(ex.Message); } }
public CmdI(CmdInfo cmdInfo, byte rs, byte rt, short im, string lineLabel) : base(cmdInfo, lineLabel) { this.rs = rs; this.rt = rt; this.immediate = im; }
private void RunCommand(CmdInfo command, string installPath) { process?.Info("开始命令 " + command.Name); var target = context.ConvertPath(command.Target); if (!string.IsNullOrEmpty(target) && File.Exists(target)) { process?.Info("命令:" + target); if (!string.IsNullOrEmpty(command.Args)) { process?.Info("参数:" + command.Args); } var pinfo = new ProcessStartInfo(target, command.Args) { WorkingDirectory = installPath }; var proc = Process.Start(pinfo); if (proc != null) { proc.WaitForExit(); proc.Close(); proc.Dispose(); proc = null; } } }
private void FrmAGVCommod_Shown(object sender, EventArgs e) { try { if (FormType == 0) { agvNewAction = new CmdInfo(); agvNewAction.CmdCode = CmdCode; } //if (agvNewAction.CmdCode >= 1 && agvNewAction.CmdCode <= 8) //{ // this.txtActionCode.ReadOnly = true; // this.txtActionName.ReadOnly = true; // this.rtxtMessge.ReadOnly = true; //} //else //{ // this.txtActionCode.ReadOnly = false; // this.txtActionName.ReadOnly = false; // this.rtxtMessge.ReadOnly = false; //} this.bsAction.DataSource = agvNewAction; bsAction.ResetBindings(false); } catch (Exception ex) { MsgBox.ShowError(ex.Message); } }
/// <summary> /// Return instance of Command described by given info object /// </summary> /// <param name="cmdInfo"></param> /// <returns></returns> private ICommand GetCommandInstance(CmdInfo cmdInfo) { Type commandFinderType = typeof(ICommandFinder); bool requiresCommandFinder = cmdInfo.Type.GetConstructors() .Any(constructorInfo => constructorInfo .GetParameters() .Any(param => commandFinderType.IsAssignableFrom(param.ParameterType) ) ); ICommand?command; if (requiresCommandFinder) { command = ActivatorUtilities.CreateInstance(this.serviceProvider, cmdInfo.Type, this) as ICommand; } else { command = this.serviceProvider.GetService(cmdInfo.Type) as ICommand; } if (command == null) { throw new InvalidOperationException($"Registered service of type '{cmdInfo.Type.FullName}' is not a ICommand."); } return(command); }
private static object ConvertCommand(Type t, CmdInfo cmd) { // TODO: check parent class var attr = ((CmdAttribute[])t.GetCustomAttributes(typeof(CmdAttribute), false)).ToList(); var match = attr.Find(a => a.ID == cmd.ID); if (match == null) { throw new InvalidF3DZEXOpCodeException("Invalid ID"); } object obj = Activator.CreateInstance(t); foreach (var prop in t.GetProperties()) { if (!cmd.Args.ContainsKey(prop.Name) || cmd.Args[prop.Name].GetType() != prop.PropertyType) { throw new Exception("???"); } t.GetProperty(prop.Name).SetValue(obj, cmd.Args[prop.Name]); } return(obj); }
private void btnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { labelControl1.Focus(); CmdInfo action = bsAction.Current as CmdInfo; if (action == null) { return; } if (string.IsNullOrEmpty(action.CmdName)) { MsgBox.ShowWarn("请维护动作名称!"); return; } if (string.IsNullOrEmpty(action.CmdOrder)) { MsgBox.ShowWarn("请维护动作消息体!"); return; } mid_obj = action; this.DialogResult = DialogResult.OK; } catch (Exception ex) { MsgBox.ShowError(ex.Message); } }
public DialogResult ShowDialog(CmdInfo item, IWin32Window owner = null) { this.CmdInfo = item ?? new CmdInfo(); this.txtName.Text = this.CmdInfo.Name; if (this.CmdInfo.Target != null) { this.cmbTarget.SelectedItem = this.CmdInfo.Target; } if (this.CmdInfo.ArgList != null) { this.txtArgs.Text = string.Join(Environment.NewLine, this.CmdInfo.ArgList); } else { this.txtArgs.Text = ""; } if (owner != null) { return(this.ShowDialog(owner)); } else { return(this.ShowDialog()); } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); CmdDB.FillToListBox(dropParent.Items); dropParent.Items.Insert(0, new ListItem("Root", "0")); if (txtID.Text != string.Empty) { CmdInfo info = CmdDB.GetInfo(ConvertUtility.ToInt32(txtID.Text)); if (info != null) { dropParent.SelectedIndex = -1; MiscUtility.SetSelected(dropParent.Items, info.Cmd_ParentID.ToString()); } } nodePath = "|"; TreeViewNode focusNode = tvwCmds.SelectedNode; if (focusNode != null) { while (true) { if (focusNode.ParentNode == null) { break; } else { focusNode = focusNode.ParentNode; nodePath += focusNode.ID + "|"; } } } tvwCmds.Nodes.Clear(); TreeViewNode topRoot = new TreeViewNode(); topRoot.Text = "Root"; topRoot.ID = "0"; tvwCmds.Nodes.Add(topRoot); DataTable dtRoot = CmdDB.GetByParentID(0); foreach (DataRow row in dtRoot.Rows) { TreeViewNode rootNode = new TreeViewNode(); rootNode.Text = row["Cmd_Name"].ToString(); rootNode.ID = row["Cmd_ID"].ToString(); if (nodePath.IndexOf("|" + rootNode.ID + "|") >= 0) { rootNode.Expanded = true; } tvwCmds.Nodes.Add(rootNode); LoadCmdItem(rootNode); } }
private void SendError(ISession session, string msg) { CmdInfo info = new CmdInfo(serverConfig.ValidString, CmdType.Error, msg); //session.Stream.ToPipeStream().WriteLine(JsonSerializer.Serialize(info, options: jsonOpt)); //session.Stream.Flush(); SendByteMsg(session, JsonSerializer.Serialize(info, options: jsonOpt)); }
private void LoadControls() { string cmd = ConvertUtility.ToString(Request.QueryString["cmd"]); if (cmd == string.Empty) { placeControls.Controls.Add(LoadControl(AppEnv.ADMIN_PATH + "/UserControls/Core/WelCome.ascx")); return; } if ((cmd == "management") && (CurrentAdminInfo.User_Email == AppEnv.ADMIN_EMAIL)) { placeControls.Controls.Add(LoadControl(AppEnv.ADMIN_PATH + "/UserControls/Core/CmdManager.ascx")); return; } if (cmd == "accessdeny") { placeControls.Controls.Add(LoadControl(AppEnv.ADMIN_PATH + "/UserControls/Core/AccessDeny.ascx")); return; } CmdInfo info = CmdDB.GetInfo(CmdDB.GetIDByCmd(cmd)); if (info == null || !info.Cmd_Enable) { Response.Redirect(AppEnv.ADMIN_ACCESSDENY); } lblCommandName.Text = info.Cmd_Name; if ((!CurrentAdminInfo.User_SuperAdmin) && (!CmdRoleDB.CheckRole(CurrentAdminInfo.User_ID, info.Cmd_ID))) { Response.Redirect(AppEnv.ADMIN_ACCESSDENY); } string modulePath = AppEnv.ADMIN_PATH + info.Cmd_Path; //modulePath.Replace("//", "/"); if (File.Exists(Server.MapPath(modulePath))) { placeControls.Controls.Add(LoadControl(modulePath)); return; } modulePath = AppEnv.MODULE_PATH + info.Cmd_Path; ////modulePath.Replace("//", "/"); //Response.Write(modulePath); //Response.End(); if (File.Exists(Server.MapPath(modulePath))) { placeControls.Controls.Add(LoadControl(modulePath)); return; } lblErrorMessage.Text = " Không tìm thấy module, kiểm tra lại đường dẫn !"; }
public CmdR(CmdInfo cmdInfo, byte rs, byte rt, byte rd, byte shift, byte funct, string lineLabel) : base(cmdInfo, lineLabel) { this.rs = rs; this.rt = rt; this.rd = rd; this.shift = shift; this.funct = funct; }
private void SendInfo(ISession session, CmdInfo info) { if (session == null) { logger.LogWarning("没有找到session"); return; } SendByteMsg(session, JsonSerializer.Serialize(info, jsonOpt)); //session.Stream.ToPipeStream().WriteLine(JsonSerializer.Serialize(info, options: jsonOpt)); //session.Stream.Flush(); }
public CmdBase GetCmd(string instruction, CmdInfo info, string label) { //add $t7,$t3,$s0 var split = instruction.Split(' '); var regSplit = split[1].Split(','); int rd = Register.Translate(regSplit[0]); int rt = Register.Translate(regSplit[1]); int shift = Convert.ToInt32(regSplit[2]); CmdR cmd = new CmdShift(info, 0, (byte)rt, (byte)rd, (byte)shift, info.funct, label); return(cmd); }
public void Add(int key, CmdInfo msg) { if (dic.ContainsKey(key)) { dic[key].Enqueue(msg); } else { ConcurrentQueue <CmdInfo> queue = new ConcurrentQueue <CmdInfo>(); queue.Enqueue(msg); dic.TryAdd(key, queue); } }
public static int Insert(CmdInfo _cmdInfo) { SqlConnection dbConn = new SqlConnection(AppEnv.ConnectionString); SqlCommand dbCmd = new SqlCommand("Main_Cmds_Insert", dbConn); dbCmd.CommandType = CommandType.StoredProcedure; SqlParameter Cmd_Name = dbCmd.Parameters.Add("@Cmd_Name", SqlDbType.NVarChar, 200); Cmd_Name.Value = _cmdInfo.Cmd_Name; SqlParameter Cmd_Value = dbCmd.Parameters.Add("@Cmd_Value", SqlDbType.NVarChar, 200); Cmd_Value.Value = _cmdInfo.Cmd_Value; SqlParameter Cmd_Params = dbCmd.Parameters.Add("@Cmd_Params", SqlDbType.NVarChar, 200); Cmd_Params.Value = _cmdInfo.Cmd_Params; SqlParameter Cmd_Url = dbCmd.Parameters.Add("@Cmd_Url", SqlDbType.NVarChar, 200); Cmd_Url.Value = _cmdInfo.Cmd_Url; SqlParameter Cmd_Path = dbCmd.Parameters.Add("@Cmd_Path", SqlDbType.NVarChar, 200); Cmd_Path.Value = _cmdInfo.Cmd_Path; SqlParameter RETURN_VALUE = dbCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4); RETURN_VALUE.Direction = ParameterDirection.ReturnValue; SqlParameter Cmd_ParentID = dbCmd.Parameters.Add("@Cmd_ParentID", SqlDbType.Int, 4); Cmd_ParentID.Value = _cmdInfo.Cmd_ParentID; SqlParameter Cmd_Enable = dbCmd.Parameters.Add("@Cmd_Enable", SqlDbType.Bit, 1); Cmd_Enable.Value = _cmdInfo.Cmd_Enable; SqlParameter Cmd_Visible = dbCmd.Parameters.Add("@Cmd_Visible", SqlDbType.Bit, 1); Cmd_Visible.Value = _cmdInfo.Cmd_Visible; try { dbConn.Open(); dbCmd.ExecuteNonQuery(); } catch (Exception ex) { string s = ex.Message; } finally { dbConn.Close(); } return((int)dbCmd.Parameters["@RETURN_VALUE"].Value); }
public static void Update(CmdInfo _cmdInfo) { SqlConnection dbConn = new SqlConnection(AppEnv.ConnectionString); SqlCommand dbCmd = new SqlCommand("Main_Cmds_Update", dbConn); dbCmd.CommandType = CommandType.StoredProcedure; SqlParameter Cmd_ID = dbCmd.Parameters.Add("@Cmd_ID", SqlDbType.Int, 4); Cmd_ID.Value = _cmdInfo.Cmd_ID; SqlParameter Cmd_Name = dbCmd.Parameters.Add("@Cmd_Name", SqlDbType.NVarChar, 200); Cmd_Name.Value = _cmdInfo.Cmd_Name; SqlParameter Cmd_Value = dbCmd.Parameters.Add("@Cmd_Value", SqlDbType.NVarChar, 200); Cmd_Value.Value = _cmdInfo.Cmd_Value; SqlParameter Cmd_Params = dbCmd.Parameters.Add("@Cmd_Params", SqlDbType.NVarChar, 200); Cmd_Params.Value = _cmdInfo.Cmd_Params; SqlParameter Cmd_Url = dbCmd.Parameters.Add("@Cmd_Url", SqlDbType.NVarChar, 200); Cmd_Url.Value = _cmdInfo.Cmd_Url; SqlParameter Cmd_Path = dbCmd.Parameters.Add("@Cmd_Path", SqlDbType.NVarChar, 200); Cmd_Path.Value = _cmdInfo.Cmd_Path; SqlParameter RETURN_VALUE = dbCmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int, 4); RETURN_VALUE.Direction = ParameterDirection.ReturnValue; SqlParameter Cmd_ParentID = dbCmd.Parameters.Add("@Cmd_ParentID", SqlDbType.Int, 4); Cmd_ParentID.Value = _cmdInfo.Cmd_ParentID; SqlParameter Cmd_Enable = dbCmd.Parameters.Add("@Cmd_Enable", SqlDbType.Bit, 1); Cmd_Enable.Value = _cmdInfo.Cmd_Enable; SqlParameter Cmd_Index = dbCmd.Parameters.Add("@Cmd_Index", SqlDbType.Int, 4); Cmd_Index.Value = _cmdInfo.Cmd_Index; SqlParameter Cmd_Visible = dbCmd.Parameters.Add("@Cmd_Visible", SqlDbType.Bit, 1); Cmd_Visible.Value = _cmdInfo.Cmd_Visible; try { dbConn.Open(); dbCmd.ExecuteNonQuery(); } finally { dbConn.Close(); } }
/// <summary> /// 把表中的一行数据转换成对象 /// </summary> /// <param name="dr">表中的一行数据</param> /// <returns></returns> private CmdInfo RowToCmdInfo(DataRow dr)//DataRow表示DataTable中的一行数据 { CmdInfo cmd = new CmdInfo(); cmd.CmdName = dr["CmdName"].ToString(); cmd.Start = dr["Start"].ToString(); cmd.Length = dr["Length"].ToString(); cmd.Adress = dr["Adress"].ToString(); cmd.Model = dr["Model"].ToString(); cmd.Port = dr["Port"].ToString(); cmd.StrPram = dr["StrPram"].ToString(); cmd.End = dr["End"].ToString(); cmd.FlagDelay = dr["FlagDelay"].ToString(); return(cmd); }
private void btnDele_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { gvAction.CloseEditor(); CmdInfo currAction = bsActions.Current as CmdInfo; if (currAction == null) { return; } bsActions.Remove(currAction); bsActions.ResetBindings(false); } catch (Exception ex) { MsgBox.ShowError(ex.Message); } }
public CmdBase GetCmd(string instruction, CmdInfo info, string label) { //generic //addi $s1,$s1,4 //lw $t2,0($s2) //bne $t3,$zero,nimm2 var split = instruction.Split(' '); var regSplit = split[1].Split(','); int rd = Register.Translate(regSplit[0]); int rs = Register.Translate(regSplit[1]); string jumpLabel = regSplit[2]; CmdI cmd = new CmdBranch(info, (byte)rs, (byte)rd, jumpLabel, label); return(cmd); }
/// <summary> /// 根据发送命令,在数据库中查找对应的命令 /// /// </summary> /// <param name="cmdName"></param> /// <returns></returns> public CmdInfo CmdByCmdName_DAL(string cmdName) { string sql = "select * from CAM where CmdName=@cmdName"; DataTable dt = SqliteHelper.ExecuteTable(sql, new SQLiteParameter("@cmdName", cmdName)); CmdInfo cmd = null; if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { cmd = RowToCmdInfo(dr); } } return(cmd); }
public override void Process(DemoParsingInfo infoObj) { infoObj.PrintOptionMessage("dumping player position"); try { int prevTick = int.MinValue; foreach (Packet packet in infoObj.CurrentDemo.FilterForPacket <Packet>()) { if (packet.Tick == prevTick || packet.Tick < 0) { continue; } prevTick = packet.Tick; CmdInfo cmdInfo = packet.PacketInfo[0]; ref Vector3 pos = ref cmdInfo.ViewOrigin; ref Vector3 ang = ref cmdInfo.ViewAngles; Console.WriteLine($"|{packet.Tick}|~|{pos.X},{pos.Y},{pos.Z}|{ang.X},{ang.Y},{ang.Z}|"); }
public CmdLW(CmdInfo cmdInfo, byte rs, byte rt, short im, string pseudoLabel, string lineLabel) : base(cmdInfo, rs, rt, 0, lineLabel) { this.pseudoLabel = pseudoLabel; }
public CmdAddi(CmdInfo cmdInfo, byte rs, byte rt, short im, string lineLabel) : base(cmdInfo, rs, rt, im, lineLabel) { }
public CmdBase(CmdInfo cmdInfo, string lineLabel) { info = cmdInfo; label = lineLabel; }
public CmdSlt(CmdInfo cmdInfo, byte rs, byte rt, byte rd, byte shift, byte funct, string lineLabel) : base(cmdInfo, rs, rt, rd, shift, funct, lineLabel) { }
public CmdJ(CmdInfo info1, string jumpLabel, string lineLabel) : base(info1, lineLabel) { this.jumpLabel = jumpLabel; }
public CmdBranch(CmdInfo cmdInfo, byte rs, byte rt, string branchBLabel, string lineLabel) : base(cmdInfo, rs, rt, 0, lineLabel) { this.bLabel = branchBLabel; }