Ejemplo n.º 1
0
        private void InitializeFields()
        {
            Fields.Clear();
            DisplayFields.Clear();
            var inputFormat   = "";
            var displayFormat = "";
            var button        = new DropDownButton();
            var isWareki      = CalendarFormat == CalendarFormat.JapaneseCalendar;

            switch (InputDateType)
            {
            case DateType.YearMonthDay:
                inputFormat   = isWareki ? "ee/MM/dd" : "yyyy/MM/dd";
                displayFormat = isWareki ? "ggg ee/MM/dd" : "yyyy/MM/dd";
                DropDownCalendar.CalendarType = CalendarType.MonthDay;
                break;

            case DateType.YearMonth:
                inputFormat   = isWareki ? "ee/MM" : "yyyy/MM";
                displayFormat = isWareki ? "ggg ee/MM" : "yyyy/MM";
                DropDownCalendar.CalendarType = CalendarType.YearMonth;
                break;

            case DateType.Year:
                inputFormat   = isWareki ? "ee" : "yyyy";
                displayFormat = isWareki ? "ggg ee" : "yyyy";
                DropDownCalendar.CalendarType = CalendarType.YearMonth;
                button.Visible = ButtonVisibility.NotShown;
                break;

            case DateType.MonthDay:
                inputFormat   = "MM/dd";
                displayFormat = "MM/dd";
                DropDownCalendar.CalendarType = CalendarType.MonthDay;
                break;

            case DateType.YearMonthDayHour:
                inputFormat   = isWareki ? "ee/MM/dd HH時" : "yyyy/MM/dd HH時";
                displayFormat = isWareki ? "ggg ee/MM/dd HH時" : "yyyy/MM/dd HH時";
                DropDownCalendar.CalendarType = CalendarType.MonthDay;
                break;

            case DateType.YearMonthDayHourMinute:
                inputFormat   = isWareki ? "ee/MM/dd HH時mm分" : "yyyy/MM/dd HH時mm分";
                displayFormat = isWareki ? "ggg ee/MM/dd HH時mm分" : "yyyy/MM/dd HH時mm分";
                DropDownCalendar.CalendarType = CalendarType.MonthDay;
                break;

            case DateType.YearMonthDayHourMinuteSecond:
                inputFormat   = isWareki ? "ee/MM/dd HH時mm分ss秒" : "yyyy/MM/dd HH時mm分ss秒";
                displayFormat = isWareki ? "ggg ee/MM/dd HH時mm分ss秒" : "yyyy/MM/dd HH時mm分ss秒";
                DropDownCalendar.CalendarType = CalendarType.MonthDay;
                break;
            }
            Fields.AddRange(inputFormat);
            DisplayFields.AddRange(displayFormat);
            SideButtons.Clear();
            SideButtons.Add(button);
        }
Ejemplo n.º 2
0
 private void FormCentralPatientSearch_Load(object sender, System.EventArgs e)
 {
     DisplayFields.RefreshCache();
     _complConnAmt    = 0;
     _dataConnPats    = new DataSet();
     _invalidConnsLog = "";
     StartThreadsForConns();
 }
 private void FormCentralPatientSearch_Load(object sender, System.EventArgs e)
 {
     DisplayFields.RefreshCache();
     _complConnCount  = 0;
     _dataSetPats     = new DataSet();
     _invalidConnsLog = "";
     //if(IsSelectionMode) {//always selection mode
     gridPats.Title = "Double Click to Select Patient";
     StartThreadsForConns();
 }
        private void GetDataTablePatForConn(ODThread odThread)
        {
            CentralConnection connection = (CentralConnection)odThread.Parameters[0];
            //Filter the threads by their connection name
            string connName = "";

            if (connection.DatabaseName == "")           //uri
            {
                connName = connection.ServiceURI;
            }
            else
            {
                connName = connection.ServerName + ", " + connection.DatabaseName;
            }
            if (!CentralConnectionHelper.SetCentralConnection(connection, false))
            {
                lock (_lockObj) {
                    _invalidConnsLog += "\r\n" + connName;
                    _complConnCount++;
                }
                connection.ConnectionStatus = "OFFLINE";
                BeginInvoke((Action)FillGridPats);
                return;
            }
            List <DisplayField> fields = DisplayFields.GetForCategory(DisplayFieldCategory.CEMTSearchPatients);
            bool      hasNextLastVisit = fields.Any(x => x.InternalName.In("NextVisit", "LastVisit"));
            DataTable table            = new DataTable();

            try {
                PtTableSearchParams ptTableSearchParams = new PtTableSearchParams(checkLimit.Checked, textLName.Text, textFName.Text, textPhone.Text,
                                                                                  textAddress.Text, checkHideInactive.Checked, textCity.Text, textState.Text, textSSN.Text, textPatNum.Text, textChartNumber.Text, 0,
                                                                                  checkGuarantors.Checked, !checkHideArchived.Checked,//checkHideArchived is opposite label for what this function expects, but hideArchived makes more sense
                                                                                  SIn.DateT(textBirthdate.Text), 0, textSubscriberID.Text, textEmail.Text, textCountry.Text, "", "", "", "", hasNextLastVisit: hasNextLastVisit);
                table = Patients.GetPtDataTable(ptTableSearchParams);
            }
            catch (ThreadAbortException tae) {
                throw tae;                //ODThread needs to clean up after an abort exception is thrown.
            }
            catch (Exception) {
                //This can happen if the connection to the server was severed somehow during the execution of the query.
                lock (_lockObj) {
                    _invalidConnsLog += "\r\n" + connName + "  -GetPtDataTable";
                    _complConnCount++;
                }
                BeginInvoke((Action)FillGridPats);                //Pops up a message box if this was the last thread to finish.
                return;
            }
            table.TableName = connName;
            odThread.Tag    = table;
            lock (_lockObj) {
                _complConnCount++;
                _dataSetPats.Tables.Add((DataTable)odThread.Tag);
            }
            BeginInvoke((Action)FillGridPats);
        }
    public override string ToString()
    {
        var  sb      = new StringBuilder("ChatRoomAnnouncementContents(");
        bool __first = true;

        if (__isset.displayFields)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("DisplayFields: ");
            DisplayFields.ToString(sb);
        }
        if (Text != null && __isset.text)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Text: ");
            Text.ToString(sb);
        }
        if (Link != null && __isset.link)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Link: ");
            Link.ToString(sb);
        }
        if (Thumbnail != null && __isset.thumbnail)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Thumbnail: ");
            Thumbnail.ToString(sb);
        }
        sb.Append(")");
        return(sb.ToString());
    }
        private void SetGridCols()
        {
            //This pattern is wrong.
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            fields = DisplayFields.GetForCategory(DisplayFieldCategory.PatientSelect);
            for (int i = 0; i < fields.Count; i++)
            {
                if (fields[i].Description == "")
                {
                    col = new ODGridColumn(fields[i].InternalName, fields[i].ColumnWidth);
                }
                else
                {
                    col = new ODGridColumn(fields[i].Description, fields[i].ColumnWidth);
                }
                gridMain.Columns.Add(col);
            }
            gridMain.EndUpdate();
        }
Ejemplo n.º 7
0
    public override int GetHashCode()
    {
        int hashcode = 157;

        unchecked {
            if (__isset.displayFields)
            {
                hashcode = (hashcode * 397) + DisplayFields.GetHashCode();
            }
            if (__isset.text)
            {
                hashcode = (hashcode * 397) + Text.GetHashCode();
            }
            if (__isset.link)
            {
                hashcode = (hashcode * 397) + Link.GetHashCode();
            }
            if (__isset.thumbnail)
            {
                hashcode = (hashcode * 397) + Thumbnail.GetHashCode();
            }
        }
        return(hashcode);
    }
Ejemplo n.º 8
0
        protected override void RenderContents(HtmlTextWriter output)
        {
            String html = "";

            output.AddAttribute(HtmlTextWriterAttribute.Id, this.ID);
            if (Class != null)
            {
                output.AddAttribute("class", this.Class);
            }

            try
            {
                DataSet ds = null;
                if (SQL != "")
                {
                    string[] kolonlar = Columns.Split(',');
                    string[] fieldlar = DisplayFields.Split(',');
                    string   prov     = Config.provider.ToString();
                    if (prov == "MSSQL")
                    {
                        ds = WebFramework.DataSetFill(SQL, SQLParams.ToArray());
                    }
                    else if (prov == "MYSQL")
                    {
                        ds = MySQLDb.WebFramework.DataSetFill(SQL, SQLParams.ToArray());
                    }
                    else if (prov == "ACCESS")
                    {
                        ds = AccessDb.WebFramework.DataSetFill(SQL, SQLParams.ToArray());
                    }
                    else if (prov == "ORACLE")
                    {
                        ds = OracleDb.WebFramework.DataSetFill(SQL, SQLParams.ToArray());
                    }
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        html += "<thead><tr>";
                        for (int i = 0; i < fieldlar.Length; i++)
                        {
                            html += "<td>" + fieldlar[i].Trim() + "</td>";
                        }
                        String content = "";
                        if (this.Content != null)
                        {
                            Control templateContainer = new Control();
                            Content.InstantiateIn(templateContainer);

                            content = RenderControl(templateContainer);
                        }
                        if (content != "")
                        {
                            html += "<td class='tablecontrol_content'>" + ContentHeaderTitle + "</td>";
                        }
                        html += "</tr></thead>";
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            if (PrimaryKey != "")
                            {
                                html += "<tr data-id='" + ds.Tables[0].Rows[i].Field <Object>(PrimaryKey) + "'>";
                            }
                            else
                            {
                                html += "<tr>";
                            }
                            for (int j = 0; j < kolonlar.Length; j++)
                            {
                                html += "<td>" + ds.Tables[0].Rows[i].Field <Object>(kolonlar[j].Trim()) + "</td>";
                            }
                            if (content != "")
                            {
                                html += "<td>" + content + "</td>";
                            }
                            html += "</tr>";
                        }
                    }
                }
                output.RenderBeginTag("table");
            }
            catch (Exception hata)
            {
                output.RenderBeginTag("div");
                html += "<p style='color:red;'><strong>Hata:</strong> " + hata.Message + "</p>";
            }
            output.Write(html);
            output.RenderEndTag();
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
//            if (!IsPostBack)
            {
                // extract URL parameters
                if (Request.Params["UCE"] != null)
                {
                    UserControlForEditing = Request.Params["UCE"];
                }
                if (Request.Params["BO"] != null)
                {
                    BaseObject = Request.Params["BO"];
                }
                if (Request.Params["SF"] != null)
                {
                    ShowFields = Request.Params["SF"];
                }
                if (Request.Params["DF"] != null)
                {
                    DisplayFields = Request.Params["DF"];
                }
                if (Request.Params["SEL"] != null)
                {
                    SelectionField = Request.Params["SEL"];
                }
                if (Request.Params["ID"] != null)
                {
                    SelectionID = Request.Params["ID"];
                }
                if (Request.Params["ORD"] != null)
                {
                    OrderField = Request.Params["ORD"];
                }
                if (Request.Params["LNK"] != null)
                {
                    LinkField = Request.Params["LNK"];
                }

                // configure the entity data source
                // use the commandtext to specify the query
                string Query = "select " + ShowFields + " from " + BaseObject + " where " + SelectionField + "=@Par order by " + OrderField;
                EntityDataSourceLinks.CommandText = Query;
                EntityDataSourceLinks.CommandParameters.Clear();
                EntityDataSourceLinks.CommandParameters.Add("Par", System.Data.DbType.Guid, SelectionID);

                // now generate the columns
                GridView1.AutoGenerateColumns = false;
                string[] FieldList  = ShowFields.Split(',');
                string[] FieldNames = DisplayFields.Split(',');
                for (int i = 0; i < FieldList.Count(); i++)
                {
                    BoundField bc = new BoundField();

                    bc.DataField  = FieldList[i];
                    bc.HeaderText = FieldList[i];
                    if (FieldNames.Count() > i)
                    {
                        bc.HeaderText = FieldNames[i];
                    }
                    bc.Visible = bc.HeaderText.ToUpper() != "X";

                    // strip of leading this like it.
                    if (bc.DataField.IndexOf('.') > 0)
                    {
                        bc.DataField = bc.DataField.Split('.')[1];
                    }
                    if (bc.HeaderText.IndexOf('.') > 0)
                    {
                        bc.HeaderText = bc.HeaderText.Split('.')[1];
                    }

                    GridView1.Columns.Add(bc);
                }
            }
        }
