コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            int      lineId = 0;
            DateTime date, end_date;

            try
            {
                lineId   = Convert.ToInt32(context.Request.Params["lineId"].ToLower());
                date     = Convert.ToDateTime(context.Request.Params["date"].ToLower());
                end_date = date.AddDays(1);
            }
            catch (System.Exception)
            {
                context.Response.Write(null);
                context.Response.End();
                return;
            }
            context.Response.ContentType = "text/plain";
            context.Response.Clear();
            List <DetectRecord> detectRecords = new List <DetectRecord>();
            MetroTunnelDB       Database      = null;

            try
            {
                Database = new MetroTunnelDB();
                Database.QueryDetectRecord(ref detectRecords, lineId, date, end_date);
            }
            catch (System.Exception)
            {
                context.Response.Write(null);
                context.Response.End();
                return;
            }
            RootJson rootJson                 = new RootJson();

            rootJson.data         = new DataJson();
            rootJson.data.devices = new List <DevicesJson>();
            if (detectRecords.Count < 1)
            {
                context.Response.Write(null);
                context.Response.End();
                return;
            }
            // 清除重复设备名
            Dictionary <string, string> device_dict = new Dictionary <string, string>();

            for (int i = 0; i < detectRecords.Count; i++)
            {
                if (!device_dict.ContainsKey(detectRecords[i].DeviceID))
                {
                    List <DetectDevice> detectDevices = new List <DetectDevice>();
                    try
                    {
                        Database.QueryDetectDevice(ref detectDevices, detectRecords[i].DeviceID);
                    }
                    catch (System.Exception)
                    {
                        continue;
                    }
                    device_dict.Add(detectRecords[i].DeviceID, detectDevices[0].DetectDeviceName);
                }
            }
            // 遍历非重复设备
            foreach (string deviceId in device_dict.Keys)
            {
                rootJson.data.devices.Add(new DevicesJson(deviceId, device_dict[deviceId]));
            }
            string rootJsonStr = JsonConvert.SerializeObject(rootJson);

            context.Response.Write(rootJsonStr);
            context.Response.End();
        }
コード例 #2
0
        // Read and Handle the Mileage csv file
        public static void HandleMileage(object param)
        {
            HandleMileageParam hm_param = (HandleMileageParam)param;
            int           record_id     = hm_param.record_id;
            string        csv_file_path = hm_param.csv_file_path;
            MainWindow    mw            = hm_param.mw;
            FileStream    fs            = new FileStream(csv_file_path, FileMode.Open, System.IO.FileAccess.Read);
            StreamReader  sr            = new StreamReader(fs);
            MetroTunnelDB database      = new MetroTunnelDB();

            // Record the line
            string strline;

            string[] arrline     = null;
            int      columncount = 0;
            bool     isfirst     = true;

            while ((strline = sr.ReadLine()) != null)
            {
                MileageTime mtime = new MileageTime();
                arrline = strline.Split(',');
                if (isfirst)
                {
                    columncount = arrline.Length;
                    isfirst     = false;
                }
                for (int i = 0; i < columncount; i++)
                {
                    try
                    {
                        // FrameNum
                        if (i == 0)
                        {
                            mtime.Timestamp = Convert.ToInt32(arrline[0]);
                        }
                        else if (i == 1)
                        {
                            mtime.mileage = Convert.ToDouble(arrline[1]);
                        }
                    }
                    catch (System.NullReferenceException)
                    {
                        ;
                    }
                    catch (System.IndexOutOfRangeException)
                    {
                        ;
                    }
                }

                // Get TandD
                TandD tandD = new TandD(record_id, mtime.Timestamp, mtime.mileage);
                // mw.SubProcessReport(mw.line_counter++);
                mw.line_counter++;
                // Insert into database
                try
                {
                    database.InsertIntoTandD(tandD);
                }
                catch (System.Exception)
                {
                    mw.DebugWriteLine("视频序列数据库插入异常");
                }
            }
            DataAnalyze.threadControlCounter += 1;
        }
コード例 #3
0
        public void ProcessRequest(HttpContext context)
        {
            int      lineId = 0;
            DateTime date, end_date;

            try
            {
                lineId   = Convert.ToInt32(context.Request.Params["lineId"].ToLower());
                date     = Convert.ToDateTime(context.Request.Params["date"].ToLower());
                end_date = date.AddDays(1);
            }
            catch (System.Exception)
            {
                context.Response.Write(null);
                context.Response.End();
                return;
            }
            context.Response.ContentType = "text/plain";
            context.Response.Clear();
            List <DetectRecord> detectRecords = new List <DetectRecord>();
            MetroTunnelDB       Database      = null;

            try
            {
                Database = new MetroTunnelDB();
                Database.QueryDetectRecord(ref detectRecords, lineId, date, end_date);
            }
            catch (System.Exception)
            {
                context.Response.Write(null);
                context.Response.End();
                return;
            }
            if (detectRecords.Count < 1)
            {
                context.Response.Write(null);
                context.Response.End();
                return;
            }
            RootJson rootJson                 = new RootJson();

            rootJson.data         = new DataJson();
            rootJson.data.records = new List <RecordsJson>();
            for (int i = 0; i < detectRecords.Count; i++)
            {
                List <DataOverview> dataOverviews = new List <DataOverview>();
                int recordsCount = 0;
                try
                {
                    Database.QueryDataOverview(ref dataOverviews, (int)(detectRecords[i].RecordID));
                    recordsCount = dataOverviews.Count();
                }
                catch (System.Exception)
                {
                    ;
                }
                rootJson.data.records.Add(new RecordsJson((int)detectRecords[i].RecordID, detectRecords[i].DeviceID, detectRecords[i].Length, recordsCount));
            }
            string rootJsonStr = JsonConvert.SerializeObject(rootJson);

            context.Response.Write(rootJsonStr);
            context.Response.End();
        }