public void ProtocolEventListBox_SelectedIndexChanged(int selectedIndex)
 {
     if (selectedIndex > -1 && selectedIndex < this.protocolEvents.Count)
     {
         this.SelectedProtocolEvent = this.protocolEvents[selectedIndex] as ProtocolEvent;
     }
 }
 public ProtocolEventEditController(IProtocolEventEditView view)
 {
     this.view = view;
     this.view.SetController(this);
     this.ProtocolEvent = new ProtocolEvent();
     this.auditItems    = new List <AuditItem>();
 }
Beispiel #3
0
        public static void UpdateItem(ProtocolEvent protocolEvent, string userName)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(CONNECTION_STRING))
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand("pe_update_event", connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add("@EventID", SqlDbType.Int).Value               = protocolEvent.ID;
                        command.Parameters.Add("@EventType", SqlDbType.NVarChar).Value        = protocolEvent.Type;
                        command.Parameters.Add("@EventDescription", SqlDbType.NVarChar).Value =
                            protocolEvent.Description;
                        command.Parameters.Add("@IsActive", SqlDbType.Bit).Value       = protocolEvent.IsActive;
                        command.Parameters.Add("@UpdatedBy", SqlDbType.NVarChar).Value = userName;

                        int result = command.ExecuteNonQuery();
                    }
                }
            }
            catch (SqlException ex)
            {
                ErrorHandler.CreateLogFile(ErrorFormName, "UpdateProtocolEvent", ex);
            }
        }
Beispiel #4
0
 //取消侦听
 public void UnListen(uint protocolId, ProtocolEvent call)
 {
     if (listeners.ContainsKey(protocolId))
     {
         listeners[protocolId] -= call;
     }
 }
        private void AddPacketHandler(string PacketName, ProtocolEvent handler)
        {
            PacketParser pp = Factory.CreatePacketHandler(PacketName);

            PacketParsers.Add(pp.type, pp);
            PacketHandlers.Add(pp.type, handler);
        }
        public void parsePacket(NetworkMessage nmsg)
        {
            int packetType = nmsg.ReadByte();

            if (PacketParsers.ContainsKey(packetType))
            {
                PacketParser  pp      = PacketParsers[packetType];
                Packet        p       = pp.parser(nmsg);
                ProtocolEvent handler = PacketHandlers[packetType];
                if (handler != null && p != null)
                {
                    handler.Invoke(p);
                }

                /*
                 * string m = "Parsing packet 0x" + packetType.ToString("X2") + " '" + ph.name + "'";
                 * if (p != null)
                 *  m += "<pre>" + p.ToString() + "</pre>";
                 * Log.Debug(m);
                 */
                if (!nmsg.ReadAllData())
                {
                    parsePacket(nmsg);
                }
            }
            else
            {
                Log.Warning("Unknown packet type parsed 0x" + packetType.ToString("X2"), this);
            }
        }
Beispiel #7
0
        public static IList SelectItemsByType(string eventType)
        {
            IList results = new ArrayList();

            try
            {
                using (SqlConnection connection = new SqlConnection(CONNECTION_STRING))
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand("pe_select_events_by_type", connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add("@EventType", SqlDbType.NVarChar).Value = eventType;
                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            ProtocolEvent protocolEvent = CreateNewProtocolEvent(reader);
                            results.Add(protocolEvent);
                        }
                    }
                }
            }
            catch (SqlException ex)
            {
                ErrorHandler.CreateLogFile(ErrorFormName, "SelectProtocolEventsByType", ex);
            }
            return(results);
        }
Beispiel #8
0
 public override void ListViewSelectedIndexChanged(int selectedIndex)
 {
     if (selectedIndex > -1 && selectedIndex < this.items.Count)
     {
         this.selectedItem = (ProtocolEvent)this.items[selectedIndex];
     }
 }
Beispiel #9
0
 public ProtocolEventsController(IUCToolStripListView1 view)
 {
     this.view = view;
     this.view.SetController(this);
     this.items   = new ArrayList();
     selectedItem = null;
     loginInfo    = LoginInfo.GetInstance();
 }
