private Guid SaveAndNotifyRevenueRepresentative(ContractModification model)
 {
     try
     {
         var revenuedata = _revenueRecognitionService.GetAwardAmountDetail(model.ContractGuid);
         if (revenuedata != null)
         {
             bool isRevenueTriggered = RevenueRecognitionHelper.IsValidForRevenueRecognitionRequest(_configuration, revenuedata.ContractType, revenuedata.AwardAmount, revenuedata.FundingAmount);
             if (isRevenueTriggered)
             {
                 //Adding new revenue recognition for Mods
                 //_contractService.updateContractRevenueRecognitionGuid(model.ContractGuid, revenueRecognitionGuid);
                 Guid revenueRecognitionGuid = AddNewRevenueAndUpdateContractModRevenueGuid(model);
                 return(revenueRecognitionGuid);
             }
         }
         return(Guid.Empty);
     }
     catch (Exception ex)
     {
         var userGuid = UserHelper.CurrentUserGuid(HttpContext);
         EventLogHelper.Error(_eventLogger, new EventLog
         {
             EventGuid   = Guid.NewGuid(),
             Action      = "",
             Application = "ESS",
             EventDate   = DateTime.UtcNow,
             Message     = ex.Message,
             Resource    = ResourceType.Notification.ToString(),
             StackTrace  = ex.StackTrace,
             UserGuid    = userGuid
         });
         return(Guid.Empty);
     }
 }
Пример #2
0
 private bool SaveAndNotifyAccountingRepresentative(RevenueRecognition model)
 {
     try
     {
         var userToNotifydetail = _contractRefactorService.GetKeyPersonnelByContractGuid(model.ContractGuid)
                                  .FirstOrDefault(x => x.UserRole == ContractUserRole._accountRepresentative);
         if (userToNotifydetail != null)
         {
             Guid userToNotify = userToNotifydetail.UserGuid;
             var  contractType = _contractRefactorService.GetContractType(model.ContractGuid);
             var  key          = Infrastructure.Helpers.FormatHelper.ConcatResourceTypeAndAction(EnumGlobal.ResourceType.RevenueRecognition.ToString(),
                                                                                                 EnumGlobal.CrudType.Notify.ToString());
             var updatedByName    = _userService.GetUserByUserGuid(model.UpdatedBy);
             var receiverUserName = _userService.GetUserByUserGuid(userToNotify).DisplayName;
             return(AddNotificationMessage(model));
         }
         return(true);
     }
     catch (Exception ex)
     {
         var userGuid = UserHelper.CurrentUserGuid(HttpContext);
         EventLogHelper.Error(_eventLogger, new EventLog
         {
             EventGuid   = Guid.NewGuid(),
             Action      = "",
             Application = "ESS",
             EventDate   = DateTime.UtcNow,
             Message     = ex.Message,
             Resource    = ResourceType.Notification.ToString(),
             StackTrace  = ex.StackTrace,
             UserGuid    = userGuid
         });
         return(false);
     }
 }
Пример #3
0
        public IActionResult Error()
        {
            var    exceptionDetails = HttpContext.Features.Get <IExceptionHandlerPathFeature>();
            string path             = exceptionDetails.Path.Substring(1, exceptionDetails.Path.Length - 1);
            string action           = "";

            try
            {
                string controller = path.Substring(0, path.IndexOf("/"));
                int    length     = path.Length;
                int    remlen     = path.Length - controller.Length;
                string newstring  = path.Substring(controller.Length + 1, remlen - 1);
                if (newstring.Contains("/"))
                {
                    action = newstring.Substring(0, newstring.IndexOf("/"));
                }
                else if (newstring.Contains("?"))
                {
                    action = newstring.Substring(0, newstring.IndexOf("?") + 1);
                }
                else
                {
                    action = newstring;
                }
                EventLogHelper.Error(_eventLogger, new Infrastructure.Models.EventLog
                {
                    EventGuid   = Guid.NewGuid(),
                    Action      = action,
                    Application = "ESS",
                    EventDate   = DateTime.UtcNow,
                    Message     = exceptionDetails.Error.Message,
                    Resource    = controller,
                    StackTrace  = exceptionDetails.Error.StackTrace,
                    UserGuid    = UserHelper.CurrentUserGuid(HttpContext)
                });
                return(View(new { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }));
            }
            catch
            {
                EventLogHelper.Error(_eventLogger, new Models.EventLog
                {
                    EventGuid   = Guid.NewGuid(),
                    Action      = "Index",
                    Application = "ESS",
                    EventDate   = DateTime.UtcNow,
                    Message     = exceptionDetails.Error.Message,
                    Resource    = path,
                    StackTrace  = exceptionDetails.Error.StackTrace,
                    UserGuid    = UserHelper.CurrentUserGuid(HttpContext)
                });
                return(View());
            }
        }
