/// <summary> /// Allows you to initialize all necessary data members and triggers sending process. /// </summary> /// <param name="surveyId">Survey identification number.</param> /// <param name="resultInfo">Instance of <see cref="ResultBasicInfo"/> class. Result you want to send.</param> public void Send(string surveyId, ResultBasicInfo resultInfo) { Survey survey = new Survey(); survey.Id = surveyId; survey.ResultInfo = resultInfo; _resultId = resultInfo.Id; Send(survey.GetSavedDocument()); }
/// <summary> /// Initializes all data members. Allows to set parent survey. /// </summary> /// <param name="parent"><see cref="Survey"/> instance that category belongs to.</param> public NormalCategory(Survey parent) { Parent = parent; Questions = new List<Question>(); }
/// <summary> /// Initializes all data members. Allows to set parent survey. /// </summary> /// <param name="parent"><see cref="Survey"/> instance that category belongs to.</param> public ConditionCategory(Survey parent) { Parent = parent; QuestionsTemplate = new List<Question>(); SubCategories = new ObservableCollection<NormalCategory>(); }
/// <summary> /// Initializes all data members. Allows to set parent survey. /// </summary> /// <param name="parent"><see cref="Survey"/> instance that category belongs to.</param> public ConditionCategory(Survey parent) { Parent = parent; QuestionsTemplate = new List <Question>(); SubCategories = new ObservableCollection <NormalCategory>(); }
/// <summary> /// Constructor which initializes Survey property and displays idSurvey survey. /// </summary> /// <param name="idSurvey">Survey ID which will be displayed in preview.</param> public PreviewSurveyViewModel(string idSurvey) { Survey = new Survey(); Survey.Display(Convert.ToInt32(idSurvey)); ProgressBar = new ProcessingBar(); }
private void SavetTestResult(Survey survey, XDocument documentXML) { String dataToSave; if ((bool)OperationsOnSettings.Instance.IsEncryptionEnabled) { AESEncryption encrypter = new AESEncryption(); dataToSave = encrypter.Encrypt(documentXML.ToString(), App.AppDictionary["EncryptionPassword"] as String, "qwhmvbzx"); } else { dataToSave = documentXML.ToString(); } using (IsolatedStorageFile isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) { String directoryPath = String.Format("surveys/{0}", survey.Id); string resultFilePath = System.IO.Path.Combine(directoryPath, String.Format("r_{0}.xml", survey.ResultInfo.Id)); if (!isolatedStorage.DirectoryExists(directoryPath)) { isolatedStorage.CreateDirectory(directoryPath); } using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(resultFilePath, FileMode.Create, isolatedStorage)) { StreamWriter writer = new StreamWriter(isoStream); writer.Write(dataToSave); writer.Close(); } } OperationsOnListOfResults operationsOnListOfResults = new OperationsOnListOfResults(SurveyId); operationsOnListOfResults.Add(survey.ResultInfo); }
/// <summary> /// Method to prepare new results with right date and GPS location. /// </summary> public void PreapreResultsForTests() { DateOperations operationsOnDate = new DateOperations(); // Wynik 1_1: Data utworzenia: 2/2/2010, szerokość: 52, długość: 21 (Warszawa) Survey survey = new Survey(); survey.Display(Convert.ToInt32(SurveyId)); survey.ResultInfo.Title = "test1"; survey.ResultInfo.Latitude = "52"; survey.ResultInfo.Longitude = "21"; XDocument documentXML = survey.PrepareResultDocument(); survey.ResultInfo.Time = operationsOnDate.DateTimeToMiliseconds(new DateTime(2010, 2, 2)).ToString(); SavetTestResult(survey, documentXML); // Wynik 1_2: Data utworzenia: 2/24/2010, bez GPS Survey survey1 = new Survey(); survey1.Display(Convert.ToInt32(SurveyId)); survey1.ResultInfo.Title = "test2"; XDocument documentXML1 = survey1.PrepareResultDocument(); survey1.ResultInfo.Time = operationsOnDate.DateTimeToMiliseconds(new DateTime(2010, 2, 24)).ToString(); if (documentXML1.Element("latitude") != null) documentXML1.Element("latitude").Remove(); if (documentXML1.Element("longitude") != null) documentXML1.Element("longitude").Remove(); SavetTestResult(survey1, documentXML1); // Wynik 1_3: Data utworzenia: 5/10/2010, szerokość: 50, długość: 20 (Kraków) Survey survey2 = new Survey(); survey2.Display(Convert.ToInt32(SurveyId)); survey2.ResultInfo.Title = "test3"; survey2.ResultInfo.Latitude = "50"; survey2.ResultInfo.Longitude = "20"; XDocument documentXML2 = survey2.PrepareResultDocument(); survey2.ResultInfo.Time = operationsOnDate.DateTimeToMiliseconds(new DateTime(2010, 5, 10)).ToString(); SavetTestResult(survey2, documentXML2); // Wynik 2_1: Data utworzenia: 2/2/2011, szerokość: 50, długość: 19 (Katowice) Survey survey3 = new Survey(); survey3.Display(Convert.ToInt32(SurveyId)); survey3.ResultInfo.Title = "test4"; survey3.ResultInfo.Latitude = "50"; survey3.ResultInfo.Longitude = "19"; XDocument documentXML3 = survey3.PrepareResultDocument(); survey3.ResultInfo.Time = operationsOnDate.DateTimeToMiliseconds(new DateTime(2011, 2, 2)).ToString(); SavetTestResult(survey3, documentXML3); // Wynik 2_2: Data utworzenia: 10/2/2011, szerokość: 50, długość: 20 (Kraków) Survey survey4 = new Survey(); survey4.Display(Convert.ToInt32(SurveyId)); survey4.ResultInfo.Title = "test5"; survey4.ResultInfo.Latitude = "50"; survey4.ResultInfo.Longitude = "20"; XDocument documentXML4 = survey4.PrepareResultDocument(); survey4.ResultInfo.Time = operationsOnDate.DateTimeToMiliseconds(new DateTime(2011, 10, 2)).ToString(); SavetTestResult(survey4, documentXML4); // Wynik 3_1: Data utworzenia: 10/2/2011, szerokość: 51, długość: 17 (Wrocław) Survey survey5 = new Survey(); survey5.Display(Convert.ToInt32(SurveyId)); survey5.ResultInfo.Title = "test6"; survey5.ResultInfo.Latitude = "51"; survey5.ResultInfo.Longitude = "17"; XDocument documentXML5 = survey5.PrepareResultDocument(); survey5.ResultInfo.Time = operationsOnDate.DateTimeToMiliseconds(new DateTime(2011, 10, 2)).ToString(); SavetTestResult(survey5, documentXML5); }
/// <summary> /// Initializes all data members. Allows to set parent survey. /// </summary> /// <param name="parent"><see cref="Survey"/> instance that category belongs to.</param> public NormalCategory(Survey parent) { Parent = parent; Questions = new List <Question>(); }