public ActionResult SurveyDetail(int id)
        {
            SurveyData    surveyData = new SurveyData();
            SurveyDetails details    = surveyData.Details.Single(survey => survey.ID == id);

            return(View(details));
        }
Exemple #2
0
        public IHttpActionResult Post([FromBody] SurveyData surveyData)
        {
            var answerService = new AnswerService();

            answerService.UpdateAnswers(surveyData);
            return(Ok(surveyData));
        }
Exemple #3
0
 public SurveyCompletedModel(SurveyData surveyData, UserManager <OmadaUser> userManager, ITeamData teamData, AveragesCalculate averagesCalculate)
 {
     this.surveyData        = surveyData;
     this.userManager       = userManager;
     this.teamData          = teamData;
     this.averagesCalculate = averagesCalculate;
 }
Exemple #4
0
 public async Task <IActionResult> Post([FromBody] SurveyData surveyData)
 {
     surveyService.UpdateAnswers(surveyData);
     //var form = surveyService.GetSurveyFormByUid(surveyData.UserId);
     //await dashboardService.UpdateDashboard(surveyData);
     return(Ok(surveyData));
 }
 /// <summary>
 /// Adds a new survey to the database
 /// </summary>
 /// <param name="newSurvey">Survey object with information about what to add. Only Id must be ommited</param>
 public void AddSurvey(SurveyData newSurvey)
 {
     if (newSurvey.Surveys.Rows.Count > 0)
     {
         SurveyFactory.Create().AddSurvey(newSurvey);
     }
 }
 /// <summary>
 /// Adds a new survey to the database
 /// </summary>
 /// <param name="newSurvey">Survey object with information about what to add. Only Id must be ommited</param>
 public void AddSurvey(SurveyData newSurvey)
 {
     if (newSurvey.Surveys.Rows.Count > 0)
     {
         SurveyFactory.Create().AddSurvey(newSurvey);
     }
 }
Exemple #7
0
        public void UpdateExcelUsingClosedXml(SurveyData surveyData)
        {
            using (var workbook = new XLWorkbook(excelFilePath))
            {
                var worksheet = workbook.Worksheets.Worksheet(1);

                var firstEmptyRow = worksheet.Worksheet.LastRowUsed().RowNumber() + 1;

                var columnIndex = 1;

                //set user id in first cell
                worksheet.Cell(firstEmptyRow, 1).Value = surveyData.UserId + firstEmptyRow;

                //set answers in rest of cells
                foreach (var answer in surveyData.Questions)
                {
                    columnIndex++;
                    worksheet.Cell(firstEmptyRow, columnIndex).Value = string.Join(", ", answer.SelectedAnswers.ToArray());
                }

                workbook.CalculateMode = XLCalculateMode.Auto;

                workbook.Save();
            }
        }
        public void Post([FromBody] SurveyData value)
        {
            var ip = new IpResolve(HttpContext).GetRequestIp();

            logger.Debug("Saving data: {0}...", ip);
            Save(ip, value);
        }
