Beispiel #1
0
        private static async Task <int> addStorageJob(Move move, string regNumber)
        {
            Console.WriteLine("Creating a job in Arive");
            Trace.WriteLine($"{regNumber}, , Creating a job in Arive");

            var url = string.Empty;

            var movesAccount = _accountEntities.FirstOrDefault(ae => ae.AccountingId.Equals(move.AccountId));
            var movesBooker  = _vendor.FirstOrDefault(ae => ae.Accounting_SI_Code.Equals(move.Booker));

            if (movesAccount == null)
            {
                if (move.AccountId.Equals("1674") ||
                    move.AccountId.Equals("279029") ||
                    move.AccountId.Equals("273923") ||
                    move.AccountId.Equals("370377") ||
                    move.AccountId.Equals("OM1119")) //Shipper Direct
                {
                    Trace.WriteLine($"{regNumber}, , Missing Account in Arive {move.AccountId}, thus Defaulting Shipper Direct");
                    movesAccount = _accountEntities.FirstOrDefault(ae => ae.Id == 283);
                }
                else if (move.AccountId.Equals("181359"))
                {
                    Trace.WriteLine($"{regNumber}, , Missing Account in Arive {move.AccountId}, thus Defaulting Overseas Agent");
                    movesAccount = _accountEntities.FirstOrDefault(ae => ae.Name == "OVERSEAS AGENT BOOKING");
                }
                else
                {
                    throw new Exception($"Missing Account in Arive {move.AccountId}");
                }
            }

            var response = await DetermineBillTo(move.BILL, null, regNumber);

            if (response.BilltoId == null)
            {
                Trace.WriteLine($"{regNumber}, , Missing BillTo in Arive {move.BILL}");
                Trace.WriteLine($"{regNumber}, , Defaulting BillTo as Shipper Direct");
                response.BilltoId   = 283;
                response.BilltoType = "Account";
            }

            var model = move.ToJobModel(movesAccount.Id, movesBooker?.Id, response.BilltoId, response.BilltoType);

            model.Job.ExternalReference            = regNumber;
            model.Job.ExternalReferenceDescription = "RegNumber from GMMS : Storage Migration";

            string parsedResponse = await JobsApi.CallJobsApi(_httpClient, url, model);

            Console.WriteLine($"Job created {parsedResponse}");
            Trace.WriteLine($"{regNumber},{parsedResponse} , Job created");
            return(int.Parse(parsedResponse));
        }
Beispiel #2
0
        private static async Task addJobContacts(Move move, int jobId, string regNumber)
        {
            var jobContactList = new List <CreateJobContactDto>();

            for (int i = 0; i < 5; i++)
            {
                var dictionaryValue = string.Empty;
                var contactType     = string.Empty;

                switch (i)
                {
                case 0:
                    contactType     = "Biller Contact";
                    dictionaryValue = NameTranslator.repo.GetValueOrDefault(move.BILLER.Format());
                    break;

                case 1:
                    contactType = "Move Consultant";
                    var nameToUse = string.Empty;

                    if (!string.IsNullOrEmpty(move.MOVE_MANAGER) && !move.MOVE_MANAGER.Equals("STORAGE"))
                    {
                        nameToUse = move.MOVE_MANAGER.Format();
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(move.MOVE_COORDINATOR) && !move.MOVE_COORDINATOR.Equals("STORAGE"))
                        {
                            nameToUse = move.MOVE_COORDINATOR.Format();
                        }
                        else
                        {
                            Console.WriteLine("Defaulting MoveConsultant to Angela La Fronza due to bad data");
                            Trace.WriteLine($"{regNumber}, , Defaulting MoveConsultant to Angela La Fronza due to bad data");
                            nameToUse = "Angela.Lafronza";
                        }
                    }

                    dictionaryValue = NameTranslator.repo.GetValueOrDefault(nameToUse);

                    if (string.IsNullOrEmpty(dictionaryValue))
                    {
                        Trace.WriteLine($"{regNumber}, , Move Consultant from GMMS {nameToUse} couldn't be found in Arive thus Defaulting to Angela La Fronza");
                        dictionaryValue = NameTranslator.repo.GetValueOrDefault("Angela.Lafronza");
                    }
                    break;

                case 2:
                    contactType     = "Traffic Consultant";
                    dictionaryValue = NameTranslator.repo.GetValueOrDefault(move.TRAFFIC_MANAGER.Format());
                    break;

                case 3:
                    contactType     = "Pricing Consultant";
                    dictionaryValue = NameTranslator.repo.GetValueOrDefault(move.QUOTED_BY.Format());
                    break;

                case 4:
                    contactType     = "Salesperson Contact";
                    dictionaryValue = NameTranslator.repo.GetValueOrDefault(move.SALES.Format());
                    break;
                }

                if (!string.IsNullOrEmpty(dictionaryValue))
                {
                    var adObj = await SungateApi.GetADName(_httpClient, dictionaryValue, regNumber);

                    if ((adObj == null || adObj.Count == 0) && contactType.Equals("Move Consultant"))
                    {
                        Console.WriteLine("User not found in sungate");
                        Trace.WriteLine($"{regNumber}, , user not found in sungate");

                        dictionaryValue = NameTranslator.repo.GetValueOrDefault("Angela.Lafronza");

                        adObj = await SungateApi.GetADName(_httpClient, dictionaryValue, regNumber);
                    }

                    if (adObj == null || adObj.Count == 0)
                    {
                        Console.WriteLine("User not found in sungate");
                        Trace.WriteLine($"{regNumber}, , user not found in sungate");

                        continue;
                    }

                    jobContactList.Add(new CreateJobContactDto
                    {
                        ContactType = contactType,
                        Email       = adObj.FirstOrDefault().email,
                        FullName    = adObj.FirstOrDefault().fullName,
                        Phone       = adObj.FirstOrDefault().phone
                    });
                }
            }

            Console.WriteLine("Adding Job Contacts");
            Trace.WriteLine($"{regNumber}, , Adding Job Contacts");

            var url = $"/{jobId}/contacts";

            await JobsApi.CallJobsApi(_httpClient, url, jobContactList);
        }