Beispiel #10
0
        private void AddProtocolEventToListView(ProtocolEvent protocolEvent)
        {
            ListViewItem item = this.MainListView.Items.Add(protocolEvent.ID.ToString());

            item.SubItems.Add(protocolEvent.Type);
            item.SubItems.Add(protocolEvent.Description);
            item.SubItems.Add(protocolEvent.IsActive.ToString());
        }
 public ProtocolEventAddController(IProtocolEventAddView view)
 {
     this.view = view;
     this.view.SetController(this);
     this.protocolEvents        = new ArrayList();
     this.protocolEventTypes    = new ArrayList(QProtocolEvents.SelectTypes());
     this.SelectedProtocolEvent = null;
 }
Beispiel #12
0
        private DialogResult ShowPopup(ProtocolEvent item)
        {
            ProtocolEventEditView       popup           = new ProtocolEventEditView();
            ProtocolEventEditController popupController = new ProtocolEventEditController(popup, item);
            DialogResult dialogResult = popup.ShowDialog(view.ParentControl);

            popup.Dispose();
            return(dialogResult);
        }
Beispiel #13
0
        public static ProtocolEvent CreateNewProtocolEvent(SqlDataReader reader)
        {
            ProtocolEvent protocolEvent = new ProtocolEvent();

            protocolEvent.ID          = Convert.ToInt32(reader[0].ToString());
            protocolEvent.Type        = reader[1].ToString();
            protocolEvent.Description = reader[2].ToString();
            protocolEvent.IsActive    = Convert.ToBoolean(reader[3].ToString());
            return(protocolEvent);
        }
Beispiel #14
0
        public override void NewButtonClicked()
        {
            ProtocolEvent item         = new ProtocolEvent();
            DialogResult  dialogResult = ShowPopup(item);

            if (dialogResult == DialogResult.OK)
            {
                DoInsert(item);
            }
        }
Beispiel #15
0
    //侦听
    public void Listen(uint protocolId, ProtocolEvent call)
    {
        if (!listeners.ContainsKey(protocolId))
        {
            listeners.Add(protocolId, delegate(MemoryStream body) { });
        }


        listeners[protocolId] += call;
    }
        private void AddEventToSelectedTitle()
        {
            ProtocolEvent popupResult = ShowProtocolEventAddView();

            if (popupResult.Description != "")
            {
                IList protocolActivities = CreateProtocolActivityList(popupResult.ID);
                QProtocolActivities.InsertItems(protocolActivities);
                RefreshTemplateListView();
            }
        }
 public ProtocolEventEditController(IProtocolEventEditView view, ProtocolEvent protocolEvent)
 {
     this.view = view;
     this.view.SetController(this);
     this.view.EventType        = protocolEvent.Type;
     this.view.EventDescription = protocolEvent.Description;
     this.view.IsActive         = protocolEvent.IsActive;
     this.view.SetIsActiveRadioButtonGroup_Enable(true);
     this.ProtocolEvent = protocolEvent;
     this.auditItems    = new List <AuditItem>();
 }
        // The biggest ugliest mess in the universe!
        public static List <CategoryNode> BuildTrees(List <ProtocolEvent> eventList)
        {
            if (eventList == null)
            {
                return(null);
            }
            Dictionary <string, CategoryNode> nodeDictionary = new Dictionary <string, CategoryNode>();
            List <CategoryNode>   rootNodes  = new List <CategoryNode>();
            Queue <ProtocolEvent> eventQueue = new Queue <ProtocolEvent>(eventList);

            if (eventList != null)
            {
                while (eventQueue.Count != 0)
                {
                    ProtocolEvent plotEvent = eventQueue.Dequeue();
                    if (plotEvent.HasCategory())
                    {
                        CategoryNode targetNode;
                        if (plotEvent.HasParent())
                        {
                            if (nodeDictionary.ContainsKey(plotEvent.ParentLabel))
                            {
                                if (!nodeDictionary.TryGetValue(plotEvent.FullLabel(), out targetNode))
                                {
                                    targetNode = new CategoryNode(plotEvent.CategoryLabel, nodeDictionary[plotEvent.ParentLabel]);
                                    nodeDictionary.Add(plotEvent.FullLabel(), targetNode);
                                }
                            }
                            else
                            {
                                eventQueue.Enqueue(plotEvent);
                                continue;
                            }
                        }
                        else
                        {
                            if (!nodeDictionary.TryGetValue(plotEvent.FullLabel(), out targetNode))
                            {
                                targetNode = new CategoryNode(plotEvent.CategoryLabel);
                                nodeDictionary.Add(plotEvent.FullLabel(), targetNode);
                                rootNodes.Add(targetNode);
                            }
                        }
                        targetNode.Series.Items.Add(new IntervalBarItem
                        {
                            Start = new DateTime(Convert.ToInt64(plotEvent.Arguments["TimeStartMs"]) * 10000).ToOADate(),
                            End   = new DateTime(Convert.ToInt64(plotEvent.Arguments["TimeEndMs"]) * 10000).ToOADate()
                        });
                    }
                }
            }
            return(rootNodes);
        }
