namespace VECV_WebApi.Models.Dashboard { #region Namespaces using DBHelper; using LoggingHelper; using Npgsql; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Web; using VECV_WebApi.Models.Authorization; #endregion #region Repository Class /// /// This class contain dashbord methods /// public class DashboardRepository { #region Global Variables /// /// making object of LoggingUtility class available to this class /// LoggingUtility objLog = new LoggingUtility(); /// /// making the data-log file path available to this class /// string path = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["PathLog"]); /// /// making error log file path available to this class /// string errorlogtf = (ConfigurationManager.AppSettings["ErrorLog"]); /// /// making the Database connection string available to this class /// private string _connStr; /// /// making Authentication Repository object available to this class /// AuthenticationRepository objAuthorization; #endregion #region Contructors /// /// Default constructor intialize connection string of tracking database /// public DashboardRepository(string connString) { this._connStr = connString; } #endregion #region API Methods /// /// To get tile dashboard KPIs /// /// date range and user info /// status and data public List GetTileDashboardDataSet(DashboardModel model) { List objList = new List(); DashboardModel objModel = new DashboardModel(); try { objAuthorization = new AuthenticationRepository(); if (objAuthorization.AuthenticateDevice(model.Token)) { DataSet ds = new DataSet(); NpgsqlParameter[] nSqlParam = new NpgsqlParameter[3]; nSqlParam[0] = new NpgsqlParameter("inuser_id ", model.UserId); nSqlParam[1] = new NpgsqlParameter("instart_date ", model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinutes))); nSqlParam[2] = new NpgsqlParameter("inend_date ", model.ToDate.AddMinutes(Convert.ToInt32(-model.UtcMinutes))); ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_dashboard_tile_data"], nSqlParam); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { objList = ds.Tables[0].AsEnumerable().Select(s => new DashboardModel { Key = s.Field("_key"), KeyName = s.Field("_key_name") == null ? "-" : s.Field("_key_name"), KeyValue = s.Field("_key_value") == null ? "-" : s.Field("_key_value"), Status = "1" }).ToList(); } } else { objModel.Key = "Eicher"; objModel.Key = "Truck"; objModel.Key = "Bus"; objList.Add(objModel); objModel.Key = "Volvo"; objModel.Key = "Car"; objModel.Key = "SUV"; objList.Add(objModel); } } else { objModel.Status = "0"; objModel.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString(); objList.Add(objModel); } return objList; } catch (Exception Ex) { objModel.Status = "0"; objModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message; objList.Add(objModel); objLog.ErrorLogFile("GetCustomerDetails", Ex.Message, path, errorlogtf); return objList; } } /// /// To get tile dashboard KPIs /// /// date range and user info /// status and data /// public NewDashboardModel GetTileNewDashboardDataSet(NewDashboardDataModel model) { NewDashboardModel objNewDashboardModel = new NewDashboardModel(); try { objAuthorization = new AuthenticationRepository(); if (objAuthorization.AuthenticateDevice(model.Token)) { DataSet ds = new DataSet(); // nSqlParam[8] = new NpgsqlParameter("indealer_val_str", result); //nSqlParam[7] = new NpgsqlParameter("inverticle_val", model.verticleVal); if (model.customerVal == null && model.fuel_type == null && model.dealerVal == null && model.emissionVal == null && model.regionVal == null && model.verticleVal == null) { NpgsqlParameter[] nSqlParam = new NpgsqlParameter[8]; nSqlParam[0] = new NpgsqlParameter("inuser_id ", model.UserId); nSqlParam[1] = new NpgsqlParameter("instart_date", model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam[2] = new NpgsqlParameter("inend_date", model.ToDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam[3] = new NpgsqlParameter("incustomer_val", model.customerVal); nSqlParam[4] = new NpgsqlParameter("indealer_val", model.dealerVal); nSqlParam[5] = new NpgsqlParameter("inemission_val", model.emissionVal); nSqlParam[6] = new NpgsqlParameter("inregion_val", model.regionVal); nSqlParam[7] = new NpgsqlParameter("inverticle_val", model.verticleVal); // nSqlParam[8] = new NpgsqlParameter("infuel_type", model.fuel_type); DateTime cutoffDate = new DateTime(2025, 8, 31); if (model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute)) <= cutoffDate) { ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_Newdashboard_tile_data"], nSqlParam); } else { ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_Newdashboard_tile_data_new"], nSqlParam); } if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { objNewDashboardModel.OpenTicket = ds.Tables[0].Rows[0]["open_ticket_count"].ToString(); // objNewDashboardModel.OpenTicket = "400"; objNewDashboardModel.OpenTicket24hours = ds.Tables[0].Rows[0]["open_ticket_24hours"].ToString(); objNewDashboardModel.AverageResolutionTime = ds.Tables[0].Rows[0]["average_resolution_time"].ToString(); objNewDashboardModel.AverageVanReachTime = ds.Tables[0].Rows[0]["average_van_reach_time"].ToString(); objNewDashboardModel.SLA1hrs = ds.Tables[0].Rows[0]["sla_1_hrs"].ToString(); // Double d = double(ds.Tables[0].Rows[0]["sla_1_hrs"].ToString()); // Double dc = Math.Round((Double)d, 2); objNewDashboardModel.SLA2hrs = ds.Tables[0].Rows[0]["sla_2_hrs"].ToString(); objNewDashboardModel.SLA3hrs = ds.Tables[0].Rows[0]["sla_3_hrs"].ToString(); objNewDashboardModel.SLAMoreThan3hrs = ds.Tables[0].Rows[0]["sla_more_than_3_hrs"].ToString(); objNewDashboardModel.SLARes1hrs = ds.Tables[0].Rows[0]["sla_res_1_hrs"].ToString(); objNewDashboardModel.SLARes3hrs = ds.Tables[0].Rows[0]["sla_res_3_hrs"].ToString(); objNewDashboardModel.SLA5hrs = ds.Tables[0].Rows[0]["sla_5_hrs"].ToString(); objNewDashboardModel.SLA7hrs = ds.Tables[0].Rows[0]["sla_7_hrs"].ToString(); objNewDashboardModel.SLA10hrs = ds.Tables[0].Rows[0]["sla_10_hrs"].ToString(); objNewDashboardModel.SLA12hrs = ds.Tables[0].Rows[0]["sla_12_hrs"].ToString(); objNewDashboardModel.SLA16hrs = ds.Tables[0].Rows[0]["sla_16_hrs"].ToString(); objNewDashboardModel.SLA18hrs = ds.Tables[0].Rows[0]["sla_18_hrs"].ToString(); objNewDashboardModel.SLAMoreThan18hrs = ds.Tables[0].Rows[0]["sla_more_than_18_hrs"].ToString(); objNewDashboardModel.TABsBusyCount = ds.Tables[0].Rows[0]["tabs_busy_count"].ToString(); objNewDashboardModel.TABsFreeCount = ds.Tables[0].Rows[0]["tabs_free_count"].ToString(); objNewDashboardModel.TABsOfflineMorethan7Days = ds.Tables[0].Rows[0]["tabs_free_count_7days"].ToString(); objNewDashboardModel.NewTicketCount = ds.Tables[0].Rows[0]["new_ticket_count"].ToString(); objNewDashboardModel.AssignedTicketCount = ds.Tables[0].Rows[0]["assigned_ticket_count"].ToString(); objNewDashboardModel.InprogressTicketCount = ds.Tables[0].Rows[0]["inprogress_ticket_count"].ToString(); objNewDashboardModel.ClosedTicketCount = ds.Tables[0].Rows[0]["closed_ticket_count"].ToString(); objNewDashboardModel.DeclinedTicketCount = ds.Tables[0].Rows[0]["declined_ticket_count"].ToString(); objNewDashboardModel.ActiveCount = ds.Tables[0].Rows[0]["active_count"].ToString(); objNewDashboardModel.BreakDownTickets = ds.Tables[0].Rows[0]["breakdown_tickets"].ToString(); objNewDashboardModel.CSat = ds.Tables[0].Rows[0]["csat"].ToString(); objNewDashboardModel.OppLostCount = ds.Tables[0].Rows[0]["Opplost_ticket_count"].ToString(); objNewDashboardModel.BreakDownTicketsBystatus = ds.Tables[0].Rows[0]["breakdown_tickets_by_status"].ToString(); objNewDashboardModel.TripStartCount = ds.Tables[0].Rows[0]["trip_start_count"].ToString(); objNewDashboardModel.PreclosureCount = ds.Tables[0].Rows[0]["preclosure_count"].ToString(); } } } else { // //NewDashboardModel objNewDashboardModel1 = new NewDashboardModel(); //objAuthorization = new AuthenticationRepository(); //if (objAuthorization.AuthenticateDevice(model.Token)) //{ DataSet ds1 = new DataSet(); NpgsqlParameter[] nSqlParam1 = new NpgsqlParameter[9]; nSqlParam1[0] = new NpgsqlParameter("inuser_id ", model.UserId); nSqlParam1[1] = new NpgsqlParameter("instart_date", model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam1[2] = new NpgsqlParameter("inend_date", model.ToDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam1[3] = new NpgsqlParameter("indealer_val", model.dealerVal); nSqlParam1[4] = new NpgsqlParameter("inregion_val", model.regionVal); nSqlParam1[5] = new NpgsqlParameter("inverticle_val", model.verticleVal); nSqlParam1[6] = new NpgsqlParameter("inemission_val", model.emissionVal); nSqlParam1[7] = new NpgsqlParameter("incustomer_val", model.customerVal); nSqlParam1[8] = new NpgsqlParameter("infuel_type", model.fuel_type); // nSqlParam1[9] = new NpgsqlParameter("in_modelno", model.modelNumber); DateTime cutoffDate = new DateTime(2025, 8, 31); if (model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute)) <= cutoffDate) { ds1 = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_newdashboard_tile_data_sorting"], nSqlParam1); } else { ds1 = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_newdashboard_tile_data_sorting_new"], nSqlParam1); } // ds1.Tables[0].DefaultView.RowFilter = "ticket_activity = '7'"; // DataTable dt = (ds.Tables[0].DefaultView).ToTable(); if (ds1.Tables.Count > 0) { if (ds1.Tables[0].Rows.Count > 0) { objNewDashboardModel.OpenTicket = ds1.Tables[0].Rows[0]["open_ticket_count"].ToString(); // objNewDashboardModel.OpenTicket = "400"; objNewDashboardModel.OpenTicket24hours = ds1.Tables[0].Rows[0]["open_ticket_24hours"].ToString(); objNewDashboardModel.AverageResolutionTime = ds1.Tables[0].Rows[0]["average_resolution_time"].ToString(); objNewDashboardModel.AverageVanReachTime = ds1.Tables[0].Rows[0]["average_van_reach_time"].ToString(); objNewDashboardModel.SLA1hrs = ds1.Tables[0].Rows[0]["sla_1_hrs"].ToString(); // Double d = double(ds.Tables[0].Rows[0]["sla_1_hrs"].ToString()); // Double dc = Math.Round((Double)d, 2); objNewDashboardModel.SLA2hrs = ds1.Tables[0].Rows[0]["sla_2_hrs"].ToString(); objNewDashboardModel.SLA3hrs = ds1.Tables[0].Rows[0]["sla_3_hrs"].ToString(); objNewDashboardModel.SLAMoreThan3hrs = ds1.Tables[0].Rows[0]["sla_more_than_3_hrs"].ToString(); objNewDashboardModel.SLARes1hrs = ds1.Tables[0].Rows[0]["sla_res_1_hrs"].ToString(); objNewDashboardModel.SLARes3hrs = ds1.Tables[0].Rows[0]["sla_res_3_hrs"].ToString(); objNewDashboardModel.SLA5hrs = ds1.Tables[0].Rows[0]["sla_5_hrs"].ToString(); objNewDashboardModel.SLA7hrs = ds1.Tables[0].Rows[0]["sla_7_hrs"].ToString(); objNewDashboardModel.SLA10hrs = ds1.Tables[0].Rows[0]["sla_10_hrs"].ToString(); objNewDashboardModel.SLA12hrs = ds1.Tables[0].Rows[0]["sla_12_hrs"].ToString(); objNewDashboardModel.SLA12hrs = ds1.Tables[0].Rows[0]["sla_12_hrs"].ToString(); objNewDashboardModel.SLA16hrs = ds1.Tables[0].Rows[0]["sla_16_hrs"].ToString(); objNewDashboardModel.SLA18hrs = ds1.Tables[0].Rows[0]["sla_18_hrs"].ToString(); objNewDashboardModel.SLAMoreThan18hrs = ds1.Tables[0].Rows[0]["sla_more_than_18_hrs"].ToString(); objNewDashboardModel.TABsBusyCount = ds1.Tables[0].Rows[0]["tabs_busy_count"].ToString(); objNewDashboardModel.TABsFreeCount = ds1.Tables[0].Rows[0]["tabs_free_count"].ToString(); objNewDashboardModel.TABsOfflineMorethan7Days = ds1.Tables[0].Rows[0]["tabs_free_count_7days"].ToString(); objNewDashboardModel.NewTicketCount = ds1.Tables[0].Rows[0]["new_ticket_count"].ToString(); objNewDashboardModel.AssignedTicketCount = ds1.Tables[0].Rows[0]["assigned_ticket_count"].ToString(); objNewDashboardModel.InprogressTicketCount = ds1.Tables[0].Rows[0]["inprogress_ticket_count"].ToString(); objNewDashboardModel.ClosedTicketCount = ds1.Tables[0].Rows[0]["closed_ticket_count"].ToString(); objNewDashboardModel.DeclinedTicketCount = ds1.Tables[0].Rows[0]["declined_ticket_count"].ToString(); objNewDashboardModel.ActiveCount = ds1.Tables[0].Rows[0]["active_count"].ToString(); objNewDashboardModel.BreakDownTickets = ds1.Tables[0].Rows[0]["breakdown_tickets"].ToString(); objNewDashboardModel.CSat = ds1.Tables[0].Rows[0]["csat"].ToString(); objNewDashboardModel.OppLostCount = ds1.Tables[0].Rows[0]["Opplost_ticket_count"].ToString(); objNewDashboardModel.BreakDownTicketsBystatus = ds1.Tables[0].Rows[0]["breakdown_tickets_by_status"].ToString(); objNewDashboardModel.TripStartCount = ds1.Tables[0].Rows[0]["trip_start_count"].ToString(); objNewDashboardModel.PreclosureCount = ds1.Tables[0].Rows[0]["preclosure_count"].ToString(); } } } } } catch (Exception Ex) { // write error log into file // objticketModel.Status = "0"; // objticketModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message; objLog.ErrorLogFile("GetTicketStatusByRegistrationNumber", Ex.Message, path, errorlogtf); return objNewDashboardModel; } return objNewDashboardModel; } /// /// To get customer details /// /// device and ticket info /// status and customer details public List GetDealerDetails(NewDashboardDataModel model) { List objList = new List(); try { DealerModel objNewDashboardModel = new DealerModel(); objAuthorization = new AuthenticationRepository(); if (objAuthorization.AuthenticateDevice(model.Token)) { DataSet ds = new DataSet(); if (model.customerVal == null && model.fuel_type == null && model.dealerVal == null && model.emissionVal == null && model.regionVal == null && model.verticleVal == null) { NpgsqlParameter[] nSqlParam1 = new NpgsqlParameter[4]; nSqlParam1[0] = new NpgsqlParameter("inuser_id ", model.UserId); nSqlParam1[1] = new NpgsqlParameter("instart_date", model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam1[2] = new NpgsqlParameter("inend_date", model.ToDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam1[3] = new NpgsqlParameter("inverticle_val", model.verticleVal); DateTime cutoffDate = new DateTime(2025, 8, 31); if (model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute)) <= cutoffDate) { ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_top_dealer_detail"], nSqlParam1); } else { ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_top_dealer_detail_new"], nSqlParam1); } } else { NpgsqlParameter[] nSqlParam1 = new NpgsqlParameter[9]; nSqlParam1[0] = new NpgsqlParameter("inuser_id ", model.UserId); nSqlParam1[1] = new NpgsqlParameter("instart_date", model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam1[2] = new NpgsqlParameter("inend_date", model.ToDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam1[3] = new NpgsqlParameter("inemission_val", model.emissionVal); nSqlParam1[4] = new NpgsqlParameter("inregion_val", model.regionVal); nSqlParam1[5] = new NpgsqlParameter("inverticle_val", model.verticleVal); nSqlParam1[6] = new NpgsqlParameter("incustomer_val", model.customerVal); nSqlParam1[7] = new NpgsqlParameter("indealer_val", model.dealerVal); nSqlParam1[8] = new NpgsqlParameter("infuel_type", model.fuel_type); // nSqlParam1[9] = new NpgsqlParameter("in_modelno", model.modelNumber); DateTime cutoffDate = new DateTime(2025, 8, 31); if (model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute)) <= cutoffDate) { ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_top_dealer_detail_sorting"], nSqlParam1); } else { ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_top_dealer_detail_sorting"], nSqlParam1); } } if (ds.Tables[0].Rows.Count > 0) { objList = ds.Tables[0].AsEnumerable().Select(s => new DealerModel { DealerName = s.Field("_dealer_name"), Region = s.Field("_region"), TicketCount = s.Field("_ticket_count"), DealerId = s.Field("_dealer_id"), }).ToList(); } } else { //objCustomerVehicleModel.Status = 0; // objCustomerVehicleModel.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString(); } return objList; } catch (Exception Ex) { // objNewDashboardModel = new CustomerVehicleModel(); // objNewDashboardModel.Status = 0; // objCustomerVehicleModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message; objLog.ErrorLogFile("GetCustomerDetails", Ex.Message, path, errorlogtf); return objList; } } public List GetDTCDetails(NewDashboardDataModel model) { List objList = new List(); try { DTCModel objNewDashboardModel = new DTCModel(); objAuthorization = new AuthenticationRepository(); if (objAuthorization.AuthenticateDevice(model.Token)) { DataSet ds = new DataSet(); if (model.customerVal == null && model.fuel_type == null && model.dealerVal == null && model.emissionVal == null && model.regionVal == null && model.verticleVal == null) { NpgsqlParameter[] nSqlParam1 = new NpgsqlParameter[4]; nSqlParam1[0] = new NpgsqlParameter("inuser_id ", model.UserId); nSqlParam1[1] = new NpgsqlParameter("instart_date", model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam1[2] = new NpgsqlParameter("inend_date", model.ToDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam1[3] = new NpgsqlParameter("inverticle_val", model.verticleVal); ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_top_dtc_detail"], nSqlParam1); } else { NpgsqlParameter[] nSqlParam1 = new NpgsqlParameter[9]; nSqlParam1[0] = new NpgsqlParameter("inuser_id ", model.UserId); nSqlParam1[1] = new NpgsqlParameter("instart_date", model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam1[2] = new NpgsqlParameter("inend_date", model.ToDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam1[3] = new NpgsqlParameter("inemission_val", model.emissionVal); nSqlParam1[4] = new NpgsqlParameter("inregion_val", model.regionVal); nSqlParam1[5] = new NpgsqlParameter("inverticle_val", model.verticleVal); nSqlParam1[6] = new NpgsqlParameter("incustomer_val", model.customerVal); nSqlParam1[7] = new NpgsqlParameter("indealer_val", model.dealerVal); nSqlParam1[8] = new NpgsqlParameter("infuel_type", model.fuel_type); // nSqlParam1[9] = new NpgsqlParameter("in_modelno", model.modelNumber); ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_top_dtc_detail_sorting"], nSqlParam1); } if (ds.Tables[0].Rows.Count > 0) { objList = ds.Tables[0].AsEnumerable().Select(s => new DTCModel { DTCCode = s.Field("_dtc_code"), DTCCount = s.Field("_dtc_count"), }).ToList(); } } else { //objCustomerVehicleModel.Status = 0; // objCustomerVehicleModel.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString(); } return objList; } catch (Exception Ex) { // objNewDashboardModel = new CustomerVehicleModel(); // objNewDashboardModel.Status = 0; // objCustomerVehicleModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message; objLog.ErrorLogFile("GetCustomerDetails", Ex.Message, path, errorlogtf); return objList; } } /// /// To get customer details /// /// device and ticket info /// status and customer details public List GetGraphDetails(NewDashboardDataModel model) { List objList = new List(); try { GraphModel objNewDashboardModel = new GraphModel(); objAuthorization = new AuthenticationRepository(); if (objAuthorization.AuthenticateDevice(model.Token)) { DataSet ds = new DataSet(); if (model.customerVal == null && model.fuel_type == null && model.dealerVal == null && model.emissionVal == null && model.regionVal == null && model.verticleVal == null) { NpgsqlParameter[] nSqlParam = new NpgsqlParameter[8]; nSqlParam[0] = new NpgsqlParameter("inuser_id ", model.UserId); nSqlParam[1] = new NpgsqlParameter("instart_date", model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam[2] = new NpgsqlParameter("inend_date", model.ToDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam[3] = new NpgsqlParameter("incustomer_val", model.customerVal); nSqlParam[4] = new NpgsqlParameter("indealer_val", model.dealerVal); nSqlParam[5] = new NpgsqlParameter("inemission_val", model.emissionVal); nSqlParam[6] = new NpgsqlParameter("inregion_val", model.regionVal); nSqlParam[7] = new NpgsqlParameter("inverticle_val", model.verticleVal); DateTime cutoffDate = new DateTime(2025, 8, 31); if (model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute)) <= cutoffDate) { ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_Graph_detail"], nSqlParam); } else { ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_Graph_detail_new"], nSqlParam); } } else { NpgsqlParameter[] nSqlParam = new NpgsqlParameter[9]; nSqlParam[0] = new NpgsqlParameter("inuser_id ", model.UserId); nSqlParam[1] = new NpgsqlParameter("instart_date", model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam[2] = new NpgsqlParameter("inend_date", model.ToDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam[3] = new NpgsqlParameter("inemission_val", model.emissionVal); nSqlParam[4] = new NpgsqlParameter("inregion_val", model.regionVal); nSqlParam[5] = new NpgsqlParameter("inverticle_val", model.verticleVal); nSqlParam[6] = new NpgsqlParameter("incustomer_val", model.customerVal); nSqlParam[7] = new NpgsqlParameter("indealer_val", model.dealerVal); nSqlParam[8] = new NpgsqlParameter("infuel_type", model.fuel_type); // nSqlParam[9] = new NpgsqlParameter("in_modelno", model.modelNumber); DateTime cutoffDate = new DateTime(2025, 8, 31); if (model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute)) <= cutoffDate) { ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_graph_detail_Sorting"], nSqlParam); } else { ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_graph_detail_Sorting_new"], nSqlParam); } } if (ds.Tables[0].Rows.Count > 0) { objList = ds.Tables[0].AsEnumerable().Select(s => new GraphModel { // objNewDashboardModel = s.Field("_customer_vehicle_is_owner"), //DealerName = model.TicketNo, RegionName = s.Field("_region_name"), count_25km = s.Field("_count_25km"), count_50km = s.Field("_count_50km"), count_100km = s.Field("_count_100km"), count_More_Than_100km = s.Field("_count_More_Than_100km"), }).ToList(); } } else { //objCustomerVehicleModel.Status = 0; // objCustomerVehicleModel.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString(); } return objList; } catch (Exception Ex) { // objNewDashboardModel = new CustomerVehicleModel(); // objNewDashboardModel.Status = 0; // objCustomerVehicleModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message; objLog.ErrorLogFile("GetCustomerDetails", Ex.Message, path, errorlogtf); return objList; } } public List GetAllDealerListDataSet(int[] dealers) { List objList = new List(); DashboardModel objModel = new DashboardModel(); try { objAuthorization = new AuthenticationRepository(); DataSet ds = new DataSet(); // NpgsqlParameter[] nSqlParam = new NpgsqlParameter[3]; if (dealers == null) { ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_alldealers"]); } else { NpgsqlParameter[] nSqlParam = new NpgsqlParameter[1]; nSqlParam[0] = new NpgsqlParameter("inorganization_id ", dealers); ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_alldealers_byRegion"], nSqlParam); } if (ds.Tables[0].Rows.Count > 0) { objList = ds.Tables[0].AsEnumerable().Select(s => new DealerModel { // objNewDashboardModel = s.Field("_customer_vehicle_is_owner"), //DealerName = model.TicketNo, DealerName = s.Field("_dealer_name"), // Region = s.Field("_region"), // TicketCount = s.Field("_ticket_count"), DealerId = s.Field("_id"), }).ToList(); } //} return objList; } catch (Exception Ex) { // objNewDashboardModel = new CustomerVehicleModel(); // objNewDashboardModel.Status = 0; // objCustomerVehicleModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message; objLog.ErrorLogFile("GetCustomerDetails", Ex.Message, path, errorlogtf); return objList; } } /// /// To get all State list /// /// state info /// all State list public List GetAllEmissionList() { List objList = new List(); EmissionModel objModel = new EmissionModel(); try { objAuthorization = new AuthenticationRepository(); // if (objAuthorization.AuthenticateDevice(model.Token)) // { DataSet ds = new DataSet(); ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_allemissionnorms"]); if (ds.Tables[0].Rows.Count > 0) { objList = ds.Tables[0].AsEnumerable().Select(s => new EmissionModel { EmissionName = s.Field("_emissionnorms"), // StateAlias = s.Field("state_alias") }).ToList(); } // } //else //{ // objModel.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString(); // objList.Add(objModel); // } return objList; } catch (Exception Ex) { objModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message; objList.Add(objModel); objLog.ErrorLogFile("GetAllStateList", Ex.Message, path, errorlogtf); return objList; } } public List GetAllRegionListDataSet() { List objList = new List(); DashboardModel objModel = new DashboardModel(); try { DataSet ds = new DataSet(); // NpgsqlParameter[] nSqlParam = new NpgsqlParameter[3]; ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_allregions"]); if (ds.Tables[0].Rows.Count > 0) { objList = ds.Tables[0].AsEnumerable().Select(s => new RegionModel { // objNewDashboardModel = s.Field("_customer_vehicle_is_owner"), //DealerName = model.TicketNo, // RegionName = s.Field("_dealer_name"), RegionName = s.Field("_region"), //TicketCount = s.Field("_ticket_count"), Id = s.Field("_id"), }).ToList(); } return objList; } catch (Exception Ex) { // objNewDashboardModel = new CustomerVehicleModel(); // objNewDashboardModel.Status = 0; // objCustomerVehicleModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message; objLog.ErrorLogFile("GetCustomerDetails", Ex.Message, path, errorlogtf); return objList; } } public List GetVerticleListDataSet() { List objList = new List(); VerticleModel objModel = new VerticleModel(); try { DataSet ds = new DataSet(); // NpgsqlParameter[] nSqlParam = new NpgsqlParameter[3]; ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_allvertical"]); if (ds.Tables[0].Rows.Count > 0) { objList = ds.Tables[0].AsEnumerable().Select(s => new VerticleModel { // objNewDashboardModel = s.Field("_customer_vehicle_is_owner"), //DealerName = model.TicketNo, VerticleName = s.Field("_vertical"), // Id = s.Field("_region"), // TicketCount = s.Field("_ticket_count"), // DealerId = s.Field("_dealer_id"), }).ToList(); } return objList; } catch (Exception Ex) { // objNewDashboardModel = new CustomerVehicleModel(); // objNewDashboardModel.Status = 0; // objCustomerVehicleModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message; objLog.ErrorLogFile("GetCustomerDetails", Ex.Message, path, errorlogtf); return objList; } } public List GetTileDashboardDataSetVECV(DashboardModel model) { List dashboardDataSetVecv = new List(); DashboardModel dashboardModel = new DashboardModel(); try { if (model.Email == "") { model.Email = null; } objAuthorization = new AuthenticationRepository(); if (objAuthorization.AuthenticateDevice(model.Token)) { DataSet ds = new DataSet(); NpgsqlParameter[] nSqlParam = new NpgsqlParameter[5]; nSqlParam[0] = new NpgsqlParameter("inuser_id ", model.UserId); nSqlParam[1] = new NpgsqlParameter("instart_date ", model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinutes))); nSqlParam[2] = new NpgsqlParameter("inend_date ", model.ToDate.AddMinutes(Convert.ToInt32(-model.UtcMinutes))); nSqlParam[3] = new NpgsqlParameter("inemails ", model.Email); nSqlParam[4] = new NpgsqlParameter("indealercodes ", model.dealerCodes); ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_dashboard_tile_data_VECV_User"], nSqlParam); if (ds.Tables[0].Rows.Count > 0) { dashboardDataSetVecv = ds.Tables[0].AsEnumerable().Select(s => new DashboardModel { Key = s.Field("_key"), KeyName = s.Field("_key_name") == null ? "-" : s.Field("_key_name"), KeyValue = s.Field("_key_value") == null ? "-" : s.Field("_key_value"), Status = "1" }).ToList(); } else { dashboardModel.Key = "Eicher"; dashboardModel.Key = "Truck"; dashboardModel.Key = "Bus"; dashboardDataSetVecv.Add(dashboardModel); dashboardModel.Key = "Volvo"; dashboardModel.Key = "Car"; dashboardModel.Key = "SUV"; dashboardDataSetVecv.Add(dashboardModel); } } else { dashboardModel.Status = "0"; dashboardModel.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString(); dashboardDataSetVecv.Add(dashboardModel); } return dashboardDataSetVecv; } catch (Exception ex) { dashboardModel.Status = "0"; dashboardModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + ex.Message; dashboardDataSetVecv.Add(dashboardModel); this.objLog.ErrorLogFile("GetCustomerDetails", ex.Message, this.path, this.errorlogtf); return dashboardDataSetVecv; } } public List GetSyncTicketDetail_VECV(VECVSyncModel model) { List ticketDetailVecv = new List(); List openTicketDetailList = new List(); List activityOpenModelVecvList = new List(); List closeTicketDetailList = new List(); List activityCloseModelVecvList = new List(); try { objAuthorization = new AuthenticationRepository(); if (objAuthorization.AuthenticateDevice(model.Token)) { if (model.Email == "") { model.Email = null; } if(model.DealerCode == null) { model.DealerCode =""; } DataSet ds = new DataSet(); DataSet ds1 = new DataSet(); NpgsqlParameter[] nSqlParam = new NpgsqlParameter[3]; nSqlParam[0] = new NpgsqlParameter("indealer_code ", model.DealerCode); nSqlParam[1] = new NpgsqlParameter("db_syn_last_time ", model.DbSynLastTime); nSqlParam[2] = new NpgsqlParameter("inemails ", model.Email); ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_syn_android_db_ticket_open_VECV_User"], nSqlParam); ds1 = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_syn_android_db_ticket_closed_VECV_User"], nSqlParam); if (ds.Tables[0].Rows.Count > 0) { openTicketDetailList = ds.Tables[0].AsEnumerable().Select(s => new VECVCustomerOpenTicketDetail { TicketId = s.Field("ticket_id"), Description = s.Field("description"), AssignedTo = s.Field("assigned_to"), ReportedVia = s.Field("reported_via"), TicketStatus = s.Field("ticket_status"), Priority = s.Field("priority"), CustomerScore = s.Field("customer_score"), CreatedBy = s.Field("created_by"), CreationTime = Convert.ToDateTime((object)s.Field("creation_time")).ToString("dd MMM yyy HH:mm:ss"), LastModifiedBy = s.Field("last_modified_by"), LastModifiedTime = Convert.ToDateTime((object)s.Field("last_modified_time")).ToString("dd MMM yyy HH:mm:ss"), BreakdownLocation = s.Field("breakdown_location"), BreakdownLongitude = s.Field("breakdown_longitude"), BreakdownLattitude = s.Field("breakdown_lattitude"), AssignedToUserId = s.Field("assigned_to_user_id"), AssignedToUserLattitude = s.Field("assigned_to_user_lattitude"), AssignedToUserLongitude = s.Field("assigned_to_user_longitude"), Isdeclined = s.Field("isdeclined"), EstimatedTimeForJobCompletion = s.Field("estimated_time_for_job_completion"), TotalTicketLifecycleTimeSla = s.Field("total_ticket_lifecycle_time_sla"), EstimatedTimeForJobCompletionSubmitTime = Convert.ToDateTime((object)s.Field("estimated_time_for_job_completion_submit_time")).ToString("dd MMM yyy HH:mm:ss"), VehicleRegisterNumber = s.Field("vehicle_register_number"), BreakdownLocationLandmark = s.Field("breakdown_location_landmark"), RouteId = s.Field("route_id"), CustomerContactNo = s.Field("customer_contact_no"), RepairCost = s.Field("repair_cost"), DefaultSlaTime = s.Field("default_sla_time"), SlaMissedReason = s.Field("sla_missed_reason"), SuggestionComment = s.Field("suggestion_comment"), JobCompleteResponseTime = s.Field("default_col_1"), DefaultCol2 = s.Field("default_col_2"), DefaultCol3 = s.Field("default_col_3"), EstimatedDistance = s.Field("estimated_distance"), Owner_Contact_no = s.Field("_owner_contact_no"), TicketIdAlias = s.Field("_ticket_id_alias") }).ToList(); } if (ds1.Tables[0].Rows.Count > 0) { closeTicketDetailList = ds1.Tables[0].AsEnumerable().Select(s => new VECVCustomerCloseTicketDetail { TicketId = s.Field("ticket_id"), Description = s.Field("description"), AssignedTo = s.Field("assigned_to"), ReportedVia = s.Field("reported_via"), TicketStatus = s.Field("ticket_status"), Priority = s.Field("priority"), CustomerScore = s.Field("customer_score"), CreatedBy = s.Field("created_by"), CreationTime = Convert.ToDateTime((object)s.Field("creation_time")).ToString("dd MMM yyy HH:mm:ss"), LastModifiedBy = s.Field("last_modified_by"), LastModifiedTime = Convert.ToDateTime((object)s.Field("last_modified_time")).ToString("dd MMM yyy HH:mm:ss"), BreakdownLocation = s.Field("breakdown_location"), BreakdownLongitude = s.Field("breakdown_longitude"), BreakdownLattitude = s.Field("breakdown_lattitude"), AssignedToUserId = s.Field("assigned_to_user_id"), AssignedToUserLattitude = s.Field("assigned_to_user_lattitude"), AssignedToUserLongitude = s.Field("assigned_to_user_longitude"), Isdeclined = s.Field("isdeclined"), EstimatedTimeForJobCompletion = s.Field("estimated_time_for_job_completion"), TotalTicketLifecycleTimeSla = s.Field("total_ticket_lifecycle_time_sla"), EstimatedTimeForJobCompletionSubmitTime = Convert.ToDateTime((object)s.Field("estimated_time_for_job_completion_submit_time")).ToString(ConfigurationManager.AppSettings["DateTimeFormat"]), VehicleRegisterNumber = s.Field("vehicle_register_number"), BreakdownLocationLandmark = s.Field("breakdown_location_landmark"), RouteId = s.Field("route_id"), CustomerContactNo = s.Field("customer_contact_no"), RepairCost = s.Field("repair_cost"), DefaultSlaTime = s.Field("default_sla_time"), SlaMissedReason = s.Field("sla_missed_reason"), SuggestionComment = s.Field("suggestion_comment"), JobCompleteResponseTime = s.Field("default_col_1"), DefaultCol2 = s.Field("default_col_2"), DefaultCol3 = s.Field("default_col_3"), EstimatedDistance = s.Field("estimated_distance"), Owner_Contact_no = s.Field("_owner_contact_no"), TicketIdAlias = s.Field("_ticket_id_alias"), }).ToList(); } ticketDetailVecv.Add(new VECVSyncModel() { TicketOpenList = openTicketDetailList, TicketCloseList = closeTicketDetailList, DeviceAlias = model.DeviceAlias, DbSynLastTime = DateTime.UtcNow.ToString(ConfigurationManager.AppSettings["DateTimeFormat"]), Status = "1" }); return ticketDetailVecv; } ticketDetailVecv.Add(new VECVSyncModel() { DeviceAlias = model.DeviceAlias, DbSynLastTime = model.DbSynLastTime, Status = "0", Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString() }); return ticketDetailVecv; } catch (Exception ex) { ticketDetailVecv.Add(new VECVSyncModel() { DeviceAlias = model.DeviceAlias, DbSynLastTime = model.DbSynLastTime, Status = "0", Message = ex.Message }); this.objLog.ErrorLogFile("GetSyncTicketDetail_Dealer", ex.Message, this.path, this.errorlogtf); return ticketDetailVecv; } } public VECVTicketRequestModel GetDealerOpenTicketDetailVECV(VECVTicketRequestModel model) { VECVTicketRequestModel ticketDetailVecv = new VECVTicketRequestModel(); List vecvTicketOpenModelList = new List(); try { objAuthorization = new AuthenticationRepository(); if (objAuthorization.AuthenticateDevice(model.Token)) { if (model.Email == "") { model.Email = null; } DataSet ds = new DataSet(); NpgsqlParameter[] nSqlParam = new NpgsqlParameter[1]; nSqlParam[0] = new NpgsqlParameter("inuser_id ", model.UserId); ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_dealer_open_ticket_details"], nSqlParam); if (ds.Tables[0].Rows.Count > 0) { vecvTicketOpenModelList = ds.Tables[0].AsEnumerable().Select(s => new VECVTicketOpenModel { Id = s.Field("ticket_id"), Description = s.Field("description"), AssignedTo = s.Field("assigned_to"), ReportedVia = s.Field("reported_via"), TicketStatus = s.Field("ticket_status"), Priority = s.Field("priority"), CutomerScore = s.Field("customer_score"), CreatedBy = s.Field("created_by"), // DateTime dateTime1 = Convert.ToDateTime((object)s.Field("creation_time")), // dateTime1 = dateTime1.AddMinutes((double)Convert.ToInt16((object)model.UtcMinute)), // CreationTime = dateTime1.ToString(ConfigurationManager.AppSettings["DateTimeFormat"]), //ateTime dateTime2 = Convert.ToDateTime((object)s.Field("last_modified_time")); //dateTime2 = dateTime2.AddMinutes((double)Convert.ToInt16((object)model.UtcMinute)); //LastModifiedTime = dateTime2.ToString(ConfigurationManager.AppSettings["DateTimeFormat"]), LastModifiedBy = s.Field("last_modified_by"), BreakDownLocation = s.Field("breakdown_location"), BreackDownLongitude = s.Field("breakdown_longitude"), BreackDownLatitude = s.Field("breakdown_lattitude"), AssignedToUserId = s.Field("assigned_to_user_id"), AssignedToUserLatitude = s.Field("assigned_to_user_lattitude"), AssignedToUserLongitude = s.Field("assigned_to_user_longitude"), IsDeclined = s.Field("isdeclined"), EstimatedTimeForJobComplition = s.Field("estimated_time_for_job_completion"), TotalTicketLifeCycleTimeSlab = s.Field("total_ticket_lifecycle_time_sla"), VehicleRegistrationNo = s.Field("vehicle_register_number"), BreakdownLocationLandmark = s.Field("breakdown_location_landmark"), RouteId = s.Field("route_id"), CustomeContact_no = s.Field("customer_contact_no"), RepairCost = s.Field("repair_cost"), DefaultSlaTime = s.Field("default_sla_time"), SlaMissedReason = s.Field("sla_missed_reason"), SuggestionComment = s.Field("suggestion_comment"), TicketStatusAlias = s.Field("ticket_status_alias"), JobCompleteResponseTime = s.Field("default_col_1"), DefaultCol2 = s.Field("default_col_2"), DefaultCol3 = s.Field("default_col_3"), ticketid_alias = s.Field("_ticket_id_alias"), }).ToList(); ticketDetailVecv.TicketList = vecvTicketOpenModelList; ticketDetailVecv.Status = "1"; } else { ticketDetailVecv.Status = "0"; ticketDetailVecv.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString(); } } } catch (Exception ex) { ticketDetailVecv.Status = "0"; ticketDetailVecv.Message = ex.Message; this.objLog.ErrorLogFile("GetDealerOpenTicketDetail", ex.Message, this.path, this.errorlogtf); } return ticketDetailVecv; } /// /// To get open and close ticket detail user id wise /// /// ticket info /// status and open and close ticket detail user id wise public VECVTicketRequestModel GetOpenCloseTicketDetailVECV(VECVTicketRequestModel model) { VECVTicketRequestModel objModel = new VECVTicketRequestModel(); List objList = new List(); try { DataSet ds = new DataSet(); objAuthorization = new AuthenticationRepository(); if (objAuthorization.AuthenticateDevice(model.Token)) { // Get Open ticket report details. if (model.TicketType.Trim().ToLower() == "open") { NpgsqlParameter[] nSqlParam = new NpgsqlParameter[5]; nSqlParam[0] = new NpgsqlParameter("inuser_id", model.UserId); nSqlParam[1] = new NpgsqlParameter("instart_date", model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam[2] = new NpgsqlParameter("inend_date", model.ToDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam[3] = new NpgsqlParameter("inemails", model.Email); nSqlParam[4] = new NpgsqlParameter("indealercodes", model.Dealers); ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_open_tickets_user_wise_VECV_User"], nSqlParam); } else if (model.TicketType.Trim().ToLower() == "count") { // Get closed ticket record count. NpgsqlParameter[] nSqlParam = new NpgsqlParameter[6]; nSqlParam[0] = new NpgsqlParameter("inuser_id", model.UserId); nSqlParam[1] = new NpgsqlParameter("instart_date", model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam[2] = new NpgsqlParameter("inend_date", model.ToDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam[3] = new NpgsqlParameter("inlimit", model.Limit); nSqlParam[4] = new NpgsqlParameter("inoff_set", model.OffSet); nSqlParam[5] = new NpgsqlParameter("incondition", model.Condition); ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_closed_tickets_count_user_wise"], nSqlParam); } else { // Get closed ticket report details. NpgsqlParameter[] nSqlParam = new NpgsqlParameter[7]; nSqlParam[0] = new NpgsqlParameter("inuser_id", model.UserId); nSqlParam[1] = new NpgsqlParameter("instart_date", model.FromDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam[2] = new NpgsqlParameter("inend_date", model.ToDate.AddMinutes(Convert.ToInt32(-model.UtcMinute))); nSqlParam[3] = new NpgsqlParameter("inlimit", model.Limit); nSqlParam[4] = new NpgsqlParameter("inoff_set", model.OffSet); nSqlParam[5] = new NpgsqlParameter("incondition", model.Condition); nSqlParam[6] = new NpgsqlParameter("inemails", model.Email); // nSqlParam[7] = new NpgsqlParameter("indealercodes", model.Dealers); ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_closed_tickets_user_wise_VECV_User"], nSqlParam); } if (model.TicketType.Trim().ToLower() == "count") { objModel.TicketCount = Convert.ToInt64(ds.Tables[0].Rows[0][0]); } else if (model.TicketType.Trim().ToLower() == "open") { objList = ds.Tables[0].AsEnumerable().Select(s => new VECVTicketOpenModel { Id = s.Field("_ticket_id"), DefaultSlaTime = s.Field("_default_sla_time"), CustomeContact_no = s.Field("_customer_contact_no"), TotalTicketLifeCycleTimeSlab = s.Field("_total_ticket_lifecycle_time_sla") == null || s.Field("_total_ticket_lifecycle_time_sla") <= 0 ? 0 : s.Field("_total_ticket_lifecycle_time_sla"), ServiceEngineerName = s.Field("_van_dealer_name"), DealerDealerName = s.Field("_dealer_name"), ServiceEngineerContactNumber = s.Field("_dealer_contact_number1"), TicketStatusAlias = s.Field("_ticket_status_alias"), VehicleTagging = s.Field("_customer_vehicle_model_tagging"), CustomerName = s.Field("_customer_name"), CreationTime = Convert.ToDateTime(s.Field("_creation_time")).AddMinutes(Convert.ToInt16(model.UtcMinute)).ToString(ConfigurationManager.AppSettings["DateTimeFormat"]), LastModifiedTime = Convert.ToDateTime(s.Field("_lastmodifytime")).AddMinutes(Convert.ToInt16(model.UtcMinute)).ToString(ConfigurationManager.AppSettings["DateTimeFormat"]), AssignedTo = s.Field("_assignedto"), EstimatedTimeForJobComplition = s.Field("_estimatedtimeforjobcompletion"), Age = Convert.ToDouble(s.Field("_age")), DefaultCol2 = model.TicketType.Trim().ToLower() == "close" ? s.Field("_feedbackagent") : null, DefaultCol3 = model.TicketType.Trim().ToLower() == "close" ? s.Field("_reasonformorethen24hours") : null, VehicleRegistrationNo = s.Field("_vehicle_registration_number"), ticketid_alias = s.Field("_ticket_id_alias"), caller_language = s.Field("_caller_language"), gps_status = s.Field("_gps_status"), current_latitude = s.Field("_current_latitude"), current_longitude = s.Field("_current_longitude"), PreClosureTime = Convert.ToDateTime(s.Field("_pre_closure_time")).AddMinutes(Convert.ToInt16(model.UtcMinute)).ToString(ConfigurationManager.AppSettings["DateTimeFormat"]), ChassisNo = s.Field("_chassis_number"), OdometerReading = s.Field("_odometer_reading"), Remarks = s.Field("_last_remark"), Description = s.Field("_nature_of_problem"), BreakDownLocation = s.Field("csm"), BreackDownLongitude = s.Field("csm_contact_no"), BreackDownLatitude = s.Field("rsm"), AssignedToUserLongitude = s.Field("rsm_contact_no"), AssignedToUserLatitude = s.Field("asm"), BreakdownLocationLandmark = s.Field("asm_contact_no"), Designation = s.Field("_Dealer_name_1scode"), VehicleType = s.Field("_vehicle_status"), ServiceEngineerPinPassword = s.Field("_vehicle_emission_norms"), ServiceEngineerAlias = s.Field("_created_by"), ServiceEngineerApplicationLicenseKey = s.Field("_region"), VanReachedPunchTime = s.Field("_van_reached_punch_time") == null ? "" : Convert.ToDateTime(s.Field("_van_reached_punch_time")).ToString(ConfigurationManager.AppSettings["DateTimeFormat"]), //added on 23-12-2020 }).ToList(); } else if (model.TicketType.Trim().ToLower() == "close") { objList = ds.Tables[0].AsEnumerable().Select(s => new VECVTicketOpenModel { Id = s.Field("_ticket_id"), DefaultSlaTime = s.Field("_default_sla_time"), CustomeContact_no = s.Field("_customer_contact_no"), TotalTicketLifeCycleTimeSlab = s.Field("_total_ticket_lifecycle_time_sla") == null || s.Field("_total_ticket_lifecycle_time_sla") <= 0 ? 0 : s.Field("_total_ticket_lifecycle_time_sla"), ServiceEngineerName = s.Field("_van_dealer_name"), DealerDealerName = s.Field("_dealer_name"), ServiceEngineerContactNumber = s.Field("_dealer_contact_number1"), TicketStatusAlias = s.Field("_ticket_status_alias"), //added on 25-09-2020 VanLatitudeAtTripStart = s.Field("_van_trip_start_latitude"), VanLongitudeAtTripStart = s.Field("_van_trip_start_longitude"), VanLatitudeAtVanReached = s.Field("_van_reached_latitude"), VanLongitudeAtVanReached = s.Field("_van_reached_longitude"), VanLatitudeAtTripEnd = s.Field("_van_trip_end_latitude"), VanLongitudeAtTripEnd = s.Field("_van_trip_end_longitude"), BreakdownLocationLatitude = s.Field("_breakdown_location_latitude"), BreakdownLocationLongitude = s.Field("_breakdown_location_longitude"), //----------------added on 25-11-2020 (start) ------------------------------------- TicketClosedReason = s.Field("_ticket_closed_reason"), //----------------added on 25-11-2020 (end) ------------------------------------- VehicleTagging = s.Field("_customer_vehicle_model_tagging"), CustomerName = s.Field("_customer_name"), CreationTime = Convert.ToDateTime(s.Field("_creation_time")).AddMinutes(Convert.ToInt16(model.UtcMinute)).ToString(ConfigurationManager.AppSettings["DateTimeFormat"]), LastModifiedTime = Convert.ToDateTime(s.Field("_lastmodifytime")).AddMinutes(Convert.ToInt16(model.UtcMinute)).ToString(ConfigurationManager.AppSettings["DateTimeFormat"]), AssignedTo = s.Field("_assignedto"), EstimatedTimeForJobComplition = s.Field("_estimatedtimeforjobcompletion"), Age = Convert.ToDouble(s.Field("_age")), DefaultCol2 = model.TicketType.Trim().ToLower() == "close" ? s.Field("_feedbackagent") : null, DefaultCol3 = model.TicketType.Trim().ToLower() == "close" ? s.Field("_reasonformorethen24hours") : null, CallStatus = s.Field("_call_status"), VehicleRegistrationNo = s.Field("_vehicle_registration_number"), ticketid_alias = s.Field("_ticket_id_alias"), caller_language = s.Field("_caller_language"), feedback_call_status = s.Field("_feedback_status"), total_count = Convert.ToString(s.Field("_feedback_count")), reopen_count = Convert.ToString(s.Field("_reopen_count")), Score = s.Field("_score"), ChassisNo = s.Field("_chassis_number"), OdometerReading = s.Field("_odometer_reading"), //added on 03/12/2020 vehicle_warranty = s.Field("_vehicle_warranty"), vehicle_amc = s.Field("_vehicle_amc"), vehicle_emission_norms = s.Field("_vehicle_emission_norms"), vehicle_sales_date = s.Field("_vehicle_sales_date"), AssignedToUserLatitude = s.Field("_assigned_lat"), AssignedToUserLongitude = s.Field("_assigned_long"), BreackDownLongitude = s.Field("_estimated_van_reach_time"), VanReachedPunchTime = s.Field("_van_reached_punch_time") == null ? "" : Convert.ToDateTime(s.Field("_van_reached_punch_time")).ToString(ConfigurationManager.AppSettings["DateTimeFormat"]), //added on 23-12-2020 }).ToList(); } objModel.TicketList = objList; objModel.Status = "1"; } else { objModel.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString(); objModel.Status = "0"; } } catch (Exception Ex) { objLog.ErrorLogFile("GetOpenCloseTicketDetail", Ex.Message, path, errorlogtf); objModel.Message = Ex.Message; objModel.Status = "0"; } return objModel; } public List GetVehicleModelFilter(string fueltype,string[] vehicleTagging) { try { DataSet ds = new DataSet(); List objList = new List(); if (fueltype == null || fueltype == "null") { fueltype = ""; } //else //{ // if (fueltype == "ELECTRIC") // { // } // else // { // fueltype = "Diesel,CNG"; // } //} NpgsqlParameter[] nSqlParam = new NpgsqlParameter[2]; nSqlParam[0] = new NpgsqlParameter("infueltype", fueltype); nSqlParam[1] = new NpgsqlParameter("invehicleTagging", vehicleTagging); ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_vehicle_model_dashboard"], nSqlParam); if (ds.Tables[0].Rows.Count > 0) { objList = ds.Tables[0].AsEnumerable().Select(s => new VehicleTypeModel { VehicleTypeId = s.Field("_name"), VehicleTypeName = s.Field("_name") }).ToList(); } return objList; } catch (Exception Ex) { objLog.ErrorLogFile("GlobalRepository GetAllVehicleTypeList", Ex.Message, path, errorlogtf); throw Ex; } } #endregion } #endregion }