596 lines
30 KiB
C#
596 lines
30 KiB
C#
namespace VECV_WebApi.Controllers.DTCData
|
|
{
|
|
using ExcelHelper;
|
|
#region Namespaces
|
|
|
|
using LoggingHelper;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using RestSharp;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Reflection;
|
|
using System.Web;
|
|
using System.Web.Http;
|
|
using System.Web.Mvc;
|
|
using System.Web.Script.Serialization;
|
|
using VECV_WebApi.Models.EmailServices;
|
|
using VECV_WebApi.Models.Sync;
|
|
using VECV_WebApi.Models.Ticket;
|
|
|
|
#endregion
|
|
|
|
|
|
public class DTCDataController : 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 Global Repository object available to this class
|
|
/// </summary>
|
|
GlobalRepository objGlobalRepository = new GlobalRepository("");
|
|
|
|
/// <summary>
|
|
/// making Sync Repository object available to this class
|
|
/// </summary>
|
|
SyncRepository objSyncRepository;
|
|
|
|
/// <summary>
|
|
/// making the Database connection string available to this class
|
|
/// </summary>
|
|
private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString();
|
|
|
|
#endregion
|
|
|
|
|
|
#region APIs
|
|
public string Get([FromUri] string dtcDta)
|
|
{
|
|
var clientVehicleType = new RestClient("https://protech.vecv.net/ProTechApp/vehicleParameter/parameterDetail");
|
|
clientVehicleType.Timeout = -1;
|
|
var requestVehicleType = new RestRequest(Method.POST);
|
|
ServicePointManager.Expect100Continue = true;
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
|
|
| SecurityProtocolType.Tls11
|
|
| SecurityProtocolType.Tls12
|
|
| SecurityProtocolType.Ssl3
|
|
| (SecurityProtocolType)3072;
|
|
string customerName = "";
|
|
string casenumber = "";
|
|
string deviceId = "";
|
|
string jsonAuthVariable = "{\"chassisNum\":\"" + dtcDta + "\",\n\"customerName\":\"\"" + customerName + ",\n\"casenumber\":\"\"" + casenumber + ",\n\"deviceId\":\"\"" + deviceId + "}";
|
|
requestVehicleType.AddHeader("Content-Type", "application/json");
|
|
requestVehicleType.AddParameter("application/json", jsonAuthVariable, ParameterType.RequestBody);
|
|
IRestResponse responseVehicleType = clientVehicleType.Execute(requestVehicleType);
|
|
Console.WriteLine(responseVehicleType.Content);
|
|
var stringvehcileResultVehicleType = responseVehicleType.Content.ToString();
|
|
string strdevicetype = "";
|
|
if (stringvehcileResultVehicleType.ToString() == "[]")
|
|
{
|
|
strdevicetype = "";
|
|
|
|
}
|
|
else
|
|
{
|
|
JArray jsondatavehicletype = (JArray)JsonConvert.DeserializeObject(stringvehcileResultVehicleType);
|
|
// JArray vehicletype = (JArray)jsondatavehicletype.First["vehicleDetail"];
|
|
string json = jsondatavehicletype.First["vehicleDetail"].ToString();
|
|
var obj = JObject.Parse(json);
|
|
strdevicetype = obj["devicetype"].ToString();
|
|
}
|
|
return strdevicetype;
|
|
|
|
}
|
|
public List<DTCRawDataModel> Get([FromUri] string devicetype, [FromUri] string chassisnumber, [FromUri] string startdate, [FromUri] string enddate)
|
|
{
|
|
List<DTCRawDataModel> dtcrawlist = new List<DTCRawDataModel>();
|
|
var client = new RestClient("https://protech.vecv.net/ProTechApp/vehicleDtcDetail/dtcRawDetail");
|
|
client.Timeout = -1;
|
|
var request = new RestRequest(Method.POST);
|
|
ServicePointManager.Expect100Continue = true;
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
|
|
| SecurityProtocolType.Tls11
|
|
| SecurityProtocolType.Tls12
|
|
| SecurityProtocolType.Ssl3
|
|
| (SecurityProtocolType)3072;
|
|
startdate = startdate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["startTimeFormat"]);
|
|
enddate = enddate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["endTimeFormat"]);
|
|
|
|
string emissionNorms = "";
|
|
string engineNo = "";
|
|
string segment = "";
|
|
string dtcStatus = "";
|
|
string dtcCode = "";
|
|
|
|
DateTime dtstart = Convert.ToDateTime(startdate);
|
|
DateTime dtEnd = Convert.ToDateTime(enddate);
|
|
string strstartdate = string.Format("{0:s}", dtstart);
|
|
string strenddate = string.Format("{0:s}", dtEnd);
|
|
request.AddHeader("Content-Type", "application/json");
|
|
string jsonAuthVariable = "{\"chassisNo\":\"" + chassisnumber + "\",\n\"deviceType\":\"" + devicetype + "\",\n\"endDate\":\"" + strenddate + "\",\n\"startDate\":\"" + strstartdate + "\",\n\"emissionNorms\":\"\"" + emissionNorms + ",\n\"segment\":\"\"" + segment + ", \n\"dtcStatus\":\"\"" + dtcStatus + " ,\n\"engineNo\":\"\"" + engineNo + ",\n\"dtcCode\":\"\"" + dtcCode + "}";
|
|
request.AddHeader("Content-Type", "application/json");
|
|
|
|
request.AddParameter("application/json", jsonAuthVariable, ParameterType.RequestBody);
|
|
IRestResponse response = client.Execute(request);
|
|
Console.WriteLine(response.Content);
|
|
var stringvehcileResult = response.Content.ToString();
|
|
var dtcdetails = string.Concat(stringvehcileResult.Skip(1).Take(stringvehcileResult.Length - 2));
|
|
JArray jsondata = (JArray)JsonConvert.DeserializeObject(dtcdetails);
|
|
dtcrawlist = jsondata.ToObject<List<DTCRawDataModel>>();
|
|
|
|
//var result = jsondata.CastTo<List<DTCRawDataModel>>();
|
|
//List<DTCRawDataModel> items = (jsondata).Select(x => new DTCRawDataModel
|
|
//{
|
|
// chassisNo = (string)x["chassisNo"],
|
|
// engineNo = (string)x["engineNo"]
|
|
//}).ToList();
|
|
return dtcrawlist;
|
|
|
|
|
|
}
|
|
|
|
public List<DTCRawDataModelWabco> Get([FromUri] string devicetype, [FromUri] string chassisnumber, [FromUri] string startdate, [FromUri] string enddate, [FromUri] string iswabco)
|
|
{
|
|
|
|
List<DTCRawDataModelWabco> dtcrawlist = new List<DTCRawDataModelWabco>();
|
|
|
|
var client = new RestClient("https://protech.vecv.net/ProTechApp/vehicleDtcDetail/dtcRawDetail");
|
|
client.Timeout = -1;
|
|
var request = new RestRequest(Method.POST);
|
|
ServicePointManager.Expect100Continue = true;
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
|
|
| SecurityProtocolType.Tls11
|
|
| SecurityProtocolType.Tls12
|
|
| SecurityProtocolType.Ssl3
|
|
| (SecurityProtocolType)3072;
|
|
// string endDate = "2022-11-30 16:19:24";
|
|
// string startDate = "2022-10-30 16:19:24";
|
|
startdate = startdate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["startTimeFormat"]);
|
|
enddate = enddate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["endTimeFormat"]);
|
|
|
|
string emissionNorms = "";
|
|
string engineNo = "";
|
|
string segment = "";
|
|
string dtcStatus = "";
|
|
string dtcCode = "";
|
|
DateTime dtstart = Convert.ToDateTime(startdate);
|
|
DateTime dtEnd = Convert.ToDateTime(enddate);
|
|
string strstartdate = string.Format("{0:s}", dtstart);
|
|
string strenddate = string.Format("{0:s}", dtEnd);
|
|
request.AddHeader("Content-Type", "application/json");
|
|
string jsonAuthVariable = "{\"chassisNo\":\"" + chassisnumber + "\",\n\"deviceType\":\"" + devicetype + "\",\n\"endDate\":\"" + strenddate + "\",\n\"startDate\":\"" + strstartdate + "\",\n\"emissionNorms\":\"\"" + emissionNorms + ",\n\"segment\":\"\"" + segment + ", \n\"dtcStatus\":\"\"" + dtcStatus + " ,\n\"engineNo\":\"\"" + engineNo + ",\n\"dtcCode\":\"\"" + dtcCode + "}";
|
|
request.AddParameter("application/json", jsonAuthVariable, ParameterType.RequestBody);
|
|
IRestResponse response = client.Execute(request);
|
|
Console.WriteLine(response.Content);
|
|
var stringvehcileResult = response.Content.ToString();
|
|
var dtcdetails = string.Concat(stringvehcileResult.Skip(1).Take(stringvehcileResult.Length - 2));
|
|
JArray jsondata = (JArray)JsonConvert.DeserializeObject(dtcdetails);
|
|
dtcrawlist = jsondata.ToObject<List<DTCRawDataModelWabco>>();
|
|
string strdtccode = "";
|
|
foreach (var item in dtcrawlist)
|
|
{
|
|
strdtccode += item.dtccode + ',';
|
|
}
|
|
strdtccode = strdtccode.TrimEnd(',');
|
|
objSyncRepository = new SyncRepository(_connStr);
|
|
string[] strings = strdtccode.Split(',');
|
|
// int[] ints = Array.ConvertAll(strings, s => int.Parse(s));
|
|
List<DTCCodeMaster> objDTCcode = new List<DTCCodeMaster>();
|
|
objDTCcode = objSyncRepository.GetAllDtcDescriptionListDataSet(strings);
|
|
foreach (var ema in dtcrawlist)
|
|
{
|
|
if (ema.dtccode == null)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
if (objDTCcode.Count() == 0) { }
|
|
else
|
|
{
|
|
var isexist = objDTCcode.Any(a => ema.dtccode.Contains(a.DTCCode));
|
|
//var isexist = objDTCcode.Contains(ema.dtccode.ToString()).ToString();
|
|
if (isexist == true)
|
|
{
|
|
ema.description = objDTCcode.Where(j => j.DTCCode == ema.dtccode).DefaultIfEmpty().FirstOrDefault().Description;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
return dtcrawlist;
|
|
|
|
|
|
}
|
|
|
|
public string Post([FromUri] string devicetype, [FromUri] string chassisnumber, [FromUri] string startdate, [FromUri] string enddate, [FromUri] string iswabco)
|
|
{
|
|
|
|
List<DTCRawDataModelWabco> dtcrawlist = new List<DTCRawDataModelWabco>();
|
|
|
|
var client = new RestClient("https://protech.vecv.net/ProTechApp/vehicleDtcDetail/dtcRawDetail");
|
|
client.Timeout = -1;
|
|
var request = new RestRequest(Method.POST);
|
|
ServicePointManager.Expect100Continue = true;
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
|
|
| SecurityProtocolType.Tls11
|
|
| SecurityProtocolType.Tls12
|
|
| SecurityProtocolType.Ssl3
|
|
| (SecurityProtocolType)3072;
|
|
// string endDate = "2022-11-30 16:19:24";
|
|
// string startDate = "2022-10-30 16:19:24";
|
|
startdate = startdate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["startTimeFormat"]);
|
|
enddate = enddate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["endTimeFormat"]);
|
|
|
|
string emissionNorms = "";
|
|
string engineNo = "";
|
|
string segment = "";
|
|
string dtcStatus = "";
|
|
string dtcCode = "";
|
|
bool isCreated = false;
|
|
request.AddHeader("Content-Type", "application/json");
|
|
DateTime dtstart = Convert.ToDateTime(startdate);
|
|
DateTime dtEnd = Convert.ToDateTime(enddate);
|
|
string strstartdate = string.Format("{0:s}", dtstart);
|
|
string strenddate = string.Format("{0:s}", dtEnd);
|
|
request.AddHeader("Content-Type", "application/json");
|
|
string jsonAuthVariable = "{\"chassisNo\":\"" + chassisnumber + "\",\n\"deviceType\":\"" + devicetype + "\",\n\"endDate\":\"" + strenddate + "\",\n\"startDate\":\"" + strstartdate + "\",\n\"emissionNorms\":\"\"" + emissionNorms + ",\n\"segment\":\"\"" + segment + ", \n\"dtcStatus\":\"\"" + dtcStatus + " ,\n\"engineNo\":\"\"" + engineNo + ",\n\"dtcCode\":\"\"" + dtcCode + "}";
|
|
|
|
request.AddParameter("application/json", jsonAuthVariable, ParameterType.RequestBody);
|
|
IRestResponse response = client.Execute(request);
|
|
Console.WriteLine(response.Content);
|
|
var stringvehcileResult = response.Content.ToString();
|
|
var dtcdetails = string.Concat(stringvehcileResult.Skip(1).Take(stringvehcileResult.Length - 2));
|
|
JArray jsondata = (JArray)JsonConvert.DeserializeObject(dtcdetails);
|
|
dtcrawlist = jsondata.ToObject<List<DTCRawDataModelWabco>>();
|
|
string strdtccode = "";
|
|
foreach (var item in dtcrawlist)
|
|
{
|
|
strdtccode += item.dtccode + ',';
|
|
}
|
|
strdtccode = strdtccode.TrimEnd(',');
|
|
objSyncRepository = new SyncRepository(_connStr);
|
|
string[] strings = strdtccode.Split(',');
|
|
// int[] ints = Array.ConvertAll(strings, s => int.Parse(s));
|
|
List<DTCCodeMaster> objDTCcode = new List<DTCCodeMaster>();
|
|
objDTCcode = objSyncRepository.GetAllDtcDescriptionListDataSet(strings);
|
|
foreach (var ema in dtcrawlist)
|
|
{
|
|
if (ema.dtccode == null)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
if (objDTCcode.Count() == 0) { }
|
|
else
|
|
{
|
|
var isexist = objDTCcode.Any(a => ema.dtccode.Contains(a.DTCCode));
|
|
//var isexist = objDTCcode.Contains(ema.dtccode.ToString()).ToString();
|
|
if (isexist == true)
|
|
{
|
|
ema.description = objDTCcode.Where(j => j.DTCCode == ema.dtccode).DefaultIfEmpty().FirstOrDefault().Description;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
DataTable OpenTicketTable = dtcrawlist.ToDataTable();
|
|
Int32 OpenTicketTableColumnCount = OpenTicketTable.Columns.Count - 1;
|
|
DataSet ds = new DataSet();
|
|
ds.Tables.Add(OpenTicketTable);
|
|
ds.Tables[0].Columns[0].ColumnName = "Chassis No";
|
|
ds.Tables[0].Columns[1].ColumnName = "Emission Norms";
|
|
ds.Tables[0].Columns[2].ColumnName = "Segment";
|
|
ds.Tables[0].Columns[3].ColumnName = "Engine No";
|
|
ds.Tables[0].Columns[4].ColumnName = "Model";
|
|
ds.Tables[0].Columns[5].ColumnName = "Chassis Id";
|
|
ds.Tables[0].Columns[6].ColumnName = "Device ID";
|
|
ds.Tables[0].Columns[7].ColumnName = "Occurance Count";
|
|
ds.Tables[0].Columns[8].ColumnName = "Spn";
|
|
ds.Tables[0].Columns[9].ColumnName = "Dtc Code";
|
|
ds.Tables[0].Columns[14].ColumnName = "Description";
|
|
ds.Tables[0].Columns[10].ColumnName = "Dtc Occurance Date";
|
|
ds.Tables[0].Columns[11].ColumnName = "Case Number";
|
|
ds.Tables[0].Columns[12].ColumnName = "Dtc Status";
|
|
ds.Tables[0].Columns[13].ColumnName = "Packet DateTime";
|
|
ExcelUtility objExcelUtility = new ExcelHelper.ExcelUtility();
|
|
List<WorkbookMappingModel> workbokkMapping = new List<WorkbookMappingModel>();
|
|
|
|
string _excelExportPathOnServer = ConfigurationManager.AppSettings["excelExportPathOnServer"].ToString();
|
|
string fileName = "DtcData_" + DateTime.Now.ToString("ddMMMyyyyhhmmss") + ".xlsx";
|
|
workbokkMapping.Add(new WorkbookMappingModel { DataTableName = ds.Tables[0].TableName, WorkSheetName = "DTC Data 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 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"; }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
public string Post([FromUri] string devicetype, [FromUri] string chassisnumber, [FromUri] string startdate, [FromUri] string enddate)
|
|
{
|
|
string _excelExportPath = ConfigurationManager.AppSettings["excelExportPath"].ToString();
|
|
// write data log into file
|
|
bool isCreated = false;
|
|
List<DTCRawDataModel> dtcrawlist = new List<DTCRawDataModel>();
|
|
var client = new RestClient("https://protech.vecv.net/ProTechApp/vehicleDtcDetail/dtcRawDetail");
|
|
client.Timeout = -1;
|
|
var request = new RestRequest(Method.POST);
|
|
ServicePointManager.Expect100Continue = true;
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
|
|
| SecurityProtocolType.Tls11
|
|
| SecurityProtocolType.Tls12
|
|
| SecurityProtocolType.Ssl3
|
|
| (SecurityProtocolType)3072;
|
|
startdate = startdate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["startTimeFormat"]);
|
|
enddate = enddate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["endTimeFormat"]);
|
|
|
|
string emissionNorms = "";
|
|
string engineNo = "";
|
|
string segment = "";
|
|
string dtcStatus = "";
|
|
string dtcCode = "";
|
|
DateTime dtstart = Convert.ToDateTime(startdate);
|
|
DateTime dtEnd = Convert.ToDateTime(enddate);
|
|
string strstartdate = string.Format("{0:s}", dtstart);
|
|
string strenddate = string.Format("{0:s}", dtEnd);
|
|
string jsonAuthVariable = "{\"chassisNo\":\"" + chassisnumber + "\",\n\"deviceType\":\"" + devicetype + "\",\n\"endDate\":\"" + strenddate + "\",\n\"startDate\":\"" + strstartdate + "\",\n\"emissionNorms\":\"\"" + emissionNorms + ",\n\"segment\":\"\"" + segment + ", \n\"dtcStatus\":\"\"" + dtcStatus + " ,\n\"engineNo\":\"\"" + engineNo + ",\n\"dtcCode\":\"\"" + dtcCode + "}";
|
|
request.AddHeader("Content-Type", "application/json");
|
|
|
|
request.AddParameter("application/json", jsonAuthVariable, ParameterType.RequestBody);
|
|
IRestResponse response = client.Execute(request);
|
|
Console.WriteLine(response.Content);
|
|
var stringvehcileResult = response.Content.ToString();
|
|
var dtcdetails = string.Concat(stringvehcileResult.Skip(1).Take(stringvehcileResult.Length - 2));
|
|
JArray jsondata = (JArray)JsonConvert.DeserializeObject(dtcdetails);
|
|
dtcrawlist = jsondata.ToObject<List<DTCRawDataModel>>();
|
|
//foreach (var item in oList)
|
|
// {
|
|
// ticketCreationDateTime = item.PreClosureTime;
|
|
// string[] split_ticketCreationDateTime = ticketCreationDateTime.Split(' ');
|
|
// ticketCreationTime = split_ticketCreationDateTime[3];
|
|
|
|
// for (var count = 0; count < 12; count++)
|
|
// {
|
|
// //if ((DateTime.Parse("01/01/0001 " + ticketCreationTime) >= DateTime.Parse("01/01/0001 " + (2 * count) + ":00:00")) && (DateTime.Parse("01/01/0001 " + ticketCreationTime) <= DateTime.Parse("01/01/0001 " + ((2 * count) + 1) + ":59:59")))
|
|
// if (ticketCreationDateTime == "01 Jan 0001 05:30:00")
|
|
// {
|
|
// item.PreClosureTime = "";// (2 * count) + ":00 - " + ((2 * count) + 2) + ":00";
|
|
// break;
|
|
// }
|
|
// }
|
|
// // item.ChassisNo = item.chassis_number;
|
|
// }
|
|
|
|
//
|
|
DataTable OpenTicketTable = dtcrawlist.ToDataTable();
|
|
Int32 OpenTicketTableColumnCount = OpenTicketTable.Columns.Count - 1;
|
|
DataSet ds = new DataSet();
|
|
ds.Tables.Add(OpenTicketTable);
|
|
ds.Tables[0].Columns[0].ColumnName = "Chassis No";
|
|
ds.Tables[0].Columns[1].ColumnName = "Emission Norms";
|
|
ds.Tables[0].Columns[2].ColumnName = "Segment";
|
|
ds.Tables[0].Columns[3].ColumnName = "Engine No";
|
|
ds.Tables[0].Columns[4].ColumnName = "Model";
|
|
ds.Tables[0].Columns[5].ColumnName = "Chassis Id";
|
|
ds.Tables[0].Columns[6].ColumnName = "Dtc Code";
|
|
ds.Tables[0].Columns[7].ColumnName = "Dtc Status";
|
|
ds.Tables[0].Columns[8].ColumnName = "Description";
|
|
ds.Tables[0].Columns[9].ColumnName = "Occurance Count";
|
|
ds.Tables[0].Columns[10].ColumnName = "First Failure Time";
|
|
ds.Tables[0].Columns[11].ColumnName = "Last Failure Time";
|
|
ds.Tables[0].Columns[12].ColumnName = "Main Software";
|
|
ds.Tables[0].Columns[13].ColumnName = "Packet DateTime";
|
|
ExcelUtility objExcelUtility = new ExcelHelper.ExcelUtility();
|
|
List<WorkbookMappingModel> workbokkMapping = new List<WorkbookMappingModel>();
|
|
|
|
string _excelExportPathOnServer = ConfigurationManager.AppSettings["excelExportPathOnServer"].ToString();
|
|
string fileName = "DtcData_" + DateTime.Now.ToString("ddMMMyyyyhhmmss") + ".xlsx";
|
|
workbokkMapping.Add(new WorkbookMappingModel { DataTableName = ds.Tables[0].TableName, WorkSheetName = "DTC Data 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 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"; }
|
|
|
|
}
|
|
|
|
public string Post([FromUri] string ticketId, [FromUri] string startdate, [FromUri] string enddate)
|
|
{
|
|
// objDTCcode = objSyncRepository.GetAllDtcDescriptionListDataSet(strings);
|
|
// objTicketRepository = new TicketRepository(_connStr);
|
|
objSyncRepository = new SyncRepository(_connStr);
|
|
var strreg = ticketId.Contains("TICKETID");
|
|
string strchassinumber = "";
|
|
if (strreg == true)
|
|
{
|
|
strchassinumber = objSyncRepository.getChassisNumber(ticketId);
|
|
}
|
|
else
|
|
{
|
|
strchassinumber = objSyncRepository.getChassisNumberByRegnum(ticketId);
|
|
|
|
}
|
|
string[] res = strchassinumber.Split(',');
|
|
string strcount = "0";
|
|
if (res[1].ToLower() == "connected")
|
|
{
|
|
|
|
strcount = getDTcCount(res[0], startdate, enddate);
|
|
|
|
}
|
|
|
|
return strcount + "," + strchassinumber;
|
|
|
|
|
|
}
|
|
|
|
public List<DTCReport> Post([FromUri] string ticketId, [FromUri] string startdate,[FromBody] DTCReport model)
|
|
{
|
|
List<DTCReport> objDTCReport = new List<DTCReport>();
|
|
try {
|
|
|
|
TicketRepository objTicketRepository = new TicketRepository(_connStr);
|
|
objDTCReport = objTicketRepository.GetDTCReportByTicketId(model);
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
|
|
objLog.ErrorLogFile("DashboardController GetTileDashboardDataSet", Ex.Message, path, errorlogtf);
|
|
}
|
|
return objDTCReport;
|
|
}
|
|
|
|
public string Post([FromUri] string DtcCount, [FromUri] string ticketId, [FromUri] string startdate, [FromBody] DTCReport model)
|
|
{
|
|
string strcount = "0";
|
|
try
|
|
{
|
|
|
|
TicketRepository objTicketRepository = new TicketRepository(_connStr);
|
|
strcount = objTicketRepository.GetDTCReportCountByTicketId(model);
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
|
|
objLog.ErrorLogFile("DashboardController GetTileDashboardDataSet", Ex.Message, path, errorlogtf);
|
|
}
|
|
return strcount;
|
|
}
|
|
|
|
//public string Post([FromUri] string Regnum, [FromUri] string startdate, [FromUri] string enddate)
|
|
//{
|
|
// // objDTCcode = objSyncRepository.GetAllDtcDescriptionListDataSet(strings);
|
|
// // objTicketRepository = new TicketRepository(_connStr);
|
|
// objSyncRepository = new SyncRepository(_connStr);
|
|
// string strchassinumber = objSyncRepository.getChassisNumberByRegnum(Regnum);
|
|
// string strcount = getDTcCount( strchassinumber);
|
|
// return strchassinumber;
|
|
|
|
|
|
//}
|
|
|
|
public string getDTcCount(string strchassinumber,string startDate,string EndDate)
|
|
{
|
|
string count = "0";
|
|
var clientVehicleType = new RestClient("https://protech.vecv.net/ProTechApp/vehicleParameter/parameterDetail");
|
|
clientVehicleType.Timeout = -1;
|
|
var requestVehicleType = new RestRequest(Method.POST);
|
|
ServicePointManager.Expect100Continue = true;
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
|
|
| SecurityProtocolType.Tls11
|
|
| SecurityProtocolType.Tls12
|
|
| SecurityProtocolType.Ssl3
|
|
| (SecurityProtocolType)3072;
|
|
string customerName = "";
|
|
string casenumber = "";
|
|
string deviceId = "";
|
|
string jsonAuthVariable = "{\"chassisNum\":\"" + strchassinumber + "\",\n\"customerName\":\"\"" + customerName + ",\n\"casenumber\":\"\"" + casenumber + ",\n\"deviceId\":\"\"" + deviceId + "}";
|
|
requestVehicleType.AddHeader("Content-Type", "application/json");
|
|
requestVehicleType.AddParameter("application/json", jsonAuthVariable, ParameterType.RequestBody);
|
|
IRestResponse responseVehicleType = clientVehicleType.Execute(requestVehicleType);
|
|
Console.WriteLine(responseVehicleType.Content);
|
|
var stringvehcileResultVehicleType = responseVehicleType.Content.ToString();
|
|
string strdevicetype = "";
|
|
if (stringvehcileResultVehicleType.ToString() == "[]")
|
|
{
|
|
strdevicetype = "";
|
|
|
|
}
|
|
else
|
|
{
|
|
JArray jsondatavehicletype = (JArray)JsonConvert.DeserializeObject(stringvehcileResultVehicleType);
|
|
// JArray vehicletype = (JArray)jsondatavehicletype.First["vehicleDetail"];
|
|
string json = jsondatavehicletype.First["vehicleDetail"].ToString();
|
|
var obj = JObject.Parse(json);
|
|
strdevicetype = obj["devicetype"].ToString();
|
|
|
|
}
|
|
|
|
var client = new RestClient("https://protech.vecv.net/ProTechApp/vehicleDtcDetail/dtcRawDetail");
|
|
client.Timeout = -1;
|
|
var request = new RestRequest(Method.POST);
|
|
ServicePointManager.Expect100Continue = true;
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
|
|
| SecurityProtocolType.Tls11
|
|
| SecurityProtocolType.Tls12
|
|
| SecurityProtocolType.Ssl3
|
|
| (SecurityProtocolType)3072;
|
|
// string endDate = "2022-11-30 16:19:24";
|
|
// string startDate = "2022-10-30 16:19:24";
|
|
startDate = startDate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["startTimeFormat"]);
|
|
EndDate = EndDate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["endTimeFormat"]);
|
|
|
|
string emissionNorms = "";
|
|
string engineNo = "";
|
|
string segment = "";
|
|
string dtcStatus = "";
|
|
string dtcCode = "";
|
|
DateTime dtstart = Convert.ToDateTime(startDate);
|
|
DateTime dtEnd = Convert.ToDateTime(EndDate);
|
|
string strstartdate = string.Format("{0:s}", dtstart);
|
|
string strenddate = string.Format("{0:s}", dtEnd);
|
|
request.AddHeader("Content-Type", "application/json");
|
|
string jsonAuthVariablecount = "{\"chassisNo\":\"" + strchassinumber + "\",\n\"deviceType\":\"" + strdevicetype + "\",\n\"endDate\":\"" + strenddate + "\",\n\"startDate\":\"" + strstartdate + "\",\n\"emissionNorms\":\"\"" + emissionNorms + ",\n\"segment\":\"\"" + segment + ", \n\"dtcStatus\":\"\"" + dtcStatus + " ,\n\"engineNo\":\"\"" + engineNo + ",\n\"dtcCode\":\"\"" + dtcCode + "}";
|
|
request.AddParameter("application/json", jsonAuthVariablecount, ParameterType.RequestBody);
|
|
IRestResponse response = client.Execute(request);
|
|
Console.WriteLine(response.Content);
|
|
var stringvehcileResult = response.Content.ToString();
|
|
var dtcdetails = string.Concat(stringvehcileResult.Skip(1).Take(stringvehcileResult.Length - 2));
|
|
JArray jsondata = (JArray)JsonConvert.DeserializeObject(dtcdetails);
|
|
|
|
if (strdevicetype == "iswabco")
|
|
{
|
|
List<DTCRawDataModelWabco> dtcrawlist = new List<DTCRawDataModelWabco>();
|
|
dtcrawlist = jsondata.ToObject<List<DTCRawDataModelWabco>>();
|
|
count = dtcrawlist.Count().ToString();
|
|
}
|
|
else {
|
|
List<DTCRawDataModel> dtcrawlist = new List<DTCRawDataModel>();
|
|
dtcrawlist = jsondata.ToObject<List<DTCRawDataModel>>();
|
|
count = dtcrawlist.Count().ToString();
|
|
}
|
|
|
|
return count;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|