309 lines
9.9 KiB
C#
309 lines
9.9 KiB
C#
|
|
|
|
namespace VECV_WebApi.Controllers.BoatAPI
|
|
{
|
|
using DocumentFormat.OpenXml.Bibliography;
|
|
using DocumentFormat.OpenXml.EMMA;
|
|
using DocumentFormat.OpenXml.Office2010.ExcelAc;
|
|
using DocumentFormat.OpenXml.Wordprocessing;
|
|
using ExcelHelper;
|
|
#region Namespaces
|
|
|
|
using LoggingHelper;
|
|
using Microsoft.Ajax.Utilities;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Net.Configuration;
|
|
using System.Web;
|
|
using System.Web.Helpers;
|
|
using System.Web.Http;
|
|
using System.Web.Http.Results;
|
|
using System.Web.Mvc;
|
|
using VECV_WebApi.Common;
|
|
using VECV_WebApi.CommonAuthorization;
|
|
using VECV_WebApi.Models.BoatAPIModel;
|
|
using VECV_WebApi.Models.BoatAPIRepository;
|
|
using VECV_WebApi.Models.Notification;
|
|
using VECV_WebApi.Models.Ticket;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// This controller contain ticket related api
|
|
/// </summary>
|
|
|
|
[JwtAuthentication]
|
|
[System.Web.Http.Authorize]
|
|
[RoutePrefix("api/ai-boat")]
|
|
public class BoatAPIController : 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"]);
|
|
|
|
string _appName = (ConfigurationManager.AppSettings["ApplicationName"]);
|
|
|
|
/// <summary>
|
|
/// making the Database connection string available to this class
|
|
/// </summary>
|
|
private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString();
|
|
|
|
#endregion
|
|
|
|
|
|
#region APIs
|
|
|
|
[System.Web.Http.HttpPost]
|
|
[System.Web.Http.Route("Ticket_detail")]
|
|
/*{
|
|
"TicketId": "T123456",
|
|
"Reg_No": "MH12AB1234"
|
|
}*/
|
|
public IHttpActionResult Ticket_detail([FromBody] TicketDetailsRequestModel model)
|
|
{
|
|
TicketDetailsResponseModel objTicketDetailsResponseModel = new TicketDetailsResponseModel();
|
|
if (model == null)
|
|
return BadRequest("Request body is missing or invalid.");
|
|
try
|
|
{
|
|
BoatAPIRepository objBoatAPI = new BoatAPIRepository(_connStr);
|
|
objTicketDetailsResponseModel = objBoatAPI.GetTicketDetails(model);
|
|
return Ok(objTicketDetailsResponseModel);
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("BoatAPIController Ticket_detail", Ex.Message, path, errorlogtf);
|
|
return Ok($"Received: Error = {Ex.Message}");
|
|
}
|
|
}
|
|
|
|
[System.Web.Http.HttpPost]
|
|
[System.Web.Http.Route("UpdateRemarks")]
|
|
public IHttpActionResult UpdateRemarks([FromBody] updateRemarksRequestModel model)
|
|
{
|
|
|
|
ResponseModel objResponseModel = new ResponseModel();
|
|
|
|
if (model == null)
|
|
return BadRequest("Request body is missing or invalid.");
|
|
try
|
|
{
|
|
BoatAPIRepository objBoatAPI = new BoatAPIRepository(_connStr);
|
|
string str = objBoatAPI.InsertBoatComment(model);
|
|
objResponseModel.Status = "true";
|
|
objResponseModel.Message = "Remarks Updated Successfully";
|
|
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("BoatAPIController UpdateRemarks", Ex.Message, path, errorlogtf);
|
|
|
|
objResponseModel.Status = "false";
|
|
objResponseModel.Message = Ex.Message;
|
|
}
|
|
return Ok(objResponseModel);
|
|
}
|
|
|
|
[System.Web.Http.HttpPost]
|
|
[System.Web.Http.Route("preclosureUpdate")]
|
|
|
|
|
|
public IHttpActionResult preclosureUpdate([FromBody] preClosureUpdateRequestModel model)
|
|
{
|
|
ResponseModel objResponseModel = new ResponseModel();
|
|
|
|
|
|
if (model == null)
|
|
return BadRequest("Request body is missing or invalid.");
|
|
try
|
|
|
|
{
|
|
TicketWhatsupAPIModel objTicketWhatsupAPIModel = new TicketWhatsupAPIModel();
|
|
NotificationRepository oNotificationRepository = new NotificationRepository(_connStr);
|
|
objTicketWhatsupAPIModel = oNotificationRepository.GetTicketStatusByTicketId(model.Ticket_Id.Trim());
|
|
|
|
|
|
InsertOpenTicket requestmodel = new InsertOpenTicket();
|
|
requestmodel.ChassisNo = "DUMMYCHASSISEOS";
|
|
requestmodel.LastModifiedBy = "autopreclosure.vecv.in";
|
|
requestmodel.OdometerReading = Convert.ToDouble(model.OdoMeter_reading);
|
|
requestmodel.preclosure_reason = model.preclosure_reason;
|
|
requestmodel.SuggestionComment = model.SuggestionComment;
|
|
requestmodel.TicketId = objTicketWhatsupAPIModel.TicketId;
|
|
requestmodel.TicketIdAlias = model.SuggestionComment;
|
|
requestmodel.VehicleRegistrationNumber = objTicketWhatsupAPIModel.VehicleRegisterNumber;
|
|
requestmodel.VehicleType = "Haulage";
|
|
requestmodel.TicketStatus = 4;
|
|
BoatAPIRepository objBoatAPI = new BoatAPIRepository(_connStr);
|
|
InsertOpenTicket objInsertOpenTicket=new InsertOpenTicket();
|
|
objInsertOpenTicket= objBoatAPI.UpdateOpenTicketaBoat(requestmodel);
|
|
|
|
|
|
objResponseModel.Status = "true";
|
|
objResponseModel.Message = "Ticket Preclose Successfully";
|
|
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("BoatAPIController preclosureUpdate", Ex.Message, path, errorlogtf);
|
|
|
|
objResponseModel.Status = "false";
|
|
objResponseModel.Message = Ex.Message;
|
|
}
|
|
return Ok(objResponseModel);
|
|
|
|
}
|
|
|
|
[System.Web.Http.HttpPost]
|
|
[System.Web.Http.Route("getVanList")]
|
|
public IHttpActionResult getVanList([FromBody] VanListRequestModel model)
|
|
{
|
|
List<VanListResponseModel> objVanListResponseModel = new List<VanListResponseModel>();
|
|
|
|
if (model == null)
|
|
return BadRequest("Request body is missing or invalid.");
|
|
|
|
|
|
try
|
|
{
|
|
BoatAPIRepository objBoatAPI = new BoatAPIRepository(_connStr);
|
|
objVanListResponseModel = objBoatAPI.GetVanListBoatAPI(model);
|
|
return Ok(objVanListResponseModel);
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("BoatAPIController getVanList", Ex.Message, path, errorlogtf);
|
|
return Ok($"Received: Error = {Ex.Message}");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
[System.Web.Http.HttpPost]
|
|
[System.Web.Http.Route("assignvan")]
|
|
public IHttpActionResult assignvan([FromBody] AssignVanRequestModel model)
|
|
{
|
|
if (model == null)
|
|
return BadRequest("Request body is missing or invalid.");
|
|
ResponseModel objResponseModel = new ResponseModel();
|
|
|
|
|
|
try
|
|
{
|
|
BoatAPIRepository objBoatAPI = new BoatAPIRepository(_connStr);
|
|
VanDetailsRequestModel objVanDetailsRequestModel = new VanDetailsRequestModel();
|
|
TicketRepository objTicketRepository = new TicketRepository(_connStr);
|
|
TicketWhatsupAPIModel objTicketWhatsupAPIModel = new TicketWhatsupAPIModel();
|
|
NotificationRepository oNotificationRepository = new NotificationRepository(_connStr);
|
|
if (model.Type == "Reg_no")
|
|
{
|
|
objVanDetailsRequestModel.Reg_no = model.Value;
|
|
}
|
|
|
|
else
|
|
{
|
|
objVanDetailsRequestModel.Liscensce_key = model.Value;
|
|
}
|
|
objTicketWhatsupAPIModel = oNotificationRepository.GetTicketStatusByTicketId(model.TicketIdAlias.Trim());
|
|
// Licsecsce_Key
|
|
VanDetailsResponseModel objVanDetailsResponseModel = new VanDetailsResponseModel();
|
|
|
|
|
|
objVanDetailsResponseModel = objBoatAPI.Getvandetailsbyfilter(objVanDetailsRequestModel);
|
|
|
|
|
|
|
|
string regno = objTicketWhatsupAPIModel.VehicleRegisterNumber;
|
|
InsertOpenTicket objModel = new InsertOpenTicket();
|
|
|
|
try
|
|
{
|
|
objModel.AssignedToUserLattitude = objVanDetailsResponseModel.Latitude;
|
|
objModel.AssignedToUserLongitude = objVanDetailsResponseModel.Longitude;
|
|
objModel.TicketStatusAlias = "new";
|
|
objModel.TicketStatus = 1;
|
|
objModel.OtherRemarks = "assign van";
|
|
objModel.Message = "assign van";
|
|
objModel.AssignedTo = "van";
|
|
objModel.EstimateDistance = "10";
|
|
|
|
//model.Token = model.Token;
|
|
objModel = objTicketRepository.UpdateOpenTicketWeb(objModel);
|
|
|
|
objModel.Token = "teramatrix";
|
|
objModel.TicketStatus = 2;
|
|
objModel.TicketStatusAlias = "assigned";
|
|
objModel.OtherRemarks = "assign van";
|
|
objModel.Message = "assign van";
|
|
objModel.AssignedTo = "van";
|
|
objModel.EstimateDistance = "10";
|
|
objModel.TicketIdAlias = model.TicketIdAlias;
|
|
objModel.VehicleRegistrationNumber = objVanDetailsResponseModel.Reg_no;
|
|
objModel.AssignedToUserLattitude = objVanDetailsResponseModel.Latitude;
|
|
objModel.AssignedToUserLongitude = objVanDetailsResponseModel.Longitude;
|
|
objModel = objTicketRepository.UpdateOpenTicketWeb(objModel);
|
|
|
|
objResponseModel.Status = "true";
|
|
objResponseModel.Message = "Ticket Re-Assign Successfully";
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("getVanList assignvan", Ex.Message, path, errorlogtf);
|
|
|
|
objResponseModel.Status = "false";
|
|
objResponseModel.Message = Ex.Message;
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("BoatAPIController getVanList", Ex.Message, path, errorlogtf);
|
|
return Ok($"Received: Error = {Ex.Message}");
|
|
}
|
|
return Ok(objResponseModel);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
}
|