public async Task <ActionResult> GetTrainingBySkillCompetencyId(int SkillId, int CompetencyId)
        {
            InitializeServiceClient();
            List <SelectListItem> trainings = new List <SelectListItem>();

            try
            {
                UserTrainingsRequest utr = new UserTrainingsRequest();
                utr.SkillId      = SkillId;
                utr.CompetenceId = CompetencyId;
                HttpResponseMessage responseMessage = await client.PostAsJsonAsync("Training/GetTrainings", utr);

                List <Training> traininglist = await responseMessage.Content.ReadAsAsync <List <Training> >();

                traininglist.ForEach(x =>
                {
                    trainings.Add(new SelectListItem {
                        Text = x.TrainingName, Value = x.TrainingId.ToString()
                    });
                }
                                     );
            }
            catch (Exception ex)
            {
                //LogHelper.AddLog("AssessmentMasterController", ex.Message, ex.StackTrace, "HCL.Academy.Web", user.EmailID);
                TelemetryClient telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
            }
            return(Json(trainings, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public List <Training> GetTrainings(UserTrainingsRequest trainingPreReq)
        {
            List <Training> trainings = new List <Training>();

            try
            {
                SqlSvrDAL dal = new SqlSvrDAL(trainingPreReq.ClientInfo);
                trainings = dal.GetTrainings(trainingPreReq.SkillId, trainingPreReq.CompetenceId);
            }
            catch (Exception ex)
            {
                //LogHelper.AddLog("TrainingController,GetTrainings", ex.Message, ex.StackTrace, "HCL.Academy.Service", trainingPreReq.ClientInfo.emailId);
                TelemetryClient telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
            }
            return(trainings);
        }
Ejemplo n.º 3
0
        public TrainingReport GetTrainingsReport(UserTrainingsRequest preRquisiteInfo)
        {
            TrainingReport trainingReport = new TrainingReport();

            try
            {
                SqlSvrDAL dal = new SqlSvrDAL(preRquisiteInfo.ClientInfo);
                trainingReport = dal.GetTrainingsReport(preRquisiteInfo.SkillId, preRquisiteInfo.CompetenceId, preRquisiteInfo.ProjectId);
            }
            catch (Exception ex)
            {
                // LogHelper.AddLog("TrainingController,GetTrainingsReport", ex.Message, ex.StackTrace, "HCL.Academy.Service", preRquisiteInfo.ClientInfo.emailId);
                TelemetryClient telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
            }
            return(trainingReport);
        }
Ejemplo n.º 4
0
        public async Task <JsonResult> GetTrainingsReport(string skillid, string competencyid, string projectid)
        {
            InitializeServiceClient();
            UserTrainingsRequest preRquisiteInfo = new UserTrainingsRequest();

            preRquisiteInfo.ClientInfo   = req.ClientInfo;
            preRquisiteInfo.SkillId      = Convert.ToInt32(skillid);
            preRquisiteInfo.ProjectId    = Convert.ToInt32(projectid);
            preRquisiteInfo.CompetenceId = Convert.ToInt32(competencyid);
            HttpResponseMessage trainingResponse = await client.PostAsJsonAsync("Training/GetTrainingsReport", preRquisiteInfo);

            TrainingReport usersList = await trainingResponse.Content.ReadAsAsync <TrainingReport>();

            return(new JsonResult {
                Data = usersList
            });
        }
        public async Task <ActionResult> Edit(int AssessmentId, int SelSkillId, string SelectedSkill, int SelCompetencyId, int?SelTrainingId)
        {
            InitializeServiceClient();
            AssessmentMaster am = new AssessmentMaster();

            am.SelSkillId    = SelSkillId;
            am.SelTrainingId = SelTrainingId;
            am.SelTrainingId = SelTrainingId;
            List <Skill>      skilllist      = new List <Skill>();
            List <Competence> competencelist = new List <Competence>();

            try
            {
                HttpResponseMessage response = await client.PostAsJsonAsync("AssessmentMaster/GetAssessmentById?id=" + AssessmentId, req);

                am = await response.Content.ReadAsAsync <AssessmentMaster>();

                response = await client.PostAsJsonAsync("Skill/GetAllSkills", req);

                skilllist = await response.Content.ReadAsAsync <List <Skill> >();

                am.Skills = skilllist;

                response = await client.PostAsJsonAsync("Competency/GetCompetenciesBySkillName?skillName=" + SelectedSkill, req);

                competencelist = await response.Content.ReadAsAsync <List <Competence> >();

                am.Competencies = competencelist;

                UserTrainingsRequest utr = new UserTrainingsRequest();
                utr.SkillId      = SelSkillId;
                utr.CompetenceId = SelCompetencyId;
                HttpResponseMessage responseMessage = await client.PostAsJsonAsync("Training/GetTrainings", utr);

                List <Training> traininglist = await responseMessage.Content.ReadAsAsync <List <Training> >();

                am.Trainings = traininglist;
            }
            catch (Exception ex)
            {
                //LogHelper.AddLog("AssessmentMasterController", ex.Message, ex.StackTrace, "HCL.Academy.Web", user.EmailID);
                TelemetryClient telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
            }
            return(View(am));
        }
Ejemplo n.º 6
0
        public async Task <FileResult> DownloadReportToExcel(string skill, string competency, string projectId)
        {
            ExcelPackage excel     = new ExcelPackage();
            var          workSheet = excel.Workbook.Worksheets.Add("Sheet1");

            workSheet.TabColor         = System.Drawing.Color.Black;
            workSheet.DefaultRowHeight = 12;
            InitializeServiceClient();
            UserTrainingsRequest trainingPreReq = new UserTrainingsRequest();

            trainingPreReq.ClientInfo   = req.ClientInfo;
            trainingPreReq.CompetenceId = Convert.ToInt32(competency);
            trainingPreReq.SkillId      = Convert.ToInt32(skill);
            trainingPreReq.ProjectId    = Convert.ToInt32(projectId);
            HttpResponseMessage trainingResponse = await client.PostAsJsonAsync("Training/GetTrainings", trainingPreReq);

            List <Training> SkillBasedTrainings = await trainingResponse.Content.ReadAsAsync <List <Training> >();

            int k = 3;

            try
            {
                if (SkillBasedTrainings.Count > 0)
                {
                    workSheet.Row(1).Height = 40;
                    workSheet.Row(1).Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                    workSheet.Row(1).Style.VerticalAlignment   = ExcelVerticalAlignment.Top;
                    workSheet.Row(1).Style.Fill.PatternType    = ExcelFillStyle.Solid;
                    workSheet.Row(1).Style.Font.Bold           = true;
                    workSheet.Row(1).Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.SkyBlue);
                    workSheet.Row(2).Style.VerticalAlignment = ExcelVerticalAlignment.Top;
                    workSheet.Row(3).Style.VerticalAlignment = ExcelVerticalAlignment.Top;
                    workSheet.Cells[1, 1].Value           = "Training Name";
                    workSheet.Cells[2, 1].Value           = "Training Completed";
                    workSheet.Cells[2, 1].Style.Font.Bold = true;
                    workSheet.Cells[3, 1].Value           = "Training Not Completed";
                    workSheet.Cells[3, 1].Style.Font.Bold = true;
                    workSheet.Column(1).Width             = 28;

                    for (int i = 0; i < SkillBasedTrainings.Count; i++)
                    {
                        workSheet.Column(i + 2).Width          = 50;
                        workSheet.Column(i + 2).Style.WrapText = true;
                        workSheet.Cells[1, i + 2].Value        = SkillBasedTrainings[i].TrainingName;
                        k = 2;
                        InitializeServiceClient();
                        HttpResponseMessage userResponse = await client.PostAsJsonAsync("Training/GetUserTrainingsByTrainingID?trainingId=" + SkillBasedTrainings[i].TrainingId + "&projectId=" + projectId, req);

                        List <UserTraining> userTrainings = await userResponse.Content.ReadAsAsync <List <UserTraining> >();

                        if (userTrainings != null & userTrainings.Count > 0)
                        {
                            StringBuilder completedUserList = new StringBuilder();
                            StringBuilder wipUserList       = new StringBuilder();

                            foreach (UserTraining userTraining in userTrainings)
                            {
                                if (userTraining.IsTrainingCompleted)
                                {
                                    completedUserList.Append(userTraining.Employee);
                                    completedUserList.Append(";");
                                }
                                else
                                {
                                    wipUserList.Append(userTraining.Employee);
                                    wipUserList.Append(";");
                                }
                            }
                            workSheet.Cells[k, i + 2].Value = completedUserList.ToString();
                            k = k + 1;
                            workSheet.Cells[k, i + 2].Value = wipUserList.ToString();
                        }
                    }
                }
                ////////////Get Assessments for the skill and competency level//////////
                SkillwiseAssessmentsRequest request = new SkillwiseAssessmentsRequest();
                request.ClientInfo   = req.ClientInfo;
                request.SkillId      = Convert.ToInt32(skill);
                request.CompetenceId = Convert.ToInt32(competency);

                HttpResponseMessage response = await client.PostAsJsonAsync("Assessment/GetAssessments", request);

                List <Assessment> SkillBasedAssessments = await response.Content.ReadAsAsync <List <Assessment> >();

                if (SkillBasedAssessments.Count > 0)
                {
                    k = k + 3;
                    workSheet.Row(k).Height = 40;
                    workSheet.Row(k).Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                    workSheet.Row(k).Style.Fill.PatternType    = ExcelFillStyle.Solid;
                    workSheet.Row(k).Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.SkyBlue);
                    workSheet.Row(k).Style.Font.Bold             = true;
                    workSheet.Row(k).Style.VerticalAlignment     = ExcelVerticalAlignment.Top;
                    workSheet.Row(k + 1).Style.VerticalAlignment = ExcelVerticalAlignment.Top;
                    workSheet.Row(k + 2).Style.VerticalAlignment = ExcelVerticalAlignment.Top;
                    workSheet.Cells[k, 1].Value               = "Assessment Name";
                    workSheet.Cells[k + 1, 1].Value           = "Assessment Completed";
                    workSheet.Cells[k + 1, 1].Style.Font.Bold = true;
                    workSheet.Cells[k + 2, 1].Value           = "Assessment Not Completed";
                    workSheet.Cells[k + 2, 1].Style.Font.Bold = true;

                    for (int i = 0; i < SkillBasedAssessments.Count; i++)
                    {
                        workSheet.Cells[k, i + 2].Value = SkillBasedAssessments[i].AssessmentName;
                        HttpResponseMessage assessmentResponse = await client.PostAsJsonAsync("Assessment/GetUserAssessmentsByAssessmentId?assessmentId=" + SkillBasedAssessments[i].AssessmentId + "&projectId=" + projectId, request);

                        List <UserAssessment> userAssessments = await assessmentResponse.Content.ReadAsAsync <List <UserAssessment> >();

                        string userlist = String.Empty;
                        if (userAssessments != null & userAssessments.Count > 0)
                        {
                            StringBuilder completedAssmtUserList = new StringBuilder();
                            StringBuilder wipAssmtUserList       = new StringBuilder();
                            foreach (UserAssessment userAssessment in userAssessments)
                            {
                                if (userAssessment.IsAssessmentComplete)
                                {
                                    completedAssmtUserList.Append(userAssessment.Employee);
                                    completedAssmtUserList.Append(";");
                                }
                                else
                                {
                                    wipAssmtUserList.Append(userAssessment.Employee);
                                    wipAssmtUserList.Append(";");
                                }
                            }
                            workSheet.Cells[k + 1, i + 2].Value = completedAssmtUserList.ToString();
                            workSheet.Cells[k + 2, i + 2].Value = wipAssmtUserList.ToString();
                        }
                    }
                }
                string clientName = ConfigurationManager.AppSettings["ClientName"].ToString();
                string excelName  = clientName + "_TrainingReport_" + DateTime.Now.Day + DateTime.Now.Month + DateTime.Now.Year + ".xlsx";
                using (var memoryStream = new MemoryStream())
                {
                    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                    Response.AddHeader("content-disposition", "attachment; filename=" + excelName);
                    excel.SaveAs(memoryStream);
                    memoryStream.WriteTo(Response.OutputStream);
                    Response.Flush();
                    Response.End();
                    return(File(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"));
                }
            }
            catch (Exception ex)
            {
                //LogHelper.AddLog("TrainingReportController", ex.Message, ex.StackTrace, "HCL.Academy.Web", user.EmailID);
                TelemetryClient telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
                return(null);
            }
        }
        public async Task <ActionResult> Edit(AssessmentMaster AM)
        {
            InitializeServiceClient();
            List <Skill>      skilllist      = new List <Skill>();
            List <Competence> competencelist = new List <Competence>();
            string            SelSkill       = String.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    AssessmentMasterRequest AMR = new AssessmentMasterRequest();
                    AMR.AssessmentId         = AM.AssessmentId;
                    AMR.AssessmentLink       = AM.AssessmentLink;
                    AMR.AssessmentName       = AM.AssessmentName;
                    AMR.AssessmentTimeInMins = AM.AssessmentTimeInMins;
                    AMR.Description          = AM.Description;
                    AMR.IsMandatory          = AM.IsMandatory;
                    AMR.PassingMarks         = AM.PassingMarks;
                    AMR.Points = AM.Points;
                    //AMR.SelectedCompetency = AM.SelectedCompetency;
                    AMR.SelCompetencyId = AM.SelCompetencyId;
                    //AMR.SelectedSkill = AM.SelectedSkill;
                    AMR.SelSkillId = AM.SelSkillId;
                    //AMR.SelectedTraining = AM.SelectedTraining;
                    AMR.SelTrainingId = AM.SelTrainingId;
                    HttpResponseMessage response = await client.PostAsJsonAsync("AssessmentMaster/UpdateAssessmentMaster", AMR);

                    bool result = await response.Content.ReadAsAsync <bool>();

                    if (result)
                    {
                        ViewBag.Success = true;
                    }
                    else
                    {
                        ViewBag.Success = false;
                    }
                    response = await client.PostAsJsonAsync("Skill/GetAllSkills", req);

                    skilllist = await response.Content.ReadAsAsync <List <Skill> >();

                    AM.Skills = skilllist;
                    SelSkill  = skilllist.Where(x => x.SkillId == AM.SelSkillId).FirstOrDefault().SkillName;
                    response  = await client.PostAsJsonAsync("Competency/GetCompetenciesBySkillName?skillName=" + SelSkill, req);

                    competencelist = await response.Content.ReadAsAsync <List <Competence> >();

                    AM.Competencies = competencelist;

                    UserTrainingsRequest utr = new UserTrainingsRequest();
                    //utr.SkillId = skilllist.Where(x=>x.SkillName == SelectedSkill).FirstOrDefault().SkillId;
                    utr.SkillId = AM.SelSkillId;
                    //utr.CompetenceId = competencelist.Where(x=>x.CompetenceName == SelectedCompetency).FirstOrDefault().CompetenceId;
                    utr.CompetenceId = AM.SelCompetencyId;
                    HttpResponseMessage responseMessage = await client.PostAsJsonAsync("Training/GetTrainings", utr);

                    List <Training> traininglist = await responseMessage.Content.ReadAsAsync <List <Training> >();

                    AM.Trainings = traininglist;
                }
                else
                {
                    AssessmentMaster am = new AssessmentMaster();
                    try
                    {
                        HttpResponseMessage response = await client.PostAsJsonAsync("Skill/GetAllSkills", req);

                        skilllist = await response.Content.ReadAsAsync <List <Skill> >();

                        am.Skills = skilllist;

                        response = await client.PostAsJsonAsync("Competency/GetAllCompetencyLevels", req);

                        competencelist = await response.Content.ReadAsAsync <List <Competence> >();

                        am.Competencies = competencelist;

                        response = await client.PostAsJsonAsync("Training/GetAllTrainings", req);

                        List <Training> traininglist = await response.Content.ReadAsAsync <List <Training> >();

                        am.Trainings = traininglist;
                    }
                    catch (Exception ex)
                    {
                        //LogHelper.AddLog("AssessmentMasterController", ex.Message, ex.StackTrace, "HCL.Academy.Web", user.EmailID);
                        TelemetryClient telemetry = new TelemetryClient();
                        telemetry.TrackException(ex);
                    }
                    return(View(am));
                }
            }
            catch (Exception ex)
            {
                //LogHelper.AddLog("AssessmentMasterController", ex.Message, ex.StackTrace, "HCL.Academy.Web", user.EmailID);
                TelemetryClient telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
            }
            return(View(AM));
        }