182 lines
6.4 KiB
C#
182 lines
6.4 KiB
C#
namespace VECV_WebApi.Controllers.Dashboard
|
|
{
|
|
using ExcelHelper;
|
|
#region Namespaces
|
|
|
|
using LoggingHelper;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Http;
|
|
using System.Web.Mvc;
|
|
using VECV_WebApi.Models.Dashboard;
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// This controller contain APIs related to Dashboard
|
|
/// </summary>
|
|
public class DashboardController : 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
|
|
|
|
/// <summary>
|
|
/// To get tile dashboard KPIs
|
|
/// </summary>
|
|
/// <param name="model">Date range and user information</param>
|
|
/// <returns>Dashboard KPIs</returns>
|
|
public List<DashboardModel> Post([FromBody] DashboardModel model)
|
|
{
|
|
List<DashboardModel> objList = new List<DashboardModel>();
|
|
try
|
|
{
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
objList = ObjDashBoardRepository.GetTileDashboardDataSet(model);
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
objList.Add(new DashboardModel
|
|
{
|
|
Status = "0",
|
|
Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message
|
|
});
|
|
// write error log into file
|
|
objLog.ErrorLogFile("DashboardController GetTileDashboardDataSet", Ex.Message, path, errorlogtf);
|
|
}
|
|
return objList;
|
|
}
|
|
|
|
|
|
public List<DashboardModel> Post([FromUri] string VECVUser,[FromBody] DashboardModel model)
|
|
{
|
|
List<DashboardModel> objList = new List<DashboardModel>();
|
|
try
|
|
{
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
objList = ObjDashBoardRepository.GetTileDashboardDataSetVECV(model);
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
objList.Add(new DashboardModel
|
|
{
|
|
Status = "0",
|
|
Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message
|
|
});
|
|
// write error log into file
|
|
objLog.ErrorLogFile("DashboardController GetTileDashboardDataSet", Ex.Message, path, errorlogtf);
|
|
}
|
|
return objList;
|
|
}
|
|
/// <summary>
|
|
/// To get closed/open ticket report.
|
|
/// </summary>
|
|
/// <param name="TicketType">extra param to idenify the api</param>
|
|
/// <param name="model">ticket info</param>
|
|
/// <returns>closed/open ticket report</returns>
|
|
public VECVTicketRequestModel Post([FromUri] string VECVUser,[FromUri] string TicketType, [FromBody] VECVTicketRequestModel model)
|
|
|
|
{
|
|
// write data log into file
|
|
VECVTicketRequestModel ObjModel = new VECVTicketRequestModel();
|
|
try
|
|
{
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
model.TicketType = TicketType;
|
|
ObjModel = ObjDashBoardRepository.GetOpenCloseTicketDetailVECV(model);
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetOpenCloseTicketDetail", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
return ObjModel;
|
|
}
|
|
/// <summary>
|
|
/// To get open ticket detail of dealer
|
|
/// </summary>
|
|
/// <param name="model">Dealer info</param>
|
|
/// <returns>open ticket details of dealer</returns>
|
|
public VECVTicketRequestModel Post([FromUri] string VECVUser, [FromUri] string isdealer,[FromUri] string TicketType, [FromUri] string dealer,[FromBody] VECVTicketRequestModel model)
|
|
{ // write data log into file
|
|
VECVTicketRequestModel ObjModel = new VECVTicketRequestModel();
|
|
try
|
|
{
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
model.TicketType = TicketType;
|
|
ObjModel = ObjDashBoardRepository.GetDealerOpenTicketDetailVECV(model);
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetOpenCloseTicketDetail", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
return ObjModel;
|
|
// objList = objDealerRepository.GetDealerOpenTicketDetail(model);
|
|
|
|
|
|
}
|
|
|
|
|
|
public List<VECVSyncModel> Post([FromUri] string Sync, [FromUri] string VECVUser, [FromUri] string VECV, [FromBody] VECVSyncModel model)
|
|
{
|
|
VECVSyncModel objModel = new VECVSyncModel();
|
|
List<VECVSyncModel> objList = new List<VECVSyncModel>();
|
|
|
|
try
|
|
{
|
|
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
|
|
objList = ObjDashBoardRepository.GetSyncTicketDetail_VECV(model);
|
|
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
objList.Add(new VECVSyncModel
|
|
{
|
|
Status = "0",
|
|
Message = Ex.Message
|
|
|
|
});
|
|
return objList;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|