コード例 #1
0
        public ActionResult Questions(Account session, QuestionModel model)
        {
            if (null == session)
            {
                return(RedirectToAction("Login", "Home"));
            }

            Choice choice = new Choice();

            choice.Id       = StringHelper.GuidString();
            choice.UserId   = session.Id;
            choice.UserName = session.UserName;

            var areaParam = areaExtendParamsService.GetStreetByStreatId(model.Street);

            choice.FirstChoice  = model.Street;
            choice.SecondChoice = model.BuildLevel;  //200
            choice.ThirdChoice  = model.StructLevel; //4
            choice.ForthChoice  = model.Designed;    //0
            choice.FifthChoice  = model.Jobstatus;   //1
            choice.Sixth        = model.YearLevel;   //1
            choice.CreateDate   = DateTime.Now;
            choice.FromType     = (int)EnumUserType.Web;
            choice.Address      = model.Address;


            QuakeViewerCalculate quakeViewerCalculate = new QuakeViewerCalculate();

            quakeViewerCalculate.InputData(areaParam.GroupNo.Value,
                                           areaParam.SiteType.Value,
                                           areaParam.IntensityDegree.Value,
                                           choice.SecondChoice.Value,
                                           choice.ThirdChoice.Value,
                                           choice.ForthChoice.Value == 1,
                                           choice.FifthChoice.Value,
                                           choice.Sixth.Value);


            quakeViewerCalculate.ResponseMinor();
            quakeViewerCalculate.ResponseMajor();

            choice.MinorResult = quakeViewerCalculate.DamageDgreeMinor;
            choice.MajorResult = quakeViewerCalculate.DamageDgreeMajor;

            choiceService.SaveChoice(choice);

            return(RedirectToAction("QuakeResult", new { id = choice.Id }));
        }
コード例 #2
0
        public ActionResult QuestionsResult(string token, string regionId,
                                            int storyNum,
                                            int struType,
                                            int isDesigned,
                                            int contructionQuality,
                                            int builtYearGroup,
                                            string address)
        {
            Response.ContentType = "application/json";
            JObject result = new JObject();
            JObject obj    = new JObject();

            if (string.IsNullOrEmpty(token))
            {
                obj.Add("success", false);
                obj.Add("msg", "权限错误,请登录后使用");

                result.Add("result", obj);

                return(Content(result.ToString()));
            }

            if (string.IsNullOrEmpty(address))
            {
                obj.Add("success", false);
                obj.Add("msg", "详细地址不能为空!");

                result.Add("result", obj);

                return(Content(result.ToString()));
            }

            Choice choice = new Choice();

            choice.Id = StringHelper.GuidString();

            var account = accountService.GetAccountById(token);

            choice.UserId   = account.Id;
            choice.UserName = account.UserName;

            var areaExtendParams = areaExtendParamsService.GetStreetByStreatId(regionId);

            choice.FirstChoice  = regionId;
            choice.SecondChoice = storyNum;
            choice.ThirdChoice  = struType;
            choice.ForthChoice  = isDesigned;
            choice.FifthChoice  = contructionQuality;
            choice.Sixth        = builtYearGroup;
            choice.CreateDate   = DateTime.Now;
            choice.FromType     = (int)EnumUserType.Mobile;
            choice.Address      = address;


            QuakeViewerCalculate quakeViewerCalculate = new QuakeViewerCalculate();

            /* quakeViewerCalculate.InputData(areaParam.GroupNo.Value,
             *                              areaParam.SiteType.Value,
             *                              areaParam.IntensityDegree.Value,
             *                              choice.SecondChoice.Value,
             *                              choice.ThirdChoice.Value,
             *                              choice.ForthChoice.Value,
             *                              choice.FifthChoice.Value,
             *                              choice.Sixth.Value == 1); */

            quakeViewerCalculate.InputData(areaExtendParams.GroupNo.Value,
                                           areaExtendParams.SiteType.Value,
                                           areaExtendParams.IntensityDegree.Value,
                                           choice.SecondChoice.Value,
                                           choice.ThirdChoice.Value,
                                           choice.ForthChoice.Value == 1,
                                           choice.FifthChoice.Value,
                                           choice.Sixth.Value);

            quakeViewerCalculate.ResponseMinor();
            quakeViewerCalculate.ResponseMajor();

            choice.MinorResult = quakeViewerCalculate.DamageDgreeMinor;
            choice.MajorResult = quakeViewerCalculate.DamageDgreeMajor;

            choiceService.SaveChoice(choice);

            ResultModel model = new ResultModel();

            model.UserName   = choice.UserName;
            model.MajorLevel = choice.MajorResult.Value;
            model.MinorLevel = choice.MinorResult.Value;
            model.Reason1    = choice.ThirdChoice.Value;
            model.Reason2    = choice.ForthChoice.Value;
            model.Reason3    = choice.FifthChoice.Value;

            obj.Add("resultModel", JObject.FromObject(model));
            obj.Add("success", true);
            result.Add("result", obj);

            return(Content(result.ToString()));
        }