Ejemplo n.º 10
0
        private void FillGrid()
        {
            Cursor = Cursors.WaitCursor;
            gridMain.BeginUpdate();
            List <DisplayField> fields = DisplayFields.GetForCategory(DisplayFieldCategory.CEMTSearchPatients);

            if (gridMain.Columns.Count == 0)           //Init only once.
            {
                foreach (DisplayField field in fields)
                {
                    string heading = field.InternalName;
                    if (string.IsNullOrEmpty(heading))
                    {
                        heading = field.Description;
                    }
                    gridMain.Columns.Add(new ODGridColumn(heading, field.ColumnWidth));
                }
            }
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < _dataConnPats.Tables.Count; i++)
            {
                for (int j = 0; j < _dataConnPats.Tables[i].Rows.Count; j++)
                {
                    row = new ODGridRow();
                    foreach (DisplayField field in fields)
                    {
                        switch (field.InternalName)
                        {
                            #region Row Cell Filling
                        case "Conn":
                            row.Cells.Add(_dataConnPats.Tables[i].TableName);
                            break;

                        case "PatNum":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["PatNum"].ToString());
                            break;

                        case "LName":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["LName"].ToString());
                            break;

                        case "FName":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["FName"].ToString());
                            break;

                        case "SSN":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["SSN"].ToString());
                            break;

                        case "PatStatus":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["PatStatus"].ToString());
                            break;

                        case "Age":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["age"].ToString());
                            break;

                        case "City":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["City"].ToString());
                            break;

                        case "State":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["State"].ToString());
                            break;

                        case "Address":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["Address"].ToString());
                            break;

                        case "Wk Phone":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["WkPhone"].ToString());
                            break;

                        case "Email":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["Email"].ToString());
                            break;

                        case "ChartNum":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["ChartNumber"].ToString());
                            break;

                        case "MI":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["MiddleI"].ToString());
                            break;

                        case "Pref Name":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["Preferred"].ToString());
                            break;

                        case "Hm Phone":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["HmPhone"].ToString());
                            break;

                        case "Bill Type":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["BillingType"].ToString());
                            break;

                        case "Pri Prov":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["PriProv"].ToString());
                            break;

                        case "Birthdate":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["Birthdate"].ToString());
                            break;

                        case "Site":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["site"].ToString());
                            break;

                        case "Clinic":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["clinic"].ToString());
                            break;

                        case "Wireless Ph":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["WirelessPhone"].ToString());
                            break;

                        case "Sec Prov":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["SecProv"].ToString());
                            break;

                        case "LastVisit":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["lastVisit"].ToString());
                            break;

                        case "NextVisit":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["nextVisit"].ToString());
                            break;
                            #endregion
                        }
                    }
                    row.Tag = ListConns.Find(x => ((x.ServerName + ", " + x.DatabaseName) == _dataConnPats.Tables[i].TableName || x.ServiceURI == _dataConnPats.Tables[i].TableName));
                    gridMain.Rows.Add(row);
                }
            }
            gridMain.EndUpdate();
            Cursor = Cursors.Default;
            if (_complConnAmt == ListConns.Count)
            {
                ODThread.QuitSyncThreadsByGroupName(1, "FetchPats");               //Clean up finished threads.
                butRefresh.Text    = Lans.g(this, "Refresh");
                labelFetch.Visible = false;
                if (!_hasWarningShown && _invalidConnsLog != "")
                {
                    _hasWarningShown = true;                  //Keeps the message box from showing up for subsequent threads.
                    MessageBox.Show(this, Lan.g(this, "Could not connect to the following servers") + ":" + _invalidConnsLog);
                }
            }
            else
            {
                butRefresh.Text    = Lans.g(this, "Stop Refresh");
                labelFetch.Visible = true;
            }
        }