Exemple #9
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Email,YearsHere,Answer")] SurveyData surveyData)
        {
            if (id != surveyData.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(surveyData);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SurveyDataExists(surveyData.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(surveyData));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="folderId"></param>
        /// <returns></returns>
        public SurveyData GetAllSurveysByFolderId(int? folderId)
        {
            SurveyData surveyData = new SurveyData();

            DbConnection.db.LoadDataSet("vts_spSurveyGetListByFolderId", surveyData, new string[] { "Surveys" }, new SqlParameter("@FolderID", folderId).SqlValue);

            return surveyData;
        }
Exemple #11
0
        private void DisplaySurveyLoot(BasePlayer player, SurveyData data)
        {
            SendReply(player, "<color=" + GetConfig("Colors", "PrefixColor", player) + ">" + Lang("Prefix", player.UserIDString) + "</color>", null, Icon);

            foreach (KeyValuePair <int, SurveyItem> item in data.Items)
            {
                SendReply(player, "<color=" + GetConfig("Colors", "ResultsAmountColor", player) + ">" + item.Value.Amount + " x</color>" + " <color=" + GetConfig("Colors", "ResultResourseNameColor", player) + ">" + item.Value.DisplayName + "</color>", null, Icon);
            }
        }
Exemple #12
0
        /// <summary>
        /// Return a survey object that reflects the database poll
        /// </summary>
        /// <param name="surveyId">Id of the survey you need</param>
        /// <returns>A SurveyData dataset object with the current database values</returns>
        public SurveyData GetSurveyById(int surveyId, string languageCode)
        {
            SurveyData surveyById = SurveyFactory.Create().GetSurveyById(surveyId, languageCode);

            if (surveyById.Surveys.Rows.Count == 0)
            {
                throw new SurveyNotFoundException();
            }
            return(surveyById);
        }
        public async Task <List <Entity.Survey.Survey> > GetSurveys()
        {
            List <Entity.Survey.Survey> result = null;
            await Task.Run(() =>
            {
                result = SurveyData.Select(s => s.Value.Value).ToList();
            });

            return(result);
        }
        public async Task <Entity.Survey.Survey> CreateSurvey(Entity.Survey.Survey survey)
        {
            await Task.Run(() =>
            {
                survey.Id = ++LastSurveyId;
                SurveyData.TryAdd(survey.Id, new Lazy <Entity.Survey.Survey>(survey));
            });

            return(survey);
        }
 public IActionResult PostSurveyEntity([FromBody] SurveyData surveyData)
 {
     try
     {
         return(Ok(_logic.CreateSurvey(AdminId, surveyData)));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
 public IActionResult PutSurveyEntity([FromRoute] int surveyId, [FromBody] SurveyData surveyData)
 {
     try
     {
         return(Ok(_logic.UpdateSurvey(AdminId, surveyId, surveyData)));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
 private void Save(string ip, SurveyData value)
 {
     using (var client = cache.GetClient())
     {
         foreach (var localAuthority in value.Data.Where(item => item.Active).OrderBy(item => item.Code))
         {
             var line = $"{DateTime.Now},{ip},{value.PostCode},{value.Authority},{localAuthority.Code},{localAuthority.RatingOne},{localAuthority.RatingTwo}";
             client.AddItemToList("Survey:Results", line);
         }
     }
 }
Exemple #18
0
        public async Task <IActionResult> Create([Bind("FirstName,LastName,Email,YearsHere,Answer")] SurveyData surveyData)
        {
            if (ModelState.IsValid)
            {
                _context.Add(surveyData);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Survey)));
            }
            return(View(surveyData));
        }
Exemple #19
0
 public IActionResult Create(SurveyData results)
 {
     if (ModelState.IsValid)
     {
         return(View("Result", results));
     }
     else
     {
         return(View("Index"));
     }
 }
    public void LoadScore()
    {
        SurveyData data = SaveSystem.LoadScore(this);

        sp_score = data.sangatPuas;
        p_score  = data.puas;
        tp_score = data.tidakPuas;

        sp_Score.text = "" + sp_score;
        p_Score.text  = "" + p_score;
        tp_Score.text = "" + tp_score;
    }
Exemple #21
0
    public static void SaveScore(ButtonHandler buttonHandler)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/survey.chaedir";
        //string path = "C:/coba/" + "/survey.chaedir";
        FileStream stream = new FileStream(path, FileMode.Create);

        SurveyData data = new SurveyData(buttonHandler);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Exemple #22
0
        private void CreateSurveyButton_Click(object sender, System.EventArgs e)
        {
            // Creates a new entity and assign
            // the new values
            SurveyData surveyData = new SurveyData();

            SurveyData.SurveysRow surveyRow = surveyData.Surveys.NewSurveysRow();

            if (TitleTextBox.Text.Length == 0)
            {
                ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("MissingSurveyTitleMessage"));
                MessageLabel.Visible = true;
                return;
            }

            surveyRow.Title = TitleTextBox.Text;

            surveyRow.Activated           = false;
            surveyRow.Archive             = false;
            surveyRow.AccessPassword      = string.Empty;
            surveyRow.SurveyDisplayTimes  = 0;
            surveyRow.ResultsDisplayTimes = 0;
            surveyRow.SetOpenDateNull();
            surveyRow.SetCloseDateNull();
            surveyRow.CreationDate              = DateTime.Now;
            surveyRow.IPExpires                 = 1440;
            surveyRow.CookieExpires             = 1440;
            surveyRow.OnlyInvited               = false;
            surveyRow.Scored                    = false;
            surveyRow.QuestionNumberingDisabled = false;
            surveyRow.FolderId                  = ((PageBase)Page).SelectedFolderId;
            surveyRow.ProgressDisplayModeID     = (int)ProgressDisplayMode.PagerNumbers;
            surveyRow.ResumeModeID              = (int)ResumeMode.NotAllowed;
            surveyData.Surveys.AddSurveysRow(surveyRow);

            try
            {
                // Add the survey in the DB
                new Survey().AddSurvey(surveyData);
                AssignSurveyToUser(surveyData.Surveys[0].SurveyId);
                ((PageBase)Page).SurveyId      = surveyData.Surveys[0].SurveyId;
                ((Wap)Page.Master).isTreeStale = true;
                //This messes up the tree astructure etc so Stay where you are
                UINavigator.NavigateToSurveyBuilder(surveyRow.SurveyId, 4);
            }
            catch (SurveyExistsFoundException ex)
            {
                string x = ex.Message;
                ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("SurveyExistsInFolder"));
                MessageLabel.Visible = true;
            }
        }
Exemple #23
0
        public async Task UpdateDashboard(SurveyData surveyData)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://survey-dashboards.azurewebsites.net");
                var content = new StringContent(JsonConvert.SerializeObject(aggregationService.GetChartData(surveyData.FormName), new JsonSerializerSettings {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                }), Encoding.UTF8, "application/json");
                var result = await client.PostAsync("/questionnaire/", content);

                string resultContent = await result.Content.ReadAsStringAsync();
            }
        }
        public void UpdateSurveyAnswers(SurveyData surveyData, bool isSubmit = false)
        {
            if (surveyData == null)
            {
                return;
            }
            var surveyToUpdate = GetSurveyByUid(surveyData.UserId);

            surveyToUpdate.Answers   = JsonConvert.SerializeObject(surveyData);
            surveyToUpdate.Submitted = isSubmit;

            (dbContext as DbContext).SaveChanges();
        }
