Пример #1
0
 public ActionResult Index()
 {
     SummaryReportCreatorModel model = new SummaryReportCreatorModel();
     model.Activities = _infoAdapter.GetActivities();
     model.EducationLevels = _infoAdapter.GetEducationLevels();
     model.PostLevels = _infoAdapter.GetPostLevels();
     return View(model);
 }
Пример #2
0
 public IEnumerable<StatisticDataModel> GetSummaryReport(SummaryReportCreatorModel model)
 {
     using (var proxy = new StatisticDataServiceClient())
     {
         IEnumerable<StatisticData> statisticData = proxy.GetSummaryReport(model.EnterpriseId, model.FederalSubjectId,model.FederalDistrictId, DateTime.Parse(model.BoundDate),
                 model.SelectedActivities.ToArray(), model.SelectedGenders.ToArray(), model.SelectedEducationLevels.ToArray(),model.SelectedPostLevels.ToArray());
         return Convert(statisticData);
     }
 }
Пример #3
0
        public ActionResult Index(SummaryReportCreatorModel model)
        {
            if (!model.SelectedActivities.Any()
                || !model.SelectedGenders.Any()
                || !model.SelectedEducationLevels.Any()
                ||!model.SelectedPostLevels.Any()
                )
            {
                ModelState.AddModelError("activities", "Необходимо указать виды деятельности.");
                ModelState.AddModelError("genders", "Необходимо указать пол.");
                ModelState.AddModelError("educationlevels", "Необходимо указать уровни образования.");
                ModelState.AddModelError("postlevels", "Необходимо указать категории работников.");
            }

            if (!ModelState.IsValid) { return Index(); }

            IEnumerable<StatisticDataModel> statisticData = _summaryAdapter.GetSummaryReport(model);
            foreach (StatisticDataModel eModel in statisticData)
            {
                eModel.MainActivity = "Связи, информационных технологий и массовых коммуникаций";
                eModel.ReportName = "Количественный";
                eModel.CreatedDateTime = String.Format("{0} {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString());
                eModel.FederalDistrict = model.FederalDistrictId == 0
                                            ? "Все Федеральные округа"
                                            : _infoAdapter.GetFederalDistricts().Single(x => x.Id == model.FederalDistrictId)
                                                  .Title;

                if (model.FederalSubjectId == 0)
                {
                    eModel.FederalSubject = "Все субъекты федерации";
                }
                else
                {
                    FederalSubjectModel federalSubject =
                        _infoAdapter.GetFederalSubjects(0).Single(x => x.Id == model.FederalSubjectId);
                    eModel.FederalSubject = federalSubject.Title;
                }

                if (model.EnterpriseId == 0)
                {
                    eModel.Enterprise = "Все предприятия";
                }
                else
                {
                    EnterpriseModel enterprise = _infoAdapter.GetEnterprises(0).Single(x => x.Id == model.EnterpriseId);
                    eModel.Enterprise = enterprise.Title;
                }
            }

            return View("StaticStatisticData", statisticData);
        }
Пример #4
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            SummaryReportCreatorModel model = new SummaryReportCreatorModel();
            const string activitiesMark = "activitycheckbox_";
            const string gendersMark = "gendercheckbox_";
            const string educationLevelsMark = "educationlevelcheckbox_";
            const string postLevelsMark = "postlevelcheckbox_";

            NameValueCollection form = controllerContext.HttpContext.Request.Form;
            var activitiesCollection = new List<int>();
            var gendersCollection = new List<int>();
            var educationLevelsCollection = new List<int>();
            var postLevelsCollection = new List<int>();

            foreach (var formItem in form.AllKeys)
            {
                if (form[formItem].IndexOf(Boolean.TrueString, StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    if (formItem.StartsWith(activitiesMark))
                    {
                        int item = Int32.Parse(formItem.Replace(activitiesMark, ""));
                        activitiesCollection.Add(item);
                    }
                    else if (formItem.StartsWith(gendersMark))
                    {
                        int item = Int32.Parse(formItem.Replace(gendersMark, ""));
                        gendersCollection.Add(item);
                    }
                    else if (formItem.StartsWith(educationLevelsMark))
                    {
                        int item = Int32.Parse(formItem.Replace(educationLevelsMark, ""));
                        educationLevelsCollection.Add(item);
                    }
                    else if (formItem.StartsWith(postLevelsMark))
                    {
                        int item = Int32.Parse(formItem.Replace(postLevelsMark, ""));
                        postLevelsCollection.Add(item);
                    }
                }
            }
            model.SelectedActivities = activitiesCollection;
            model.SelectedEducationLevels = educationLevelsCollection;
            model.SelectedPostLevels = postLevelsCollection;
            model.SelectedGenders = gendersCollection;

            int federalDistrictId = 0;
            if (Int32.TryParse(form["federalDistrictId"], out federalDistrictId))
            {
                model.FederalDistrictId = federalDistrictId;
            }
            int federalSubjectId = 0;

            if (Int32.TryParse(form["federalSubjectId"], out federalSubjectId))
            {
                model.FederalSubjectId = federalSubjectId;
            }

            int enterpriseId = 0;

            if (Int32.TryParse(form["enterpriseId"], out enterpriseId))
            {
                model.EnterpriseId = enterpriseId;
            }

            model.BoundDate = form["endDate"];
            return model;
        }