home | products | customer | support | forums | contact
Sign in | Join |
in
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 04-22-2010 12:16

    Create a new Voter

    Hi, I need to save the data from a "custom form", generated by an xml. example: Simon White so I wrote the following code: Surveys FSForm surveyForm = new (). GetFormForExport (surveyID, false, false); DataTable dt = surveyForm.Answer; foreach (XmlNode xField in xDoc.SelectNodes (/ FORM / FIELDS / FIELD ")) ( DataRow [] dr = dt.Select (AnswerText = '"xField.Attributes [" NAME "]. "'"); Value if (dr.Length> 0) ( ansID string = dr [0] ["RefAnswerId"]. ToString (); VoterAnswersData.VotersAnswersRow respondentAnswer answerRespondent.VotersAnswers.NewVotersAnswersRow = (); respondentAnswer.AnswerId = int.Parse (ansID); respondentAnswer.VoterId = ?????? respondentAnswer.SectionNumber = ???????; respondentAnswer.AnswerText = xField.FirstChild.InnerText; answerRespondent.VotersAnswers.AddVotersAnswersRow (respondentAnswer); ) ) The problem is that I do not know how to create a new voter and so save the data entered in form. I hope in your help Thanks a lot Simone
  • 04-23-2010 4:00 In reply to

    • Tom
    • Top 10 Contributor
    • Joined on 05-19-2007
    • Switzerland
    • Data Illusion

    Re: Create a new Voter

    Hi Simone,

    do you want to add new respondent entries to an existing form in the db is that correct ?

  • 04-23-2010 4:09 In reply to

    Re: Create a new Voter

    Hi Tom, Yes, I want to add new entries of a survey present in the db. I create the FSxml of the survey, I transform the FSxml into a customXML to be played by Flash. So I need to recreate the Submit button to save the data entered. Thanks a lot Simone
  • 04-23-2010 4:41 In reply to

    • Tom
    • Top 10 Contributor
    • Joined on 05-19-2007
    • Switzerland
    • Data Illusion

    Re: Create a new Voter

    Hi,

    you can't go through xml since there isnt a way in FS that would allow you to reimport an xml just to store respondent answers.

    What you will need to do is a web service that will get the values from your flash application and then use following code to create a new entry :

    // Creates a new voter identity
    VoterAnswersData.VotersRow voter = voterAnswers.Voters.NewVotersRow();
    voter.SurveyId = yoursurveyid;
    voter.StartDate = datesurveystarted;
    voter.VoteDate = dateofresponses;
    voter.IPSource = ipofrespondent;
    voter.LanguageCode = languageofrespondentl;
    voter.Validated = true;
    voterAnswers.Voters.AddVotersRow(voter);
     

    and then for each of the answer you want to store for that respondent

    VoterAnswersData.VotersAnswersRow voterAnswer = voterAnswers.VotersAnswers.NewVotersAnswersRow();
    voterAnswer.VoterId = voter.VoterId;
    voterAnswer.QuestionId = -1;
    voterAnswer.SectionNumber = 0;
    voterAnswer.AnswerId = answeridthathasbeenanswered;
    voterAnswer.AnswerText = iftextfromatextboxotherwiseleavenull;
    voterAnswers.VotersAnswers.AddVotersAnswersRow(voterAnswer);


    and finally store everything in the db :
    new Voter().AddVoter(voterAnswers);

    While I am not proficient with flash I believe that you could get the VoterAnswersData xml / xsd definition through the WSDL once you have setup your web service using .net and then setup everything directly from your flash code and have a simple web service method like this on the .net side :

    [WebMethod]
    public void AddVoter(VoterAnswersData voterAnswers)
    {
    new Voter().AddVoter(voterAnswers);
    }

    if you want to do it through REST you will need to download the REST toolkit of Microsoft to generate REST compatible code.

  • 04-26-2010 5:59 In reply to

    Re: Create a new Voter

    Hi Tom, This works perfectly! thanks a lot! I noticed that saving data in this way, the server-side validation does not work. I can recall the validation through the code? Thanks a lot I hope in your help Simone
  • 04-26-2010 9:18 In reply to

    • Tom
    • Top 10 Contributor
    • Joined on 05-19-2007
    • Switzerland
    • Data Illusion

    Re: Create a new Voter

    Hi Simone,

    its not possible to recall validation through the code at the moment since its managed directly by the answer item instances web control when there are displayed, the next version of the framework should support "external" validation but at the moment its unfortunately not possible to reuse the answer items validations based on a current set of answers.

  • 06-07-2010 4:32 In reply to

    • spotvice29
    • Not Ranked
      Male
    • Joined on 05-21-2010
    • Mountain View California

    Just want to ask

     hi can I just join a little bit if you dont mind. . .

     Is this code is tested?? can it mix with PHP script with out error??

     Thanks

    Advice 

  • 06-07-2010 14:06 In reply to

    • Tom
    • Top 10 Contributor
    • Joined on 05-19-2007
    • Switzerland
    • Data Illusion

    Re: Just want to ask

    Hi,

    FeedbackServer only support .net based application integration PHP is not supported.

Page 1 of 1 (8 items)
(c) 2008 Data Illusion. All Rights Reserved.