Exemple #1
0
        protected override void OnMessage(Context context, Intent intent)
        {
            var payloadString         = intent.Extras.GetString("payload");
            PushNotificationData data = JsonConvert.DeserializeObject <PushNotificationData> (payloadString);
            string title  = "";
            string detail = "";

            PushNotificationUtils.GetDetailedActionDescription(data, out title, out detail);
            long[] vibratePattern = { 0, 500, 100, 200, 100, 200 };

            Intent        todoIntent    = new Intent(context, typeof(MyGamesActivity));
            PendingIntent pendingIntent = PendingIntent.GetActivity(context, 123, todoIntent, PendingIntentFlags.CancelCurrent);

            NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                                                 .SetContentTitle(title)
                                                 .SetContentText(detail)
                                                 .SetSmallIcon(Resource.Drawable.Icon)
                                                 .SetVibrate(vibratePattern)
                                                 .SetLights(Color.Purple.ToArgb(), 1000, 2000)
                                                 .SetContentIntent(pendingIntent)
                                                 .SetOnlyAlertOnce(true);
            if (!string.IsNullOrEmpty(data.ThumbnailUri))
            {
                WebClient client  = new WebClient();
                var       imgData = client.DownloadData(data.ThumbnailUri);
                var       bmp     = BitmapFactory.DecodeByteArray(imgData, 0, imgData.Length);
                builder.SetLargeIcon(bmp);
            }

            // Obtain a reference to the NotificationManager
            var notification = builder.Build();
            NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);

            notificationManager.Notify(125165626, notification);
        }
Exemple #2
0
        ///<summary>Dependencies checked first and throws an exception if any found. So surround by try catch</summary>
        public static void Delete(TreatPlan tp)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), tp);
                return;
            }
            //check proctp for dependencies
            string    command = "SELECT * FROM proctp WHERE TreatPlanNum =" + POut.Long(tp.TreatPlanNum);
            DataTable table   = Db.GetTable(command);

            if (table.Rows.Count > 0)
            {
                //this should never happen
                throw new ApplicationException(Lans.g("TreatPlans", "Cannot delete treatment plan because it has ProcTP's attached"));
            }
            command = "DELETE from treatplan WHERE TreatPlanNum = '" + POut.Long(tp.TreatPlanNum) + "'";
            Db.NonQ(command);
            if (!tp.TPStatus.In(TreatPlanStatus.Saved))
            {
                return;
            }
            List <MobileAppDevice> listPatDevices = MobileAppDevices.GetAll(tp.PatNum);

            if (listPatDevices.Count > 0)
            {
                PushNotificationUtils.CI_RemoveTreatmentPlan(listPatDevices.First().MobileAppDeviceNum, tp);
            }
        }
        ///<summary>Attempts to find exact match for patient. If found, creates commlog, associates Patnum, and inserts into DB.
        ///Otherwise, it simply inserts SmsFromMobiles into the DB. ClinicNum should have already been set before calling this function.</summary>
        public static void ProcessInboundSms(List <SmsFromMobile> listMessages)
        {
            if (listMessages == null || listMessages.Count == 0)
            {
                return;
            }
            List <SmsBlockPhone> listBlockedPhones = SmsBlockPhones.GetDeepCopy();

            for (int i = 0; i < listMessages.Count; i++)
            {
                SmsFromMobile sms = listMessages[i];
                if (listBlockedPhones.Any(x => TelephoneNumbers.AreNumbersEqual(x.BlockWirelessNumber, sms.MobilePhoneNumber)))
                {
                    continue;                    //The office has blocked this number.
                }
                sms.DateTimeReceived = DateTime.Now;
                string countryCode = CultureInfo.CurrentCulture.Name.Substring(CultureInfo.CurrentCulture.Name.Length - 2);
                if (sms.SmsPhoneNumber != SmsPhones.SHORTCODE)
                {
                    SmsPhone smsPhone = SmsPhones.GetByPhone(sms.SmsPhoneNumber);
                    if (smsPhone != null)
                    {
                        sms.ClinicNum = smsPhone.ClinicNum;
                        countryCode   = smsPhone.CountryCode;
                    }
                }
                if (!PrefC.HasClinicsEnabled)
                {
                    //We want customer side records of this message to list SmsPhones.SHORTCODE as the number on which the message was sent.  This ensures we do
                    //not record this communication on a different valid SmsPhone/VLN that it didn't truly take place on.  However, on the HQ side, we want
                    //records of this communication to be listed as having taken place on the actual Short Code number.  In the case of a Short Code,
                    //sms.SmsPhoneNumber will read "SHORTCODE", which won't be found in the customer's SmsPhone table.  As a result, the code to use the
                    //customer's SmsPhone.ClinicNum and Country code cannot be used.  Since this code was intended to handle the case where the customer had
                    //turned clinics on->off, we will specifically check if the customer has disabled clinics and only then change the sms.ClinicNum.
                    //Otherwise, trust HQ sent the correct ClinicNum.  Since we expect to only use Short Codes in the US/Canada, we will trust the server we
                    //are processing inbound sms will have the correct country code, which will be used here.
                    sms.ClinicNum = 0;
                }
                //First try the clinic that belongs to this phone.
                List <long> listClinicNums = new List <long>();
                if (sms.ClinicNum != 0)
                {
                    listClinicNums.Add(sms.ClinicNum);
                }
                List <long[]> listPatNums = FindPatNums(sms.MobilePhoneNumber, countryCode, listClinicNums);
                if (listPatNums.Count == 0 && listClinicNums.Count > 0)            //Could not find that patient in this clinic so try again for all clinics.
                {
                    listPatNums = FindPatNums(sms.MobilePhoneNumber, countryCode);
                }
                sms.MatchCount = listPatNums.Count;
                //Item1=PatNum; Item2=Guarantor
                if (listPatNums.Count == 0 || listPatNums.Select(x => x[1]).Distinct().ToList().Count != 1)
                {
                    //We could not find definitive match, either 0 matches found, or more than one match found with different garantors
                    Insert(sms);
                    //Alert ODMobile where applicable.
                    PushNotificationUtils.ODM_NewTextMessage(sms);
                    continue;
                }
                if (listPatNums.Count == 1)
                {
                    sms.PatNum = listPatNums[0][0];                  //PatNum
                }
                else
                {
                    sms.PatNum = listPatNums[0][1];                  //GuarantorNum;  more than one match, but all have the same garantor.
                }
                Commlog comm = new Commlog()
                {
                    CommDateTime   = sms.DateTimeReceived,
                    Mode_          = CommItemMode.Text,
                    Note           = sms.MsgText,
                    PatNum         = sms.PatNum,
                    CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.TEXT),
                    SentOrReceived = CommSentOrReceived.Received
                };
                sms.CommlogNum = Commlogs.Insert(comm);
                Insert(sms);
                //Alert ODMobile where applicable.
                PushNotificationUtils.ODM_NewTextMessage(sms, sms.PatNum);
            }
            //We used to update the SmsNotification indicator via a queries and a signal here.  Now managed by the eConnector.
        }