296 lines
9.7 KiB
C#
296 lines
9.7 KiB
C#
|
|
#region Namespaces
|
|
|
|
using LoggingHelper;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Http;
|
|
using System.Web.Mvc;
|
|
using VECV_WebApi.Models.Dashboard;
|
|
|
|
#endregion
|
|
|
|
namespace VECV_WebApi.Controllers.NewDashboard
|
|
{
|
|
public class NewDashboardController : ApiController
|
|
{
|
|
#region Global Variable
|
|
|
|
/// <summary>
|
|
/// making object of LoggingUtility class available to this class
|
|
/// </summary>
|
|
LoggingUtility objLog = new LoggingUtility();
|
|
|
|
/// <summary>
|
|
/// making the data-log file path available to this class
|
|
/// </summary>
|
|
string path = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["PathLog"]);
|
|
|
|
/// <summary>
|
|
/// making data log file path available to this class
|
|
/// </summary>
|
|
string logtf = (ConfigurationManager.AppSettings["Log"]);
|
|
|
|
/// <summary>
|
|
/// making error log file path available to this class
|
|
/// </summary>
|
|
string errorlogtf = (ConfigurationManager.AppSettings["ErrorLog"]);
|
|
|
|
/// <summary>
|
|
/// making the Database connection string available to this class
|
|
/// </summary>
|
|
private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString();
|
|
|
|
#endregion
|
|
|
|
|
|
#region APIs
|
|
|
|
|
|
public List<RegionModel> post(string region)
|
|
{
|
|
List<RegionModel> objList = new List<RegionModel>();
|
|
try
|
|
{
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
objList = ObjDashBoardRepository.GetAllRegionListDataSet();
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// writing error logs
|
|
objLog.ErrorLogFile("GetAllRegionList_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
public NewDashboardModel Post([FromBody] NewDashboardDataModel model)
|
|
|
|
{
|
|
NewDashboardModel objList = new NewDashboardModel();
|
|
string startdate = model.StartDate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["startTimeFormat"]);
|
|
string enddate = model.EndDate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["endTimeFormat"]);
|
|
string _dateTimeFormat = ConfigurationManager.AppSettings["dateTimeFormat"].ToString();
|
|
model.FromDate = Convert.ToDateTime(startdate);
|
|
model.ToDate = Convert.ToDateTime(enddate);
|
|
try
|
|
{
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
objList = ObjDashBoardRepository.GetTileNewDashboardDataSet(model);
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
|
|
// write error log into file
|
|
objLog.ErrorLogFile("NewDashboardController GetTileNewDashboardDataSet", Ex.Message, path, errorlogtf);
|
|
}
|
|
return objList;
|
|
}
|
|
|
|
public List<DealerModel> post(string dealer,[FromBody] NewDashboardDataModel model)
|
|
{
|
|
List<DealerModel> objList = new List<DealerModel>();
|
|
try
|
|
{
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
objList = ObjDashBoardRepository.GetDealerDetails(model);
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetAllCityListStateIdWise_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
public List<DTCModel> post(string dtc,string dtccount, [FromBody] NewDashboardDataModel model)
|
|
{
|
|
List<DTCModel> objList = new List<DTCModel>();
|
|
try
|
|
{
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
objList = ObjDashBoardRepository.GetDTCDetails(model);
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetAllCityListStateIdWise_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public List<GraphModel> post(string graph, string graph1, string graph2, [FromBody] NewDashboardDataModel model)
|
|
{
|
|
|
|
List<GraphModel> objList = new List<GraphModel>();
|
|
try
|
|
{
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
objList = ObjDashBoardRepository.GetGraphDetails(model);
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetAllCityListStateIdWise_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
|
|
public List<VerticleModel> Get()
|
|
{
|
|
List<VerticleModel> objList = new List<VerticleModel>();
|
|
try
|
|
{
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
objList = ObjDashBoardRepository.GetVerticleListDataSet();
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// writing error logs
|
|
objLog.ErrorLogFile("GetAllRegionList_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
public List<EmissionModel> get(string emission)
|
|
{
|
|
List<EmissionModel> objList = new List<EmissionModel>();
|
|
|
|
try
|
|
{
|
|
DashboardRepository objDashboardRepository = new DashboardRepository(_connStr);
|
|
objList = objDashboardRepository.GetAllEmissionList();
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetAllEmissionList_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
public List<DealerModel> Get(string dealer, string dealer1)
|
|
{
|
|
List<DealerModel> objList = new List<DealerModel>();
|
|
try
|
|
{
|
|
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
if(dealer == null)
|
|
{
|
|
int[] intarr = null;
|
|
objList = ObjDashBoardRepository.GetAllDealerListDataSet(intarr);
|
|
}
|
|
else if (dealer.ToLower() == "dealer" )
|
|
{
|
|
int[] intarr = null;
|
|
objList = ObjDashBoardRepository.GetAllDealerListDataSet(intarr);
|
|
}
|
|
else
|
|
{
|
|
//int[] Arr = new int[dealer.Length];//int array for string console values
|
|
//for (int i = 0; i < dealer.Length; i++)//goes true all elements and converts them into Int32
|
|
//{
|
|
// Arr[i] = Convert.ToInt32(dealer[i].ToString());
|
|
//}
|
|
// string[] strings = new string[] { dealer };
|
|
string[] strings = dealer.Split(',');
|
|
int[] ints = Array.ConvertAll(strings, s => int.Parse(s));
|
|
objList = ObjDashBoardRepository.GetAllDealerListDataSet(ints);
|
|
}
|
|
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetAllCityListStateIdWise_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
|
|
public List<DealerModel> Get(string dtcdata, string dtcdatareport,string dtclist )
|
|
{
|
|
List<DealerModel> objList = new List<DealerModel>();
|
|
try
|
|
{
|
|
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
if (dtcdata == null)
|
|
{
|
|
int[] intarr = null;
|
|
objList = ObjDashBoardRepository.GetAllDealerListDataSet(intarr);
|
|
}
|
|
else if (dtcdata.ToLower() == "dtc")
|
|
{
|
|
int[] intarr = null;
|
|
objList = ObjDashBoardRepository.GetAllDealerListDataSet(intarr);
|
|
}
|
|
else
|
|
{
|
|
//int[] Arr = new int[dealer.Length];//int array for string console values
|
|
//for (int i = 0; i < dealer.Length; i++)//goes true all elements and converts them into Int32
|
|
//{
|
|
// Arr[i] = Convert.ToInt32(dealer[i].ToString());
|
|
//}
|
|
// string[] strings = new string[] { dealer };
|
|
string[] strings = dtcdata.Split(',');
|
|
int[] ints = Array.ConvertAll(strings, s => int.Parse(s));
|
|
objList = ObjDashBoardRepository.GetAllDealerListDataSet(ints);
|
|
}
|
|
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetAllCityListStateIdWise_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
public List<VehicleTypeModel> Get(string vehicleModel, string fueltype, string vehicleTagging,string modellist)
|
|
{
|
|
List<VehicleTypeModel> objList = new List<VehicleTypeModel>();
|
|
try
|
|
{
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
|
|
if (vehicleTagging == null)
|
|
{
|
|
string[] intarr = null;
|
|
objList = ObjDashBoardRepository.GetVehicleModelFilter(fueltype, intarr);
|
|
}
|
|
else
|
|
{
|
|
string[] strings = vehicleTagging.Split(',');
|
|
// string[] ints = Array.ConvertAll(strings);
|
|
objList = ObjDashBoardRepository.GetVehicleModelFilter(fueltype, strings);
|
|
}
|
|
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// writing error logs
|
|
objLog.ErrorLogFile("GetAllRegionList_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|