Пример #4
0
        public static BadRequestObjectResult BadRequest(this Controller controller, string errorMessage)
        {
            string controllerName = controller.ControllerContext.RouteData.Values["controller"].ToString();
            string action         = controller.ControllerContext.RouteData.Values["action"].ToString();

            EventLogHelper.Error(_eventLogger, new EventLog
            {
                EventGuid   = Guid.NewGuid(),
                Action      = action,
                Application = "ESS",
                EventDate   = DateTime.UtcNow,
                Message     = errorMessage,
                Resource    = controllerName,
                StackTrace  = null,
                UserGuid    = UserHelper.CurrentUserGuid(controller.HttpContext)
            });
            return(controller.BadRequest(errorMessage));
        }
        private bool AddNotificationMessage(ContractNotificationModel contractModel)
        {
            try
            {
                var     notificationModel            = new GenericNotificationViewModel();
                var     notificationTemplatesDetails = new NotificationTemplatesDetail();
                var     userList        = new List <User>();
                var     receiverInfo    = new User();
                Guid?   receiverGuid    = Guid.Empty;
                decimal thresholdAmount = 0.00M;

                notificationModel.ResourceId              = contractModel.ContractGuid;
                notificationModel.RedirectUrl             = _configuration.GetSection("SiteUrl").Value + ("/contract/Details/" + contractModel.ContractGuid);
                notificationModel.NotificationTemplateKey = contractModel.key;
                notificationModel.CurrentDate             = CurrentDateTimeHelper.GetCurrentDateTime();
                notificationModel.CurrentUserGuid         = UserHelper.CurrentUserGuid(HttpContext);
                notificationModel.SendEmail = true;


                var keyPersonnels = _contractService.GetKeyPersonnelByContractGuid(contractModel.ContractGuid);

                if (keyPersonnels?.Any() == true)
                {
                    receiverGuid = keyPersonnels.FirstOrDefault(x => x.UserRole == ContractUserRole._contractRepresentative)?.UserGuid;
                    if (receiverGuid != Guid.Empty)
                    {
                        thresholdAmount = RevenueRecognitionHelper.GetAmountByContractType(_configuration, contractModel.ContractType);

                        receiverInfo = _userService.GetUserByUserGuid(receiverGuid ?? Guid.Empty);

                        var    resourcevalue = _resourceAttributeValueService.GetResourceAttributeValueByValue(contractModel.ContractType);
                        string contracttype  = string.Empty;
                        if (resourcevalue != null)
                        {
                            contracttype = resourcevalue.Name;
                        }

                        if (receiverInfo != null)
                        {
                            userList.Add(receiverInfo);
                            notificationModel.IndividualRecipients = userList;
                        }

                        var keyList = "<ul>";
                        keyList += "<li>" + receiverInfo.DisplayName + " (" + receiverInfo.JobTitle + ")" + "</li>";
                        StringBuilder additionalUser = new StringBuilder(keyList);

                        notificationTemplatesDetails.ContractNumber   = contractModel.ContractNumber;
                        notificationTemplatesDetails.Title            = contractModel.ContractTitle;
                        notificationTemplatesDetails.ContractType     = contracttype;
                        notificationTemplatesDetails.ContractTitle    = contractModel.ContractTitle;
                        notificationTemplatesDetails.ProjectNumber    = contractModel.ProjectNumber;
                        notificationTemplatesDetails.AdditionalUser   = additionalUser.ToString();
                        notificationTemplatesDetails.ThresholdAmount  = thresholdAmount;
                        notificationTemplatesDetails.Status           = "";
                        notificationModel.NotificationTemplatesDetail = notificationTemplatesDetails;
                        _genericNotificationService.AddNotificationMessage(notificationModel);
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                var userGuid = UserHelper.CurrentUserGuid(HttpContext);
                EventLogHelper.Error(_eventLogger, new EventLog
                {
                    EventGuid   = Guid.NewGuid(),
                    Action      = "Index",
                    Application = "ESS",
                    EventDate   = DateTime.UtcNow,
                    Message     = ex.Message,
                    Resource    = ResourceType.Contract.ToString(),
                    StackTrace  = ex.StackTrace,
                    UserGuid    = userGuid
                });
                return(false);
            }
        }
Пример #6
0
        private bool SendNotification(Guid resourceId, Guid contractGuid, int currentStage)
        {
            try
            {
                var notificationModel            = new GenericNotificationViewModel();
                var notificationTemplatesDetails = new NotificationTemplatesDetail();
                var userList     = new List <User>();
                var receiverInfo = new User();
                var receiverGuid = Guid.Empty;

                notificationModel.ResourceId              = resourceId;
                notificationModel.RedirectUrl             = _configuration.GetSection("SiteUrl").Value + ("/JobRequest/Detail/" + contractGuid);
                notificationModel.NotificationTemplateKey = Infrastructure.Helpers.FormatHelper.ConcatResourceTypeAndAction
                                                                (EnumGlobal.ResourceType.JobRequest.ToString(), EnumGlobal.CrudType.Notify.ToString());
                notificationModel.CurrentDate     = CurrentDateTimeHelper.GetCurrentDateTime();
                notificationModel.CurrentUserGuid = UserHelper.CurrentUserGuid(HttpContext);
                notificationModel.SendEmail       = true;

                var jobRequestEntity = _jobRequestService.GetDetailsForJobRequestById(contractGuid);
                var model            = ContractsMapper.MapJobRequestToViewModel(jobRequestEntity);

                var keyPersonnels = _contractRefactorService.GetKeyPersonnelByContractGuid(contractGuid);
                if (keyPersonnels?.Any() == true)
                {
                    switch (currentStage)
                    {
                    case (int)JobRequestStatus.ProjectControl:
                        var projectControls = keyPersonnels.FirstOrDefault(x => x.UserRole == ContractUserRole._projectControls);
                        if (projectControls != null)
                        {
                            receiverGuid = projectControls.UserGuid;
                        }
                        break;

                    case (int)JobRequestStatus.ProjectManager:
                        var projectManager = keyPersonnels.FirstOrDefault(x => x.UserRole == ContractUserRole._projectManager);
                        if (projectManager != null)
                        {
                            receiverGuid = projectManager.UserGuid;
                        }
                        break;

                    case (int)JobRequestStatus.Accounting:
                        var accountRepresentative = keyPersonnels.FirstOrDefault(x => x.UserRole == ContractUserRole._accountRepresentative);
                        if (accountRepresentative != null)
                        {
                            receiverGuid = accountRepresentative.UserGuid;
                        }
                        break;
                    }

                    receiverInfo = _userService.GetUserByUserGuid(receiverGuid);
                    if (receiverInfo != null)
                    {
                        userList.Add(receiverInfo);
                        notificationModel.IndividualRecipients = userList;
                    }

                    var keyList = "<ul>";
                    foreach (var person in keyPersonnels)
                    {
                        keyList += "<li>" + person.User.DisplayName + " (" + person.UserRole + ")" + "</li>";
                    }
                    keyList += "</li>";
                    StringBuilder additionalUser = new StringBuilder(keyList);

                    notificationTemplatesDetails.ContractNumber   = model.BasicContractInfo.ContractNumber;
                    notificationTemplatesDetails.AwardingAgency   = model.CustomerInformation.AwardingAgencyOfficeName;
                    notificationTemplatesDetails.FundingAgency    = model.CustomerInformation.FundingAgencyOfficeName;
                    notificationTemplatesDetails.ProjectNumber    = model.BasicContractInfo.ProjectNumber;
                    notificationTemplatesDetails.ContractTitle    = model.BasicContractInfo.ContractTitle;
                    notificationTemplatesDetails.Description      = model.BasicContractInfo.Description;
                    notificationTemplatesDetails.AdditionalUser   = additionalUser.ToString();
                    notificationTemplatesDetails.Status           = "";
                    notificationModel.NotificationTemplatesDetail = notificationTemplatesDetails;
                    _genericNotificationService.AddNotificationMessage(notificationModel);
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                var userGuid = UserHelper.CurrentUserGuid(HttpContext);
                EventLogHelper.Error(_eventLogger, new EventLog
                {
                    EventGuid   = Guid.NewGuid(),
                    Action      = "Index",
                    Application = "ESS",
                    EventDate   = DateTime.UtcNow,
                    Message     = ex.Message,
                    Resource    = ResourceType.Contract.ToString(),
                    StackTrace  = ex.StackTrace,
                    UserGuid    = userGuid
                });
                return(false);
            }
        }