Ejemplo n.º 1
0
        private string GetTreeMapData(CitiesStatistic someSitiesStat)
        {
            // full value of data parameter. Should be quoted in view
            string result = "["; //  "data": [

            result += "{            \"label\": \"Україна\",       \"fillcolor\": \"8c8c8c\",  \"value\": \"" + someSitiesStat.TotalServicesProvided + "\",      \"data\":       \r\n\t[ ";


            foreach (CityStatistic city in someSitiesStat.CitiesStats)
            {
                result += " \r\n\t{\r\n\t\t\"label\": \"" + city.City.Name + "\",    \"fillcolor\": \"8c8c8c\",  \"value\": \"" + city.ServicesProvided + "\", \"data\": \r\n\t\t[\r\n";

                OrganizationOperations orgOp = new OrganizationOperations(db);

                foreach (Organization organization in city.City.Organizations)
                {
                    OrganizationStatistic orgStat = orgOp.GetOrganizationStatistic(organization.Id, false);
                    result += "\r\n\t\t\t{\r\n \t\t\t\t\"label\": \"" + organization.Name + "\",  \"value\": \"" + orgStat.TotalServices + "\",  \"sValue\": \"" + orgStat.SummaryIndex.ToString("0.#") + "\" ";
                    result += "\r\n\t\t\t}\r\n\t\t\t ,";
                }
                result  = result.TrimEnd(',');
                result += "\r\n\t\t]\r\n \r\n\t}\r\n\t ,"; // data of city
            }
            result  = result.TrimEnd(',');
            result += "\r\n\t]}\r\n]\r\n";

            result += ",\r\n \"colorrange\": {        \"mapbypercent\": \"1\",        \"gradient\": \"1\",        \"minvalue\": \"0\",        \"code\": ";

            result += "   \"7FFF00\",        \"startlabel\": \"Позитивно\",      \"endlabel\": \"Негативно\",        \"color\": [            {";
            result += "\"code\": \"EE0000\",                \"maxvalue\": \"100\",                \"label\": \"Static\"            },            {                \"code\": \"7FFF00\",                \"maxvalue\": \"100\",                \"label\": \"AVERAGE\"            }        ]    }  ";


            return(result);
        }
Ejemplo n.º 2
0
        public CityStatistic GetCityStatistic(City someCity)
        {
            CityStatistic result = new CityStatistic(db, someCity);

            result.ServicesProvided       = db.ServiceToClients.Where(m => m.ValueSet.HasValue).Where(m => m.Worker.WorkPlace.Division.Organization.CityId == someCity.Id).Count();
            result.FailedServicesProvided = db.ServiceToClients.Where(m => m.ValueSet.HasValue).Where(m => m.Value == -1).Where(m => m.Worker.WorkPlace.Division.Organization.CityId == someCity.Id).Count();

            result.SuccessServicesProvided = db.ServiceToClients.Where(m => m.ValueSet.HasValue).Where(m => m.Value == 1).Where(m => m.Worker.WorkPlace.Division.Organization.CityId == someCity.Id).Count();

            result.SummaryIndex = ((double)100 / (((double)result.SuccessServicesProvided + (double)result.FailedServicesProvided) / (double)result.FailedServicesProvided));

            OrganizationOperations orgOp = new OrganizationOperations(db);

            foreach (Organization item in someCity.Organizations)
            {
                OrganizationStatistic someOrgStat = orgOp.GetOrganizationStatistic(item.Id, false);
                result.OrganizationStatistic.Add(someOrgStat);
            }

            result.TreeMapData = GetTreeMapData(result);


            return(result);
        }