public AlertCollection FetchAll() { var coll = new AlertCollection(); var qry = new Query(Alert.Schema); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
internal AlertsForm(CurrentWorldState currentWorldState, AlertCollection alertAlerts) { CurrentWorldState = currentWorldState; Alerts = alertAlerts; InitializeComponent(); PopulateData(); currentWorldState.Update += OnWorldStateUpdate; }
public Settings() { TryUpgrade(); if (Alerts == null) { Alerts = new AlertCollection(); } PropertyChanged += Settings_PropertyChanged; }
public void AlertCanBeRaised() { Member member = InsertMember(); VisitTimeAlert alert = InsertVisitTimeAlert(member); List <Member> membersToAlert = AlertCollection.ReadAlertCollections(_mongoConnection); CollectionAssert.AreEqual(new List <Member>() { member }, membersToAlert); }
public void VisitTimeAlertWillNotBeRaisedIfThereIsAVisit() { Member member = InsertMember(); VisitTimeAlert alert = InsertVisitTimeAlert(member); Visit visit = InsertVisit(member); List <Member> membersToAlert = AlertCollection.ReadAlertCollections(_mongoConnection); CollectionAssert.AreEqual(new List <Member>() { }, membersToAlert); }
private static void GetMyAlerts(ClientContext context) { Web web = context.Web; context.Load(web); context.Load(web.Lists); User currentUser = context.Web.CurrentUser; context.Load(currentUser); context.Load(currentUser.Alerts); context.Load(currentUser.Alerts, lists => lists.Include( list => list.Title, list => list.ListID)); AlertCollection myAlerts = currentUser.Alerts; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Getting alerts for user " + currentUser.Title); Console.WriteLine(""); context.ExecuteQuery(); Console.WriteLine(myAlerts.Count + " alerts found for user " + currentUser.Title); Console.WriteLine(""); foreach (Alert alert in myAlerts) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\\---------[Alert Metadata]---------/"); Console.ForegroundColor = defaultForeground; Console.WriteLine("ID: " + alert.ID); Console.WriteLine("Item: " + alert.Item); Console.WriteLine("Title: " + alert.Title); Console.WriteLine("AlertFrequency: " + alert.AlertFrequency); Console.WriteLine("AlertTemplateName: " + alert.AlertTemplateName); Console.WriteLine("AlertType: " + alert.AlertType); Console.WriteLine("AlwaysNotify: " + alert.AlwaysNotify); Console.WriteLine("DeliveryChannels: " + alert.DeliveryChannels); Console.WriteLine("EventType: " + alert.EventType); Console.WriteLine("Status: " + alert.Status); Console.WriteLine("ListID: " + alert.ListID); Console.WriteLine(""); } }
private void LoadData() { STParameters parameters = new STParameters(this.context.Document); string urn = String.Empty; string jobIdString = null; parameters.GetParam("urn", ref urn); parameters.GetParam("jobid", ref jobIdString); Job job = null; // If JobID is passed in look up by jobID if (!String.IsNullOrEmpty(jobIdString)) { job = this.context.Server.JobServer.Jobs.ItemById(Guid.Parse(jobIdString)); } else { // or use urn path to query job job = this.context.Server.GetSmoObject(urn) as Job; } // load the data if (job != null) { AlertCollection alerts = job.Parent.Alerts; // allocate the array list this.jobAlerts = new ArrayList(); for (int i = 0; i < alerts.Count; i++) { // only get alerts that point to this job. if (alerts[i].JobID == job.JobID) { //Since this job was just return from SMO, it is an existing object //Flag it with true to indicate is has already been created. this.jobAlerts.Add(new JobAlertData(alerts[i], true)); } } } else { SetDefaults(); } }
/// <summary> /// Handle request to get the alerts list /// </summary> internal async Task HandleAgentAlertsRequest(AgentAlertsParams parameters, RequestContext <AgentAlertsResult> requestContext) { await Task.Run(async() => { var result = new AgentAlertsResult(); result.Alerts = new List <AgentAlertInfo>().ToArray(); ConnectionInfo connInfo; ConnectionServiceInstance.TryFindConnection(parameters.OwnerUri, out connInfo); if (connInfo != null) { CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true); AlertCollection alerts = dataContainer.Server.JobServer.Alerts; } await requestContext.SendResult(result); }); }
private static void GetAlerts(ClientContext context) { Web web = context.Web; context.Load(web); context.Load(web.Alerts); context.ExecuteQuery(); Console.WriteLine("Get alerts from web: " + web.Title); AlertCollection alerts = web.Alerts; foreach (Alert alert in alerts) { web.Alerts.DeleteAlert(alert.ID); } web.Update(); Console.WriteLine("Update Alerts.."); context.ExecuteQuery(); Console.ReadKey(true); }
public void AlertsHaveAcceptablePerformance() { int insertGroupSize = 1000; int numberOfGroups = 10; for (int createMemberIndex = 0; createMemberIndex < numberOfGroups; createMemberIndex++) { Member[] members = InsertMembers(insertGroupSize); InsertVisits(members, insertGroupSize, 24); InsertVisitTimeAlerts(members, insertGroupSize, 24); } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); List <Member> membersToAlert = AlertCollection.ReadAlertCollections(_mongoConnection); stopwatch.Stop(); Console.Out.WriteLine($"found {membersToAlert.Count} in {stopwatch.Elapsed.TotalSeconds} Seconds"); Assert.Less(stopwatch.Elapsed, TimeSpan.FromMinutes(1)); }
private PersonBase FilledPerson() { var cruiseDetails = new GuestCruiseDetail { BeaconId = string.Empty, BerthNumber = string.Empty, IdentificationId = string.Empty, LoyaltyLevelTypeId = string.Empty, ReservationId = string.Empty, Stateroom = "00088" }; var personDetail = new PersonalDetail { CitizenshipCountryId = string.Empty, FirstName = string.Empty, LastName = string.Empty, MiddleName = string.Empty, Title = string.Empty, PreferredName = string.Empty, MaritalStatus = string.Empty, Nickname = string.Empty, Occupation = string.Empty, PassportNo = string.Empty, Suffix = string.Empty }; var alers = new AlertCollection(); alers.Add(new Alert { IsDenyAshore = true, IsParentalAuthorizationAlert = false, IsOverride = true, AlertType = "custom", AlertId = "1" }); alers.Add(new Alert { IsDenyAshore = true, IsParentalAuthorizationAlert = true, IsOverride = false, AlertType = "custom", AlertId = "1", Message = new Message() { Description = "demo", Subject = "abc" } }); alers.Add(new Alert { IsDenyAshore = false, IsParentalAuthorizationAlert = true, IsOverride = false, AlertType = "custom", AlertId = "2", Message = new Message() { Description = "demo", Subject = "abc" } }); var person = new PersonBase { IsOnboard = true, IsOnHold = true, ChargeId = "003", CruiseDetail = cruiseDetails, PersonalDetail = personDetail, LastEvent = string.Empty, PersonId = "001", PersonTypeId = "3", SecurityPhotoAddress = string.Empty, Stateroom = "00088" }; person.AssignAlerts(alers); return person; }
public AlertCollection FetchByID(object Guid) { AlertCollection coll = new AlertCollection().Where("GUID", Guid).Load(); return coll; }
public AlertCollection FetchByQuery(Query qry) { var coll = new AlertCollection(); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
/// <summary> /// Handle request to get Agent Job history /// </summary> internal async Task HandleJobHistoryRequest(AgentJobHistoryParams parameters, RequestContext <AgentJobHistoryResult> requestContext) { await Task.Run(async() => { try { var result = new AgentJobHistoryResult(); ConnectionInfo connInfo; ConnectionServiceInstance.TryFindConnection( parameters.OwnerUri, out connInfo); if (connInfo != null) { CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true); var jobs = dataContainer.Server.JobServer.Jobs; Tuple <SqlConnectionInfo, DataTable, ServerConnection> tuple = CreateSqlConnection(connInfo, parameters.JobId); SqlConnectionInfo sqlConnInfo = tuple.Item1; DataTable dt = tuple.Item2; ServerConnection connection = tuple.Item3; // Send Steps, Alerts and Schedules with job history in background // Add steps to the job if any JobStepCollection steps = jobs[parameters.JobName].JobSteps; var jobSteps = new List <AgentJobStepInfo>(); foreach (JobStep step in steps) { jobSteps.Add(AgentUtilities.ConvertToAgentJobStepInfo(step, parameters.JobId, parameters.JobName)); } result.Steps = jobSteps.ToArray(); // Add schedules to the job if any JobScheduleCollection schedules = jobs[parameters.JobName].JobSchedules; var jobSchedules = new List <AgentScheduleInfo>(); foreach (JobSchedule schedule in schedules) { jobSchedules.Add(AgentUtilities.ConvertToAgentScheduleInfo(schedule)); } result.Schedules = jobSchedules.ToArray(); // Alerts AlertCollection alerts = dataContainer.Server.JobServer.Alerts; var jobAlerts = new List <Alert>(); foreach (Alert alert in alerts) { if (alert.JobName == parameters.JobName) { jobAlerts.Add(alert); } } result.Alerts = AgentUtilities.ConvertToAgentAlertInfo(jobAlerts); // Add histories int count = dt.Rows.Count; List <AgentJobHistoryInfo> jobHistories = new List <AgentJobHistoryInfo>(); if (count > 0) { var job = dt.Rows[0]; Guid jobId = (Guid)job[AgentUtilities.UrnJobId]; int runStatus = Convert.ToInt32(job[AgentUtilities.UrnRunStatus], System.Globalization.CultureInfo.InvariantCulture); var t = new LogSourceJobHistory(parameters.JobName, sqlConnInfo, null, runStatus, jobId, null); var tlog = t as ILogSource; tlog.Initialize(); var logEntries = t.LogEntries; // Finally add the job histories jobHistories = AgentUtilities.ConvertToAgentJobHistoryInfo(logEntries, job, steps); result.Histories = jobHistories.ToArray(); result.Success = true; tlog.CloseReader(); } connection.Disconnect(); await requestContext.SendResult(result); } } catch (Exception e) { await requestContext.SendError(e); } }); }
/// <summary> /// Assigns the alerts. /// </summary> /// <param name="alertCollection">The alert collection.</param> public void AssignAlerts(AlertCollection alertCollection) { this.alerts = alertCollection; }
/// <summary> /// Function to clear other alert except CBP alert for clear mode /// </summary> /// <param name="person">person instance</param> private static void CheckForCBPAlerts(Person person) { if (DIContainer.Instance.Resolve<Workstation>().FlowDirection == FlowDirection.ClearAlert) { AlertCollection alerts = null; foreach (Guest guest in person.Guests) { if (guest.Alerts.Count > 0) { alerts = new AlertCollection(); guest.Alerts.Where(alert => alert.AlertType == CommonConstants.CustomsBorderProtectionAlert).Iterate(alert => alerts.Add(alert)); guest.AssignAlerts(alerts); guest.HasAlert = guest.Alerts.Count > 0; } } foreach (Crewmember crew in person.Crewmembers) { if (crew.Alerts.Count > 0) { alerts = new AlertCollection(); crew.Alerts.Where(alert => alert.AlertType == CommonConstants.CustomsBorderProtectionAlert).Iterate(alert => alerts.Add(alert)); crew.AssignAlerts(alerts); crew.HasAlert = crew.Alerts.Count > 0; } } foreach (Visitor visitor in person.Visitors) { if (visitor.Alerts.Count > 0) { alerts = new AlertCollection(); visitor.Alerts.Where(alert => alert.AlertType == CommonConstants.CustomsBorderProtectionAlert).Iterate(alert => alerts.Add(alert)); visitor.AssignAlerts(alerts); visitor.HasAlert = visitor.Alerts.Count > 0; } } } }
/// <summary> /// Function to retrieve sorted alerts by AlertOrder. /// </summary> /// <returns>Order alert collection</returns> private AlertCollection RetrieveSortedAlerts() { var sortedAlerts = new AlertCollection(); this.selectedPerson.Alerts.OrderBy(a => a.AlertOrder).ThenByDescending(b => b.AddedDateTime).Iterate(a => sortedAlerts.Add(a)); return sortedAlerts; }
/// <summary> /// Reset alert collection for Guest /// </summary> /// <param name="personId">person id</param> /// <param name="personList">guest enumerable</param> private static void ResetGuestAlerts(string personId, IEnumerable<Guest> personList) { Person personDetail; Workstation workStation = DIContainer.Instance.Resolve<Workstation>(); var task = Task.Run(async () => await PersonsService.RetrievePersonsBySearchText(workStation.Ship.ShipId, null, new List<PersonType> { PersonType.Guest }, SearchType.PersonId, personId: personId)); task.Wait(); if (!task.IsCanceled && !task.IsFaulted) { personDetail = task.Result; AlertCollection alerts = new AlertCollection(); var list = personList.FirstOrDefault(); if (list != null && list.Alerts != null && list.Alerts.Count > 0) { var guestDetail = personDetail.Guests.FirstOrDefault(); if (guestDetail != null && guestDetail.Alerts != null) { guestDetail.Alerts.Iterate(alert => alerts.Add(alert)); } list.AssignAlerts(alerts); list.HasAlert = list.Alerts.Count > 0; } } }
/// <summary> /// Function to retrieve ashore alerts. /// </summary> /// <param name="alerts">Collection of Alert</param> /// <returns>Collection of Ashore Alerts</returns> public static AlertCollection RetrieveAshoreAlerts(this AlertCollection alerts) { var alertCollection = new AlertCollection(); alerts.Where(a => a.IsDenyAshore || (a.IsDenyOnboard && a.IsDenyAshore) || a.IsParentalAuthorizationAlert).Iterate(a => alertCollection.Add(a)); return alertCollection; }
/// <summary> /// Retrieves the alerts. /// </summary> /// <param name="filter">The filter.</param> /// <returns> /// Alert task /// </returns> public async Task<ListResult<Alert>> ListAsync(AlertSearchParameters filter) { var alertSearch = new AlertListRequestSearchParameters { PageNumber = filter.PageNumber.RetrievePageNumber(), MaxResults = filter.MaxResults.RetrieveMaxResults(), AlertTypeIds = filter.AlertTypeIds, ApplicationId = string.IsNullOrWhiteSpace(filter.ApplicationId) ? Convert.ToString(this.applicationSettings.ApplicationId, CultureInfo.CurrentCulture) : filter.ApplicationId, OrderBy = filter.OrderBy, ShipId = filter.ShipId, PersonIds = filter.PersonIds, IsTemplate = !string.IsNullOrEmpty(filter.IsTemplate) ? Convert.ToBoolean(filter.IsTemplate, CultureInfo.CurrentCulture) : false, TypeIds = !string.IsNullOrEmpty(filter.TypeId) ? filter.TypeId : null, IsAlert = !string.IsNullOrEmpty(filter.IsAlert) ? Convert.ToBoolean(filter.IsAlert, CultureInfo.CurrentCulture) : (bool?)null, IsRecentAlert = !string.IsNullOrEmpty(filter.IsRecentAlert) ? Convert.ToBoolean(filter.IsRecentAlert, CultureInfo.CurrentCulture) : (bool?)null, IsMessage = !string.IsNullOrWhiteSpace(filter.IsMessage) ? Convert.ToBoolean(filter.IsMessage, CultureInfo.CurrentCulture) : (bool?)null, IsExpiredAlert = !string.IsNullOrWhiteSpace(filter.IsExpiredAlert) ? Convert.ToBoolean(filter.IsExpiredAlert, CultureInfo.CurrentCulture) : (bool?)null, AddedDate = filter.AddedDate }; if (string.IsNullOrWhiteSpace(filter.ShipTime)) { var shipTimeTask = await this.shipTimeRepository.GetByIdAsync(this.applicationSettings.ShipId, null); alertSearch.ShipTime = string.IsNullOrWhiteSpace(shipTimeTask) ? DateTime.Now : DateTime.UtcNow.AddMinutes(Convert.ToDouble(shipTimeTask)); } else { alertSearch.ShipTime = DateTime.Parse(filter.ShipTime, CultureInfo.InvariantCulture); } var alertData = await this.alertRepository.ListAsync(alertSearch); var result = new ListResult<Alert>(); var alerts = new AlertCollection(); foreach (var alertType in alertData.Items) { alerts.Add(MapAlertData(alertType, alertSearch.ShipTime)); } if (!alertSearch.IsExpiredAlert.GetValueOrDefault(false) && !alertSearch.IsTemplate) { var filteredAlerts = alerts.Where(alert => alert.IsActive).ToList(); result.AssignItems(filteredAlerts); result.TotalResults = filteredAlerts.Count; } else { result.AssignItems(alerts); result.TotalResults = alerts.Count; } return result; }