/// <summary> /// Traffic By Time...Non Predict /// </summary> public ArrayList DisplyTraffic(TrafficPredict myTrafficDis) { // --- DB Connection --- SqlConnection sqlConn = new SqlConnection(DL.SQL.conn); sqlConn.Open(); SqlCommand sqlcom = new System.Data.SqlClient.SqlCommand("Select SplitTime,sum(NoOfVehicles) AS TOTELVehicle From tblTraffic Where Region = '" + myTrafficDis.strRegion + "' Group By SplitTime", sqlConn); SqlDataReader sqlred = sqlcom.ExecuteReader(); while (sqlred.Read()) { ArrayTraffic objTraffic = new ArrayTraffic(); objTraffic.strSplitTime = sqlred["SplitTime"].ToString(); objTraffic.doubleNoOfVehicles = Convert.ToInt32(sqlred["TOTELVehicle"]); myArrayTraffic.Insert(indexArrTraffic, objTraffic); indexArrTraffic = indexArrTraffic + 1; } return(myArrayTraffic); }
public ArrayList FindTraffic(TrafficPredict myTrafficPredict) { // --- DB Connection --- SqlConnection sqlConn = new SqlConnection(DL.SQL.conn); SqlDataReader sqlRdr = null; TrafficPredict objTrafficPredict = new TrafficPredict(); try { sqlConn.Open(); // ----------------- SqlCommand sqlCom = new SqlCommand("TrafficPredictor", sqlConn); sqlCom.CommandType = CommandType.StoredProcedure; sqlRdr = sqlCom.ExecuteReader(); // ----------------- while (sqlRdr.Read()) { ArrayTraffic objTraffic = new ArrayTraffic(); objTraffic.intYear = Convert.ToInt16(sqlRdr["Year"]); objTraffic.doubleNoOfVehicles = Convert.ToDouble(sqlRdr["TotalTraffic"]); LoopForYr = Convert.ToInt16(sqlRdr["Year"]); myArrayTraffic.Insert(indexArrTraffic, objTraffic); indexArrTraffic = indexArrTraffic + 1; } // --- Insert Year --- int FutureYr = myTrafficPredict.intYear; // --- Find The Loop Count --- int loopCount = FutureYr - LoopForYr; for (int j = 0; j < loopCount; j++) { // --- Get the Oldest Value From the ArrayList --- ArrayTraffic objOldestVal = (ArrayTraffic)(myArrayTraffic[0]); double OldestVal = objOldestVal.doubleNoOfVehicles; // ----------------------------------------------- // --- Get the Newest Value From the ArrayList --- int NearestYrVal = myArrayTraffic.Count; NearestYrVal--; ArrayTraffic objNewVal = (ArrayTraffic)(myArrayTraffic[NearestYrVal]); double NewVal = objNewVal.doubleNoOfVehicles; DbYear = objNewVal.intYear; // ----------------------------------------------- // --- Insert The Calc Value To Array --- DbYear++; // --- Algo --- double Predicton = NewVal * Math.Exp((Math.Log((NewVal / OldestVal), Math.Exp(1)) / 4) * 1); PredictTraffic = Predicton; // --- Algo --- // --- Insert The Calc Value To Array --- ArrayTraffic objArrTrafficInsert = new ArrayTraffic(); objArrTrafficInsert.intYear = DbYear; objArrTrafficInsert.doubleNoOfVehicles = PredictTraffic; myArrayTraffic.Insert((myArrayTraffic.Count), objArrTrafficInsert); // --- Insert The Calc Value To Array --- } } catch (Exception ex) { } return(myArrayTraffic); }