예제 #1
0
 ///<summary></summary>
 public static void Update(AlertItem alertItem)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), alertItem);
         return;
     }
     Crud.AlertItemCrud.Update(alertItem);
 }
예제 #2
0
 ///<summary></summary>
 public static long Insert(AlertItem alertItem)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         alertItem.AlertItemNum = Meth.GetLong(MethodBase.GetCurrentMethod(), alertItem);
         return(alertItem.AlertItemNum);
     }
     return(Crud.AlertItemCrud.Insert(alertItem));
 }
예제 #3
0
        ///<summary>Inserts a generic alert where description will show in the menu item and itemValue will be shown within a MsgBoxCopyPaste.
        ///Set itemValue to more specific reason for the alert.  E.g. exception text details as to help the techs give better support.</summary>
        public static void CreateGenericAlert(string description, string itemValue)
        {
            AlertItem alert = new AlertItem();

            alert.Type        = AlertType.Generic;
            alert.Actions     = ActionType.MarkAsRead | ActionType.Delete | ActionType.ShowItemValue;
            alert.Description = description;
            alert.Severity    = SeverityType.Low;
            alert.ItemValue   = itemValue;
            AlertItems.Insert(alert);
        }
예제 #4
0
        public override bool Equals(object obj)
        {
            AlertItem alert = obj as AlertItem;

            if (alert == null)
            {
                return(false);
            }
            return(this.AlertItemNum == alert.AlertItemNum &&
                   this.ClinicNum == alert.ClinicNum &&
                   this.Description == alert.Description &&
                   this.Type == alert.Type &&
                   this.Severity == alert.Severity &&
                   this.Actions == alert.Actions);
        }
예제 #5
0
 ///<summary>Returns true if the two alerts match all fields other than AlertItemNum.</summary>
 public static bool AreDuplicates(AlertItem alert1, AlertItem alert2)
 {
     if (alert1 == null || alert2 == null)
     {
         return(false);
     }
     return(alert1.Actions == alert2.Actions &&
            alert1.ClinicNum == alert2.ClinicNum &&
            alert1.Description == alert2.Description &&
            alert1.FKey == alert2.FKey &&
            alert1.FormToOpen == alert2.FormToOpen &&
            alert1.ItemValue == alert2.ItemValue &&
            alert1.Severity == alert2.Severity &&
            alert1.Type == alert2.Type &&
            alert1.UserNum == alert2.UserNum);
 }
예제 #6
0
 ///<summary>Inserts if it doesn't exist, otherwise updates.</summary>
 public static long Upsert(AlertItem alertItem)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         alertItem.AlertItemNum = Meth.GetLong(MethodBase.GetCurrentMethod(), alertItem);
         return(alertItem.AlertItemNum);
     }
     if (alertItem.AlertItemNum == 0)
     {
         Insert(alertItem);
     }
     else
     {
         Update(alertItem);
     }
     return(alertItem.AlertItemNum);
 }
예제 #7
0
 ///<summary>Checks to see if the heartbeat for Open Dental Service was within the last six minutes. If not, an alert will be sent telling
 ///users OpenDental Service is down.</summary>
 public static void CheckODServiceHeartbeat()
 {
     if (!IsODServiceRunning())             //If the heartbeat is over 6 minutes old, send the alert if it does not already exist
     //Check if there are any previous alert items
     //Get previous alerts of this type
     {
         List <AlertItem> listOldAlerts = RefreshForType(AlertType.OpenDentalServiceDown);
         if (listOldAlerts.Count == 0)               //an alert does not already exist
         {
             AlertItem alert = new AlertItem();
             alert.Actions     = ActionType.MarkAsRead;
             alert.ClinicNum   = -1;                //all clinics
             alert.Description = Lans.g("Alerts", "No instance of Open Dental Service is running.");
             alert.Type        = AlertType.OpenDentalServiceDown;
             alert.Severity    = SeverityType.Medium;
             Insert(alert);
         }
     }
 }
