public void AlertItems_CreateAlertsForWebmailMethodCall() { AlertItems.CreateAlertsForNewWebmail(_log); }
///<summary>Send a summary of eConnector statistics to OD HQ. This should only be called from the eConnector.</summary> public static void UpdateEConnectorStats() { OpenDentBusiness.WebTypes.EConnectorStats eConnStats = new OpenDentBusiness.WebTypes.EConnectorStats(); eConnStats.EConnectorComputerName = Environment.MachineName; eConnStats.EConnectorDomainUserName = Environment.UserName; eConnStats.EConnectorIP = ODEnvironment.GetLocalIPAddress(); eConnStats.HasClinicsEnabled = PrefC.HasClinicsEnabled; if (PrefC.HasClinicsEnabled) { eConnStats.CountActiveClinics = OpenDentBusiness.Clinics.GetCount(); eConnStats.CountInactiveClinics = OpenDentBusiness.Clinics.GetCount() - eConnStats.CountActiveClinics; } else { eConnStats.CountActiveClinics = 0; eConnStats.CountInactiveClinics = OpenDentBusiness.Clinics.GetCount(); } eConnStats.CountActivePatients = OpenDentBusiness.Procedures.GetCountPatsComplete(DateTime.Today.AddYears(-2), DateTime.Today); eConnStats.CountNonactivePatients = OpenDentBusiness.Patients.GetPatCountAll() - eConnStats.CountActivePatients; eConnStats.ListEServiceSignals = OpenDentBusiness.EServiceSignals.GetServiceHistory(eServiceCode.ListenerService, DateTime.Today.AddDays(-30), DateTime.Today, 30); eConnStats.DateTimeNow = DateTime.Now; eConnStats.ListEServicePrefs = new List <Pref>(); foreach (PrefName prefName in Enum.GetValues(typeof(PrefName))) { if (prefName.In( PrefName.RegistrationKey, PrefName.ProgramVersion, PrefName.DataBaseVersion, PrefName.TextingDefaultClinicNum, PrefName.WebServiceServerName, PrefName.AutomaticCommunicationTimeStart, PrefName.AutomaticCommunicationTimeEnd) || prefName.ToString().StartsWith("WebSched") || prefName.ToString().StartsWith("ApptConfirm") || prefName.ToString().StartsWith("ApptRemind") || prefName.ToString().StartsWith("ApptEConfirm") || prefName.ToString().StartsWith("Recall") || prefName.ToString().StartsWith("PatientPortal") || prefName.ToString().StartsWith("Sms")) { try { eConnStats.ListEServicePrefs.Add(Prefs.GetPref(prefName.ToString())); } catch (Exception ex) { ex.DoNothing(); } } } List <EConnectorStats> listStatsToSend = new List <EConnectorStats> { eConnStats }; string dbStats = PrefC.GetString(PrefName.EConnectorStatistics); List <EConnectorStats> listDbStats = DeserializeListFromJson(dbStats) ?? new List <EConnectorStats>(); bool doCreateAlert = false; foreach (EConnectorStats stats in listDbStats) { //If a different eConnector is saving stats, add that one to the list to be sent to HQ. if (eConnStats.EConnectorComputerName != stats.EConnectorComputerName && (eConnStats.DateTimeNow - stats.DateTimeNow).TotalHours < 23) { stats.ListEServicePrefs = new List <Pref>(); //To save on bandwidth stats.ListEServiceSignals = new List <EServiceSignal>(); listStatsToSend.Add(stats); if ((eConnStats.DateTimeNow - stats.DateTimeNow).TotalHours < 3) { doCreateAlert = true; } } } if (doCreateAlert && AlertItems.RefreshForType(AlertType.MultipleEConnectors).Count == 0) { AlertItem alert = new AlertItem { Actions = ActionType.MarkAsRead | ActionType.Delete, Description = Lans.g("EConnectorStats", "eConnector services are being run on these computers:") + " " + string.Join(", ", listStatsToSend.Select(x => x.EConnectorComputerName)), Severity = SeverityType.High, Type = AlertType.MultipleEConnectors, }; AlertItems.Insert(alert); } string statsStr = SerializeToJson(listStatsToSend); OpenDentBusiness.Prefs.UpdateString(PrefName.EConnectorStatistics, statsStr); string payload = WebServiceMainHQProxy.CreateWebServiceHQPayload(WebServiceMainHQProxy.CreatePayloadContent(statsStr, "EConnectorStatsStr"), eServiceCode.ListenerService); WebServiceMainHQProxy.GetWebServiceMainHQInstance().SetEConnectorStatsAsync(payload); }
public void AlertItems_GetUniqueAlerts_Addclinic() { //This test will check the funcionality of alert items which are marked to show in all clinics(AlertItem.ClinicNum==-1). //Expected behaviour is that a user subscribed to all alert categories, and all clinics(AlertSub.ClinicNum==-1), //will see the alert no matter which clinic they are in. //In addition, when a new clinic is added, the user will be able to see alerts in that new clinic without the need to reenter //FormUserEdit and select "All" again under clinics for alert subscriptions. //Clear AlertSub table. AlertSubT.ClearAlertSubTable(); //Create Users Userod userAdmin = UserodT.CreateUser(); Userod userNormal = UserodT.CreateUser(); //Create Clinics List <Clinic> listClinics = new List <Clinic>(); for (int i = 0; i < 2; i++) { listClinics.Add(ClinicT.CreateClinic()); } //Create AlertItems //First alert Item is an alert item for all clinics(ClinicNum==-1). CreateAlertItem(true); //Second AlertItem is an AlertItem for HQ(ClinicNum==0). CreateAlertItem(false); List <AlertCategory> listAlertCats = AlertCategories.GetDeepCopy(); List <AlertSub> listAlertSubOld = new List <AlertSub>(); List <AlertSub> listAlertSubNew = new List <AlertSub>(); foreach (AlertCategory alertCat in listAlertCats) { AlertSub alSub = new AlertSub(userAdmin.UserNum, -1, alertCat.AlertCategoryNum); listAlertSubNew.Add(alSub); } AlertSubs.Sync(listAlertSubNew, listAlertSubOld); //Check number of alerts which will display in headquarters clinic. //Call CheckUniqueAlerts for user subscribed to all alert categories List <List <AlertItem> > listUniqueAlertsAll = AlertItems.GetUniqueAlerts(userAdmin.UserNum, 0); List <List <AlertItem> > listUniqueAlertsOne = AlertItems.GetUniqueAlerts(userNormal.UserNum, 0); //Assert lists are correct //UserAdmin should see two alerts, one for the generic headquarters alert and one for the eConnector all clinics alert. Assert.AreEqual(2, listUniqueAlertsAll.Count()); //UserNormal is not subscribed to any clinics or alert categories and should not see any alerts. Assert.AreEqual(0, listUniqueAlertsOne.Count()); //Add clinic listClinics.Add(ClinicT.CreateClinic()); //Check that alert for all clinics is included for userAdmin(subscribed to all clinics) listUniqueAlertsAll = AlertItems.GetUniqueAlerts(userAdmin.UserNum, listClinics.LastOrDefault().ClinicNum); Assert.AreEqual(1, listUniqueAlertsAll.Count()); //Check new clinic for user who is not subscribed to all alerts. listUniqueAlertsOne = AlertItems.GetUniqueAlerts(userNormal.UserNum, listClinics.LastOrDefault().ClinicNum); Assert.AreEqual(0, listUniqueAlertsOne.Count()); //Add new alert for new clinic only. CreateAlertItem(false, listClinics.LastOrDefault().ClinicNum); //Check that userAdmin sees new alert item in new clinic. Should have 2, one all clinic econnector alert and the new clinic specific alert. listUniqueAlertsAll = AlertItems.GetUniqueAlerts(userAdmin.UserNum, listClinics.LastOrDefault().ClinicNum); Assert.AreEqual(2, listUniqueAlertsAll.Count()); //Check that userNormal sees no alerts in new clinic, as they are not subscribed to any alert categories, nor clinics. listUniqueAlertsOne = AlertItems.GetUniqueAlerts(userNormal.UserNum, listClinics.LastOrDefault().ClinicNum); Assert.AreEqual(0, listUniqueAlertsOne.Count()); }