398 lines
14 KiB
C#
398 lines
14 KiB
C#
#region Namespaces
|
|
|
|
using ExcelHelper;
|
|
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.Authorization;
|
|
using VECV_WebApi.Models.Dealer;
|
|
using VECV_WebApi.Models.Notification;
|
|
using VECV_WebApi.Models.Ticket;
|
|
using VECV_WebApi.Models.User;
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// This cotroller
|
|
/// apis releted to dealer
|
|
/// </summary>
|
|
public class TitanDealerController : ApiController
|
|
{
|
|
|
|
#region Global References
|
|
|
|
/// <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 Dealer Repository object available to this class
|
|
/// </summary>
|
|
DealerRepository objDealerRepository;
|
|
|
|
/// <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 open ticket detail of dealer
|
|
/// </summary>
|
|
/// <param name="model">Dealer info</param>
|
|
/// <returns>open ticket details of dealer</returns>
|
|
public TiatnResponseModel Post([FromBody] TiatnResponseModel model)
|
|
{
|
|
TiatnResponseModel objModel = new TiatnResponseModel();
|
|
//List<DealerOpenTicketDetailModel> objList = new List<DealerOpenTicketDetailModel>();
|
|
try
|
|
{
|
|
objDealerRepository = new DealerRepository(_connStr);
|
|
objModel = objDealerRepository.GetTitanDealerDetail(model);
|
|
return objModel;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
// objModel.Status = "0";
|
|
// objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("GetTitanDealerDetail_Controller", Ex.Message, path, errorlogtf);
|
|
|
|
return objModel;
|
|
}
|
|
}
|
|
|
|
public List<TitanTicketDealerModel> Post(string type, string dealerlist,[FromBody] TiatnResponseModel model)
|
|
{
|
|
List<TitanTicketDealerModel> objModel = new List<TitanTicketDealerModel>();
|
|
//List<DealerOpenTicketDetailModel> objList = new List<DealerOpenTicketDetailModel>();
|
|
try
|
|
{
|
|
objDealerRepository = new DealerRepository(_connStr);
|
|
// objModel = objDealerRepository.GetTitanticketList(model);
|
|
return objModel;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
// objModel.Status = "0";
|
|
// objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("GetTitanDealerDetail_Controller", Ex.Message, path, errorlogtf);
|
|
|
|
return objModel;
|
|
}
|
|
}
|
|
public string Get()
|
|
{
|
|
List<SVCDetails> objListfullDetails = new List<SVCDetails>();
|
|
try
|
|
{
|
|
string fileName = null;
|
|
bool isCreated = false;
|
|
TicketRepository objTicketRepository = new TicketRepository(_connStr);
|
|
// TicketOpenModel objModel = new TicketOpenModel();
|
|
objTicketRepository = new TicketRepository(_connStr);
|
|
objListfullDetails = objTicketRepository.GetAllSVCDeatils();
|
|
DataTable OpenTicketTable = objListfullDetails.ToDataTable();
|
|
Int32 OpenTicketTableColumnCount = OpenTicketTable.Columns.Count - 1;
|
|
|
|
|
|
DataSet ds = new DataSet();
|
|
|
|
|
|
|
|
for (var count = OpenTicketTableColumnCount; count >= 10; count--) //modified count on 25-11-2020 //modified count from 34 to 35 on 23-12-2020
|
|
{
|
|
OpenTicketTable.Columns.RemoveAt(count);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ds.Tables.Add(OpenTicketTable);
|
|
ds.Tables[0].Columns[0].ColumnName = "Customer Name";
|
|
ds.Tables[0].Columns[1].ColumnName = "Customer Mobile Number";
|
|
ds.Tables[0].Columns[2].ColumnName = "Address";
|
|
ds.Tables[0].Columns[3].ColumnName = "Existing User of SCV";
|
|
ds.Tables[0].Columns[4].ColumnName = "OEM Name";
|
|
ds.Tables[0].Columns[5].ColumnName = "Activity Punch By";
|
|
ds.Tables[0].Columns[6].ColumnName = "Activity Creation Date & Time";
|
|
ds.Tables[0].Columns[7].ColumnName = "Quantity";
|
|
|
|
ExcelUtility objExcelUtility = new ExcelHelper.ExcelUtility();
|
|
List<WorkbookMappingModel> workbokkMapping = new List<WorkbookMappingModel>();
|
|
|
|
string _excelExportPathOnServer = ConfigurationManager.AppSettings["excelExportPathOnServer"].ToString();
|
|
fileName = "SVCReport_" + DateTime.Now.ToString("ddMMMyyyyhhmmss") + ".xlsx";
|
|
|
|
// filename = "CloseTicket_" + DateTime.Now.ToString("ddMMMyyyyhhmmss") + ".xlsx";
|
|
workbokkMapping.Add(new WorkbookMappingModel { DataTableName = ds.Tables[0].TableName, WorkSheetName = "Open Report", StartColumnName = "A", StartRowNumber = 2, WorkSheetNumber = 1, AutoFit = false });
|
|
string templatePath = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["OpenTicketReportTemplate"].ToString());
|
|
string _exportLocation = ConfigurationManager.AppSettings["excelExportPath"].ToString();
|
|
|
|
string pathToExcelFile = _exportLocation + fileName;
|
|
|
|
//string saveAs = Server.MapPath(_excelExportPathOnServer + fileName);
|
|
|
|
string SaveCsvAs = HttpContext.Current.Server.MapPath(_excelExportPathOnServer + fileName);
|
|
|
|
|
|
//commented on 24-07-2020(excel download same as consolidate report)
|
|
isCreated = CreateExcelFile.CreateExcelDocument(ds, SaveCsvAs);
|
|
if (isCreated == true) { return _exportLocation + fileName; }
|
|
else { return "error"; }
|
|
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("TicketAcceptOrDecliend_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
|
|
// return objListfullDetails;
|
|
}
|
|
public string Get(string accidentalReport)
|
|
{
|
|
List<AccidentalDetails> objListfullDetails = new List<AccidentalDetails>();
|
|
try
|
|
{
|
|
string fileName = null;
|
|
bool isCreated = false;
|
|
TicketRepository objTicketRepository = new TicketRepository(_connStr);
|
|
// TicketOpenModel objModel = new TicketOpenModel();
|
|
objTicketRepository = new TicketRepository(_connStr);
|
|
objListfullDetails = objTicketRepository.GetAllAccidentalDetails();
|
|
DataTable OpenTicketTable = objListfullDetails.ToDataTable();
|
|
Int32 OpenTicketTableColumnCount = OpenTicketTable.Columns.Count - 1;
|
|
|
|
|
|
DataSet ds = new DataSet();
|
|
|
|
|
|
|
|
for (var count = OpenTicketTableColumnCount; count >= 10; count--) //modified count on 25-11-2020 //modified count from 34 to 35 on 23-12-2020
|
|
{
|
|
OpenTicketTable.Columns.RemoveAt(count);
|
|
}
|
|
|
|
ds.Tables.Add(OpenTicketTable);
|
|
ds.Tables[0].Columns[0].ColumnName = "Customer Name";
|
|
ds.Tables[0].Columns[1].ColumnName = "Customer Mobile Number";
|
|
ds.Tables[0].Columns[2].ColumnName = "Vehicle Location";
|
|
ds.Tables[0].Columns[3].ColumnName = "Ambulance Support Required";
|
|
ds.Tables[0].Columns[4].ColumnName = "Dealer Support Required";
|
|
ds.Tables[0].Columns[5].ColumnName = "Dealer Connect";
|
|
ds.Tables[0].Columns[6].ColumnName = "Activity Punch By";
|
|
ds.Tables[0].Columns[7].ColumnName = "Activity Creation Date & Time";
|
|
ds.Tables[0].Columns[8].ColumnName = " Registration Number";
|
|
|
|
|
|
ExcelUtility objExcelUtility = new ExcelHelper.ExcelUtility();
|
|
|
|
List<WorkbookMappingModel> workbokkMapping = new List<WorkbookMappingModel>();
|
|
|
|
string _excelExportPathOnServer = ConfigurationManager.AppSettings["excelExportPathOnServer"].ToString();
|
|
fileName = "AccidentalReport_" + DateTime.Now.ToString("ddMMMyyyyhhmmss") + ".xlsx";
|
|
|
|
// filename = "CloseTicket_" + DateTime.Now.ToString("ddMMMyyyyhhmmss") + ".xlsx";
|
|
workbokkMapping.Add(new WorkbookMappingModel { DataTableName = ds.Tables[0].TableName, WorkSheetName = "Open Report", StartColumnName = "A", StartRowNumber = 2, WorkSheetNumber = 1, AutoFit = false });
|
|
string templatePath = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["OpenTicketReportTemplate"].ToString());
|
|
string _exportLocation = ConfigurationManager.AppSettings["excelExportPath"].ToString();
|
|
|
|
string pathToExcelFile = _exportLocation + fileName;
|
|
|
|
//string saveAs = Server.MapPath(_excelExportPathOnServer + fileName);
|
|
|
|
string SaveCsvAs = HttpContext.Current.Server.MapPath(_excelExportPathOnServer + fileName);
|
|
|
|
|
|
//commented on 24-07-2020(excel download same as consolidate report)
|
|
isCreated = CreateExcelFile.CreateExcelDocument(ds, SaveCsvAs);
|
|
if (isCreated == true) { return _exportLocation + fileName; }
|
|
else { return "error"; }
|
|
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("TicketAcceptOrDecliend_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
|
|
// return objListfullDetails;
|
|
}
|
|
|
|
public string Get([FromUri] string dealercode, [FromUri] string getdealer)
|
|
{
|
|
string dealerEmail = "";
|
|
TicketRepository objTicketRepository;
|
|
objTicketRepository = new TicketRepository(_connStr);
|
|
dealerEmail = objTicketRepository.getEmailFromDealerCode(dealercode);
|
|
return dealerEmail;
|
|
}
|
|
|
|
|
|
public string Post(string svcdetails, string assignvan, string type, string dealerlist, [FromBody] SVCDetails model)
|
|
{
|
|
string strmsg = "";
|
|
TicketRepository objTicketRepository = new TicketRepository(_connStr);
|
|
|
|
// VanDealerListStateWise objVanDealerListStateWise = objTicketRepository.GetVanlatlngbydevicealias(model.SenderId);
|
|
try
|
|
{
|
|
strmsg = objTicketRepository.InsertSVCDetails(model);
|
|
return strmsg;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
// objModel.Status = "0";
|
|
// objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("GetTitanDealerDetail_Controller", Ex.Message, path, errorlogtf);
|
|
|
|
return strmsg;
|
|
}
|
|
}
|
|
|
|
public string Post(string accidentaldetails, string svcdetails, string assignvan, string type, string dealerlist, [FromBody] AccidentalDetails model)
|
|
{
|
|
string strmsg = "";
|
|
TicketRepository objTicketRepository = new TicketRepository(_connStr);
|
|
|
|
// VanDealerListStateWise objVanDealerListStateWise = objTicketRepository.GetVanlatlngbydevicealias(model.SenderId);
|
|
try
|
|
{
|
|
strmsg = objTicketRepository.InsertAccidentalDetails(model);
|
|
return strmsg;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
// objModel.Status = "0";
|
|
// objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("GetTitanDealerDetail_Controller", Ex.Message, path, errorlogtf);
|
|
|
|
return strmsg;
|
|
}
|
|
}
|
|
|
|
|
|
public InsertOpenTicket Post(string assignvan,string type, string dealerlist, [FromBody] InsertOpenTicket model)
|
|
{
|
|
TicketRepository objTicketRepository = new TicketRepository(_connStr);
|
|
string ticketid_alias = objTicketRepository.getticketidalias(model.TicketId);
|
|
string[] CSMContactNo = ticketid_alias.Split(',');
|
|
ticketid_alias = CSMContactNo[0].ToString();
|
|
string regno = CSMContactNo[1].ToString();
|
|
InsertOpenTicket objModel = new InsertOpenTicket();
|
|
|
|
string estimatedkm = model.EstimateDistance;
|
|
string lat = model.VanLatitude;
|
|
string lng = model.VanLongitude;
|
|
//List<DealerOpenTicketDetailModel> objList = new List<DealerOpenTicketDetailModel>();
|
|
try
|
|
{
|
|
string strupdate= objTicketRepository.updatetempvandetail(model);
|
|
// VanDealerListStateWise objVanDealerListStateWise = objTicketRepository.GetVanlatlngbydevicealias(model.SenderId);
|
|
|
|
//model.Token = model.Token;
|
|
model = objTicketRepository.GetTitanTicketDetail(model);
|
|
model.AssignedToUserLattitude = lat;
|
|
model.AssignedToUserLongitude = lng;
|
|
model.TicketStatusAlias = "new";
|
|
model.TicketStatus = 1;
|
|
model.OtherRemarks = "allocated";
|
|
model.Message = "allocated";
|
|
model.AssignedTo = "van";
|
|
model.EstimateDistance = estimatedkm;
|
|
model.AssignedToUserLattitude = lat;
|
|
model.AssignedToUserLongitude = lng;
|
|
//model.Token = model.Token;
|
|
objModel = objTicketRepository.UpdateOpenTicketWeb(model);
|
|
model.Token = model.Token;
|
|
model.TicketStatus = 2;
|
|
model.TicketStatusAlias = "assigned";
|
|
model.OtherRemarks = "allocated";
|
|
model.Message = "allocated";
|
|
model.AssignedTo ="van";
|
|
model.EstimateDistance = estimatedkm;
|
|
model.TicketIdAlias = ticketid_alias;
|
|
model.VehicleRegistrationNumber = regno;
|
|
model.AssignedToUserLattitude = lat;
|
|
model.AssignedToUserLongitude = lng;
|
|
objModel = objTicketRepository.UpdateOpenTicketWeb(model);
|
|
objDealerRepository = new DealerRepository(_connStr);
|
|
TiatnAllocationModel modelTiatnAllocationModel = new TiatnAllocationModel();
|
|
modelTiatnAllocationModel.Status = "true";
|
|
modelTiatnAllocationModel.ticketid_alias = ticketid_alias;
|
|
string strsuccess = objDealerRepository.updateAllocationStatus(modelTiatnAllocationModel);
|
|
model.Message = "Ticket Allocated Successfully";
|
|
return model;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
// objModel.Status = "0";
|
|
// objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("GetTitanDealerDetail_Controller", Ex.Message, path, errorlogtf);
|
|
|
|
return objModel;
|
|
}
|
|
}
|
|
|
|
public string Post(string updateallocatedstatus, [FromBody] TiatnAllocationModel model)
|
|
{
|
|
string strsuccess = "";
|
|
//List<DealerOpenTicketDetailModel> objList = new List<DealerOpenTicketDetailModel>();
|
|
try
|
|
{
|
|
|
|
objDealerRepository = new DealerRepository(_connStr);
|
|
strsuccess = objDealerRepository.updateAllocationStatus(model);
|
|
return strsuccess;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
// objModel.Status = "0";
|
|
// objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("GetTitanDealerDetail_Controller", Ex.Message, path, errorlogtf);
|
|
|
|
return strsuccess;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
} |