Esempio n. 1
0
        /// <summary>
        /// Reschedule the instance of the chosen SurveyAnswer.
        /// </summary>
        public void Reschedule()
        {
            ScheduleController.reschedule(chosenSurvey);
            string rescheduled = JSonTranslator.Serialize(chosenSurvey);

            IOController.SaveFile(rescheduled, chosenSurvey.Survey.SurveyName + "_" + chosenSurvey.Survey.SurveyId.ToString().Substring(0, 4), Constants.toFillFolder);
        }
Esempio n. 2
0
        /// <summary>
        /// Saves the survey definition.
        /// </summary>
        /// <param name="s">The Survey definition to be saved. Used by ConnectionController.</param>
        public static async void SaveSurveyDefinition(Survey s)
        {
            IFolder rootFolder = FileSystem.Current.LocalStorage;
            IFolder folder     = await rootFolder.CreateFolderAsync(Constants.schemasFolder,
                                                                    CreationCollisionOption.OpenIfExists);

            string fileName = s.SurveyId.ToString().Substring(0, 5) + "_" + s.SurveyName + ".json";

            IFile file = await folder.CreateFileAsync(fileName,
                                                      CreationCollisionOption.ReplaceExisting);

            string serialized = JSonTranslator.Serialize(s);
            await file.WriteAllTextAsync(serialized);
        }
Esempio n. 3
0
        /// <summary>
        /// Writes the survey result.
        /// </summary>
        /// <param name="surveyScheme">Survey scheme.</param>
        /// <param name="currentViews">Current views.</param>
        public static async void WriteSurveyResult(Survey surveyScheme, ICollection <QuestionView> currentViews)
        {
            IFolder rootFolder = FileSystem.Current.LocalStorage;
            IFolder folder     = await rootFolder.CreateFolderAsync(Constants.filledFolder,
                                                                    CreationCollisionOption.OpenIfExists);

            string fileName = surveyScheme.SurveyId.ToString().Substring(0, 5) + "_" + surveyScheme.SurveyName + "_" + DateTime.Now.DayOfYear.ToString() + ".json";

            IFile file = await folder.CreateFileAsync(fileName,
                                                      CreationCollisionOption.ReplaceExisting);

            SurveyAnswer SurveyfilledScheme = PutAnswersToSurveyInstance(currentViews, surveyScheme);
            string       serialized         = JSonTranslator.Serialize(SurveyfilledScheme);

            await file.WriteAllTextAsync(serialized);
        }
Esempio n. 4
0
        /// <summary>
        /// Deeply clones object.
        /// </summary>
        /// <returns>The clone.</returns>
        /// <param name="obj">Object.</param>
        /// <typeparam name="T">The type of the object.</typeparam>
        public static T DeepClone <T>(T obj)
        {
            var temp = JSonTranslator.Serialize(obj);

            return(JSonTranslator.Deserialize <T> (temp));
        }