トラックが指定されたルートをたどり、正しい順序でポイントを通過したかどうかを判断する必要がある C# Winforms アプリを開発しています。有効なルートの例は次のとおりです。
ROUTE 1
入口ゲート1
スケールゲート入口側
スケールゲート出口側
出口ゲート1
ROUTE 2
入口ゲート2
スケールゲート入口側
スケールゲート出口側
出口ゲート2
スケールゲートは両方のルートで同じですが、私が心配する必要があるのは入口と出口のゲートです。トラックがゲート 1 から入り、ゲート 1 から出る場合、たどったルートは正しいものでした。ただし、トラックがゲート 2 に入り、ゲート 1 から出る場合は、通知を送信する必要があります。
各ゲートには、読み取りポイントとして構成されたハードウェアがあります。トラックが読み取りポイントを通過すると、データベースにタイムスタンプ付きのレコードが作成されます。指定された間隔で有効なトラック ID のリストを取得するようにタイマーを設定しました。次に、指定された時間内に各トラックが通過した読み取りポイントを取得し、それらもリストに格納します。よくわからないのは、「正しいルート」リストと、トラックが通過した読み取りポイントのリストを比較する方法です。現在、各トラックは 1 日に 1 回だけ移動するという前提で作業を進めています。
タイマーのコードは次のとおりです
private void tmr_Tick(object sender, EventArgs e)
    {
        int maxTime = int.Parse(AppSettings.GetAppSetting("MaxTime"));
        List<string> _assets = new List<string>();
        List<ReadPoint> _assetReads = new List<ReadPoint>();
        //Get the list of assets to process
        DataSet ds = du.ExecuteTextCommand("SELECT DISTINCT AssetId FROM " + 
             "(SELECT a.TagId, a.AssetId, a.Description, rp.Comments, DateScanned " + 
             "FROM AssetsReads ar JOIN Assets a on ar.AssetTagID = a.AssetTagID " + 
             "JOIN ReadPointLocations rp on " + 
             "ar.ReadPointLocationsID = rp.ReadPointLocationsID) AS AssetResult " + 
             "ORDER BY AssetId");
        if (ds != null && ds.Tables[0].Rows.Count > 0)
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                _assets.Add(dr["AssetId"].ToString());
            }
        }
        //Loop through and process the assets
        foreach (string asset in _assets)
        {
            ds = du.ExecuteTextCommand("SELECT a.TagId, a.AssetId, a.Description, " + 
                 "rp.ReadPointLocationId, rp.Comments, DateScanned " + 
                 "FROM AssetsReads ar JOIN Assets a on ar.AssetTagID = a.AssetTagID " + 
                 "JOIN ReadPointLocations rp on " + 
                 "ar.ReadPointLocationsID = rp.ReadPointLocationsID " + 
                 "WHERE a.AssetID = '" + asset + "' ORDER BY DateScanned");
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                _assetReads.Clear();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    ReadPoint ar = new ReadPoint();
                    ar.ReadPointLocationId = int.Parse(dr["ReadPointLocationId"].ToString());
                    ar.ReadpointName = dr["Comments"].ToString();
                    ar.DateScanned = DateTime.Parse(dr["DateScanned"].ToString());
                    _assetReads.Add(ar);
                }
                //Check to see if the asset has been seen in the last (MaxTime) minutes
                if (DateTime.Parse(_assetReads[0].DateScanned.ToString()) < DateTime.Now)
                {
                    ///////////////////////
                    //Send notification
                    ///////////////////////
                    continue;
                }
                //Determine the correct route to follow
                Route currentRoute = null;
                foreach (Route rt in _routes)
                {
                    foreach (ReadPoint rp in rt.ReadPoints)
                    {
                        if (_assetReads[0].ReadPointLocationId == rp.ReadPointLocationId)
                        {
                            currentRoute = rt;
                            break;
                        }
                    }
                    if (currentRoute != null)
                        break;
                }
                //Check if the route was correctly followed
                if (currentRoute != null)
                {
                    //////////////////////////////
                    //This is where I'm stuck
                    //////////////////////////////
                }
            }
        }
    }