/// <summary> /// Traffic /// </summary> public void Traffic() { objTrafficPredict.intYear = Convert.ToInt16(txt1.Text); ArrayList FindTraffic = objTrafficPredict.FindTraffic(objTrafficPredict); // --- xml Graph--- StringBuilder xmlDataTraffic = new StringBuilder(); xmlDataTraffic.Append("<chart caption='Year-Traffic Count Report' subCaption='' Column3DSliceDepth='10' showBorder='1' formatNumberScale='0' numberSuffix=' '>"); int Get = FindTraffic.Count; for (int i = 0; i < Get; i++) { BL.ArrayTraffic obj = (BL.ArrayTraffic)(FindTraffic[i]); int yr = obj.intYear; double val = Math.Ceiling(obj.doubleNoOfVehicles); xmlDataTraffic.AppendFormat("<set label='{0}' value='{1}' />", yr.ToString(), val.ToString()); //ListBox1.Items.Add("Year --->" + yr + " Value --> " + val); } xmlDataTraffic.Append("</chart>"); TrafficGraph.Text = FusionCharts.RenderChart("FusionCharts/Line.swf", "", xmlDataTraffic.ToString(), "Column3DTraffic", "825", "350", false, true); }
/// <summary> /// Traffic By Time /// </summary> public void TrafficByTime() { // --- xml Graph--- StringBuilder xmlDataTraffic = new StringBuilder(); xmlDataTraffic.Append("<chart caption='Split Time-Traffic Status Report' subCaption='' Column3DSliceDepth='10' showBorder='1' formatNumberScale='0' numberSuffix=' '>"); // ---------------- objTrafficPredict.strRegion = ddlRegion.SelectedItem.ToString(); ArrayList DisVehTraffic = objTrafficPredict.DisplyTraffic(objTrafficPredict); // Loop only By Traffic int Get = DisVehTraffic.Count; for (int i = 0; i < Get; i++) { // --- DisVehPopulation Data To xml --- BL.ArrayTraffic objVehicleTraffic = (BL.ArrayTraffic)(DisVehTraffic[i]); string SplitTim = objVehicleTraffic.strSplitTime; double vehPopValTyp = objVehicleTraffic.doubleNoOfVehicles; xmlDataTraffic.AppendFormat("<set label='{0}' value='{1}' />", SplitTim.ToString(), vehPopValTyp.ToString()); } /// Create The Vehicle Population Chart - Column3D Chart With Data From xmlDataVehPop xmlDataTraffic.Append("</chart>"); LiteralVehicleTrafficByTime.Text = FusionCharts.RenderChart("FusionCharts/Column3D.swf", "", xmlDataTraffic.ToString(), "Column3DTrafficByTime", "810", "300", false, true); }
/// <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); }