public List <AL_GetNotification> SendNotification(string Filter, AL_SetNotification Info) { DataTable dataTableModel = AL.Set(Filter, Info); List <AL_GetNotification> ListModel = dataTableModel.ToList <AL_GetNotification>(); return(ListModel); }
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 DataTable Set(string Filter, AL_SetNotification Info) { SqlCommand loCommand = DataContext.OpenConnection(); try { loCommand = DataContext.SetStoredProcedure(loCommand, "AL_ManageAlert"); return(DataContext.Select(DataContext.AddParameters(loCommand, "@Filter", Filter, "@AlertConfigId", Info.AlertConfigId, "@EntityId", Info.EntityId, "@Notification", Info.Notification, "@AlertRecieverId", Info.AlertRecieverId, "@UserId", Info.UserId, "@IsEmailAlertSent", Info.IsEmailAlertSent, "@IsPushAlertRead", Info.IsPushAlertRead, "@IsPushAlertSent", Info.IsPushAlertSent))); } catch (Exception ex) { throw; } finally { DataContext.CloseConnection(loCommand); } }
public void SendNotification(FM_Tracker_Alarms modelBind, string Vreg, int VID, int AssignTo) { /* == Insert Notification When Create New Vehicle Start == */ AL_SetNotification DumyObject = new AL_SetNotification(); AL_GetNotification UserNotify = new AL_GetNotification(); AL_AlertBL AlertModel = new AL_AlertBL(); string AlarmDescriptions = GetDescription(modelBind.AlrmCodes); WebConfig wc = new WebConfig(); string UserIDForNotication = wc.AppSettings("NotificationUserID"); DumyObject.AlertConfigId = 1005; DumyObject.EntityId = VID; DumyObject.Notification = "Car:" + Vreg + " generates " + AlarmDescriptions + " Alarm, current value: " + modelBind.CurrentVal; DumyObject.AlertRecieverId = 29; //11; //AssignTo; DumyObject.UserId = Convert.ToInt32(UserIDForNotication); //12;//(int)ViewBag.UserId; DumyObject.IsPushAlertSent = 1; 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 == */ }
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() })); } }