public static void ShowNotification(Models.Notification _Notification)
        {
            if (DateTime.ParseExact(_Notification.START_DATE, Constants.TIME_FORMAT, null) > DateTime.Now)
            {
                var             HUINotification = new UILocalNotification();
                NSDateFormatter HFormatter      = new NSDateFormatter();
                HFormatter.DateFormat       = Params.Constants.TIME_FORMAT;
                HUINotification.FireDate    = HFormatter.Parse(_Notification.START_DATE);
                HUINotification.AlertTitle  = _Notification.CAPTION;
                HUINotification.AlertBody   = _Notification.DESCRIPTION;
                HUINotification.AlertAction = "ViewAlert";

                NSMutableDictionary HCustomDictionary = new NSMutableDictionary();

                HCustomDictionary.SetValueForKey(new NSNumber(_Notification.EVENT_IDENT != -1), new NSString("BY_EVENT"));
                if (_Notification.EVENT_IDENT != -1)
                {
                    HCustomDictionary.SetValueForKey(new NSNumber(_Notification.EVENT_IDENT), new NSString("EVENT_IDENT"));
                }
                else
                {
                    if (_Notification.EVENT_DATE != "")
                    {
                        HCustomDictionary.SetValueForKey(new NSString(_Notification.EVENT_DATE), new NSString("START_DATE"));
                    }
                }
                HUINotification.UserInfo = HCustomDictionary;
                UIApplication.SharedApplication.ScheduleLocalNotification(HUINotification);
            }
        }
Esempio n. 2
0
        private async void ClientExistsListener_Succes(object sender, EventArgs e)
        {
            var documentSnap = (DocumentSnapshot)sender;

            if (documentSnap.Exists())
            {
                clientLoggedData.MedicSubscribed = medicSelected;
                await _storageService.SaveClientDataLocal(clientLoggedData);

                // send notification to the new medic
                Models.Notification subscribeNotif = new Models.Notification()
                {
                    Description = $"{clientLoggedData.FirstName}, {clientLoggedData.LastName} s-a abonat la dumneavoastra.",
                    Type        = "Client nou",
                    Timestamp   = DateTime.Now.ToLocalTime(),
                    MedicId     = clientLoggedData.MedicSubscribed.Id,
                };
                await _functionsService.AddNotification(subscribeNotif, "notificationCreate");

                progress.Dismiss();
                Toast.MakeText(this, "Migrarea efectuata cu succes!", ToastLength.Long).Show();
            }
            else
            {
                Toast.MakeText(this, "Migrarea nu a fost efectuata, relogati-va!", ToastLength.Long).Show();
                progress.Dismiss();
            }
        }