Beispiel #19
0
 //绑定注册
 public static void BindEventHandler(DispatcherEventHandler handle, EProtocolId id)
 {
     try
     {
         ProtocolEvent Event = new ProtocolEvent();
         Event.EventHandler += new DispatcherEventHandler(handle);
         DictProtocolEvent.Add(id, Event);
         Debug(string.Format("注册消息->  {0,-30} -> {1,-10} 成功", id, (int)id));
     }
     catch
     {
         Error(string.Format("注册消息->  {0,-30} -> {1,-10} 失败", id, (int)id));
     }
 }
        private ProtocolEvent ShowProtocolEventAddView()
        {
            ProtocolEvent              result          = new ProtocolEvent();
            ProtocolEventAddView       popup           = new ProtocolEventAddView();
            ProtocolEventAddController popupController = new ProtocolEventAddController(popup);

            popupController.LoadView();
            DialogResult dialogResult = popup.ShowDialog(this.view.ParentControl);

            if (dialogResult == DialogResult.OK)
            {
                result = popupController.SelectedProtocolEvent;
            }
            return(result);
        }
Beispiel #21
0
        public async Task <Guid> WriteAsync(IDictionary <string, object> fields, string description = null)
        {
            var e = new ProtocolEvent
            {
                Id          = Guid.NewGuid(),
                Created     = DateTime.Now,
                Fields      = fields,
                Description = description,
                IsRemoved   = false
            };

            await _protocols.InsertOneAsync(e);

            return(e.Id);
        }
Beispiel #22
0
 private void DoInsert(ProtocolEvent item)
 {
     QProtocolEvents.InsertItem(item, loginInfo.UserName);
     MessageBox.Show("New event is added.");
     LoadView();
 }
Beispiel #23
0
 public void RemoveListener(ProtocolEvent type, EventListenerDelegate listener)
 {
     RemoveListener((int)type, listener);
 }
 private void AddPacketHandler(string PacketName, ProtocolEvent handler)
 {
     PacketParser pp = Factory.CreatePacketHandler(PacketName);
     PacketParsers.Add(pp.type, pp);
     PacketHandlers.Add(pp.type, handler);
 }
Beispiel #25
0
 public void AddProtocolEventToView(ProtocolEvent protocolEvent)
 {
     this.ProtocolEventsListBox.Items.Add(protocolEvent.Description);
 }
Beispiel #26
0
 public void AddListener(ProtocolEvent type, EventListenerDelegate listener)
 {
     AddListener((int)type, listener);
 }
Beispiel #27
0
 public void SendMessage(ProtocolEvent type, params System.Object[] param)
 {
     SendMessage((int)type, param);
 }
Beispiel #28
0
 private void DoUpdate(ProtocolEvent item)
 {
     QProtocolEvents.UpdateItem(item, loginInfo.UserName);
     MessageBox.Show("Updated!");
     LoadView();
 }
Beispiel #29
0
 protected void TriggerEvent()
 {
     ProtocolEvent?.Invoke(this, EventArgs.Empty);
 }
Beispiel #30
0
 internal void FireProtocolEvent(GenericParsedEventArgs args) => ProtocolEvent?.Invoke(this, args);