internal async Task <bool> UploadProjects()
        {
            string clientID = link.ClientIDForUplinkProject;

            //AbstractProject abstractProject = projects[1];   // Test line
            foreach (AbstractProject abstractProject in projects)
            {
                Log.AddLog("Adding project to XTRF: " + abstractProject.ExternalProjectCode, ErrorLevels.Information);

                try
                {
                    HttpResponseMessage response;
                    string newXTRFProjectID     = "";
                    string newXTRFProjectIDCode = "";

                    XTRF_CreateProjectRequest xcprequest = new XTRF_CreateProjectRequest()
                    {
                        clientId  = Int32.Parse(clientID),
                        name      = MappingManager.GetScriptedValue(link, MapType.ProjectName, abstractProject),
                        serviceId = Convert.ToInt32(MappingManager.DoMappingToUplinkCustomValues(MapType.Workflow, link, MappingManager.GetScriptedValue(link, MapType.Workflow, abstractProject)))
                    };

                    try
                    {
                        response = await client.PostAsJsonAsync("v2/projects", xcprequest);

                        response.EnsureSuccessStatusCode();
                        XTRF_ProjectCreateResponse xpcresponse = await response.Content.ReadAsAsync <XTRF_ProjectCreateResponse>();

                        newXTRFProjectID     = xpcresponse.id;
                        newXTRFProjectIDCode = xpcresponse.projectIdNumber;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("XTRF project creation failed. " + ex.Message);
                    }

                    try
                    {
                        XTRF_SetSourceLanguage xssl = new XTRF_SetSourceLanguage()
                        {
                            sourceLanguageId = Convert.ToInt32(MappingManager.DoMappingToUplinkGeneral(MapType.Language, link.UplinkBTMSSystemTypeID, abstractProject.SourceLanguageID.ToString()))
                        };
                        response = await client.PutAsJsonAsync("v2/projects/" + newXTRFProjectID + "/sourceLanguage", xssl);
                    }
                    catch (Exception ex)
                    {
                        Log.AddLog("XTRF project source language (" + abstractProject.SourceLanguageID.ToString() + " ) cannot be set. " + ex.Message, ErrorLevels.Error);
                    }

                    try
                    {
                        XTRF_SetTargetLanguage xstl = new XTRF_SetTargetLanguage();
                        foreach (int languageID in abstractProject.TargetLanguageIDs)
                        {
                            try
                            {
                                xstl.targetLanguageIds.Add(Convert.ToInt32(MappingManager.DoMappingToUplinkGeneral(MapType.Language, link.UplinkBTMSSystemTypeID, languageID.ToString())));
                            }
                            catch (Exception ex)
                            {
                                Log.AddLog("XTRF project target language is not mapped (" + languageID.ToString() + " ). " + ex.Message, ErrorLevels.Error);
                            }
                        }

                        if (xstl.targetLanguageIds.Count > 0)
                        {
                            response = await client.PutAsJsonAsync("v2/projects/" + newXTRFProjectID + "/targetLanguages", xstl);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.AddLog("XTRF project target language setting error. " + ex.Message, ErrorLevels.Error);
                    }

                    try
                    {
                        XTRF_SetSpecialization xsspec = new XTRF_SetSpecialization()
                        {
                            specializationId = Convert.ToInt32(MappingManager.DoMappingToUplinkGeneral(MapType.Speciality, link.UplinkBTMSSystemTypeID, abstractProject.SpecialityID.ToString()))
                        };
                        response = await client.PutAsJsonAsync("v2/projects/" + newXTRFProjectID + "/specialization", xsspec);
                    }
                    catch (Exception ex)
                    {
                        Log.AddLog("XTRF project specialization (" + abstractProject.SpecialityID.ToString() + " ) cannot be set. " + ex.Message, ErrorLevels.Error);
                    }

                    try
                    {
                        XTRF_SetClientContact xscc = new XTRF_SetClientContact();
                        xscc.primaryId = Convert.ToInt32(MappingManager.DoMappingToUplinkCustomValues(MapType.Contact, link, abstractProject.ExternalProjectManagerName));
                        response       = await client.PutAsJsonAsync("v2/projects/" + newXTRFProjectID + "/clientContacts", xscc);
                    }
                    catch (Exception ex)
                    {
                        Log.AddLog("XTRF project client PM (" + abstractProject.ExternalProjectManagerName + " ) cannot be set. " + ex.Message, ErrorLevels.Error);
                    }

                    XTRF_SetValue  xsv = new XTRF_SetValue();
                    DateTimeOffset dto;

                    try
                    {
                        dto       = new DateTimeOffset(abstractProject.Deadline);
                        xsv.value = dto.ToUnixTimeMilliseconds().ToString();
                        response  = await client.PutAsJsonAsync("v2/projects/" + newXTRFProjectID + "/clientDeadline", xsv);
                    }
                    catch (Exception ex)
                    {
                        Log.AddLog("XTRF project deadline (" + abstractProject.Deadline.ToString() + " ) cannot be set. " + ex.Message, ErrorLevels.Error);
                    }

                    try
                    {
                        dto       = new DateTimeOffset(abstractProject.DateOrdered);
                        xsv.value = dto.ToUnixTimeMilliseconds().ToString();
                        response  = await client.PutAsJsonAsync("v2/projects/" + newXTRFProjectID + "/orderDate", xsv);
                    }
                    catch (Exception ex)
                    {
                        Log.AddLog("XTRF project order date (" + abstractProject.DateOrdered.ToString() + " ) cannot be set. " + ex.Message, ErrorLevels.Error);
                    }

                    try
                    {
                        xsv.value = abstractProject.ClientNotes;
                        response  = await client.PutAsJsonAsync("v2/projects/" + newXTRFProjectID + "/clientNotes", xsv);
                    }
                    catch (Exception ex)
                    {
                        Log.AddLog("XTRF project client notes (" + abstractProject.ClientNotes + " ) cannot be set. " + ex.Message, ErrorLevels.Error);
                    }

                    try
                    {
                        xsv.value = abstractProject.ExternalProjectCode;
                        response  = await client.PutAsJsonAsync("v2/projects/" + newXTRFProjectID + "/clientReferenceNumber", xsv);
                    }
                    catch (Exception ex)
                    {
                        Log.AddLog("XTRF project client reference number (" + abstractProject.ExternalProjectCode + " ) cannot be set. " + ex.Message, ErrorLevels.Error);
                    }

                    try
                    {
                        xsv.value = abstractProject.PMNotes;
                        response  = await client.PutAsJsonAsync("v2/projects/" + newXTRFProjectID + "/internalNotes", xsv);
                    }
                    catch (Exception ex)
                    {
                        Log.AddLog("XTRF project PM notes (" + abstractProject.PMNotes + " ) cannot be set. " + ex.Message, ErrorLevels.Error);
                    }

                    try
                    {
                        xsv.value = abstractProject.VendorNotes;
                        response  = await client.PutAsJsonAsync("v2/projects/" + newXTRFProjectID + "/vendorInstructions", xsv);
                    }
                    catch (Exception ex)
                    {
                        Log.AddLog("XTRF project vendor instructions (" + abstractProject.VendorNotes + " ) cannot be set. " + ex.Message, ErrorLevels.Error);
                    }

                    try
                    {
                        xsv.value = abstractProject.PayableVolume.ToString();
                        response  = await client.PutAsJsonAsync("v2/projects/" + newXTRFProjectID + "/volume", xsv);
                    }
                    catch (Exception ex)
                    {
                        Log.AddLog("XTRF project volume (" + abstractProject.PayableVolume.ToString() + " ) cannot be set. " + ex.Message, ErrorLevels.Error);
                    }

                    try
                    {
                        try
                        {
                            xsv.value = "";

                            foreach (var analysisCategory in abstractProject.AnalysisCategories)
                            {
                                if (xsv.value != "")
                                {
                                    xsv.value += "¤";
                                }
                                xsv.value += ((analysisCategory.StartPc == -1) ? "Rep" : ("F" + analysisCategory.StartPc)) + ";"
                                             + analysisCategory.WordCount + ";" + analysisCategory.Weight;
                            }
                            response = await client.PutAsJsonAsync("v2/projects/" + newXTRFProjectID + "/customFields/BeLazyField", xsv);
                        }
                        catch (Exception ex)
                        {
                            throw new Exception("XTRF project custom field cannot be set. " + ex.Message);
                        }

                        // Hard coded IDs for PoC purposes
                        int viewID = 0, macroID = 0;
                        switch (link.linkID)
                        {
                        case 1:
                            viewID  = 62;
                            macroID = 4;
                            break;

                        case 2:
                            viewID  = 62;
                            macroID = 9;
                            break;

                        default:
                            break;
                        }
                        // End of hard coded values


                        response = await client.GetAsync("browser?viewId=" + viewID + "&q.idNumber=" + newXTRFProjectIDCode);

                        response.EnsureSuccessStatusCode();
                        string projectList = await response.Content.ReadAsStringAsync();

                        Regex internalProjectIDMatcher = new Regex(@"(?<=\s*""rows""\s*:\s*{\s*""\d+""\s*:\s*{\s*""id""\s*:\s*)(\d+)(?=,)");
                        if (internalProjectIDMatcher.IsMatch(projectList))
                        {
                            int           internalProjectID = Convert.ToInt32(internalProjectIDMatcher.Match(projectList).Value);
                            XTRF_RunMacro xrm = new XTRF_RunMacro();
                            xrm.ids.Add(internalProjectID);
                            response = await client.PostAsJsonAsync("macros/" + macroID + "/run", xrm);

                            string akarmi = await response.Content.ReadAsStringAsync();
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.AddLog("XTRF project macro cannot be run." + ex.Message, ErrorLevels.Error);
                    }
                }
                catch (Exception ex)
                {
                    Log.AddLog("Error while creating XTRF project. " + ex.Message, ErrorLevels.Error);
                }
            }

            return(true);
        }
        private void MapProject(TransactProjectList tp, ref List <AbstractProject> abstractProjects)
        {
            foreach (TransactProject transactProject in tp.data)
            {
                try
                {
                    AbstractProject abstractProject = new AbstractProject();

                    if (!String.IsNullOrEmpty(transactProject.number))
                    {
                        abstractProject.ExternalProjectCode = transactProject.number;
                    }

                    if (!String.IsNullOrEmpty(transactProject.status))
                    {
                        switch (transactProject.status)
                        {
                        case "Not confirmed":
                            abstractProject.Status = ProjectStatus.New;
                            break;

                        case "Confirmed":
                            abstractProject.Status = ProjectStatus.InProgress;
                            break;

                        case "Quality check started":
                            abstractProject.Status = ProjectStatus.QAinProgress;
                            break;

                        case "Invoiceable":
                            abstractProject.Status = ProjectStatus.Completed;
                            break;

                        case "Invoiced":
                            abstractProject.Status = ProjectStatus.Closed;
                            break;

                        case "Cancelled":
                            abstractProject.Status = ProjectStatus.Cancelled;
                            break;

                        case "Denied bill acceptance":
                            abstractProject.Status = ProjectStatus.Completed;
                            break;

                        case "Completeness check started":
                            abstractProject.Status = ProjectStatus.Completed;
                            break;

                        default:
                            abstractProject.Status = ProjectStatus.Undefined;
                            break;
                        }
                    }

                    if (abstractProject.Status == ProjectStatus.Undefined)
                    {
                        if (!unmappedStatuses.Contains(transactProject.status))
                        {
                            unmappedStatuses.Add(transactProject.status);
                        }
                    }

                    if (!String.IsNullOrEmpty(transactProject.your_processing_number))
                    {
                        abstractProject.InternalProjectCode = transactProject.your_processing_number;
                    }

                    DateTime tempDT = DateTime.MinValue;

                    if (DateTime.TryParse(transactProject.date_ordered, out tempDT))
                    {
                        abstractProject.DateOrdered = tempDT;
                    }
                    else
                    {
                        abstractProject.DateOrdered = DateTime.Now;
                    }

                    if (DateTime.TryParse(transactProject.date_confirmed, out tempDT))
                    {
                        abstractProject.DateApproved = tempDT;
                    }
                    else
                    {
                        abstractProject.DateApproved = DateTime.Now;
                    }

                    if (DateTime.TryParse(transactProject.date_delivery, out tempDT))
                    {
                        abstractProject.Deadline = tempDT;
                    }
                    else
                    {
                        abstractProject.Deadline = DateTime.Now;
                        Log.AddLog("Deadline could not be parsed.", ErrorLevels.Error);
                    }

                    if (!String.IsNullOrEmpty(transactProject.project_coordinator))
                    {
                        abstractProject.ExternalProjectManagerName = transactProject.project_coordinator;
                    }

                    if (!String.IsNullOrEmpty(transactProject.project_coordinator_mail))
                    {
                        abstractProject.ExternalProjectManagerEmail = transactProject.project_coordinator_mail;
                    }

                    if (!String.IsNullOrEmpty(transactProject.project_coordinator_phone))
                    {
                        abstractProject.ExternalProjectManagerPhone = transactProject.project_coordinator_phone;
                    }

                    if (!String.IsNullOrEmpty(transactProject.end_customer))
                    {
                        abstractProject.EndCustomer = transactProject.end_customer;
                    }

                    if (!String.IsNullOrEmpty(transactProject.specialty))
                    {
                        try
                        {
                            abstractProject.SpecialityID = MappingManager.DoMappingToAbstract(MapType.Speciality, link.DownlinkBTMSSystemTypeID, transactProject.specialty);
                        }
                        catch (Exception ex)
                        {
                            if (!unmappedSpecialities.Contains(transactProject.specialty))
                            {
                                unmappedSpecialities.Add(transactProject.specialty);
                            }
                        }
                    }

                    if (!String.IsNullOrEmpty(transactProject.language_source))
                    {
                        try
                        {
                            abstractProject.SourceLanguageID = MappingManager.DoMappingToAbstract(MapType.Language, link.DownlinkBTMSSystemTypeID, transactProject.language_source);
                        }
                        catch (Exception ex)
                        {
                            if (!unmappedLanguages.Contains(transactProject.language_source))
                            {
                                unmappedLanguages.Add(transactProject.language_source);
                            }
                        }
                    }

                    if (!String.IsNullOrEmpty(transactProject.language_target))
                    {
                        try
                        {
                            abstractProject.TargetLanguageIDs.Add(MappingManager.DoMappingToAbstract(MapType.Language, link.DownlinkBTMSSystemTypeID, transactProject.language_target));
                        }
                        catch (Exception ex)
                        {
                            if (!unmappedLanguages.Contains(transactProject.language_target))
                            {
                                unmappedLanguages.Add(transactProject.language_target);
                            }
                        }
                    }

                    abstractProject.Workflow = "";
                    foreach (string to_do_item in transactProject.to_do)
                    {
                        if (abstractProject.Workflow == "")
                        {
                            abstractProject.Workflow += to_do_item;
                        }
                        else
                        {
                            abstractProject.Workflow += "¤" + to_do_item;
                        }
                    }

                    if (!String.IsNullOrEmpty(transactProject.system))
                    {
                        abstractProject.CATTool = transactProject.system;
                    }

                    Regex analysisLineMatcher = new Regex(@"^\s*(?<category>[\p{L}\d\s%-]+):\s*(?<wordcount>[\d,\.]+)\s*Words at\s*(?<weight>[\d\.]+)%;\s*$");

                    foreach (string analysisLine in transactProject.scaling)
                    {
                        if (analysisLineMatcher.IsMatch(analysisLine))
                        {
                            Match analysisLineParser   = analysisLineMatcher.Match(analysisLine);
                            WordCountAnalysisItem wcai = new WordCountAnalysisItem();

                            wcai.Weight    = Double.Parse(analysisLineParser.Groups["weight"].ToString());
                            wcai.WordCount = Double.Parse(analysisLineParser.Groups["wordcount"].ToString().Replace(",", ""));   // value can be 1,319 => 1319
                            string category = analysisLineParser.Groups["category"].ToString();

                            switch (category)
                            {
                            case "Repetitions":
                                wcai.StartPc = -1;
                                wcai.EndPc   = -1;
                                break;

                            case "100%":
                                wcai.StartPc = 100;
                                wcai.EndPc   = 100;
                                break;

                            case "No Match":
                                wcai.StartPc = 0;
                                wcai.EndPc   = 0;
                                break;

                            default:
                                Regex pcCategoryMatcher = new Regex(@"^\s*(?<startPc>\d+)%\s*-\s*(?<endPc>\d+)%\s*$");
                                if (pcCategoryMatcher.IsMatch(category))
                                {
                                    Match pcParser = pcCategoryMatcher.Match(category);
                                    wcai.StartPc = int.Parse(pcParser.Groups["startPc"].ToString());
                                    wcai.EndPc   = int.Parse(pcParser.Groups["endPc"].ToString());
                                }
                                break;
                            }

                            abstractProject.AnalysisCategories.Add(wcai);
                        }
                    }


                    double payableVolume = 0.0, priceTotal = 0.0, priceUnit = 0.0;

                    if (double.TryParse(transactProject.quantity, System.Globalization.NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out payableVolume))
                    {
                        abstractProject.PayableVolume = payableVolume;
                    }
                    else
                    {
                        abstractProject.PayableVolume = 0;
                    }

                    if (double.TryParse(transactProject.price_unit, System.Globalization.NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out priceUnit))
                    {
                        abstractProject.PriceUnit = priceUnit;
                    }
                    else
                    {
                        abstractProject.PriceUnit = 0;
                    }

                    if (double.TryParse(transactProject.prize_total, System.Globalization.NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out priceTotal))
                    {
                        abstractProject.PriceTotal = priceTotal;
                    }
                    else
                    {
                        abstractProject.PriceTotal = 0;
                    }

                    if (!String.IsNullOrEmpty(transactProject.quantity_unit))
                    {
                        try
                        {
                            abstractProject.PayableUnitID = MappingManager.DoMappingToAbstract(MapType.Unit, link.DownlinkBTMSSystemTypeID, transactProject.quantity_unit);
                        }
                        catch (Exception ex)
                        {
                            if (!unmappedUnits.Contains(transactProject.quantity_unit))
                            {
                                unmappedUnits.Add(transactProject.quantity_unit);
                            }
                        }
                    }

                    if (!String.IsNullOrEmpty(transactProject.instructions))
                    {
                        abstractProject.VendorNotes = transactProject.instructions;
                    }

                    if (!String.IsNullOrEmpty(transactProject.customer_check_criteria))
                    {
                        abstractProject.PMNotes = transactProject.customer_check_criteria;
                    }

                    if (transactProject.feedback_deliveries.Count > 0 && !String.IsNullOrEmpty(transactProject.feedback_deliveries[0].link_download))
                    {
                        abstractProject.ClientNotes = transactProject.feedback_deliveries[0].link_download;
                    }

                    abstractProjects.Add(abstractProject);
                }
                catch (Exception ex)
                {
                    Log.AddLog("Processing Transact project failed:" + ex.Message, ErrorLevels.Error);
                }
            }
        }
        internal async Task GenerateReport()
        {
            string clientID = link.ClientIDForUplinkProject;

            List <string> checkMappingWorkflows    = new List <string>();
            List <string> checkMappingLanguages    = new List <string>();
            List <string> checkMappingSpecialities = new List <string>();
            List <string> checkMappingPMs          = new List <string>();

            foreach (AbstractProject abstractProject in projects)
            {
                try
                {
                    string value = MappingManager.GetScriptedValue(link, MapType.Workflow, abstractProject);
                    if (!checkMappingWorkflows.Contains(value))
                    {
                        checkMappingWorkflows.Add(value);
                    }

                    if (!checkMappingLanguages.Contains(abstractProject.SourceLanguageID.ToString()))
                    {
                        checkMappingLanguages.Add(abstractProject.SourceLanguageID.ToString());
                    }

                    foreach (int languageID in abstractProject.TargetLanguageIDs)
                    {
                        if (!checkMappingLanguages.Contains(languageID.ToString()))
                        {
                            checkMappingLanguages.Add(languageID.ToString());
                        }
                    }

                    if (!checkMappingSpecialities.Contains(abstractProject.SpecialityID.ToString()))
                    {
                        checkMappingSpecialities.Add(abstractProject.SpecialityID.ToString());
                    }

                    if (!checkMappingPMs.Contains(abstractProject.ExternalProjectManagerName))
                    {
                        checkMappingPMs.Add(abstractProject.ExternalProjectManagerName);
                    }
                }
                catch (Exception ex)
                {
                    Log.AddLog("Mapping check for XTRF failed for project: " + abstractProject.ExternalProjectCode, ErrorLevels.Error);
                }
            }

            Log.AddLog("XTRF uplink onboarding succesfully processed abstract projects", ErrorLevels.Information);

            Dictionary <string, string> checkXTRFValuesWorkflows    = new Dictionary <string, string>();
            Dictionary <string, string> checkXTRFValuesLanguages    = new Dictionary <string, string>();
            Dictionary <string, string> checkXTRFValuesPMs          = new Dictionary <string, string>();
            Dictionary <string, string> checkXTRFValuesSpecialities = new Dictionary <string, string>();

            foreach (var wfItem in checkMappingWorkflows)
            {
                try
                {
                    string value = MappingManager.DoMappingToUplinkCustomValues(MapType.Workflow, link, wfItem);
                    if (!checkXTRFValuesWorkflows.ContainsKey(value))
                    {
                        checkXTRFValuesWorkflows.Add(value, wfItem);
                    }
                }
                catch (Exception ex)
                {
                    if (!unmappedWorkflows.Contains(wfItem))
                    {
                        unmappedWorkflows.Add(wfItem);
                    }
                }
            }

            foreach (var langItem in checkMappingLanguages)
            {
                try
                {
                    string value = MappingManager.DoMappingToUplinkGeneral(MapType.Language, link.UplinkBTMSSystemTypeID, langItem).ToString();
                    if (!checkXTRFValuesLanguages.ContainsKey(value))
                    {
                        checkXTRFValuesLanguages.Add(value, langItem);
                    }
                }
                catch (Exception ex)
                {
                    if (!unmappedLanguages.Contains(langItem))
                    {
                        unmappedLanguages.Add(langItem);
                    }
                }
            }

            foreach (var spItem in checkMappingSpecialities)
            {
                try
                {
                    string value = MappingManager.DoMappingToUplinkGeneral(MapType.Speciality, link.UplinkBTMSSystemTypeID, spItem).ToString();
                    if (!checkXTRFValuesSpecialities.ContainsKey(value))
                    {
                        checkXTRFValuesSpecialities.Add(value, spItem);
                    }
                }
                catch (Exception ex)
                {
                    if (!unmappedSpecialities.Contains(spItem))
                    {
                        unmappedSpecialities.Add(spItem);
                    }
                }
            }

            foreach (var pmItem in checkMappingPMs)
            {
                try
                {
                    string value = MappingManager.DoMappingToUplinkCustomValues(MapType.Contact, link, pmItem);
                    if (!checkXTRFValuesPMs.ContainsKey(value))
                    {
                        checkXTRFValuesPMs.Add(value, pmItem);
                    }
                }
                catch (Exception ex)
                {
                    if (!unmappedPMs.Contains(pmItem))
                    {
                        unmappedPMs.Add(pmItem);
                    }
                }
            }

            Log.AddLog("XTRF uplink onbboarding - SQL mapping check succesful.", ErrorLevels.Information);

            HttpResponseMessage response;

            try
            {
                response = await client.GetAsync("dictionaries/language/active");

                response.EnsureSuccessStatusCode();
                string xllJson = await response.Content.ReadAsStringAsync();

                List <XTRF_Language> xllObj          = JsonConvert.DeserializeObject <List <XTRF_Language> >(xllJson);
                List <int>           activeXTRFLangs = xllObj.Select(x => x.id).ToList();

                foreach (string languageItem in checkXTRFValuesLanguages.Keys)
                {
                    if (!activeXTRFLangs.Contains(Convert.ToInt32(languageItem)))
                    {
                        unmappedLanguages.Add(checkXTRFValuesLanguages[languageItem] + " - " + languageItem);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.AddLog("Error processing XTRF language mappings. " + ex.Message, ErrorLevels.Error);
            }

            try
            {
                response = await client.GetAsync("dictionaries/specialization/active");

                response.EnsureSuccessStatusCode();
                string xslJson = await response.Content.ReadAsStringAsync();

                List <XTRF_DictionaryItem> xslObj    = JsonConvert.DeserializeObject <List <XTRF_DictionaryItem> >(xslJson);
                List <int> activeXTRFSpecializations = xslObj.Select(x => x.id).ToList();

                foreach (string specializationItem in checkXTRFValuesSpecialities.Keys)
                {
                    if (!activeXTRFSpecializations.Contains(Convert.ToInt32(specializationItem)))
                    {
                        unmappedSpecialities.Add(checkXTRFValuesSpecialities[specializationItem] + " - " + specializationItem);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.AddLog("Error processing XTRF specialization mappings. " + ex.Message, ErrorLevels.Error);
            }

            try
            {
                response = await client.GetAsync("services/active");

                response.EnsureSuccessStatusCode();
                string xservlJson = await response.Content.ReadAsStringAsync();

                List <XTRF_DictionaryItem> xservlObj = JsonConvert.DeserializeObject <List <XTRF_DictionaryItem> >(xservlJson);
                List <int> activeXTRFServices        = xservlObj.Select(x => x.id).ToList();

                foreach (string serviceItem in checkXTRFValuesWorkflows.Keys)
                {
                    if (!activeXTRFServices.Contains(Convert.ToInt32(serviceItem)))
                    {
                        unmappedWorkflows.Add(checkXTRFValuesWorkflows[serviceItem] + " - " + serviceItem);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.AddLog("Error processing XTRF services (workflow) mappings. " + ex.Message, ErrorLevels.Error);
            }

            try
            {
                foreach (var contactID in checkXTRFValuesPMs.Keys)
                {
                    try
                    {
                        response = await client.GetAsync("customers/persons/" + contactID);

                        response.EnsureSuccessStatusCode();
                        string xcJson = await response.Content.ReadAsStringAsync();

                        XTRF_Contact xc = JsonConvert.DeserializeObject <XTRF_Contact>(xcJson);
                        if (xc.customerId.ToString() != clientID)
                        {
                            unmappedPMs.Add(checkXTRFValuesPMs[contactID] + " - " + contactID);
                        }
                    }
                    catch (Exception ex)
                    {
                        unmappedPMs.Add(checkXTRFValuesPMs[contactID] + " - " + contactID);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.AddLog("Error processing XTRF client PM mappings. " + ex.Message, ErrorLevels.Error);
            }

            Log.AddLog("Generating output for XTRF uplink onboarding.", ErrorLevels.Information);
            GenerateOutput();
        }