예제 #1
0
        private static async Task AddPromptsFromGmmsToArive(Move move, int jobId, string regNumber)
        {
            var legacyPromptEntity = await WaterDbAccess.RetrievePrompts(move.RegNumber);

            if (legacyPromptEntity == null || legacyPromptEntity.Count == 0)
            {
                Trace.WriteLine($"{regNumber}, , No Available prompts found in GMMS");
                return;
            }

            foreach (var prompt in legacyPromptEntity)
            {
                var adObj = await SungateApi.GetADName(_httpClient, NameTranslator.repo.GetValueOrDefault(prompt.ENTERED_BY), regNumber);

                if (adObj != null && adObj.Count > 0)
                {
                    prompt.ENTERED_BY = adObj.FirstOrDefault().email;
                }
                else
                {
                    Console.WriteLine($"{regNumber}, Can't get Prompt created User So defaulting it to [email protected]");
                    Trace.WriteLine($"{regNumber}, , Can't get Prompt created User So defaulting it to [email protected]");
                    prompt.ENTERED_BY = "*****@*****.**";
                }

                prompt.JobId = jobId;
            }

            var workflowTasks = legacyPromptEntity.ToWorkFlowTask();

            await TaskDbAccess.AddPrompts(workflowTasks, regNumber, jobId);
        }
예제 #2
0
        private static async Task AddNotesFromGmmsToArive(Move move, int jobId, string regNumber)
        {
            var notesEntity = await WaterDbAccess.RetrieveNotesForMove(move.RegNumber);

            if (notesEntity == null)
            {
                Trace.WriteLine($"{regNumber}, , No Available notes found in GMMS");
                return;
            }

            foreach (var note in notesEntity)
            {
                var adObj = await SungateApi.GetADName(_httpClient, NameTranslator.repo.GetValueOrDefault(note.ENTERED_BY), regNumber);

                if (adObj != null && adObj.Count > 0)
                {
                    note.ENTERED_BY = adObj.FirstOrDefault().email;
                }
                else
                {
                    note.ENTERED_BY = "*****@*****.**";
                }
            }

            var createJobNoteRequests = notesEntity.ToNotesModel();

            foreach (var noteobj in createJobNoteRequests)
            {
                if (!noteobj.Category.Equals("serviceboard"))
                {
                    noteobj.DisplayId = regNumber;
                }

                noteobj.ReferenceId = jobId;
            }

            await TaskDbAccess.AddNotes(createJobNoteRequests, jobId, regNumber);

            //await TaskApi.CreateNotes(_httpClient, createJobNoteRequests, jobId, regNumber);
        }
예제 #3
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);
        }
예제 #4
0
        private static async Task Main(string[] args)
        {
            loadAllRecords = true;

            SetConsoleWriteLine();
            SetMovesToImport(loadAllRecords);
            await RetrieveJobsAccountAndVendor();

            Trace.WriteLine($"GMMS REG Number, Arive Job# , Log text ");
            int counter = 0;
            var jobId   = 0;

            //Normal Import
            foreach (var regNumber in movesToImport)
            {
                try
                {
                    Console.WriteLine("-----------------------------------------------------------------------------------");
                    Console.WriteLine($"Processing { ++counter} records of {movesToImport.Count} to import");

                    Trace.WriteLine($"{regNumber}, , ");
                    Trace.WriteLine($"{regNumber}, , -----------------------------------------------------------------------------------");

                    await SungateApi.setApiAccessTokenAsync(_httpClient);

                    var move = await WaterDbAccess.RetrieveWaterRecords(regNumber);

                    if (move == null)
                    {
                        continue;
                    }

                    //Add the job
                    jobId = await addStorageJob(move, regNumber);

                    //update datecreated on the job
                    JobsDbAccess.ChangeDateCreated(jobId, move.DateEntered.GetValueOrDefault(DateTime.UtcNow), regNumber);

                    //Add JobContacts
                    await addJobContacts(move, jobId, regNumber);

                    //Add SuperService
                    var result = await JobsApi.CreateStorageSSO(_httpClient, jobId, regNumber);

                    var ssoId = result.Id;

                    var serviceOrders = await JobsDbAccess.GetServiceOrderForJobs(jobId, regNumber);

                    // ORIGIN
                    var oaVendor = _vendor.Find(v => v.Accounting_SI_Code.Equals(move.OriginAgent.VendorNameId));
                    await JobsApi.UpdateOriginMilestone(_httpClient, serviceOrders.FirstOrDefault(so => so.ServiceId == 24).Id, oaVendor, move, jobId, regNumber);

                    // DESTINATION
                    var daVendor = _vendor.Find(v => v.Accounting_SI_Code.Equals(move.DestinationAgent.VendorNameId));
                    await JobsApi.UpdateDestinationMilestone(_httpClient, serviceOrders.FirstOrDefault(so => so.ServiceId == 26).Id, daVendor, move, jobId, regNumber);

                    var legacyInsuranceClaims = await WaterDbAccess.RetrieveInsuranceClaims(move.RegNumber);

                    // STORAGE
                    var transfereeEntity = await JobsDbAccess.GetJobsTransfereeId(jobId);
                    await updateStorageJob(move, jobId, serviceOrders, regNumber, transfereeEntity, legacyInsuranceClaims, ssoId);

                    // INSURANCE
                    await JobsApi.UpdateICtMilestone(_httpClient, serviceOrders.FirstOrDefault(so => so.ServiceId == 27).Id, move, jobId, legacyInsuranceClaims, regNumber);

                    #region JobCost

                    var superServiceOrderId = serviceOrders.FirstOrDefault(so => so.ServiceId == 29).SuperServiceOrderId;

                    try
                    {
                        if (move.READY_TO_ACCRUE_DATE != null)
                        {
                            await JobsDbAccess.LockJC(jobId, regNumber, superServiceOrderId, move.READY_TO_ACCRUE_DATE.Value);

                            await JobsDbAccess.MarkAsPosted(superServiceOrderId, DateTime.Now, true, regNumber, move.ACCRUED_DATE);

                            //await JobsDbAccess.MarkAllAsVoid(superServiceOrderId, regNumber);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error while trying to change JC status manually");
                        Trace.WriteLine($"{regNumber}, , Error while trying to change JC status manually");
                        Trace.WriteLine($"{regNumber}, , {ex.Message}");
                    }

                    #endregion JobCost

                    //Add Notes
                    await AddNotesFromGmmsToArive(move, jobId, regNumber);

                    //Add Prompts
                    await AddPromptsFromGmmsToArive(move, jobId, regNumber);

                    decimal percentage = (decimal)(counter * 100) / movesToImport.Count;

                    Console.WriteLine($"{ Math.Round(percentage, 2)}% Completed ");
                    Trace.WriteLine($"{regNumber}, , EndTime: {DateTime.Now}");
                }
                catch (Exception ex)
                {
                    Trace.WriteLine($"{regNumber}, , *** ERROR ***");
                    if (ex.InnerException != null)
                    {
                        Trace.WriteLine($"{regNumber}, , {ex.InnerException.Message}");
                    }
                    else
                    {
                        Trace.WriteLine($"{regNumber}, , {ex.Message}");
                    }

                    Console.WriteLine($"**** ERROR ****");
                    Console.WriteLine($"{ex.Message}");
                }

                Trace.Flush();
            }

            //Remove Prompts from MigrationScript
            TaskDbAccess.RemovePrompts();
        }