Esempio n. 1
0
    // Chiama API RAGIC e popola gli attributi del modello Curriculum
    public bool BuildFromRagicAPI(string RagidId, string Language)
    {
        bool ret;

        // imposta la lingua del CV, gestito Inglese ed Italiano
        if (Language == "EN" || Language == "IT")
        {
            CVLanguage = Language;
        }
        else
        {
            CVLanguage = "EN";
        }

        // ** RestClient da pacchetto nuget RestSharp
        var client = new RestClient(ConfigurationManager.AppSettings["RAGICURL"]);

        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

        var request = new RestRequest(ConfigurationManager.AppSettings["APIURL"] + RagidId, Method.GET);

        //request.AddParameter("subtables", "0");
        request.AddParameter("api", "1");
        request.AddParameter("Authorization", ConfigurationManager.AppSettings["APIKEY"], ParameterType.HttpHeader);

        var response = client.Execute(request);

        // converte la stringa nel modello dati
        RagicModel model = JsonConvert.DeserializeObject <RagicModel>(response.Content);

        // popola i valori dal modello dati Ragic
        ret = MapRagiIntoObject(model);
        return(ret);
    }
Esempio n. 2
0
    // Popola l'oggetto Curriculum dal modello dati tornato dalla API RAGIC (www.ragic.com)
    private bool MapRagiIntoObject(RagicModel model)
    {
        The0 rec = new The0(); // The0 rappresenta la struttura del record tornato dalla API

        try
        {
            // valorizza rec
            foreach (KeyValuePair <string, The0> pair in model)
            {
                rec = pair.Value;
            }

            // Header
            Name    = rec.Name;
            Surname = rec.Surname;
            Level   = rec.Level;
            // formatta HireData
            HireDate    = (rec.HireDate != null && rec.HireDate != "") ? HireDate = rec.HireDate.Substring(8, 2) + "/" + rec.HireDate.Substring(5, 2) + "/" + rec.HireDate.Substring(0, 4) : "";
            Summary     = rec.Summary;
            LastUpdated = rec.LastUpdated;

            // Education
            if (rec.Subtable1000040 != null)
            {
                foreach (KeyValuePair <string, Subtable1000040> EduRecord in rec.Subtable1000040)
                {
                    EducationList.Add(new EducationSet()
                    {
                        //EducationId = FormatField(EduRecord.Value.EducationId),
                        SortString = FormatField(EduRecord.Value.Year).ToString(),
                        Title      = EduRecord.Value.Title ?? "",
                        Year       = EduRecord.Value.Year ?? "",
                        School     = EduRecord.Value.School ?? ""
                                     //Comment = EduRecord.Value.Comment ?? ""
                    });
                }
            }

            // Certificate
            if (rec.Subtable1000041 != null)
            {
                foreach (KeyValuePair <string, Subtable1000041> CertRecord in rec.Subtable1000041)
                {
                    CertificateList.Add(new CertificateSet()
                    {
                        //CertificateId = FormatField(CertRecord.Value.CertificateId),
                        SortString  = FormatField(CertRecord.Value.Year).ToString(),
                        Certificate = FormatField(CertRecord.Value.Certificate),
                        Institute   = FormatField(CertRecord.Value.Institute),
                        Year        = FormatField(CertRecord.Value.Year)
                                      //Comment = FormatField(CertRecord.Value.Comment)
                    });
                }
            }

            // Language
            if (rec.Subtable1000027 != null)
            {
                foreach (KeyValuePair <string, Subtable1000027> LangRecord in rec.Subtable1000027)
                {
                    LanguageList.Add(new LanguageSet()
                    {
                        LanguageName  = LangRecord.Value.LanguageName ?? "",
                        LanguageLevel = LangRecord.Value.LanguageLevel ?? ""
                                        //Comment = LangRecord.Value.Comment ?? ""
                    });
                }
            }

            // Skill
            if (rec.Subtable1000042 != null)
            {
                foreach (KeyValuePair <string, Subtable1000042> SkillRecord in rec.Subtable1000042)
                {
                    SkillList.Add(new SkillSet()
                    {
                        Area             = FormatField(SkillRecord.Value.Area),
                        SkillDescription = FormatField(SkillRecord.Value.SkillDescription)
                                           //Comment = FormatField(SkillRecord.Value.Comment)
                    });
                }
            }

            // Project
            if (rec.Subtable1000061 != null)
            {
                foreach (KeyValuePair <string, Subtable1000061> PrjRecord in rec.Subtable1000061)
                {
                    ProjectList.Add(new ProjectSet()
                    {
                        //ProjectId = FormatField(PrjRecord.Value.ProjectId).ToString().PadLeft(6,'0'),
                        SortString         = FormatField(PrjRecord.Value.Year).ToString(),
                        Client             = FormatField(PrjRecord.Value.Client),
                        Industry           = FormatField(PrjRecord.Value.Industry),
                        Year               = FormatField(PrjRecord.Value.Year),
                        ProjectName        = FormatField(PrjRecord.Value.ProjectName),
                        ProjectDescription = FormatField(PrjRecord.Value.ProjectDescription),
                        Role               = FormatField(PrjRecord.Value.Role),
                        JobDescription     = FormatField(PrjRecord.Value.JobDescription)
                    });
                }
            }

            return(true);
        }
        catch
        {
            return(false);
        }
    }