Ejemplo n.º 1
0
        public string GetSingleChannelData(string json)
        {
            ResultInfo resultInfo = new ResultInfo();

            try
            {
                Request request    = JsonConvert.DeserializeObject <Request>(json);
                string  FilePath   = request.filepath;
                int     channelNum = request.channelnum;
                if (request.startpos != 0 && request.endpos != 0)
                {
                    var    data   = citHelper.GetSingleChannelData(FilePath, channelNum, request.startpos, request.endpos);
                    string result = JsonConvert.SerializeObject(data);
                    resultInfo.flag = 1;
                    resultInfo.msg  = "";
                    resultInfo.data = result;
                }
                else if (!String.IsNullOrWhiteSpace(request.channelname))
                {
                    var    data   = citHelper.GetSingleChannelData(FilePath, request.channelname, request.startmile, request.endmile);
                    string result = JsonConvert.SerializeObject(data);
                    resultInfo.flag = 1;
                    resultInfo.msg  = "";
                    resultInfo.data = result;
                }
                else
                {
                    var    data   = citHelper.GetSingleChannelData(FilePath, channelNum);
                    string result = JsonConvert.SerializeObject(data);
                    resultInfo.flag = 1;
                    resultInfo.msg  = "";
                    resultInfo.data = result;
                }
            }
            catch (Exception ex)
            {
                resultInfo.flag = 0;
                resultInfo.msg  = ex.Message;
            }

            return(JsonConvert.SerializeObject(resultInfo));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 导出通道数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Export_Click(object sender, EventArgs e)
        {
            try
            {
                this.btn_Export.Enabled = false;

                GetChannelNames();
                if (channelNameList.Count == 0)
                {
                    MessageBox.Show("请选择至少一个通道");
                    return;
                }

                dataList.Clear();

                for (int i = 0; i < channelNameList.Count; i++)
                {
                    CitFileHelper citHelper = new CitFileHelper();

                    if (channelNameList[i].sNameEn == "sample")
                    {
                        double[] d = citHelper.GetSingleChannelDataNoConvert(filePathStr, 2);
                        dataList.Add(d);
                    }
                    else
                    {
                        double[] d = citHelper.GetSingleChannelData(filePathStr, citHelper.GetChannelId(channelNameList[i].sNameEn, filePathStr));
                        dataList.Add(d);
                    }
                }

                //使用中文名称
                if (ckb_Chinese.Checked)
                {
                    ExportDataTxt(true);
                }
                else
                {
                    ExportDataTxt(false);
                }

                MessageBox.Show("数据导出完成");

                this.btn_Export.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }