コード例 #1
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);
     }
 }
コード例 #2
0
        private bool AddNotificationMessage(RevenueRecognition model)
        {
            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;
                string  key             = string.Empty;
                string  contractNumber  = string.Empty;
                string  taskorderNumber = string.Empty;

                var contractdetails = _contractRefactorService.GetOnlyRequiredContractData(model.ContractGuid);
                notificationModel.RedirectUrl = _configuration.GetSection("SiteUrl").Value + ("/contract/Details/" + model.ContractGuid);
                if (contractdetails != null)
                {
                    if (contractdetails.ParentContractGuid != null)
                    {
                        if (contractdetails.ParentContractGuid != Guid.Empty)
                        {
                            key = Infrastructure.Helpers.FormatHelper.ConcatResourceTypeAndAction(EnumGlobal.ResourceType.RevenueRecognition.ToString(),
                                                                                                  EnumGlobal.ResourceAction.TaskOrderReview.ToString());
                            var parentcontractEntity = _contractRefactorService.GetOnlyRequiredContractData(contractdetails.ParentContractGuid);
                            contractNumber  = parentcontractEntity.ContractNumber;
                            taskorderNumber = contractdetails.ContractNumber;
                            notificationModel.RedirectUrl = _configuration.GetSection("SiteUrl").Value + ("/project/Details/" + model.ContractGuid);
                        }
                        else
                        {
                            key = Infrastructure.Helpers.FormatHelper.ConcatResourceTypeAndAction(EnumGlobal.ResourceType.RevenueRecognition.ToString(),
                                                                                                  EnumGlobal.ResourceAction.ContractReview.ToString());
                        }
                    }
                    else
                    {
                        key = Infrastructure.Helpers.FormatHelper.ConcatResourceTypeAndAction(EnumGlobal.ResourceType.RevenueRecognition.ToString(),
                                                                                              EnumGlobal.ResourceAction.ContractReview.ToString());
                    }

                    notificationModel.ResourceId = model.ContractGuid;
                    notificationModel.NotificationTemplateKey = key;
                    notificationModel.CurrentDate             = CurrentDateTimeHelper.GetCurrentDateTime();
                    notificationModel.CurrentUserGuid         = UserHelper.CurrentUserGuid(HttpContext);
                    notificationModel.SendEmail = true;


                    var keyPersonnels = _contractRefactorService.GetKeyPersonnelByContractGuid(model.ContractGuid);

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

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

                            var    resourcevalue = _resourceAttributeValueService.GetResourceAttributeValueByValue(model.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   = contractNumber;
                            notificationTemplatesDetails.TaskOrderNumber  = taskorderNumber;
                            notificationTemplatesDetails.Title            = contractdetails.ContractTitle;
                            notificationTemplatesDetails.ContractType     = contracttype;
                            notificationTemplatesDetails.ContractTitle    = contractdetails.ContractTitle;
                            notificationTemplatesDetails.ProjectNumber    = contractdetails.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);
            }
        }
コード例 #3
0
 public int UpdateRevenueRecognition(RevenueRecognition RevenueRecognition)
 {
     return(_iRevenueRecognitionRepository.UpdateRevenueRecognition(RevenueRecognition));
 }
コード例 #4
0
 public bool AddRevenueWithResourceGuid(RevenueRecognition revenueRecognition)
 {
     return(_iRevenueRecognitionRepository.AddRevenueWithResourceGuid(revenueRecognition));
 }