Пример #1
0
        //Overloaded Method, if we require report for whole Year.

        #region CaluclateProjectScore(for Year)
        public List <List <CalculatedScoreModel> > CalculateProjectKraScore(int AccountId, int Year)
        {
            List <List <CalculatedScoreModel> > KraScores = new List <List <CalculatedScoreModel> >();

            string[] Quarters = AccountParams.GetQuarters(AccountId, Year);
            for (int i = 0; i < Quarters.Length; i++)
            {
                List <CalculatedScoreModel> QuarterScore = CalculateProjectKraScore(AccountId, Quarters[i], Year);
                if (QuarterScore.Count != 0)
                {
                    KraScores.Add(QuarterScore);
                }
            }

            return(KraScores);
        }
        public JsonResult GetQuarters(AccountParametersModel Account)
        {
            string response;

            string[] Quarters = AccountParams.GetQuarters(Account.AccountID, Account.Year);
            if (Quarters != null)
            {
                return(Json(Quarters, JsonRequestBehavior.AllowGet));
            }
            else
            {
                response = "Please Select the parameters";
            }

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        public DataTable GetScoresDataTable(int AccountId, int Year)
        {
            DataTable scorestable = new DataTable();

            scorestable.Columns.Add("Parameter Name");
            scorestable.Columns.Add("Weightage");
            scorestable.Columns.Add("Q1");
            scorestable.Columns.Add("Q2");
            scorestable.Columns.Add("Q3");
            scorestable.Columns.Add("Q4");



            try
            {
                string[] Quarters = AccountParams.GetQuarters(AccountId, Year);
                List <AccountParametersModel> Parameters = AccountParams.GetParameters(AccountId, Year);
                List <CalculatedScoreYear>    list       = new List <CalculatedScoreYear>();
                foreach (var items in Parameters)
                {
                    CalculatedScoreYear ob = new CalculatedScoreYear();
                    ob.ParameterName = items.ParameterName;
                    ob.Weightage     = Convert.ToInt32(items.Weightage);
                    ob.Score         = new float[Quarters.Length];


                    for (int i = 0; i < Quarters.Length; i++)
                    {
                        AccountParametersModel parameter =
                            AccountParams.GetParameter(AccountId, items.ParamID, Quarters[i], Year);
                        if (parameter != null)
                        {
                            KraInputScores score = InputScores.GetScores(parameter.AccountParamID);
                            if (score != null)
                            {
                                ob.Score[i] = score.Score;
                            }
                            else
                            {
                                ob.Score[i] = 0;
                            }
                        }

                        else
                        {
                            ob.Score[i] = 0;
                        }
                    }
                    list.Add(ob);
                }

                foreach (var items in list)
                {
                    int size = items.Score.Length;
                    if (size == 1)
                    {
                        scorestable.Rows.Add(items.ParameterName, items.Weightage, items.Score[0]);
                    }
                    else if (size == 2)
                    {
                        scorestable.Rows.Add(items.ParameterName, items.Weightage, items.Score[0], items.Score[1]);
                    }
                    else if (size == 3)
                    {
                        scorestable.Rows.Add(items.ParameterName, items.Weightage, items.Score[0], items.Score[1], items.Score[2]);
                    }
                    else if (size == 4)
                    {
                        scorestable.Rows.Add(items.ParameterName, items.Weightage, items.Score[0], items.Score[1], items.Score[2], items.Score[3]);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                logger.Error(ex.Message);
                logger.Error(ex.Source);
                scorestable = null;
            }

            return(scorestable);
        }