static void Main() { // Example of using the Nfield SDK with a user defined IoC container. // In most cases the IoC container is created and managed through the application. using (IKernel kernel = new StandardKernel()) { InitializeNfield(kernel); const string serverUrl = "http://*****:*****@"*QUESTION 1 *CODES 61L1 Do you watch TV? 1:Yes 2:No *END" }; var updatedScript = surveyScriptService.PostAsync("surveyWithOdinScriptId", myScript).Result; // Upload survey script with file path var scriptFilePath = @"C:\SimpleQ.odin"; var myUpdatedScript = surveyScriptService.PostAsync("surveyWithOdinScriptId", scriptFilePath).Result; // Create survey var newSurvey = surveysService.AddAsync(new Survey(SurveyType.Basic) { ClientName = "clientName", Description = "description", SurveyName = "abc" }).Result; surveyScriptService.PostAsync(newSurvey.SurveyId, myScript).Wait(); var surveyFieldworkService = connection.GetService <INfieldSurveyFieldworkService>(); //Get survey fieldwork status var surveyFieldworkStatus = surveyFieldworkService.GetStatusAsync(newSurvey.SurveyId).Result; //Should be under construction // Start the fieldwork for the survey surveyFieldworkService.StartFieldworkAsync(newSurvey.SurveyId).Wait(); surveyFieldworkStatus = surveyFieldworkService.GetStatusAsync(newSurvey.SurveyId).Result; //Should be started // Example of a download data request: filtering testdata collected today var surveyDataService = connection.GetService <INfieldSurveyDataService>(); var myRequest = new SurveyDownloadDataRequest { DownloadSuccessfulLiveInterviewData = false, DownloadNotSuccessfulLiveInterviewData = false, DownloadOpenAnswerData = true, DownloadClosedAnswerData = true, DownloadSuspendedLiveInterviewData = false, DownloadCapturedMedia = false, DownloadParaData = false, DownloadTestInterviewData = true, DownloadFileName = "MyFileName", StartDate = DateTime.Today.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture), // UTC time start of today EndDate = DateTime.Today.AddDays(1).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture), // UTC time end of today SurveyId = "SomeSurveyId" }; var task = surveyDataService.PostAsync(myRequest).Result; // request the background tasks service var backgroundTasksService = connection.GetService <INfieldBackgroundTasksService>(); // Example of performing operations on background tasks. var backgroundTaskQuery = backgroundTasksService.QueryAsync().Result.Where(s => s.Id == task.Id); var mybackgroundTask = backgroundTaskQuery.FirstOrDefault(); if (mybackgroundTask != null) { var status = mybackgroundTask.Status; } // Example of creating a new translation const string surveyName = "Language"; const string languageName = "Dutch"; const string translationName = "ButtonNext"; const string translationText = "Volgende"; // First create the survey if it does not exist var languageSurvey = surveysService.QueryAsync().Result .SingleOrDefault(s => s.SurveyName == surveyName); if (languageSurvey == null) { languageSurvey = surveysService.AddAsync( new Survey(SurveyType.Basic) { SurveyName = surveyName }).Result; } // Then find the language we wish to change a translation for var languageService = connection.GetService <INfieldLanguagesService>(); var language = languageService.QueryAsync(languageSurvey.SurveyId) .Result.SingleOrDefault(l => l.Name == languageName); if (language == null) { language = languageService.AddAsync(languageSurvey.SurveyId, new Language { Name = languageName }).Result; } // Now add or update a translation var translationsService = connection.GetService <INfieldTranslationsService>(); var translation = translationsService.QueryAsync(languageSurvey.SurveyId, language.Id).Result.SingleOrDefault(t => t.Name == translationName); if (translation == null) { translationsService.AddAsync(languageSurvey.SurveyId, language.Id, new Translation { Name = translationName, Text = translationText }).Wait(); } else { translation.Text = translationText; translationsService.UpdateAsync(languageSurvey.SurveyId, language.Id, translation).Wait(); } } }
/// <summary> /// Constructor. /// </summary> public NfieldSamplingPointManagement(INfieldSurveysService surveysService) { _surveysService = surveysService; }
/// <summary> /// A synchronous version of <see cref="INfieldSurveysService.SamplingPointImageAddAsync(string, string, string, byte[])"/> /// </summary> public static void SamplingPointImageAdd(this INfieldSurveysService surveysService, string surveyId, string samplingPointId, string filename, byte[] content) { surveysService.SamplingPointImageAddAsync(surveyId, samplingPointId, filename, content).Wait(); }
/// <summary> /// Constructor. /// </summary> public NfieldSamplingPointManagement(INfieldSurveysService surveysService) { _surveysService = surveysService; }
/// <summary> /// A synchronous version of <see cref="INfieldSurveysService.SamplingPointImageAddAsync(string, string, string)"/> /// </summary> public static void SamplingPointImageAdd(this INfieldSurveysService surveysService, string surveyId, string samplingPointId, string filePath) { surveysService.SamplingPointImageAddAsync(surveyId, samplingPointId, filePath).Wait(); }
/// <summary> /// A synchronous version of <see cref="INfieldSurveysService.SamplingPointUpdateAsync"/> /// </summary> public static void SamplingPointUpdate(this INfieldSurveysService surveysService, string surveyId, SamplingPoint samplingPoint) { surveysService.SamplingPointUpdateAsync(surveyId, samplingPoint).Wait(); }
/// <summary> /// A synchronous version of <see cref="INfieldSurveysService.SamplingPointQueryAsync"/> /// </summary> /// <param name="surveysService"></param> /// <param name="surveyId"></param> /// <param name="samplingPointId"></param> /// <returns></returns> public static SamplingPoint SamplingPointQuery(this INfieldSurveysService surveysService, string surveyId, string samplingPointId) { return(surveysService.SamplingPointQueryAsync(surveyId, samplingPointId).Result); }
/// <summary> /// A synchronous version of <see cref="INfieldSurveysService.SamplingPointsQueryAsync"/> /// </summary> public static IQueryable <SamplingPoint> SamplingPointsQuery(this INfieldSurveysService surveysService, string surveyId) { return(surveysService.SamplingPointsQueryAsync(surveyId).Result); }
/// <summary> /// A synchronous version of <see cref="INfieldSurveysService.QueryAsync"/> /// </summary> public static IQueryable <Survey> Query(this INfieldSurveysService surveysService) { return(surveysService.QueryAsync().Result); }