Example #1
0
        /// <summary>
        /// 保存心电数据
        /// </summary>
        private void SaveEcgData()
        {
            _dCount++;
            var pm = new PermissionModel();

            for (int i = 1; i < pace_makingOptions.Pacing_signal_list.Count - 2; i++)
            {
                if (pace_makingOptions.Pacing_signal_list[i] == 1 && pace_makingOptions.Pacing_signal_list[i - 1] != 1)
                {
                    _paceCount++;
                }

                if (pace_makingOptions.Pacing_signal_list[i] == 1)
                {
                    _totPaceCount++;
                }
            }
            if (_paceCount > 0 && _totPaceCount > 0)
            {
                _isQiBo = "1";
            }
            _paceCount    = 0;
            _totPaceCount = 0;
            try
            {
                _ecgDataDicAfterFilter = serialPortOption.CreateInstance().EcgData_Dic_AfterFilter;
            }
            catch
            {
                _ecgDataDicAfterFilter = serialPortOption.CreateInstance().EcgData_Dic;
            }
            int ecgCount = (_ecgDataDicAfterFilter.Count > 0 ? _ecgDataDicAfterFilter[0].Count : 0);

            try
            {
                for (int leadIndex = 0; leadIndex < 12; leadIndex++)
                {
                    var leadEcgData = new List <float>();
                    for (int i = 0; i < ecgCount; i++)
                    {
                        if (serialPortOption.CreateInstance().EcgData_Dic_AfterFilter.Count > 0 && i < _ecgDataDicAfterFilter[leadIndex].Count)
                        {
                            leadEcgData.Add(_ecgDataDicAfterFilter[leadIndex][i]);
                        }
                    }
                    pm.Add(leadIndex, leadEcgData);
                }
            }
            catch (Exception ex)
            {
            }
            byte[] hospitalTel = pm.Compress(pm.Dict); string ednPathDir = Application.StartupPath + "\\ECG_DATA_NEW";
            if (!Directory.Exists(ednPathDir))
            {
                Directory.CreateDirectory(ednPathDir);
            }
            try
            {
                var fs = new FileStream(ednPathDir + "\\" + ConfigHelper.AppId + "_0", FileMode.CreateNew, FileAccess.Write);
                var bw = new BinaryWriter(fs, Encoding.UTF8);
                bw.Write(hospitalTel);
                bw.Close();
                //fs.Close();
            }
            catch (Exception ex)
            {
            }
            _filter = "低通:75Hz";

            var pLocs = new StringBuilder();

            for (int k = 0; k < serialPortOption.CreateInstance().PaceLocs.Count; k++)
            {
                serialPortOption.CreateInstance().PaceLocs[k] = serialPortOption.CreateInstance().PaceLocs[k] + serialPortOption.CreateInstance().PaceOffset;
                if (serialPortOption.CreateInstance().PaceLocs[k] < 2500)
                {
                    serialPortOption.CreateInstance().PaceLocs.RemoveAt(k);
                }
                else
                {
                    pLocs.Append(serialPortOption.CreateInstance().PaceLocs[k] - 2500).Append(",");
                }
            }
            string strdel       = "delete from data_packs where ApplicationID='" + ConfigHelper.AppId + "'";
            string strsql       = "insert into data_packs (ApplicationID,beginTime,dataSizePerLead,EcgFilter,isLead,LeadEndTime,paceLocs) values ('" + ConfigHelper.AppId + "','" + _beginCollectTime + "','" + Dataperlead + "','" + _filter + "','0','" + _endCollectTime + "','" + pLocs.ToString().TrimEnd(',') + "') ";
            string strsqlUpdate = "update tb_patientinfo set IsQiBo='" + _isQiBo + "' where PatientID='" + _patientId + "'";

            //执行SQL语句,将数据插入表中
            try
            {
                if (hospitalTel.Length > 0)
                {
                    _sqlite.SqliteDelete(strdel);
                    _sqlite.SqliteAdd(strsql);
                    _sqlite.SqliteUpdate(strsqlUpdate);
                }
                serialPortOption.CreateInstance().PaceLocs.Clear();
            }
            catch (Exception ex)
            {
            }
        }