public async Task Run(string deviceIdList) { var connectionString = Models.Settings.Instance.NotificaitonHubConnectionStrings; var hubName = Models.Settings.Instance.NotificationHubName; var actionList = new[] { update_cart, receipt }; var action = Prompt.Select("Select Action", actionList); var utiility = new NotificationUtility(_logger); utiility.ConnectionString = connectionString; utiility.HubName = hubName; foreach (var deviceToken in deviceIdList.Split(',')) { if (action == update_cart) { await utiility.PushUpdatedCartNotificationAsync(deviceToken); } if (action == receipt) { await utiility.PushClosedCartNotificationAsync(deviceToken); } } }
public override void OnActivated(UIApplication application) { // Restart any tasks that were paused (or not yet started) while the application was inactive. // If the application was previously in the background, optionally refresh the user interface. LogUtility.LogMessage("OnActivated called, App is active."); ServiceContainer.InvalidateCache(); // invalidate cache after backgrounding app NotificationUtility.PostNotification(NotificationType.Activated); }
public HttpResponseMessage Invite([FromBody] UserEmailDTO emailDTO) { //Gets the Sender from token var token = Request.Headers.Authorization.Parameter; User sender = UserUtility.GetUserByToken(token); CustomResponse response; bool userHasTeam = _repository.UserHasTeam(sender.email); bool isUserLeader = _repository.IsUserLeader(sender.email); //Checks whether sender has a team or not if (!userHasTeam || !isUserLeader) { response = ResponseMessageHelper.CreateResponse(HttpStatusCode.BadRequest, true, null, ConstantResponse.TEAM_INVITE_SENDER_ERR); return(Request.CreateResponse <CustomResponse>(HttpStatusCode.BadRequest, response)); } //Checks whether sender is trying to invite himself/herself else if (sender.email == emailDTO.email) { response = ResponseMessageHelper.CreateResponse(HttpStatusCode.BadRequest, true, null, ConstantResponse.TEAM_INVITE_YOURSELF); return(Request.CreateResponse <CustomResponse>(HttpStatusCode.BadRequest, response)); } //used to get sender name etc.. User senderLocal = _userRepository.GetByEmail(sender.email); User receiver = _userRepository.GetByEmail(emailDTO.email); //Checks whether the sender has already sent an invitation which is not answered by the receiver yet bool inProgressInvite = _notificationRepository.InProgressInvite(senderLocal.id, receiver.id); if (inProgressInvite) { response = ResponseMessageHelper.CreateResponse(HttpStatusCode.BadRequest, true, null, ConstantResponse.TEAN_INVITE_INPROGRESS); return(Request.CreateResponse <CustomResponse>(HttpStatusCode.BadRequest, response)); } //Checks whether the receiver is exist or not if (receiver == null) { response = ResponseMessageHelper.CreateResponse(HttpStatusCode.BadRequest, true, null, ConstantResponse.TEAM_INVITE_RECEIVER_ERR); return(Request.CreateResponse <CustomResponse>(HttpStatusCode.BadRequest, response)); } //Checks whether the receiver has already had a team or not else if (receiver.team != null) { response = ResponseMessageHelper.CreateResponse(HttpStatusCode.BadRequest, true, null, ConstantResponse.TEAM_INVITE_RECEIVER_HAS_TEAM); return(Request.CreateResponse <CustomResponse>(HttpStatusCode.BadRequest, response)); } //Helper class to create notification Notification notification = NotificationUtility.CreateForTeam(senderLocal, receiver.id); //Inserts created notification _notificationRepository.Insert(notification); response = ResponseMessageHelper.CreateResponse(HttpStatusCode.OK, false, ConstantResponse.OK, ConstantResponse.TEAM_INVITE_SUCCESS); return(Request.CreateResponse <CustomResponse>(HttpStatusCode.OK, response)); }
/// <summary> /// Takes appropriate actions up on failed reconnect /// </summary> private static void OnFailure() { Stop(); //if auth failure timeout, redirect to login screen if (IsAuthFailure) { NotificationUtility.PostNotification(NotificationType.AuthFailure); } }
/// <summary> /// Internally sets the instance connection state /// </summary> /// <param name="state">The state value to set</param> /// <param name="message">Optional message to display on banner</param> private static void SetState(ConnectionState state, string message = null) { state.Message = message; if (_state != state) { LogUtility.LogMessage(String.Format("Connection state set to {0}", state.ToString())); _state = state; NotificationUtility.PostNotification(NotificationType.ConnectionStateChanged); } }
/// <summary> /// Sets the active alert count. /// </summary> /// <param name="count">The value to set</param> public static void SetActiveAlertsCount(int?count) { if (count.HasValue) { if (_activeAlertsCount != count.Value) { _activeAlertsCount = count.Value; NotificationUtility.PostNotification(NotificationType.AlertsCountChanged, null); } } }
private void Button_InstallAPK_OnClick(object sender, RoutedEventArgs e) { if (ListBox_APKList.SelectedItem == null) { NotificationUtility.ShowMessage("Please select an APK."); return; } var apk = Path.Combine(TextBox_APKDirectory.Text, ListBox_APKList.SelectedItem.ToString()); InvokeNotifyStartEvent($"Attempting to install {apk}..."); AndroidDevice.InstallAPK(apk); }
/// <summary> /// Handles a failed websocket request /// </summary> /// <param name="client">The websocket client which sent the request</param> /// <param name="args">Arguments associated with failure</param> private static void HandleFailedRequest(IWebSocketsClient client, RequestFailureEventArgs args) { LogUtility.LogMessage(String.Format("Request Failure (reason: {0})", Enum.GetName(typeof(RequestFailureReason), args.FailureReason))); bool tryReconnect = false; string message = null; switch (args.FailureReason) { case RequestFailureReason.Auth: tryReconnect = false; message = "authentication problem"; NotificationUtility.PostNotification(NotificationType.AuthFailure); break; case RequestFailureReason.Timeout: tryReconnect = ReconnectIsAllowed(); message = "timeout"; break; case RequestFailureReason.ServerDown: tryReconnect = ReconnectIsAllowed(); message = "server down"; break; case RequestFailureReason.Network: tryReconnect = ReconnectIsAllowed(); message = "network issue"; break; case RequestFailureReason.ServerRequestedReconnect: tryReconnect = ReconnectIsAllowed(); message = "server requested reconnect"; break; case RequestFailureReason.Error: break; } if (tryReconnect) { SetState(ConnectionState.Disconnected, message); ReconnectProcess.Begin(args.ForegroundAction, args.OnResume, args.Request, args.FailureReason); } }
protected virtual IEnumerable Action(PXAdapter adapter, [PXInt] [SOShipmentEntryActions] int?actionID, [PXString()] string ActionName ) { object queueName = null; if (actionID == SOShipmentEntryActionsAttribute.PrintPickList && adapter.Arguments.TryGetValue("PrintQueue", out queueName) && !String.IsNullOrEmpty(queueName as string)) { GL.Branch company = null; using (new PXReadBranchRestrictedScope()) { company = Base.Company.Select(); } using (PXTransactionScope ts = new PXTransactionScope()) { var jobMaint = PXGraph.CreateInstance <PrintJobMaint>(); foreach (SOShipment shipment in adapter.Get <SOShipment>()) { Base.Document.Current = shipment; string actualReportID = new NotificationUtility(Base).SearchReport(ARNotificationSource.Customer, Base.customer.Current, "SO644000", company.BranchID); jobMaint.AddPrintJob(PXMessages.LocalizeFormatNoPrefix(WM.Messages.PrintPickList, shipment.ShipmentNbr), queueName as string, actualReportID, new Dictionary <string, string> { { "ShipmentNbr", shipment.ShipmentNbr } }); shipment.PickListPrinted = true; Base.Document.Update(shipment); } Base.Save.Press(); ts.Complete(); } return(adapter.Get()); } else { return(Base.action.Press(adapter)); } }
public static void SendNotification(AppointmentEntry graphAppointmentEntry, PXCache sourceCache, string notificationCD, int?branchID, IDictionary <string, string> parameters, IList <Guid?> attachments = null) { if (sourceCache.Current == null) { throw new PXException(PX.Objects.CR.Messages.EmailNotificationError); } Guid?setupID = new NotificationUtility(graphAppointmentEntry).SearchSetupID(FSNotificationSource.Appointment, notificationCD); if (setupID == null) { sourceCache.RaiseExceptionHandling <FSAppointment.srvOrdType>( sourceCache.Current, ((FSAppointment)sourceCache.Current).SrvOrdType, new PXSetPropertyException( PX.Objects.CR.Messages.EmailNotificationSetupNotFound, PXErrorLevel.Warning, notificationCD)); return; } if (branchID == null) { branchID = graphAppointmentEntry.Accessinfo.BranchID; } if (parameters == null) { parameters = new Dictionary <string, string>(); foreach (string key in sourceCache.Keys) { object value = sourceCache.GetValueExt(sourceCache.Current, key); parameters[key] = value != null?value.ToString() : null; } } Send(graphAppointmentEntry, sourceCache, (Guid)setupID, branchID, parameters, attachments); }
private void Button_Provision_OnClick(object sender, RoutedEventArgs e) { var host = GetSelectedHost(); var org = GetSelectedOrg(); if (host == null) { NotificationUtility.ShowError("Invalid Host"); return; } var vehicle = TextBox_VehicleID.Text; if (CheckBox_UseIntent.IsChecked == true) { InvokeNotifyStartEvent($"Provisioning device to Org \"{org.Name}\" with intent..."); AndroidDevice.ProvisionDevice_Intent(org.Name, org.ProvisioningKey, host.HostName, vehicle); } else { InvokeNotifyStartEvent($"Provisioning device to Org \"{org.Name}\" with keystrokes..."); AndroidDevice.ProvisionDevice_Key(org.Name, org.ProvisioningKey, host.HostName, vehicle); } }
private void Button_DeleteVSFolderForMobile_OnClick(object sender, RoutedEventArgs e) { var output = FileSystemUtility.RemoveFolder(Path.Combine(FolderPaths.EFS_ANDROID_REPO, @"eFleetDroid\.vs")); NotificationUtility.ShowMessage(output.Message); }
/// <summary> /// Does the work of sending a call to the server, and waiting for the response. /// </summary> /// <param name="jsonRequest">The request to send</param> /// <returns>A Task result with the response</returns> private Task <TResponse> Send <TResponse>(IApiRequest jsonRequest, string channel, bool silentMode = false) where TResponse : IApiResponse, new() { TResponse output = default(TResponse); return(Task.Run(() => { ExceptionUtility.Try(() => { string jsonRequestString = JsonUtility.Serialize(jsonRequest); string jsonRequestStringForLogging = jsonRequestString.Replace(User.Current.Password, "********"); LogUtility.LogMessage(String.Format("{2}: Sending Request to {0}: {1}", this.Url, FormatJsonForLogging(jsonRequestStringForLogging), this._instanceId.ToString())); var waitHandle = new AutoResetEvent(false); bool gotResponse = false; Action <IApiResponse> receivedResponse = (r) => { gotResponse = true; if (r is Lib.Domain.Responses.ConnectionResponse && ((ConnectionResponse)r).IsSuccessful) { NotificationUtility.PostNotification(NotificationType.Reconnected); } if (r is Lib.Domain.Responses.ErrorResponse) { output = ResponseFactory.ParseResponse <TResponse>(r.RawResponse); } else { try { output = (TResponse)r; } catch (System.InvalidCastException ice) { LogUtility.LogException(ice, String.Format("The server returned a type of response that was not expected. The type of response expected was {0}", (typeof(TResponse)).Name), LogSeverity.Warn); output = default(TResponse); } } if (r.IsAuthFailure) { output = ResponseFactory.FabricateLoginFailureResponse <TResponse>(jsonRequest); } gotResponse = true; waitHandle.Set(); }; RegisterWaitingForResponse(channel, receivedResponse); if (_client != null) { _client.Send(new NSString(jsonRequestString)); waitHandle.WaitOne(DefaultSendTimeoutMs); UnregisterWaitingForResponse(channel); } //here we will fabricate an error response for case of timeout if (output == null && !gotResponse) { output = ResponseFactory.FabricateRequestTimeoutResponse <TResponse>(jsonRequest); this.FireRequestFailureEvent(jsonRequest, null, RequestFailureReason.Timeout, foregroundAction: (!silentMode)); } }); return output; })); }
/// <summary> /// Hide the reconnecting banner /// </summary> private static void HideReconBanner() { _showingReconBar = false; NotificationUtility.PostNotification(NotificationType.HideReconnecting); }
/// <summary> /// Display the reconnecting banner /// </summary> private static void ShowReconBanner() { _showingReconBar = true; NotificationUtility.PostNotification(NotificationType.ShowReconnecting); }
protected override IEnumerable Report(PXAdapter adapter, [PXString(8, InputMask = "CC.CC.CC.CC")] string reportID ) { if (!String.IsNullOrEmpty(reportID)) { Save.Press(); int i = 0; Dictionary<string, string> parameters = new Dictionary<string, string>(); string actualRecoprtID = null; foreach (ARInvoice doc in adapter.Get<ARInvoice>()) { parameters["ARInvoice.DocType" + i.ToString()] = doc.DocType; parameters["ARInvoice.RefNbr" + i.ToString()] = doc.RefNbr; actualRecoprtID = new NotificationUtility(this).SearchReport(ARNotificationSource.Customer, customer.Current, reportID, doc.BranchID); i++; } if (i > 0) { throw new PXReportRequiredException(parameters, actualRecoprtID, "Report " + actualRecoprtID); } } return adapter.Get(); }