231 lines
9.1 KiB
C#
231 lines
9.1 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;
|
|
|
|
namespace VECV_WebApi.Controllers.Ticket
|
|
{
|
|
public class PaymentDetailsController : 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
|
|
|
|
/// <summary>
|
|
/// To find ticket detail on device alias.
|
|
/// </summary>
|
|
/// <param name="model">ticket Payment info</param>
|
|
/// <returns>payment details on ti alias</returns>
|
|
public string Post([FromBody] PaymentDetailsModel model)
|
|
{
|
|
try
|
|
{
|
|
string strsuccess = "";
|
|
List<TicketOpenModel> objList = new List<TicketOpenModel>();
|
|
objTicketRepository = new TicketRepository(_connStr);
|
|
|
|
string strid = objTicketRepository.GetTicketdetailsByTicketId(model.TicketId);
|
|
model.TicketId_Alias = strid;
|
|
strsuccess = objTicketRepository.insertPaymentDetails(model);
|
|
return strsuccess;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetTicketDetailOnDeviceAlias_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// To find ticket details based on Device alias.
|
|
/// </summary>
|
|
/// <param name="TicketAccept">extra param to identify the api</param>
|
|
/// <param name="model">ticket info</param>
|
|
/// <returns>ticket details based on Device alias</returns>
|
|
public List<PaymentDetailsModel> Post([FromUri] string getDetails, [FromBody] PaymentDetailsModel model)
|
|
{
|
|
List<PaymentDetailsModel> objListfullDetails = new List<PaymentDetailsModel>();
|
|
try
|
|
{
|
|
|
|
// TicketOpenModel objModel = new TicketOpenModel();
|
|
objTicketRepository = new TicketRepository(_connStr);
|
|
objListfullDetails = objTicketRepository.GetPaymentDetailsHistory(model);
|
|
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("TicketAcceptOrDecliend_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
|
|
return objListfullDetails;
|
|
}
|
|
|
|
public string Get(string ticketId)
|
|
{
|
|
string status = "";
|
|
objTicketRepository = new TicketRepository(_connStr);
|
|
status = objTicketRepository.GetTicketPrevStatusByTicketId(ticketId);
|
|
return status;
|
|
}
|
|
|
|
public string Get(string paymentstatus, string ticketId)
|
|
{
|
|
string status = "";
|
|
objTicketRepository = new TicketRepository(_connStr);
|
|
status = objTicketRepository.GetPaymentStatusByTicketId(ticketId);
|
|
return status;
|
|
}
|
|
public string Get()
|
|
{
|
|
List<PaymentDetailsModel> objListfullDetails = new List<PaymentDetailsModel>();
|
|
try
|
|
{
|
|
string fileName = null;
|
|
bool isCreated = false;
|
|
// TicketOpenModel objModel = new TicketOpenModel();
|
|
objTicketRepository = new TicketRepository(_connStr);
|
|
objListfullDetails = objTicketRepository.GetAllPaymentDetailsHistory();
|
|
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 = "Payment Date";
|
|
ds.Tables[0].Columns[1].ColumnName = "Time";
|
|
ds.Tables[0].Columns[2].ColumnName = "Paid By";
|
|
ds.Tables[0].Columns[3].ColumnName = "Mobile number";
|
|
ds.Tables[0].Columns[4].ColumnName = "Paid Amount";
|
|
ds.Tables[0].Columns[5].ColumnName = "Mode Of Payment";
|
|
ds.Tables[0].Columns[6].ColumnName = "Remarks";
|
|
ds.Tables[0].Columns[7].ColumnName = "Ticket Id";
|
|
ds.Tables[0].Columns[8].ColumnName = "Created by";
|
|
ds.Tables[0].Columns[9].ColumnName = "Payment updated By";
|
|
//ds.Tables[0].Columns[11].ColumnName = "Reassignment Time";
|
|
//ds.Tables[0].Columns[12].ColumnName = "Dealer Code";
|
|
//ds.Tables[0].Columns[13].ColumnName = "Dealer Name";
|
|
// ds.Tables[0].Columns.RemoveAt(7);
|
|
// ds.Tables[0].Columns.RemoveAt(8);
|
|
//ds.Tables[0].Columns.RemoveAt(9);
|
|
// ds.Tables[0].Columns.RemoveAt(10);
|
|
// ds.Tables[0].Columns.RemoveAt(11);
|
|
// ds.Tables[0].Columns.RemoveAt(12);
|
|
// ds.Tables[0].Columns.RemoveAt(13);
|
|
// ds.Tables[0].Columns[30].ColumnName = "";
|
|
ExcelUtility objExcelUtility = new ExcelHelper.ExcelUtility();
|
|
List<WorkbookMappingModel> workbokkMapping = new List<WorkbookMappingModel>();
|
|
|
|
string _excelExportPathOnServer = ConfigurationManager.AppSettings["excelExportPathOnServer"].ToString();
|
|
fileName = "paymentReport_" + 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 List<PaymentDropDown> Post([FromUri] string getPaymentDetails, [FromUri] string dropdown, [FromUri] string option)
|
|
{
|
|
// write data log into file
|
|
|
|
try
|
|
{
|
|
List<PaymentDropDown> objListfullDetails = new List<PaymentDropDown>();
|
|
// TicketOpenModel objModel = new TicketOpenModel();
|
|
objTicketRepository = new TicketRepository(_connStr);
|
|
objListfullDetails = objTicketRepository.getPaymentDropDown();
|
|
|
|
return objListfullDetails;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("TicketAcceptOrDecliend_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
|