예제 #1
0
        private static Stream HandleException(string id, string snsTopicArn, Exception e)
        {
            Logger.Log(e);

            string snsMessage = SNS.CreateMessage(e.Message, "exception", e.StackTrace);

            SNS.SendMessage(snsTopicArn, snsMessage);

            return(LambdaResponse.Create(id, e.Message, null));
        }
예제 #2
0
        private static NirvanaResult GetNirvanaFailResult(StringBuilder runLog, NirvanaConfig config, ErrorCategory errorCategory, string errorMessage, string stackTrace, string snsTopicArn)
        {
            string status = GetFailedRunStatus(errorCategory, errorMessage);

            if (errorCategory != ErrorCategory.UserError)
            {
                string snsMessage = SNS.CreateMessage(runLog.ToString(), status, stackTrace);
                SNS.SendMessage(snsTopicArn, snsMessage);
            }

            return(new NirvanaResult
            {
                id = config.id,
                status = status
            });
        }
예제 #3
0
        public static Stream GetStream(string id, string snsTopicArn, Exception e)
        {
            Logger.Log(e);
            GC.Collect();

            string snsMessage = SNS.CreateMessage(e.Message, "exception", e.StackTrace);

            SNS.SendMessage(snsTopicArn, snsMessage);

            ErrorCategory errorCategory = ExceptionUtilities.ExceptionToErrorCategory(e);
            string        message       = GetMessage(errorCategory, e.Message);

            LogUtilities.LogObject("Result", message);

            return(SingleResult.Create(id, message, null));
        }
예제 #4
0
        private static AnnotationResult HandleException(StringBuilder runLog, AnnotationResult result, Exception e, string snsTopicArn)
        {
            Logger.Log(e);

            result.status        = e.Message;
            result.errorCategory = ExceptionUtilities.ExceptionToErrorCategory(e);
            Logger.WriteLine($"Error Category: {result.errorCategory}");

            if (result.errorCategory != ErrorCategory.UserError)
            {
                string snsMessage = SNS.CreateMessage(runLog.ToString(), result.status, e.StackTrace);
                SNS.SendMessage(snsTopicArn, snsMessage);
            }

            LogUtilities.LogObject("Result", result);
            return(result);
        }
예제 #5
0
        private ValidationResult HandleException(string id, Exception exception, string snsTopicArn)
        {
            Logger.Log(exception);

            string snsMessage = SNS.CreateMessage(exception.Message, "exception", exception.StackTrace);

            SNS.SendMessage(snsTopicArn, snsMessage);

            ErrorCategory errorCategory      = ExceptionUtilities.ExceptionToErrorCategory(exception);
            var           errorMessagePrefix = errorCategory == ErrorCategory.UserError ? "User error" : "Nirvana error";

            return(new ValidationResult
            {
                id = id,
                status = $"{errorMessagePrefix}: {exception.Message}"
            });
        }
예제 #6
0
        private static CustomResult HandleException(StringBuilder runLog, CustomResult result, Exception e, string snsTopicArn)
        {
            Logger.Log(e);

            var errorCategory = ExceptionUtilities.ExceptionToErrorCategory(e);

            result.status = $"{errorCategory}: {e.Message}";

            if (errorCategory != ErrorCategory.UserError)
            {
                string snsMessage = SNS.CreateMessage(runLog.ToString(), result.status, e.StackTrace);
                SNS.SendMessage(snsTopicArn, snsMessage);
            }

            LogUtilities.LogObject("Result", result);
            LambdaUtilities.DeleteTempOutput();

            return(result);
        }
예제 #7
0
        private void SendPushNotification(string DeviceARN)
        {
            var message = "Notification";

            switch (TypeId)
            {
            case NotificationType.BookingCancelled:
                message = string.Format(Translations.Translate("Booking Cancelled", User.LanguageId), BookingId);
                break;

            case NotificationType.BookingConfirmed:
                message = string.Format(Translations.Translate("Booking Confirmed", User.LanguageId), BookingId);
                break;

            case NotificationType.NewBooking:
                message = string.Format(Translations.Translate("Booking Received", User.LanguageId), BookingId);
                break;

            case NotificationType.NewReview:
                message = string.Format(Translations.Translate("New Review", User.LanguageId), BookingId);
                break;

            case NotificationType.PaymentReceived:
                message = string.Format(Translations.Translate("Payment Received", User.LanguageId), BookingId);
                break;

            case NotificationType.ServiceComplete:
                message = string.Format(Translations.Translate("Booking Completed", User.LanguageId), BookingId);
                break;

            case NotificationType.ServiceIncomplete:
                message = string.Format(Translations.Translate("Booking Not Completed", User.LanguageId), BookingId);
                break;
            }

            var args = new Dictionary <string, object>
            {
                { "UserId", UserId },
                { "BookingId", BookingId }
            };

            SNS.SendMessage(DeviceARN, message, $"app.agrishare.category.{TypeId}", args);
        }
예제 #8
0
 public bool SendMessage(string Message, string Category = "", Dictionary <string, object> Params = null)
 {
     return(SNS.SendMessage(EndpointARN, Message, Category, Params));
 }