Beispiel #1
0
        private void UpdateParam(RiskChartViewModel vm)
        {
            Dictionary<int, string> posList = new Dictionary<int, string>();
            posList.Add(1, "Kantor Pusat");
            posList.Add(2, "Cabang");
            vm.PosList = new SelectList(posList, "Key", "Value", vm.PosId);

            Dictionary<int, string> branchList = new Dictionary<int, string>();
            foreach (var branch in db.Branches.OrderBy(m => m.ClassId).ThenBy(m => m.BranchName))
                branchList.Add(branch.BranchId, branch.BranchName + " (Kelas " + branch.BranchClass.ClassName + ")");
            vm.Branches = new SelectList(branchList, "Key", "Value", vm.BranchId);

            Dictionary<int, string> chartTypes = new Dictionary<int, string>();
            chartTypes.Add(1, "Kolom");
            chartTypes.Add(2, "Bar");
            chartTypes.Add(3, "Pie");
            vm.ChartTypes = new SelectList(chartTypes, "Key", "Value", vm.ChartTypeId);

            Dictionary<int, string> xValues = new Dictionary<int, string>();
            xValues.Add(1, "(Tanpa pengelompokan)");
            xValues.Add(2, "Sebab Risiko");
            xValues.Add(3, "Akibat Risiko");
            xValues.Add(4, "Klasifikasi Risiko");
            xValues.Add(5, "Pusat/Cabang");
            xValues.Add(6, "Kelas Cabang");
            xValues.Add(7, "Cabang Kelas I");
            xValues.Add(8, "Cabang Kelas II");
            xValues.Add(9, "Cabang Kelas III");
            xValues.Add(10, "Tingkat Probabilitas");
            xValues.Add(11, "Tingkat Dampak");
            xValues.Add(12, "Tingkat Risiko");
            vm.XValues = new SelectList(xValues, "Key", "Value", vm.XValueId);

            Dictionary<int, string> yValues = new Dictionary<int, string>();
            yValues.Add(1, "Jumlah Data");
            yValues.Add(2, "Tingkat Probabilitas");
            yValues.Add(3, "Tingkat Dampak");
            yValues.Add(4, "Tingkat Probabilitas dan Tingkat Dampak");
            yValues.Add(5, "Tingkat Risiko");
            vm.YValues = new SelectList(yValues, "Key", "Value", vm.YValueId);
        }
Beispiel #2
0
        private IEnumerable<Risk> CalcRisks(RiskChartViewModel vm)
        {
            var risks = db.Risks.Where(p => p.ProbLevelId != null && p.ImpactLevelId != null);
            if (vm.PosId == 1)
                risks = risks.Where(p => p.DeptId != null);
            else if (vm.PosId == 2)
            {
                risks = risks.Where(p => p.BranchId != null);
                if (vm.BranchId != null)
                    risks = risks.Where(p => p.BranchId == vm.BranchId);
            }

            if (vm.IsApproved)
            {
                risks = risks.Where(p => p.CloseDate == null || p.CloseDate > vm.ReportDate);
                risks = risks.Where(p => p.ApprovalDate != null && p.ApprovalDate <= vm.ReportDate);
            }
            else
            {
                risks = risks.Where(p => p.ApprovalDate == null && p.RiskDate <= vm.ReportDate);
            }
            return risks;
        }
Beispiel #3
0
 public ActionResult Index(RiskChartViewModel vm)
 {
     UpdateParam(vm);
     var risks = CalcRisks(vm);
     var listData = CalcChartData(risks, vm);
     Session["ListData"] = listData;
     Session["RiskChartViewModel"] = vm;
     ViewBag.DataTypeText = GetDataTypeText(vm.YValueId);
     return View(vm);
 }
Beispiel #4
0
        private List<ChartData> CalcChartData(IEnumerable<Risk> risks, RiskChartViewModel vm)
        {
            List<ChartData> listData = new List<ChartData>();
            InitializeListData(listData, vm.XValueId);

            switch (vm.XValueId)
            {
                case GROUP_NONE:
                    CalcChartData_NoGroup(listData, risks, vm.YValueId);
                    break;
                case GROUP_CAUSE:
                    CalcChartData_Cause(listData, risks, vm.YValueId);
                    break;
                case GROUP_EFFECT:
                    CalcChartData_Effect(listData, risks, vm.YValueId);
                    break;
                case GROUP_RISKCLASS:
                    CalcChartData_RiskClass(listData, risks, vm.YValueId);
                    break;
                case GROUP_HQ_BRANCH:
                    CalcChartData_HQBranch(listData, risks, vm.YValueId);
                    break;
                case GROUP_CLASSBRANCH:
                    CalcChartData_ClassBranch(listData, risks, vm.YValueId);
                    break;
                case GROUP_BRANCH_CLASS1:
                    CalcChartData_Branch1(listData, risks, vm.YValueId);
                    break;
                case GROUP_BRANCH_CLASS2:
                    CalcChartData_Branch2(listData, risks, vm.YValueId);
                    break;
                case GROUP_BRANCH_CLASS3:
                    CalcChartData_Branch3(listData, risks, vm.YValueId);
                    break;
                case GROUP_PROBLEVEL:
                    CalcChartData_ProbLevel(listData, risks, vm.YValueId);
                    break;
                case GROUP_IMPACTLEVEL:
                    CalcChartData_ImpactLevel(listData, risks, vm.YValueId);
                    break;
                case GROUP_RISKLEVEL:
                    CalcChartData_RiskLevel(listData, risks, vm.YValueId);
                    break;
            }

            foreach (var data in listData)
            {
                if (data.Count > 0)
                {
                    switch (vm.YValueId)
                    {
                        case DATA_COUNT:
                            //data.Value++;
                            break;
                        case DATA_PROBLEVEL:
                            data.Value = data.Value / data.Count;
                            break;
                        case DATA_IMPACTLEVEL:
                            data.Value = data.Value / data.Count;
                            //data.Value += (int)r.ImpactLevelId;
                            break;
                        case DATA_PROBIMPACTLEVEL:
                            data.Value = data.Value / data.Count;
                            data.Value2 = data.Value2 / data.Count;
                            break;
                        case DATA_RISKLEVEL:
                            data.Value = data.Value / data.Count;
                            break;
                    }
                }
            }

            return listData;
        }
Beispiel #5
0
        public ActionResult Index()
        {
            RiskChartViewModel vm = new RiskChartViewModel();
            vm.PosId = 1;
            vm.IsApproved = true;
            vm.ReportDate = DateTime.Now;
            vm.ChartTypeId = 1;
            vm.XValueId = 1;
            vm.YValueId = 1;

            UpdateParam(vm);
            var risks = CalcRisks(vm);
            var listData = CalcChartData(risks, vm);
            Session["ListData"] = listData;
            Session["RiskChartViewModel"] = vm;
            ViewBag.DataTypeText = GetDataTypeText(vm.YValueId);
            return View(vm);
        }