예제 #8
0
        /// <summary>This method grabs all unread webmails, and creates/modifies/deletes alerts for the providers and linked users the webmails are addressed to.</summary>
        public static void CreateAlertsForNewWebmail(Logger.IWriteLine log)
        {
            //This method first collect all unread webmails, and counts how many each provider has.
            //It then fetches all WebMailRecieved alerts, and will create/modify alerts for each provider who was counted before.
            //Finally, it will sync the alerts in the database with the ones we created.
            //If the user has unread webmail and an existing alert, it is modified.
            //If the user has unread webmail and no existing alert, an alert is created.
            //If the user has no unread webmail and an existing alert, it will be deleted.
            //Key: ProvNum, Value: Number of unread webmails
            Dictionary <long, long> dictRecievedCount = EmailMessages.GetProvUnreadWebMailCount();

            log.WriteLine("Collected Webmails for the following providers (ProvNum: # Webmails): "
                          + String.Join(", ", dictRecievedCount.Select(x => POut.Long(x.Key) + ":" + POut.Long(x.Value))), LogLevel.Verbose);
            //This list contains every single WebMailRecieved alert and is synced with listAlerts later.
            List <AlertItem> listOldAlerts = AlertItems.RefreshForType(AlertType.WebMailRecieved);

            log.WriteLine("Fetched current alerts for users: " + String.Join(", ", listOldAlerts.Select(x => POut.Long(x.UserNum))), LogLevel.Verbose);
            //If a user doesn't have any unread webmail, they won't be placed on this list, and any alert they have in listOldAlerts will be deleted.
            List <AlertItem> listAlerts = new List <AlertItem>();
            List <long>      listChangedAlertItemNums = new List <long>();

            //Go through each provider value, and create/update alerts for each patnum under that provider.
            //There will only be a value if they have atleast 1 unread webmail.
            foreach (KeyValuePair <long, long> kvp in dictRecievedCount)
            {
                List <Userod> listUsers = Providers.GetAttachedUsers(kvp.Key);
                //Go through each usernum and create/update their alert item.
                foreach (long usernum in listUsers.Select(x => x.UserNum))
                {
                    AlertItem alertForUser = listOldAlerts.FirstOrDefault(x => x.UserNum == usernum);
                    //If an alert doesn't exist for the user, we'll create it.
                    if (alertForUser == null)
                    {
                        alertForUser             = new AlertItem();
                        alertForUser.Type        = AlertType.WebMailRecieved;
                        alertForUser.FormToOpen  = FormType.FormEmailInbox;
                        alertForUser.Actions     = ActionType.MarkAsRead | ActionType.OpenForm; //Removed delete because the alert will just be re-added next time it checks.
                        alertForUser.Severity    = SeverityType.Normal;
                        alertForUser.ClinicNum   = -1;                                          //The alert is user dependent, not clinic dependent.
                        alertForUser.UserNum     = usernum;
                        alertForUser.Description = POut.Long(kvp.Value);
                        listAlerts.Add(alertForUser);
                        log.WriteLine("Created webmail alert for user " + POut.Long(usernum), LogLevel.Verbose);
                    }
                    else
                    {
                        //If the alert already exists, we'll be updating it and usually mark it as unread.
                        AlertItem selectedAlert = alertForUser.Copy();
                        long      previousValue = PIn.Long(selectedAlert.Description);
                        //We only need to modify the alert if the amount of unread webmails changed.
                        if (previousValue != kvp.Value)
                        {
                            selectedAlert.Description = POut.Long(kvp.Value);
                            //If the new value is greater, the user has recieved more webmails so we want to mark the alert as "Unread".
                            if (previousValue < kvp.Value)
                            {
                                listChangedAlertItemNums.Add(selectedAlert.AlertItemNum);
                            }
                        }
                        listAlerts.Add(selectedAlert);
                        log.WriteLine("Modified webmail alert for user " + POut.Long(usernum), LogLevel.Verbose);
                    }
                }
            }
            //Push our changes to the database.
            AlertItems.Sync(listAlerts, listOldAlerts);
            List <AlertItem> listDeletedAlerts = listOldAlerts.Where(x => !listAlerts.Any(y => y.AlertItemNum == x.AlertItemNum)).ToList();

            log.WriteLine("Deleted webmail alerts for users: " + String.Join(", ", listDeletedAlerts.Select(x => POut.Long(x.UserNum))), LogLevel.Verbose);
            //Make sure to mark alerts that were deleted, modified (not created) and increased as unread.
            listChangedAlertItemNums.AddRange(listDeletedAlerts.Select(x => x.AlertItemNum));
            AlertReads.DeleteForAlertItems(listChangedAlertItemNums);
        }