Ejemplo n.º 11
0
        public CapturePacket(Raw raw)
        {
            //RawCapture = raw;
            Date           = raw.TimeStamp;
            _linkLayerType = raw.LinkLayer;

            try
            {
                Packet = Packet.ParsePacket((LinkLayers)raw.LinkLayer, raw.RawData);
            }
            catch (Exception e)
            {
                Error = e.Message;
            }


            if (Packet == null)
            {
                return;
            }

            // protect against corrupted data with a try read
            try
            {
                var throwaway = Packet.Bytes.Length + Packet.HeaderData.Length;
            }
            catch (Exception e)
            {
                _protocolinfo = "Malformed Packet or Header";
                this.Error    = "Malformed Packet or Header";
                return;
            }

            if (Packet.PayloadPacket is IPv4Packet)
            {
                var ipv4 = (IPv4Packet)Packet.PayloadPacket;

                switch (ipv4.Protocol)
                {
                case PacketDotNet.ProtocolType.Tcp:
                    var tcpPacket = (TcpPacket)ipv4.PayloadPacket;
                    Protocol = ProtocolType.TCP;

                    // catch a semi-rare error in PacketDotNet that cannot be checked against
                    try
                    {
                        if (tcpPacket.PayloadData.Length == 0)
                        {
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        Error = e.Message;
                        break;
                    }

                    if ((tcpPacket.DestinationPort == 50039 || tcpPacket.DestinationPort == 50040) &&
                        tcpPacket.PayloadData.Length > 0)
                    {
                        Protocol = ProtocolType.JRU;


                        try
                        {
                            var ss27 = ExtractSS27Packet(tcpPacket);

                            DisplayFields.Add(new Tuple <string, object>("time", ss27.DateTime));
                            if (ss27.Events.Count == 0)
                            {
                                // if there is no event, chuck some other data in there, maybe
                                // ParsedData = new ParsedDataSet() { ParsedFields = new List<ParsedField>(ss27.Header) };
                            }
                            else
                            {
                                // TODO FIX THIS SO IT WORKS
                                ss27.Events.ForEach(e => DisplayFields.Add(new Tuple <string, object>(e.EventType.ToString(), e.Description)));
                            }

                            this.SS27Packet = ss27;
                        }
                        catch (Exception e)
                        {
                            Error = e.Message;
                        }
                    }

                    if (tcpPacket.SourcePort == 50041 && tcpPacket.PayloadData.Length > 0)
                    {
                        Protocol = ProtocolType.JRU;
                        var jruload = tcpPacket.PayloadData;
                        try
                        {
                            ushort jrulen = BitConverter.ToUInt16(new byte[] { jruload[1], jruload[0] }, 0);
                            var    buffer = new byte[jrulen];
                            Array.Copy(jruload, 2, buffer, 0, jrulen);
                            ParsedData = VSIS210.JRU_STATUS.Parse(buffer);
                        }
                        catch (Exception e)
                        {
                            Error = e.Message;
                        }
                    }

                    break;

                case PacketDotNet.ProtocolType.Udp:

                    Protocol = ProtocolType.UDP;
                    var udp = (UdpPacket)ipv4.PayloadPacket;

                    if (udp == null)
                    {
                        _protocolinfo = "Malformed UDP";
                        this.Error    = "Malformed UDP";
                        return;
                    }

                    // protect against corrupted data with a try read
                    try
                    {
                        var throwaway = udp.DestinationPort + udp.SourcePort + udp.Length + udp.Checksum;
                    }
                    catch (Exception e)
                    {
                        _protocolinfo = "Malformed UDP";
                        this.Error    = "Malformed UDP";
                        return;
                    }


                    if (udp.SourcePort == 123 && udp.DestinationPort == 123)
                    {
                        Protocol = ProtocolType.NTP;
                    }
                    else if (Equals(ipv4.SourceAddress, VapAddress))
                    {
                        if (udp.DestinationPort == 50023)
                        {
                            _protocolinfo = "VAP->ETC (TR)";
                        }
                        else if (udp.DestinationPort == 50030)
                        {
                            _protocolinfo = "VAP->ETC (DMI1 to ETC)";
                        }
                        else if (udp.DestinationPort == 50031)
                        {
                            _protocolinfo = "VAP->ETC (DMI2 to ETC)";
                        }
                        else if (udp.DestinationPort == 50032)
                        {
                            _protocolinfo = "VAP->ETC (DMI1 to iSTM)";
                        }
                        else if (udp.DestinationPort == 50033)
                        {
                            _protocolinfo = "VAP->ETC (DMI2 to iSTM)";
                        }
                        else if (udp.DestinationPort == 50051)
                        {
                            _protocolinfo = "VAP->ETC (DMI1 to gSTM)";
                        }
                        else if (udp.DestinationPort == 50052)
                        {
                            _protocolinfo = "VAP->ETC (DMI2 to gSTM)";
                        }
                        else if (udp.DestinationPort == 50024)
                        {
                            _protocolinfo = "VAP->ETC (DMI1 EVC-102)";
                        }
                        else if (udp.DestinationPort == 50025)
                        {
                            _protocolinfo = "VAP->ETC (DMI2 EVC-102)";
                        }
                        else if (udp.DestinationPort == 50039)
                        {
                            _protocolinfo = "VAP->ETC (STM to JRU)";
                        }
                        else if (udp.DestinationPort == 50041)
                        {
                            _protocolinfo = "VAP->ETC (JRU Status)";
                        }
                        else if (udp.DestinationPort == 50050)
                        {
                            _protocolinfo = "VAP->ETC (VAP Status)";
                        }
                        else if (udp.DestinationPort == 50015)
                        {
                            Protocol      = ProtocolType.UDP_SPL;
                            _protocolinfo = "VAP->OPC (DMI to STM)";
                        }
                        else if (udp.DestinationPort == 5514)
                        {
                            _protocolinfo = "VAP->BDS (VAP Diag)";
                        }
                    }
                    else if (Equals(ipv4.DestinationAddress, VapAddress))
                    {
                        if (udp.DestinationPort == 50022)
                        {
                            _protocolinfo = "ETC->VAP (OBU)";
                        }
                        else if (udp.DestinationPort == 50026)
                        {
                            _protocolinfo = "ETC->VAP (ETC to DMI1)";
                        }
                        else if (udp.DestinationPort == 50027)
                        {
                            _protocolinfo = "ETC->VAP (ETC to DMI2)";
                        }
                        else if (udp.DestinationPort == 50037)
                        {
                            _protocolinfo = "ETC->VAP (EVC-1&7)";
                        }
                        else if (udp.DestinationPort == 50035)
                        {
                            _protocolinfo = "ETC->VAP (EVC-1&7)";
                        }
                        else if (udp.DestinationPort == 50028)
                        {
                            _protocolinfo = "ETC->VAP (iSTM to DMI1)";
                        }
                        else if (udp.DestinationPort == 50029)
                        {
                            _protocolinfo = "ETC->VAP (iSTM to DMI2)";
                        }
                        else if (udp.DestinationPort == 50055)
                        {
                            _protocolinfo = "ETC->VAP (gSTM to DMI1)";
                        }
                        else if (udp.DestinationPort == 50056)
                        {
                            _protocolinfo = "ETC->VAP (gSTM to DMI2)";
                        }
                        else if (udp.DestinationPort == 50034)
                        {
                            _protocolinfo = "ETC->VAP (to JRU)";
                        }
                        else if (udp.DestinationPort == 50057)
                        {
                            _protocolinfo = "ETC->VAP (VAP Config)";
                        }
                        else if (udp.DestinationPort == 50014)
                        {
                            Protocol      = ProtocolType.UDP_SPL;
                            _protocolinfo = "OPC->VAP";

                            var payload = udp.PayloadData;
                            var spl     = VAP.UDP_SPL.Parse(payload);
                            this.DisplayFields =
                                spl.ParsedFields.Select(f => new Tuple <string, object>(f.Name, f.Value)).ToList();

                            if (spl.ParsedFields.Last().Value.Equals("C9"))
                            {
                                var nextBytes = Functions.SubArrayGetter(payload, 81);
                                var stm       = VAP.STM_Packet.Parse(nextBytes);
                                DisplayFields.AddRange(stm.ParsedFields.Select(f => new Tuple <string, object>(f.Name, f.Value)).ToList());
                            }
                        }
                        else if (udp.DestinationPort == 50036)
                        {
                            _protocolinfo = "BDS->VAP (Diag)";
                        }
                        else if (udp.DestinationPort == 50070)
                        {
                            _protocolinfo = "ETC->VAP (ATO)";
                        }
                        else if (udp.DestinationPort == 50068)
                        {
                            _protocolinfo = "ETC->VAP (ATO)";
                        }
                        else if (udp.DestinationPort == 50072)
                        {
                            _protocolinfo = "ETC->VAP (ATO)";
                        }
                    }


                    try
                    {
                        IPTWPPacket = IPTWPPacket.Extract(udp);
                    }
                    catch (Exception e)
                    {
                        Error = e.Message;
                    }

                    if (IPTWPPacket != null)
                    {
                        Protocol = ProtocolType.IPTWP;
                    }
                    break;

                case PacketDotNet.ProtocolType.Icmp:
                    Protocol = ProtocolType.ICMP;
                    // dunno
                    break;

                case PacketDotNet.ProtocolType.Igmp:
                    Protocol = ProtocolType.IGMP;
                    // dunno
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else if (Packet.PayloadPacket is ArpPacket arpPacket)
            {
                Protocol = ProtocolType.ARP;
            }
            else if (Packet.PayloadPacket is IPv6Packet)
            {
                Protocol = ProtocolType.IPv6;
                // ignore, for now
            }
            else if (raw.LinkLayer == LinkLayerType.Ethernet && Packet.HeaderData[12] == 0x88 &&
                     Packet.HeaderData[13] == 0xe1)
            {
                Protocol = ProtocolType.HomeplugAV;
                // ignore
            }
            else if (raw.LinkLayer == LinkLayerType.Ethernet && Packet.HeaderData[12] == 0x89 &&
                     Packet.HeaderData[13] == 0x12)
            {
                Protocol = ProtocolType.Mediaxtream;
                // ignore
            }
            else if (raw.LinkLayer == LinkLayerType.Ethernet && Packet.HeaderData[12] == 0x88 &&
                     Packet.HeaderData[13] == 0xcc)
            {
                Protocol = ProtocolType.LLDP;
                // ignore
            }
            else
            {
                Protocol = ProtocolType.UNKNOWN;
#if DEBUG
                // if we are in debug, we might want to know what is in the unknown
                //                throw new NotImplementedException("Surprise data! " + BitConverter.ToString(packet.Bytes));
#endif
            }

            var extractParsedData = ExtractParsedData(this, out var displayfields);
            this.DisplayFields.AddRange(displayfields);
            this.ParsedData = extractParsedData;
        }