Exemple #1
0
        public FieldConfigInfo GetFields(string recordType, CaseActionEnum action)
        {
            var eventType = $"CaseBase_Get{action}Fields";

            try
            {
                if (string.IsNullOrWhiteSpace(recordType))
                {
                    throw new BadRequestException("Required field RecordType is empty",
                                                  new LogObject(eventType, null));
                }
                var caseSetting = SfdcSetting.Setting(recordType);
                if (caseSetting == null)
                {
                    throw new BadRequestException($"{action} required field RecordType is invalid",
                                                  new LogObject(eventType, null));
                }
                var settingPath = action == CaseActionEnum.Create ? caseSetting.CaseSettingPath : caseSetting.UpdateCaseSettingPath;
                var configPath  = Utility.GetFullpath(Path.Combine("CaseConfiguration", settingPath));
                return(JsonConvert.DeserializeObject <FieldConfigInfo>(File.ReadAllText(configPath)));
            }
            catch (BadRequestException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new GdErrorException(
                          $"An error has occurred when trying to deserialize case configuration for RecordType {recordType}",
                          new LogObject(eventType, new Dictionary <string, object> {
                    { "RecordType", recordType }
                }), ex);
            }
        }
Exemple #2
0
 public void Execute(CaseEx request, CaseActionEnum action)
 {
     if (request != null)
     {
         var fieldConfig = CaseRepository.GetFields(request.RecordType, action);
         if (action == CaseActionEnum.Create)
         {
             if (!AllowToCreateNewCase())
             {
                 throw new BadRequestException(
                           "Not allowed to create a new case because the current case is still in pending",
                           new LogObject("CaseValidationTask_ExecuteAsync", null));
             }
         }
         Validation(request, fieldConfig);
     }
 }
Exemple #3
0
 public async Task PreProcessing <TRequest>(TRequest request, dynamic tasks, CaseActionEnum action)
 {
     if (request == null)
     {
         throw new BadRequestException("Case request object is null", new LogObject("CaseBase_PreProcessing", null));
     }
     foreach (var task in tasks)
     {
         if (task.IsAsync)
         {
             await task.ExecuteAsync(request, action);
         }
         else
         {
             task.Execute(request, action);
         }
     }
 }
        public void Execute(CaseEx request, CaseActionEnum action)
        {
            var fieldConfig = CaseRepository.GetFields(request.RecordType, action);
            var sfdcSetting = SfdcSetting.Setting(request.RecordType);

            if (sfdcSetting != null)
            {
                if (string.IsNullOrWhiteSpace(fieldConfig.AssemplyName))
                {
                    //make assumption that AssemplyName is the same as the current project's AssemplyName
                    fieldConfig.AssemplyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
                }
                if (string.IsNullOrWhiteSpace(fieldConfig.ClassName))
                {
                    //make assummption that a class a created under Gdot.Partner.Care.SFDC.Logic.RecordTypes namespace + recordtype
                    fieldConfig.ClassName = action == CaseActionEnum.Create
                        ? $"{fieldConfig.AssemplyName}.RecordTypes.{Path.GetFileNameWithoutExtension(sfdcSetting.CaseSettingPath)}"
                        : $"{fieldConfig.AssemplyName}.RecordTypes.{Path.GetFileNameWithoutExtension(sfdcSetting.UpdateCaseSettingPath)}";
                }
                var recordTypeObj = _createRecordTypeFunc(request.RecordType);
                recordTypeObj?.Execute(request);
            }
        }
Exemple #5
0
        public async Task ExecuteAsync(CaseEx request, CaseActionEnum action)
        {
            if (action == CaseActionEnum.Update && string.IsNullOrEmpty(request.Id))
            {
                request.Id = await CaseRepository.GetCaseId(request.CaseNumber);

                if (string.IsNullOrEmpty(request.Id))
                {
                    throw new NotFoundException("Cannot find the case with case number.",
                                                new LogObject("GetDataFromExternalTask_UpdateExecuteAsync", null));
                }
            }
            Task <string> ownerId = null;

            if (!string.IsNullOrEmpty(request.GroupName))
            {
                ownerId = CaseRepository.GetOwnerId(request.GroupName);
            }
            else if (!string.IsNullOrEmpty(request.CaseOwner))
            {
                ownerId = CaseRepository.GetOwnerIdByUserName(request.CaseOwner);
            }
            var personAccountInput = new PersonAccountInput
            {
                FirstName         = request.First_Name__c,
                LastName          = request.Last_Name__c,
                AccountIdentifier = request.AccountIdentifier,
                Brand             = request.Brand_OFAC__c,
                Product           = "Wave"
            };
            //await GetCustomerInfo(personAccountInput);//Get Customer info from CardAccount service

            var recordTypeId  = CaseRepository.GetRecordTypeId(request.RecordType, ObjectTypeEnum.Case);
            var personAccount = CaseRepository.GetPersonAccount(personAccountInput);//Get or Create person Account

            string ownerIdResult = null;

            if (ownerId != null)
            {
                ownerIdResult = await ownerId;
            }

            var recordTypeIdResult  = await recordTypeId;
            var personAccountResult = await personAccount;

            if (!string.IsNullOrWhiteSpace(ownerIdResult))
            {
                request.OwnerId = ownerIdResult;
            }
            if (action == CaseActionEnum.Update)
            {
                if (!string.IsNullOrEmpty(request.CaseOwner) && string.IsNullOrEmpty(request.OwnerId))
                {
                    throw new NotFoundException("Salesforce case owner does not exist.",
                                                new LogObject("GetDataFromExternalTask_UpdateExecuteAsync", null));
                }
            }
            if (!string.IsNullOrWhiteSpace(recordTypeIdResult))
            {
                request.RecordTypeId = recordTypeIdResult;
            }
            if (personAccountResult != null)
            {
                request.AccountId = personAccountResult.Id;
                request.ContactId = personAccountResult.PersonContactId;
            }
        }
Exemple #6
0
        //private async Task GetCustomerInfo(PersonAccountInput personAccountInput)
        //{
        //    if (!string.IsNullOrEmpty(personAccountInput.AccountKey))
        //    {
        //        try
        //        {
        //            var cardAccountRequest = new CardAccountRequest()
        //            {
        //                CardAccountToken = personAccountInput.AccountKey
        //            };
        //            var customerInfo = await cardAccountService.GetCustomerByAccountKey(cardAccountRequest);

        //            personAccountInput.CustomerKey = customerInfo?.CustomerKey;
        //            personAccountInput.FirstName = customerInfo?.FirstName;
        //            personAccountInput.LastName = customerInfo?.LastName;
        //        }
        //        catch (ExternalErrorException ex)
        //        {
        //            Logger.Warn(new LogObject("GetCustomerByAccountKey", ex.ResponseText));
        //        }
        //    }
        //}

        public void Execute(CaseEx request, CaseActionEnum action)
        {
            throw new NotImplementedException();
        }
 public Task ExecuteAsync(CaseEx request, CaseActionEnum action)
 {
     throw new NotImplementedException();
 }
Exemple #8
0
 public Task ExecuteAsync(CaseEx request, CaseActionEnum action)
 {
     throw new GdErrorException("ExecuteAsync not implemented");
 }
        public void Execute(CaseEx request, CaseActionEnum action)
        {
            var fieldConfig = CaseRepository.GetFields(request.RecordType, action);

            SetProperty(request, fieldConfig);
        }