235 lines
7.8 KiB
C#
235 lines
7.8 KiB
C#
using ExcelHelper;
|
|
using LoggingHelper;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web;
|
|
using System.Web.Http;
|
|
using VECV_WebApi.Models.Ticket;
|
|
using VECV_WebApi.Models.EmailServices;
|
|
using VECV_WebApi.Models.User;
|
|
|
|
namespace VECV_WebApi.Controllers.Ticket
|
|
{
|
|
public class EPSController : 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 Ticket Repository object available to this class
|
|
/// </summary>
|
|
TicketRepository objTicketRepository;
|
|
|
|
/// <summary>
|
|
/// making the Database connection string available to this class
|
|
/// </summary>
|
|
private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString();
|
|
|
|
|
|
#endregion
|
|
#region APIs
|
|
|
|
public string Post([FromBody] EPSSalesDetails model)
|
|
{
|
|
|
|
string strmsg = "";
|
|
TicketRepository objTicketRepository = new TicketRepository(_connStr);
|
|
|
|
// VanDealerListStateWise objVanDealerListStateWise = objTicketRepository.GetVanlatlngbydevicealias(model.SenderId);
|
|
try
|
|
{
|
|
strmsg = objTicketRepository.InsertEPSSalesDetails(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 Get(string epsSalesReport)
|
|
{
|
|
List<EPSSalesDetails> objListfullDetails = new List<EPSSalesDetails>();
|
|
try
|
|
{
|
|
string fileName = null;
|
|
bool isCreated = false;
|
|
TicketRepository objTicketRepository = new TicketRepository(_connStr);
|
|
// TicketOpenModel objModel = new TicketOpenModel();
|
|
objTicketRepository = new TicketRepository(_connStr);
|
|
objListfullDetails = objTicketRepository.GetAllEPSSalesDetails();
|
|
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 = "Prdoduct Type";
|
|
ds.Tables[0].Columns[4].ColumnName = "Quantity";
|
|
ds.Tables[0].Columns[5].ColumnName = "Activity Punch By";
|
|
ds.Tables[0].Columns[6].ColumnName = "Activity Creation Date & Time";
|
|
|
|
|
|
ExcelUtility objExcelUtility = new ExcelHelper.ExcelUtility();
|
|
|
|
List<WorkbookMappingModel> workbokkMapping = new List<WorkbookMappingModel>();
|
|
|
|
string _excelExportPathOnServer = ConfigurationManager.AppSettings["excelExportPathOnServer"].ToString();
|
|
fileName = "EPSSalesLeadReport_" + 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 Post(string epscount, [FromBody] InsertOpenTicket model)
|
|
{
|
|
string strsuccess = "";
|
|
try
|
|
{
|
|
|
|
GlobalRepository objGlobalRepository = new GlobalRepository(_connStr);
|
|
strsuccess = objGlobalRepository.getvehiclewarrantychassis(model.ChassisNo);
|
|
return strsuccess;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// writing error logs
|
|
objLog.ErrorLogFile("GetAllTimeZoneList_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
public string Post(string seteps, string iseps, [FromBody] UserModel model)
|
|
{
|
|
|
|
try
|
|
{
|
|
UserModel objUserModel = new UserModel();
|
|
UserRepository objGlobalRepository = new UserRepository(_connStr);
|
|
objUserModel = objGlobalRepository.UpdateEPSStatus(model);
|
|
|
|
return objUserModel.Status;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// writing error logs
|
|
objLog.ErrorLogFile("GetAllTimeZoneList_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
public string Post(string geteps, string seteps, string iseps, [FromBody] UserModel model)
|
|
{
|
|
string strsuccess = "";
|
|
try
|
|
{
|
|
|
|
UserRepository objGlobalRepository = new UserRepository(_connStr);
|
|
strsuccess = objGlobalRepository.getEPSStatus(model.AuthEngineId);
|
|
return strsuccess;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// writing error logs
|
|
objLog.ErrorLogFile("GetAllTimeZoneList_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
public string Post(string role, string geteps, string seteps, string iseps, [FromBody] UserModel model)
|
|
{
|
|
string strsuccess = "";
|
|
try
|
|
{
|
|
|
|
UserRepository objGlobalRepository = new UserRepository(_connStr);
|
|
strsuccess = objGlobalRepository.getEPSStatusByUserId(model.AuthEngineId);
|
|
return strsuccess;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// writing error logs
|
|
objLog.ErrorLogFile("GetAllTimeZoneList_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
public CustomerOpenTicketDetail Post([FromUri] string OpenTicket, [FromUri] string OpenTicket1, [FromUri] int kam, [FromUri] string check, [FromBody] CustomerOpenTicketDetail model)
|
|
|
|
{
|
|
try
|
|
{
|
|
CustomerOpenTicketDetail oCustomerOpenTicketDetail = new CustomerOpenTicketDetail();
|
|
objTicketRepository = new TicketRepository(_connStr);
|
|
oCustomerOpenTicketDetail = objTicketRepository.CheckTicketCreatedForRegNo(model);
|
|
|
|
return oCustomerOpenTicketDetail;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |