Exemplo n.º 1
0
        public string Export(string json)
        {
            Response resultInfo = new Response();

            try
            {
                CITRequest request = JsonConvert.DeserializeObject <CITRequest>(json);

                CitProcess.Process process = new CitProcess.Process();


                if (!String.IsNullOrEmpty(request.idfFile) && !String.IsNullOrEmpty(request.dbFile))
                {
                    if (request.channelNames != null && request.channelNames.Length > 0)
                    {
                        process.SaveChannelDataTxt(request.path, request.idfFile, request.dbFile, request.channelNames, request.exportTxtPath, request.startMile, request.endMile, request.sampleCount, request.isChinese);
                    }
                    else
                    {
                        throw new Exception("channleNames 通道数组为空");
                    }
                }
                else
                {
                    if (request.channelNames != null && request.channelNames.Length > 0)
                    {
                        process.SaveChannelDataTxt(request.path, request.channelNames, request.exportTxtPath, request.startMile, request.endMile, request.sampleCount, request.isChinese);
                    }
                    else
                    {
                        throw new Exception("channleNames 通道数组为空");
                    }
                }


                resultInfo.flag = 1;
                resultInfo.msg  = "Success";
                resultInfo.data = request.exportTxtPath;
            }
            catch (Exception ex)
            {
                resultInfo.flag = 0;
                resultInfo.msg  = ex.Message;
            }

            return(JsonConvert.SerializeObject(resultInfo));
        }
Exemplo n.º 2
0
        private void btnCitToTxt2_Click(object sender, EventArgs e)
        {
            CITRequest request = new CITRequest();

            request.channelNames  = new string[] { "M", "AB_Vt_L_11" };
            request.sampleCount   = 100000;
            request.exportTxtPath = @"F:\个人文件\铁路\testCit\1111.txt";
            request.path          = @"F:\个人文件\铁路\testCit\CitData_160424063432_CNGX.cit";

            request.path          = @"H:\工作文件汇总\铁科院\程序\车载加速度\数据文件\CitData_160424063432_CNGX.cit";
            request.exportTxtPath = @"H:\工作文件汇总\铁科院\程序\车载加速度\数据文件\test.txt";
            request.startMile     = 1;
            request.endMile       = 100;
            request.isChinese     = false;

            string str = JsonConvert.SerializeObject(request);

            AccelerationOffLineCommon.Cit cit = new AccelerationOffLineCommon.Cit();
            string json   = "{\"sampleCount\":\"100000\",\"serviceID\":\"cit2txt\",\"exportTxtPath\":\"d:/user/赵桂东/CitData_160606204011_GJGX.txt\",\"path\":\"d:/user/赵桂东/CitData_160606204011_GJGX.cit\",\"user\":\"赵桂东\",\"channelNames\":[\"M\",\"AB_Vt_L_11\"]}";
            string result = cit.Export(str);
        }