Exemple #25
0
        public void UpdateExcel(SurveyData surveyData)
        {
            //using Interop.Excel
            var excelApp       = new Application();
            var workbooks      = excelApp.Workbooks;
            var openedWorkbook = workbooks.Open(excelFilePath, 0, false, 5, "", "", true, XlPlatform.xlWindows, "\t",
                                                true, false, 0, true, 1, 0);
            var allWorksheets  = openedWorkbook.Worksheets;
            var firstWorksheet = (Worksheet)allWorksheets.get_Item(1);
            var worksheetCells = firstWorksheet.Cells;

            var rowIdx   = 0;
            var notEmpty = 1;

            while (notEmpty > 0)
            {
                var aCellAddress = "A" + (++rowIdx);
                var row          = excelApp.get_Range(aCellAddress, aCellAddress).EntireRow;
                notEmpty = (int)excelApp.WorksheetFunction.CountA(row);
            }

            //update actual data
            var columnIndex = 1;
            var cellGuid    = (Range)worksheetCells.Item[rowIdx, columnIndex];

            cellGuid.Value = surveyData.UserId;

            foreach (var answer in surveyData.Questions)
            {
                columnIndex++;
                var cellToUpdate = (Range)worksheetCells.Item[rowIdx, columnIndex];
                cellToUpdate.Value = string.Join(", ", answer.SelectedAnswers.ToArray());;
            }

            //force refresh of all formulas in document
            var worksheetsCount = allWorksheets.Count;

            for (var iWorksheet = 1; iWorksheet <= worksheetsCount; iWorksheet++)
            {
                var ws        = (Worksheet)allWorksheets.get_Item(iWorksheet);
                var usedRange = ws.UsedRange;
                usedRange.Formula = usedRange.Formula;
                ws.Calculate();
            }

            openedWorkbook.Save();
            workbooks.Close();
            excelApp.Quit();
        }
        public async Task <Entity.Survey.Survey> GetSurveyById(int id)
        {
            Lazy <Entity.Survey.Survey> survey = null;
            await Task.Run(() =>
            {
                SurveyData.TryGetValue(id, out survey);
            });

            if (survey != null)
            {
                return(survey.Value);
            }

            return(null);
        }
        public ActionResult UploadData()
        {
            if (Request.Files.Count > 0)
            {
                try
                {
                    SurveyData    surveyData    = new SurveyData();
                    SurveyDetails surveyDetails = new SurveyDetails();

                    HttpPostedFileBase file = Request.Files[0];

                    string fname;

                    if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                    {
                        string[] testfiles = file.FileName.Split(new char[] { '\\' });
                        fname = testfiles[testfiles.Length - 1];
                    }
                    else
                    {
                        fname = file.FileName;
                    }

                    var fname2 = Path.Combine(Server.MapPath("~/Uploads/"), fname);
                    file.SaveAs(fname2);

                    surveyDetails.Name      = Request.Form.Get("Name");
                    surveyDetails.Age       = Convert.ToInt16(Request.Form.Get("Age"));
                    surveyDetails.Gender    = Request.Form.Get("Gender");
                    surveyDetails.Email     = Request.Form.Get("Email");
                    surveyDetails.City      = Request.Form.Get("City");
                    surveyDetails.Resume    = fname;
                    surveyDetails.Education = Request.Form.Get("Education");

                    string id = surveyData.AddSurvey(surveyDetails);

                    return(Json(id));
                }
                catch (Exception ex)
                {
                    return(Json("Error occurred. Error details: " + ex.Message));
                }
            }
            else
            {
                return(Json("Data not entered."));
            }
        }
Exemple #28
0
        public void UpdateAnswers(SurveyData surveyData)
        {
            var isSubmitted      = repositories.SurveyRepository.GetSurveyStatus(surveyData.UserId);
            var isSurveyComplete = surveyData.Questions.All(q => q.SelectedAnswers.Any());

            if (isSubmitted)
            {
                return;
            }

            repositories.SurveyRepository.UpdateSurveyAnswers(surveyData, isSurveyComplete);

            if (isSurveyComplete)
            {
                excelService.UpdateExcelUsingClosedXml(surveyData);
            }
        }
Exemple #29
0
        public bool Run(SurveyTransferMessage message)
        {
            Tenant tenant = this.tenantStore.GetTenant(message.Tenant);

            this.surveySqlStore.Reset(tenant.SqlAzureConnectionString, message.Tenant, message.SlugName);

            Survey surveyWithQuestions = this.surveyStore.GetSurveyByTenantAndSlugName(message.Tenant, message.SlugName, true);

            IEnumerable <string> answerIds = this.surveyAnswerStore.GetSurveyAnswerIds(message.Tenant, surveyWithQuestions.SlugName);

            SurveyData surveyData = surveyWithQuestions.ToDataModel();

            foreach (var answerId in answerIds)
            {
                SurveyAnswer surveyAnswer = this.surveyAnswerStore.GetSurveyAnswer(surveyWithQuestions.Tenant, surveyWithQuestions.SlugName, answerId);

                var responseData = new ResponseData {
                    Id = Guid.NewGuid().ToString(), CreatedOn = surveyAnswer.CreatedOn
                };
                foreach (var answer in surveyAnswer.QuestionAnswers)
                {
                    QuestionAnswer answerCopy           = answer;
                    var            questionResponseData = new QuestionResponseData
                    {
                        QuestionId = (from question in surveyData.QuestionDatas
                                      where question.QuestionText == answerCopy.QuestionText
                                      select question.Id).FirstOrDefault(),
                        Answer = answer.Answer
                    };

                    responseData.QuestionResponseDatas.Add(questionResponseData);
                }

                if (responseData.QuestionResponseDatas.Count > 0)
                {
                    surveyData.ResponseDatas.Add(responseData);
                }
            }

            this.surveySqlStore.SaveSurvey(tenant.SqlAzureConnectionString, surveyData);

            return(true);
        }
 public void SaveSurvey(string connectionString, SurveyData surveyData)
 {
     this.ConnectionRetryPolicy.ExecuteAction(() =>
     {
         using (var dataContext = new SurveySqlDataContext(connectionString))
         {
             dataContext.SurveyDatas.InsertOnSubmit(surveyData);
             try
             {
                 this.CommandRetryPolicy.ExecuteAction(() => dataContext.SubmitChanges());
             }
             catch (SqlException ex)
             {
                 TraceHelper.TraceError(ex.TraceInformation());
                 throw;
             }
         }
     });
 }
 public void SaveSurvey(string connectionString, SurveyData surveyData)
 {
     this.ConnectionRetryPolicy.ExecuteAction(() =>
     {
         using (var dataContext = new SurveySqlDataContext(connectionString))
         {
             dataContext.SurveyDatas.InsertOnSubmit(surveyData);
             try
             {
                 this.CommandRetryPolicy.ExecuteAction(() => dataContext.SubmitChanges());
             }
             catch (SqlException ex)
             {
                 TraceHelper.TraceError(ex.TraceInformation());
                 throw;
             }
         }
     });
 }
Exemple #32
0
 /// <summary>
 /// Ctor: init immutable instance (when putting data into storage).
 /// </summary>
 public StoredResult(string countryCode, DateTime date,
                     int prevQuizCount, int prevSurveyCount, int score,
                     string encodedResult, SurveyData surveyData)
 {
     CountryCode     = countryCode;
     Date            = date;
     PrevQuizCount   = prevQuizCount;
     PrevSurveyCount = prevSurveyCount;
     Score           = score;
     EncodedResult   = encodedResult;
     // Fill key-value map by reflecting on surveyData instance
     foreach (FieldInfo fi in typeof(SurveyData).GetFields(BindingFlags.Public | BindingFlags.Instance))
     {
         string val = fi.GetValue(surveyData) as string;
         if (val == null || val == string.Empty)
         {
             continue;
         }
         survey[fi.Name] = val;
     }
 }
