private Metrices LoadCustomer(Metrices metrices, int metricPerspectiveId, int companyDepartmentJobRoleId, long appraisalHeaderId, int periodId, string staffId) { try { List <Customer> metrics = new List <Customer>(); metrices.CustomerTarget = "CUSTOMER (" + 0 + "%)"; if (periodId < 6) { DataSet ds = metricDb.SelectMetricByMetricPerspectiveIDAndCompanyDepartmentJobRoleIDAndAppraisalHeaderId(metricPerspectiveId, companyDepartmentJobRoleId, appraisalHeaderId); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { metrices.CustomerTargetValue = 0; metrices.CustomerActualScoreTotal = 0; metricRatingDbFacade = new MetricRatingDbFacade(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //decimal target = 0; Customer metric = new Customer(); metric.StaffMetricId = ds.Tables[0].Rows[i][metricDb.FIELD_STAFF_METRIC_ID] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i][metricDb.FIELD_STAFF_METRIC_ID]); metric.Id = ds.Tables[0].Rows[i][metricDb.FIELD_METRIC_ID] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i][metricDb.FIELD_METRIC_ID]); metric.Kpi = ds.Tables[0].Rows[i][metricDb.FIELD_KPI] == DBNull.Value ? null : Convert.ToString(ds.Tables[0].Rows[i][metricDb.FIELD_KPI]); metric.Measure = ds.Tables[0].Rows[i][metricDb.FIELD_MEASURE] == DBNull.Value ? null : Convert.ToString(ds.Tables[0].Rows[i][metricDb.FIELD_MEASURE]); metric.Target = ds.Tables[0].Rows[i][metricDb.FIELD_TARGET] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[i][metricDb.FIELD_TARGET]); metric.Score = ds.Tables[0].Rows[i][metricDb.FIELD_SCORE] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[i][metricDb.FIELD_SCORE]); metric.Rating = ds.Tables[0].Rows[i][metricDb.FIELD_RATING] == DBNull.Value ? 0 : Convert.ToByte(ds.Tables[0].Rows[i][metricDb.FIELD_RATING]); if (metric.Rating > 0) { metric.Period = new Period() { Id = periodId }; metrices.CustomerActualScoreTotal += Math.Round((Convert.ToDecimal(metric.Rating) / Convert.ToDecimal(metricRatingDbFacade.GetBy(metric))) * metric.Target, 2); } metrices.CustomerTargetValue += metric.Target; metrices.CustomerTarget = "CUSTOMER (" + metrices.CustomerTargetValue + "%)"; metrices.CustomerSumTotal += metric.Score; metrices.Customers.Add(metric); } } } } else { metrices = GetStaffInps(metrices, periodId, staffId); } return(metrices); } catch (Exception ex) { throw ex; } }
private Metrices LoadDefaultProcess(Metrices metrices, int metricPerspectiveId, int companyDepartmentJobRoleId, bool isSupervisor, int periodId) { try { List <Process> metrics = new List <Process>(); metrices.ProcessTarget = "PROCESS (" + 0 + "%)"; //DataSet ds = metricDb.SelectDefaultMetricByMetricPerspectiveIDAndCompanyDepartmentJobRoleID(metricPerspectiveId, companyDepartmentJobRoleId); DataSet ds = metricDb.SelectDefaultMetricByMetricPerspectiveIDAndCompanyDepartmentJobRoleIDAndPeriodID(metricPerspectiveId, companyDepartmentJobRoleId, periodId); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { metrices.ProcessTargetValue = 0; metricRatingDbFacade = new MetricRatingDbFacade(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //decimal target = 0; Process metric = new Process(); metric.Id = ds.Tables[0].Rows[i][metricDb.FIELD_METRIC_ID] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i][metricDb.FIELD_METRIC_ID]); metric.Kpi = ds.Tables[0].Rows[i][metricDb.FIELD_KPI] == DBNull.Value ? null : Convert.ToString(ds.Tables[0].Rows[i][metricDb.FIELD_KPI]); metric.Measure = ds.Tables[0].Rows[i][metricDb.FIELD_MEASURE] == DBNull.Value ? null : Convert.ToString(ds.Tables[0].Rows[i][metricDb.FIELD_MEASURE]); metric.Target = ds.Tables[0].Rows[i][metricDb.FIELD_TARGET] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[i][metricDb.FIELD_TARGET]); metric.Score = ds.Tables[0].Rows[i][metricDb.FIELD_SCORE] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[i][metricDb.FIELD_SCORE]); metric.Rating = ds.Tables[0].Rows[i][metricDb.FIELD_RATING] == DBNull.Value ? 0 : Convert.ToByte(ds.Tables[0].Rows[i][metricDb.FIELD_RATING]); metric.IsSupervisor = isSupervisor; if (metric.Rating > 0) { //metrices.ProcessActualScoreTotal += Math.Round((Convert.ToDecimal(metric.Rating) / Convert.ToDecimal(5)) * metric.Target, 2); metric.Period = new Period() { Id = periodId }; metrices.ProcessActualScoreTotal += Math.Round((Convert.ToDecimal(metric.Rating) / Convert.ToDecimal(metricRatingDbFacade.GetBy(metric))) * metric.Target, 2); } //metric.Kpi = UtilityLogic.JumbbleText(metric.Kpi); //metric.Measure = UtilityLogic.JumbbleText(metric.Kpi); metrices.ProcessTargetValue += metric.Target; metrices.ProcessTarget = "PROCESS (" + metrices.ProcessTargetValue + "%)"; metrices.ProcessSumTotal += metric.Score; metric.MetricRatings = GetMetricRating(metric.Id, metricPerspectiveId, companyDepartmentJobRoleId, periodId); metrices.Processes.Add(metric); } } } return(metrices); } catch (Exception ex) { throw ex; } }
public bool Add(List <Risk> metrices, int newPeriodId, int oldPeriodId, Transaction transaction) { metricRatingDbFacade = new MetricRatingDbFacade(); Risk risk = metrices[0]; List <MetricRating> metricRatings = metricRatingDbFacade.GetMetricRatingByPeriodId(risk.Period.Id); //transaction = new Transaction(DataAccess.DataAccess.ConnString); try { if (metrices != null) { foreach (Metric metric in metrices) { long metricId = metricDb.InsertMetric(metric.PerspectiveId, metric.CompanyDepartmentJobRoleId, metric.Kpi, metric.Measure, metric.DataSource, metric.ResponsibilityDepartmentId, metric.Target, metric.Score, newPeriodId, transaction); //List<MetricRating> selectedMetricRatings = metricRatings.Where(m => m.Rating.Id == metric.Id).ToList(); List <MetricRating> selectedMetricRatings = metricRatings.Where(m => m.Metrics.Id == metric.Id).ToList(); List <MetricRating> newMetricRatings = UpdatMetricRatings(selectedMetricRatings, metricId, newPeriodId); if (!metricRatingDbFacade.Add(newMetricRatings, transaction)) { //transaction.Abort(); return(false); } newMetricRatings = null; } } if (!metricDb.InsertOtherEntitiesForNewAppraisal(oldPeriodId, newPeriodId, transaction)) { //transaction.Abort(); return(false); } //transaction.Commit(); return(true); } catch (Exception) { throw; } }
private Metrices LoadPeople(Metrices metrices, int metricPerspectiveId, int companyDepartmentJobRoleId, bool isSupervisor, long appraisalHeaderId, int periodId, string staffId) { try { List <People> metrics = new List <People>(); metrices.PeopleTarget = "PEOPLE (" + 0 + "%)"; DataSet ds = metricDb.SelectMetricByMetricPerspectiveIDAndCompanyDepartmentJobRoleIDAndAppraisalHeaderId(metricPerspectiveId, companyDepartmentJobRoleId, appraisalHeaderId); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { //get learning and growth for this staff decimal learningScore = 0; Learning learning = learningDbFacade.GetByStaffAndPeriod(staffId, periodId); if (learning != null) { learningScore = learning.PercentageScore; } metrices.PeopleTargetValue = 0; metricRatingDbFacade = new MetricRatingDbFacade(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //decimal target = 0; People metric = new People(); metric.StaffMetricId = ds.Tables[0].Rows[i][metricDb.FIELD_STAFF_METRIC_ID] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i][metricDb.FIELD_STAFF_METRIC_ID]); metric.Id = ds.Tables[0].Rows[i][metricDb.FIELD_METRIC_ID] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i][metricDb.FIELD_METRIC_ID]); metric.Kpi = ds.Tables[0].Rows[i][metricDb.FIELD_KPI] == DBNull.Value ? null : Convert.ToString(ds.Tables[0].Rows[i][metricDb.FIELD_KPI]); metric.Measure = ds.Tables[0].Rows[i][metricDb.FIELD_MEASURE] == DBNull.Value ? null : Convert.ToString(ds.Tables[0].Rows[i][metricDb.FIELD_MEASURE]); metric.Target = ds.Tables[0].Rows[i][metricDb.FIELD_TARGET] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[i][metricDb.FIELD_TARGET]); metric.Score = learningScore; //metric.Score = ds.Tables[0].Rows[i]["Metric_Score"] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[i]["Metric_Score"]); metric.Rating = ds.Tables[0].Rows[i][metricDb.FIELD_RATING] == DBNull.Value ? 0 : Convert.ToByte(ds.Tables[0].Rows[i][metricDb.FIELD_RATING]); metric.IsSupervisor = isSupervisor; metric.MetricRatings = GetMetricRating(metric.Id, metricPerspectiveId, companyDepartmentJobRoleId, periodId); if (metric.Rating > 0) { metric.Period = new Period() { Id = periodId }; //metrices.PeopleActualScoreTotal += Math.Round((Convert.ToDecimal(metric.Rating) / Convert.ToDecimal(5)) * metric.Target, 2); metrices.PeopleActualScoreTotal += Math.Round((Convert.ToDecimal(metric.Rating) / Convert.ToDecimal(metricRatingDbFacade.GetBy(metric))) * metric.Target, 2); } metrices.PeopleTargetValue += metric.Target; metrices.PeopleTarget = "PEOPLE (" + metrices.PeopleTargetValue + "%)"; metrices.PeopleSumTotal += metric.Score; metrices.Peoples.Add(metric); } } } return(metrices); } catch (Exception ex) { throw ex; } }