Esempio n. 3
0
        public async Task <bool> RegisterNotification(Models.Notification notification, bool isReminderAlreadyInserted = false)
        {
            try
            {
                Reminder reminder = new Reminder();
                reminder.Body  = notification.Body;
                reminder.Title = notification.Title;
                reminder.ETA   = notification.UntilDate;

                if (!isReminderAlreadyInserted)
                {
                    await ReminderLocalDbService.InsertReminderAsync(reminder);

                    notification.ReminderID = reminder.ID;
                }
                else
                {
                    reminder.ID = notification.ReminderID;
                }

                TimeSpan timeSpan = new TimeSpan();
                timeSpan = notification.UntilDate.Subtract(DateTime.Now);



                // Todo: Extract to method that takes NotificationFrequency and builds a notification list based on that
                if (notification.FrequencyToSend == Enums.NotificationFrequency.DAILY)
                {
                    for (int i = 0; i < timeSpan.Days; i++)
                    {
                        Plugin.Notifications.Notification notificationObject = new Plugin.Notifications.Notification
                        {
                            Title   = notification.Title,
                            Message = $"{notification.Body} ({timeSpan.Days - i} Day(s))",
                            Vibrate = true,
                            When    = TimeSpan.FromDays(i)
                        };
                        await CrossNotifications.Current.Send(notificationObject);

                        if (notificationObject.Id != 0)
                        {
                            NotificationLink notificationLink = new NotificationLink();
                            notificationLink.ReminderID     = reminder.ID;
                            notificationLink.NotificationID = notificationObject.Id ?? 0;

                            var a = await NotificationLinkLocalService.InsertNotificationLinkAsync(notificationLink);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Notifies the specified notification.
        /// </summary>
        /// <param name="notification">The notification.</param>
        public void Notify(Models.Notification notification)
        {
            long triggerTime = NotifyTimeInMilliseconds(notification.NotifyTime);

            AlarmManager.Set(AlarmType.ElapsedRealtimeWakeup,
                             SystemClock.ElapsedRealtime() + triggerTime,
                             CreatePendingIntent(notification.Id, notification));
        }
Esempio n. 5
0
        public void SendNotification(string message, int user)
        {
            //Create an instance of the Repository class
            Models.Notification Repos = new Models.Notification();


            //Invoke the Add Notification method that we created in the repository to add the notification to the database 
            Repos.AddNotification(message, user);
        }
Esempio n. 6
0
        private async void OnDelete(Models.Notification notification)
        {
            if (notification != null)
            {
                Notifications.Remove(notification);
                await _notificationService.DeleteNotificationAsync(notification);

                HasItems = Notifications.Count > 0;
            }
        }
Esempio n. 7
0
        private string SerializeNotification(Models.Notification notification)
        {
            XmlSerializer xmlSerializer = new(notification.GetType());

            using StringWriter stringWriter = new();

            xmlSerializer.Serialize(stringWriter, notification);

            return(stringWriter.ToString());
        }
        public void Post([FromBody] List <Models.ReportIncident> incidents)
        {
            var incidentTypes = this._db.IncidentTypes.Where(t => t.incidentReportTypeId == 1).ToList();


            foreach (Models.ReportIncident incident in incidents)
            {
                this._db.ReportIncidents.Add(incident);
                this._db.SaveChanges();

                var incidentType = incidentTypes.Where(t => t.incidentTypeId == incident.incidentTypeId).SingleOrDefault();

                if (incidentType != null)
                {
                    if (incidentType.incidentCategoryId == 1 || incidentType.incidentCategoryId == 2) // REPORTABLE TO JC
                    {
                        ReportsController reportsController         = new ReportsController();
                        Models.Presentation.ReportsViewModel report = reportsController.GetReportHeader(incident.incidentId);
                        reportsController.Dispose();


                        Controllers.MailController mailer = new MailController();

                        List <string> sendTos = new List <string>();
                        StringBuilder msg     = new StringBuilder();

                        sendTos.Add("*****@*****.**");

                        Models.Notification notification = new Models.Notification();

                        notification.incidentId        = incident.incidentId;
                        notification.notifyPartyId     = 37;
                        notification.notifyDateTime    = DateTime.Now;
                        notification.notifyContact     = "CFS Compliance";
                        notification.notifyMethod      = "E-Mail";
                        notification.notifyStaffId     = 0;
                        notification.notifyComments    = "Automatic E-Mail sent to compliance by incident report system.";
                        notification.isAcknowledged    = 1;
                        notification.acknowledgeUserId = 0;

                        this._db.Notifications.Add(notification);
                        this._db.SaveChanges();

                        msg.Append("<h1>Incident Report: Compliance Notification</h1>");
                        msg.Append("<p>A new incident report for client " + report.clientName + " by " + report.staffName + " has been created and is being forwarded to compliance.</p>");
                        msg.Append("<p><a href=\"http://cfs-incidents/Admin/Review/" + report.incidentId.ToString() + "\">Click here to view the report.</a></p>");


                        //sendTos.Add(notifier.emailAddress);
                        //sendTos.Add("*****@*****.**"); //MTS - commented out March '18
                        mailer.SendMail(sendTos, "*****@*****.**", "Incident Report Compliance Notification: " + report.clientName, System.Net.Mail.MailPriority.High, msg);
                    }
                }
            }
        }
        public Models.Notification GetSingle(long id)
        {
            var notification = this._db.Notifications.Where(n => n.notificationId == id).SingleOrDefault();

            if (notification == null)
            {
                notification = new Models.Notification();
            }

            return(notification);
        }
Esempio n. 10
0
        public override System.Threading.Tasks.Task OnConnected()
        {
            //Create an instance of the Repository class
            Models.Notification objRepository = new Models.Notification();

            //refreshNotification is the client side method which will be writing in the future section. GetLogin() is a static extensions extract just the login name scrapping the domain name 
            Clients.User(Context.User.Identity.Name).refreshNotification(objRepository.GetNotifications("Avil");

            return base.OnConnected();

        }
        // POST api/<controller>
        public void Post([FromBody] Models.Notification notification)
        {
            if (notification.notificationId == 0)
            {
                this._db.Notifications.Add(notification);
            }
            else
            {
                this._db.Notifications.Attach(notification);
                this._db.Entry(notification).State = System.Data.Entity.EntityState.Modified;
            }

            this._db.SaveChanges();


            if (notification.notifyPartyId == 8)  // JUSTICE CENTER
            {
                ReportsController reportsController         = new ReportsController();
                Models.Presentation.ReportsViewModel report = reportsController.GetReportHeader(notification.incidentId);
                reportsController.Dispose();


                Controllers.MailController mailer = new MailController();

                List <string> sendTos = new List <string>();
                StringBuilder msg     = new StringBuilder();

                sendTos.Add("*****@*****.**");

                Models.Notification complianceNotification = new Models.Notification();

                complianceNotification.incidentId        = notification.incidentId;
                complianceNotification.notifyPartyId     = 37;
                complianceNotification.notifyDateTime    = DateTime.Now;
                complianceNotification.notifyContact     = "CFS Compliance";
                complianceNotification.notifyMethod      = "E-Mail";
                complianceNotification.notifyStaffId     = 0;
                complianceNotification.notifyComments    = "Automatic E-Mail sent to compliance by incident report system.";
                complianceNotification.isAcknowledged    = 1;
                complianceNotification.acknowledgeUserId = 0;

                this._db.Notifications.Add(complianceNotification);
                this._db.SaveChanges();

                msg.Append("<h1>Incident Report: Compliance Notification</h1>");
                msg.Append("<p>A new incident report for client " + report.clientName + " by " + report.staffName + " has been created and is being forwarded to compliance.</p>");
                msg.Append("<p><a href=\"http://cfs-incidents/admin/review/" + report.incidentId.ToString() + "\">Click here to view the report.</a></p>");


                //sendTos.Add(notifier.emailAddress);
                //sendTos.Add("*****@*****.**"); //MTS - commented out March '18
                mailer.SendMail(sendTos, "*****@*****.**", "Incident Report Compliance Notification: Justice Center Called", System.Net.Mail.MailPriority.High, msg);
            }
        }
Esempio n. 12
0
        public async void SendSingleNotification(Models.Notification notification)
        {
            TimeSpan ts       = notification.UntilDate.Subtract(DateTime.Now);
            int      dayCount = ts.Days;

            await CrossNotifications.Current.Send(new Notification()
            {
                Title   = notification.Title,
                Message = $"{notification.Body} ({dayCount} days)",
                When    = TimeSpan.FromSeconds(0)
            });
        }
        public HttpResponseMessage Send([FromBody] Models.Notification notification)
        {
            #region log user request and response

            /***********************************************
            *  To log user request and response
            ***********************************************/
            if (_logRequestResponse)
            {
                LogManager.CurrentInstance.InfoLogger.LogInfo(
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, System.Reflection.MethodBase.GetCurrentMethod().Name + "===>" +
                    "Request ===> " + JsonConvert.SerializeObject(notification));
            }

            //Console.WriteLine("Request ===> " + JsonConvert.SerializeObject(notification));

            #endregion

            if (ModelState.IsValid)
            {
                try
                {
                    if (_notificationManager == null)
                    {
                        _notificationManager = new NotificationManager();
                    }
                    _notificationManager.SendNotification(notification);
                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                catch (ApplicationException appExp)
                {
                    LogManager.CurrentInstance.ErrorLogger.LogError(
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,
                        JsonConvert.SerializeObject(notification) + ", error:" + appExp.Message, System.Reflection.MethodBase.GetCurrentMethod().Name);
                    return(Request.CreateErrorResponse((HttpStatusCode)Convert.ToInt32(appExp.Message), ""));
                }
                catch (Exception exp)
                {
                    LogManager.CurrentInstance.ErrorLogger.LogError(
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,
                        JsonConvert.SerializeObject(notification) + ", error:" + exp.Message, exp, System.Reflection.MethodBase.GetCurrentMethod().Name);
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ""));
                }
            }
            else
            {
                LogManager.CurrentInstance.ErrorLogger.LogError(
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,
                    JsonConvert.SerializeObject(notification), System.Reflection.MethodBase.GetCurrentMethod().Name);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ""));
            }
        }
Esempio n. 14
0
        private PendingIntent CreatePendingIntent(int id, Models.Notification noti = null)
        {
            Intent intent = new Intent(Application.Context, typeof(ScheduledAlarmReceiver))
                            .SetAction($"LocalNotiIntent{id}");

            if (noti is not null)
            {
                intent.PutExtra(ScheduledAlarmReceiver.LocalNotificationKey, SerializeNotification(noti));
            }

            return(PendingIntent.GetBroadcast(Application.Context, 0, intent,
                                              PendingIntentFlags.UpdateCurrent | PendingIntentFlags.Mutable));
        }
Esempio n. 15
0
        private void AppointmentAdapter_Click(object sender, EventArgs e)
        {
            // get services;
            UserService userService = new UserService();
            var         firestoreDb = userService.GetDatabase(_context);
            // get local storage service

            View receivedView = (View)sender;
            var  appoitnId    = receivedView.GetTag(deleteBtn.Id);

            Console.WriteLine("Button clicked.");


            var deleteAppointAlert = new AlertDialog.Builder(_context);

            deleteAppointAlert.SetTitle("Sterge programare");
            deleteAppointAlert.SetMessage($"Sunteti sigur ca doriti sa stergeti aceasta programare?");
            deleteAppointAlert.SetPositiveButton("Da", async delegate {
                StorageService storage = new StorageService();
                var clientLogged       = await storage.GetClientDataLocal();
                firestoreDb.Collection("Medics").Document(clientLogged.MedicSubscribed.Id).Collection("Appointments").Document(appoitnId.ToString())
                .Delete();
                // delete appointment also from list
                List <Appointment> appointsList = _appointments.ToList <Appointment>();
                var appointToDelete             = appointsList.FirstOrDefault(appoint => appoint.Id.Equals(appoitnId.ToString()));
                appointsList.Remove(appointToDelete);

                //send notification that appointment was deleted
                Models.Notification newNotif = new Models.Notification()
                {
                    Description = $"Programarea a fost anulata de catre {clientLogged.FirstName}, {clientLogged.LastName}.",
                    Type        = "Programare anulata",
                    Timestamp   = DateTime.Now.ToLocalTime(),
                    MedicId     = clientLogged.MedicSubscribed.Id,
                };

                await _functionsService.AddNotification(newNotif, "notificationCreate");

                _appointments = appointsList.ToArray();
                deleteAppointAlert.Dispose();
                _context.Finish();
                _context.StartActivity(typeof(UpcomingAppointmentsActivity));
                return;
            });
            deleteAppointAlert.SetNegativeButton("Nu", delegate
            {
                deleteAppointAlert.Dispose();
            });
            deleteAppointAlert.Show();
        }
Esempio n. 16
0
        public async Task <int> AddNotification(Models.Notification notification)
        {
            var dbModel = new NotificationDB()
            {
                Link = notification.Link,
                Id   = notification.Id,
                Text = notification.Text,
            };
            await _databaseContext.Notifications.AddAsync(dbModel);

            await _databaseContext.SaveChangesAsync();

            return(dbModel.Id);
        }
Esempio n. 17
0
        public async Task AddNotification(Models.Notification newNotif, string functionCall)
        {
            TaskCompletionListener taskCompletionListener = new TaskCompletionListener();
            var app = FirebaseApp.InitializeApp(_context);

            firebaseFunc = FirebaseFunctions.GetInstance(app);

            var func = firebaseFunc.GetHttpsCallable(functionCall)
                       .Call(JsonConvert.SerializeObject(newNotif))
                       .AddOnSuccessListener(_activity, taskCompletionListener);

            taskCompletionListener.Succes  += TaskCompletionListener_Succes;
            taskCompletionListener.Failure += TaskCompletionListener_Failure;
        }
Esempio n. 18
0
        public void Notify(Models.Notification notification)
        {
            ToastContent builder = new ToastContentBuilder()
                                   .AddToastActivationInfo("ResinNoti", ToastActivationType.Foreground)
                                   .AddText(notification.Title)
                                   .AddText(notification.Text)
                                   .GetToastContent();

            var toast = new ScheduledToastNotification(builder.GetXml(), notification.NotifyTime)
            {
                Tag   = notification.Id.ToString(),
                Group = $"ResinNoti"
            };

            UWPNotifier.AddToSchedule(toast);
        }
Esempio n. 19
0
        public long SaveNotifications(PushNotification model)
        {
            long result          = -1;
            var  message         = "{\"data\":{\"subject\":\"" + model.Subject + "\",\"content\":\"" + model.Body + "\"}}";
            var  context         = new EventAppDataModelEntity();
            var  notificationAdd = new Models.Notification()
            {
                Message = @model.Body, Title = @model.Subject, CreatedOn = DateTime.UtcNow
            };

            context.Notifications.Add(notificationAdd);
            context.SaveChanges();
            result = notificationAdd.NotificationId;
            return(result);
            // return result;
        }
Esempio n. 20
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Notification = await _context.Notifications
                           .Include(n => n.Customer).FirstOrDefaultAsync(m => m.NotificationID == id);

            if (Notification == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IdResult> UpdateRead(Models.Notification item)
        {
            if (item == null)
            {
                return(new IdResult()
                {
                    IsOk = false,
                    ErrorMessage = "No notification info"
                });
            }

            Common.Model.Notification itemDb = null;
            var dbUser = DbUser;

            using (NotificationRepository _notificationRepository = new NotificationRepository(Context, dbUser, null))
            {
                itemDb = _notificationRepository.GetById(item.Id);
                if (itemDb != null)
                {
                    try
                    {
                        _notificationRepository.Update(itemDb);
                        itemDb.ReadDate = DateTime.Now;
                        Context.SaveChanges();
                        return(new IdResult()
                        {
                            IsOk = true,
                            Id = itemDb.Id
                        });
                    }
                    catch (Exception e)
                    {
                        LogHelper.WriteError(e);
                        return(new IdResult()
                        {
                            IsOk = false,
                            ErrorMessage = "Error On Save"
                        });
                    }
                }
                return(new IdResult()
                {
                    IsOk = false,
                    ErrorMessage = "No notification info"
                });
            }
        }
Esempio n. 22
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Notification = await _context.Notifications
                           .Include(n => n.Customer).FirstOrDefaultAsync(m => m.NotificationID == id);

            if (Notification == null)
            {
                return(NotFound());
            }
            ViewData["CustomerID"] = new SelectList(_context.Customers, "CustomerID", "CustomerID");
            return(Page());
        }
Esempio n. 23
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Notification = await _context.Notifications.FindAsync(id);

            if (Notification != null)
            {
                _context.Notifications.Remove(Notification);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        /*public Notification GenerateNotification(Intent intent)
        {
            if (intent.Extras != null)
            {
                var shipmentId = long.Parse((string)intent.Extras.Get(Constants.SHIPMENT_ID_KEY));
                var jobReference = (string)intent.Extras.Get(Constants.JOB_REFERENCE_KEY);
                var transportType = (string)intent.Extras.Get(Constants.TRANSPORT_TYPE_KEY);
                var title = (string)intent.Extras.Get("Title");
                var description = (string)intent.Extras.Get("Description");
                Shipment shipment = ((List<Shipment>)ListDataModel.shipments).Find(
                delegate (Shipment sm)
                {
                    return sm.JobReferenceNumber.ToLowerInvariant().Contains(jobReference.Trim().ToLowerInvariant());
                });
                app.Notify(true, shipment);
            }
        }*/

        private void HandleNotification(RemoteMessage message)
        {
            int id = DateTime.Now.Millisecond;
            Log.Debug(TAG, "message data: " + message.Data); // this will return android.support.v4.util.ArrayMap
            Log.Debug(TAG, "message data: " + message.Data.GetEnumerator().ToString()); //  Android.Runtime.JavaDictionary`2+<GetEnumerator>c__Iterator0[System.String,System.String]
            Log.Debug(TAG, "From: " + message.From); //From: sender
            Log.Debug(TAG, "Notification Message Body: " + message.GetNotification().Body);
            var intent = message.ToIntent();

            if (intent.Extras != null)
            {
                foreach (var key in intent.Extras.KeySet())
                {
                    var value = intent.Extras.GetString(key);
                    Log.Debug(TAG, "Key: {0} Value: {1}", key.ToString(), Convert.ToString(value));
                }
            }

            Models.Notification notification = new Models.Notification
            {
                Title = message.GetNotification().Title,
                Description = message.GetNotification().Body,
                ReceiptDateTime = DateTime.Now,
                Payload = new Models.NotificationPayload(),
                IsRead = false
            };

            if (intent.Extras.ContainsKey(Constants.SHIPMENT_ID_KEY))
            {
                notification.Payload.ShipmentId = long.Parse(((string)intent.Extras.Get(Constants.SHIPMENT_ID_KEY)).Trim());
            }

            if (intent.Extras.ContainsKey(Constants.JOB_REFERENCE_KEY))
            {
                notification.Payload.JobReferenceNumber = ((string)intent.Extras.Get(Constants.JOB_REFERENCE_KEY)).Trim();
            }

            if (intent.Extras.ContainsKey(Constants.TRANSPORT_TYPE_KEY))
            {
                notification.Payload.TransportType = ((string)intent.Extras.Get(Constants.TRANSPORT_TYPE_KEY)).Trim();
            }

            NotificationViewModel.AddNotification(notification);
            NotificationViewModel.UpdateNotifications(Constants.Notification_VM_Instance);
            MainViewModel.UpdateBadgeAttributes(Constants.Main_VM_Instance, false, Constants.Main_VM_Instance.UnreadNotificationCount + 1);
        }
Esempio n. 25
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Notification = await _context.Notification
                           .Include(n => n.Assignee)
                           .Include(n => n.Bug).FirstOrDefaultAsync(m => m.Id == id);

            if (Notification == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Esempio n. 26
0
        private Notification CreateNativeNotification(Context context, Models.Notification notification)
        {
            var builder = new NotificationCompat.Builder(Application.Context, AndroidAppEnvironment.CHANNEL_ID)
                          .SetAutoCancel(true)
                          .SetVisibility((int)NotificationVisibility.Public)
                          .SetContentIntent(PendingIntent.GetActivity(context, 0, new Intent(context, typeof(SplashActivity)),
                                                                      PendingIntentFlags.UpdateCurrent |
                                                                      PendingIntentFlags.Mutable))
                          .SetContentTitle(notification.Title)
                          .SetContentText(notification.Text)
                          .SetSmallIcon(Application.Context.ApplicationInfo.Icon);

            if (context.PackageManager.GetLaunchIntentForPackage("com.miHoYo.GenshinImpact") is not null)
            {
                Intent runIntent = new Intent(context, typeof(NotiActionReceiver))
                                   .SetAction("RUN_GENSHIN")
                                   .PutExtra("NotiId", notification.Id);

                PendingIntent pRunIntent = PendingIntent.GetBroadcast(context, 0, runIntent,
                                                                      PendingIntentFlags.UpdateCurrent |
                                                                      PendingIntentFlags.Mutable);

                builder.AddAction(0, AppResources.Noti_QuickAction_RunGenshinApp, pRunIntent);
            }

            if (!((notification.NotiType is NotiManager.NotificationType.Resin) ||
                  (notification.NotiType is NotiManager.NotificationType.RealmCurrency) ||
                  (notification.NotiType is NotiManager.NotificationType.RealmFriendship)))
            {
                Intent resetIntent = new Intent(context, typeof(NotiActionReceiver))
                                     .SetAction("RESET_TIMER")
                                     .PutExtra("NotiId", notification.Id)
                                     .PutExtra("NotiType", (int)notification.NotiType);

                PendingIntent pResetIntent = PendingIntent.GetBroadcast(context, 0, resetIntent,
                                                                        PendingIntentFlags.UpdateCurrent |
                                                                        PendingIntentFlags.Mutable);

                builder.AddAction(0, AppResources.Noti_QuickAction_ResetTimer, pResetIntent);
            }

            return(builder.Build());
        }
Esempio n. 27
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Notification = await _context.Notification
                           .Include(n => n.Assignee)
                           .Include(n => n.Bug).FirstOrDefaultAsync(m => m.Id == id);

            if (Notification == null)
            {
                return(NotFound());
            }
            ViewData["AssigneeId"] = new SelectList(_context.User, "Id", "Login");
            ViewData["BugId"]      = new SelectList(_context.Bug, "Id", "Title");
            return(Page());
        }
Esempio n. 28
0
        private static Dictionary <string, Models.Notification> _GetNotifications(JObject message)
        {
            Dictionary <string, Models.Notification> notifications = new Dictionary <string, Models.Notification>();

            if (message != null)
            {
                JArray value  = JArray.Parse(message["value"].ToString());
                string userId = string.Empty;
                foreach (var notification in value)
                {
                    Models.Notification current = JsonConvert.DeserializeObject <Models.Notification>(notification.ToString());
                    if (current.Validate())
                    {
                        notifications[current.Resource] = current;
                    }
                }
            }
            return(notifications);
        }
        public IActionResult OnPost()
        {
            int userId = 0;

            if (HttpContext.Session.GetInt32(SD.UserSessionId) != null)
            {
                if (HttpContext.Session.GetInt32(SD.UserSessionId).HasValue)
                {
                    userId = HttpContext.Session.GetInt32(SD.UserSessionId).Value;
                }
            }
            UserObj = _unitOfWork.User.GetFirstorDefault(u => u.ID == userId);

            if (UserObj.UserType == 'I')
            {
                Models.Notification NotificationObj = new Models.Notification();
                var points = SubmissionObj.Points;
                SubmissionObj       = _context.Submission.Where(x => x.ID == SubmissionObj.ID).FirstOrDefault();
                AssignmentObj       = _context.Assignment.Where(x => x.ID == SubmissionObj.AssignmentId).FirstOrDefault();
                AssignmentObj.Grade = points;

                NotificationObj.sourceID = SubmissionObj.AssignmentId;
                NotificationObj.Type     = 'A';
                NotificationObj.Message  = "Assignment: " + AssignmentObj.Title + " Has been Graded";


                _context.Notification.Add(NotificationObj);

                _context.SaveChanges();

                var objFromDb = _unitOfWork.Submission.Get(SubmissionObj.ID);
                objFromDb.Points = SubmissionObj.Points;
                _unitOfWork.Submission.Update(objFromDb);

                _unitOfWork.Save();

                return(Redirect("/Assignments/Grade?id=" + objFromDb.AssignmentId.ToString()));
            }

            return(NotFound());
        }
Esempio n. 30
0
 public static void FillDto(Models.Notification entity, ViewModels.NotificationX notification)
 {
     notification.Id             = entity.Id;
     notification.UserId         = entity.UserId;
     notification.CustomerId     = entity.CustomerId;
     notification.Message        = entity.Message;
     notification.DateSent       = DateTime.Now;
     notification.SenderId       = entity.SenderId;
     notification.SMS            = entity.SMS;
     notification.Email          = entity.Email;
     notification.App            = entity.App;
     notification.DateSMSSent    = null;
     notification.DateEmailSent  = null;
     notification.DateAppSent    = null;
     notification.SMSIssue       = null;
     notification.EmailIssue     = null;
     notification.AppIssue       = null;
     notification.DateAppVisited = null;
     notification.TypeId         = entity.TypeId;
     notification.Subject        = entity.Subject;
     notification.ModuleId       = entity.ModuleId;
 }