public ActionResult Notifications() { List <notificationModel> Noticafition = new List <notificationModel>(); OasisConnectionManager = ConfigurationManager.ConnectionStrings["OasisConnectionString"].ConnectionString; OasisConnection = new SqlConnection(OasisConnectionManager); DataTable dataTable = new DataTable(); OasisConnection.Open(); var query = "select * from Notifications where RecieverRole='" + "ProductionDepartment" + "'"; SqlCommand SelectCommand = new SqlCommand(query, OasisConnection); using (SqlDataReader rd = SelectCommand.ExecuteReader()) { while (rd.Read()) { notificationModel notify = new notificationModel(); notify.Fk_senderID = Convert.ToInt32(rd["Fk_SenderID"]); notify.RecieverRole = rd["RecieverRole"].ToString(); notify.Notification = rd["Notification"].ToString(); notify.datesent = Convert.ToDateTime(rd["datesent"]); Noticafition.Add(notify); } } return(View(Noticafition)); }
public HttpResponseMessage Get() { HttpResponseMessage message = null; string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim(); notificationModel response = new notificationModel(); try { if (dbconn.idbCheck(out dbres)) { string userCardNo = string.Empty; string userAdminNo = string.Empty; if (dbconn.checkToken(token, out userCardNo, out userAdminNo)) { DataTable dt = dbconn.getTable(appServiceQry.getAppNotification(userCardNo)); List <notificationDetial> notis = new List <notificationDetial>(); foreach (DataRow item in dt.Rows) { notificationDetial dtl = new notificationDetial(); dtl.notiName = item["NOTIFICATION_NAME"].ToString(); dtl.notiText = item["NOTIFICATION_TEXT"].ToString(); dtl.notiImgUrl = item["NOTIFICATION_IMG_URL"].ToString(); dtl.notiDate = item["NOTIDATE"].ToString(); notis.Add(dtl); } response.isSuccess = true; response.resultCode = HttpStatusCode.OK.ToString(); response.resultMessage = "success"; response.notifications = notis; } else { response.isSuccess = false; response.resultCode = HttpStatusCode.Unauthorized.ToString(); response.resultMessage = appConstantValues.MSG_EXPIRED; } } else { response.isSuccess = false; response.resultCode = HttpStatusCode.NotFound.ToString(); response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR; LogWriter._error(TAG, dbres); } } catch (Exception ex) { exceptionManager.ManageException(ex, TAG); response.isSuccess = false; response.resultCode = HttpStatusCode.NotFound.ToString(); response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR; } message = Request.CreateResponse(HttpStatusCode.OK, response); LogWriter._noti(TAG, string.Format("IP: [{0}], Request: [{1}], Response: [{2}], Token: [{3}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), "", serializer.Serialize(response), token)); return(message); }
/*IFirebaseConfig config = new FirebaseConfig * { * AuthSecret = "XrO8HZD-SsUSld64BI62NgD7SabTXOMA_k6z_kq1ORM", * BasePath = "https://xdadeveloperes.firebaseio.com/" * * };*/ // GET: notification public ActionResult notify() { var id = vendorId(User.Identity.Name); notificationModel tempmodel = new notificationModel(); tempmodel.detail = Getarea(id); tempmodel.vendorId = id; // return View(detail); return(View(tempmodel)); }
public ActionResult NotificationDetailProduction(int NotificationID) { { List <TaskModel> Noticafition = new List <TaskModel>(); Session["notificationID"] = NotificationID; OasisConnectionManager = ConfigurationManager.ConnectionStrings["OasisConnectionString"].ConnectionString; OasisConnection = new SqlConnection(OasisConnectionManager); DataTable dataTable = new DataTable(); OasisConnection.Open(); var query = "select * from Notifications where id='" + NotificationID + "'"; SqlCommand SelectCommand = new SqlCommand(query, OasisConnection); notificationModel notify = new notificationModel(); using (SqlDataReader rd = SelectCommand.ExecuteReader()) { if (rd.Read()) { notify.id = Convert.ToInt32(rd["id"]); notify.Fk_TaskID = Convert.ToInt32(rd["Fk_TaskID"]); notify.RecieverRole = rd["RecieverRole"].ToString(); notify.Notification = rd["Notification"].ToString(); notify.datesent = Convert.ToDateTime(rd["datesent"]); OasisConnection.Close(); return(View(notify)); } else { notify.RecieverRole = "no data"; return(View(notify)); } } } }
public ActionResult notify(notificationModel n) { //string path = uploadimage(notimage); using (var context = new promoLacDbEntities()) { if (ModelState.IsValid) { { foreach (var x in n.areaName) { notification not = new notification() { notificationTitle = n.notificationTitle, notificationDescription = n.notificationDescription, notificationAreaId = getAreaId(x), notificationStatus = "s", vendorId = n.vendorId, notificationTime = DateTime.Now }; string towards = getHashCode(not.notificationAreaId); context.notifications.Add(not); updatemessagesent(); context.SaveChanges(); string SERVER_API_KEY = "AAAAtlCjlu4:APA91bGGwQ8HSMWLf7dVoD3c1XB3O7IBmhet0im9YCbFuxDF5pVui8IBZ8iCXcnUv2K32XVLnoAFwU17CdeYs3SGW6IX01dKeRSXAht8cS7WPg21fU_WIrkX8o-1FpWyQjlPxFj_mp8R"; var SENDER_ID = "783036946158"; WebRequest tRequest; tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send"); tRequest.Method = "post"; tRequest.ContentType = "application/json"; tRequest.Headers.Add(string.Format("Authorization: key={0}", SERVER_API_KEY)); tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID)); var data = new { notification = new { body = not.notificationDescription, title = not.notificationTitle } , to = "/topics/" + towards }; var serializer = new JavaScriptSerializer(); var json = serializer.Serialize(data); //logger.Info("json: " + json); Byte[] byteArray = Encoding.UTF8.GetBytes(json); tRequest.ContentLength = byteArray.Length; Stream dataStream = tRequest.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse tResponse = tRequest.GetResponse(); dataStream = tResponse.GetResponseStream(); StreamReader tReader = new StreamReader(dataStream); String sResponseFromServer = tReader.ReadToEnd(); tReader.Close(); dataStream.Close(); tResponse.Close(); /* notificationModel nt = new notificationModel(); * nt.notificationAreaId = not.notificationAreaId.ToString(); * nt.notificationDescription = n.notificationDescription; * nt.notificationId = not.notificationId.ToString(); * nt.notificationStatus = "s"; * nt.notificationTitle = n.notificationTitle; * * * * IFirebaseConfig mes = new FirebaseConfig * { * AuthSecret = "CwnE0VGXMqxNxcY5YSWVNcL7IAM3hfqRuSiNjWm5", * BasePath = "https://xdadeveloperes.firebaseio.com/" * }; * * IFirebaseClient mfc; * mfc = new FireSharp.FirebaseClient(mes); * * var set = mfc.Set(@"Messages/" + not.notificationId, nt); */ } } } } return(Json(new { success = true, message = "dddd" }, JsonRequestBehavior.AllowGet)); }
public ActionResult just() { List <notificationModel> Noticafition = new List <notificationModel>(); OasisConnectionManager = ConfigurationManager.ConnectionStrings["OasisConnectionString"].ConnectionString; OasisConnection = new SqlConnection(OasisConnectionManager); DataTable dataTable = new DataTable(); OasisConnection.Open(); var query = "select * from messages where FK_RecieverID=" + Convert.ToInt32(Session["id"]); SqlCommand SelectCommand = new SqlCommand(query, OasisConnection); int count = 0; using (SqlDataReader rd = SelectCommand.ExecuteReader()) { Session["totalMsg"] = rd.FieldCount; while (rd.Read()) { if (rd["MsgStatus"].ToString() == "Sent") { count = count + 1; } } Session["msgNum"] = count; } if (OasisConnection.State == ConnectionState.Open) { OasisConnection.Close(); OasisConnectionManager = ConfigurationManager.ConnectionStrings["OasisConnectionString"].ConnectionString; OasisConnection = new SqlConnection(OasisConnectionManager); OasisConnection.Open(); var queryNotification = "select * from Notifications where RecieverRole='" + "ProductionDepartment" + "'"; SqlCommand SelectNotificatoinCommand = new SqlCommand(queryNotification, OasisConnection); using (SqlDataReader rd = SelectNotificatoinCommand.ExecuteReader()) { while (rd.Read()) { notificationModel notify = new notificationModel(); notify.id = Convert.ToInt32(rd["id"]); notify.RecieverRole = rd["RecieverRole"].ToString(); notify.Notification = rd["Notification"].ToString(); notify.datesent = Convert.ToDateTime(rd["datesent"]); Noticafition.Add(notify); } } } return(View(Noticafition)); }