Exemple #33
0
    public static SurveyData LoadScore(ButtonHandler buttonHandler)
    {
        //string path = "C:/coba/" + "/survey.chaedir";
        string path = Application.persistentDataPath + "/survey.chaedir";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            SurveyData data = formatter.Deserialize(stream) as SurveyData;
            stream.Close();

            return(data);
        }
        else
        {
            //buttonHandler.warning.text = "Data tidak ditemukan";
            return(null);
        }
    }
 /// <summary>
 /// Get all surveys that have been flaged as archived
 /// </summary>
 public SurveyData GetArchivedSurveys()
 {
     SurveyData surveyData = new SurveyData();
    DbConnection.db.LoadDataSet("vts_spSurveysGetArchive", surveyData, new string[] { "Surveys" });
     return surveyData;
 }
        /// <summary>
        /// Update the database with the given survey
        /// </summary>
        /// <param name="updatedSurvey">survey to update, must contain the surveyid</param>
        public void UpdateSurvey(SurveyData updatedSurvey, string languageCode)
        {
            try
            {
                SqlConnection dbConnection = new SqlConnection(DbConnection.NewDbConnectionString);
                SqlCommand updateSurvey = new SqlCommand("vts_spSurveyUpdate", dbConnection);
                updateSurvey.CommandType = CommandType.StoredProcedure;

                updateSurvey.Parameters.AddWithValue("@LanguageCode", languageCode);
                updateSurvey.Parameters.Add("@SurveyID", SqlDbType.Int, 4, "SurveyID");
                updateSurvey.Parameters.Add(new SqlParameter("@OpenDate", SqlDbType.DateTime, 8, "OpenDate"));
                updateSurvey.Parameters.Add(new SqlParameter("@CloseDate", SqlDbType.DateTime, 8, "CloseDate"));
                updateSurvey.Parameters.Add("@Title", SqlDbType.NVarChar, 255, "Title");
                updateSurvey.Parameters.Add("@ThankYouMessage", SqlDbType.NVarChar, 4000, "ThankYouMessage");
                updateSurvey.Parameters.Add("@RedirectionURL", SqlDbType.NVarChar, 1024, "RedirectionURL");
                updateSurvey.Parameters.Add("@Archive", SqlDbType.Bit, 1, "Archive");
                updateSurvey.Parameters.Add("@Activated", SqlDbType.Bit, 1, "Activated");
                updateSurvey.Parameters.Add("@ResumeModeID", SqlDbType.Int, 1, "ResumeModeID");
                updateSurvey.Parameters.Add("@NavigationEnabled", SqlDbType.Bit, 1, "NavigationEnabled");
                updateSurvey.Parameters.Add("@ProgressDisplayModeId", SqlDbType.Int, 4, "ProgressDisplayModeId");
                updateSurvey.Parameters.Add("@NotificationModeId", SqlDbType.Int, 4, "NotificationModeId");
                updateSurvey.Parameters.Add("@Scored", SqlDbType.Bit, 1, "Scored");
                updateSurvey.Parameters.Add("@QuestionNumberingDisabled", SqlDbType.Bit, 1, "QuestionNumberingDisabled");
                updateSurvey.Parameters.Add("@DefaultSurvey", SqlDbType.Bit, 1, "DefaultSurvey");

                DbConnection.db.UpdateDataSet(updatedSurvey, "Surveys", updateSurvey, updateSurvey, new SqlCommand(), UpdateBehavior.Transactional);
            }
            catch (SqlException ex)
            {
                if (ex.Message == "DUPLICATEFOLDER") throw new SurveyExistsFoundException();
                throw;
            }

            if ((NotificationMode)updatedSurvey.Surveys[0].NotificationModeID != NotificationMode.None)
            {
                //SqlParameter[] spParameters = new SqlParameter[4];
                //spParameters[0] = new SqlParameter("@SurveyId", updatedSurvey.Surveys[0].SurveyId);
                //spParameters[1] = new SqlParameter("@EmailFrom", updatedSurvey.Surveys[0].EmailFrom);
                //spParameters[2] = new SqlParameter("@EmailTo", updatedSurvey.Surveys[0].EmailTo);
                //spParameters[3] = new SqlParameter("@EmailSubject", updatedSurvey.Surveys[0].EmailSubject);

                ArrayList sqlParams = new ArrayList();
                {
                    sqlParams.Add(new SqlParameter("@SurveyId", updatedSurvey.Surveys[0].SurveyId).SqlValue);
                    sqlParams.Add(new SqlParameter("@EmailFrom", updatedSurvey.Surveys[0].EmailFrom).SqlValue);
                    sqlParams.Add(new SqlParameter("@EmailTo", updatedSurvey.Surveys[0].EmailTo).SqlValue);
                    sqlParams.Add(new SqlParameter("@EmailSubject", updatedSurvey.Surveys[0].EmailSubject).SqlValue);
                }

               DbConnection.db.ExecuteNonQuery("vts_spEmailNotificationSettingsAddNew", sqlParams.ToArray());
            }
            else
            {
                //SqlParameter[] spParameters = new SqlParameter[4];
                //spParameters[0] = new SqlParameter("@SurveyId", updatedSurvey.Surveys[0].SurveyId);

                ArrayList sqlParams = new ArrayList();
                {
                    sqlParams.Add(new SqlParameter("@SurveyId", updatedSurvey.Surveys[0].SurveyId).SqlValue);
                }

                DbConnection.db.ExecuteNonQuery("vts_spEmailNotificationSettingsDelete", sqlParams.ToArray());
            }
        }
 // Use this for initialization
 void Start()
 {
     gl = (GameLogic)FindObjectOfType(typeof(GameLogic));
     surveyData = new SurveyData();
 }
        private void CreateSurveyButton_Click(object sender, System.EventArgs e)
        {
            // Creates a new entity and assign
            // the new values
            SurveyData surveyData = new SurveyData();
            SurveyData.SurveysRow surveyRow = surveyData.Surveys.NewSurveysRow();

            if (TitleTextBox.Text.Length == 0)
            {
                ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("MissingSurveyTitleMessage"));
                MessageLabel.Visible = true;
                return;
            }

            surveyRow.Title = TitleTextBox.Text;

            surveyRow.Activated = false;
            surveyRow.Archive = false;
            surveyRow.AccessPassword = string.Empty;
            surveyRow.SurveyDisplayTimes = 0;
            surveyRow.ResultsDisplayTimes = 0;
            surveyRow.SetOpenDateNull();
            surveyRow.SetCloseDateNull();
            surveyRow.CreationDate = DateTime.Now;
            surveyRow.IPExpires = 1440;
            surveyRow.CookieExpires = 1440;
            surveyRow.OnlyInvited = false;
            surveyRow.Scored = false;
            surveyRow.QuestionNumberingDisabled = false;
            surveyRow.FolderId = ((PageBase)Page).SelectedFolderId;
            surveyRow.ProgressDisplayModeID = (int)ProgressDisplayMode.PagerNumbers;
            surveyRow.ResumeModeID = (int)ResumeMode.NotAllowed;
            surveyData.Surveys.AddSurveysRow(surveyRow);

            try
            {
                // Add the survey in the DB
                new Survey().AddSurvey(surveyData);
                AssignSurveyToUser(surveyData.Surveys[0].SurveyId);
                ((PageBase)Page).SurveyId = surveyData.Surveys[0].SurveyId;
                ((Wap)Page.Master).isTreeStale = true;
                //This messes up the tree astructure etc so Stay where you are
                UINavigator.NavigateToSurveyBuilder(surveyRow.SurveyId, 4);
            }
            catch (SurveyExistsFoundException ex)
            {
                string x = ex.Message;
                ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("SurveyExistsInFolder"));
                MessageLabel.Visible = true;
            }
        }
        /// <summary>
        /// Apply the survey data changes to the DB
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ApplyChangesButton_Click(object sender, System.EventArgs e)
        {
            if (OpeningDateTextBox.Text.Length != 0 &&
                !Information.IsDate(OpeningDateTextBox.Text))
            {
                ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("InvalidOpeningDate"));
                MessageLabel.Visible = true;
                return;
            }

            if (CloseDateTextbox.Text.Length != 0 &&
                !Information.IsDate(CloseDateTextbox.Text))
            {
                ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("InvalidClosingDate"));
                MessageLabel.Visible = true;
                return;
            }

            if (((NotificationMode)int.Parse(EntryNotificationDropdownlist.SelectedValue)) !=
                NotificationMode.None)
            {
                if (EmailFromTextbox.Text.Length == 0 || !((PageBase)Page).isEmail(EmailFromTextbox.Text))
                {
                    ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("InvalidFromEmail"));
                    MessageLabel.Visible = true;
                    return;
                }

                if (EmailToTextBox.Text.Length == 0 || !((PageBase)Page).isEmail(EmailToTextBox.Text))
                {
                    ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("InvalidToEmail"));
                    MessageLabel.Visible = true;
                    return;
                }
                NotificationPlaceHolder.Visible = true;
            }
            else
            {
                EmailFromTextbox.Text = string.Empty;
                EmailToTextBox.Text = string.Empty;
                EmailSubjectTextbox.Text = string.Empty;
                NotificationPlaceHolder.Visible = false;
            }

            try
            {
                // Creates a new entity and assign
                // the updated values
                SurveyData surveyData = new SurveyData();
                SurveyData.SurveysRow surveyRow = surveyData.Surveys.NewSurveysRow();
                surveyRow.SurveyId = SurveyId;
                surveyRow.Title = TitleTextBox.Text;
                surveyRow.Activated = ActiveCheckBox.Checked;
                surveyRow.Archive = ArchiveCheckBox.Checked;
                surveyRow.Scored = ScoredCheckbox.Checked;
                surveyRow.QuestionNumberingDisabled = QuestionNumberingCheckbox.Checked;
                surveyRow.NavigationEnabled = EnableNavigationCheckbox.Checked;
                surveyRow.ResumeModeID = int.Parse(ResumeModeDropdownlist.SelectedValue);
                surveyRow.ProgressDisplayModeID = int.Parse(ProgressDisplayDropDownList.SelectedValue);
                surveyRow.NotificationModeID = int.Parse(EntryNotificationDropdownlist.SelectedValue);
                surveyRow.DefaultSurvey = DefaultSurveyCheckBox.Checked;
                surveyRow.ThankYouMessage = ViewState["ThanksMessage"] == null ?
                    null : ViewState["ThanksMessage"].ToString();
                if (((NotificationMode)surveyRow.NotificationModeID) !=
                    NotificationMode.None)
                {
                    surveyRow.EmailFrom = EmailFromTextbox.Text;
                    surveyRow.EmailTo = EmailToTextBox.Text;
                    surveyRow.EmailSubject = EmailSubjectTextbox.Text;
                }

                if (OpeningDateTextBox.Text.Length != 0)
                {
                    surveyRow.OpenDate = DateTime.Parse(OpeningDateTextBox.Text);
                }
                if (CloseDateTextbox.Text.Length != 0)
                {
                    surveyRow.CloseDate = DateTime.Parse(CloseDateTextbox.Text);
                }
                surveyData.Surveys.AddSurveysRow(surveyRow);

                // Update the DB
                new Survey().UpdateSurvey(surveyData, "");

                ((PageBase)Page).ShowNormalMessage(MessageLabel, ((PageBase)Page).GetPageResource("SurveyUpdatedMessage"));
                MessageLabel.Visible = true;

                ((Wap)this.Page.Master.Master).isTreeStale = true;
                ((Wap)this.Page.Master.Master).RebuildTree();

                // Let the subscribers know that something changed
                OnOptionChanged();
            }

            catch (SurveyExistsFoundException ex)
            {
                ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("SurveyExistsInFolder"));
                MessageLabel.Visible = true;
            }
        }
        /// <summary>
        /// Return a survey object that reflects the database survey
        /// </summary>
        /// <param name="surveyId">Id of the survey you need</param>
        /// <returns>A survey object with the current database values</returns>
        public SurveyData GetSurveyById(int surveyId, string languageCode)
        {
            //SqlParameter[] spParameters = new SqlParameter[2];
            //spParameters[0] = new SqlParameter("@SurveyId", surveyId);

            //spParameters[0] = new SqlParameter();
            //spParameters[0].ParameterName = "@SurveyId";
            //spParameters[0].SqlDbType = SqlDbType.Variant;
            //spParameters[0].Value = surveyId;


            //spParameters[1] = new SqlParameter("@LanguageCode", languageCode);

            //spParameters[1] = new SqlParameter();
            //spParameters[1].ParameterName = "@LanguageCode";
            //spParameters[1].SqlDbType = SqlDbType.NVarChar;
            //spParameters[1].IsNullable = true;
            //spParameters[1].Value = languageCode ?? (object)DBNull.Value;


            ArrayList sqlParams = new ArrayList();
            {
                sqlParams.Add(new SqlParameter("@SurveyId", Convert.ToInt32(surveyId)).SqlValue);
                sqlParams.Add(new SqlParameter("@LanguageCode", languageCode ?? (object)DBNull.Value).SqlValue);
            }

            SurveyData surveyData = new SurveyData();
           DbConnection.db.LoadDataSet("vts_spSurveyGetDetails", surveyData, new string[] { "Surveys" }, sqlParams.ToArray());
            return surveyData;
        }
        /// <summary>
        /// Get a survey list assigned to the user
        /// </summary>
        /// <returns></returns>
        public SurveyData GetAssignedSurveysList(int userId)
        {
            SurveyData surveyData = new SurveyData();

           DbConnection.db.LoadDataSet("vts_spSurveyGetAssignedListForUser", surveyData, new string[] { "Surveys" }, new SqlParameter("@UserId", userId).SqlValue);
            return surveyData;
        }
 /// <summary>
 /// Get a survey list with only the survey id and title
 /// </summary>
 /// <returns></returns>
 public SurveyData GetAllSurveysList()
 {
     SurveyData surveyData = new SurveyData();
    DbConnection.db.LoadDataSet("vts_spSurveyGetList", surveyData, new string[] { "Surveys" });
     return surveyData;
 }
        /// <summary>
        /// Get a survey list with only the survey id and title with matching title
        /// </summary>
        /// <returns></returns>
        public SurveyData GetAllSurveysByTitle(string title, int? folderID, int userID)
        {

            //SqlCommand command = new SqlCommand("vts_spSurveyGetListByTitle");
            //command.CommandType = CommandType.StoredProcedure;
                        
            SurveyData surveyData = new SurveyData();

            //SqlParameter[] spParameters = new SqlParameter[3];
            //spParameters[0] = command.Parameters.AddWithValue("@SurveyTitle", title);
            //spParameters[1] = command.Parameters.AddWithValue("@FolderId", folderID);
            //spParameters[2] = command.Parameters.AddWithValue("@UserId", userID);

            //spParameters[0] = new SqlParameter("@SurveyTitle", title);
            //spParameters[1] = new SqlParameter("@FolderId", folderID);
            //spParameters[2] = new SqlParameter("@UserId", userID);

            ArrayList sqlParams = new ArrayList();
            {
                sqlParams.Add(new SqlParameter("@SurveyTitle", title).SqlValue);
                sqlParams.Add(new SqlParameter("@FolderId", folderID).SqlValue);
                sqlParams.Add(new SqlParameter("@UserId", userID).SqlValue);
            }

           DbConnection.db.LoadDataSet("vts_spSurveyGetListByTitle", surveyData, new string[] { "Surveys" }, sqlParams.ToArray());
            //db.LoadDataSet("vts_spSurveyGetListByTitle", surveyData, new string[] { "Surveys" }, spParameters);
            return surveyData;
        }
 /// <summary>
 /// Clone the given survey and returns its clone
 /// </summary>
 /// <param name="surveyId">Id of the survey you want to clone</param>
 /// <returns>A SurveyData dataset object with the current database values of the clone</returns>
 public SurveyData CloneSurvey(int surveyId)
 {
     SurveyData surveyData = new SurveyData();
    DbConnection.db.LoadDataSet("vts_spSurveyClone", surveyData, new string[] { "Surveys" }, new SqlParameter("@SurveyID", surveyId).SqlValue);
     return surveyData;
 }
 /// <summary>
 /// Return a survey object that reflects the current activated survey. 
 /// IE: The survey that shows up when the surveybox has a surveyid value of 
 /// 0
 /// </summary>
 /// <returns>A survey object with the current database values</returns>
 public SurveyData GetActivatedSurvey()
 {
     SurveyData surveyData = new SurveyData();
    DbConnection.db.LoadDataSet("vts_spSurveyGetActivated", surveyData, new string[] { "Surveys" });
     return surveyData;
 }
 /// <summary>
 /// Update the database with the given survey
 /// </summary>
 /// <param name="updatedSurvey">survey to update, must contain the surveyid</param>
 public void UpdateSurvey(SurveyData updatedSurvey, string languageCode)
 {
     SurveyFactory.Create().UpdateSurvey(updatedSurvey, languageCode);
 }
Exemple #46
0
 public void StartWork(Vector3 point)
 {
     position = point;
     pendingDataGather = true;
     surveyData = new SurveyData(point,loadSurveyPlane);
 }
        /// <summary>
        /// Adds a new survey to the database
        /// </summary>
        /// <param name="newSurvey">Survey object with information about what to add. Only Id must be ommited</param>
        public void AddSurvey(SurveyData newSurvey)
        {

            try
            {
                SqlConnection dbConnection = new SqlConnection(DbConnection.NewDbConnectionString);
                SqlCommand addNewSurvey = GetInsertSurveyCommand(dbConnection, null);
               //SqlHelper.UpdateDataset(addNewSurvey, new SqlCommand(), new SqlCommand(), newSurvey, "Surveys", true);
               DbConnection.db.UpdateDataSet(newSurvey, "Surveys", addNewSurvey, new SqlCommand(), new SqlCommand(), UpdateBehavior.Transactional );
            }
            catch (SqlException ex)
            {
                if (ex.Message == "DUPLICATEFOLDER") throw new SurveyExistsFoundException();
                throw;
            }
        }