public IEnumerable <ProtocolRow> GetProtocolData(string storageName, int startRow, int maxRows, string filter, DateTime?FromDate, DateTime?ToDate)
        {
            var datasetConfig = ProtokollerConfiguration.ActualConfigInstance.Datasets.FirstOrDefault(s => s.Name == storageName);

            IDBInterface dbInterface = StorageHelper.GetStorage(datasetConfig, null);

            dbInterface.Connect_To_Database(datasetConfig.Storage);
            IDBViewable        dbViewable = dbInterface as IDBViewable;
            List <ProtocolRow> list       = new List <ProtocolRow>();
            DataTable          table      = dbViewable.ReadData(datasetConfig, filter, startRow, maxRows, FromDate, ToDate);

            foreach (DataRow row in table.Rows)
            {
                ProtocolRow storageLine = new ProtocolRow();
                var         date        = row["datetime"];
                if (date is DateTime)
                {
                    storageLine.Timestamp = (DateTime)date;
                }
                else
                {
                    storageLine.Timestamp = DateTime.ParseExact(row["datetime"].ToString(), "yyyy.MM.dd - HH:mm:ss.fff", null);
                }

                storageLine.Telegram = Convert.ToString(row["data"]);
                list.Add(storageLine);
            }

            return(list);
        }
示例#2
0
            /// <summary>
            /// Creates new protocol row in protocol data table
            /// </summary>
            /// <param name="channelID">Chanel identifier</param>
            /// <param name="pPrefix">prefix for the name</param>
            /// <returns>New <see cref="ProtocolRow"/></returns>
            /// <remarks>
            /// Default values:
            /// - ProtocolType = 0;
            /// - Name = "Protocol ID"
            /// </remarks>
            public ProtocolRow NewProtocolRow(long channelID, string pPrefix)
            {
                ProtocolRow protocolRow = NewProtocolRow();

                protocolRow.ChannelID = channelID;
                protocolRow.Name      = string.Format("{1}{2}Protocol{0}", protocolRow.ProtocolID.ToString(), pPrefix, m_IdentSep);
                return(protocolRow);
            }
        public void RecordProtocolUsageTime(int protocolId)
        {
            ProtocolRow protocolRow = theDataStore.Protocol.FindByProtocolId(protocolId);

            if (protocolRow != null)
            {
                protocolRow.ProtocolUsageTime  = DateTime.Now;
                protocolRow.ProtocolUsageCount = protocolRow.ProtocolUsageCount + 1;
            }
        }
        public int GetProtocolQuadrantCount(int protocolId)
        {
            ProtocolRow pRow   = theDataStore.Protocol.FindByProtocolId(protocolId);
            int         QCount = 0;

            if (pRow != null)
            {
                QCount = pRow.ProtocolQuadrantCount;
            }
            return(QCount);
        }
        public void RetrieveMRU_Statistics()
        {
            // To do this, retrieve persisted data (if any) and update the MRU field
            // of any protocol for which we have a matching protocol ID.
            using (SeparatorDataStore persistedDataStore = new SeparatorDataStore())
            {
                try
                {
                    string protocolsPath        = GetProtocolsPath();
                    string protocolsXmlFileName = protocolsPath + @"\" + theProtocolsInfoBaseFilename + theProtocolsInfoFilenameExtenstion;
                    if (File.Exists(protocolsXmlFileName))
                    {
                        persistedDataStore.EnforceConstraints = false;
                        persistedDataStore.ReadXml(protocolsXmlFileName);
                        foreach (ProtocolRow persistRow in persistedDataStore.Protocol)
                        {
                            //  03/14/06 MRU fix
                            // Create a filter string to lookup protocols based on the Protocol Instrument
                            // Control ID (a unique hash code based on the protocol name).
                            string filter = string.Format("ProtocolInstrumentControlId={0}",
                                                          persistRow.ProtocolInstrumentControlId);

                            // Search for a match between the persisted list of protocols and the
                            // current list of protocols returned from the instrument control layer.
                            // We need to do this lookup in case someone has added or deleted protocol
                            // files from the protocol directory since last running the application.
                            ProtocolRow[] pRows = (ProtocolRow[])theDataStore.Protocol.Select(filter);
                            if (pRows.GetLength(0) == 1)
                            {
                                ProtocolRow pRow = pRows[0];
                                if (pRow != null)
                                {
                                    pRow.ProtocolUsageCount = persistRow.ProtocolUsageCount;
                                    pRow.ProtocolUsageTime  = persistRow.ProtocolUsageTime;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
            }
        }
示例#6
0
            /// <summary>
            /// Creates new protocol row in protocol data table
            /// </summary>
            /// <param name="channelID">Channel ID</param>
            /// <param name="pRowToBeCopied">ow to be copied</param>
            /// <param name="pShallowCopy">indicates if the copy is shallow or deep</param>
            /// <param name="pPrefix">prefix for the name</param>
            public void NewProtocolRow(long channelID, ProtocolRow pRowToBeCopied, bool pShallowCopy, string pPrefix)
            {
                ProtocolRow pr = NewProtocolRow(channelID, pPrefix);

                pr.ChannelID = channelID;
                if (!pRowToBeCopied.IsDPIdentifierNull())
                {
                    pr.DPIdentifier = pRowToBeCopied.DPIdentifier;
                }
                if (!pRowToBeCopied.IsDPConfigNull())
                {
                    pr.DPConfig = pRowToBeCopied.DPConfig;
                }
                AddProtocolRow(pr);
                if (!pShallowCopy)
                {
                    foreach (SegmentsRow sr in pRowToBeCopied.GetSegmentsRows())
                    {
                        ((ComunicationNet)DataSet).Segments.NewSegmentsRow(pr.ProtocolID, sr, pr.Name);
                    }
                }
                return;
            }
        public int GetInstrumentControlProtocolId(int protocolId)
        {
            System.Diagnostics.Debug.WriteLine(String.Format("--------- GetInstrumentControlProtocolId called. protocolId = {0} ----------", protocolId));
            int ProtoColID = 0;

            try
            {
                if ((theDataStore != null) && (theDataStore.Protocol != null))
                {
                    ProtocolRow pRow = theDataStore.Protocol.FindByProtocolId(protocolId);
                    if (pRow != null)
                    {
                        ProtoColID = pRow.ProtocolInstrumentControlId;
                        System.Diagnostics.Debug.WriteLine(String.Format("--------- theDataStore.Protocol.FindByProtocolId returns instrument control protocol Id = {0} ----------", ProtoColID));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(0);
            }
            return(ProtoColID);
        }