private void AddOptionToSurveyList(SurveyVO Survey) { Survey.SurveyOptions.Add(new SurveyOptionVO { Id = 0, OptionId = 0 }); }
public ActionResult DeleteSurvey(int SurveyId, bool?IsSoftDelete) { SurveyVO objSurvey = _surveyBizManager.GetAllSurvey(SurveyId).FirstOrDefault(); DeleteImage(objSurvey.PicturePath); bool IsDeleted = _surveyBizManager.DeleteSurvey(SurveyId, false); List <SurveyVO> objSurveyList = _surveyBizManager.GetAllSurvey(null); // ViewBag.CategoryDll = objSurveyList.Select(x => new SelectListItem { Text = x.CategoryName, Value = x.CategoryId.ToString() }).ToList(); return(RedirectToAction("Index", "Survey", objSurveyList)); }
public Boolean CreateUpdateSurvey(SurveyVO Survey) { Boolean IsDone = _surveyDataManager.CreateUpdateSurvey(Mapper.Map <SurveyVO, Survey>(Survey)); long SurveyId = Survey.SurveyId != 0 ? Survey.SurveyId : GetLastGeneratedSurveyId(); foreach (SurveyOptionVO SurveyOption in Survey.SurveyOptions) { if (SurveyOption.OptionId != 0) { _surveyOptionDataManager.CreateUpdateSurveyOption(SurveyOption.Id, SurveyOption.OptionId, SurveyId); } } return(IsDone); }
public ActionResult SurveyDetails(long surveyId, string suveryQs) { ViewBag.PageTitle = suveryQs.Replace('-', ' '); List <CategoryVO> objCategoryList = new List <CategoryVO>(); List <SurveyVO> objSurveyList = _surveyBizManager.GetAllSurvey(surveyId, null, null, null); JavaScriptSerializer jss = new JavaScriptSerializer(); ViewBag.JsonResult = jss.Serialize(GetResultJson(objSurveyList.SingleOrDefault())); SurveyVO ObjSurvey = objSurveyList.SingleOrDefault(); if (CheckCookie("Voted_" + surveyId)) { ObjSurvey.IsVoted = true; ObjSurvey.VoteValue = GetCookie("Voted_" + ObjSurvey.SurveyId); } if (CheckCookie("Rated_" + surveyId)) { ObjSurvey.IsRated = true; ObjSurvey.RateValue = GetCookie("Rated_" + ObjSurvey.SurveyId); } ViewBag.RelatedSurvey = GetRealtedSurvey(surveyId, true); List <SurveyVO> ViewedSurveyList = GetRealtedSurvey(surveyId, null).ToList(); ViewBag.PeopleViewedSurvey1 = ViewedSurveyList.Take(3).ToList(); ViewBag.PeopleViewedSurvey2 = ViewedSurveyList.Skip(3).Take(3).ToList(); ViewBag.PeopleViewedSurvey3 = ViewedSurveyList.Skip(6).Take(3).ToList(); if (Session["Categories"] == null) { objCategoryList = _categoryBizManager.GetAllCategory(null, true); Session["Categories"] = objCategoryList; } else { objCategoryList = Session["Categories"] as List <CategoryVO>; } ViewBag.SurveyCategory = objCategoryList; return(View("../user/survey/Surveydetails", ObjSurvey)); }
public ActionResult create(SurveyVO Survey, String AddOption) { SetCategoryDropDown(); if (string.IsNullOrEmpty(AddOption)) { Int64 SurveyId = Survey.SurveyId != 0 ? Survey.SurveyId - 1 : _surveyBizManager.GetLastGeneratedSurveyId(); HttpPostedFileBase file = Request.Files["SurveyImage"]; String path = string.Empty; string extension = ""; if (file != null && file.ContentLength > 0) { extension = Path.GetExtension(file.FileName); path = Path.Combine(Server.MapPath("~/SurveyImages"), "Survey_" + (SurveyId + 1) + extension); file.SaveAs(path); Image imgOriginal = Image.FromFile(path); //pass in whatever value you want Image imgActual = Scale(imgOriginal); imgOriginal.Dispose(); imgActual.Save(path); imgActual.Dispose(); Survey.PicturePath = "../SurveyImages/Survey_" + (SurveyId + 1) + extension; } Survey.CreatedBy = HttpContext.User.Identity.Name; bool IsCreated = _surveyBizManager.CreateUpdateSurvey(Survey); if (IsCreated) { ViewBag.Message = "Data Save Successfully."; SurveyVO objSurvey = new SurveyVO(); objSurvey.SurveyOptions = new List <SurveyOptionVO>(); AddOptionToSurveyList(objSurvey); return(View("../Admin/survey/create", objSurvey)); } return(View("../Admin/survey/create", Survey)); } else { AddOptionToSurveyList(Survey); return(View("../Admin/survey/create", Survey)); } }
public ActionResult create(long?id) { SetCategoryDropDown(); SurveyVO objSurvey = null; if (id != null) { SurveyVO objTempSurvey = _surveyBizManager.GetAllSurvey(id).FirstOrDefault(); objSurvey = objTempSurvey != null ? objTempSurvey : new SurveyVO(); } else { objSurvey = new SurveyVO(); objSurvey.SurveyOptions = new List <SurveyOptionVO>(); AddOptionToSurveyList(objSurvey); } return(View("../Admin/survey/create", objSurvey)); }
private List <SurveyResult> GetResultJson(SurveyVO Survey) { long Sum = 0; List <SurveyResult> objSurveyResult = new List <SurveyResult>(); foreach (SurveyOptionVO SO in Survey.SurveyOptions) { Sum += SO.SurveyOptionCount; } Sum = Sum != 0 ? Sum : 1; foreach (SurveyOptionVO SO in Survey.SurveyOptions) { objSurveyResult.Add(new SurveyResult() { name = SO.OptionName, y = ((double)SO.SurveyOptionCount / Sum) * 100 }); } return(objSurveyResult); }
/// <summary> /// 更新问卷 /// </summary> /// <param name="survey"></param> /// <returns></returns> public ResultVO UpdateSurveyInfo(SurveyVO survey) { var res = _surveyInfoService.UpdateSurveyInfo(survey); return(res); }
/// <summary> /// 插入新调查问卷 /// </summary> /// <param name="survey"></param> /// <returns></returns> public ResultVO InsertSurvey(SurveyVO survey) { var res = _surveyInfoService.InsertSurvey(survey); return(res); }
/// <summary> /// 插入新调查问卷 /// </summary> /// <returns></returns> public ResultVO InsertSurvey(SurveyVO survey) { ResultVO result = new ResultVO() { Result = 0 }; try { using (TransactionScope trans = new TransactionScope()) { var surveyInfo = survey.SurveyInfo; var questionInfo = survey.QuestionInfo; var requireInfo = survey.RequiredInfo; var userInfo = _userInfoRepository.LoadEntities(u => u.UserName == survey.UserName && u.Deleted == false) .FirstOrDefault(); _unitOfWork.Commit(); surveyInfo.TmplId = survey.TemplateId; //初始化数据 surveyInfo.CreateTime = base.CurrentServerTime; surveyInfo.Deleted = false; surveyInfo.CreateId = userInfo.UserId; surveyInfo.StaticUrl = String.Format("{0}/{1}", "statics", CurrentServerTime.ToString("yyyyMMddHHmmss") + ".html"); surveyInfo.RequiredInfos = string.Join(",", survey.RequiredInfo.ToArray()); var insertedSurveyInfo = _surveyInfoRepository.Insert(surveyInfo); _unitOfWork.Commit(); var insertedQuestion = new QuestionInfo(); var insertedOpt = new OptionInfo(); questionInfo.ForEach(q => { var question = new QuestionInfo() { SurveyId = insertedSurveyInfo.SurveyId, QuestionTitle = q.QuestionTitle, IsOrientation = q.IsOrientation, QuestionOptionsCount = q.QuestionOptionsCount, RequiredOptionsCount = q.IsOrientation == false ? 0 : q.RequiredOptionsCount, Deleted = false }; insertedQuestion = _quesionInfoRepository.Insert(question); _unitOfWork.Commit(); q.Options.ForEach(o => { o.Deleted = false; o.QuesionId = insertedQuestion.QuestionId; insertedOpt = _optionInfoRepository.Insert(o); _unitOfWork.Commit(); }); }); var insertedQuestionList = _quesionInfoRepository.LoadEntities(q => q.SurveyId == insertedSurveyInfo.SurveyId).ToList(); var quesionList = new List <QuestionVO>(); insertedQuestionList.ForEach(q => quesionList.Add(new QuestionVO { QuesionId = q.QuestionId, QuestionTitle = q.QuestionTitle, IsOrientation = q.IsOrientation, QuestionOptionsCount = q.QuestionOptionsCount, RequiredOptionsCount = q.RequiredOptionsCount, Options = _optionInfoRepository.LoadEntities(o => o.QuesionId == q.QuestionId).ToList() })); var tmplInfo = _templateRepository.LoadEntities(t => t.TmplId == insertedSurveyInfo.TmplId).FirstOrDefault(); var arr = tmplInfo.StoredName.Split('\\'); var tmplFolder = arr[arr.Length - 1]; var surveyTmplObj = new { QuestionInfo = quesionList, SurveyInfo = insertedSurveyInfo, RequiredInfo = survey.RequiredInfo, TemplateFolderName = tmplFolder, isExample = 0 }; StaticPageHelper.GenerateHtml(surveyTmplObj, "wapTmpl.html", survey.SurveyInfo.StaticUrl.Split("/".ToCharArray())[1].Split('.')[0]); trans.Complete(); result.Result = 1; } } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
/// <summary> /// 更新问卷信息 /// </summary> /// <param name="survey"></param> /// <returns></returns> public ResultVO UpdateSurveyInfo(SurveyVO survey) { ResultVO result = new ResultVO() { Result = 0 }; try { using (TransactionScope tran = new TransactionScope()) { survey.SurveyInfo.TmplId = survey.TemplateId; _surveyInfoRepository.Update(survey.SurveyInfo); _unitOfWork.Commit(); survey.QuestionInfo.ForEach(q => { var tmpQuestion = new QuestionInfo() { QuestionId = q.QuesionId, QuestionOptionsCount = q.QuestionOptionsCount, QuestionTitle = q.QuestionTitle, IsOrientation = q.IsOrientation, SurveyId = survey.SurveyInfo.SurveyId, RequiredOptionsCount = q.IsOrientation == false ? 0 : q.RequiredOptionsCount }; _quesionInfoRepository.Update(tmpQuestion); _unitOfWork.Commit(); q.Options.ForEach(o => { var tmpOpt = new OptionInfo() { QuesionId = q.QuesionId, OptionId = o.OptionId, OptionKey = o.OptionKey, OptionValue = o.OptionValue }; _optionInfoRepository.Update(tmpOpt); _unitOfWork.Commit(); }); }); var surveyInfo = _surveyInfoRepository.LoadEntities(s => s.SurveyId == survey.SurveyInfo.SurveyId) .FirstOrDefault(); var insertedQuestionList = _quesionInfoRepository.LoadEntities(q => q.SurveyId == survey.SurveyInfo.SurveyId).ToList(); var quesionList = new List <QuestionVO>(); insertedQuestionList.ForEach(q => quesionList.Add(new QuestionVO { QuesionId = q.QuestionId, QuestionTitle = q.QuestionTitle, QuestionOptionsCount = q.QuestionOptionsCount, RequiredOptionsCount = q.RequiredOptionsCount, Options = _optionInfoRepository.LoadEntities(o => o.QuesionId == q.QuestionId).ToList() })); var tmplInfo = _templateRepository.LoadEntities(t => t.TmplId == survey.SurveyInfo.TmplId).FirstOrDefault(); var arr = tmplInfo.StoredName.Split('\\'); var tmplFolder = arr[arr.Length - 1]; var surveyTmplObj = new { QuestionInfo = quesionList, SurveyInfo = surveyInfo, RequiredInfo = survey.SurveyInfo.RequiredInfos.Split(','), TemplateFolderName = tmplFolder, isExample = 0 }; StaticPageHelper.GenerateHtml(surveyTmplObj, "wapTmpl.html", survey.SurveyInfo.StaticUrl.Split("/".ToCharArray())[1].Split('.')[0]); tran.Complete(); result.Result = 1; } } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }