Esempio n. 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);
        }
Esempio n. 2
0
        internal static async Task CreateNotes(HttpClient httpClient, List <CreateJobNoteRequest> createJobNoteRequests, int jobId, string regNumber)
        {
            Console.WriteLine($"Adding {createJobNoteRequests.Count} Notes to Task");
            Trace.WriteLine($"{regNumber}, , Adding {createJobNoteRequests.Count} Notes to Task");

            //string url = "​Notes"; //TODO: figure out why this isn't working
            string url = $"Notes/jobs/{jobId}";

            foreach (var createJobNote in createJobNoteRequests)
            {
                createJobNote.JobId       = jobId;
                createJobNote.ReferenceId = jobId;

                var noteId = await PostToTaskApi(httpClient, url, createJobNote);

                var note = JsonConvert.DeserializeObject <NoteResponseModel>(noteId);

                //call taskdb and update the datecreated
                TaskDbAccess.ChangeDateCreated(note.Id, createJobNote.DateCreated, regNumber);
            }
        }
Esempio n. 3
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);
        }
Esempio n. 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();
        }