public JsonResult ValidateChassisNumberOnUpdate(string id, string RN, int VID) { var CN_Result = model.ValidateChassisNumberOnUpdation("Validate_ChassisNumber_OnUpd", id, VID); var RN_Result = model.ValidateRegistrationNumberOnUpdate("Validate_RegistrationNumber_OnUpd", RN, VID); FM_Vehicle ReturnObject = new FM_Vehicle(); if (CN_Result == 1) { ReturnObject.ChassisNumber = "1"; } else { ReturnObject.ChassisNumber = "0"; } if (RN_Result == 1) { ReturnObject.RegistrationNumber = "1"; } else { ReturnObject.RegistrationNumber = "0"; } return(Json(ReturnObject, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveIMEI(int Id, int TrackerIMEI, string PreviousIMEI, string CurrentTrackerIMEI) { model.Update_Vehicle("Edit_Vehicle_For_Tracker", Id, TrackerIMEI); ViewBag.EditResponse = "Success"; FM_Vehicle modelList = new FM_Vehicle(); modelList = model.Get_EditVehicle("Get_EditVehicle_By_Id", Id); if (TrackerIMEI != 0) { model.Insert_VehicleTracker("Insert_FM_VehicleTrackerHistory", modelList.IMEIId, modelList.VehicleId); } else { FM_Vehicle temp = new FM_Vehicle(); temp.IMEI = ""; modelList = temp; } if (!(PreviousIMEI == CurrentTrackerIMEI)) { bool ConnectionEstb = CreateTCPClient(); if (ConnectionEstb) { ServerCommunication(CurrentTrackerIMEI.ToString(), "1002", "", PreviousIMEI.ToString()); } } return(Json(modelList, JsonRequestBehavior.AllowGet)); }
public ActionResult Index() { //@ViewBag.VehicleEntry = "Initiated"; FM_Vehicle modelBind = new FM_Vehicle(); return(View(modelBind)); }
public ActionResult Edit(int id) { if (id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FM_Vehicle modelList = model.Get_EditVehicle("Get_EditVehicle", id); if (modelList == null) { return(Redirect("/Error/index?type=noUrlFound")); } ViewBag.EditResponse = "Initiated"; if (TempData["EditResp"] != null) { ViewBag.EditResponse = "CreatedSuccessfully"; TempData.Remove("EditResp"); } return(View(modelList)); }
public List <FM_Vehicle> Get_List_IMEI_ByUserID(string Filter, int id) { try { DataTable dataTableModel = model.Get_List_IMEI_ByUserID(Filter, id); List <FM_Vehicle> LstVehicle = new List <FM_Vehicle>(); foreach (DataRow rows in dataTableModel.Rows) { FM_Vehicle objFMVehcile = new FM_Vehicle(); objFMVehcile.IMEIId = Convert.ToInt32(rows["UEId"]); objFMVehcile.IMEI = rows["SerialNo"].ToString() + " (" + rows["UENumber"].ToString() + ")"; objFMVehcile.TypeName = rows["UERefNo"].ToString(); objFMVehcile.ManuName = rows["ManufacturerModel"].ToString(); LstVehicle.Add(objFMVehcile); } return(LstVehicle); } catch (Exception ex) { return(null); } }
public ActionResult Index(FM_Vehicle modelBind) { if (ModelState.IsValid) { string Picture = null; FM_Vehicle modelResult = new FM_Vehicle(); Picture = UploadImg("/Content/Images/Vehicles/Original/", "v-" + modelBind.ChassisNumber.Replace(" ", "_"), 150, 150); string Thumb = (!string.IsNullOrEmpty(Picture)) ? UploadImg("/Content/Images/Vehicles/Thumb/", "v-" + modelBind.ChassisNumber.Replace(" ", "_"), 32, 32) : null; if (!string.IsNullOrEmpty(Picture)) { // ud.Manage("UpdatePicture", Id.ToString(), Picture);xyz.Replace(" ", string.empty); modelResult = model.Insert_Vehicle("Insert_Vehicle_With_Image", modelBind.TypeId, modelBind.ManuId, modelBind.ModelId, modelBind.SubModelId, modelBind.Year, modelBind.ChassisNumber, modelBind.RegistrationNumber, true, Picture.Replace(" ", "_"), modelBind.VehicleGroupId, modelBind.IMEIId); } else { modelResult = model.Insert_Vehicle("Insert_Vehicle", modelBind.TypeId, modelBind.ManuId, modelBind.ModelId, modelBind.SubModelId, modelBind.Year, modelBind.ChassisNumber, modelBind.RegistrationNumber, true, modelBind.VehicleGroupId, modelBind.IMEIId); } ViewBag.VehicleEntry = "True"; TempData["EditResp"] = "CreatedSuccessfully"; /* == Insert Notification When Create New Vehicle Start == */ AL_SetNotification DumyObject = new AL_SetNotification(); DumyObject.AlertConfigId = 7; DumyObject.EntityId = modelResult.VehicleId; DumyObject.Notification = "Vehicle \"" + modelBind.RegistrationNumber + "\" Created."; DumyObject.AlertRecieverId = 11; DumyObject.UserId = 29; DumyObject.IsPushAlertSent = 0; DumyObject.IsPushAlertRead = 0; DumyObject.IsEmailAlertSent = 0; AlertModel.SendNotification("InsertNotification", DumyObject); /* == Insert Notification When Create New Vehicle End == */ return(RedirectToAction("Edit", new { id = modelResult.VehicleId })); } else { ViewBag.VehicleEntry = "False"; ViewBag.VehicleGroupId = modelBind.VehicleGroupId; ViewBag.ManuId = modelBind.ManuId; ViewBag.TypeId = modelBind.TypeId; ViewBag.ModelId = modelBind.ModelId; ViewBag.SubModelId = modelBind.SubModelId; ViewBag.IMEI = modelBind.IMEI; } return(View(modelBind)); }
public FM_Tracker_VM Get_List_IMEI(string Filter, int id) { try { DataSet ds = model.Get_List_IMEI(Filter, id); //DataTable dataTableModel = model.Get_List_IMEI(Filter, id); //DataTable dataTableModelHistory = model.Get_List_IMEI(Filter, id); FM_Tracker_VM LstVehicle = new FM_Tracker_VM(); List <FM_VehicleTrackerHistory> HistoryObjectList = new List <FM_VehicleTrackerHistory>(); DataTable dataTableModel = ds.Tables[0]; DataTable dataTableModelHistory = ds.Tables[1]; foreach (DataRow rows in dataTableModel.Rows) { FM_Vehicle objFMVehcile = new FM_Vehicle(); objFMVehcile.IMEIId = Convert.ToInt32(rows["UEId"]); objFMVehcile.IMEI = rows["SerialNo"].ToString() + " (" + rows["UENumber"].ToString() + ")"; objFMVehcile.TypeName = rows["UERefNo"].ToString(); objFMVehcile.ManuName = rows["ManufacturerModel"].ToString(); LstVehicle.Vehicle = objFMVehcile; } foreach (DataRow rows in dataTableModelHistory.Rows) { FM_VehicleTrackerHistory HistoryObject = new FM_VehicleTrackerHistory(); HistoryObject.TypeName = rows["UERefNo"].ToString(); HistoryObject.ManuName = rows["ManufacturerModel"].ToString(); HistoryObject.IMEI = rows["SerialNo"].ToString() + " (" + rows["UENumber"].ToString() + ")"; HistoryObject.TrackerDate = Convert.ToDateTime(rows["TrackerDate"]); HistoryObject.UENumber = rows["UENumber"].ToString(); HistoryObjectList.Add(HistoryObject); } LstVehicle.History = HistoryObjectList; return(LstVehicle); } catch (Exception ex) { return(null); } }
public List <FM_Vehicle> GetAllTrackers(string Filter) { DataTable dataTableModel = model.Get_List_IMEI(Filter); List <FM_Vehicle> LstVehicle = new List <FM_Vehicle>(); foreach (DataRow rows in dataTableModel.Rows) { FM_Vehicle objFMVehcile = new FM_Vehicle(); objFMVehcile.IMEIId = Convert.ToInt32(rows["UEId"]); objFMVehcile.IMEI = rows["SerialNo"].ToString();//+ " (" + rows["UENumber"].ToString() + ")"; objFMVehcile.TypeName = rows["UERefNo"].ToString(); objFMVehcile.ManuName = rows["ManufacturerModel"].ToString(); objFMVehcile.RegistrationNumber = rows["RegistrationNumber"].ToString(); LstVehicle.Add(objFMVehcile); } return(LstVehicle); }
public JsonResult ValidateChassisNumber(string Id, string RN, string IMEI) { var CN_Result = model.ValidateChassisNumber("Validate_ChassisNumber", Id); var RN_Result = model.ValidateRegistrationNumber("Validate_RegistrationNumber", RN); var IMEI_Result = model.ValidateRegistrationNumber("Validate_IMEI", IMEI); FM_Vehicle ReturnObject = new FM_Vehicle(); if (CN_Result == 1) { ReturnObject.ChassisNumber = "1"; } else { ReturnObject.ChassisNumber = "0"; } if (RN_Result == 1) { ReturnObject.RegistrationNumber = "1"; } else { ReturnObject.RegistrationNumber = "0"; } if (IMEI_Result == 1) { ReturnObject.IMEI = "1"; } else { ReturnObject.IMEI = "0"; } return(Json(ReturnObject, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(FM_Vehicle modelBind) { try { FM_Vehicle modelList = new FM_Vehicle(); if (ModelState.IsValid) { string Picture = null; Picture = UploadImg("/Content/Images/Vehicles/Original/", "v-" + modelBind.ChassisNumber.Replace(" ", "_"), 150, 150); string Thumb = (!string.IsNullOrEmpty(Picture)) ? UploadImg("/Content/Images/Vehicles/Thumb/", "v-" + modelBind.ChassisNumber.Replace(" ", "_"), 32, 32) : null; if (!string.IsNullOrEmpty(Picture)) { model.Update_Vehicle("Edit_Vehicle_With_Image", modelBind.TypeId, modelBind.ManuId, modelBind.ModelId, modelBind.SubModelId, modelBind.Year, modelBind.ChassisNumber, modelBind.RegistrationNumber, true, modelBind.VehicleId, Picture.Replace(" ", "_"), modelBind.VehicleGroupId); } else { model.Update_Vehicle("Edit_Vehicle", modelBind.TypeId, modelBind.ManuId, modelBind.ModelId, modelBind.SubModelId, modelBind.Year, modelBind.ChassisNumber, modelBind.RegistrationNumber, true, modelBind.VehicleId, modelBind.VehicleGroupId); } ViewBag.EditResponse = "Success"; modelList = model.Get_EditVehicle("Get_EditVehicle", modelBind.VehicleId); //return RedirectToAction("List"); /* == Insert Notification When Create New Vehicle Start == */ AL_SetNotification DumyObject = new AL_SetNotification(); AL_GetNotification UserNotify = new AL_GetNotification(); DumyObject.AlertConfigId = 7; DumyObject.EntityId = modelBind.VehicleId; DumyObject.Notification = "Vehicle \"" + modelBind.RegistrationNumber + "\" Updated."; DumyObject.AlertRecieverId = 11; DumyObject.UserId = (int)ViewBag.UserId; DumyObject.IsPushAlertSent = 0; DumyObject.IsPushAlertRead = 0; DumyObject.IsEmailAlertSent = 0; //sendEmail(); NotificationHub SRNotificationHub = new NotificationHub(); AL_Notification ReadNotification = new AL_Notification(); ReadNotification.SentTo = "11"; /* == Send Alerts based on Users == */ List <AL_GetNotification> ModelResultReceiver = AlertModel.SendNotification("InsertNotification", DumyObject); for (var x = 0; x < ModelResultReceiver.Count; x++) { UserNotify.AlertRecieverId = ModelResultReceiver[x].AlertRecieverId; List <AL_GetNotification> ModelResult = AlertModel.GetNotification("NotificationBell", UserNotify); var json = JsonConvert.SerializeObject(ModelResult); SRNotificationHub.SendNotification(ModelResultReceiver[x].AlertRecieverId.ToString(), json); } /* == Insert Notification When Create New Vehicle End == */ } return(View(modelList)); } catch (Exception ex) { return(this.Json(new { success = false, message = ex.ToString() })); } }
// POST api/<controller> public void Post([FromBody] FM_Vehicle m) { //TrackerInfoModel.IMEI = m.TrackerID; //TrackerInfoModel.Status = true; //var Result = TrackerInfo.Find(x => x.IMEI == m.TrackerID); //if (Convert.ToBoolean(Result)) //{ // if(TrackerInfo.Find(x => x.IMEI == m.IMEI).Status) // { // if (m.GPSSignalStatus != "invalid" && m.ObjInpOutStatus.InEngineOnOff != false) // { // model.Insert_Tracker("InsertTrackerLog", m.TrackerID, m.Latitude, m.Longitude, m.Speed, m.Odometer, m.Direction, m.Rotation, m.Altitude, m.TrackerStream, m.GPSSignalStatus, m.UTCTimeAndDate, m.ObjInpOutStatus, m.IsOfflineData); // } // else // { // TrackerInfo.Find(x => x.IMEI == m.IMEI).Status = false; // } // } //} //else //{ // TrackerInfo.Add(TrackerInfoModel); // //insert record //} if (m.GPSSignalStatus != "invalid" && m.ObjInpOutStatus.InEngineOnOff != false) { if (m.objTrackerTrip != null) { if (m.objTrackerTrip.TripNo == -1) { m.objTrackerTrip.TripNo = 1; } } model.Insert_Tracker("InsertTrackerLog", m.TrackerID, m.Latitude, m.Longitude, m.Speed, m.Odometer, m.Direction, m.Rotation, m.Altitude, m.TrackerStream, m.GPSSignalStatus, m.UTCTimeAndDate, m.ObjInpOutStatus, m.IsOfflineData, m.DeviceState, m.ExtendState, m.Address, m.FuelConsumedPercentage, m.CurrentTripFuelConsumed, m.Temperature, m.CurrentTripMileage, m.GSMSignal, m.objTrackerTrip.TripNo); if (m.LstVState != null && m.LstVState.Count > 0) { foreach (FM_VehicleStates VState in m.LstVState) { model.Insert_VState("Insert_VState", m.TrackerID, m.VehicleId, m.Latitude, m.Longitude, VState); } } if (m.LstAlarms != null) { foreach (FM_Tracker_Alarms Alrm in m.LstAlarms) { model.Insert_TrackingAlarms("Insert_TrackingAlarms", m.TrackerID, m.VehicleId, m.Latitude, m.Longitude, Alrm); List <FM_TrackerAlarmConfiguration> lstAlrmsToNotify = model.GetAlarmsToSendNotification("GetAlarmsForNotification", m.TrackerID); if (lstAlrmsToNotify != null) { if (lstAlrmsToNotify.Where(x => x.AlrmCodes == Alrm.AlrmCodes.ToString()).ToList().Count > 0) { //Here Trackerid property contains the AssignTo value if (lstAlrmsToNotify[0].AssignedUserID != "") { SendNotification(Alrm, lstAlrmsToNotify[0].IMEI, m.VehicleId, Convert.ToInt32(lstAlrmsToNotify[0].AssignedUserID)); } } } } } } //FM_Vehicle x = new FM_Vehicle(); //Random rnd = new Random(); //int month = rnd.Next(1, 10); //x = m; //x.Latitude = x.Latitude + (0.00001* month); var json = JsonConvert.SerializeObject(m); var hubContext = GlobalHost.ConnectionManager.GetHubContext <ClientHub>(); hubContext.Clients.All.VehicleStream(json); }
//Start Fleet Replay Record public List <FM_FleetReplay_VM> GetFleetReplayRecord(FleetReplayCriteria fleetreplaycriteria) { try { DataTable dataTableModel = model.Get_FleetReplayRecords(fleetreplaycriteria); List <FM_FleetReplay_VM> ListModel = dataTableModel.ToList <FM_FleetReplay_VM>(); int counter = 0; foreach (DataRow row in dataTableModel.Rows) { var objVeh = new FM_Vehicle(); objVeh.RegistrationNumber = row["RegistrationNumber"].ToString(); objVeh.IMEI = row["IMEI"].ToString(); if (fleetreplaycriteria.Filter == "IdleEngineReport") { objVeh.Longitude = Convert.ToDouble(row["Longitude"]); objVeh.Latitude = Convert.ToDouble(row["Latitude"]); } if (fleetreplaycriteria.Filter == "Alarms" || fleetreplaycriteria.Filter == "DetailTrack") { objVeh.Longitude = Convert.ToDouble(row["Longitude"]); objVeh.Latitude = Convert.ToDouble(row["Latitude"]); objVeh.Speed = Convert.ToDouble(row["Speed"]); objVeh.Direction = Convert.ToDouble(row["Direction"]); objVeh.Odometer = Convert.ToDouble(row["Odometer"]); objVeh.Rotation = row["Rotation"].ToString(); objVeh.CurrentTripMileage = Convert.ToDouble(row["CurrentTripMileage"]); objVeh.GPSSignalStatus = row["GPSSignalStatus"].ToString(); objVeh.GSMSignal = row["GSMSignal"].ToString(); } ListModel[counter].LstVehicle = objVeh; counter = counter + 1; } var FatigueStatus = ListModel.Where(u => u.Status != null).Select(a => a.Status).ToList(); var engineStatus = ListModel.Where(u => u.InEngineOnOff != null).Select(a => a.InEngineOnOff).ToList(); var alarmState = ListModel.Where(u => u.AlarmState != null).Select(a => a.AlarmState).ToList(); if (FatigueStatus.Count > 0 || engineStatus.Count > 0) { foreach (var item in ListModel) { if (item.Status == "True") { item.Status = "Yes"; } if (item.AlarmState == "True") { item.AlarmState = "On"; } else { item.AlarmState = "Off"; } if (item.InEngineOnOff == "True") { item.InEngineOnOff = "On"; } else { item.InEngineOnOff = "Off"; } } return(ListModel.ToList()); } else { return(ListModel.ToList()); } } catch (Exception ex) { throw ex; } }